diff --git a/meson.build b/meson.build index b430150..8dd391b 100644 --- a/meson.build +++ b/meson.build @@ -29,18 +29,21 @@ message('Processing xPack @micro-os-plus/micro-test-plus...') # ----------------------------------------------------------------------------- -xpack_common_args = [] -xpack_c_args = [] -xpack_cpp_args = [] -xpack_include_directories = [] -xpack_sources = [] -xpack_compile_definitions = [] +_local_compile_args = [] # Common C/C++ args. +_local_compile_c_args = [] +_local_compile_cpp_args = [] +_local_include_directories = [] +_local_sources = [] +_local_compile_definitions = [] +_local_dependencies = [] +_local_link_args = [] +_local_link_with = [] -xpack_include_directories += [ +_local_include_directories += [ 'include', ] -xpack_sources += [ +_local_sources += [ 'src/micro-test-plus.cpp', 'src/test-runner.cpp', 'src/test-reporter.cpp', @@ -49,19 +52,21 @@ xpack_sources += [ # https://mesonbuild.com/Reference-manual_functions.html#declare_dependency micro_os_plus_micro_test_plus_dependency = declare_dependency( - include_directories: include_directories(xpack_include_directories), - compile_args: xpack_common_args, - sources: files(xpack_sources), - dependencies: [] + include_directories: include_directories(_local_include_directories), + compile_args: _local_compile_args, + sources: files(_local_sources), + dependencies: _local_dependencies, + link_args: _local_link_args, + link_with: _local_link_with, ) +# meson dependencies cannot differentiate c/cpp args; pass them separately. +micro_os_plus_micro_test_plus_dependency_compile_c_args = _local_compile_c_args +micro_os_plus_micro_test_plus_dependency_compile_cpp_args = _local_compile_cpp_args -# micro_os_plus_micro_test_plus_dependency_c_args = xpack_c_args -# micro_os_plus_micro_test_plus_dependency_cpp_args = xpack_cpp_args - -foreach name : xpack_include_directories +foreach name : _local_include_directories message('+ -I ' + name) endforeach -foreach name : xpack_sources + xpack_common_args +foreach name : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args message('+ ' + name) endforeach message('> micro_os_plus_micro_test_plus_dependency') diff --git a/tests/meson.build b/tests/meson.build index 5b2d1ec..8141b07 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -32,6 +32,12 @@ project('micro-os-plus-micro-test-plus-tests', # c++2a, c++1z, gnu++03, gnu++11, gnu++14, gnu++17, gnu++1z, # gnu++2a, gnu++20, vc++14, vc++17, vc++latest +# ----------------------------------------------------------------------------- +# Global definitions # + +enable_sample_test = true +enable_unit_test = true + # ----------------------------------------------------------------------------- fs = import('fs') @@ -71,22 +77,20 @@ message('Build type: ' + get_option('buildtype')) message('Platform name: ' + xpack_platform_name) # ----------------------------------------------------------------------------- -## Global definitions ## - -enable_sample_test = true -enable_unit_test = true # https://mesonbuild.com/Reference-manual.html#subdir -subdir('meson/common') +subdir('meson/common-options') subdir('xpacks/@micro-os-plus/build-helper/meson/enable-all-warnings') -subdir('platform-'+ xpack_platform_name + '/meson/common') + +# Since the order of processing is significative, include it in dependencies. +# subdir('platform-'+ xpack_platform_name + '/meson/platform-options') # ----------------------------------------------------------------------------- -## Dependencies ## +# Dependencies # -subdir('platform-'+ xpack_platform_name + '/meson/dependencies') +# Set `xpack_dependencies_folders` with the platform specific dependencies. +subdir('platform-'+ xpack_platform_name + '/meson/dependencies-folders') -# xpack_dependencies_folders[] must be set in the platform. foreach dep: xpack_dependencies_folders message('Adding ' + dep + '...') subdir(dep) @@ -95,9 +99,13 @@ endforeach # ----------------------------------------------------------------------------- # Include the project library, defined one level above. +message('Adding top library...') subdir('top') -# Include the platform specific code. +# ----------------------------------------------------------------------------- +# Platform specifics # + +# Include the platform specific targets and tests. subdir('platform-' + xpack_platform_name) # ----------------------------------------------------------------------------- diff --git a/tests/meson/common/meson.build b/tests/meson/common-options/meson.build similarity index 51% rename from tests/meson/common/meson.build rename to tests/meson/common-options/meson.build index 650ee83..e9ed391 100644 --- a/tests/meson/common/meson.build +++ b/tests/meson/common-options/meson.build @@ -15,9 +15,15 @@ message('Including top common definitions...') -xpack_global_common_args = [] -xpack_global_include_directories = [] -xpack_global_compile_definitions = [] +_local_compile_args = [] # Common C/C++ args. +_local_compile_c_args = [] +_local_compile_cpp_args = [] +_local_include_directories = [] +_local_sources = [] +_local_compile_definitions = [] +_local_dependencies = [] +_local_link_args = [] +_local_link_with = [] # Assume GCC or clang, for MSVC things are different # https://mesonbuild.com/Reference-tables.html#c_compiler-ids @@ -26,34 +32,34 @@ if c_compiler.get_id() == 'gcc' or c_compiler.get_id().contains('clang') # Global compiler preprocessor definitions. # Native builds may not use them. if get_option('buildtype').contains('debug') - xpack_global_compile_definitions += [ '-DDEBUG' ] - xpack_global_compile_definitions += [ '-DMICRO_OS_PLUS_DEBUG' ] - xpack_global_compile_definitions += [ '-DMICRO_OS_PLUS_TRACE' ] + _local_compile_definitions += [ '-DDEBUG' ] + _local_compile_definitions += [ '-DMICRO_OS_PLUS_DEBUG' ] + _local_compile_definitions += [ '-DMICRO_OS_PLUS_TRACE' ] endif if get_option('buildtype') == 'release' - xpack_global_compile_definitions += [ '-DNDEBUG' ] + _local_compile_definitions += [ '-DNDEBUG' ] endif - xpack_global_compile_definitions += [ '-DMICRO_OS_PLUS_INCLUDE_CONFIG_H' ] + _local_compile_definitions += [ '-DMICRO_OS_PLUS_INCLUDE_CONFIG_H' ] # DO NOT define it globally, one test does not need it! - # xpack_global_compile_definitions += ['-DMICRO_OS_PLUS_TRACE'] + # _local_compile_definitions += ['-DMICRO_OS_PLUS_TRACE'] # Options for both compilers and linkers. When using `-flto`, all options # must also be passed to the linker. if get_option('buildtype') == 'debug' - # xpack_global_common_args += [ '-O0' ] + # _local_compile_args += [ '-O0' ] elif get_option('buildtype') == 'debugoptimized' - xpack_global_common_args += [ '-Og' ] # Override -O2 + _local_compile_args += [ '-Og' ] # Override -O2 elif get_option('buildtype') == 'minsize' - # xpack_global_common_args += [ '-Os' ] + # _local_compile_args += [ '-Os' ] elif get_option('buildtype') == 'release' - # xpack_global_common_args += [ '-O3' ] + # _local_compile_args += [ '-O3' ] else - xpack_global_common_args += [ '-O' ] + _local_compile_args += [ '-O' ] endif - xpack_global_common_args += [ + _local_compile_args += [ '-fmessage-length=0', '-fsigned-char', @@ -62,23 +68,25 @@ if c_compiler.get_id() == 'gcc' or c_compiler.get_id().contains('clang') '-fdata-sections' ] - add_global_arguments( - xpack_global_include_directories + xpack_global_common_args + xpack_global_compile_definitions, - - language: [ 'c', 'cpp' ] + common_options_dependency = declare_dependency( + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + compile_args: _local_compile_args + _local_compile_definitions, + # When `-flto` is used, the compile options must be passed to the linker too. + dependencies: _local_dependencies, + link_args: _local_compile_args + _local_link_args, + link_with: _local_link_with, ) + common_options_dependency_compile_c_args = _local_compile_c_args + common_options_dependency_compile_cpp_args = _local_compile_cpp_args - foreach xn : xpack_global_include_directories + xpack_global_common_args + xpack_global_compile_definitions + foreach xn : _local_include_directories + message('G+ -I ' + xn) + endforeach + foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args message('G+ ' + xn) endforeach - # When `-flto` is used, the compile options must be passed to the linker too. - add_global_link_arguments( - xpack_global_common_args, - - language: [ 'c', 'cpp' ] - ) - # Warnings must be included from the tests. else diff --git a/tests/package-lock.json b/tests/package-lock.json index 62e8bb1..e9c3a30 100644 --- a/tests/package-lock.json +++ b/tests/package-lock.json @@ -429,6 +429,15 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -495,15 +504,6 @@ "node": ">=6" } }, - "node_modules/has": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.4.tgz", - "integrity": "sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ==", - "dev": true, - "engines": { - "node": ">= 0.4.0" - } - }, "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -513,6 +513,18 @@ "node": ">=4" } }, + "node_modules/hasown": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", + "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/hosted-git-info": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", @@ -569,12 +581,12 @@ "dev": true }, "node_modules/is-core-module": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", - "integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==", + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", + "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", "dev": true, "dependencies": { - "has": "^1.0.3" + "hasown": "^2.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" diff --git a/tests/platform-native/meson.build b/tests/platform-native/meson.build index e4346c8..a04059c 100644 --- a/tests/platform-native/meson.build +++ b/tests/platform-native/meson.build @@ -17,110 +17,38 @@ message('Processing tests/platform-native...') # ----------------------------------------------------------------------------- -# Define the platform library. - -xpack_common_args = [] -xpack_include_directories = [] -xpack_sources = [] -xpack_compile_definitions = [] - -xpack_include_directories += [ - 'include', -] - -# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency -platform_native_dependency = declare_dependency( - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - compile_args: xpack_common_args + xpack_compile_definitions, - dependencies: [ - micro_os_plus_architecture_synthetic_posix_dependency - ] -) - -foreach xn : xpack_include_directories - message('+ -I ' + xn) -endforeach -# Note: depenedencies compile_args not shown. -foreach xn : xpack_sources + xpack_common_args + xpack_compile_definitions - message('+ ' + xn) -endforeach -message('> platform_native_dependency') - -# ============================================================================= - -# https://mesonbuild.com/Unit-tests.html#malloc_perturb_ -nomalloc = environment({'MALLOC_PERTURB_': '0'}) - -# ----------------------------------------------------------------------------- - -xpack_common_link_args = [] -xpack_common_link_args += [ - # '-v', -] - -if c_compiler.get_id() == 'gcc' - xpack_common_link_args += [ - '-static-libgcc', - '-static-libstdc++', - ] -endif +# Define the tests executables. -# https://mesonbuild.com/Reference-tables.html#operating-system-names -if build_machine.system() == 'darwin' - # macOS always uses the Apple linker, regarless of the c_compiler. - xpack_common_link_args += [ - '-Wl,-dead_strip' - ] -elif build_machine.system() == 'linux' - xpack_common_link_args += [ - '-Wl,--gc-sections', - ] - if c_compiler.get_id().contains('clang') - xpack_common_link_args += [ - # '-Wl,-fuse-ld=ld.gold' - ] - endif -else # Windows - if c_compiler.get_id() == 'gcc' - # TODO: clang with gold might need it too. - xpack_common_link_args += [ - '-Wl,--gc-sections' - ] - elif c_compiler.get_id() == 'msvc' - xpack_common_link_args += [ - # TODO: Add MSVC options here. - ] - endif -endif +test_names = [ 'sample-test', 'unit-test' ] -# ----------------------------------------------------------------------------- +foreach name : test_names -if enable_sample_test + _local_compile_args = [] # Common C/C++ args. + _local_compile_c_args = [] + _local_compile_cpp_args = [] + _local_include_directories = [] + _local_sources = [] + _local_compile_definitions = [] + _local_dependencies = [] + _local_link_args = [] + _local_link_with = [] - xpack_common_args = [] - xpack_c_args = [] - xpack_cpp_args = [] - xpack_include_directories = [] - xpack_sources = [] - xpack_compile_definitions = [] - xpack_dependencies = [] - xpack_link_args = [] - xpack_link_with = [] - - xpack_include_directories += [ + _local_include_directories += [ '../include', ] - xpack_sources += [ - '../src/sample-test.cpp', + _local_sources += [ + '../src/' + name + '.cpp', ] - # xpack_c_args += micro_os_plus_micro_test_plus_dependency_c_args - # xpack_cpp_args += micro_os_plus_micro_test_plus_dependency_cpp_args + _local_compile_c_args += platform_native_dependency_compile_c_args + _local_compile_cpp_args += platform_native_dependency_compile_cpp_args - xpack_dependencies += [ + _local_compile_c_args += micro_os_plus_micro_test_plus_dependency_compile_c_args + _local_compile_cpp_args += micro_os_plus_micro_test_plus_dependency_compile_cpp_args + + _local_dependencies += [ # Tested library. micro_os_plus_micro_test_plus_dependency, @@ -131,35 +59,42 @@ if enable_sample_test platform_native_dependency, ] - xpack_link_args += xpack_common_link_args - - xpack_link_with += [ - # Tested library. - # None. - ] - # https://mesonbuild.com/Reference-manual.html#executable - sample_test = executable( - 'sample-test', - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - c_args: xpack_common_args + xpack_c_args + xpack_compile_definitions, - cpp_args: xpack_common_args + xpack_cpp_args + xpack_compile_definitions, - dependencies: xpack_dependencies, - link_args: xpack_link_args, - link_with: xpack_link_with, + exe = executable( + name, + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + c_args: _local_compile_definitions + _local_compile_args + _local_compile_c_args, + cpp_args: _local_compile_definitions + _local_compile_args + _local_compile_cpp_args, + dependencies: _local_dependencies, + link_args: _local_link_args, + link_with: _local_link_with, ) - foreach xn : xpack_include_directories + foreach xn : _local_include_directories message('A+ -I ' + xn) endforeach # Note: depenedencies compile_args not shown. - foreach xn : xpack_sources + xpack_common_args + xpack_c_args + xpack_cpp_args + xpack_compile_definitions + xpack_link_args + foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args message('A+ ' + xn) endforeach - message('A> sample-test') + message('A> ' + name) + + # Leave the result in a variable with the test name. + set_variable(name.underscorify(), exe) + + # Native tests do not need size, list, hex targets. + +endforeach + +# ----------------------------------------------------------------------------- + +# https://mesonbuild.com/Unit-tests.html#malloc_perturb_ +xpack_environment = environment({'MALLOC_PERTURB_': '0'}) + +# ----------------------------------------------------------------------------- - # --------------------------------------------------------------------------- +if enable_sample_test # https://mesonbuild.com/Reference-manual_functions.html#test test( @@ -169,7 +104,7 @@ if enable_sample_test 'one', 'two' ], - env: nomalloc + env: xpack_environment ) endif @@ -178,72 +113,12 @@ endif if enable_unit_test - xpack_common_args = [] - xpack_c_args = [] - xpack_cpp_args = [] - xpack_include_directories = [] - xpack_sources = [] - xpack_compile_definitions = [] - xpack_dependencies = [] - xpack_link_args = [] - xpack_link_with = [] - - xpack_include_directories += [ - '../include', - ] - - xpack_sources += [ - '../src/unit-test.cpp', - ] - - # xpack_c_args += micro_os_plus_micro_test_plus_dependency_c_args - # xpack_cpp_args += micro_os_plus_micro_test_plus_dependency_cpp_args - - xpack_dependencies += [ - # Tested library. - micro_os_plus_micro_test_plus_dependency, - - # Portable dependencies. - micro_os_plus_diag_trace_dependency, - - # Platform specific dependencies. - platform_native_dependency, - ] - - xpack_link_args += xpack_common_link_args - - xpack_link_with += [ - # Tested library. - # None. - ] - - # https://mesonbuild.com/Reference-manual.html#executable - unit_test = executable( - 'unit-test', - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - c_args: xpack_common_args + xpack_c_args + xpack_compile_definitions, - cpp_args: xpack_common_args + xpack_cpp_args + xpack_compile_definitions, - dependencies: xpack_dependencies, - link_args: xpack_link_args, - link_with: xpack_link_with, - ) - - foreach xn : xpack_include_directories - message('A+ -I ' + xn) - endforeach - # Note: depenedencies compile_args not shown. - foreach xn : xpack_sources + xpack_common_args + xpack_c_args + xpack_cpp_args + xpack_compile_definitions + xpack_link_args - message('A+ ' + xn) - endforeach - message('A> sample-test') - # https://mesonbuild.com/Reference-manual_functions.html#test test( 'unit-test', unit_test, args: [], - env: nomalloc + env: xpack_environment ) endif diff --git a/tests/platform-native/meson/common/meson.build b/tests/platform-native/meson/common/meson.build deleted file mode 100644 index 5c593e9..0000000 --- a/tests/platform-native/meson/common/meson.build +++ /dev/null @@ -1,118 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# This file is part of the µOS++ distribution. -# (https://github.com/micro-os-plus/) -# Copyright (c) 2022 Liviu Ionescu -# -# Permission to use, copy, modify, and/or distribute this software -# for any purpose is hereby granted, under the terms of the MIT license. -# -# If a copy of the license was not distributed with this file, it can -# be obtained from https://opensource.org/licenses/MIT/. -# -# ----------------------------------------------------------------------------- - -# Definitions required for compiling all files, thus the use of -# add_global_*() functions. -# Must be added with subdir() before creating any library or executable. - -message('Including platform-native common definitions...') - -# ----------------------------------------------------------------------------- - -xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_NATIVE' - -# ----------------------------------------------------------------------------- - -xpack_platform_common_args = [] -xpack_platform_common_c_args = [] -xpack_platform_common_cpp_args = [] -xpack_platform_compile_definitions = [] - -xpack_platform_compile_definitions += [ - '-D' + xpack_platform_compile_definition, -] - -if c_compiler.get_id().contains('clang') and build_machine.system() == 'darwin' - # On macOS enabling the macro fails with: - # error: unknown type name 'u_int' -else - xpack_platform_compile_definitions += [ - # Full POSIX conformance: - # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 - '-D_POSIX_C_SOURCE=200809L', - ] -endif - -if c_compiler.get_id().contains('clang') and build_machine.system() == 'windows' - xpack_platform_common_args += [ - '-Wno-used-but-marked-unused', - ] -endif - -if get_option('buildtype') == 'release' or get_option('buildtype') == 'minsize' or get_option('buildtype') == 'debugoptimized' - # https://mesonbuild.com/Reference-tables.html#operating-system-names - # message(build_machine.cpu()) - # Match armv[78]l. - if c_compiler.get_id().contains('clang') and build_machine.system() == 'linux' and build_machine.cpu().contains('armv') - # clang-12: error: unable to execute command: Segmentation fault - # clang-12: error: linker command failed due to signal (use -v to see invocation) - else - # meson-out/sample-test.p/.._src_sample-test.cpp.o: file not recognized: file format not recognized - xpack_platform_common_args += [ - '-flto', - ] - endif -endif - -xpack_platform_common_args += [ - '-Werror', -] - -if build_machine.system() == 'darwin' - xpack_platform_common_args += [ - '-Wno-missing-include-dirs', - ] -endif - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_compile_definitions, - - language: [ 'c' ] -) - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions, - - language: [ 'cpp' ] -) - -foreach xn : xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions - message('G+ ' + xn) -endforeach - -# When `-flto` is used, the compile options must be passed to the linker too. -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_c_args, - - language: [ 'c' ] -) - -# When `-flto` is used, the compile options must be passed to the linker too. -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args, - - language: [ 'cpp' ] -) - -# ----------------------------------------------------------------------------- - -# The base folder is tests. The order is significative. -xpack_dependencies = [ - - 'xpacks/@micro-os-plus/diag-trace', # - - - xpack_build_folder_relative_path + '/xpacks/@micro-os-plus/architecture-synthetic-posix', # (architecture) - -] - -# ----------------------------------------------------------------------------- diff --git a/tests/platform-native/meson/dependencies/meson.build b/tests/platform-native/meson/dependencies-folders/meson.build similarity index 69% rename from tests/platform-native/meson/dependencies/meson.build rename to tests/platform-native/meson/dependencies-folders/meson.build index 2728482..0d0779b 100644 --- a/tests/platform-native/meson/dependencies/meson.build +++ b/tests/platform-native/meson/dependencies-folders/meson.build @@ -12,7 +12,13 @@ # # ----------------------------------------------------------------------------- -# Add the platform dependencies. +# Define a list of folders where the platform dependencies are located. + +# ----------------------------------------------------------------------------- + +xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_NATIVE' + +# ----------------------------------------------------------------------------- # The base folder is tests. The order is significative. xpack_dependencies_folders = [ @@ -21,6 +27,9 @@ xpack_dependencies_folders = [ # (architecture) - xpack_build_folder_relative_path + '/xpacks/@micro-os-plus/architecture-synthetic-posix', + + # (platform) architecture-synthetic-posix + 'platform-native/meson/platform-options', ] # ----------------------------------------------------------------------------- diff --git a/tests/platform-native/meson/platform-options/meson.build b/tests/platform-native/meson/platform-options/meson.build new file mode 100644 index 0000000..1277741 --- /dev/null +++ b/tests/platform-native/meson/platform-options/meson.build @@ -0,0 +1,199 @@ +# ----------------------------------------------------------------------------- +# +# This file is part of the µOS++ distribution. +# (https://github.com/micro-os-plus/) +# Copyright (c) 2022 Liviu Ionescu +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose is hereby granted, under the terms of the MIT license. +# +# If a copy of the license was not distributed with this file, it can +# be obtained from https://opensource.org/licenses/MIT/. +# +# ----------------------------------------------------------------------------- + +message('Including platform-native common definitions...') + +# ----------------------------------------------------------------------------- + +if build_machine.system() == 'linux' or build_machine.system() == 'darwin' + + _local_cxx_library_path = run_command( + xpack_tests_folder_path + '/xpacks/@micro-os-plus/build-helper/dev-scripts/get-libraries-paths.sh', + cpp_compiler.cmd_array()[0], + check: false, + capture: true + ).stdout().strip().split(':') + + message('RPATH_LIST:') + _local_rpath_options_list = [] + foreach _local_rpath : _local_cxx_library_path + _local_rpath_options_list += '-Wl,-rpath,' + _local_rpath + message('-Wl,-rpath,' + _local_rpath) + endforeach + +endif + +# ----------------------------------------------------------------------------- + +# Define the platform library. + +_local_compile_args = [] # Common C/C++ args. +_local_compile_c_args = [] +_local_compile_cpp_args = [] +_local_include_directories = [] +_local_sources = [] +_local_compile_definitions = [] +_local_dependencies = [] +_local_link_args = [] +_local_link_with = [] + +_local_include_directories += [ + # Go back to the platform include. + '../../include', +] + +_local_sources += [ + # None. +] + +_local_compile_definitions += [ + '-D' + xpack_platform_compile_definition, + + # Full POSIX conformance: + # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 + '-D_POSIX_C_SOURCE=200809L', +] + +# if c_compiler.get_id().contains('clang') and build_machine.system() == 'darwin' +# # On macOS enabling the macro fails with: +# # error: unknown type name 'u_int' +# else +# _local_compile_definitions += [ +# ] +# endif + +_local_compile_args += [ + '-Werror', +] + +if build_machine.system() == 'darwin' + _local_compile_args += [ + '-Wno-missing-include-dirs', + ] +endif + +if c_compiler.get_id().contains('clang') and build_machine.system() == 'windows' + _local_compile_args += [ + '-Wno-used-but-marked-unused', + ] +endif + +if get_option('buildtype') == 'release' or get_option('buildtype') == 'minsize' or get_option('buildtype') == 'debugoptimized' + # https://mesonbuild.com/Reference-tables.html#operating-system-names + # message(build_machine.cpu()) + # Match armv[78]l. + if c_compiler.get_id().contains('clang') and build_machine.system() == 'linux' and build_machine.cpu().contains('armv') + # clang-12: error: unable to execute command: Segmentation fault + # clang-12: error: linker command failed due to signal (use -v to see invocation) + else + # meson-out/sample-test.p/.._src_sample-test.cpp.o: file not recognized: file format not recognized + _local_compile_args += [ + '-flto', + ] + endif +endif + +if c_compiler.get_id().contains('clang') + _local_compile_cpp_args += [ + '-stdlib=libc++' + ] +endif + +_local_compile_c_args += common_options_dependency_compile_c_args +_local_compile_cpp_args += common_options_dependency_compile_cpp_args + +_local_link_args += [ + # '-v', +] + +if c_compiler.get_id().contains('clang') + _local_link_args += [ + '-stdlib=libc++', + '-rtlib=compiler-rt' + ] + if build_machine.system() == 'linux' + _local_link_args += [ + '-lunwind', + '-fuse-ld=lld' + ] + endif +endif + +# if c_compiler.get_id() == 'gcc' +# _local_link_args += [ +# '-static-libgcc', +# '-static-libstdc++', +# ] +# endif + +# https://mesonbuild.com/Reference-tables.html#operating-system-names +if build_machine.system() == 'darwin' + _local_link_args += _local_rpath_options_list + # macOS always uses the Apple linker, regarless of the c_compiler. + _local_link_args += [ + '-Wl,-dead_strip' + ] +elif build_machine.system() == 'linux' + _local_link_args += _local_rpath_options_list + _local_link_args += [ + '-Wl,--gc-sections', + ] + if c_compiler.get_id().contains('clang') + _local_link_args += [ + # '-Wl,-fuse-ld=ld.gold' + ] + endif +else # Windows + _local_link_args += [ + '-static', + ] + if c_compiler.get_id() == 'gcc' + # TODO: clang with gold might need it too. + _local_link_args += [ + '-Wl,--gc-sections' + ] + elif c_compiler.get_id() == 'msvc' + _local_link_args += [ + # TODO: Add MSVC options here. + ] + endif +endif + +_local_dependencies += [ + common_options_dependency, + micro_os_plus_architecture_synthetic_posix_dependency +] + +# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency +platform_native_dependency = declare_dependency( + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + compile_args: _local_compile_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_compile_args + _local_link_args, + link_with: _local_link_with, +) +platform_native_dependency_compile_c_args = _local_compile_c_args +platform_native_dependency_compile_cpp_args = _local_compile_cpp_args + +foreach xn : _local_include_directories + message('+ -I ' + xn) +endforeach +# Note: depenedencies compile_args not shown. +foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args + message('+ ' + xn) +endforeach +message('> platform_native_dependency') + +# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-a15/meson.build b/tests/platform-qemu-cortex-a15/meson.build index 1bc1f17..2ed6c03 100644 --- a/tests/platform-qemu-cortex-a15/meson.build +++ b/tests/platform-qemu-cortex-a15/meson.build @@ -23,46 +23,6 @@ xpack_create_listing = false xpack_create_hex = false # ----------------------------------------------------------------------------- -# Define the platform library. - -xpack_common_args = [] -xpack_include_directories = [] -xpack_sources = [] -xpack_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -xpack_include_directories += [ - 'include', -] - -xpack_sources += [ -] - -xpack_compile_definitions += [ -] - -# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency -platform_qemu_cortex_a15_dependency = declare_dependency( - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - compile_args: xpack_common_args + xpack_compile_definitions, - dependencies: [ - micro_os_plus_devices_qemu_aarch32_dependency, - ] -) - -foreach xn : xpack_include_directories - message('+ -I ' + xn) -endforeach -# Note: depenedencies compile_args not shown. -foreach xn : xpack_sources + xpack_common_args + xpack_compile_definitions - message('+ ' + xn) -endforeach -message('> platform_qemu_cortex_a15_dependency') - -# ============================================================================= -# Define the tests executables. # Get the command names from the toolchain file. size = find_program('size') @@ -71,56 +31,44 @@ objcopy = find_program('objcopy') # ----------------------------------------------------------------------------- +# Define the tests executables. + test_names = [ 'sample-test', 'unit-test' ] foreach name : test_names - xpack_common_args = [] - xpack_c_args = [] - xpack_cpp_args = [] - xpack_include_directories = [] - xpack_sources = [] - xpack_compile_definitions = [] - xpack_dependencies = [] - xpack_link_args = [] - xpack_link_with = [] + _local_compile_args = [] # Common C/C++ args. + _local_compile_c_args = [] + _local_compile_cpp_args = [] + _local_include_directories = [] + _local_sources = [] + _local_compile_definitions = [] + _local_dependencies = [] + _local_link_args = [] + _local_link_with = [] # --------------------------------------------------------------------------- - xpack_include_directories += [ + _local_include_directories += [ '../include', ] - xpack_sources += [ + _local_sources += [ '../src/' + name + '.cpp', ] - # xpack_c_args += micro_os_plus_utils_lists_dependency_c_args - # xpack_cpp_args += micro_os_plus_utils_lists_dependency_cpp_args - - xpack_link_args += [ - '-nostartfiles', - # '--specs=rdimon.specs', '-Wl,--start-group', '-lgcc', '-lc', '-lc', '-lm', '-lrdimon', '-Wl,--end-group', - - # Ensure the linker will keep the interrupt vectors which otherwise - # are not referred from anywhere. - # '-u_interrupt_vectors', - - # nano has no exceptions. - # '-specs=nano.specs' + _local_compile_c_args += platform_qemu_cortex_a15_dependency_compile_c_args + _local_compile_cpp_args += platform_qemu_cortex_a15_dependency_compile_cpp_args - '-Wl,--gc-sections', + _local_compile_c_args += micro_os_plus_micro_test_plus_dependency_compile_c_args + _local_compile_cpp_args += micro_os_plus_micro_test_plus_dependency_compile_cpp_args + _local_link_args += [ '-Wl,-Map,'+ name + '-map.txt', # '-v', - - # Path are relative to the build folder. - '-Txpacks/@micro-os-plus/devices-qemu-aarch32/linker-scripts/mem-cortex-a15.ld', - # '-Txpacks/@micro-os-plus/architecture-aarch32/linker-scripts/sections-flash.ld', - '-Txpacks/@micro-os-plus/architecture-aarch32/linker-scripts/sections-ram.ld', ] - xpack_dependencies += [ + _local_dependencies += [ # Tested library. micro_os_plus_micro_test_plus_dependency, @@ -128,13 +76,7 @@ foreach name : test_names micro_os_plus_diag_trace_dependency, ] - if name == 'unit-test' - xpack_dependencies += [ - micro_os_plus_micro_test_plus_dependency, - ] - endif - - xpack_dependencies += [ + _local_dependencies += [ # Platform specific dependencies. platform_qemu_cortex_a15_dependency, # bring device & architecture too @@ -142,29 +84,24 @@ foreach name : test_names micro_os_plus_startup_dependency, ] - xpack_link_with += [ - # Tested library. - # micro_os_plus_utils_lists_static, - ] - # https://mesonbuild.com/Reference-manual.html#executable exe = executable( name, - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - c_args: xpack_common_args + xpack_c_args + xpack_compile_definitions, - cpp_args: xpack_common_args + xpack_cpp_args + xpack_compile_definitions, - dependencies: xpack_dependencies, - link_args: xpack_link_args, - link_with: xpack_link_with, + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + c_args: _local_compile_args + _local_compile_c_args + _local_compile_definitions, + cpp_args: _local_compile_args + _local_compile_cpp_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_link_args, + link_with: _local_link_with, name_suffix: 'elf', ) - foreach xn : xpack_include_directories + foreach xn : _local_include_directories message('A+ -I ' + xn) endforeach # Note: depenedencies compile_args not shown. - foreach xn : xpack_sources + xpack_common_args + xpack_c_args + xpack_cpp_args + xpack_compile_definitions + xpack_link_args + foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args message('A+ ' + xn) endforeach message('A> ' + name) diff --git a/tests/platform-qemu-cortex-a15/meson/common/meson.build b/tests/platform-qemu-cortex-a15/meson/common/meson.build deleted file mode 100644 index 7815a03..0000000 --- a/tests/platform-qemu-cortex-a15/meson/common/meson.build +++ /dev/null @@ -1,108 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# This file is part of the µOS++ distribution. -# (https://github.com/micro-os-plus/) -# Copyright (c) 2022 Liviu Ionescu. All rights reserved. -# -# Permission to use, copy, modify, and/or distribute this software -# for any purpose is hereby granted, under the terms of the MIT license. -# -# If a copy of the license was not distributed with this file, it can -# be obtained from https://opensource.org/licenses/MIT/. -# -# ----------------------------------------------------------------------------- - -# Definitions required for compiling all files, thus the use of -# add_global_*() functions. -# Must be added with subdir() before creating any library or executable. - -message('Including platform-qemu-cortex-a15 common definitions...') - -# ----------------------------------------------------------------------------- - -# Required in devices-qemu-cortexa. -xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_CORTEX_A15' - -xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_CORTEX_A15' - -# ----------------------------------------------------------------------------- - -xpack_platform_common_args = [] -xpack_platform_common_c_args = [] -xpack_platform_common_cpp_args = [] -xpack_platform_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -# Compiler definitions must passed as options. -xpack_platform_compile_definitions += [ - '-D' + xpack_platform_compile_definition, - - # Full POSIX conformance: - # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 - '-D_POSIX_C_SOURCE=200809L', -] - -xpack_platform_common_args += [ - # https://gcc.gnu.org/onlinedocs/gcc-11.3.0/gcc/ARM-Options.html#ARM-Options - '-mcpu=cortex-a15', - - # '-fno-move-loop-invariants', - - # Embedded builds must be warning free. - '-Werror', -] - -if get_option('buildtype').contains('debug') - xpack_platform_common_args += [ - '-fno-omit-frame-pointer' - ] -else - xpack_platform_common_args += [ - # -flto fails with undefined reference to `_write', `_fstat`... - # '-flto' - ] -endif - -xpack_platform_common_cpp_args += [ - # '-fno-exceptions', - # '-fno-rtti', - # '-fno-use-cxa-atexit', - '-fno-threadsafe-statics', -] - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_compile_definitions, - - language: [ 'c' ] -) - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions, - - language: [ 'cpp' ] -) - -foreach xn : xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions - message('G+ ' + xn) -endforeach - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_c_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'c' ] -) - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'cpp' ] -) - -# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-a15/meson/dependencies/meson.build b/tests/platform-qemu-cortex-a15/meson/dependencies-folders/meson.build similarity index 74% rename from tests/platform-qemu-cortex-a15/meson/dependencies/meson.build rename to tests/platform-qemu-cortex-a15/meson/dependencies-folders/meson.build index 3861a91..256e38c 100644 --- a/tests/platform-qemu-cortex-a15/meson/dependencies/meson.build +++ b/tests/platform-qemu-cortex-a15/meson/dependencies-folders/meson.build @@ -12,7 +12,16 @@ # # ----------------------------------------------------------------------------- -# Add the platform dependencies. +# Define a list of folders where the platform dependencies are located. + +# ----------------------------------------------------------------------------- + +# Required in devices-qemu-cortexa. +xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_CORTEX_A15' + +xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_CORTEX_A15' + +# ----------------------------------------------------------------------------- # The base folder is tests. The order is significative. xpack_dependencies_folders = [ @@ -34,6 +43,8 @@ xpack_dependencies_folders = [ # +(arm_cmsis_core_m, devices_cortexa, startup) >devices_qemu_aarch32 xpack_build_folder_relative_path + '/xpacks/@micro-os-plus/devices-qemu-aarch32', + + 'platform-qemu-cortex-a15/meson/platform-options', ] # ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-a15/meson/platform-options/meson.build b/tests/platform-qemu-cortex-a15/meson/platform-options/meson.build new file mode 100644 index 0000000..66bfecb --- /dev/null +++ b/tests/platform-qemu-cortex-a15/meson/platform-options/meson.build @@ -0,0 +1,133 @@ +# ----------------------------------------------------------------------------- +# +# This file is part of the µOS++ distribution. +# (https://github.com/micro-os-plus/) +# Copyright (c) 2022 Liviu Ionescu. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose is hereby granted, under the terms of the MIT license. +# +# If a copy of the license was not distributed with this file, it can +# be obtained from https://opensource.org/licenses/MIT/. +# +# ----------------------------------------------------------------------------- + +message('Including platform-qemu-cortex-a15 common definitions...') + +# ----------------------------------------------------------------------------- + +_local_compile_args = [] # Common C/C++ args. +_local_compile_c_args = [] +_local_compile_cpp_args = [] +_local_include_directories = [] +_local_sources = [] +_local_compile_definitions = [] +_local_dependencies = [] +_local_link_args = [] +_local_link_with = [] + +# ----------------------------------------------------------------------------- + +_local_include_directories += [ + # Go back to the platform include. + '../../include', +] + +_local_sources += [ + # None. +] + +# Compiler definitions must passed as options. +_local_compile_definitions += [ + '-D' + xpack_platform_compile_definition, + + # Full POSIX conformance: + # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 + '-D_POSIX_C_SOURCE=200809L', + + # For S_IREAD + '-D_GNU_SOURCE' +] + +_local_compile_args += [ + # https://gcc.gnu.org/onlinedocs/gcc-11.3.0/gcc/ARM-Options.html#ARM-Options + '-mcpu=cortex-a15', + + # '-fno-move-loop-invariants', + + # Embedded builds must be warning free. + '-Werror', +] + +if get_option('buildtype').contains('debug') + _local_compile_args += [ + '-fno-omit-frame-pointer' + ] +else + _local_compile_args += [ + # -flto fails with undefined reference to `_write', `_fstat`... + # '-flto' + ] +endif + +_local_compile_cpp_args += [ + # '-fno-exceptions', + # '-fno-rtti', + # '-fno-use-cxa-atexit', + '-fno-threadsafe-statics', +] + +_local_compile_c_args += common_options_dependency_compile_c_args +_local_compile_cpp_args += common_options_dependency_compile_cpp_args + +_local_link_args += [ + '-v', + + '-nostartfiles', + # '--specs=rdimon.specs', '-Wl,--start-group', '-lgcc', '-lc', '-lc', '-lm', '-lrdimon', '-Wl,--end-group', + + # Ensure the linker will keep the interrupt vectors which otherwise + # are not referred from anywhere. + # '-u_interrupt_vectors', + + # nano has no exceptions. + # '-specs=nano.specs' + + '-Wl,--gc-sections', + + # .elf has a LOAD segment with RWX permissions (GCC 12) + '-Wl,--no-warn-rwx-segments', + + # Path are relative to the build folder. + '-Txpacks/@micro-os-plus/devices-qemu-aarch32/linker-scripts/mem-cortex-a15.ld', + # '-Txpacks/@micro-os-plus/architecture-aarch32/linker-scripts/sections-flash.ld', + '-Txpacks/@micro-os-plus/architecture-aarch32/linker-scripts/sections-ram.ld', +] + +_local_dependencies += [ + common_options_dependency, + micro_os_plus_devices_qemu_aarch32_dependency, +] + +# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency +platform_qemu_cortex_a15_dependency = declare_dependency( + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + compile_args: _local_compile_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_compile_args + _local_link_args, + link_with: _local_link_with, +) +platform_qemu_cortex_a15_dependency_compile_c_args = _local_compile_c_args +platform_qemu_cortex_a15_dependency_compile_cpp_args = _local_compile_cpp_args + +foreach xn : _local_include_directories + message('+ -I ' + xn) +endforeach +# Note: depenedencies compile_args not shown. +foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args + message('+ ' + xn) +endforeach +message('> platform_qemu_cortex_a15_dependency') + +# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-a72/meson.build b/tests/platform-qemu-cortex-a72/meson.build index 87d914e..7af34c5 100644 --- a/tests/platform-qemu-cortex-a72/meson.build +++ b/tests/platform-qemu-cortex-a72/meson.build @@ -23,47 +23,6 @@ xpack_create_listing = false xpack_create_hex = false # ----------------------------------------------------------------------------- -# Define the platform library. - -xpack_common_args = [] -xpack_include_directories = [] -xpack_sources = [] -xpack_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -xpack_include_directories += [ - 'include', -] - -xpack_sources += [ -] - -xpack_compile_definitions += [ - '-D' + xpack_platform_compile_definition, -] - -# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency -platform_qemu_cortex_a72_dependency = declare_dependency( - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - compile_args: xpack_common_args + xpack_compile_definitions, - dependencies: [ - micro_os_plus_devices_qemu_aarch64_dependency, - ] -) - -foreach xn : xpack_include_directories - message('+ -I ' + xn) -endforeach -# Note: depenedencies compile_args not shown. -foreach xn : xpack_sources + xpack_common_args + xpack_compile_definitions - message('+ ' + xn) -endforeach -message('> platform_qemu_cortex_a72_dependency') - -# ============================================================================= -# Define the tests executables. # Get the command names from the toolchain file. size = find_program('size') @@ -72,56 +31,44 @@ objcopy = find_program('objcopy') # ----------------------------------------------------------------------------- +# Define the tests executables. + test_names = [ 'sample-test', 'unit-test' ] foreach name : test_names - xpack_common_args = [] - xpack_c_args = [] - xpack_cpp_args = [] - xpack_include_directories = [] - xpack_sources = [] - xpack_compile_definitions = [] - xpack_dependencies = [] - xpack_link_args = [] - xpack_link_with = [] + _local_compile_args = [] # Common C/C++ args. + _local_compile_c_args = [] + _local_compile_cpp_args = [] + _local_include_directories = [] + _local_sources = [] + _local_compile_definitions = [] + _local_dependencies = [] + _local_link_args = [] + _local_link_with = [] # --------------------------------------------------------------------------- - xpack_include_directories += [ + _local_include_directories += [ '../include', ] - xpack_sources += [ + _local_sources += [ '../src/' + name + '.cpp', ] - # xpack_c_args += micro_os_plus_utils_lists_dependency_c_args - # xpack_cpp_args += micro_os_plus_utils_lists_dependency_cpp_args - - xpack_link_args += [ - '-nostartfiles', - # '--specs=rdimon.specs', '-Wl,--start-group', '-lgcc', '-lc', '-lc', '-lm', '-lrdimon', '-Wl,--end-group', - - # Ensure the linker will keep the interrupt vectors which otherwise - # are not referred from anywhere. - # '-u_interrupt_vectors', - - # nano has no exceptions. - # '-specs=nano.specs' + _local_compile_c_args += platform_qemu_cortex_a72_dependency_compile_c_args + _local_compile_cpp_args += platform_qemu_cortex_a72_dependency_compile_cpp_args - '-Wl,--gc-sections', + _local_compile_c_args += micro_os_plus_micro_test_plus_dependency_compile_c_args + _local_compile_cpp_args += micro_os_plus_micro_test_plus_dependency_compile_cpp_args + _local_link_args += [ '-Wl,-Map,'+ name + '-map.txt', # '-v', - - # Path are relative to the build folder. - '-Txpacks/@micro-os-plus/devices-qemu-aarch64/linker-scripts/mem-cortex-a72.ld', - # '-Txpacks/@micro-os-plus/architecture-aarch64/linker-scripts/sections-flash.ld', - '-Txpacks/@micro-os-plus/architecture-aarch64/linker-scripts/sections-ram.ld', ] - xpack_dependencies += [ + _local_dependencies += [ # Tested library. micro_os_plus_micro_test_plus_dependency, @@ -129,13 +76,7 @@ foreach name : test_names micro_os_plus_diag_trace_dependency, ] - if name == 'unit-test' - xpack_dependencies += [ - micro_os_plus_micro_test_plus_dependency, - ] - endif - - xpack_dependencies += [ + _local_dependencies += [ # Platform specific dependencies. platform_qemu_cortex_a72_dependency, # bring device & architecture too @@ -143,29 +84,24 @@ foreach name : test_names micro_os_plus_startup_dependency, ] - xpack_link_with += [ - # Tested library. - # micro_os_plus_utils_lists_static, - ] - # https://mesonbuild.com/Reference-manual.html#executable exe = executable( name, - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - c_args: xpack_common_args + xpack_c_args + xpack_compile_definitions, - cpp_args: xpack_common_args + xpack_cpp_args + xpack_compile_definitions, - dependencies: xpack_dependencies, - link_args: xpack_link_args, - link_with: xpack_link_with, + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + c_args: _local_compile_args + _local_compile_c_args + _local_compile_definitions, + cpp_args: _local_compile_args + _local_compile_cpp_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_link_args, + link_with: _local_link_with, name_suffix: 'elf', ) - foreach xn : xpack_include_directories + foreach xn : _local_include_directories message('A+ -I ' + xn) endforeach # Note: depenedencies compile_args not shown. - foreach xn : xpack_sources + xpack_common_args + xpack_c_args + xpack_cpp_args + xpack_compile_definitions + xpack_link_args + foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args message('A+ ' + xn) endforeach message('A> ' + name) diff --git a/tests/platform-qemu-cortex-a72/meson/common/meson.build b/tests/platform-qemu-cortex-a72/meson/common/meson.build deleted file mode 100644 index 8fedaee..0000000 --- a/tests/platform-qemu-cortex-a72/meson/common/meson.build +++ /dev/null @@ -1,109 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# This file is part of the µOS++ distribution. -# (https://github.com/micro-os-plus/) -# Copyright (c) 2022 Liviu Ionescu. All rights reserved. -# -# Permission to use, copy, modify, and/or distribute this software -# for any purpose is hereby granted, under the terms of the MIT license. -# -# If a copy of the license was not distributed with this file, it can -# be obtained from https://opensource.org/licenses/MIT/. -# -# ----------------------------------------------------------------------------- - -# Definitions required for compiling all files, thus the use of -# add_global_*() functions. -# Must be added with subdir() before creating any library or executable. - -message('Including platform-qemu-cortex-a72 common definitions...') - -# ----------------------------------------------------------------------------- - -# Required in devices-qemu-aarch64. -xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_CORTEX_A72' - -xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_CORTEX_A72' - -# ----------------------------------------------------------------------------- - -xpack_platform_common_args = [] -xpack_platform_common_c_args = [] -xpack_platform_common_cpp_args = [] -xpack_platform_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -# Compiler definitions must passed as options. -xpack_platform_compile_definitions += [ - '-D' + xpack_platform_compile_definition, - - # Full POSIX conformance: - # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 - '-D_POSIX_C_SOURCE=200809L', -] - -xpack_platform_common_args += [ - '-mcpu=cortex-a72', - '-mabi=lp64', - - # '-fno-move-loop-invariants', - - # Embedded builds must be warning free. - '-Werror', -] - -if get_option('buildtype').contains('debug') - xpack_platform_common_args += [ - '-fno-omit-frame-pointer' - ] -else - xpack_platform_common_args += [ - # -flto fails with undefined reference to `_write', `_fstat`... - # '-flto' - ] -endif - -xpack_platform_common_cpp_args += [ - '-fno-exceptions', - # '-fno-rtti', - # '-fno-use-cxa-atexit', - - '-fno-threadsafe-statics', -] - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_compile_definitions, - - language: [ 'c' ] -) - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions, - - language: [ 'cpp' ] -) - -foreach xn : xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions - message('G+ ' + xn) -endforeach - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_c_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'c' ] -) - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'cpp' ] -) - -# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-a72/meson/dependencies/meson.build b/tests/platform-qemu-cortex-a72/meson/dependencies-folders/meson.build similarity index 74% rename from tests/platform-qemu-cortex-a72/meson/dependencies/meson.build rename to tests/platform-qemu-cortex-a72/meson/dependencies-folders/meson.build index fb57d69..e32985c 100644 --- a/tests/platform-qemu-cortex-a72/meson/dependencies/meson.build +++ b/tests/platform-qemu-cortex-a72/meson/dependencies-folders/meson.build @@ -12,7 +12,16 @@ # # ----------------------------------------------------------------------------- -# Add the platform dependencies. +# Define a list of folders where the platform dependencies are located. + +# ----------------------------------------------------------------------------- + +# Required in devices-qemu-aarch64. +xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_CORTEX_A72' + +xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_CORTEX_A72' + +# ----------------------------------------------------------------------------- # The base folder is tests. The order is significative. xpack_dependencies_folders = [ @@ -34,6 +43,8 @@ xpack_dependencies_folders = [ # +(arm_cmsis_core_m, devices_cortexa, startup) >devices_qemu_aarch64 xpack_build_folder_relative_path + '/xpacks/@micro-os-plus/devices-qemu-aarch64', + + 'platform-qemu-cortex-a72/meson/platform-options', ] # ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-a72/meson/platform-options/meson.build b/tests/platform-qemu-cortex-a72/meson/platform-options/meson.build new file mode 100644 index 0000000..6abb8c4 --- /dev/null +++ b/tests/platform-qemu-cortex-a72/meson/platform-options/meson.build @@ -0,0 +1,134 @@ +# ----------------------------------------------------------------------------- +# +# This file is part of the µOS++ distribution. +# (https://github.com/micro-os-plus/) +# Copyright (c) 2022 Liviu Ionescu. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose is hereby granted, under the terms of the MIT license. +# +# If a copy of the license was not distributed with this file, it can +# be obtained from https://opensource.org/licenses/MIT/. +# +# ----------------------------------------------------------------------------- + +message('Including platform-qemu-cortex-a72 common definitions...') + +# ----------------------------------------------------------------------------- + +_local_compile_args = [] # Common C/C++ args. +_local_compile_c_args = [] +_local_compile_cpp_args = [] +_local_include_directories = [] +_local_sources = [] +_local_compile_definitions = [] +_local_dependencies = [] +_local_link_args = [] +_local_link_with = [] + +# ----------------------------------------------------------------------------- + +_local_include_directories += [ + # Go back to the platform include. + '../../include', +] + +_local_sources += [ + # None. +] + +# Compiler definitions must passed as options. +_local_compile_definitions += [ + '-D' + xpack_platform_compile_definition, + + # Full POSIX conformance: + # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 + '-D_POSIX_C_SOURCE=200809L', + + # For S_IREAD + '-D_GNU_SOURCE' +] + +_local_compile_args += [ + # https://gcc.gnu.org/onlinedocs/gcc-11.3.0/gcc/ARM-Options.html#ARM-Options + '-mcpu=cortex-a72', + '-mabi=lp64', + + # '-fno-move-loop-invariants', + + # Embedded builds must be warning free. + '-Werror', +] + +if get_option('buildtype').contains('debug') + _local_compile_args += [ + '-fno-omit-frame-pointer' + ] +else + _local_compile_args += [ + # -flto fails with undefined reference to `_write', `_fstat`... + # '-flto' + ] +endif + +_local_compile_cpp_args += [ + '-fno-exceptions', # !!! + # '-fno-rtti', + # '-fno-use-cxa-atexit', + '-fno-threadsafe-statics', +] + +_local_compile_c_args += common_options_dependency_compile_c_args +_local_compile_cpp_args += common_options_dependency_compile_cpp_args + +_local_link_args += [ + '-v', + + '-nostartfiles', + # '--specs=rdimon.specs', '-Wl,--start-group', '-lgcc', '-lc', '-lc', '-lm', '-lrdimon', '-Wl,--end-group', + + # Ensure the linker will keep the interrupt vectors which otherwise + # are not referred from anywhere. + # '-u_interrupt_vectors', + + # nano has no exceptions. + # '-specs=nano.specs' + + '-Wl,--gc-sections', + + # .elf has a LOAD segment with RWX permissions (GCC 12) + '-Wl,--no-warn-rwx-segments', + + # Path are relative to the build folder. + '-Txpacks/@micro-os-plus/devices-qemu-aarch64/linker-scripts/mem-cortex-a72.ld', + # '-Txpacks/@micro-os-plus/architecture-aarch64/linker-scripts/sections-flash.ld', + '-Txpacks/@micro-os-plus/architecture-aarch64/linker-scripts/sections-ram.ld', +] + +_local_dependencies += [ + common_options_dependency, + micro_os_plus_devices_qemu_aarch64_dependency, +] + +# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency +platform_qemu_cortex_a72_dependency = declare_dependency( + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + compile_args: _local_compile_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_compile_args + _local_link_args, + link_with: _local_link_with, +) +platform_qemu_cortex_a72_dependency_compile_c_args = _local_compile_c_args +platform_qemu_cortex_a72_dependency_compile_cpp_args = _local_compile_cpp_args + +foreach xn : _local_include_directories + message('+ -I ' + xn) +endforeach +# Note: depenedencies compile_args not shown. +foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args + message('+ ' + xn) +endforeach +message('> platform_qemu_cortex_a72_dependency') + +# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-m0/meson.build b/tests/platform-qemu-cortex-m0/meson.build index bed3e40..efecd16 100644 --- a/tests/platform-qemu-cortex-m0/meson.build +++ b/tests/platform-qemu-cortex-m0/meson.build @@ -23,47 +23,6 @@ xpack_create_listing = false xpack_create_hex = false # ----------------------------------------------------------------------------- -# Define the platform library. - -xpack_common_args = [] -xpack_include_directories = [] -xpack_sources = [] -xpack_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -xpack_include_directories += [ - 'include', -] - -xpack_sources += [ -] - -xpack_compile_definitions += [ - '-D' + xpack_platform_compile_definition, -] - -# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency -platform_qemu_cortex_m0_dependency = declare_dependency( - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - compile_args: xpack_common_args + xpack_compile_definitions, - dependencies: [ - micro_os_plus_devices_qemu_cortexm_dependency, - ] -) - -foreach xn : xpack_include_directories - message('+ -I ' + xn) -endforeach -# Note: depenedencies compile_args not shown. -foreach xn : xpack_sources + xpack_common_args + xpack_compile_definitions - message('+ ' + xn) -endforeach -message('> platform_qemu_cortex_m0_dependency') - -# ============================================================================= -# Define the tests executables. # Get the command names from the toolchain file. size = find_program('size') @@ -72,56 +31,44 @@ objcopy = find_program('objcopy') # ----------------------------------------------------------------------------- +# Define the tests executables. + test_names = [ 'sample-test', 'unit-test' ] foreach name : test_names - xpack_common_args = [] - xpack_c_args = [] - xpack_cpp_args = [] - xpack_include_directories = [] - xpack_sources = [] - xpack_compile_definitions = [] - xpack_dependencies = [] - xpack_link_args = [] - xpack_link_with = [] + _local_compile_args = [] # Common C/C++ args. + _local_compile_c_args = [] + _local_compile_cpp_args = [] + _local_include_directories = [] + _local_sources = [] + _local_compile_definitions = [] + _local_dependencies = [] + _local_link_args = [] + _local_link_with = [] # --------------------------------------------------------------------------- - xpack_include_directories += [ + _local_include_directories += [ '../include', ] - xpack_sources += [ + _local_sources += [ '../src/' + name + '.cpp', ] - # xpack_c_args += micro_os_plus_utils_lists_dependency_c_args - # xpack_cpp_args += micro_os_plus_utils_lists_dependency_cpp_args - - xpack_link_args += [ - '-nostartfiles', - # '--specs=rdimon.specs', '-Wl,--start-group', '-lgcc', '-lc', '-lc', '-lm', '-lrdimon', '-Wl,--end-group', - - # Ensure the linker will keep the interrupt vectors which otherwise - # are not referred from anywhere. - # '-u_interrupt_vectors', + _local_compile_c_args += platform_qemu_cortex_m0_dependency_compile_c_args + _local_compile_cpp_args += platform_qemu_cortex_m0_dependency_compile_cpp_args - # nano has no exceptions. - # '-specs=nano.specs' - - '-Wl,--gc-sections', + _local_compile_c_args += micro_os_plus_micro_test_plus_dependency_compile_c_args + _local_compile_cpp_args += micro_os_plus_micro_test_plus_dependency_compile_cpp_args + _local_link_args += [ '-Wl,-Map,'+ name + '-map.txt', # '-v', - - # Path are relative to the build folder. - '-Txpacks/@micro-os-plus/devices-qemu-cortexm/linker-scripts/mem-mps2-an385.ld', - '-Txpacks/@micro-os-plus/architecture-cortexm/linker-scripts/sections-flash.ld', - # '-Txpacks/@micro-os-plus/architecture-cortexm/linker-scripts/sections-ram.ld', ] - xpack_dependencies += [ + _local_dependencies += [ # Tested library. micro_os_plus_micro_test_plus_dependency, @@ -130,12 +77,12 @@ foreach name : test_names ] if name == 'unit-test' - xpack_dependencies += [ + _local_dependencies += [ micro_os_plus_micro_test_plus_dependency, ] endif - xpack_dependencies += [ + _local_dependencies += [ # Platform specific dependencies. platform_qemu_cortex_m0_dependency, # bring device & architecture too @@ -143,29 +90,24 @@ foreach name : test_names micro_os_plus_startup_dependency, ] - xpack_link_with += [ - # Tested library. - # micro_os_plus_utils_lists_static, - ] - # https://mesonbuild.com/Reference-manual.html#executable exe = executable( name, - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - c_args: xpack_common_args + xpack_c_args + xpack_compile_definitions, - cpp_args: xpack_common_args + xpack_cpp_args + xpack_compile_definitions, - dependencies: xpack_dependencies, - link_args: xpack_link_args, - link_with: xpack_link_with, + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + c_args: _local_compile_args + _local_compile_c_args + _local_compile_definitions, + cpp_args: _local_compile_args + _local_compile_cpp_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_link_args, + link_with: _local_link_with, name_suffix: 'elf', ) - foreach xn : xpack_include_directories + foreach xn : _local_include_directories message('A+ -I ' + xn) endforeach # Note: depenedencies compile_args not shown. - foreach xn : xpack_sources + xpack_common_args + xpack_c_args + xpack_cpp_args + xpack_compile_definitions + xpack_link_args + foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args message('A+ ' + xn) endforeach message('A> ' + name) diff --git a/tests/platform-qemu-cortex-m0/meson/common/meson.build b/tests/platform-qemu-cortex-m0/meson/common/meson.build deleted file mode 100644 index 1ec038a..0000000 --- a/tests/platform-qemu-cortex-m0/meson/common/meson.build +++ /dev/null @@ -1,110 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# This file is part of the µOS++ distribution. -# (https://github.com/micro-os-plus/) -# Copyright (c) 2022 Liviu Ionescu. All rights reserved. -# -# Permission to use, copy, modify, and/or distribute this software -# for any purpose is hereby granted, under the terms of the MIT license. -# -# If a copy of the license was not distributed with this file, it can -# be obtained from https://opensource.org/licenses/MIT/. -# -# ----------------------------------------------------------------------------- - -# Definitions required for compiling all files, thus the use of -# add_global_*() functions. -# Must be added with subdir() before creating any library or executable. - -message('Including platform-qemu-cortex-m0 common definitions...') - -# ----------------------------------------------------------------------------- - -# Required in devices-qemu-cortexm. -xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_CORTEX_M0' - -xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_CORTEX_M0' - -# ----------------------------------------------------------------------------- - -xpack_platform_common_args = [] -xpack_platform_common_c_args = [] -xpack_platform_common_cpp_args = [] -xpack_platform_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -# Compiler definitions must passed as options. -xpack_platform_compile_definitions += [ - '-D' + xpack_platform_compile_definition, - - # Full POSIX conformance: - # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 - '-D_POSIX_C_SOURCE=200809L', -] - -xpack_platform_common_args += [ - '-mcpu=cortex-m0', - '-mthumb', - '-mfloat-abi=soft', - - # '-fno-move-loop-invariants', - - # Embedded builds must be warning free. - '-Werror', -] - -if get_option('buildtype').contains('debug') - xpack_platform_common_args += [ - '-fno-omit-frame-pointer' - ] -else - xpack_platform_common_args += [ - # -flto fails to run on QEMU. - # '-flto' - ] -endif - -xpack_platform_common_cpp_args += [ - # '-fno-exceptions', - # '-fno-rtti', - # '-fno-use-cxa-atexit', - - '-fno-threadsafe-statics', -] - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_compile_definitions, - - language: [ 'c' ] -) - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions, - - language: [ 'cpp' ] -) - -foreach xn : xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions - message('G+ ' + xn) -endforeach - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_c_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'c' ] -) - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'cpp' ] -) - -# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-m0/meson/dependencies/meson.build b/tests/platform-qemu-cortex-m0/meson/dependencies-folders/meson.build similarity index 74% rename from tests/platform-qemu-cortex-m0/meson/dependencies/meson.build rename to tests/platform-qemu-cortex-m0/meson/dependencies-folders/meson.build index eb26999..3cb4eb4 100644 --- a/tests/platform-qemu-cortex-m0/meson/dependencies/meson.build +++ b/tests/platform-qemu-cortex-m0/meson/dependencies-folders/meson.build @@ -12,7 +12,16 @@ # # ----------------------------------------------------------------------------- -# Add the platform dependencies. +# Define a list of folders where the platform dependencies are located. + +# ----------------------------------------------------------------------------- + +# Required in devices-qemu-cortexm. +xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_CORTEX_M0' + +xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_CORTEX_M0' + +# ----------------------------------------------------------------------------- # The base folder is tests. The order is significative. xpack_dependencies_folders = [ @@ -34,6 +43,8 @@ xpack_dependencies_folders = [ # +(arm_cmsis_core_m, devices_cortexm, startup) >devices_qemu_cortexm xpack_build_folder_relative_path + '/xpacks/@micro-os-plus/devices-qemu-cortexm', + + 'platform-qemu-cortex-m0/meson/platform-options', ] # ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-m0/meson/platform-options/meson.build b/tests/platform-qemu-cortex-m0/meson/platform-options/meson.build new file mode 100644 index 0000000..2c9651a --- /dev/null +++ b/tests/platform-qemu-cortex-m0/meson/platform-options/meson.build @@ -0,0 +1,135 @@ +# ----------------------------------------------------------------------------- +# +# This file is part of the µOS++ distribution. +# (https://github.com/micro-os-plus/) +# Copyright (c) 2022 Liviu Ionescu. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose is hereby granted, under the terms of the MIT license. +# +# If a copy of the license was not distributed with this file, it can +# be obtained from https://opensource.org/licenses/MIT/. +# +# ----------------------------------------------------------------------------- + +message('Including platform-qemu-cortex-m0 common definitions...') + +# ----------------------------------------------------------------------------- + +_local_compile_args = [] # Common C/C++ args. +_local_compile_c_args = [] +_local_compile_cpp_args = [] +_local_include_directories = [] +_local_sources = [] +_local_compile_definitions = [] +_local_dependencies = [] +_local_link_args = [] +_local_link_with = [] + +# ----------------------------------------------------------------------------- + +_local_include_directories += [ + # Go back to the platform include. + '../../include', +] + +_local_sources += [ + # None. +] + +# Compiler definitions must passed as options. +_local_compile_definitions += [ + '-D' + xpack_platform_compile_definition, + + # Full POSIX conformance: + # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 + '-D_POSIX_C_SOURCE=200809L', + + # For S_IREAD + '-D_GNU_SOURCE' +] + +_local_compile_args += [ + # https://gcc.gnu.org/onlinedocs/gcc-11.3.0/gcc/ARM-Options.html#ARM-Options + '-mcpu=cortex-m0', + '-mthumb', + '-mfloat-abi=soft', + + # '-fno-move-loop-invariants', + + # Embedded builds must be warning free. + '-Werror', +] + +if get_option('buildtype').contains('debug') + _local_compile_args += [ + '-fno-omit-frame-pointer' + ] +else + _local_compile_args += [ + # -flto fails with undefined reference to `_write', `_fstat`... + # '-flto' + ] +endif + +_local_compile_cpp_args += [ + # '-fno-exceptions', + # '-fno-rtti', + # '-fno-use-cxa-atexit', + '-fno-threadsafe-statics', +] + +_local_compile_c_args += common_options_dependency_compile_c_args +_local_compile_cpp_args += common_options_dependency_compile_cpp_args + +_local_link_args += [ + '-v', + + '-nostartfiles', + # '--specs=rdimon.specs', '-Wl,--start-group', '-lgcc', '-lc', '-lc', '-lm', '-lrdimon', '-Wl,--end-group', + + # Ensure the linker will keep the interrupt vectors which otherwise + # are not referred from anywhere. + # '-u_interrupt_vectors', + + # nano has no exceptions. + # '-specs=nano.specs' + + '-Wl,--gc-sections', + + # .elf has a LOAD segment with RWX permissions (GCC 12) + '-Wl,--no-warn-rwx-segments', + + # Path are relative to the build folder. + '-Txpacks/@micro-os-plus/devices-qemu-cortexm/linker-scripts/mem-mps2-an385.ld', + '-Txpacks/@micro-os-plus/architecture-cortexm/linker-scripts/sections-flash.ld', + # '-Txpacks/@micro-os-plus/architecture-cortexm/linker-scripts/sections-ram.ld', +] + +_local_dependencies += [ + common_options_dependency, + micro_os_plus_devices_qemu_cortexm_dependency, +] + +# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency +platform_qemu_cortex_m0_dependency = declare_dependency( + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + compile_args: _local_compile_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_compile_args + _local_link_args, + link_with: _local_link_with, +) +platform_qemu_cortex_m0_dependency_compile_c_args = _local_compile_c_args +platform_qemu_cortex_m0_dependency_compile_cpp_args = _local_compile_cpp_args + +foreach xn : _local_include_directories + message('+ -I ' + xn) +endforeach +# Note: depenedencies compile_args not shown. +foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args + message('+ ' + xn) +endforeach +message('> platform_qemu_cortex_m0_dependency') + +# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-m7f/meson.build b/tests/platform-qemu-cortex-m7f/meson.build index a9e3526..328c3d3 100644 --- a/tests/platform-qemu-cortex-m7f/meson.build +++ b/tests/platform-qemu-cortex-m7f/meson.build @@ -23,47 +23,6 @@ xpack_create_listing = false xpack_create_hex = false # ----------------------------------------------------------------------------- -# Define the platform library. - -xpack_common_args = [] -xpack_include_directories = [] -xpack_sources = [] -xpack_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -xpack_include_directories += [ - 'include', -] - -xpack_sources += [ -] - -xpack_compile_definitions += [ - '-D' + xpack_platform_compile_definition, -] - -# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency -platform_qemu_cortex_m7f_dependency = declare_dependency( - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - compile_args: xpack_common_args + xpack_compile_definitions, - dependencies: [ - micro_os_plus_devices_qemu_cortexm_dependency, - ] -) - -foreach xn : xpack_include_directories - message('+ -I ' + xn) -endforeach -# Note: depenedencies compile_args not shown. -foreach xn : xpack_sources + xpack_common_args + xpack_compile_definitions - message('+ ' + xn) -endforeach -message('> platform_qemu_cortex_m7f_dependency') - -# ============================================================================= -# Define the tests executables. # Get the command names from the toolchain file. size = find_program('size') @@ -72,56 +31,44 @@ objcopy = find_program('objcopy') # ----------------------------------------------------------------------------- +# Define the tests executables. + test_names = [ 'sample-test', 'unit-test' ] foreach name : test_names - xpack_common_args = [] - xpack_c_args = [] - xpack_cpp_args = [] - xpack_include_directories = [] - xpack_sources = [] - xpack_compile_definitions = [] - xpack_dependencies = [] - xpack_link_args = [] - xpack_link_with = [] + _local_compile_args = [] # Common C/C++ args. + _local_compile_c_args = [] + _local_compile_cpp_args = [] + _local_include_directories = [] + _local_sources = [] + _local_compile_definitions = [] + _local_dependencies = [] + _local_link_args = [] + _local_link_with = [] # --------------------------------------------------------------------------- - xpack_include_directories += [ + _local_include_directories += [ '../include', ] - xpack_sources += [ + _local_sources += [ '../src/' + name + '.cpp', ] - # xpack_c_args += micro_os_plus_utils_lists_dependency_c_args - # xpack_cpp_args += micro_os_plus_utils_lists_dependency_cpp_args - - xpack_link_args += [ - '-nostartfiles', - # '--specs=rdimon.specs', '-Wl,--start-group', '-lgcc', '-lc', '-lc', '-lm', '-lrdimon', '-Wl,--end-group', - - # Ensure the linker will keep the interrupt vectors which otherwise - # are not referred from anywhere. - # '-u_interrupt_vectors', - - # nano has no exceptions. - # '-specs=nano.specs' + _local_compile_c_args += platform_qemu_cortex_m7f_dependency_compile_c_args + _local_compile_cpp_args += platform_qemu_cortex_m7f_dependency_compile_cpp_args - '-Wl,--gc-sections', + _local_compile_c_args += micro_os_plus_micro_test_plus_dependency_compile_c_args + _local_compile_cpp_args += micro_os_plus_micro_test_plus_dependency_compile_cpp_args + _local_link_args += [ '-Wl,-Map,'+ name + '-map.txt', # '-v', - - # Path are relative to the build folder. - '-Txpacks/@micro-os-plus/devices-qemu-cortexm/linker-scripts/mem-mps2-an500.ld', - '-Txpacks/@micro-os-plus/architecture-cortexm/linker-scripts/sections-flash.ld', - # '-Txpacks/@micro-os-plus/architecture-cortexm/linker-scripts/sections-ram.ld', ] - xpack_dependencies += [ + _local_dependencies += [ # Tested library. micro_os_plus_micro_test_plus_dependency, @@ -129,13 +76,7 @@ foreach name : test_names micro_os_plus_diag_trace_dependency, ] - if name == 'unit-test' - xpack_dependencies += [ - micro_os_plus_micro_test_plus_dependency, - ] - endif - - xpack_dependencies += [ + _local_dependencies += [ # Platform specific dependencies. platform_qemu_cortex_m7f_dependency, # bring device & architecture too @@ -143,29 +84,24 @@ foreach name : test_names micro_os_plus_startup_dependency, ] - xpack_link_with += [ - # Tested library. - # micro_os_plus_utils_lists_static, - ] - # https://mesonbuild.com/Reference-manual.html#executable exe = executable( name, - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - c_args: xpack_common_args + xpack_c_args + xpack_compile_definitions, - cpp_args: xpack_common_args + xpack_cpp_args + xpack_compile_definitions, - dependencies: xpack_dependencies, - link_args: xpack_link_args, - link_with: xpack_link_with, + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + c_args: _local_compile_args + _local_compile_c_args + _local_compile_definitions, + cpp_args: _local_compile_args + _local_compile_cpp_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_link_args, + link_with: _local_link_with, name_suffix: 'elf', ) - foreach xn : xpack_include_directories + foreach xn : _local_include_directories message('A+ -I ' + xn) endforeach # Note: depenedencies compile_args not shown. - foreach xn : xpack_sources + xpack_common_args + xpack_c_args + xpack_cpp_args + xpack_compile_definitions + xpack_link_args + foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args message('A+ ' + xn) endforeach message('A> ' + name) diff --git a/tests/platform-qemu-cortex-m7f/meson/common/meson.build b/tests/platform-qemu-cortex-m7f/meson/common/meson.build deleted file mode 100644 index e0c3eb7..0000000 --- a/tests/platform-qemu-cortex-m7f/meson/common/meson.build +++ /dev/null @@ -1,111 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# This file is part of the µOS++ distribution. -# (https://github.com/micro-os-plus/) -# Copyright (c) 2022 Liviu Ionescu. All rights reserved. -# -# Permission to use, copy, modify, and/or distribute this software -# for any purpose is hereby granted, under the terms of the MIT license. -# -# If a copy of the license was not distributed with this file, it can -# be obtained from https://opensource.org/licenses/MIT/. -# -# ----------------------------------------------------------------------------- - -# Definitions required for compiling all files, thus the use of -# add_global_*() functions. -# Must be added with subdir() before creating any library or executable. - -message('Including platform-qemu-cortex-m7f common definitions...') - -# ----------------------------------------------------------------------------- - -# Required in devices-qemu-cortexm. -xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_CORTEX_M7' - -xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_CORTEX_M7F' - -# ----------------------------------------------------------------------------- - -xpack_platform_common_args = [] -xpack_platform_common_c_args = [] -xpack_platform_common_cpp_args = [] -xpack_platform_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -# Compiler definitions must passed as options. -xpack_platform_compile_definitions += [ - '-D' + xpack_platform_compile_definition, - - # Full POSIX conformance: - # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 - '-D_POSIX_C_SOURCE=200809L', -] - -xpack_platform_common_args += [ - '-mcpu=cortex-m7', - '-mthumb', - '-mfloat-abi=hard', - # '-mfloat-abi=soft', - - # '-fno-move-loop-invariants', - - # Embedded builds must be warning free. - '-Werror', -] - -if get_option('buildtype').contains('debug') - xpack_platform_common_args += [ - '-fno-omit-frame-pointer' - ] -else - xpack_platform_common_args += [ - # -flto fails to run on QEMU. - # '-flto' - ] -endif - -xpack_platform_common_cpp_args += [ - # '-fno-exceptions', - # '-fno-rtti', - # '-fno-use-cxa-atexit', - - '-fno-threadsafe-statics', -] - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_compile_definitions, - - language: [ 'c' ] -) - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions, - - language: [ 'cpp' ] -) - -foreach xn : xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions - message('G+ ' + xn) -endforeach - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_c_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'c' ] -) - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'cpp' ] -) - -# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-m7f/meson/dependencies/meson.build b/tests/platform-qemu-cortex-m7f/meson/dependencies-folders/meson.build similarity index 74% rename from tests/platform-qemu-cortex-m7f/meson/dependencies/meson.build rename to tests/platform-qemu-cortex-m7f/meson/dependencies-folders/meson.build index eb26999..2b2c5b6 100644 --- a/tests/platform-qemu-cortex-m7f/meson/dependencies/meson.build +++ b/tests/platform-qemu-cortex-m7f/meson/dependencies-folders/meson.build @@ -12,7 +12,16 @@ # # ----------------------------------------------------------------------------- -# Add the platform dependencies. +# Define a list of folders where the platform dependencies are located. + +# ----------------------------------------------------------------------------- + +# Required in devices-qemu-cortexm. +xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_CORTEX_M7' + +xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_CORTEX_M7F' + +# ----------------------------------------------------------------------------- # The base folder is tests. The order is significative. xpack_dependencies_folders = [ @@ -34,6 +43,8 @@ xpack_dependencies_folders = [ # +(arm_cmsis_core_m, devices_cortexm, startup) >devices_qemu_cortexm xpack_build_folder_relative_path + '/xpacks/@micro-os-plus/devices-qemu-cortexm', + + 'platform-qemu-cortex-m7f/meson/platform-options', ] # ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-cortex-m7f/meson/platform-options/meson.build b/tests/platform-qemu-cortex-m7f/meson/platform-options/meson.build new file mode 100644 index 0000000..d46726f --- /dev/null +++ b/tests/platform-qemu-cortex-m7f/meson/platform-options/meson.build @@ -0,0 +1,136 @@ +# ----------------------------------------------------------------------------- +# +# This file is part of the µOS++ distribution. +# (https://github.com/micro-os-plus/) +# Copyright (c) 2022 Liviu Ionescu. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose is hereby granted, under the terms of the MIT license. +# +# If a copy of the license was not distributed with this file, it can +# be obtained from https://opensource.org/licenses/MIT/. +# +# ----------------------------------------------------------------------------- + +message('Including platform-qemu-cortex-m7f common definitions...') + +# ----------------------------------------------------------------------------- + +_local_compile_args = [] # Common C/C++ args. +_local_compile_c_args = [] +_local_compile_cpp_args = [] +_local_include_directories = [] +_local_sources = [] +_local_compile_definitions = [] +_local_dependencies = [] +_local_link_args = [] +_local_link_with = [] + +# ----------------------------------------------------------------------------- + +_local_include_directories += [ + # Go back to the platform include. + '../../include', +] + +_local_sources += [ + # None. +] + +# Compiler definitions must passed as options. +_local_compile_definitions += [ + '-D' + xpack_platform_compile_definition, + + # Full POSIX conformance: + # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 + '-D_POSIX_C_SOURCE=200809L', + + # For S_IREAD + '-D_GNU_SOURCE' +] + +_local_compile_args += [ + # https://gcc.gnu.org/onlinedocs/gcc-11.3.0/gcc/ARM-Options.html#ARM-Options + '-mcpu=cortex-m7', + '-mthumb', + '-mfloat-abi=hard', + # '-mfloat-abi=soft', + + # '-fno-move-loop-invariants', + + # Embedded builds must be warning free. + '-Werror', +] + +if get_option('buildtype').contains('debug') + _local_compile_args += [ + '-fno-omit-frame-pointer' + ] +else + _local_compile_args += [ + # -flto fails with undefined reference to `_write', `_fstat`... + # '-flto' + ] +endif + +_local_compile_cpp_args += [ + # '-fno-exceptions', + # '-fno-rtti', + # '-fno-use-cxa-atexit', + '-fno-threadsafe-statics', +] + +_local_compile_c_args += common_options_dependency_compile_c_args +_local_compile_cpp_args += common_options_dependency_compile_cpp_args + +_local_link_args += [ + '-v', + + '-nostartfiles', + # '--specs=rdimon.specs', '-Wl,--start-group', '-lgcc', '-lc', '-lc', '-lm', '-lrdimon', '-Wl,--end-group', + + # Ensure the linker will keep the interrupt vectors which otherwise + # are not referred from anywhere. + # '-u_interrupt_vectors', + + # nano has no exceptions. + # '-specs=nano.specs' + + '-Wl,--gc-sections', + + # .elf has a LOAD segment with RWX permissions (GCC 12) + '-Wl,--no-warn-rwx-segments', + + # Path are relative to the build folder. + '-Txpacks/@micro-os-plus/devices-qemu-cortexm/linker-scripts/mem-mps2-an385.ld', + '-Txpacks/@micro-os-plus/architecture-cortexm/linker-scripts/sections-flash.ld', + # '-Txpacks/@micro-os-plus/architecture-cortexm/linker-scripts/sections-ram.ld', +] + +_local_dependencies += [ + common_options_dependency, + micro_os_plus_devices_qemu_cortexm_dependency, +] + +# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency +platform_qemu_cortex_m7f_dependency = declare_dependency( + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + compile_args: _local_compile_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_compile_args + _local_link_args, + link_with: _local_link_with, +) +platform_qemu_cortex_m7f_dependency_compile_c_args = _local_compile_c_args +platform_qemu_cortex_m7f_dependency_compile_cpp_args = _local_compile_cpp_args + +foreach xn : _local_include_directories + message('+ -I ' + xn) +endforeach +# Note: depenedencies compile_args not shown. +foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args + message('+ ' + xn) +endforeach +message('> platform_qemu_cortex_m7f_dependency') + +# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-riscv-rv32imac/meson.build b/tests/platform-qemu-riscv-rv32imac/meson.build index 925eb38..316ee04 100644 --- a/tests/platform-qemu-riscv-rv32imac/meson.build +++ b/tests/platform-qemu-riscv-rv32imac/meson.build @@ -23,47 +23,6 @@ xpack_create_listing = false xpack_create_hex = false # ----------------------------------------------------------------------------- -# Define the platform library. - -xpack_common_args = [] -xpack_include_directories = [] -xpack_sources = [] -xpack_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -xpack_include_directories += [ - 'include', -] - -xpack_sources += [ -] - -xpack_compile_definitions += [ - '-D' + xpack_platform_compile_definition, -] - -# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency -platform_qemu_riscv_rv32imac_dependency = declare_dependency( - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - compile_args: xpack_common_args + xpack_compile_definitions, - dependencies: [ - micro_os_plus_devices_qemu_riscv_dependency, - ] -) - -foreach xn : xpack_include_directories - message('+ -I ' + xn) -endforeach -# Note: depenedencies compile_args not shown. -foreach xn : xpack_sources + xpack_common_args + xpack_compile_definitions - message('+ ' + xn) -endforeach -message('> platform_qemu_riscv_rv32imac_dependency') - -# ============================================================================= -# Define the tests executables. # Get the command names from the toolchain file. size = find_program('size') @@ -72,55 +31,44 @@ objcopy = find_program('objcopy') # ----------------------------------------------------------------------------- +# Define the tests executables. + test_names = [ 'sample-test', 'unit-test' ] foreach name : test_names - xpack_common_args = [] - xpack_c_args = [] - xpack_cpp_args = [] - xpack_include_directories = [] - xpack_sources = [] - xpack_compile_definitions = [] - xpack_dependencies = [] - xpack_link_args = [] - xpack_link_with = [] + _local_compile_args = [] # Common C/C++ args. + _local_compile_c_args = [] + _local_compile_cpp_args = [] + _local_include_directories = [] + _local_sources = [] + _local_compile_definitions = [] + _local_dependencies = [] + _local_link_args = [] + _local_link_with = [] # --------------------------------------------------------------------------- - xpack_include_directories += [ + _local_include_directories += [ '../include', ] - xpack_sources += [ + _local_sources += [ '../src/' + name + '.cpp', ] - # xpack_c_args += micro_os_plus_utils_lists_dependency_c_args - # xpack_cpp_args += micro_os_plus_utils_lists_dependency_cpp_args - - xpack_link_args += [ - '-nostartfiles', - - # Ensure the linker will keep the interrupt vectors which otherwise - # are not referred from anywhere. - # '-u_interrupt_vectors', - - # nano has no exceptions. - # '-specs=nano.specs' + _local_compile_c_args += platform_qemu_riscv_rv32imac_dependency_compile_c_args + _local_compile_cpp_args += platform_qemu_riscv_rv32imac_dependency_compile_cpp_args - '-Wl,--gc-sections', + _local_compile_c_args += micro_os_plus_micro_test_plus_dependency_compile_c_args + _local_compile_cpp_args += micro_os_plus_micro_test_plus_dependency_compile_cpp_args + _local_link_args += [ '-Wl,-Map,'+ name + '-map.txt', # '-v', - - # Path are relative to the build folder. - '-Txpacks/@micro-os-plus/devices-qemu-riscv/linker-scripts/mem-virt-rv32.ld', - # '-Txpacks/@micro-os-plus/architecture-riscv/linker-scripts/sections-flash.ld', - '-Txpacks/@micro-os-plus/architecture-riscv/linker-scripts/sections-ram.ld', ] - xpack_dependencies += [ + _local_dependencies += [ # Tested library. micro_os_plus_micro_test_plus_dependency, @@ -128,13 +76,7 @@ foreach name : test_names micro_os_plus_diag_trace_dependency, ] - if name == 'unit-test' - xpack_dependencies += [ - micro_os_plus_micro_test_plus_dependency, - ] - endif - - xpack_dependencies += [ + _local_dependencies += [ # Platform specific dependencies. platform_qemu_riscv_rv32imac_dependency, # bring device & architecture too @@ -142,29 +84,24 @@ foreach name : test_names micro_os_plus_startup_dependency, ] - xpack_link_with += [ - # Tested library. - # micro_os_plus_utils_lists_static, - ] - # https://mesonbuild.com/Reference-manual.html#executable exe = executable( name, - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - c_args: xpack_common_args + xpack_c_args + xpack_compile_definitions, - cpp_args: xpack_common_args + xpack_cpp_args + xpack_compile_definitions, - dependencies: xpack_dependencies, - link_args: xpack_link_args, - link_with: xpack_link_with, + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + c_args: _local_compile_args + _local_compile_c_args + _local_compile_definitions, + cpp_args: _local_compile_args + _local_compile_cpp_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_link_args, + link_with: _local_link_with, name_suffix: 'elf', ) - foreach xn : xpack_include_directories + foreach xn : _local_include_directories message('A+ -I ' + xn) endforeach # Note: depenedencies compile_args not shown. - foreach xn : xpack_sources + xpack_common_args + xpack_c_args + xpack_cpp_args + xpack_compile_definitions + xpack_link_args + foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args message('A+ ' + xn) endforeach message('A> ' + name) diff --git a/tests/platform-qemu-riscv-rv32imac/meson/common/meson.build b/tests/platform-qemu-riscv-rv32imac/meson/common/meson.build deleted file mode 100644 index bdba6ad..0000000 --- a/tests/platform-qemu-riscv-rv32imac/meson/common/meson.build +++ /dev/null @@ -1,114 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# This file is part of the µOS++ distribution. -# (https://github.com/micro-os-plus/) -# Copyright (c) 2022 Liviu Ionescu. All rights reserved. -# -# Permission to use, copy, modify, and/or distribute this software -# for any purpose is hereby granted, under the terms of the MIT license. -# -# If a copy of the license was not distributed with this file, it can -# be obtained from https://opensource.org/licenses/MIT/. -# -# ----------------------------------------------------------------------------- - -# Definitions required for compiling all files, thus the use of -# add_global_*() functions. -# Must be added with subdir() before creating any library or executable. - -message('Including platform-qemu-riscv-rv32imac common definitions...') - -# ----------------------------------------------------------------------------- - -# Required in devices-qemu-riscv. -xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_RISCV_RV32IMAC' - -xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_RISCV_RV32IMAC' - -# ----------------------------------------------------------------------------- - -xpack_platform_common_args = [] -xpack_platform_common_c_args = [] -xpack_platform_common_cpp_args = [] -xpack_platform_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -# Compiler definitions must passed as options. -xpack_platform_compile_definitions += [ - '-D' + xpack_platform_compile_definition, - - # Full POSIX conformance: - # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 - '-D_POSIX_C_SOURCE=200809L', -] - -xpack_platform_common_args += [ - # https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Options.html - # The compiler matches rv32gc, but better use the explicit string. - '-march=rv32imac_zicsr', - '-mabi=ilp32', - '-mcmodel=medany', - '-msmall-data-limit=8', - - # '-fno-move-loop-invariants', - - # Embedded builds must be warning free. - '-Werror', -] - -if get_option('buildtype').contains('debug') - xpack_platform_common_args += [ - '-fno-omit-frame-pointer' - ] -else - xpack_platform_common_args += [ - # (.text._write_r+0x14): undefined reference to `_write' - # (.text._write_r+0x14): relocation truncated to fit: R_RISCV_GPREL_I against undefined symbol `_write' - # '-flto' - ] -endif - -xpack_platform_common_cpp_args += [ - '-fno-exceptions', - # '-fno-rtti', - # '-fno-use-cxa-atexit', - - '-fno-threadsafe-statics', -] - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_compile_definitions, - - language: [ 'c' ] -) - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions, - - language: [ 'cpp' ] -) - -foreach xn : xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions - message('G+ ' + xn) -endforeach - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_c_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'c' ] -) - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'cpp' ] -) - -# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-riscv-rv32imac/meson/dependencies/meson.build b/tests/platform-qemu-riscv-rv32imac/meson/dependencies-folders/meson.build similarity index 71% rename from tests/platform-qemu-riscv-rv32imac/meson/dependencies/meson.build rename to tests/platform-qemu-riscv-rv32imac/meson/dependencies-folders/meson.build index b81eaf4..b3b547c 100644 --- a/tests/platform-qemu-riscv-rv32imac/meson/dependencies/meson.build +++ b/tests/platform-qemu-riscv-rv32imac/meson/dependencies-folders/meson.build @@ -12,7 +12,16 @@ # # ----------------------------------------------------------------------------- -# Add the platform dependencies. +# Define a list of folders where the platform dependencies are located. + +# ----------------------------------------------------------------------------- + +# Required in devices-qemu-riscv. +xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_RISCV_RV32IMAC' + +xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_RISCV_RV32IMAC' + +# ----------------------------------------------------------------------------- # The base folder is tests. The order is significative. xpack_dependencies_folders = [ @@ -32,6 +41,8 @@ xpack_dependencies_folders = [ # - xpack_build_folder_relative_path + '/xpacks/@micro-os-plus/devices-qemu-riscv', + + 'platform-qemu-riscv-rv32imac/meson/platform-options', ] # ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-riscv-rv32imac/meson/platform-options/meson.build b/tests/platform-qemu-riscv-rv32imac/meson/platform-options/meson.build new file mode 100644 index 0000000..f33530c --- /dev/null +++ b/tests/platform-qemu-riscv-rv32imac/meson/platform-options/meson.build @@ -0,0 +1,137 @@ +# ----------------------------------------------------------------------------- +# +# This file is part of the µOS++ distribution. +# (https://github.com/micro-os-plus/) +# Copyright (c) 2022 Liviu Ionescu. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose is hereby granted, under the terms of the MIT license. +# +# If a copy of the license was not distributed with this file, it can +# be obtained from https://opensource.org/licenses/MIT/. +# +# ----------------------------------------------------------------------------- + +message('Including platform-qemu-riscv-rv32imac common definitions...') + +# ----------------------------------------------------------------------------- + +_local_compile_args = [] # Common C/C++ args. +_local_compile_c_args = [] +_local_compile_cpp_args = [] +_local_include_directories = [] +_local_sources = [] +_local_compile_definitions = [] +_local_dependencies = [] +_local_link_args = [] +_local_link_with = [] + +# ----------------------------------------------------------------------------- + +_local_include_directories += [ + # Go back to the platform include. + '../../include', +] + +_local_sources += [ + # None. +] + +# Compiler definitions must passed as options. +_local_compile_definitions += [ + '-D' + xpack_platform_compile_definition, + + # Full POSIX conformance: + # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 + '-D_POSIX_C_SOURCE=200809L', + + # For S_IREAD + '-D_GNU_SOURCE' +] + +_local_compile_args += [ + # https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Options.html + # The compiler matches rv32gc, but better use the explicit string. + '-march=rv32imac_zicsr', + '-mabi=ilp32', + '-mcmodel=medany', + '-msmall-data-limit=8', + + # '-fno-move-loop-invariants', + + # Embedded builds must be warning free. + '-Werror', +] + +if get_option('buildtype').contains('debug') + _local_compile_args += [ + '-fno-omit-frame-pointer' + ] +else + _local_compile_args += [ + # -flto fails with undefined reference to `_write', `_fstat`... + # '-flto' + ] +endif + +_local_compile_cpp_args += [ + '-fno-exceptions', + # '-fno-rtti', + # '-fno-use-cxa-atexit', + '-fno-threadsafe-statics', +] + +_local_compile_c_args += common_options_dependency_compile_c_args +_local_compile_cpp_args += common_options_dependency_compile_cpp_args + +_local_link_args += [ + '-v', + + '-nostartfiles', + # '--specs=rdimon.specs', '-Wl,--start-group', '-lgcc', '-lc', '-lc', '-lm', '-lrdimon', '-Wl,--end-group', + + # Ensure the linker will keep the interrupt vectors which otherwise + # are not referred from anywhere. + # '-u_interrupt_vectors', + + # nano has no exceptions. + # '-specs=nano.specs' + + '-Wl,--gc-sections', + + # .elf has a LOAD segment with RWX permissions (GCC 12) + '-Wl,--no-warn-rwx-segments', + + # Path are relative to the build folder. + '-Txpacks/@micro-os-plus/devices-qemu-riscv/linker-scripts/mem-virt-rv32.ld', + # '-Txpacks/@micro-os-plus/architecture-riscv/linker-scripts/sections-flash.ld', + '-Txpacks/@micro-os-plus/architecture-riscv/linker-scripts/sections-ram.ld', +] + +_local_dependencies += [ + common_options_dependency, + micro_os_plus_devices_qemu_riscv_dependency, +] + +# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency +platform_qemu_riscv_rv32imac_dependency = declare_dependency( + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + compile_args: _local_compile_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_compile_args + _local_link_args, + link_with: _local_link_with, +) +platform_qemu_riscv_rv32imac_dependency_compile_c_args = _local_compile_c_args +platform_qemu_riscv_rv32imac_dependency_compile_cpp_args = _local_compile_cpp_args + +foreach xn : _local_include_directories + message('+ -I ' + xn) +endforeach +# Note: depenedencies compile_args not shown. +foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args + message('+ ' + xn) +endforeach +message('> platform_qemu_riscv_rv32imac_dependency') + +# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-riscv-rv64imafdc/meson.build b/tests/platform-qemu-riscv-rv64imafdc/meson.build index 98246bf..884a6bb 100644 --- a/tests/platform-qemu-riscv-rv64imafdc/meson.build +++ b/tests/platform-qemu-riscv-rv64imafdc/meson.build @@ -23,47 +23,6 @@ xpack_create_listing = false xpack_create_hex = false # ----------------------------------------------------------------------------- -# Define the platform library. - -xpack_common_args = [] -xpack_include_directories = [] -xpack_sources = [] -xpack_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -xpack_include_directories += [ - 'include', -] - -xpack_sources += [ -] - -xpack_compile_definitions += [ - '-D' + xpack_platform_compile_definition, -] - -# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency -platform_qemu_riscv_rv64imafdc_dependency = declare_dependency( - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - compile_args: xpack_common_args + xpack_compile_definitions, - dependencies: [ - micro_os_plus_devices_qemu_riscv_dependency, - ] -) - -foreach xn : xpack_include_directories - message('+ -I ' + xn) -endforeach -# Note: depenedencies compile_args not shown. -foreach xn : xpack_sources + xpack_common_args + xpack_compile_definitions - message('+ ' + xn) -endforeach -message('> platform_qemu_riscv_rv64imafdc_dependency') - -# ============================================================================= -# Define the tests executables. # Get the command names from the toolchain file. size = find_program('size') @@ -72,55 +31,44 @@ objcopy = find_program('objcopy') # ----------------------------------------------------------------------------- +# Define the tests executables. + test_names = [ 'sample-test', 'unit-test' ] foreach name : test_names - xpack_common_args = [] - xpack_c_args = [] - xpack_cpp_args = [] - xpack_include_directories = [] - xpack_sources = [] - xpack_compile_definitions = [] - xpack_dependencies = [] - xpack_link_args = [] - xpack_link_with = [] + _local_compile_args = [] # Common C/C++ args. + _local_compile_c_args = [] + _local_compile_cpp_args = [] + _local_include_directories = [] + _local_sources = [] + _local_compile_definitions = [] + _local_dependencies = [] + _local_link_args = [] + _local_link_with = [] # --------------------------------------------------------------------------- - xpack_include_directories += [ + _local_include_directories += [ '../include', ] - xpack_sources += [ + _local_sources += [ '../src/' + name + '.cpp', ] - # xpack_c_args += micro_os_plus_utils_lists_dependency_c_args - # xpack_cpp_args += micro_os_plus_utils_lists_dependency_cpp_args - - xpack_link_args += [ - '-nostartfiles', - - # Ensure the linker will keep the interrupt vectors which otherwise - # are not referred from anywhere. - # '-u_interrupt_vectors', - - # nano has no exceptions. - # '-specs=nano.specs' + _local_compile_c_args += platform_qemu_riscv_rv64imafdc_dependency_compile_c_args + _local_compile_cpp_args += platform_qemu_riscv_rv64imafdc_dependency_compile_cpp_args - '-Wl,--gc-sections', + _local_compile_c_args += micro_os_plus_micro_test_plus_dependency_compile_c_args + _local_compile_cpp_args += micro_os_plus_micro_test_plus_dependency_compile_cpp_args + _local_link_args += [ '-Wl,-Map,'+ name + '-map.txt', # '-v', - - # Path are relative to the build folder. - '-Txpacks/@micro-os-plus/devices-qemu-riscv/linker-scripts/mem-virt-rv64.ld', - # '-Txpacks/@micro-os-plus/architecture-riscv/linker-scripts/sections-flash.ld', - '-Txpacks/@micro-os-plus/architecture-riscv/linker-scripts/sections-ram.ld', ] - xpack_dependencies += [ + _local_dependencies += [ # Tested library. micro_os_plus_micro_test_plus_dependency, @@ -128,13 +76,7 @@ foreach name : test_names micro_os_plus_diag_trace_dependency, ] - if name == 'unit-test' - xpack_dependencies += [ - micro_os_plus_micro_test_plus_dependency, - ] - endif - - xpack_dependencies += [ + _local_dependencies += [ # Platform specific dependencies. platform_qemu_riscv_rv64imafdc_dependency, # bring device & architecture too @@ -142,29 +84,24 @@ foreach name : test_names micro_os_plus_startup_dependency, ] - xpack_link_with += [ - # Tested library. - # micro_os_plus_utils_lists_static, - ] - # https://mesonbuild.com/Reference-manual.html#executable exe = executable( name, - include_directories: include_directories(xpack_include_directories), - sources: files(xpack_sources), - c_args: xpack_common_args + xpack_c_args + xpack_compile_definitions, - cpp_args: xpack_common_args + xpack_cpp_args + xpack_compile_definitions, - dependencies: xpack_dependencies, - link_args: xpack_link_args, - link_with: xpack_link_with, + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + c_args: _local_compile_args + _local_compile_c_args + _local_compile_definitions, + cpp_args: _local_compile_args + _local_compile_cpp_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_link_args, + link_with: _local_link_with, name_suffix: 'elf', ) - foreach xn : xpack_include_directories + foreach xn : _local_include_directories message('A+ -I ' + xn) endforeach # Note: depenedencies compile_args not shown. - foreach xn : xpack_sources + xpack_common_args + xpack_c_args + xpack_cpp_args + xpack_compile_definitions + xpack_link_args + foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args message('A+ ' + xn) endforeach message('A> ' + name) diff --git a/tests/platform-qemu-riscv-rv64imafdc/meson/common/meson.build b/tests/platform-qemu-riscv-rv64imafdc/meson/common/meson.build deleted file mode 100644 index 04538fc..0000000 --- a/tests/platform-qemu-riscv-rv64imafdc/meson/common/meson.build +++ /dev/null @@ -1,114 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# This file is part of the µOS++ distribution. -# (https://github.com/micro-os-plus/) -# Copyright (c) 2022 Liviu Ionescu. All rights reserved. -# -# Permission to use, copy, modify, and/or distribute this software -# for any purpose is hereby granted, under the terms of the MIT license. -# -# If a copy of the license was not distributed with this file, it can -# be obtained from https://opensource.org/licenses/MIT/. -# -# ----------------------------------------------------------------------------- - -# Definitions required for compiling all files, thus the use of -# add_global_*() functions. -# Must be added with subdir() before creating any library or executable. - -message('Including platform-qemu-riscv-rv64imafdc common definitions...') - -# ----------------------------------------------------------------------------- - -# Required in devices-qemu-riscv. -xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_RISCV_RV64IMAFDC' - -xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_RISCV_RV64IMAFDC' - -# ----------------------------------------------------------------------------- - -xpack_platform_common_args = [] -xpack_platform_common_c_args = [] -xpack_platform_common_cpp_args = [] -xpack_platform_compile_definitions = [] - -# ----------------------------------------------------------------------------- - -# Compiler definitions must passed as options. -xpack_platform_compile_definitions += [ - '-D' + xpack_platform_compile_definition, - - # Full POSIX conformance: - # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 - '-D_POSIX_C_SOURCE=200809L', -] - -xpack_platform_common_args += [ - # https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Options.html - # Do not use rv64gc, the compiler does not match it as rv64imafdc. - '-march=rv64imafdc_zicsr', - '-mabi=lp64d', - '-mcmodel=medany', - '-msmall-data-limit=8', - - # '-fno-move-loop-invariants', - - # Embedded builds must be warning free. - '-Werror', -] - -if get_option('buildtype').contains('debug') - xpack_platform_common_args += [ - '-fno-omit-frame-pointer' - ] -else - xpack_platform_common_args += [ - # (.text._write_r+0x14): undefined reference to `_write' - # (.text._write_r+0x14): relocation truncated to fit: R_RISCV_GPREL_I against undefined symbol `_write' - # '-flto' - ] -endif - -xpack_platform_common_cpp_args += [ - '-fno-exceptions', - # '-fno-rtti', - # '-fno-use-cxa-atexit', - - '-fno-threadsafe-statics', -] - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_compile_definitions, - - language: [ 'c' ] -) - -add_global_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions, - - language: [ 'cpp' ] -) - -foreach xn : xpack_platform_common_args + xpack_platform_common_c_args + xpack_platform_common_cpp_args + xpack_platform_compile_definitions - message('G+ ' + xn) -endforeach - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_c_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'c' ] -) - -add_global_link_arguments( - xpack_platform_common_args + xpack_platform_common_cpp_args, - - # .elf has a LOAD segment with RWX permissions (GCC 12) - '-Wl,--no-warn-rwx-segments', - - language: [ 'cpp' ] -) - -# ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-riscv-rv64imafdc/meson/dependencies/meson.build b/tests/platform-qemu-riscv-rv64imafdc/meson/dependencies-folders/meson.build similarity index 71% rename from tests/platform-qemu-riscv-rv64imafdc/meson/dependencies/meson.build rename to tests/platform-qemu-riscv-rv64imafdc/meson/dependencies-folders/meson.build index b81eaf4..16421dc 100644 --- a/tests/platform-qemu-riscv-rv64imafdc/meson/dependencies/meson.build +++ b/tests/platform-qemu-riscv-rv64imafdc/meson/dependencies-folders/meson.build @@ -12,7 +12,16 @@ # # ----------------------------------------------------------------------------- -# Add the platform dependencies. +# Define a list of folders where the platform dependencies are located. + +# ----------------------------------------------------------------------------- + +# Required in devices-qemu-riscv. +xpack_device_compile_definition='MICRO_OS_PLUS_DEVICE_QEMU_RISCV_RV64IMAFDC' + +xpack_platform_compile_definition = 'MICRO_OS_PLUS_PLATFORM_QEMU_RISCV_RV64IMAFDC' + +# ----------------------------------------------------------------------------- # The base folder is tests. The order is significative. xpack_dependencies_folders = [ @@ -32,6 +41,8 @@ xpack_dependencies_folders = [ # - xpack_build_folder_relative_path + '/xpacks/@micro-os-plus/devices-qemu-riscv', + + 'platform-qemu-riscv-rv64imafdc/meson/platform-options', ] # ----------------------------------------------------------------------------- diff --git a/tests/platform-qemu-riscv-rv64imafdc/meson/platform-options/meson.build b/tests/platform-qemu-riscv-rv64imafdc/meson/platform-options/meson.build new file mode 100644 index 0000000..3119280 --- /dev/null +++ b/tests/platform-qemu-riscv-rv64imafdc/meson/platform-options/meson.build @@ -0,0 +1,137 @@ +# ----------------------------------------------------------------------------- +# +# This file is part of the µOS++ distribution. +# (https://github.com/micro-os-plus/) +# Copyright (c) 2022 Liviu Ionescu. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose is hereby granted, under the terms of the MIT license. +# +# If a copy of the license was not distributed with this file, it can +# be obtained from https://opensource.org/licenses/MIT/. +# +# ----------------------------------------------------------------------------- + +message('Including platform-qemu-riscv-rv64imafdc common definitions...') + +# ----------------------------------------------------------------------------- + +_local_compile_args = [] # Common C/C++ args. +_local_compile_c_args = [] +_local_compile_cpp_args = [] +_local_include_directories = [] +_local_sources = [] +_local_compile_definitions = [] +_local_dependencies = [] +_local_link_args = [] +_local_link_with = [] + +# ----------------------------------------------------------------------------- + +_local_include_directories += [ + # Go back to the platform include. + '../../include', +] + +_local_sources += [ + # None. +] + +# Compiler definitions must passed as options. +_local_compile_definitions += [ + '-D' + xpack_platform_compile_definition, + + # Full POSIX conformance: + # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_03 + '-D_POSIX_C_SOURCE=200809L', + + # For S_IREAD + '-D_GNU_SOURCE' +] + +_local_compile_args += [ + # https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Options.html + # Do not use rv64gc, the compiler does not match it as rv64imafdc. + '-march=rv64imafdc_zicsr', + '-mabi=lp64d', + '-mcmodel=medany', + '-msmall-data-limit=8', + + # '-fno-move-loop-invariants', + + # Embedded builds must be warning free. + '-Werror', +] + +if get_option('buildtype').contains('debug') + _local_compile_args += [ + '-fno-omit-frame-pointer' + ] +else + _local_compile_args += [ + # -flto fails with undefined reference to `_write', `_fstat`... + # '-flto' + ] +endif + +_local_compile_cpp_args += [ + '-fno-exceptions', + # '-fno-rtti', + # '-fno-use-cxa-atexit', + '-fno-threadsafe-statics', +] + +_local_compile_c_args += common_options_dependency_compile_c_args +_local_compile_cpp_args += common_options_dependency_compile_cpp_args + +_local_link_args += [ + '-v', + + '-nostartfiles', + # '--specs=rdimon.specs', '-Wl,--start-group', '-lgcc', '-lc', '-lc', '-lm', '-lrdimon', '-Wl,--end-group', + + # Ensure the linker will keep the interrupt vectors which otherwise + # are not referred from anywhere. + # '-u_interrupt_vectors', + + # nano has no exceptions. + # '-specs=nano.specs' + + '-Wl,--gc-sections', + + # .elf has a LOAD segment with RWX permissions (GCC 12) + '-Wl,--no-warn-rwx-segments', + + # Path are relative to the build folder. + '-Txpacks/@micro-os-plus/devices-qemu-riscv/linker-scripts/mem-virt-rv64.ld', + # '-Txpacks/@micro-os-plus/architecture-riscv/linker-scripts/sections-flash.ld', + '-Txpacks/@micro-os-plus/architecture-riscv/linker-scripts/sections-ram.ld', +] + +_local_dependencies += [ + common_options_dependency, + micro_os_plus_devices_qemu_riscv_dependency, +] + +# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency +platform_qemu_riscv_rv64imafdc_dependency = declare_dependency( + include_directories: include_directories(_local_include_directories), + sources: files(_local_sources), + compile_args: _local_compile_args + _local_compile_definitions, + dependencies: _local_dependencies, + link_args: _local_compile_args + _local_link_args, + link_with: _local_link_with, +) +platform_qemu_riscv_rv64imafdc_dependency_compile_c_args = _local_compile_c_args +platform_qemu_riscv_rv64imafdc_dependency_compile_cpp_args = _local_compile_cpp_args + +foreach xn : _local_include_directories + message('+ -I ' + xn) +endforeach +# Note: depenedencies compile_args not shown. +foreach xn : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args + _local_link_args + message('+ ' + xn) +endforeach +message('> platform_qemu_riscv_rv64imafdc_dependency') + +# -----------------------------------------------------------------------------