Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move BitThunder to Meson build system #53

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "meson/meson"]
path = meson/meson
url = https://github.com/mesonbuild/meson.git
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,8 @@ clean_images: | dbuild_splash
$(Q)rm -rf $(CONFIG_HEADER_PATH)/$(CONFIG_HEADER_NAME) $(PRM_PIPE)
$(Q)rm -rf $(PROJECT_DIR)/linktree

.PHONY: meson
meson:
CC=gcc $(BASE)/meson/meson/meson.py --cross-file $(BASE)/meson/cross-files/arm.cross builddir

$(CONFIG_HEADER_PATH)/$(CONFIG_HEADER_NAME): MODULE_NAME:=$(MODULE_NAME)
5 changes: 5 additions & 0 deletions arch/arm/mach/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Include the correct machine build file.
#

subdir(SUBARCH)
4 changes: 4 additions & 0 deletions arch/arm/mach/zynq/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ config CPU_CORES
int
default 2

config ARCH_ARM_GIC_TOTAL_IRQS
int
default 95

source arch/arm/mach/zynq/boards/Kconfig

comment "Zynq Platform Options"
Expand Down
61 changes: 61 additions & 0 deletions arch/arm/mach/zynq/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# vmthunder.mach.zynq
# Build recipe for Zynq Machine.
#

#
# Empty sources list.
#
zynq_sources = []


#
# Add all mandatory sources.
#
zynq_sources += 'zynq.c'
zynq_sources += 'slcr.c'
zynq_sources += 'headsmp.S'
zynq_sources += 'early_console.c'

#
# Add all optional sources.
#
if config.has('BT_CONFIG_MACH_ZYNQ_DEVCFG')
zynq_sources += 'devcfg.c'
endif

if config.has('BT_CONFIG_MACH_ZYNQ_GEM')
zynq_sources += 'gem.c'
endif

if config.has('BT_CONFIG_MACH_ZYNQ_GPIO')
zynq_sources += 'gpio.c'
endif

if config.has('BT_CONFIG_MACH_ZYNQ_I2C')
zynq_sources += 'i2c.c'
endif

if config.has('BT_CONFIG_MACH_ZYNQ_SDIO')
zynq_sources += 'sdio.c'
endif

if config.has('BT_CONFIG_MACH_ZYNQ_TIMER')
zynq_sources += 'timer.c'
endif

if config.has('BT_CONFIG_MACH_ZYNQ_UART')
zynq_sources += 'uart.c'
endif


#
# Add any extra includes.
#
zynq_includes = []
zynq_includes += 'arch/arm/mach/zynq'

#
# Hook this into the build.
#
vm_libs += { 'name': 'vmthunder.mach.zynq', 'path': meson.current_source_dir(), 'sources': zynq_sources, 'includes': zynq_includes }
22 changes: 22 additions & 0 deletions arch/arm/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
vm_includes += 'arch/arm/include'
vm_includes += 'arch/arm/include/arch/common'


#
# Common ARM build files.
#
vm_sources += 'arch/arm/boot/head.S'
vm_sources += 'arch/arm/common/arm11cpu.c'
vm_sources += 'arch/arm/common/arm-cache.c'
vm_sources += 'arch/arm/common/crtinit.s'
vm_sources += 'arch/arm/common/cpuinit.S'
vm_sources += 'arch/arm/common/gic.c'
vm_sources += 'arch/arm/common/freertos-ca9.c'
vm_sources += 'arch/arm/common/freertos-ca9-asm.S'

if config.has('BT_CONFIG_HAS_MMU')
vm_sources += 'arch/arm/mm/v7-mmu.c'
vm_sources += 'arch/arm/mm/v7-mmu-asm.S'
endif

subdir('mach')
1 change: 1 addition & 0 deletions drivers/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vm_includes += 'drivers'
14 changes: 14 additions & 0 deletions kernel/FreeRTOS/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# FreeRTOS build module.
#

#
# Adding to the default source list.
#
vm_includes += 'kernel/FreeRTOS/Source/include'
vm_sources += 'kernel/FreeRTOS/Source/tasks.c'
vm_sources += 'kernel/FreeRTOS/Source/list.c'
vm_sources += 'kernel/FreeRTOS/Source/queue.c'
vm_sources += 'kernel/FreeRTOS/Source/event_groups.c'


3 changes: 3 additions & 0 deletions kernel/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
subdir('FreeRTOS')

vm_sources += 'kernel/bt_freertos_if.c'
4 changes: 4 additions & 0 deletions lib/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vm_includes += 'lib/include'

vm_sources += 'lib/src/collections/bt_fifo.c'
vm_sources += 'lib/src/handles/bt_handles.c'
89 changes: 89 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#
# Meson Build file for BitThunder
#
project('bitthunder', 'c',
version : '1.0',
default_options : ['warning_level=3'])


find_program('git')

#
# Import the Kconfig data.
#
config = configuration_data()
cfg = run_command('cat', '.config').stdout().strip().split('\n')
foreach item : cfg
if not item.startswith('#')
splits = item.split('=')
if splits.length() == 2
config.set(splits[0], splits[1].strip('"'))
endif
endif
endforeach

#
# Top-Level Build variables
#
ARCH=config.get('BT_CONFIG_ARCH')
SUBARCH=config.get('BT_CONFIG_SUBARCH')

#
# Subdirs can simply add to vm_sources and vm_includes.
# Or to isolate components of the build, they can create static libs in vm_libs.
#
vm_sources = []
vm_includes = []
vm_libs = []

#
# Generate config headers
#

#bsp_config = custom_target(
# 'bt_bsp_config.h',
# output : 'bt_bsp_config.h',
# input : '.config',
# command : [prog_python, '@INPUT@', '--header', '@OUTPUT@'],
#]

