Skip to content

Commit

Permalink
Revert "chore(meson): compile libraries and link to executables"
Browse files Browse the repository at this point in the history
This reverts commit e5f857f.

Compiling the HAL as a static library causes issues where __weak
functions are not overridden. The reason is that when the library is
linked the first function definition found is used, which is provided
by the HAL, and the overridden function in the user application is
ignored.
  • Loading branch information
hashemmm96 committed Oct 9, 2023
1 parent fe04822 commit b346dbd
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 68 deletions.
3 changes: 1 addition & 2 deletions apps/battery-monitor/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ battery_monitor_src = files(

battery_monitor_elf = executable(
'battery-monitor.elf',
battery_monitor_src,
[common_libs_src, battery_monitor_src],
include_directories: [common_libs_inc, battery_monitor_inc],
link_with: common_libs,
link_depends: app_linker_script,
link_args: ['-T@0@'.format(app_linker_script.full_path())],
)
Expand Down
3 changes: 1 addition & 2 deletions apps/joystick/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ joystick_src = files(

joystick_elf = executable(
'joystick.elf',
joystick_src,
[common_libs_src, joystick_src],
include_directories: [common_libs_inc, joystick_inc],
link_with: common_libs,
link_depends: app_linker_script,
link_args: ['-T@0@'.format(app_linker_script.full_path())],
)
Expand Down
3 changes: 1 addition & 2 deletions apps/sbus-receiver/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ sbus_receiver_src = files(

sbus_receiver_elf = executable(
'sbus-receiver.elf',
sbus_receiver_src,
[common_libs_src, sbus_receiver_src],
include_directories: [common_libs_inc, sbus_receiver_inc],
link_with: common_libs,
link_depends: app_linker_script,
link_args: ['-T@0@'.format(app_linker_script.full_path())],
)
Expand Down
6 changes: 2 additions & 4 deletions apps/servo/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ servo_src = files(

servo_elf = executable(
'servo.elf',
servo_src,
[common_libs_src, servo_src],
include_directories: [common_libs_inc, servo_inc],
link_with: common_libs,
link_depends: app_linker_script,
link_args: ['-T@0@'.format(app_linker_script.full_path())],
)
Expand All @@ -30,9 +29,8 @@ servo_bin = custom_target(

motor_elf = executable(
'motor.elf',
servo_src,
[common_libs_src, servo_src],
include_directories: [common_libs_inc, servo_inc],
link_with: common_libs,
link_depends: app_linker_script,
link_args: ['-T@0@'.format(app_linker_script.full_path())],
c_args: ['-DMOTOR'],
Expand Down
3 changes: 1 addition & 2 deletions bootloader/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ bootloader_linker_script = fs.copyfile(files('src' / 'bootloader.ld'))

bootloader_elf = executable(
'bootloader.elf',
bootloader_src,
[bootloader_src, common_libs_src],
include_directories: [bootloader_inc, common_libs_inc],
link_with: common_libs,
link_depends: bootloader_linker_script,
link_args: ['-T@0@'.format(bootloader_linker_script.full_path())],
)
Expand Down
10 changes: 9 additions & 1 deletion libs/can-kingdom/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ can_kingdom_inc = include_directories('include')

can_kingdom_postmaster_src = files('src' / 'postmaster-dummy.c')

can_kingdom_postmaster_native_lib = library(
'can-kingdom-postmaster-native',
can_kingdom_postmaster_src,
include_directories: can_kingdom_inc,
native: true,
)

can_kingdom_src = files(
'src' / 'king.c',
'src' / 'mayor.c',
Expand All @@ -11,8 +18,9 @@ can_kingdom_src = files(
# Build native lib for unit testing
can_kingdom_native_lib = library(
'can-kingdom-native',
[can_kingdom_src, can_kingdom_postmaster_src],
can_kingdom_src,
include_directories: can_kingdom_inc,
link_with: can_kingdom_postmaster_native_lib,
native: true,
)

Expand Down
52 changes: 9 additions & 43 deletions libs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,18 @@ subdir('rover')
subdir('stm32-common')
subdir('stm32-postmaster')

# All libs that depend on other libs are built here. Libs that don't have
# dependencies are built in their respective subdir.

drivers_lib = library(
'drivers',
drivers_src,
include_directories: [drivers_inc, stm32_common_inc],
)

freertos_lib = library(
'freertos',
freertos_src,
include_directories: [freertos_inc, stm32_common_inc],
)

stm32_common_lib = library(
'stm32-common',
# Convenience source file list
common_libs_src = [
can_kingdom_src,
rover_src,
stm32_common_src,
include_directories: [stm32_common_inc, drivers_inc, freertos_inc],
link_with: drivers_lib,
)

stm32_postmaster_lib = library(
'stm32-postmaster',
stm32_postmaster_src,
include_directories: [stm32_postmaster_inc, stm32_common_inc, drivers_inc, can_kingdom_inc],
link_with: drivers_lib,
)

can_kingdom_lib = library(
'can-kingdom',
can_kingdom_src,
include_directories: [can_kingdom_inc, stm32_postmaster_inc],
link_with: stm32_postmaster_lib,
)
# third-party
drivers_src,
freertos_src,
printf_src,
]

# Convenience include dir list
common_libs_inc = [
Expand All @@ -53,17 +30,6 @@ common_libs_inc = [
printf_inc,
]

# Convenience lib list
common_libs = [
can_kingdom_lib,
drivers_lib,
freertos_lib,
printf_lib,
rover_lib,
stm32_common_lib,
stm32_postmaster_lib,
]

common_libs_tidy_files = [
can_kingdom_tidy_files,
rover_tidy_files,
Expand Down
6 changes: 0 additions & 6 deletions libs/rover/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@ rover_inc = include_directories('include')

rover_src = files('src' / 'rover.c')

rover_lib = library(
'rover',
rover_src,
include_directories: rover_inc,
)

rover_tidy_files = [rover_src]
6 changes: 1 addition & 5 deletions libs/third-party/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,4 @@ freertos_src = files(

printf_inc = include_directories('printf')

printf_lib = library(
'printf',
files('printf' / 'printf.c'),
include_directories: printf_inc,
)
printf_src = files('printf' / 'printf.c')
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project(
'Rover',
'c',
meson_version: '>=1.2.0',
version: '0.2.0',
version: '0.1',
default_options: [
'buildtype=debugoptimized',
'default_library=static',
Expand Down

0 comments on commit b346dbd

Please sign in to comment.