Commit graph

598 commits

Author SHA1 Message Date
Daniel Leung 2ce9d81a88 cmake: xcc: fix compile warnings and errors
XCC does not support the "-undef" flag so set NOSYSDEF_CFLAGS to
empty string to fix compile warning.

Also, XCC does not supply the macro __SIZEOF_LONG__ which breaks
the build. So define it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2018-11-01 16:30:02 -04:00
Daniel Leung 3829cb5c41 cmake: parameterized flags to not include standard defines/files
Not all compiles/linkers support the GCC flags to not include standard
defines, include files and libraries. So make these parameters such
that the toolchain can define them when supported.

Also, according to documentation, -nostdlib does the same for both
-nostartfiles and -nodefaultlibs. So remove the redundant ones.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2018-11-01 16:30:02 -04:00
Sebastian Bøe 0f1b6ffbdd cmake: Make the target name generation code re-usable
The CMake extension 'generate_inc_file_for_target()' has some code for
generating a unique target name that is needed elsewhere, for instance
by DeviceTree.

Make the code re-usable by refactoring it out into it's own function.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-01 09:14:22 -04:00
Sebastian Bøe d5754d3d0d cmake: Enforce that the DTC is at least 1.4.6
The Zephyr SDK distributes a device-tree-compiler with version
"1.4.6-dirty". As of recently, we have started using flags that are
only present in recent versions of dtc. Like the flag "-E
unit_address_vs_reg".

Users that are opting out of using the Zephyr SDK's host tools are
reporting obscure error messages.

