Commit graph

34 commits

Author SHA1 Message Date
Martí Bolívar a043d48c54 cmake: fix the build on windows
Commit ef3c5e5516 changed the way
WEST_TOPDIR is initialized from calling 'west topdir' as a subprocess
to using the west API.

However, WEST_TOPDIR is a cmake variable and must be a cmake-style
path, with forward slashes. While 'west topdir' as a command does
output a forward slash separated path (basically in order to make the
zephyr build system work), west_topdir() as an API returns the path in
the host environment path style, which on Windows uses backslashes.

This turns out to be the ultimate cause of the following build error:

CMake Error at C:/.../CheckCCompilerFlag.cmake:41 (set):
  Syntax error in cmake code when parsing string
    -fmacro-prefix-map=C:\Users\Marti\zp=WEST_TOPDIR

Fix it by converting to POSIX style in Python. We could have
potentially also done this using file(TO_CMAKE_PATH "${WEST_TOPDIR}"
...), but I'm intentionally repeating the old way of doing things
since it was known to work.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-09 18:13:44 -04:00
Torsten Rasmussen ef3c5e5516 cmake: west: invoke west using same python as rest of build system
When running CMake, then Python3 will be used.
This is detected through FindPython3, with a preference for using the
python or python3 in path, if any of those matches the required Python
minimal version in Zephyr.

It is also possible for users to specify a different Python, as example
by using:
`cmake -DPYTHON_PREFER=/usr/bin/python3.x`

However, when running `west` as native command, then west will be
invoked on linux based on the python defined in:
`west` launcher, which could be: `#!/usr/bin/python3.y`

Thus there could be mismatch in Pythons used for `west` and the python
used for other scripts.

This is even worse on windows, where a user might experience:
```
>.\opt\bin\Scripts\west.exe --version
Traceback (most recent call last):
  File "C:\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  ...
  File "C:\Python37\lib\socket.py", line 49, in <module>
    import _socket
ImportError: Module use of python38.dll conflicts with this version of
Python.
```

when testing out a newer Python, but the python in path is still a 3.7.

By importing `west` into zephyr_module.py and by using, as example
`python -c "from west.util import west_topdir; print(topdir())"`
we ensure the same python is used in all python scripts.

Also it allows the user to control the python to use for west.

It also ensures that the west version being tested, is also the version
being used, where old code would test the version imported by python,
but using the west in path (which could be a different version)

If the west version installed in the current Python, and west invocation
is using a different Python interpreter, then an additional help text
is printed, to easier assist users with debugging.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-07-08 23:23:04 -04:00
Torsten Rasmussen 8e8c6cd92b cmake: improved DTC detection handling
Fixes: #26096

In some cases DTC may be installed, but in a non-working state.
In such cases, CMake will abort processing with an cryptic error.

This commit now handles dtc version errors and print a warning., and
CMake processing continues.

dtc is an optional component and failures should not break CMake run.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-06-12 17:10:36 +02:00
Martí Bolívar 14d55bcad8 cmake: host-tools fixes for DTC
1. Fix the regular expression used to parse version numbers. This uses
\. and . to parse literal dots; the second one matches any character.
Just use [.] instead in both cases.

2. Don't error out if the installed dtc is too old. It's optional, so
we should just proceed without it. Print a warning instead, and make
it so dts.cmake won't do anything with the installed dtc.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-05 11:05:58 -05:00
Martí Bolívar 53f6aaee2e cmake: host-tools cosmetics
Align the comment styles for each tool.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-05 11:05:58 -05:00
Torsten Rasmussen 39cd4c8f52 cmake: propagating zephyr base to west
West utilizes Zephyr base when invoked out-of-tree in order to determine
west topdir.

This commit ensures that zephyr base when invoking west from CMake is
set to current zephyr base.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Emil Hammarstrom df9adeca44 cmake: Bump MIN_WEST_VERSION to 0.7.1
Updated WEST_DIR requires version >= 0.7.0

Signed-off-by: Emil Hammarstrom <emil.a.hammarstrom@gmail.com>
2020-03-23 17:55:14 +01:00
Torsten Rasmussen 9dbc5eeb3b cmake: Invoke west topdir only with version >= 0.7.1
West version 0.7.0 introduced `west topdir` command.
Unfortunately version 0.7.0 would print the path in windows path style
when executed in Windows.

This commit ensure that `west topdir` is only used if west >= 0.7.1.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-02-10 22:52:34 +01:00
Sebastian Bøe f17428a009 cmake: Have gperf be opt-out instead of mandatory
gperf is only used when CONFIG_USERSPACE is enabled. Users that use
arch's that don't support CONFIG_USERSPACE, or happen to not never
enable CONFIG_USERSPACE should not be artificially required to install
gperf.

