Skip to content

Commit d5eb2f0

Browse files
committed
Let the build script use a default for toolchain
The `cmake` directory already contains several toolchain files for various platforms (operating system + architecture). However, `tools/build.py` does not define a toolchain file for cmake unless explicitly specified. This patch changes the script to look into the `cmake` directory for a file named `toolchain_$(os)_$(arch).cmake` and, if found, pass that to cmake by default. OS and arch are determined by `os.uname()`. As Linux on Raspberry Pi identifies itself as "armv7l", the legacy "armv7l-hf" arch name is shortened to "armv7l". This way, building jerry on RPi (natively, not cross) becomes possible by simply running `tools/build.py` without any extra options. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent 2836f49 commit d5eb2f0

File tree

9 files changed

+15
-10
lines changed

9 files changed

+15
-10
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ script: "python tools/run-tests.py $OPTS"
1616
env:
1717
- OPTS="--check-signed-off --check-cppcheck --check-vera"
1818
- OPTS="--jerry-tests --jerry-test-suite"
19-
- OPTS="--jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l-hf.cmake" TIMEOUT=300
19+
- OPTS="--jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l.cmake" TIMEOUT=300
2020
- OPTS=--buildoption-test
2121
- OPTS=--unittests
2222

cmake/toolchain_linux_armv7l-hf.cmake renamed to cmake/toolchain_linux_armv7l.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
set(CMAKE_SYSTEM_NAME Linux)
16-
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)
16+
set(CMAKE_SYSTEM_PROCESSOR armv7l)
1717

1818
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
1919
#

cmake/toolchain_mcu_stm32f3.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
include(CMakeForceCompiler)
1616

1717
set(CMAKE_SYSTEM_NAME MCU)
18-
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)
18+
set(CMAKE_SYSTEM_PROCESSOR armv7l)
1919
set(CMAKE_SYSTEM_VERSION STM32F3)
2020

2121
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)

cmake/toolchain_mcu_stm32f4.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
include(CMakeForceCompiler)
1616

1717
set(CMAKE_SYSTEM_NAME MCU)
18-
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)
18+
set(CMAKE_SYSTEM_PROCESSOR armv7l)
1919
set(CMAKE_SYSTEM_VERSION STM32F4)
2020

2121
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)

docs/01.GETTING-STARTED.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ python tools/build.py --toolchain=TOOLCHAIN
7474
For example the cross-compile to RaspberryPi 2 is something like this:
7575

7676
```bash
77-
python tools/build.py --toolchain=cmake/toolchain_linux_armv7l-hf.cmake
77+
python tools/build.py --toolchain=cmake/toolchain_linux_armv7l.cmake
7878
```
7979

8080
##### To get a list of all the available buildoptions for Linux:

jerry-libc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ project (${JERRY_LIBC_NAME} C ASM)
2020
# Architecture-specific configuration
2121
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
2222
set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_x64)
23-
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-hf")
23+
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
2424
set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_HARD_FLOAT)
2525
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-el")
2626
set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_SOFT_FLOAT)

targets/nuttx-stm32f4/Makefile.nuttx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ all:
4040
-DENABLE_LTO=OFF \
4141
-DENABLE_VALGRIND=OFF \
4242
-DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_external.cmake \
43-
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l-hf \
43+
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l \
4444
-DEXTERNAL_CMAKE_C_COMPILER=arm-none-eabi-gcc \
4545
-DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \
4646
-DEXTERNAL_BUILD_ENTRY_FILE=./targets/nuttx-stm32f4/main-nuttx.c \

targets/riot-stm32f4/Makefile.riot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ libjerry:
3737
-DJERRY_CMDLINE=OFF \
3838
-DCOMPILER_DEFAULT_LIBC=ON \
3939
-DENABLE_ALL_IN_ONE=OFF \
40-
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l-hf \
40+
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l \
4141
-DEXTERNAL_CMAKE_C_COMPILER=arm-none-eabi-gcc \
4242
-DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \
4343
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \

tools/build.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@
1919
import shutil
2020
import subprocess
2121
import sys
22-
from os import makedirs
22+
from os import makedirs, uname
2323
from settings import *
2424

2525
BUILD_DIR = path.join(PROJECT_DIR, 'build')
2626

27+
def default_toolchain():
28+
(sysname, _, _, _, machine) = uname()
29+
toolchain = path.join(PROJECT_DIR, 'cmake', 'toolchain_%s_%s.cmake' % (sysname.lower(), machine.lower()))
30+
return toolchain if path.isfile(toolchain) else None
31+
2732
def add_build_args(parser):
2833
parser.add_argument('--verbose', '-v', action='store_const', const='ON', default='OFF', help='Increase verbosity')
2934
parser.add_argument('--unittests', action='store_const', const='ON', default='OFF', help='Build unittests too')
@@ -45,7 +50,7 @@ def add_build_args(parser):
4550
parser.add_argument('--cmake-param', action='append', default=[], help='Add custom arguments to CMake')
4651
parser.add_argument('--compile-flag', action='append', default=[], help='Add custom compile flag')
4752
parser.add_argument('--linker-flag', action='append', default=[], help='Add custom linker flag')
48-
parser.add_argument('--toolchain', action='store', default='', help='Add toolchain file')
53+
parser.add_argument('--toolchain', action='store', default=default_toolchain(), help='Add toolchain file (default: %(default)s)')
4954
parser.add_argument('--jerry-libc', choices=['on', 'off'], default='on', help='Use jerry-libc (default: %(default)s)')
5055
parser.add_argument('--compiler-default-libc', choices=['on', 'off'], default='off', help='Use compiler-default libc (default: %(default)s)')
5156
parser.add_argument('--jerry-core', choices=['on', 'off'], default='on', help='Use jerry-core (default: %(default)s)')

0 commit comments

Comments
 (0)