To avoid this we use an appropriate error message when the detected
version is unsupported.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-19 16:12:42 -04:00
Sebastian Bøe e7dcc9dec3 cmake: Re-write the capability database to avoid file appends
CI sometimes fails with a temporarily corrupted toolchain capabilitiy
database file. Although not proven, there is evidence that CMake's
file(APPEND does not work atomically when there are concurrent writes
and reads of a certain size.

To avoid file appending, we re-write the key-value database
implementation to store keys in filenames and values in individual
single-byte files.

This is (most likely) fixes #9992.

NB: Users that have been overriding the database file location with
the CMake variable ZEPHYR_TOOLCHAIN_CAPABILITY_CACHE must now specify
a directory with the variable ZEPHYR_TOOLCHAIN_CAPABILITY_CACHE_DIR.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-19 16:12:18 -04:00
Istvan Bisz 26e6162a82 cmake: Eclipse CDT4 generator amendment
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>
2018-10-17 18:16:55 -04:00
Sebastian Bøe 7f99086d64 cmake: Fix 'run' command of native_posix
The 'run' target was missing it's dependency on the executable and
thereby behaving incorrectly.

This fixes #10639 .

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-16 10:50:29 -04:00
Sebastian Bøe 92efb09a33 cmake: Fix minor typo in docs
Fix a minor copy-paste error in the help text.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-15 09:57:28 -04:00
François Delawarde c11e96d9b8 cmake: Support custom out-of-tree toolchains
Add a new optional TOOLCHAIN_ROOT cmake and environment variable to
specify an alternative location for toolchain cmake files.

When set, Zephyr will look for a toolchain cmake file located in:
${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}.cmake

Signed-off-by: François Delawarde <fnde@oticon.com>
2018-10-08 12:43:32 -04:00
Sebastian Bøe d0fc988e9f cmake: Error-out when dts.fixup files are detected
The filename dts.fixup is deprecated, dts_fixup.h should be used
instead. This commit detects when fixup files have not been renamed
and errors out with a warning.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-08 11:38:56 -04:00
Sebastian Bøe 8eb734cd82 DT: Rename from dts.fixup to dts_fixup.h
The Zephyr configuration system uses many different files in many
different formats. It makes it a lot easier for users to understand
what these files do if when we use the correct file extensions.

To this end we rename the dts.fixup files to the correct file
extension '.h'.

This is a breaking change for out-of-tree fixup files. Such files will
be detected and given an appropriate error message.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-08 11:38:56 -04:00
Kumar Gala c361405e90 dts: Reduce include paths for building dts
Drop a few paths from when we preprocess the dts.  This is to reduce
creep of where #defines might get resolved from.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-10-04 07:48:05 -05:00
Sebastian Bøe f612c3c167 dts: Allow users to pass extra flags to DTC
Allow application build scripts to pass extra flags to DTC, this could
for instance be done to enable/disable warnings.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-03 08:22:44 -05:00
Sebastian Bøe e8b501976c dts: Treat a missing 'reg property warning' as an error
As far as testing can tell, all occurences of the "Node has a unit
name, but no reg property" warnings have been fixed. To prevent them
from re-appearing we turn the warning into an error.

This is a breaking change for out-of-tree boards that are affected by
the warning.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-03 08:22:44 -05:00
Sebastian Bøe 6da970e593 revert: print a note about the changed 'default' behavior"
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>
2018-10-02 14:06:02 -07:00
Sebastian Bøe d6de4c7a99 cmake: Fall back to ZEPHYR_BASE when the board is not in BOARD_ROOT
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>
2018-10-01 09:46:46 -04:00
Sebastian Bøe fd8022ae16 cmake: Misc. cleanups of how BOARD_ROOT and BOARD_DIR are used
Misc. refactorings that clean up how BOARD_ROOT and BOARD_DIR are
used.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-01 09:46:46 -04:00
Sebastian Bøe 669781f2be cmake: version: Misc. refactorings for readability
Misc. refactorings to increase the readability of cmake/version.cmake.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-01 09:16:05 -04:00
Sebastian Bøe 8ade26267f kconfig: Change the format of KERNELVERSION
Change the format of KERNELVERSION as it exists in Kconfig to match
it's format elsewhere. Specifically, change from a string format
"1.10.3" to a numerical format.

This format change is a backwards-incompatible change. Any out-of-tree
Kconfig sources that were accessing KERNELVERSION with
$(KERNELVERSION) will need to be ported.

This change is to fix a bug. KERNELVERSION should have always been in
a numerical format. It should have been in a numerical format because;

KERNELVERSION is in a numerical format as a CMake variable and as a C
macro.

The purpose of having KERNELVERSION available in Kconfig is to have
configuration depend on the version, but this is only possible if it
exists in a numerical format[0].

[0] A string comparison of two semver strings does not always result
in a correct version comparison.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-01 09:16:05 -04:00
Sebastian Bøe 4dfd3114aa kconfig: Don't set the deprecated env var KCONFIG_AUTOHEADER
KCONFIG_AUTOHEADER is an environment variable that was used by the C
Kconfig tools to determine where the autconf.h file is. After the
migration to python this environment variable became unused.

This patch removes the deprecated env var.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-30 12:09:08 -04:00
Sebastian Bøe 20b28ba6e1 misc: mic
misc

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-30 12:09:08 -04:00
Yasushi SHOJI c0ff084f74 cmake: Do not abort even if git describe failed
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>
2018-09-26 15:11:37 +02:00
Maureen Helm ab67639403 cmake: Add build system target for west attach command
Adds a build system target for the west attach command, which starts a
debugging session without programming the flash.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-09-26 08:06:41 +05:30
Marti Bolivar 55b462cdfa scripts: update west to latest upstream version.
Update to the latest west. This includes a new 'attach' command. There
are also multi-repo commands, but those won't get exposed to the user
unless they install Zephyr using "west init" + "west fetch" (and not,
say, "git clone").

Replace the launchers; they now detect whether zephyr is part of a
multi-repo installation, and run the west code in its own repository
if that is the case.

This also requires an update to:

- the flash/debug CMakeLists.txt, as the new west package is no longer
  executable as a module and must have its main script run by the
  interpreter instead.

- the documentation, to reflect a rename and with a hack to fix
  the automodule directive in flash-debug.rst for now

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-09-25 17:51:22 +02:00
Björn Stenberg 4e61ccd1f0 cmake: Add quotes to handle missing ZEPHYR_TOOLCHAIN_VARIANT variable
If this environment variable is missing, the user gets a rather
confusing cmake error message about "STREQUAL" "gccarmemb" from the
lines below.

Adding quotes to the check makes cmake handle it better and instead
report the problem in the later ASSERT.

Signed-off-by: Björn Stenberg <bjorn@haxx.se>
2018-09-24 15:57:09 +02:00
Sebastian Bøe 350c3d7734 dts: Simplify overlay build scripts
Miscellaneous refactorings to simplify the overlay build scripts.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-21 18:51:26 -04:00
Erwan Gouriou 6af514b67f build: enable shields dir treatment
In dts.cmake, build shield list. For each shield, check if
associate KCONFIG is enabled and if it is, add matching files
to following new cmake variables:
-DTC_SHIELD_OVERLAY_FILE
-DTC_SHIELD_FIXUP
Then, consume these variables when needed.

Shield overlay is conceived as the very first overlay applied
to the board dts. It intends to build a new board that should
then behave as any other board versus common or user's overlay.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-09-21 18:51:26 -04:00
Sebastian Bøe 89a197be84 cmake: Re-direct KCONFIG_ROOT when convention is used
Automatically detect the Kconfig file in it's conventional placement
${APPLICATION_SOURCE_DIR}/Kconfig and set KCONFIG_ROOT accordingly.

'Convention over configuration' is an imporant principle for
minimizing metadata and keeping things consistent. We use this
principle for instance with the file prj.conf.

This commit applies this principle to also re-direrct KCONFIG_ROOT.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-21 13:37:21 -04:00
Sebastian Bøe b6a65a97aa kconfig: Make CONIG_FP_SOFTABI generate floating point instructions
This re-applies a patch that was merged in pr #6989, but then
accidentally reverted in a bad merge conflict resolution in pr #6842.

The actual behaviour of CONIG_FP_SOFTABI has not been matching the
documenation. The Kconfig documentation states that floating point
instructions should be generated, but this Kconfig option has been
turning off floating point instructions instead.

This commit causes floating point instructions to be generated when
CONFIG_FP_SOFTABI is enabled, as was originally intended and
documented.

This commit can cause regressions if users have been relying on the
actual behaviour instead of the documented behaviour.

Kconfig documentation:

config FP_SOFTABI
	help
	  This option selects the Floating point ABI in which hardware
	  floating point instructions are generated but soft-float calling
	  conventions.

GCC documentation:

Specifying ‘soft’ causes GCC to generate output containing library
calls for floating-point operations. ‘softfp’ allows the generation of
code using hardware floating-point instructions, but still uses the
soft-float calling conventions. ‘hard’ allows generation of
floating-point instructions and uses FPU-specific calling conventions.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-19 10:13:30 -04:00
Sebastian Bøe 1b80f00f56 cmake: Suppress the stderr from 'git describe' on successfull runs
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>
2018-09-19 09:12:25 -04:00
Carles Cufi d3390305d1 cmake: menuconfig: Fix missing SOC_DIR macro
menuconfig was being invoked without an initialized SOC_DIR, leading to
errors when parsing the top-level Kconfig.zephyr file.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-09-13 08:58:20 -04:00
Anas Nashif 96455d5881 build: support out of tree SoC definition
Add the glue to make this work with SoC code outside of the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-09-13 00:56:48 -04:00
Anas Nashif 66b524a62a soc: support out of dir soc code
Just like boards, support also SoCs out of the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-09-13 00:56:48 -04:00
Anas Nashif 3d1252ff2d soc: adapt Kconfig/CMake for soc in top /
Change build system to point to soc/ in the top directory rather than
under arch/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-09-13 00:56:48 -04:00
Anas Nashif 81b272119a docs: fixed documenation pointers
Fixed URL to documentation, now latest docs are under /latest/..
Fixes #9932

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-09-12 12:03:18 -04:00
Sebastian Bøe 1d90bcdc75 cmake: Use find_program on CMAKE_CXX_COMPILER
'find_program' should be used instead of 'set' for determining the
paths of host programs. It resolves #9582 and various other issues.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-12 09:36:33 -04:00
Ulf Magnusson d0e8752a52 Kconfig: Rename $ENV_VAR_{ARCH,BOARD_DIR} to $ARCH/$BOARD_DIR
The prefixes might be a leftover from the old 'option env="..."' symbols
(which are no longer needed). Since environment variables can be
referenced directly now, there's no point in having a prefix.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-09-11 19:17:25 -04:00
Sebastian Bøe 19845a7489 cmake: Don't use the environment variable CFLAGS
Some distros set the environment variable CFLAGS, this will
accidentally affect Zephyr builds.

To fix this we clear the environment variable from within the Zephyr
build system for the duration of the CMake execution.

Until now we have been instructing the user to clear it, but it is
easier for the user if we clear it for him.

The same applies to CXXFLAGS.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-05 18:40:32 -04:00
Bobby Noelte 5a16b9020f dts: bindings: scan application dir for bindings
In addtion to zephyr/dts/bindings als scan the dts/bindings
directory within the application source directory for bindings.

Allows to have application specific bindings and drivers.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2018-08-27 12:50:13 -04:00
Anas Nashif 1d4e089498 qemu: support alternate path of qemu binaries
Support using an alternate QEMU path for when we want to use a qemu
version not available in the SDK.

To use the alternate qemu version, export QEMU_BIN_PATH and point it
to the bin directory which contains the qemu executables.

For example:

export QEMU_BIN_PATH=/usr/local/bin

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-08-22 15:44:53 -07:00
Sebastian Bøe 6682652a2f cmake: change policy CMP0000 to NEW
Change CMake policy CMP0000 from OLD to NEW to resolve #8355.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-08-15 04:06:50 -07:00
Sebastian Bøe 83d2a47d9b cmake: Don't propagate zephyr_library_compile_options
zephyr_library_compile_options will apply compile options to a library
with high priority. Due to bug #8438 these compile options have been
applied not only to the library, but also to it's public interface and
therefore to any library that has been linking with the library.

To resolve #8438 we use PRIVATE linking instead of PUBLIC linking.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-08-13 18:43:53 -07:00
Ulf Magnusson 9c93e8e87b Kconfig: Have CMake print a note about the changed 'default' behavior
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>
2018-08-10 12:38:28 -07:00
Sebastian Bøe b9e8cd1133 cmake: Refactor usage of target_link_libraries on Zephyr libraries
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>
2018-08-09 14:03:10 +02:00
Carles Cufi 957262e37d build: Replace GCC ARM Embedded with GNU Arm Embedded
The old GCC ARM Embedded website on launchpad
(https://launchpad.net/gcc-arm-embedded) has been superseeded by the new
GNU Arm Embedded one
(https://developer.arm.com/open-source/gnu-toolchain/gnu-rm).

This also means a change of name from "GCC" to "GNU". Reflect this in
the enviroment variables so that the proper term is used henceforth.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-08-09 13:57:55 +02:00
Ulf Magnusson a500e7e069 cmake: kconfig: Fix broken menuconfig due to misspelling
Due to a misspelling in the existence check for the stored checksum
file, zephyr/.config was always regenerated from the config fragments
(e.g. prj.conf), overwriting any custom zephyr/.config configuration
done in e.g. menuconfig.

This bug was introduced by commit 5402662dd9 ("cmake: kconfig: Fix
rerunning cmake after Kconfig warnings").

Fixes: #9270

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-03 18:41:43 +02:00
Ulf Magnusson 5402662dd9 cmake: kconfig: Fix rerunning cmake after Kconfig warnings
Commit b3d165f ("scripts: kconfig: Handle warnings generated
during evaluation") made it common for kconfig.py to fail after writing
zephyr/.config. This confuses the configuration fragment checksum logic
in cmake/kconfig.cmake, because it expects the saved checksum file to
exist if zephyr/.config exists.

The end result is a CMake error when rerunning the configuration after
non-whitelisted Kconfig warnings.

Fix it by only writing zephyr/.config (and zephyr/include/autoconf.h) in
kconfig.py if there are no warnings-turned-errors.

Also check if the saved checksum file exists in kconfig.cmake before
trying to open it. Normally this shouldn't happen though.

Move the writing of the checksum file to before writing zephyr/.config
as well. That way, zephyr/.config only gets written if the other
operations succeed.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-02 19:15:26 +02:00
Sebastian Bøe c1bf7350b1 cmake: Improve the error message when the compiler is not executable
When the SDK/toolchain has been incorrectly installed such that the
user does not have permissions to execute it an incomprehensible
errror message occurs.

This patch tests that executing 'gcc --version' does not give an error
code and errors out with an appropriate error message if it does.

This fixes #8977

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-07-31 12:40:37 -04:00
Anas Nashif 7ce9615a2b nsim: add run target
Support 'make run' with this target rather than using 'flash' which
might be confusing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-19 18:59:07 -04:00
Anas Nashif 93ca721c48 xtools: set toolchain vendor to zephyr
For xtools, we set the vendor to zephyr directly and do not get it from
a variable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-13 16:17:23 -05:00
Carles Cufi 45d58a7bb1 cmake: Rename process.cmake to reflect contents
Rename process.cmake to reflect its contents: executing the CMake
command "execute_process".

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-07-12 23:11:46 -04:00
Carles Cufi b8dd6ac741 cmake: util: Add fmerge.cmake script
In order to merge multiple files into a single one, this convenience
script is provided to be able to do so at build time in a manner
compatible with all operating systems.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-07-12 01:26:05 +02:00
Carles Cufi ff5452ef5c cmake: util: Add process.cmake script
In order to be able to execute a process at build time (and not at
configure time) in a cross-platform manner while at the same time
redirecting stdout and stderr to files, add a script that wraps CMake's
execute_process() command.

The script can be invoked with identical parameters to execute_process()
but at build time, allowing CMake users to store stdout and stderr in
files in a way that works on all operating systems.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-07-12 01:26:05 +02:00
Anas Nashif 6f29dac25a toolchain: require Zephyr SDK 0.9.3
SDK 0.9.3 has been out for a while, to avoid inconsistency and false
positive when filing bugs, require the latest version.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-08 15:39:35 -04:00
Anas Nashif 0009df8212 toolchains: fix multilib libc linking with xtools
Fixed linking with multilib toolchains by adjust the path to sysroot.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-08 15:39:35 -04:00
Anas Nashif 458fe44692 toolchain: iamcu support with xtools toolchain
Support both x86 and iamcu variants of the toolchain.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-08 15:39:35 -04:00
Anas Nashif 7c15934b53 toolchains: add xtools support for ARC
Latest crosstools NG supports ARC, so add it here for those who build
their own toolchains using xtools-ng or use the scripts from sdk-ng repo
in the zephyr project.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-08 15:39:35 -04:00
Henrik Brix Andersen ff6dbc599c build: fix git describe call on older Git versions
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>
2018-07-03 12:49:45 -05:00
Ioannis Glaropoulos 059952c8e1 arch: arm: update compile options for DSP
This commit updates the compile options in cmake to distinguish
between ARMv8-M Mainline MCUs with or withouth the optional DSP
extension. A new Kconfig option: ARMV8_M_DSP, is introduced, to
signify the use of an ARMv8-M MCU with DSP support.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-07-03 12:17:13 -05:00
Anas Nashif 72edc4e15f clang/llvm: add initial configuration file for clang
Add an LLVM backend and a clang toolchain variant to support building
with llvm coming with popular Linux distributions.

This has been tested with X86 boards:
- quark_d2000_crb
- quark_se_c1000_devboard/Arduino 101

Use:

export ZEPHYR_TOOLCHAIN_VARIANT=clang

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-01 22:58:09 +02:00
Sebastian Bøe 608778a4de cmake: Support specifying Kconfig options on the CLI
This resolves #5723 by adding support for assigning to Kconfig options
from the CMake CLI.

CMake CLI Kconfig options can be specified like so:

'cmake -DCONFIG_ASSERT=y'

The lifetime of such an option is the same as the lifetime of a CMake
cache variable, and in principle any method of populating the
CMakeCache could be used, such as cmake-gui.

This has been implemented by scanning the CMakeCache variables before
Kconfig is executed and writing any that are prefixed with 'CONFIG_'
to a new Kconfig fragment in the build directory that is merged in
with a high precedence.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-06-20 15:40:24 -04:00
Marti Bolivar 5e7e1cba69 cmake: fix git describe command line
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>
2018-06-19 17:45:45 -04:00
Alex Tereschenko 3c1a78ea0d cmake: replace PROJECT_SOURCE_DIR with ZEPHYR_BASE
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>
2018-06-18 15:25:55 -04:00
Michael R Rosen 025a1e9086 cmake: fix CONF_FILE parsing to allow for cmake lists
Modify CONF_FILE variable treatment in the cmake infrastructure
to enable the use of CMake lists and semicolon-separated strings
in setting the CONF_FILE list for multiple configuration files.
This change does not impact the current method of using
single-space-separated strings for multiple files.

Signed-off-by: Michael R Rosen <michael.r.rosen@intel.com>
2018-06-11 17:26:39 -04:00
Adithya Baglody 4a693c3c38 boards: common: bossac: Fix bossac flash script.
The flash script was broken after the cmake changes.
Updated the path needed for the flash scripts.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-06-04 12:15:31 -05:00
Paul Sokolovsky 420bfc1f2d cmake: toolchain: Don't warn of both ZEPHYR_*_VARIANT envvars defined
Someone doing bisects on Zephyr will have to have both older
ZEPHYR_GCC_VARIANT and newer ZEPHYR_TOOLCHAIN_VARIANT environment
variables defined. Then warning about ZEPHYR_GCC_VARIANT is
confusing. Issue it if only ZEPHYR_GCC_VARIANT is defined, and
ZEPHYR_TOOLCHAIN_VARIANT isn't.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-06-01 10:34:25 -04:00
Adithya Baglody 5d22834e9a cmake: extensions: Remove macro zephyr_library_ifdef.
This cmake macro was changing the control flow of the cmake files.
It is not advisable to modify the callee control flow from inside
a cmake macro.
Hence removing all instances of this macro from the build system.

Fixes: GH-7565

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-05-28 13:23:13 -04:00
Sebastian Bøe cde6bef778 kconfig: Drop support for CONFIG_TOOLCHAIN_VARIANT
The Kconfig option TOOLCHAIN_VARIANT (not to be confused with
ZEPHYR_TOOLCHAIN_VARIANT) is a legacy configuration option that has
very few use-cases and can easily be dropped.

It's functionality is easily covered by CONFIG_X86_IAMCU and
ZEPHYR_TOOLCHAIN_VARIANT.

This commit removes all references of it from Zephyr.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-05-22 11:15:36 -04:00
Marti Bolivar 5317f76dec scripts: west: introduce common runner configuration
Continue better integration of the runner subpackage into west by
moving the common runner configuration options into the command
core. This allows commands like "west flash -h" to display help for
common overrides like --kernel-hex.

Adjustments needed to make this happen are:

- Change the build system to separate common configuration values from
  runner-specific options and arguments

- Prepare the runner core by defining a new RunnerConfig class that
  represents the common configuration, and accepting that from a new
  create() method, which replaces create_from_args().

- Convert all concrete runner classes to use the new style of
  argument parsing and initialization.

- Group the command options appropriately for help output readability

There's still a bit of tool-specific stuff in the common
configuration (gdb and openocd configuration in particular); a more
generic way to deal with that will be necessary to better support
things like non-GDB debuggers, but that's out of scope of this patch.

All the runner-specific options are still in the runner packge, which
currently prevents them from being included in "west flash -h" etc.
Fixing that is also out of scope of this patch.

This has the ancillary benefit of getting rid of the legacy 'debug'
argument to ZephyrBinaryRunner, which is no longer appropriate since
verbose debug logging is handled by log.py in west.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-05-19 07:01:39 +03:00
Marti Bolivar fbd2e92b42 scripts: remove zephyr_flash_debug.py
Since, by design, the west 'flash', 'debug', and 'debugserver'
commands operate the same way as the Makefile targets when given no
arguments, so just delegate to west from cmake/flash/CMakeLists.txt
instead of invoking zephyr_flash_debug.py by hand.

Removing the old script is the first step towards being able to clean
up the command line argument handling in the runner package, which was
always kind of a hack and can be improved now that runner is part of a
larger tool.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-05-19 07:01:39 +03:00
Marti Bolivar 9e7d16acd9 scripts: make runner a west subpackage
This is a stepping-stone to adding runner functionality into west
itself.

Since all of the runner tools assume a Zephyr build directory layout,
this doesn't put anything generic into a Zephyr-specific tool.

Make minimal adjustments to zephyr_flash_debug.py to keep existing
build system targets working unmodified.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-05-19 07:01:39 +03:00
Marti Bolivar 64badd97cd cmake: flash: save runner configuration to CMake cache
Persist all the important information needed by the runner package to
the CMake cache. This serves as a parseable record for various tools
which need to understand how to run the binary.

In particular, it will be used by the west tool, which will be
introduced in subsequent patches.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-05-19 07:01:39 +03:00
Kumar Gala cc8b726517 cmake: Add new generate_inc_file_for_gen_target function
Add a variant on generate_inc_file_for_target in which the user can
specify the target that the generated file will depend on.  This allows
exposing that target to other possible places where a dependency on the
generated file existing might be needed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-05-17 15:07:48 -05:00
Andrew Boie 47fa8eb98c userspace: generate list of kernel object sizes
This used to be done by hand but can easily be generated like
we do other switch statements based on object type.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-16 17:32:59 -07:00
Adithya Baglody c674167fea cmake: extensions: Added a new macro zephyr_library_ifdef
Checks if a certain Kconfig is enabled and then do the same
operation as zephyr_library.
If it finds that the Kconfig is not set it will not
create a new library and will stop processing the rest of
the CMakeFile.txt. Usefull in processing the driver Cmake
files.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-05-15 17:48:18 +03:00
Wayne Ren 6307b8b97d arch: arc: refactor the soc part of em_starterkit
The original em7d, em9d and em11d are different configurations of
em_starterkit. They have the same peripherals, e.g. uart, spi, gpio
, ddr. The differences of them are in arc core configurations, interrupt
number assignment.

So em7d, em9d and em11d can be viewed in the same SoC family or SoC
series.

Referring other arch's implementation, this commit merges em7d, em9d
and em11d into the same SoC, named snps_emsk. This will eliminate
unnecessary duplication and make it easier for future maintainment.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-05-15 09:48:11 +02:00
Ulf Magnusson 11952a60bf kconfig: Remove the C Kconfig implementation
Remove the C Kconfig tools and various scripts associated with them.

scripts/kconfig/diffconfig is popular, so keep it.

I don't know whether anyone is using scripts/kconfig/config. Remove it
and see if anyone screams.

scripts/kconfig/streamline_config.pl deals with modules ('m' values) and
can safely be removed. Zephyr's Kconfig files do not use modules.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-05-07 21:53:37 +02:00
Ulf Magnusson 890a5a5aa1 kconfig: Remove targets specific to the C implementation
They will no longer be available once the C Kconfig implementation is
removed.

oldconfig and allno/yesconfig implementations are available for
kconfiglib and could be added later if needed. savedefconfig (minimal
configuration generation) is available from the menuconfig.py
configuration interface.

cmake/usage/kconfig-usage.cmake becomes kinda pointless after this
change, so merge it into cmake/usage/usage.cmake.

Remove the kconfig_target, COMMAND_FOR_*, and COMMAND_RUNS_ON_WIN_*
CMake variables, as there's just the 'menuconfig' target now.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-05-07 21:53:37 +02:00
Ulf Magnusson 7229a9a560 scripts: kconfig: Switch 'menuconfig' over to menuconfig.py
Make 'make/ninja menuconfig' run menuconfig.py instead of mconf from the
C Kconfig tools. Get rid of the 'pymenuconfig' target.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-05-07 21:53:37 +02:00
Sebastian Bøe aa90d72116 cmake: Introduce a key version to invalidate corrupted caches
When a bug in the caching mechanism is detected the cache format must
be bumped to ensure that we no longer get a cache hit on old corrupted
keys.

This fixes #7246 when the cache is corrupted.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-05-02 10:16:24 -04:00
Sebastian Bøe 5f08b106a8 cmake: Suppress messages about compiler checks
Messages about compiler checks are very verbose so we disable them by
default. They have always been undesirably verbose, but introducing
CMAKE_REQUIRED_FLAGS into the 'check' string made them unacceptably
so.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-05-02 10:16:24 -04:00
Sebastian Bøe 632fe1d411 cmake: check_compiler_flag: Fix bug where checks were aliased
Fix a bug where different compiler checks were aliased and therefore
the test results were incorrectly re-used.

The 'check' string is used by CMake internally to cache test results,
but when testing linker flags the check string has been aliased
between the different linker checks. To fix the aliasing issue we add
the CMAKE_REQUIRED_FLAGS variable to the 'check' string. The aliasing
issue disappears because the linker flag-under-test is in
'CMAKE_REQUIRED_FLAGS'.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-05-02 10:16:24 -04:00
Rajavardhan Gundi 08172cdf83 xtensa: provide XCC compiler support for Xtensa
This patchset provides Xtensa's xcc compiler support for Xtensa
projects in Cmake. This requires the below environment variables
to be defined aptly. The appropriate xcc license information also
need to be supplied.

ZEPHYR_GCC_VARIANT=xcc
TOOLCHAIN_VER=RF-2015.3-linux
XTENSA_CORE=cavs21_LX6HiFi3_RF3_WB16
XTENSA_SYSTEM=/opt/xtensa/XtDevTools/install/tools/
		RF-2015.3-linux/XtensaTools/config/
XTENSA_BUILD_PATHS=/opt/xtensa/XtDevTools/install/builds/

Change-Id: Ib3c10e8095439b0e32276ff37c00eca8420773ec
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-01 16:46:41 -04:00
Henrik Brix Andersen 9fbdab528e build: fix git describe call on older Git versions
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>
2018-05-01 16:33:21 -04:00
Ulf Magnusson 73549ad852 scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.

The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.

A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.

For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.

Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.

The CMake parts are originally by Sebastian Bøe.

Description, taken from the menuconfig.py docstring:

    Overview
    ========

    A curses-based menuconfig implementation. The interface should feel
    familiar to people used to mconf ('make menuconfig').

    Supports the same keys as mconf, and also supports a set of
    keybindings inspired by Vi:

      J/K     : Down/Up
      L       : Enter menu/Toggle item
      H       : Leave menu
      Ctrl-D/U: Page Down/Page Down
      G/End   : Jump to end of list
      g/Home  : Jump to beginning of list

    The mconf feature where pressing a key jumps to a menu entry with
    that character in it in the current menu isn't supported. A search
    feature with a "jump to" function for jumping directly to a
    particular symbol regardless of where it is defined will be added
    later instead.

    Space and Enter are "smart" and try to do what you'd expect for the
    given menu entry.

    Running
    =======

    menuconfig.py can be run either as a standalone executable or by
    calling the menu.menuconfig() function with an existing Kconfig
    instance. The second option is a bit inflexible in that it will
    still load and save .config, etc.

    When run in standalone mode, the top-level Kconfig file to load can
    be passed as a command-line argument. With no argument, it defaults
    to "Kconfig".

    The KCONFIG_CONFIG environment variable specifies the .config file
    to load (if it exists) and save. If KCONFIG_CONFIG is unset,
    ".config" is used.

    $srctree is supported through Kconfiglib.

    Other features
    ==============

      - Seamless terminal resizing

      - No dependencies on *nix, as the 'curses' module is in the Python
        standard library

      - Unicode text entry

      - Improved information screen compared to mconf:

          * Expressions are split up by their top-level &&/|| operands
            to improve readability

          * Undefined symbols in expressions are pointed out

          * Menus and comments have information displays

          * Kconfig definitions are printed

    Limitations
    ===========

      - Python 3 only

        This is mostly due to Python 2 not having curses.get_wch(),
        which is needed for Unicode support.

      - Doesn't work out of the box on Windows

        Has been tested to work with the wheels provided at
        https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-05-01 20:51:11 +02:00
Ulf Magnusson a4381d9ea6 kconfig.cmake: Consistently use ZEPHYR_BASE
I found the mixing of ZEPHYR_BASE and PROJECT_SOURCE_DIR confusing. They
are synonyms.

Related issue: https://github.com/zephyrproject-rtos/zephyr/issues/7173

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-05-01 20:51:11 +02:00
Anas Nashif f8c1cc175a toolchain: update xtools config
Add placeholders for all possible xtools toolchains.

Fixes #6911

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-30 12:54:35 -04:00
Anas Nashif 33d87efda5 build: simplify git describe call
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>
2018-04-30 10:16:40 -04:00
Sebastian Bøe 8bcf30e21a cmake: posix: Use absolute paths for toolchain paths
Make posix align with non-posix platforms by having CMAKE_C_COMPILER
and friends use absolute paths.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Sebastian Bøe 71b849f18c cmake: Port Zephyr to use zephyr_check_compiler_flag
This commit ports nearly all usage of check_c_compiler_flag,
check_cxx_compiler_flag, and check_compiler_flag to use
zephyr_check_compiler_flag instead.

This has a significant CMake configure-time performance impact.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Sebastian Bøe 84475810ec cmake: Introduce zephyr_check_compiler_flag()
zephyr_check_compiler_flag is introduced to resolve
https://github.com/zephyrproject-rtos/zephyr/issues/5633

The time spent when invoking CMake is halved with a warm cache.

See the API documentation for details.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Sebastian Bøe a7c3f4ed25 cmake: toolchain: Checksum the toolchain to uniquely identify it
This commit introduces TOOLCHAIN_SIGNATURE. A CMake variable that is
defined like this:

Toolchains with the same signature will always support the same set of
flags.

Currently it is implemented by MD5summing the CC binary.

This is useful for instance if the build system needs to determine if
it has seen the toolchain before, e.g. in a caching use-case.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Sebastian Bøe c95c6bef04 cmake: check_compiler_flag: Support empty-string options
This commits allows check_compiler_flag to accept the empty string as
an option. There are several use-cases for accepting no flag, one of
which is testing the toolchain itself.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Sebastian Bøe 709daa20e9 cmake: Find a directory that could be used to cache files
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>
2018-04-27 12:06:02 +02:00
Sebastian Bøe 6c3a94c01f cmake: Add function for checking if a directory is write-able
Added a CMake extention for determining if a directory is write-able
by the build system. To determine this, we attempt to 'touch' a file
in the directory and check the return code of this command.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Leandro Pereira 39dc7d03f7 scripts: gen_kobject_list: Generate enums and case statements
Adding a new kernel object type or driver subsystem requires changes
in various different places.  This patch makes it easier to create
those devices by generating as much as possible in compile time.

No behavior change.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-26 02:57:12 +05:30
Håkon Øye Amundsen 6779d3f356 cmake: Fix printed list of supported boards.
Fixes issue #7184.

Use $BOARD_ROOT to find correct list of supported boards.
This is needed since the user can set this variable to any directory.
Pass $BOARD_ROOT to usage.cmake where it is called.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2018-04-25 17:36:58 +05:30
Sebastian Bøe f10fddeb56 cmake: toolchain: Improve error feedback when toolchain is not found
Improve the error feedback when the toolchain is not found.

Currently, for some setups, presumably primarily SDK-less setups,
users can get an error message like this for certain types of
misconfigurations:

CMake Error at zephyr/cmake/extensions.cmake:984 (message):
  No such file or directory: CMAKE_READELF: 'CMAKE_READELF-NOTFOUND'
Call Stack (most recent call first):
  zephyr/cmake/compiler/gcc.cmake:14 (assert_exists)
  zephyr/cmake/toolchain.cmake:38 (include)
  zephyr/cmake/app/boilerplate.cmake:243 (include)
  CMakeLists.txt:1 (include)

This commit will improve the error feedback to give a explanation for
what kind of failure has occured and will also dump relevant variables
to ease debugging.

This fixes #7075

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-19 12:53:43 -07:00
Anas Nashif daf7716ddd build: use git version and hash for boot banner
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>
2018-04-10 10:57:50 -04:00
Sebastian Bøe 9be27f73db kconfig: Make CONIG_FP_SOFTABI generate floating point instructions
The actual behaviour of CONIG_FP_SOFTABI has not been matching the
documenation. The Kconfig documentation states that floating point
instructions should be generated, but this Kconfig option has been
turning off floating point instructions instead.

This commit causes floating point instructions to be generated when
CONFIG_FP_SOFTABI is enabled, as was originally intended and
documented.

This commit can cause regressions if users have been relying on the
actual behaviour instead of the documented behaviour.

Kconfig documentation:

config FP_SOFTABI
	help
	  This option selects the Floating point ABI in which hardware
	  floating point instructions are generated but soft-float calling
	  conventions.

GCC documentation:

Specifying ‘soft’ causes GCC to generate output containing library
calls for floating-point operations. ‘softfp’ allows the generation of
code using hardware floating-point instructions, but still uses the
soft-float calling conventions. ‘hard’ allows generation of
floating-point instructions and uses FPU-specific calling conventions.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-10 08:36:28 -05:00
Tomasz Bursztyka 1134393ac1 scripts/dts: Make extract_dts_includes generating both files by itself
Thus no need to parse twice the .dtsi, .dts and .yaml files.
Simplify provided arguments relevancy, letting argparse generating usage
message by itself.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-26 14:48:49 -04:00
Anas Nashif 993c350b92 cleanup: replace old jira numbers with GH issues
Replace all references to old JIRA issues (ZEP) with the corrosponding
Github issue ID.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-03-26 13:13:04 -04:00
Marti Bolivar 98456b30f8 cmake: fix set_ifndef() usage patterns
If the value argument to set_ifndef() may be unset, the entire value
must be double-quoted to avoid a CMake syntax error.

Fix call sites which don't handle this, or which otherwise make
non-idiomatic use of this function.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-03-23 05:32:44 -04:00
Sebastian Bøe 777e0a1b86 cmake: Support UTF-8 characters in Kconfig values
We are using the CMake command 'file(STRINGS' (which defaults to only
decoding ASCII) to read Kconfig configurations. When UTF-8 characters
are detected they are treated as newlines.

This behaviour has caused issues when users have input UTF-8
characters into Kconfig values. E.g. USB device descriptor strings.

This commit adds the flag 'ENCODING "UTF-8"' to the 'file(STRINGS'
command so that UTF-8 characters are correctly passed through the
build system.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-03-21 19:11:19 -04:00
Sebastian Bøe 87031e3cf9 cmake: Find out earlier whether ccache is to be used or not
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>
2018-03-02 07:13:21 +01:00
Kumar Gala d2e89856cc cmake: dts: Fix usage of BOARD vs BOARD_FAMILY
We assumed that ${BOARD} and ${BOARD_FAMILY} are always the same and
thus interchangeable.  That isn't always the case so use ${BOARD} proper
for when we mean the exact BOARD name we are building for vs the
BOARD_FAMILY.

We also add .dts files for board variants within a board family, such
that we have a .dts matching each board name.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-27 19:56:47 -06:00
Ioannis Glaropoulos 5343f8973d cmake: indicate single precision floating-point for Cortex-M33
ARM Cortex-M33 may implement an optional Floating Point Unit
(FPU) supporting single-precision arithmetic. This commit
modifies the respective GCC_M_CPU flag to comply with Cortex-M33.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-02-23 21:42:22 -06:00
Kumar Gala b328ec51ac cmake: dts.cmake: Use SOC_PATH to find soc/dts.fixup
Per arch the path to the SOC dir that we would find dts.fixup varies
between being ${CONFIG_SOC_FAMILY}/${CONFIG_SOC_SERIES} and just
${CONFIG_SOC}.  The ${SOC_PATH} var handles defining this correct so
use it instead when we define DTS_SOC_FIXUP_FILE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-22 10:14:02 -06:00
Kumar Gala 440cc18d1b cmake: Move SOC_* var defines to cmake/app/boilerplate.cmake
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>
2018-02-22 10:14:02 -06:00
Pedro Martucci a495b31ee0 sample: net: RPL mesh sample over QEMU
Create a net sample to setup a multi-node RPL mesh network using QMEU.
To enable this, it was necessary implement a hw filter on IEEE 802.15.4
UART Pipe driver and create a QEMU pipe management on cmake.

This sample use a tool developed on zephyr net-tools repository called
virtual-hub.

Signed-off-by: Pedro Martucci <pedropaulomartucci@gmail.com>
2018-02-20 14:47:14 +02:00
Anas Nashif e172fa3b52 build: support out-of-tree custom boards
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>
2018-02-14 19:20:29 -05:00
Anas Nashif 622ab2f6fd toolchain: organise toolchain/compiler files
Move toolchain definitions into toolchain/ and move compilers to
compilers/
Usage of toolchain- for everything was confusing, there are the actual
compiler related definitions and there is the toolchain/SDK related
configs, so keeping them separate helps understand the different and
prevents confusion.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-13 07:44:45 -08:00
Anas Nashif 7ee8bb9677 build: deprecate ZEPHYR_GCC_VARIANT
We want to support other toolchain not based on GCC, so the variable is
confusing, use ZEPHYR_TOOLCHAIN_VARIANT instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-13 07:44:45 -08:00
Carles Cufi 72684ef815 dts: mcuboot: Support for common overlays and mcuboot
When the Kconfig BOOTLOADER_MCUBOOT is selected, an overlay to place the
image at the slot0 location is required. In order to avoid having to do
this manually for all samples when targetting MCUboot, include the logic
inside the dts.cmake script to prepend a new common.dts file that then
conditionally includes mcuboot.overlay.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-09 09:11:13 -05:00
Carles Cufi 06b9841675 dts: Move dts.cmake to cmake/
Move the DTS CMake file to the cmake/ folder, where all other .cmake
files live.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-09 09:11:13 -05:00
Carles Cufi 1cce63ae8f cmake: dts: Allow multiple overlay files
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>
2018-02-05 14:09:43 -05:00
Marti Bolivar 461511e1fc cmake: fix 'ninja flash' et al with multiple boards plugged in
Fixes: 5958

Ninja by default will suppress command output and input. This is a
problem for the 'flash', 'debug', etc. targets, which may need to
interact with the user (and which display interactive output like
progress bars).

To fix this, add the USES_TERMINAL option to their target
definitions. This puts them in the console pool on Ninja, allowing the
commands to interact with the console.

References:

https://ninja-build.org/manual.html#_the_literal_console_literal_pool
https://cmake.org/cmake/help/v3.8/command/add_custom_target.html

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-02 19:04:00 +01:00
Patrick Boettcher 55109ae5fb cmake: give an assert a useful message
When the ZEPHYR_GCC_VARIANT-variable is not set properly no
message is printed, whereas this small change will help users
to easier understand why things are not working. Here: they forgot
to set an ENV-variable.

Signed-off-by: Patrick Boettcher <patrick.boettcher@posteo.de>
2018-01-29 14:32:01 +01:00
Anas Nashif de311407bd scripts: fix ram_reports and generate bin file if missing
Some boards do not generate .bin files by default, this file is however
needed when generating ram/rom reports, so in case it is not present,
create it.

Fixes #5784

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-29 05:16:52 +05:30
Jimmy Huang 4a243ffce9 arch: arc: use default optimization flag
The work-around previously setting ARC builds to use -O2 to fix an
ADC bug #3797 is no longer needed, we should this patch and revert
to the default -Os flag to optimize for smaller size.

Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
2018-01-25 07:56:58 +05:30
Ding Tao d187da4922 cmake: Fix missing braces around interface
Error occurred when using target_link_libraries in CMakeLists.txt:

Cannot specify link libraries for target "interface" which is not built
by this project.

Replace "interface" with "${interface}".

Signed-off-by: Ding Tao <miyatsu@qq.com>
2018-01-23 17:42:05 +05:30
Sebastian Bøe 690bea3a3c cmake: Fix "make usage" regression from the ZEPHYR_BASE change
$ENV{ZEPHYR_BASE} was recently search-replaced with ${ZEPHYR_BASE},
but some CMake code, like usage.cmake, is run by a seperate CMake
build system that does not have access to the CMake variable
ZEPHYR_BASE.

This patch reverts the usage of ${ZEPHYR_BASE} back to use
$ENV{ZEPHYR_BASE} in usage.cmake.

This has been proven to work on both Windows and Linux.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-18 10:44:19 -05:00
Sebastian Bøe 2c8aa87138 kconfig: Revert back to old behaviour pre-kconfiglib.py
Run Kconfig on every reconfigure but with different fragments
depending on the situation.

When .config is missing or when a file from merge_config_file has been
modified use the merge_config_file's as input, otherwise use .config
as input.

This should match the behaviour before kconfiglib.py was introduced
and fixes #5673.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-17 07:39:28 -05:00
Sebastian Bøe db31de5df6 Revert "cmake: kconfig: Run Kconfig on every reconfiguration"
This reverts commit a8b361b176.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-17 07:39:28 -05:00
Anas Nashif 54bdccc5bc cmake: do not error on missing 'config'
'conf' is part of the zephyr SDK or need to be built and installed in
the path. We now using python for Kconfig processing, so this is not a
strict requirement and we should be able to build without it. If the
binary is not found, just go on with our business.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-16 17:03:48 -05:00
Marti Bolivar 70a40813df cmake: add optional app_set_runner_args()
Due to a chicken-and-egg problem, it's not possible to call
board_runner_args() directly from an application CMakeLists.txt and
have it take effect:

  - if the board_runner_args() call appears before including the
    boilerplate file, then the function is undefined and an error
    occurs.

  - if the call appears after including the boilerplate file, then
    board_finalize_runner_args() has already been called by the
    relevant runner.board.cmake file, so it won't take effect.

Similarly to the way set_conf_file() works, allow applications to
declare additional runner args by checking if they have provided a
macro named app_set_runner_args(), which contains calls to
board_runner_args(). Using a macro means that we can invoke it with
the definition of board_runner_args() in scope.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-01-15 16:21:28 -05:00
Sebastian Bøe 8b6d3ad69b cmake: Improve error messages for detecting libgcc
Use two different variables for the distinct values LIBGCC_FILE_NAME
and LIBGCC_DIR and assert that each of them exists.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-12 08:37:41 -05:00
Sebastian Bøe 15ca6da4c8 cmake: Re-introduce support for CROSS_COMPILE
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>
2018-01-12 08:37:41 -05:00
Sebastian Bøe a896be1192 cmake: toolchain: Misc. comment cleanups
Sync the outdated comments with the code. E.g. there is no
toolchain-clang.cmake, but there is a toolchain-host-gcc.cmake.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-12 08:37:41 -05:00
Sebastian Bøe 4b61bd1b7a kconfig: Prune kconfig files that don't match the ARCH or BOARD
When Kconfiglib was introduced it caused a significant performance
issue. This patch uses pruning to mitigate the performance issue.

The pruning exploits the fact that before the Kconfig database is
parsed we already know what ARCH and BOARD has been selected. So in
theory we could prune away all Kconfig sources that are not related to
the current ARCH or BOARD. In practice, it is only the Kconfig sources
in zephyr/arch/$ARCH and zephyr/board/$ARCH/ that are easy to prune.

Still, that is quite a few Kconfig sources. For qemu_x86 this patch
reduced the number of parsed Kconfig source files from 632 to
272. This pruning resulted in a incremental reconfiguration (time
cmake ..) speedup of 21% (0.56s to 0.46) and a clean build speedup of
4% (Using board qemu_x86 and sample hello_world).

Furthermore, it should be easier to maintain ARCH's and BOARD's
out-of-tree since the user now has a mechanism to redirect where
Kconfig sources are found. But this has not been explored.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-12 07:29:05 -05:00
Sebastian Bøe a8b361b176 cmake: kconfig: Run Kconfig on every reconfiguration
Kconfiglib does not support merging fragments without parsing the
entire Kconfig "database". For Zephyr this means we no longer get a
performance gain from splitting up the fragment-merging and the
.config generation.

This patch removes the seperated merge step and it's associated
caching mechanism. Now we do a full Kconfig execution on every
reconfiguration.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-12 07:29:05 -05:00
Carles Cufi d92769b849 scripts: kconfig: Replace Kconfig exectuables with Python
We have been using a fork of the Linux kernel's Kconfig system to
configure the Zephyr tree. The issue is that this is a native tool
written in C that is not easy to compile for Windows. This patch
replaces the use of the conf executable with kconfig.py, a script that
uses Kconfiglib to generate the .config and autoconf.h files required to
compile Zephyr.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-12 07:29:05 -05:00
Carles Cufi 07a64f19ed cmake: Use find_program() to locate the toolchain
Instead of hard-coding the path use find_program(), since that allows
CMake to sort out platform-specific details such as .exe extensions on
Windows.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-11 16:05:05 -05:00
Carles Cufi 7d764b35f3 cmake: Use path-corrected version of ZEPHYR_BASE
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>
2018-01-11 14:59:03 -05:00
Sebastian Bøe daa39867b8 cmake: sdk: Improve error message when INSTALL_DIR is wrong
Add an assertion that verifies the user has not misconfigured
ZEPHYR_SDK_INSTALL_DIR.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-11 06:39:12 -05:00
Sebastian Bøe c6f367d251 cmake: Give descriptive error to user when cloned with core.autocrlf
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>
2018-01-10 22:12:27 -05:00
Carles Cufi e29744c0cd cmake: Require 3.8.2 on all platforms, including MSYS2
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>
2018-01-08 11:01:47 -05:00
Anas Nashif 33592e8aa8 cmake: remove IS_TEST handling
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>
2018-01-08 10:03:57 -05:00
Anas Nashif f746cb3aeb version: fix version handling without extra_version set
Without extra_version, we had an extra - at the end of the version
string.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-08 08:08:45 -05:00
Sebastian Bøe 5d25497f90 cmake: zephyr_get_*: Add support for SKIP_PREFIX
Usually the zephyr_get_* API returns values prefixed with tokens like
-I -system, -D. But sometimes we need the values without these
prefixes, so we introduce the optional SKIP_PREFIX argument.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-04 00:03:25 -05:00
Sebastian Bøe 3c8331d390 cmake: Introduce Zephyr interface libraries
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>
2018-01-02 22:09:01 -05:00
Sebastian Bøe d5fe808a09 cmake: net: qemu: Don't pass "-serial none" to qemu
I don't know why we have been passing "-serial none" to qemu but it
does not seem to be doing anything useful. So I propose we remove it.

According to the qemu documenation it should be disabling all serial
ports;

"-serial dev
Redirect the virtual serial port to host character device dev. The
default device is vc in graphical mode and stdio in non graphical
mode.

This option can be used several times to simulate up to 4 serial
ports.

Use -serial none to disable all serial ports."

But when we use "-serial none", we always combine it with "-serial
pipe", or "-serial unix", to redirect the serial port, so clearly it
is not disabling all serial ports as it attempting to do.

"-serial none" was first introduced to Zephyr in this commit:
0b54f984b8

As far I can tell, pinging an echo_server works fine without it, so I
suspect that our second -serial flag is overriding it and that it has
no effect.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-02 09:41:54 -05:00
Sebastian Bøe dfe5cb731c cmake: qemu: Don't use the '\$' hack with Ninja
Using the '\$' technique to accept make variables corrupts Ninja build
systems, so avoid using it when generating Ninja files. Not using it
with Ninja means we need to come up with some other mechanism to
support build-time configuration of the QEMU CLI with Ninja.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-30 11:29:24 -05:00
Sebastian Bøe c14013ca2d cmake: generate_inc: Change how the target name is constructed
The generate_inc_file_for_target() extension is a useful wrapper
around the more low-level generate_inc_file(). It takes care of
ensuring that the generated file correctly depends on it's source.

To do so it needs to name and define a custom_target, the name must be
unique, so it was constructed based on the path to the generated file,
but this caused multiple issues.

The intention was that the path of the file would help identify the
target, in hindsight, identifying the target has proven to not be
important.

This patch fixes #5466 by using a random string to construct the
target name instead of the path to the generated file.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-28 18:23:19 -05:00
Sebastian Bøe 5fb5adb34f cmake: Fix target_ld_options()
target_ld_options() was only testing whether a flag could be passed to
the compiler driver when it was compiling an object file. Not whether
a flag could be passed to the compiler driver when it was linking an
elf file.

For most flags, these tests would have the same result, but it does
not for flags like -Wl,--print-memory-usage or -Wl,notaflag.

This patch fixes #5488 by re-using the method from #5459.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-28 11:37:09 -05:00
Sebastian Bøe 4b77b4ad92 cmake: usage: Added posix to list of arch's with boards
Added posix to the list of arch's with boards. Usage will now show
native_posix as one of the available boards.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-28 11:24:21 -05:00
Anas Nashif 4592ff2d5a native: build zephyr.exe for posix arch
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>
2017-12-27 14:16:08 -05:00
Anas Nashif fd276aeb42 cmake: cleanup qemu runner configuration
All runner logic was implemented in qemu.cmake, remove the generic stuff
and make qemu.cmake qemu specific.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif e32a656962 posix: native: support native runner
This adds support of 'make run' to the native port allowing us to run
applications natively on the host instead of qemu.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif c15d3c9126 cmake: support other emulation platforms/runners
Right now we are hardcoded to only qemu, with the native port, we make
this more generic and support this in a plugin mode where a running has
its own cmake definitons implementing the various targets.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2017-12-27 14:16:08 -05:00
Alberto Escolar Piedras 76f7644118 arch: native: Run Zephyr natively in a POSIX OS
A new arch (posix) which relies on pthreads to emulate the context
switching
A new soc for it (inf_clock) which emulates a CPU running at an
infinely high clock (so when the CPU is awaken it runs till completion
in 0 time)
A new board, which provides a trivial system tick timer and
irq generation.

Origin: Original

Fixes #1891

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif 2bbe6af07c cmake: add zephyr_link_libraries_ifdef
Link libraries only when config is defined.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif 2e9064b7d6 cmake: replace @ in path with _
To avoid warnings from cmake such as:

  'path' is reserved or not valid for certain CMake features, such as
  generator expressions, and may result in undefined behavior.

This can be seen in Jenkins for example where @ is used when multiple
jobs are run on the same machine.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-23 09:13:44 -05:00
Sebastian Bøe fa53e89419 cmake: boilerplate: Define properties earlier
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>
2017-12-19 17:01:47 -05:00
Marti Bolivar 8447b5ea2e cmake: flash: support verbose output toggle
If CMAKE_VERBOSE_MAKEFILE is defined, make flashing and debugging more
verbose.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-12-15 09:57:30 -05:00
Marti Bolivar 7a3462de7a scripts: runner: use arguments, not environment vars
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>
2017-12-15 09:57:30 -05:00
Marti Bolivar 94290ee189 cmake: extensions: support list arguments to set_ifndef()
I keep tripping over not being able to use set_ifndef to set a value
to a list, like this:

set_ifndef(VARIABLE value1 value2 value3...)

Allow that to work without changing its existing behavior when called
with one argument.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-12-15 09:57:30 -05:00
Marti Bolivar e33ec242fd scripts: refactor flash/debug scripts to remove "shell"
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>
2017-12-15 09:57:30 -05:00
Marti Bolivar f8e0a0c519 cmake: extensions: add assert_not()
To be used in a later patch.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-12-15 09:57:30 -05:00
Sebastian Bøe 11c020ebf7 cmake: Support installing toolchains in "Program Files"
Support installing toolchains in "Program Files", or more generally,
in paths that contain whitespace. This is a common bug for new users
to discover.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-12 11:53:45 -06:00
Sebastian Bøe c87d262295 size_report: Use the CMake-discovered toolchain instead of ENV vars
size_report was using the environment variables NM and OBJDUMP to find
it's toolchain dependencies. It is not clear how well this will work
on different platforms; OSX, Windows. So we now pass the paths of
these dependencies from the build system to the script.

PS: This ensures that size_report uses the cross-compiler's GNU bin
tool instead of the host GNU bin tools. This is presumably beneficial
as it has been required for other GNU bin tools like GDB.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-12 11:42:05 -05:00
Sebastian Bøe 6a2a94b124 cmake: qemu: Allow -kernel to be overridden
This is needed by platforms like jailhouse.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Signed-off-by: Gustavo Lima Chaves <gustavo.lima.chaves@intel.com>
2017-12-12 09:31:31 -05:00
Sebastian Bøe e0e7a7d852 cmake: Reorganize how qemu is found
We don't want to pollute core-infrastructure with board-specific code,
so we move the qemu discovery to after board.cmake has been executed,
and we introduce the overridable QEMU_binary_suffix CMake variable.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-12 09:31:31 -05:00
Gustavo Lima Chaves fb7f914cc7 cmake: call the right QEMU binary on Jailhouse's make run target
In that case, QEMU is emulating the base (root system) that will be
partitioned to receive Zephyr as one of the cells/guests, not the direct
system Zephyr will run on. We need this one more level of indirection,
otherwise it's impossible to attest Zephyr is running in a virtualized
environment in QEMU.

Fix QEMU binary to point to the x86_64 version, then, once Jailhouse is
targeted at that architecture.

Finally, don't pass QEMU the -kernel flag in this case, since Zephyr has
to loaded manually, from inside QEMU, for Jailhouse's make run target.

Signed-off-by: Gustavo Lima Chaves <gustavo.lima.chaves@intel.com>
2017-12-12 09:31:31 -05:00
Sebastian Bøe b0c4316190 cmake: Show usage when an invalid board is given
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>
2017-12-10 19:51:21 -05:00
Sebastian Bøe 6c8ebab183 cmake: Added assert that will show usage
There is a catch-22 in that you need to run CMake to get a build
system that can show you usage, but you need to know the usage to be
able to get a build system.

This assert could be used to improve the usability somewhat. When
invalid usage is detected it can be used to print the usage.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-10 19:51:21 -05:00
Sebastian Bøe 6a61d5f82c cmake: Fix the dependency between qemu and the elf file
I can't explain why "make run" worked before, but after this patch it
should definitely work.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-07 08:09:12 -06:00
Sebastian Bøe 89516fbc25 cmake: Change the zephyr_get_* API to be LANG-aware
When exporting flags to an external build system we need to deal with
the fact that we sometimes use generator expressions. Specifically, we
use generator expressions that look like this:

$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>

This patch replaces the old API with a new one where users can ask for
compile options for specific languages, like this:

zephyr_get_compile_options_for_lang_as_string(CXX x)

The existing API would have either crashed or silently omitted flags
when a COMPILE_LANG generator expression was present.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-05 10:08:40 -05:00
Sebastian Bøe abbdd88683 cmake: Fix EXTRA_LDFLAGS feature
It is supported to add give extra flags to the linker from the
commandline like this:

cmake -DEXTRA_LDFLAGS=-Lmy_dir path

But unfortunately this was broken during the CMake
migration. Interestingly, the reason that it was broken is that KBuild
was also partially broken. KBuild would pass on EXTRA_LDFLAGS when
object files were linked together into built-in.o files, but it would
not use EXTRA_LDFLAGS for the final link into an elf file.

This patch fixes EXTRA_LDFLAGS.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-05 08:39:43 -05:00
Sebastian Bøe 13a6840261 cmake: Re-organize syscall generation wrt. the build system
This commit fixes
https://github.com/zephyrproject-rtos/zephyr/issues/5008.

It does so by splitting up gen_syscalls.py into two scripts with a
json metadata file to communicate syscall metadata between them. The
parsing script parses header files from include/ and writes syscall
metadata to a file if the contents changed. The generation script
reads from the json file and generates syscall code.

The build system DAG now looks like this:

always_rebuild -> json -> syscalls -> offset.o

The script for generating json will do so only if the content changes,
this ensures that the entire DAG does not always do a full rebuild.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-04 10:51:07 -08:00
Sebastian Bøe 2ead15de8d cmake: Move syscall_macros.h generation into the build stage
This fixes https://github.com/zephyrproject-rtos/zephyr/issues/5186

The script that generates syscall_macros.h is moved from Configuration
time to build time. This allows us to express to the build system that
syscall_macros.h depends on the script that generates it.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-11-30 06:49:33 -05:00
Sebastian Bøe bc2404aa4d Revert "cmake: add zephyr_cc_option_nocheck"
This reverts commit a01f2de734.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-11-29 09:51:55 -05:00
Anas Nashif a01f2de734 cmake: add zephyr_cc_option_nocheck
Support adding options without checking them with the compiler. In some
cases the simple check routine fails due to missing symbols.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-28 16:48:41 -05:00
Paul Sokolovsky 83cf82b7a8 cmake: qemu: Restore QEMU_PTY/QEMU_PIPE option handling.
Both options were originally parameters to *make*, not cmake, so people
can augment QEMU ibocation from run to run, not from complete rebuild
to complete rebuild. Make them such again.

However, just in case, ability to set "default" value for those options
on CMake level is preserved.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-11-27 22:33:56 -05:00
Sebastian Bøe f71c3fa665 cmake: Extend cc-option support to C++
The target_cc_option[_fallback]() CMake extentions are now C++
aware. This means that they will now test options with both C and C++
compiler and include flags appropriately.

This fixes a warning that was issued when -Wno-pointer-sign was used
 with .cpp files.

cc1plus: warning: command line option ‘-Wno-pointer-sign’ is valid for
C/ObjC but not for C++

NB: This patch is designed to only affect CONFIG_CPLUSPLUS builds in
case there are any adverse affects with using generator expressions.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-11-27 22:21:47 -05:00
Sebastian Bøe 935e95be41 cmake: extensions: Add check_compiler_flag function
This function has presents an easy-to-use interface that wraps the two
CMake built-in functions check_c_compiler_flag() and
check_cxx_compiler_flag().

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-11-27 22:21:47 -05:00
Paul Sokolovsky 5539047d93 cmake: qemu: Restore QEMU_INSTANCE option handling.
QEMU_INSTANCE should be a parameter to *make*, not cmake, so people
can run few instances of the same sample without building each of
them separately in separate dirs.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-11-24 08:28:20 -05:00
Sebastian Bøe 96e7df466a cmake: Give zephyr_library_* flags precedence over zephyr_* flags
This fixes https://github.com/zephyrproject-rtos/zephyr/issues/5097.

The desired behaviour is that when a flag that is given through the
zephyr_* API conflicts with the zephyr_library_* API then precedence
will be given to the zephyr_library_* API. In other words, local
configuration overrides global configuration.

We choose to rely upon the compiler for sane behaviour when flags are
in conflict. Compilers generally give precedence to flags given late
on the command line. So to ensure that zephyr_library_* flags are
placed late on the command line we create a dummy interface library
and link with it to obtain the flags.

Other options were considered, source file properties would also have
higher priority. But that would have required some kind of
post-processing stage that applies all the source file properties.

Linking with a dummy interface library will place flags later on the
command line than the the flags from zephyr_interface because
zephyr_interface will be the first interface library that flags are
taken from.

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-23 09:18:24 -05:00
Sebastian Bøe e51ce4d34d cmake: Generate POST_BUILD items based on KConfig
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-22 13:29:37 -05:00
Anas Nashif be25936bb2 release: make cmake happy about version
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-19 23:16:03 -05:00
Anas Nashif 388286663a cmake: fixed version handling
Use VERSION in top directory to specify version

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-19 23:16:03 -05:00
Sebastian Bøe ce2bfcdb96 cmake: Remove the PREBUILT_HOST_TOOLS variable
The PREBUILT_HOST_TOOLS variable was used during the CMake migration
but is no longer documented or needed. As the docs demonstrate, adding
tools to path is an easy way to find prebuilt host tools.

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-17 17:55:26 -05:00
Sebastian Bøe 9f59045546 cmake: Refactored EXTRA_FLAGS code into a dedicated script
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-15 19:47:44 -05:00
Kumar Gala 999b658f76 cmake: flash: Remove fake path to zephyr_flash_debug.py
We append a path to the FLASH_SCRIPT/DEBUG_SCRIPT that was bogus and not
really needed by zephyr_flash_debug.py.  So lets remove it since its
just confusing.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-11-14 12:07:44 -06:00
Luiz Augusto von Dentz 3eaeeb82ab net: Only enable QEMU_NET_STACK with CONFIG_NET_SLIP_TAP
If CONFIG_NET_SLIP_TAP is not selected QEMU_NET_STACK will not work
which happen when CONFIG_NET_L2_BT is selected.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-11-14 09:52:13 -08:00
Sebastian Bøe 8d0a80c6a9 cmake: Fix SDK-less builds
This change changes the semantics of the environment variable
ZEPHYR_SDK_INSTALL_DIR to allow the use of 3rd party toolchains
alongside the Zephyr SDK's host tools.

Specifically, setting ZEPHYR_SDK_INSTALL_DIR now indicates that the
Zephyr SDK host tools are to be used. But not necessarily that the
Zephyr SDK's toolchain is to be used.

The documentation is also changed to explain this behaviour.

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-13 13:14:32 -05:00
Anas Nashif 539d2af654 flash: support flashing multiple configurations of a single board
Some boards define multiple configuration which all are maintained under
the same board directory. The flasher was looking for an openocd.cfg
based on the board name, which can't be found for such boards.

Use the variable BOARD_DIR provided by cmake instead of trying to
assemble the board directory location on our own.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-13 10:55:26 -05:00
Sebastian Bøe 709cff1b60 cmake: Fail when zephyr_sources() is called on a directory
https://github.com/zephyrproject-rtos/zephyr/issues/4864 revealed that
calling zephyr_sources() on a directory will silently omit the
directory. This is a clear user error and should be immediately
flagged as such.

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-10 11:57:28 -05:00
Sebastian Bøe f0346bfac0 flash: Change type of FLASH_SCRIPT_ENV_VARS
The old way of constructing FLASH_SCRIPT_ENV_VARS was corrupting the
values that were passed to the flasher. This new method is the
standard way of creating a dictionary/hashmap in CMake and does not
suffer from the same problem.

This fixes
https://github.com/zephyrproject-rtos/zephyr/issues/4844#event-1334599401

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-10 07:54:54 -05:00
Sebastian Bøe 8dd3bb8666 flash: Pass env var OPENOCD_DEFAULT_PATH to flasher
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-10 07:54:54 -05:00
Jukka Rissanen ede10b96e4 cmake: Set proper QEMU options for networking applications
If compiling networking application for QEMU, then serial ports
must be set properly for QEMU<->host connectivity using SLIP.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-11-10 14:52:53 +02:00
Anas Nashif 446503dc50 cmake: Support disjoint toolchain and SDK locations
Make more toolchains use the tools provided by the Zephyr SDK.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-09 23:22:11 -05:00
Leandro Pereira 114f6032fe cmake: Support disjoint toolchain and SDK locations
Some toolchains, such as the one provided by Espressif for the ESP32,
or ISSM provided by Intel, will contain only the compiler, linker, and
supporting tools.  Other binaries needed by the build system that are
provided by the Zephyr SDK need to be found somewhere else.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-11-09 19:52:25 -05:00
Sebastian Bøe eb8e7b7969 cmake: Fixed openocd
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe c7832bd343 cmake: Use -serial bt-server when CONFIG_BT
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 4449bef955 cmake: Pass GDB env var to flasher script
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Anas Nashif adb988a577 cmake: fixed version handling
Use VERSION in top directory to specify version

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00