Follow the same convention as that of ccache.
Improve readability of boilerplate.cmake file.
Move inclusion of version.cmake up to satisfy git.cmake dependency.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Cosmetics, no functional change expected.
Fixed leading space alignment.
Replaced tabs with spaces.
Emulation error message output is now aligned.
To locate tabs in cmake, the following bash is useful:
grep -PRil "\t" * | grep -i cmake | grep -v ^sanity
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Aid user in understanding what CMake expects of:
* Document and add CMAKE_SYSTEM_VERSION
* Document CMAKE_SYSTEM_NAME
* Document CMAKE_SYSTEM_PROCESSOR
* Document BUILD_SHARED_LIBS
* Document Policies CMP0002, CMP0079
CMAKE_SYSTEM_VERSION is required officially by CMake, but appears
unused -- at least now we are compliant.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
CheckCCompilerFlag and CheckCXXCompilerFlag does not belong to
extensions.cmake since they are standard CMake files. Boilerplate
seems more appropriate.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Split up the toolchain configuration into two phases, generic and
target. The 'generic' phase configures the toolchain just enough to be
able to preprocess DT files. The 'target' phase completes the
configuration with target-specific configuration.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
In CMake 3.13 a warning is produced if one does not explicitly state
what the policy for CMP0079 should be. To resolve this warning we set
policy CMP0079 to OLD.
This is expected to have no semantical change. When we want a
semantical change we can flip the policy and port the build scripts to
the new behaviour.
This fixes#11794
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This patch creates a rule in the cmake to trigger the generation
of linker_relocate.ld and code_relocation.c files.
The linker_relocate.ld will create appropriate sections and will
link the required functions or variables from all the selected
files.
The code_relocation.c will have code that is needed for
initializing data sections and copy of text sections(if XIP).
Also this will contain code that is needed for zeroing of bss.
The procedure to invoke this feature is:
1. Enable CONFIG_CODE_RELOCATION in the prj.conf
2. Inside CMakeList.txt in the project we need to mention
all the files that needs to get relocated.
zephyr_kernel_code_relocate(src/*.c SRAM2)
Where the first argument is the file/files and the second
argument is the memory where it has be placed.
NOTE: The file argument supports glob expressions.
NOTE: Step 2 can be done as many times as required. And relative
paths can be given here.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
Move libapp.a into it's own directory. This would make it's placement
consistent with how zephyr.elf is placed.
E.g. it might now look like:
ls b/*
b/build.ninja b/CMakeCache.txt b/cmake_install.cmake b/rules.ninja
b/app:
libapp.a
b/CMakeFiles:
3.12.0 cmake.check_cache CMakeOutput.log TargetDirectories.txt
app.dir CMakeError.log CMakeTmp
b/zephyr:
arch kernel subsys
boards lib tests
cmake liboffsets.a zephyr.bin
CMakeFiles libzephyr.a zephyr.elf
cmake_install.cmake linker.cmd zephyr.hex
ext linker_pass_final.cmd zephyr.map
include linker_pass_final.cmd.dep zephyr_prebuilt.elf
isrList.bin misc zephyr.stat
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
The 'FindPythonInterp' that is distributed with CMake 3.8 is affected
by bug: https://github.com/zephyrproject-rtos/zephyr/issues/11103
To work around this, until we upgrade to 3.13, we copy and patch the
3.8 version of 'FindPythonInterp' into the Zephyr repository.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
CMake prints a helpful error message with all the boards supported
when a board name has been misspelled. But CMake also
remembers (caches) the corrupted board name and refuses to change it
until the board directory has been cleared.
CMake is rightly hesitant to change the board, as other cached
variables depend on what the board is. But it is safe to change the
board just after it has been selected, because we verify it's
correctness before using it to calculate other variables.
So to support the use-case of changing a misspelled board
name (without clearing the build directory) we unset the cached board
when it is invalid.
Also; change the now unused (in-tree) macro 'assert_with_usage' to
'print_usage'.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
MSYS support was added as a stop-gap while native windows support was
unsupported. Now that Native windows support is stable we can drop
support for MSYS.
Dropping support for MSYS fixes#11260 and allows us to spend more
resources on native windows support.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Introduce new Kconfig option for selecting either slip or ethernet
connectivity to host.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When Python3 is not found the build system will warn the user and then
continue. Python3 is required and continuing can only confuse the user
with new off-topic error messages.
This patch denotes Python3 as required to resolve this.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
1. The generator handles just the COMPILE_DEFINITIONS.
(See: __ZEPHYR_SUPERVISOR__)
For the defines in INTERFACE_COMPILE_DEFINITIONS
a special handling is necessary.
Solution:
The amendment function generates a macro header file
${CMAKE_BINARY_DIR}/zephyr/include/generated/cmake_intdef.h
based on INTERFACE_COMPILE_DEFINITIONS and appends the
defines from the file to
CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS.
2. Eclipse CDT4 indexer has problems with CMake 'Eclipse CDT4 - x'
generator projects that use mixed C/C++.
The Eclipse CDT4 indexer is showing a lot of unresolved symbol
errors, when the project was created with CMake generator and
the code is a mix of C and C++.
The root cause of the problem is the g++ built-in __cplusplus macro,
that is passed by CMake generator in the '.cproject' file.
The defines in '.cproject' are always the same for C and C++.
In mixed C/C++ projects, the header files often contain the following
lines to let C++ code call the C functions:
#ifdef __cplusplus
extern "C" {
#endif
< header content >
#ifdef __cplusplus
}
#endif
Whenever the Eclipse CDT4 indexer compiles the code for
code analysis, it has the macro __cplusplus set,
independent of whether standard C or C++ source files are compiled.
The 'extern "C"' confuses the standard C compilation and the indexer
is messed up.
Solution:
The amendment function deletes the __cplusplus entry from
CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS.
3. The amendment function appends the defines from
${CMAKE_BINARY_DIR}/zephyr/include/generated/autoconf.h to
CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS.
Signed-off-by: Istvan Bisz <istvan.bisz@t-online.hu>
The deprecation warning has existed for 1 release and 3 months, giving
users plenty of time to be warned.
This reverts commit 9c93e8e87b.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
It is very inconvenient to maintain an application that both runs on a
Zephyr board and an out-of-tree board.
It forces one to write build scripts like this in the app:
if(BOARD STREQUAL my_out_of_tree_board)
set(BOARD_ROOT some/out/of/tree/board/path)
endif()
To avoid this we change the semantics of BOARD_ROOT. Instead of it
being a path to the board root it is now a prioritized list of board
root directories. Zephyr will append ZEPHYR_BASE to BOARD_ROOT.
This ensures that Zephyr boards can be used when the out-of-tree board
directory can not supply the requested board.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
The commit 1b80f00f56 made git describe
failure as fatal. But a failure can happens when no tag is in a
repository. And such a repository might exist for a internal build
system or some test environments.
Zephyr's build system is capable building without a commit hash.
This commit makes it non-fatal again and inform users that the build
system is failed to execute "git describe" but continues building with
KERNEL_VERSION_STRING.
Signed-off-by: Yasushi SHOJI <y-shoji@ispace-inc.com>
A confusing warning has popped up since 3.13. It can be observed as
so:
Zephyr version: 1.13.99
Parsing Kconfig tree in /home/sebo/zephyr/Kconfig
Merging /home/sebo/zephyr/samples/hello_world/prj.conf
warning: tag 'zephyr-v1.13.0' is really 'v1.13.0' here
-- Generating zephyr/include/generated/generated_dts_board.h
This warning is more confusing than useful so we suppress stderr from
'git describe' when the command runs successfully.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Always print the note to make sure it isn't missed, but make it easy to
disable (by creating an empty file).
The note will be removed later.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
CMake has several prototypes/signatures for the function
'target_link_libraries'. This commit migrates the usage of
'target_link_libraries' on Zephyr CMake libraries from the old 'plain'
signature to the new '<PRIVATE|PUBLIC|INTERFACE>' signature.
For technical reasons the two signatures can not be mixed. Each
library must exclusively use either the old or new signature.
The 'old' plain signature is equivalent to using the PUBLIC
signature. Migrating to use 'PUBLIC' is therefore expected to be a
safe change.
After the migration it will be possible to use the PRIVATE and
INTERFACE signatures on Zephyr CMake libraries. This is useful for
instance to fix issue 8438.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Older Git versions still do not support the -C argument for specifying
the working directory. Switch to using cmake WORKING_DIRECTORY instead.
This fixes#7287 again after commit 5e7e1cb.
Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
The "git describe" call for setting the boot banner is broken. The
--work-tree option sets the checked out work tree, not the directory
containing .git, which is where git describe needs to look for
information on tags.
Use -C instead so it's as if Git were run from the zephyr base
directory instead.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Both variables were used (with the same value) interchangeably
throughout CMake files and per the discussion in GH issue,
ZEPHYR_BASE is preferred.
Also add a comment with explanation of one vs. the other.
Tested by building hello_world for several boards ensuring no errors.
Fixes#7173.
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Older Git versions do not support the -C argument for specifying the
working directory. Switch to using --work-tree instead.
This fixes#7287.
Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
Instead of using a module that tries to do too many things that break
in different places, keep it simple and just call git describe.
This fixes#7044 and fixes#7207.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
To improve the build system's "clean build" runtime we need to cache
files in a directory outside of the build directory.
Caching files outside of the build directory is is already being done
to a certain degree today. For instance, if a user has installed
ccache it will cache files in $HOME/.ccache/.
This commit locates a directory that is suitable for caching files in
a cross-platform way. For instance on Linux this is believed to be
$HOME, on Windows this is believed to be %LOCALAPPDATA%.
If for whatever reason no environment variables are are found to be
suitable we fall back to using $ZEPHYR_BASE/.cache/. For users that
often use 'git -clean' the caching mechanism will not work as well,
but it will at least be better than no caching at all.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This uses the version and hash (git describe) and replaces the timestamp
currently used in the boot banner. This works much better than using
timestamps. It lets us point to the exact commit being used to run a
certain application or test.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Moving the ccache build script earlier in allows us to export ccache
to external projects. Using ccache with external projects, such as
OpenThread, can significantly speed up the build time.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
We need access to SOC_PATH in dts.cmake so we need to move the
definitions of SOC_NAME, SOC_SERIES, SOC_FAMILY, and SOC_PATH out of the
toplevel CMakeLists.txt and into cmake/app/boilerplate.cmake. We place
them before we include cmake/dts.cmake so they will be available to use
in it.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This is one way we can support out of tree board definitions. Basically
all this needs is a board definition in the application source directory
that follows the same structure we have in the main Zephyr tree (also
allowing multiple custom boards). An application tree would look like
this for example:
boards/
CMakeLists.txt
prj.conf
README.rst
src/
with boards following the same structure as in Zephyr:
.
├── boards
│ └── x86
│ └── arduino_101
│ ├── doc
│ │ └── img
│ └── support
└── src
To use this, you need to specify the BOARD_ROOT variable on the command
line when building:
cmake -DBOARD=<board name> -DBOARD_ROOT=<path to boards> ..
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This patch changes the manner in which we collect DTS overlay files so
that they comply with the same approach taken for configuration fragment
files (.conf).
Additionally it also documents the usage of those files in the
Application Developer Guide.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
CROSS_COMPILE is a KBuild feature that was dropped during the CMake
migration. It is now re-introduced. Documentation for it is still
lacking, but at least it now behaves as expected.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Instead of accessing the environment variable ZEPHYR_BASE every time we
require accessing the source code root, use an intermediate variable
that has OS path separators correctly set to '/' to avoid issues on
Windows.
Note: This removes the ZEPHYR_SOURCE_DIR CMake variable. External
applications using that will need to change to use the new ZEPHYR_BASE
variable.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Windows users have on multiple occasions cloned Zephyr using a Windows
git client. It seems that the windows git client defaults to
converting line endings from LF to CRLF when cloning repo's. This
breaks at least one of Zephyr's tools (Kconfig).
This patch introduces a sanity check of the environment for MSYS
users.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Now that MSYS2 ships with CMake 3.9.6 there's no need anymore to
downgrade the minimum required CMake version for it.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Depending on a path inside the Zephyr tree to determine if we are a test
does not scale. Also some samples were marked as TEST while they are
not, just to get some options defined for tests.
Idenitfying a test will be addressed in another patch introducing
CONFIG_TEST.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Introduce Zephyr interface libraries to fix#5351.
From the documentation:
A Zephyr interface library is a thin wrapper over a CMake INTERFACE
library. The most important responsibility of this abstraction is to
ensure that when a user KConfig-enables a library then the header
files of this library will be accessible to the 'app' library.
This is done because when a user uses Kconfig to enable a library he
expects to be able to include it's header files and call it's
functions out-of-the box.
A Zephyr interface library should be used when there exists some
build information (include directories, defines, compiler flags,
etc.) that should be applied to a set of Zephyr libraries and 'app'
might be one of these libraries.
Zephyr libraries must explicitly call
zephyr_library_link_libraries(<interface_library>) to use this build
information. 'app' is treated as a special case for usability
reasons; a Kconfig option (CONFIG_APP_LINK_WITH_<interface_library>)
should exist for each interface_library and will determine if 'app'
links with the interface_library.
This API has a constructor like the zephyr_library API has, but it
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
To indicate the generated binary is executable on the host, add .exe
extension to the generated ELF file.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The properties definitions were not doing much because they were
defined after they were used. They were actually overriding the true
properties with "".
Moving them earlier ensures that the properties behave as expected, as
documented global mutable variables.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
The various runners (flash/debug scripts) use environment variables to
take arguments. This is legacy behavior which is not desirable.
Use command line arguments instead.
Note: this leaves more general environment variables with publicly
documented behavior in place for now, for compatibility, e.g.:
ZEPHYR_FLASH_OVER_DFU, OPENSDA_FW, ESP_IDF_PATH, PYOCD_DAPARG
For example, when using dfu-util to flash arduino_101, instead of
setting DFUUTIL_PID, DFUUTIL_ALT, and DFUUTIL_IMG environment
variables, have the script invocation look like this:
python3 .../zephyr_flash_debug.py dfu-util flash \
[common arguments omitted] \
--pid=8087:0aba --alt=x86_app \
--img=.../build/zephyr/zephyr.bin
Make similar changes for other runners (openocd, etc.) and
targets (debug, debugserver).
To implement this in the scripts:
- have the individual scripts/support/runner/some-runner.py files
register their own command line arguments
- teach them to construct instances from arguments, not the
environment
- have zephyr_flash_debug.py request runners to register command
line argument parsers, and handle arguments
In the build system:
- add a new board_runner_args() extension function that board.cmake
files can use to add to the zephyr_flash_debug.py command line
- adjust cmake/flash/CMakeLists.txt to invoke with arguments
- add new helper include files for each runner (like
boards/common/dfu-util.board.cmake, etc.), which add default
options as needed and then add on overrides from
board_runner_args() calls
- update board.cmake files to use the new includes and extension
This implied some tweaking when using openocd to make the CMake string
escaping and unescaping work properly.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
The Python-based runners have replaced the old shell scripts. Refactor
the build system accordingly:
- FLASH_SCRIPT is now BOARD_FLASH_RUNNER
- DEBUG_SCRIPT is now BOARD_DEBUG_RUNNER
The values, rather than being the names of files, are now the names of
runners in scripts/support/runner. They are still short, descriptive
names like "openocd", "jlink", "em-starterkit", etc.
Adjust the zephyr_flash_debug.py call and runner internals
accordingly. Have each runner class report a name and the commands it
can handle. This lets us move some boilerplate from each do_run()
method into the common run() routine, and enables further improvements
in future patches.
The handles_command() method is temporary, and will be replaced by a
more general mechanism for describing runner capabilities in a
subsequent patch. The initial use case for extending this is to add
device tree awareness to the runners.
To try to avoid user confusion, abort the configuration if an
xxx_SCRIPT is defined.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Print the usage when an invalid board is given, this somewhat
allievates the catch-22 where you need to run CMake to know what
boards exist, but you need a board to run CMake.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>