This change makes gperf optional by moving it's presence-check to it's
usage.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2020-02-08 09:13:45 -05:00
Sebastian Bøe 23df708aa3 dtc: Support opting-out of installing dtc
dtc is only used for static analysis (producing warnings) of the
DeviceTree sources. This means that valid Zephyr firmware can sanely
be built without it.

For some users, for instance Windows users that are not permitted to
use Chocolatey, installing dtc is problematic and installing it is not
worth the DT warnings that it provides.

To make using Zephyr easier for these users we make using DTC
recommended and opt-out, instead of mandatory.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2020-01-28 12:47:54 -06:00
Marc Herbert eddbf3c986 cmake: -fmacro-prefix-map=${WEST_TOPDIR}=WEST_TOPDIR
Commit 28a5657f1f and f67dcdbdf8 stopped ZEPHYR_BASE and
CMAKE_SOURCE_DIR from leaking into __FILE__ and other macros.
WEST_TOPDIR was still missing. Add it now that the new 'west topdir'
command has been implemented in
https://github.com/zephyrproject-rtos/west/pull/311

If the west version is too old then do nothing; same as before.

Any ASSERT in a zephyr module outside ZEPHYR_BASE is enough to test
this. One example:

$ZEPHYR_BASE/sanitycheck -T $ZEPHYR_BASE/tests/posix/fs/ -p qemu_x86 -v

readelf --string-dump=.rodata.disk_status.str1.1 {} \
  $(find sanity-out -name zfs_diskio.c.obj | head -n 1)

String dump of section '.rodata.disk_status.str1.1':

  [     0]  WEST_TOPDIR/modules/fs/fatfs/zfs_diskio.c
  [    2a]  pdrv < ((long) (((int) sizeof(char[1 - 2 * !(!__built....
  [    de]  ASSERTION FAIL [%s] @ %s:%d^J

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-11-06 21:17:56 +01:00
Sebastian Bøe 6d6173f247 cmake: Speed up CMake by not invoking 'west'
Speed up CMake by 100ms by importing west instead of invoking it as an
executable.

There is significant overhead in invoking west as a script via
pip. The exact reason why is not clear.

Also, simplify the version output parsing as we get the version in a
more machine-readable form now.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-11-05 15:05:48 -06:00
Marti Bolivar 2b3d9df1d7 west: require v0.6.0 or higher
The main change is the elimination of the bootstrapper, a design flaw
/ misfeature.

Update the documentation to be compatible with the 0.6.x releases as
well. This has to be done atomically, as there were incompatible
changes.  Make use of the versionchanged and versionadded directives
to begin keeping track of how these APIs are evolving.

(Note that west 0.6.0 will remain compatible with the extension
commands in Zephyr v1.14 LTS as long as that is still alive. This
change is targeted towards Zephyr 2.0 users.)

This requires a bump in the shippable container and allows us to
simplify the west_commands test procedure.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-05 15:17:45 +02:00
Thomas Stilwell 538e12e5c3 cmake: fix regex for west version check in host-tools.cmake
'west --version' output has the path to the west manifest directory.
If there is a semantic version string in this path name, it will
raise a false version check failure.

Signed-off-by: Thomas Stilwell <Thomas.Stilwell@nordicsemi.no>
2019-05-21 08:19:09 -04:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Marti Bolivar 2785bee30e west: require version 0.5.6
Set the revision to the v0.5.6 tag in west.yml and update the minimum
version. Barring any (more) major undiscovered issues, this will be the
version used with Zephyr v1.14.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-25 22:46:56 -04:00
Marti Bolivar 6929c374a4 cmake: add west version checking
Parse the west version output and make sure both bootstrapper and
installation wests are up to date. This will still work after the two
are combined into what gets installed via PyPI.

Fixes: #13209
Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-11 20:37:27 -07:00
Anas Nashif 2b9458c378 doc: restructure and create index pages
Move all lead pages to be index pages and create redirect rules from the
old pointers.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-05 07:04:40 -05:00
Carles Cufi 1b5bed04e2 cmake: Use west installation directly
Since we install west from pip and it becomes an executable, use it
directly assuming it's in the user's PATH.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-01-29 10:15:01 +01:00
Anas Nashif 55cf16a524 toolchains: move zephyr sdk host tools to toolchain folder
Should be part of other files related to the Zephyr SDK.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-24 10:51:14 -06:00
Mark Ruvald Pedersen 0efad5f7fd cmake: Whitespace and commentary fixes
Cosmetics, no functional change expected.
Fixed leading space alignment.
Replaced tabs with spaces.
Emulation error message output is now aligned.

To locate tabs in cmake, the following bash is useful:
grep -PRil "\t" * | grep -i cmake | grep -v ^sanity

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-12-20 12:23:50 +01: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
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
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
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
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
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 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 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 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 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
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 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