Skip to content

Commit

Permalink
basic meson setup
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossless committed Apr 22, 2024
1 parent 99993a9 commit 181b71a
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ jobs:
with:
name: smk
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Build release
run: nix develop --command make all
- name: Configure
run: nix develop --command meson setup build
- name: Build
run: nix develop --command meson compile -C build
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: firmware
path: bin/*.hex
path: build/*.hex

lint:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@

bin/
obj/

build/
123 changes: 123 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
project(
'smk',
'c',
version: 'alpha'
)

cc_args = [
# '--Werror', # TODO: reeneable
'--std-c2x',

'-mmcs51',
'--model-small',
'--xram-size', '0x1000',
'--xram-loc', '0x0000',
'--code-size', '0xf000',
'--opt-code-speed',
'--out-fmt-ihx',

'-DDEBUG=1',
'-DFREQ_SYS=24000000',
'-DWATCHDOG_ENABLE=1',
'-DUSB_VID=0x05ac',
'-DUSB_PID=0x024f',
'-DSMK_VERSION=@0@'.format(meson.project_version()),
]

sdar_args = ['-rc']

inc_dirs = [
'.',
'src',
'src/smk',
'src/plaform',
'src/plaform/sh68f90a', # TODO: move to a conditional
'src/user',
'src/keyboards',

# TODO: should be based on keyboard + layout selection
'src/keyboards/nuphy-air60',
]

src_main = [
'src/main.c',
'src/smk/host.c',
'src/smk/matrix.c',
'src/smk/report.c',

# TODO: should be based on keyboard + layput seleciton
'src/keyboards/nuphy-air60/smatrix.c', # TODO: rename properly
'src/keyboards/nuphy-air60/layouts/default/indicators.c',
'src/keyboards/nuphy-air60/layouts/default/layout.c',
]

src_platform = [ # TODO: should be based on platform selection
'src/platform/sh68f90a/clock.c',
'src/platform/sh68f90a/delay.c',
'src/platform/sh68f90a/gpio.c',
'src/platform/sh68f90a/isp.c',
'src/platform/sh68f90a/ldo.c',
'src/platform/sh68f90a/pwm.c',
'src/platform/sh68f90a/uart.c',
'src/platform/sh68f90a/usb.c',
'src/platform/sh68f90a/keyboard.c',
]

src_user = [
'src/user/indicators.c',
'src/user/layout.c',
]

cc = find_program('sdcc', required : true)
sdar = find_program('sdar', required : true)
packihx = find_program('packihx', required : true)
skbt = find_program('sinowealth-kb-tool', required : true)

dir_base = meson.current_source_dir()
cc_incs = []

foreach dir : inc_dirs
cc_incs += '-I' + join_paths(dir_base, dir)
endforeach

compiler = generator(cc,
output : '@[email protected]',
arguments : cc_args + cc_incs + ['-c', '@INPUT@', '-o', '@OUTPUT@']
)

rel_platform = compiler.process(src_platform)
rel_user = compiler.process(src_user)
rel_main = compiler.process(src_main)

lib_platform = custom_target('platform.lib',
input : rel_platform,
output : 'platform.lib',
command : [sdar, sdar_args, '@OUTPUT@', '@INPUT@'],
)

lib_user = custom_target('user.lib',
input : rel_user,
output : 'user.lib',
command : [sdar, sdar_args, '@OUTPUT@', '@INPUT@'],
)

ihx_smk = custom_target('smk.ihx', # should be keyboard/layout specific
input : rel_main,
output : 'smk.ihx',
depends: [lib_platform, lib_user],
command : [cc, cc_args, '-o', '@OUTPUT@', '@INPUT@', '-l' + lib_platform.full_path(), '-l' + lib_user.full_path()],
)

hex_smk = custom_target('smk.hex', # should be keyboard/layout specific
input : ihx_smk,
output : 'smk.hex',
capture: true,
install : true,
install_dir : 'firmware',
command : [packihx, '@INPUT@'],
)

flash = run_target('flash',
command : [skbt, 'write', '-p', 'nuphy-air60', hex_smk.full_path()],
depends : hex_smk,
)
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void matrix_pre_scan(uint8_t col)

uint8_t matrix_scan_col(uint8_t col)
{
col;
// grab key for the column state
// P7_1 - R0
// P7_2 - R1
Expand Down
2 changes: 2 additions & 0 deletions src/user/indicators.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <stdint.h>
#include <stdbool.h>

void indicators_pre_update();
bool indicators_update_step(keyboard_state_t *keyboard, uint8_t current_step);
void indicators_post_update();

#endif

0 comments on commit 181b71a

Please sign in to comment.