From 8d0a80c6a92e25ffd36d0a2959e23dec7882d160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Mon, 13 Nov 2017 16:19:07 +0100 Subject: [PATCH] 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 --- cmake/host-tools-espressif.cmake | 1 - cmake/host-tools-gccarmemb.cmake | 1 - cmake/host-tools-issm.cmake | 1 - cmake/host-tools-xtools.cmake | 1 - cmake/host-tools-zephyr.cmake | 13 +++++++--- cmake/host-tools.cmake | 2 +- doc/getting_started/getting_started.rst | 34 ++++++++++++++++++++----- 7 files changed, 39 insertions(+), 14 deletions(-) delete mode 100644 cmake/host-tools-espressif.cmake delete mode 100644 cmake/host-tools-gccarmemb.cmake delete mode 100644 cmake/host-tools-issm.cmake delete mode 100644 cmake/host-tools-xtools.cmake diff --git a/cmake/host-tools-espressif.cmake b/cmake/host-tools-espressif.cmake deleted file mode 100644 index a4f86075a34..00000000000 --- a/cmake/host-tools-espressif.cmake +++ /dev/null @@ -1 +0,0 @@ -include($ENV{ZEPHYR_BASE}/cmake/host-tools-zephyr.cmake) diff --git a/cmake/host-tools-gccarmemb.cmake b/cmake/host-tools-gccarmemb.cmake deleted file mode 100644 index a4f86075a34..00000000000 --- a/cmake/host-tools-gccarmemb.cmake +++ /dev/null @@ -1 +0,0 @@ -include($ENV{ZEPHYR_BASE}/cmake/host-tools-zephyr.cmake) diff --git a/cmake/host-tools-issm.cmake b/cmake/host-tools-issm.cmake deleted file mode 100644 index a4f86075a34..00000000000 --- a/cmake/host-tools-issm.cmake +++ /dev/null @@ -1 +0,0 @@ -include($ENV{ZEPHYR_BASE}/cmake/host-tools-zephyr.cmake) diff --git a/cmake/host-tools-xtools.cmake b/cmake/host-tools-xtools.cmake deleted file mode 100644 index a4f86075a34..00000000000 --- a/cmake/host-tools-xtools.cmake +++ /dev/null @@ -1 +0,0 @@ -include($ENV{ZEPHYR_BASE}/cmake/host-tools-zephyr.cmake) diff --git a/cmake/host-tools-zephyr.cmake b/cmake/host-tools-zephyr.cmake index f2154035e7b..83ee94733df 100644 --- a/cmake/host-tools-zephyr.cmake +++ b/cmake/host-tools-zephyr.cmake @@ -5,10 +5,17 @@ # and currently provided by the Zephyr SDK. Those tools will need to be # provided for different OSes and sepearately from the toolchain. +if(DEFINED ENV{ZEPHYR_SDK_INSTALL_DIR}) + set_ifndef(ZEPHYR_SDK_INSTALL_DIR $ENV{ZEPHYR_SDK_INSTALL_DIR}) +endif() +set(ZEPHYR_SDK_INSTALL_DIR ${ZEPHYR_SDK_INSTALL_DIR} CACHE PATH "Zephyr SDK install directory") -set_ifndef(ZEPHYR_SDK_INSTALL_DIR $ENV{ZEPHYR_SDK_INSTALL_DIR}) -set( ZEPHYR_SDK_INSTALL_DIR ${ZEPHYR_SDK_INSTALL_DIR} CACHE PATH "Zephyr SDK install directory") -assert( ZEPHYR_SDK_INSTALL_DIR "ZEPHYR_SDK_INSTALL_DIR is not set") +if(NOT ZEPHYR_SDK_INSTALL_DIR) + # Until https://github.com/zephyrproject-rtos/zephyr/issues/4912 is + # resolved we use ZEPHYR_SDK_INSTALL_DIR to determine whether the user + # wants to use the Zephyr SDK or not. + return() +endif() set(REQUIRED_SDK_VER 0.9.2) set(TOOLCHAIN_VENDOR zephyr) diff --git a/cmake/host-tools.cmake b/cmake/host-tools.cmake index 43d5139c279..52b410cc9bb 100644 --- a/cmake/host-tools.cmake +++ b/cmake/host-tools.cmake @@ -1,4 +1,4 @@ -include($ENV{ZEPHYR_BASE}/cmake/host-tools-${ZEPHYR_GCC_VARIANT}.cmake OPTIONAL) +include($ENV{ZEPHYR_BASE}/cmake/host-tools-zephyr.cmake) if(PREBUILT_HOST_TOOLS) list(APPEND CMAKE_PROGRAM_PATH ${PREBUILT_HOST_TOOLS}/kconfig) diff --git a/doc/getting_started/getting_started.rst b/doc/getting_started/getting_started.rst index 6bff717a339..ef7301a4048 100644 --- a/doc/getting_started/getting_started.rst +++ b/doc/getting_started/getting_started.rst @@ -116,19 +116,27 @@ The ELF binaries generated by the build system are named by default configuration The build system generates different names for different use cases depending on the hardware and boards used. -.. _third_party_x_compilers: -Using Custom and 3rd Party Cross Compilers -========================================== +.. _sdkless_builds: + +Building without the Zephyr SDK +=============================== The Zephyr SDK is provided for convenience and ease of use. It provides cross-compilers for all ports supported by the Zephyr OS and does not require any extra flags when building applications or running tests. -If you have a custom cross-compiler or if you wish to use a vendor provided SDK, -follow the steps below to build with any custom or 3rd party cross-compilers: +In addition to cross-compilers, the Zephyr SDK also provides prebuilt +host tools. To use the SDK host tools alongside a custom or 3rd party +cross-compiler, keep the ZEPHYR_SDK_INSTALL_DIR environment variable +set to the Zephyr SDK installation directory. -#. To avoid any conflicts with the Zephyr SDK, enter the following commands. +To build without the Zephyr SDK's prebuilt host tools, the +ZEPHYR_SDK_INSTALL_DIR environment variable must be unset, the host +tools must be built and added to path, and a 3rd party cross-compiler +must be installed. + +#. Follow the steps below to build without the Zephyr SDK: .. code-block:: console @@ -152,6 +160,20 @@ follow the steps below to build with any custom or 3rd party cross-compilers: You only need to do this once after cloning the git repository. +Now that the host tools are installed, a 3rd party cross compiler must +be installed. See :ref:`below ` for +installing a cross compiler. + +.. _third_party_x_compilers: + +Using Custom and 3rd Party Cross Compilers +========================================== + +To use a 3rd party cross compiler that is not provided by the Zephyr +SDK, follow the steps below. It is possible to use a 3rd party cross +compiler and still use the Zephyr SDK's host tools. See :ref:`the +section above ` for details. + #. We will use the `GCC ARM Embedded`_ compiler for this example, download the package suitable for your operating system from the `GCC ARM Embedded`_ website and extract it on your file system. This example assumes the compiler was