1425bb815Sopenharmony_ci## Setting up prerequisites 2425bb815Sopenharmony_ci 3425bb815Sopenharmony_ciCurrently, only Ubuntu 18.04+ is officially supported as primary development environment. 4425bb815Sopenharmony_ci 5425bb815Sopenharmony_ciThere are several dependencies, that should be installed manually. The following list is the absolute minimum for building: 6425bb815Sopenharmony_ci 7425bb815Sopenharmony_ci- `gcc` or any C99-compliant compiler (native or cross, e.g., arm-none-eabi) 8425bb815Sopenharmony_ci- `cmake` >= `2.8.12.2` 9425bb815Sopenharmony_ci 10425bb815Sopenharmony_ciSeveral scripts and tools help the building and development process, thus it is recommended to have the following installed as well: 11425bb815Sopenharmony_ci 12425bb815Sopenharmony_ci- `bash` >= `4.3.11` 13425bb815Sopenharmony_ci- `cppcheck` >= `1.61` 14425bb815Sopenharmony_ci- `vera++` >= `1.2.1` 15425bb815Sopenharmony_ci- `python` >= `2.7.6` 16425bb815Sopenharmony_ci 17425bb815Sopenharmony_ci```bash 18425bb815Sopenharmony_cisudo apt-get install gcc gcc-arm-none-eabi cmake cppcheck vera++ python 19425bb815Sopenharmony_ci``` 20425bb815Sopenharmony_ci 21425bb815Sopenharmony_ciTo make our scripts run correctly, several shell utilities should be available on the system: 22425bb815Sopenharmony_ci 23425bb815Sopenharmony_ci- `awk` 24425bb815Sopenharmony_ci- `bc` 25425bb815Sopenharmony_ci- `find` 26425bb815Sopenharmony_ci- `sed` 27425bb815Sopenharmony_ci 28425bb815Sopenharmony_ci## Building JerryScript 29425bb815Sopenharmony_ci 30425bb815Sopenharmony_ci**To build debug version for Linux** 31425bb815Sopenharmony_ci 32425bb815Sopenharmony_ci```bash 33425bb815Sopenharmony_cipython tools/build.py --debug 34425bb815Sopenharmony_ci``` 35425bb815Sopenharmony_ci 36425bb815Sopenharmony_ci**To build debug version for Linux without LTO (Link Time Optimization)** 37425bb815Sopenharmony_ci 38425bb815Sopenharmony_ci```bash 39425bb815Sopenharmony_cipython tools/build.py --debug --lto=off 40425bb815Sopenharmony_ci``` 41425bb815Sopenharmony_ci 42425bb815Sopenharmony_ci**To enable more verbose outputs for debugging** 43425bb815Sopenharmony_ci 44425bb815Sopenharmony_ci```bash 45425bb815Sopenharmony_citools/build.py --debug --logging=on --error-messages=on --line-info=on 46425bb815Sopenharmony_ci``` 47425bb815Sopenharmony_ci 48425bb815Sopenharmony_ci**Add custom arguments to CMake** 49425bb815Sopenharmony_ci 50425bb815Sopenharmony_ci```bash 51425bb815Sopenharmony_cipython tools/build.py --cmake-param=CMAKE_PARAM 52425bb815Sopenharmony_ci``` 53425bb815Sopenharmony_ci 54425bb815Sopenharmony_ci**Set a profile mode (ES5.1, subset of ES2015, minimal)** 55425bb815Sopenharmony_ci 56425bb815Sopenharmony_ci```bash 57425bb815Sopenharmony_cipython tools/build.py --profile=es5.1|es2015-subset|minimal 58425bb815Sopenharmony_ci``` 59425bb815Sopenharmony_ci 60425bb815Sopenharmony_ciSee also the related [README.md](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-core/profiles/README.md). 61425bb815Sopenharmony_ci 62425bb815Sopenharmony_ci**Use (compiler-default, external) libc** 63425bb815Sopenharmony_ci 64425bb815Sopenharmony_ciThe default libc is the compiler-default libc but you can use an external libc as well: 65425bb815Sopenharmony_ci 66425bb815Sopenharmony_ci- compiler-default libc: 67425bb815Sopenharmony_ci 68425bb815Sopenharmony_ci```bash 69425bb815Sopenharmony_cipython tools/build.py 70425bb815Sopenharmony_ci``` 71425bb815Sopenharmony_ci 72425bb815Sopenharmony_ci- external libc: 73425bb815Sopenharmony_ci 74425bb815Sopenharmony_ci```bash 75425bb815Sopenharmony_cipython tools/build.py --compile-flag="-nostdlib -I/path/to/ext-libc/include" --link-lib="ext-c" 76425bb815Sopenharmony_ci``` 77425bb815Sopenharmony_ci 78425bb815Sopenharmony_ci**Add toolchain file** 79425bb815Sopenharmony_ci 80425bb815Sopenharmony_ciThe ```cmake``` dir already contains some usable toolchain files, which you can use in the following format: 81425bb815Sopenharmony_ci 82425bb815Sopenharmony_ci```bash 83425bb815Sopenharmony_cipython tools/build.py --toolchain=TOOLCHAIN 84425bb815Sopenharmony_ci``` 85425bb815Sopenharmony_ci 86425bb815Sopenharmony_ciFor example the cross-compile to RaspberryPi 2 is something like this: 87425bb815Sopenharmony_ci 88425bb815Sopenharmony_ci```bash 89425bb815Sopenharmony_cipython tools/build.py --toolchain=cmake/toolchain_linux_armv7l.cmake 90425bb815Sopenharmony_ci``` 91425bb815Sopenharmony_ci 92425bb815Sopenharmony_ci**Use system memory allocator** 93425bb815Sopenharmony_ci 94425bb815Sopenharmony_ci```bash 95425bb815Sopenharmony_cipython tools/build.py --system-allocator=on 96425bb815Sopenharmony_ci``` 97425bb815Sopenharmony_ci 98425bb815Sopenharmony_ci*Note*: System allocator is only supported on 32 bit systems. 99425bb815Sopenharmony_ci 100425bb815Sopenharmony_ci**Enable 32bit compressed pointers** 101425bb815Sopenharmony_ci 102425bb815Sopenharmony_ci```bash 103425bb815Sopenharmony_cipython tools/build.py --cpointer-32bit=on 104425bb815Sopenharmony_ci``` 105425bb815Sopenharmony_ci 106425bb815Sopenharmony_ci*Note*: There is no compression/decompression on 32 bit systems, if enabled. 107425bb815Sopenharmony_ci 108425bb815Sopenharmony_ci**Change default heap size (512K)** 109425bb815Sopenharmony_ci 110425bb815Sopenharmony_ci```bash 111425bb815Sopenharmony_cipython tools/build.py --mem-heap=256 112425bb815Sopenharmony_ci``` 113425bb815Sopenharmony_ci 114425bb815Sopenharmony_ciIf you would like to use more than 512K, then you must enable the 32 bit compressed pointers. 115425bb815Sopenharmony_ci 116425bb815Sopenharmony_ci```bash 117425bb815Sopenharmony_cipython tools/build.py --cpointer-32bit=on --mem-heap=1024 118425bb815Sopenharmony_ci``` 119425bb815Sopenharmony_ci 120425bb815Sopenharmony_ci*Note*: The heap size will be allocated statically at compile time, when JerryScript memory 121425bb815Sopenharmony_ciallocator is used. 122425bb815Sopenharmony_ci 123425bb815Sopenharmony_ci**To build with libfuzzer support** 124425bb815Sopenharmony_ci 125425bb815Sopenharmony_ci```bash 126425bb815Sopenharmony_ciCC=clang python tools/build.py --libfuzzer=on --compile-flag=-fsanitize=address --lto=off 127425bb815Sopenharmony_ci``` 128425bb815Sopenharmony_ci 129425bb815Sopenharmony_ciCheck the documentation of libfuzzer to get the runtime settings of the created fuzzer 130425bb815Sopenharmony_cibinary: https://llvm.org/docs/LibFuzzer.html. 131425bb815Sopenharmony_ci 132425bb815Sopenharmony_ci**To get a list of all the available buildoptions for Linux** 133425bb815Sopenharmony_ci 134425bb815Sopenharmony_ci```bash 135425bb815Sopenharmony_cipython tools/build.py --help 136425bb815Sopenharmony_ci``` 137425bb815Sopenharmony_ci 138425bb815Sopenharmony_ci## Checking patch 139425bb815Sopenharmony_ci 140425bb815Sopenharmony_ci```bash 141425bb815Sopenharmony_cipython tools/run-tests.py --precommit 142425bb815Sopenharmony_ci``` 143425bb815Sopenharmony_ci 144425bb815Sopenharmony_ci### Running only one type of test 145425bb815Sopenharmony_ci 146425bb815Sopenharmony_ci**To run build option tests** 147425bb815Sopenharmony_ci 148425bb815Sopenharmony_ci```bash 149425bb815Sopenharmony_cipython tools/run-tests.py --buildoption-test 150425bb815Sopenharmony_ci``` 151425bb815Sopenharmony_ci 152425bb815Sopenharmony_ci**To run unittests** 153425bb815Sopenharmony_ci 154425bb815Sopenharmony_ci```bash 155425bb815Sopenharmony_cipython tools/run-tests.py --unittests 156425bb815Sopenharmony_ci``` 157425bb815Sopenharmony_ci 158425bb815Sopenharmony_ci**To run jerry-tests** 159425bb815Sopenharmony_ci 160425bb815Sopenharmony_ci```bash 161425bb815Sopenharmony_cipython tools/run-tests.py --jerry-tests 162425bb815Sopenharmony_ci``` 163425bb815Sopenharmony_ci 164425bb815Sopenharmony_ci**To run jerry-test-suite** 165425bb815Sopenharmony_ci 166425bb815Sopenharmony_ci```bash 167425bb815Sopenharmony_cipython tools/run-tests.py --jerry-test-suite 168425bb815Sopenharmony_ci``` 169425bb815Sopenharmony_ci 170425bb815Sopenharmony_ci**To run signed-off check** 171425bb815Sopenharmony_ci 172425bb815Sopenharmony_ci```bash 173425bb815Sopenharmony_cipython tools/run-tests.py --check-signed-off 174425bb815Sopenharmony_ci``` 175425bb815Sopenharmony_ci 176425bb815Sopenharmony_ci**To run cppcheck** 177425bb815Sopenharmony_ci 178425bb815Sopenharmony_ci```bash 179425bb815Sopenharmony_cipython tools/run-tests.py --check-cppcheck 180425bb815Sopenharmony_ci``` 181425bb815Sopenharmony_ci 182425bb815Sopenharmony_ci**To run vera check** 183425bb815Sopenharmony_ci 184425bb815Sopenharmony_ci```bash 185425bb815Sopenharmony_cipython tools/run-tests.py --check-vera 186425bb815Sopenharmony_ci``` 187425bb815Sopenharmony_ci 188425bb815Sopenharmony_ci**To get a list of all the available test options** 189425bb815Sopenharmony_ci 190425bb815Sopenharmony_ci```bash 191425bb815Sopenharmony_cipython tools/run-tests.py --help 192425bb815Sopenharmony_ci``` 193