diff --git a/meson.build b/meson.build index 8fa1dd78..51b71a3d 100644 --- a/meson.build +++ b/meson.build @@ -323,7 +323,14 @@ linux_mod17_def = linux_def + {'CONFIG_SCREEN_WIDTH': '128', 'CONFIG_SCREEN_HEIG linux_c_args = ['-ffunction-sections', '-fdata-sections'] linux_cpp_args = ['-ffunction-sections', '-fdata-sections', '-std=c++14'] -linux_l_args = ['-lm', '-lreadline', '-Wl,--gc-sections'] +linux_l_args = ['-lm', '-lreadline'] + +# MacOS Clang linker uses -deadstrip instead of --gc-sections +if build_machine.system() == 'darwin' + linux_l_args += '-Wl,-dead_strip' +else + linux_l_args += '-Wl,--gc-sections' +endif # Add AddressSanitizer if required if get_option('asan') @@ -711,6 +718,8 @@ if build_machine.system() == 'linux' bin2sgl = find_program('scripts/bin2sgl.Linux', required:false, disabler:true) elif build_machine.system() == 'windows' bin2sgl = find_program('scripts/bin2sgl.exe', required:false, disabler:true) +elif build_machine.system() == 'darwin' + bin2sgl = find_program('scripts/bin2sgl.Darwin', required:false, disabler:true) endif radio_tool = find_program('radio_tool') @@ -727,21 +736,20 @@ foreach t : targets # ttwrplus is a Zephyr target, we compile it using west and package it in uf2 format if name == 'openrtx_ttwrplus' - if build_machine.system() == 'linux' + if build_machine.system() == 'windows' txt = custom_target('Copy CMakeLists.txt', input : 'CMakeLists.txt', - output : 'CMakeLists.txt', - command : ['cp', '@INPUT@', '@OUTPUT@'], + output : 'CMakeLists.txt', + command : ['xcopy', '@INPUT@', '@OUTPUT@'], install : false, build_by_default : true) - - elif build_machine.system() == 'windows' + else # Unix-like OS that has cp txt = custom_target('Copy CMakeLists.txt', input : 'CMakeLists.txt', - output : 'CMakeLists.txt', - command : ['xcopy', '@INPUT@', '@OUTPUT@'], + output : 'CMakeLists.txt', + command : ['cp', '@INPUT@', '@OUTPUT@'], install : false, build_by_default : true) endif @@ -791,7 +799,12 @@ foreach t : targets # Handle GD77 custom wrapping and flashing tools if name == 'openrtx_gd77' or name == 'openrtx_dm1801' - if build_machine.system() == 'linux' + if build_machine.system() == 'windows' + wrap = custom_target(name+'_wrap', + output : name+'_bin.sgl', + input : bin, + command : [bin2sgl, '@INPUT@', '-m', t['wrap']]) + else # Unix-like OS that has mv wrap = custom_target(name+'_wrap', output : name+'_wrap.sgl', input : bin, @@ -800,12 +813,6 @@ foreach t : targets '-m', t['wrap'], '&&', 'mv', '@INPUT@.sgl', '@OUTPUT@']) - - elif build_machine.system() == 'windows' - wrap = custom_target(name+'_wrap', - output : name+'_bin.sgl', - input : bin, - command : [bin2sgl, '@INPUT@', '-m', t['wrap']]) endif custom_target(name+'_flash', diff --git a/scripts/bin2sgl.Darwin b/scripts/bin2sgl.Darwin new file mode 100755 index 00000000..ef8ff03c Binary files /dev/null and b/scripts/bin2sgl.Darwin differ