mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
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 akiss@inf.u-szeged.hu
This commit is contained in:
parent
2836f49eec
commit
d5eb2f0be1
@ -16,7 +16,7 @@ script: "python tools/run-tests.py $OPTS"
|
||||
env:
|
||||
- OPTS="--check-signed-off --check-cppcheck --check-vera"
|
||||
- OPTS="--jerry-tests --jerry-test-suite"
|
||||
- OPTS="--jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l-hf.cmake" TIMEOUT=300
|
||||
- OPTS="--jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l.cmake" TIMEOUT=300
|
||||
- OPTS=--buildoption-test
|
||||
- OPTS=--unittests
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l)
|
||||
|
||||
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
|
||||
#
|
||||
@ -15,7 +15,7 @@
|
||||
include(CMakeForceCompiler)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME MCU)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l)
|
||||
set(CMAKE_SYSTEM_VERSION STM32F3)
|
||||
|
||||
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
include(CMakeForceCompiler)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME MCU)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l)
|
||||
set(CMAKE_SYSTEM_VERSION STM32F4)
|
||||
|
||||
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)
|
||||
|
||||
@ -74,7 +74,7 @@ python tools/build.py --toolchain=TOOLCHAIN
|
||||
For example the cross-compile to RaspberryPi 2 is something like this:
|
||||
|
||||
```bash
|
||||
python tools/build.py --toolchain=cmake/toolchain_linux_armv7l-hf.cmake
|
||||
python tools/build.py --toolchain=cmake/toolchain_linux_armv7l.cmake
|
||||
```
|
||||
|
||||
##### To get a list of all the available buildoptions for Linux:
|
||||
|
||||
@ -20,7 +20,7 @@ project (${JERRY_LIBC_NAME} C ASM)
|
||||
# Architecture-specific configuration
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_x64)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-hf")
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_HARD_FLOAT)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-el")
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_SOFT_FLOAT)
|
||||
|
||||
@ -40,7 +40,7 @@ all:
|
||||
-DENABLE_LTO=OFF \
|
||||
-DENABLE_VALGRIND=OFF \
|
||||
-DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_external.cmake \
|
||||
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l-hf \
|
||||
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l \
|
||||
-DEXTERNAL_CMAKE_C_COMPILER=arm-none-eabi-gcc \
|
||||
-DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \
|
||||
-DEXTERNAL_BUILD_ENTRY_FILE=./targets/nuttx-stm32f4/main-nuttx.c \
|
||||
|
||||
@ -37,7 +37,7 @@ libjerry:
|
||||
-DJERRY_CMDLINE=OFF \
|
||||
-DCOMPILER_DEFAULT_LIBC=ON \
|
||||
-DENABLE_ALL_IN_ONE=OFF \
|
||||
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l-hf \
|
||||
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l \
|
||||
-DEXTERNAL_CMAKE_C_COMPILER=arm-none-eabi-gcc \
|
||||
-DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \
|
||||
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
|
||||
|
||||
@ -19,11 +19,16 @@ import argparse
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from os import makedirs
|
||||
from os import makedirs, uname
|
||||
from settings import *
|
||||
|
||||
BUILD_DIR = path.join(PROJECT_DIR, 'build')
|
||||
|
||||
def default_toolchain():
|
||||
(sysname, _, _, _, machine) = uname()
|
||||
toolchain = path.join(PROJECT_DIR, 'cmake', 'toolchain_%s_%s.cmake' % (sysname.lower(), machine.lower()))
|
||||
return toolchain if path.isfile(toolchain) else None
|
||||
|
||||
def add_build_args(parser):
|
||||
parser.add_argument('--verbose', '-v', action='store_const', const='ON', default='OFF', help='Increase verbosity')
|
||||
parser.add_argument('--unittests', action='store_const', const='ON', default='OFF', help='Build unittests too')
|
||||
@ -45,7 +50,7 @@ def add_build_args(parser):
|
||||
parser.add_argument('--cmake-param', action='append', default=[], help='Add custom arguments to CMake')
|
||||
parser.add_argument('--compile-flag', action='append', default=[], help='Add custom compile flag')
|
||||
parser.add_argument('--linker-flag', action='append', default=[], help='Add custom linker flag')
|
||||
parser.add_argument('--toolchain', action='store', default='', help='Add toolchain file')
|
||||
parser.add_argument('--toolchain', action='store', default=default_toolchain(), help='Add toolchain file (default: %(default)s)')
|
||||
parser.add_argument('--jerry-libc', choices=['on', 'off'], default='on', help='Use jerry-libc (default: %(default)s)')
|
||||
parser.add_argument('--compiler-default-libc', choices=['on', 'off'], default='off', help='Use compiler-default libc (default: %(default)s)')
|
||||
parser.add_argument('--jerry-core', choices=['on', 'off'], default='on', help='Use jerry-core (default: %(default)s)')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user