Although both jerry-libc and jerry-libm have configuration options that enable/disable their build, in practice, only jerry-libc can be replaced with the system (compiler-default) libc. If jerry-libm is disabled, the build of jerry-main fails, as there is no way to instruct the linker to link the system libm to the binary. (The build system does have a way to pass flags to the linker, but those flags are listed before the linked objects. For the references to get resolved correctly, the libraries to be linked have to be specified _after_ the objects.) This patch adds the EXTERNAL_LINK_LIBS configuration option to CMakeLists, which ensures that the specified libraries get correctly passed to the linker. (E.g, replacing jerry-libm with system libm becomes possible with `JERRY_LIBM=OFF EXTERNAL_LINK_LIBS='-lm'`.) Additionally, the patch also makes the following related changes: * Removes the COMPILER_DEFAULT_LIBC configuration option, as it is (almost) always the opposite of JERRY_LIBC. Moreover, its name is misleading: its only role is to add `-nostdlib` to the linker flags. * Makes use of transitive library dependencies: if a library has another library as dependency, and it is linked to a binary, its dependency is linked as well. Thus, jerry-libc, jerry-libm, and any external libraries are added to jerry-core as dependency, and then only jerry-core is linked to executables (cmake will take care of the rest). * build.py and run-tests.py follow up the changes, along with some minor syntax changes. * Moves static linking option to global CMakeLists, as unit test binaries should be linked the same way as jerry-main. * Adds EXTERNAL_COMPILER_FLAGS and EXTERNAL_LINKER_FLAGS as last to the flag list, to allow user override of (nearly) anything. The patch speculatively follows up the build system changes in the mbed, riot-stm32f4, and zephyr targets. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2.7 KiB
Setting up prerequisites
Currently, only Ubuntu 14.04+ is officially supported as primary development environment.
There are several dependencies, that should be installed manually. The following list is the absolute minimum for building:
gccor any C99-compliant compiler (native or cross, e.g., arm-none-eabi)cmake>=2.8.12.2
Several scripts and tools help the building and development process, thus it is recommended to have the following installed as well:
bash>=4.3.11cppcheck>=1.61vera++>=1.2.1python>=2.7.6
sudo apt-get install gcc gcc-arm-none-eabi cmake cppcheck vera++ python
To make our scripts run correctly, several shell utilities should be available on the system:
awkbcfindsed
Building JerryScript
To build debug version for Linux
python tools/build.py --debug
To build debug version for Linux without LTO (Link Time Optimization)
python tools/build.py --debug --lto=off
Add custom arguments to CMake
python tools/build.py --cmake-param=CMAKE_PARAM
Set a profile mode (full, minimal)
python tools/build.py --feature=full|minimal
Use (jerry, compiler-default, external) libc
The default libc is jerry-libc, but you can use compiler-default libc or an external libc:
- compiler-default libc:
python tools/build.py --jerry-libc=off
- external libc:
python tools/build.py --jerry-libc=off --compile-flag="-nostdlib -I/path/to/ext-libc/include" --link-lib="-lext-c"
Add toolchain file
The cmake dir already contains some usable toolchain files, which you can use in the following format:
python tools/build.py --toolchain=TOOLCHAIN
For example the cross-compile to RaspberryPi 2 is something like this:
python tools/build.py --toolchain=cmake/toolchain_linux_armv7l.cmake
To get a list of all the available buildoptions for Linux
python tools/build.py --help
Checking patch
python tools/run-tests.py --precommit
Running only one type of test
To run build option tests
python tools/run-tests.py --buildoption-test
To run unittests
python tools/run-tests.py --unittests
To run jerry-tests
python tools/run-tests.py --jerry-tests
To run jerry-test-suite
python tools/run-tests.py --jerry-test-suite
To run signed-off check
python tools/run-tests.py --check-signed-off
To run cppcheck
python tools/run-tests.py --check-cppcheck
To run vera check
python tools/run-tests.py --check-vera
To get a list of all the available test options
python tools/run-tests.py --help