#
# Include the base-subdirs.
#
subdir('lib')
subdir('os')
subdir('arch/' + ARCH)
subdir('kernel')
subdir('drivers')

inc = include_directories(vm_includes)

vmthunder_core = static_library('vmthunder.core', vm_sources, include_directories: inc)

extra_libs = []

foreach lib : vm_libs
name = lib['name']
sources = lib['sources']
lib_includes = []
lib_sources = []

foreach source : sources
lib_sources += lib['path'] + '/' + source
endforeach

if 'includes' in lib
lib_includes = include_directories(lib['includes'])
endif

extra_libs += static_library(name, lib_sources, include_directories: [inc, lib_includes])
endforeach

linker_script = '@0@/build/arch/arm/bitthunder.lds'.format(meson.current_source_dir())

link_args = ['-T', linker_script, '-nostartfiles']# + meson.get_cross_property('link_args')

#
# Main vmthunder kernel executable.
#
executable('vmthunder', vm_sources, include_directories: inc, link_args: link_args, link_with: [vmthunder_core, extra_libs])
15 changes: 15 additions & 0 deletions meson/cross-files/arm.cross
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[binaries]
c = 'arm-none-eabi-gcc'
cpp = 'arm-none-eabi-g++'
ar = 'arm-none-eabi-ar'
strip = 'arm-none-eabi-strip'

[host_machine]
system = 'none'
cpu_family = 'arm'
cpu = 'cortex-a9'
endian = 'little'

[properties]
c_args = ['-march=armv7-a', '-mfloat-abi=soft', '-mfpu=neon']
link_args = ['-march=armv7-a', '-mfloat-abi=soft', '-mfpu=neon']
1 change: 1 addition & 0 deletions meson/meson
Submodule meson added at d272f2
2 changes: 2 additions & 0 deletions os/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ config DIR

config I2C
bool "I2C subsystem"
select SOFTIRQ
select TASKLETS
default n

config ADC
Expand Down
16 changes: 16 additions & 0 deletions os/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
vm_includes += 'os/include'

vm_sources += 'os/src/bt_main.c'

subdir('src/devman')
subdir('src/gpio')
subdir('src/fs')
subdir('src/helpers')
subdir('src/interfaces')
subdir('src/interrupts')
subdir('src/lib')
subdir('src/module')
subdir('src/mm')
subdir('src/process')
subdir('src/syslog')
subdir('src/timers')
6 changes: 6 additions & 0 deletions os/src/devman/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pwd = meson.current_source_dir() + '/'

vm_sources += pwd + 'bt_devman.c'
vm_sources += pwd + 'bt_device.c'
vm_sources += pwd + 'bt_resources.c'
vm_sources += pwd + 'bt_i2c.c'
4 changes: 4 additions & 0 deletions os/src/fs/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pwd = meson.current_source_dir() + '/'


vm_sources += pwd + 'bt_file.c'
3 changes: 3 additions & 0 deletions os/src/gpio/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pwd = meson.current_source_dir() + '/'

vm_sources += pwd + 'bt_gpio.c'
3 changes: 3 additions & 0 deletions os/src/helpers/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pwd = meson.current_source_dir() + '/'

vm_sources += pwd + 'bt_clkdiv.c'
4 changes: 4 additions & 0 deletions os/src/interfaces/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pwd = meson.current_source_dir() + '/'

vm_sources += pwd + 'bt_if_power.c'
vm_sources += pwd + 'bt_dev_if_uart.c'
12 changes: 12 additions & 0 deletions os/src/interrupts/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pwd = meson.current_source_dir() + '/'

vm_sources += pwd + 'bt_interrupts.c'

if config.has('BT_CONFIG_INTERRUPTS_SOFTIRQ')
vm_sources += pwd + 'bt_softirq.c'
endif

if config.has('BT_CONFIG_TASKLETS')
vm_sources += pwd + 'bt_tasklets.c'
endif

7 changes: 7 additions & 0 deletions os/src/lib/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pwd = meson.current_source_dir() + '/'


vm_sources += pwd + 'ctype.c'
vm_sources += pwd + 'string.c'
vm_sources += pwd + 'printf.c'
vm_sources += pwd + 'putc.c'
20 changes: 20 additions & 0 deletions os/src/mm/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
if config.has('BT_CONFIG_OS')
vm_sources += 'os/src/mm/bt_mm.c'
endif

if config.has('BT_CONFIG_MEM_PAGE_ALLOCATOR')
vm_sources += 'os/src/mm/bt_page.c'
endif

if config.has('BT_CONFIG_MEM_KHEAP')
vm_sources += 'os/src/mm/bt_heap.c'
endif

if config.has('BT_CONFIG_USE_VIRTUAL_ADDRESSING')
vm_sources += 'os/src/mm/bt_vm.c'
vm_sources += 'os/src/mm/bt_map.c'
endif

if config.has('BT_CONFIG_MEM_SLAB_ALLOCATOR')
vm_sources += 'os/src/mm/slab.c'
endif
3 changes: 3 additions & 0 deletions os/src/module/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pwd = meson.current_source_dir() + '/'

vm_sources += pwd + 'bt_module_init.c'
7 changes: 7 additions & 0 deletions os/src/process/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pwd = meson.current_source_dir() + '/'


vm_sources += pwd + 'bt_threads.c'
vm_sources += pwd + 'bt_process.c'
vm_sources += pwd + 'bt_queue.c'

3 changes: 3 additions & 0 deletions os/src/syslog/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pwd = meson.current_source_dir() + '/'

vm_sources += pwd + 'bt_printk.c'
3 changes: 3 additions & 0 deletions os/src/timers/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pwd = meson.current_source_dir() + '/'

vm_sources += pwd + 'bt_timers.c'