Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Replacing Make/Kbuild with CMake #1488

Closed
63 of 73 tasks
nashif opened this issue Sep 13, 2017 · 5 comments
Closed
63 of 73 tasks

Replacing Make/Kbuild with CMake #1488

nashif opened this issue Sep 13, 2017 · 5 comments
Assignees
Labels
Feature A planned feature with a milestone
Milestone

Comments

@nashif
Copy link
Member

nashif commented Sep 13, 2017

This PR implements RFC: Replacing Make/Kbuild with CMake

The Gerrit feedback has been addressed, but the work is not complete. It is uploaded in an incomplete form to enable collaboration and early feedback.

Work In Progress

Blocker TODOs

TODOs that must be fixed before the PR is merged.

  • Remove KBuild
  • Update SDK to 0.9.2 when it is ready
  • Support Device tree
  • Support generating isr_tables
  • Support generating offsets.c
  • Integrate with sanitycheck.
    • Verify that all samples are similar enough[0] before and after CMake
  • Integrate with Zephyr CI.
  • Update docs.
    • getting_started
      • getting_started.rst
      • linux.rst
      • win.rst
      • mac.rst
    • Update build instructions throughout docs using 'make` (~140 uses)
    • Document how to develop CMakeLists.txt code
  • Check if all Make CLI arguments are supported by an equivalent CMake feature
    • Support the equivalent of make help
    • Integrate with qemu
    • Integrate with openocd
    • Support debugserver
    • Support debug
    • Support flash
    • Support ram_report
    • Support rom_report
    • Support W=
    • Support htmldocs
  • Support configuring the build for code size, speed, unoptimzed, etc.
  • Port kernel
  • Port arch
    • arm
    • arc
    • nios2
    • riscv32
    • x86
    • xtensa
  • Port boards
    • arm
    • x86
    • xtensa
    • riscv32
    • arc
    • nios2
  • Port ext
  • Port subsys
  • Port samples
  • Port tests
  • Have CMake recursively call CMake to build host tools instead of
    requiring the user to first invoke a seperate CMake build system to
    build the host tools.
    Host tools will be provided in the SDK, non-SDK users will have to manually build Kconfig and add it to path.
  • Support default BOARD's in application CMakeLists.txt code.[1]
  • Fix the CLI usability problem: -DCMAKE_TOOLCHAIN_FILE=$ZEPHYR_BASE/cmake/toolchain.cmake
  • Test with
    • Linux,
    • OSX,
    • Windows + MinGW
  • Test with
    • Make
  • Port all supported toolchains
    • zephyr
    • gccarmemb
    • issm
    • espressif
    • riscv32 (The riscv32 toolchain is deprecated)
    • xcc (Requires RHEL 4 or 5)
    • xtools

Non-blocker TODOs

TODOs that must be fixed, but may be delayed until after the PR is merged.

  • Support building Zephyr on Windows natively (without MinGW)
  • Test with Ninja
  • Check if it is acceptable to use an older version of
    CMake. Currently minumum required version is 3.7, but the latest
    Ubuntu LTS ships with 3.5. Supporting an older version would make it
    easier for users to get started with Zephyr.
  • Ensure that verbose and normal builds are logging the appropriate amount of information.
  • Port this business logic that is present in many applications:

ifeq ($(CONFIG_NET_L2_BT), y)
QEMU_EXTRA_FLAGS = -serial unix:/tmp/bt-server-bredr
else
include $(ZEPHYR_BASE)/samples/net/common/Makefile.ipstack
endif

Un-classified TODOs

TODOs in need of being classified as Blocker or non-blocker.

  • Evaluate how application CMakeLists.txt code should integrate
    with Zephyr CMakeLists.txt code. Currently they interact in a manner
    very similair to how KBuild worked, but even though this worked for
    KBuild, it might not be the best solution for a CMake build system.
    In particular, consider the "bootloader use-case" of a multi-program
    build.
  • Support KBuild's ld-option (The ability to test if the linker
    supports a flag).
  • Introduce more CMake extentions to reduce boilerplate and enforce
    conventions in driver/ subsys/ ext/ CMakeLists.txt code.
  • Integrate more Kconfig targets than menuconfig

Getting started

Install CMake (>=3.7)
Install Python 3 (>=3.4)

Optionally install Ninja, recommended for most users.
To enable Ninja add the flag -GNinja when calling cmake.

Windows

Open Windows Command Prompt:

set ZEPHYR_BASE=
set ZEPHYR_GCC_VARIANT=gccarmemb
set GCCARMEMB_TOOLCHAIN_PATH=
set BOARD=nrf52_pca10040

cd samples\bluetooth\beacon
cmake -Bbuild -H.
cmake --build build

Linux

$ source zephyr-env.sh

$ cd $ZEPHYR_BASE/scripts
$ mkdir build && cd build
$ cmake .. && make
$ export PREBUILT_HOST_TOOLS=$(pwd)

$ export BOARD=nrf52_pca10040
$ export ZEPHYR_SDK_INSTALL_DIR=
$ export ZEPHYR_GCC_VARIANT=zephyr

$ cd $ZEPHYR_BASE/samples/bluetooth/beacon
$ cmake -Bbuild -H.
$ cmake --build build

[0] Binary identical FW's before and after the CMake transition would
make verification easy. But it may not be what we really want.
[1] #1107 (comment)

@nashif nashif added the Feature A planned feature with a milestone label Sep 13, 2017
@nashif nashif added this to the v1.10 milestone Sep 13, 2017
@nashif nashif added the In progress For PRs: is work in progress and should not be merged yet. For issues: Is being worked on label Sep 13, 2017
@nashif nashif modified the milestones: v1.10, v1.10.0 Oct 3, 2017
@carlescufi
Copy link
Member

carlescufi commented Nov 9, 2017

Of the blocker todos, everything is done AFAICT except the documentation.

Carles @SebastianBoe: samples/*.rst (except samples/net)
@jukkar @tbursztyka @mike-scott: samples/net/*.rst
@mbolivar: boards/*.rst
@nashif: tests/*.rst

@nashif @galak Anything else I'm missing?

@ntakouris
Copy link

Why Install CMake (>=3.7) ? Current apt version is way lower

@carlescufi
Copy link
Member

@Zarkopafilis I believe it's due to requiring add_custom_command() to use DEPFILE, which was introduced in CMake 3.7. The getting started guide gives you a step by step guide on installing CMake from cmake.org, and it's quite simple.

@ntakouris
Copy link

ntakouris commented Nov 15, 2017 via email

@carlescufi
Copy link
Member

@Zarkopafilis that's because the CMake scripts detect that you're running MSYS and lower the required version. It's an exception in the case of MSYS, which doesn't support Ninja. This is temporary since we will soon switch to native CMake with Ninja and no MSYS at all on Windows.

nagineni pushed a commit to nagineni/zephyr that referenced this issue Nov 20, 2017
A bug in Zephyr prevents this from working currently, but it has been
fixed in zephyrproject-rtos#1284. This just enables DHCP for
platforms other than K64F. Also, a minor style/convention tweak.

Fixes zephyrproject-rtos#1488

Signed-off-by: Geoff Gustafson <geoff@linux.intel.com>
@ghost ghost removed the In progress For PRs: is work in progress and should not be merged yet. For issues: Is being worked on label Nov 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A planned feature with a milestone
Projects
None yet
Development

No branches or pull requests

7 participants