aboutsummaryrefslogtreecommitdiff
path: root/00.GETTING-STARTED.md
blob: a136573bba4b755ef57f3783c34a606079de5218 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
---
layout: page
title: Getting Started
category: navbar
permalink: /getting-started/
---

* toc
{:toc}

## Setting up prerequisites

Currently, only Ubuntu 18.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:

- `gcc` or 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.11`
- `cppcheck` >= `1.61`
- `clang-format-10` >= `10.0.0`
- `python` >= `2.7.6`

```bash
sudo apt-get install gcc gcc-arm-none-eabi cmake cppcheck clang-format-10 python
```

To make our scripts run correctly, several shell utilities should be available on the system:

- `awk`
- `bc`
- `find`
- `sed`

## Building JerryScript

**To build debug version for Linux**

```bash
python tools/build.py --debug
```

**To build debug version for Linux without LTO (Link Time Optimization)**

```bash
python tools/build.py --debug --lto=off
```

**To enable more verbose outputs for debugging**

```bash
tools/build.py --debug --logging=on --error-messages=on --line-info=on
```

**Add custom arguments to CMake**

```bash
python tools/build.py --cmake-param=CMAKE_PARAM
```

**Set a profile mode (es.next, minimal)**

```bash
python tools/build.py --profile=es.next|minimal
```

See also the related [README.md](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-core/profiles/README.md).

**Use (compiler-default, external) libc**

The default libc is the compiler-default libc but you can use an external libc as well:

- compiler-default libc:

```bash
python tools/build.py
```

- external libc:

```bash
python tools/build.py --compile-flag="-nostdlib -I/path/to/ext-libc/include" --link-lib="ext-c"
```

**Add toolchain file**

The ```cmake``` dir already contains some usable toolchain files, which you can use in the following format:

```bash
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.cmake
```

**Use system memory allocator**

```bash
python tools/build.py --system-allocator=on
```

*Note*: System allocator is only supported on 32 bit systems.

**Enable 32bit compressed pointers**

```bash
python tools/build.py --cpointer-32bit=on
```

*Note*: There is no compression/decompression on 32 bit systems, if enabled.

**Change default heap size (512K)**

```bash
python tools/build.py --mem-heap=256
```

If you would like to use more than 512K, then you must enable the 32 bit compressed pointers.

```bash
python tools/build.py --cpointer-32bit=on --mem-heap=1024
```

*Note*: The heap size will be allocated statically at compile time, when JerryScript memory
allocator is used.

**To build with libfuzzer support**

```bash
CC=clang python tools/build.py --libfuzzer=on --compile-flag=-fsanitize=address --lto=off
```

Check the documentation of libfuzzer to get the runtime settings of the created fuzzer
binary: https://llvm.org/docs/LibFuzzer.html.

**To get a list of all the available buildoptions for Linux**

```bash
python tools/build.py --help
```

## Checking patch

```bash
python tools/run-tests.py --precommit
```

### Running only one type of test

**To run build option tests**

```bash
python tools/run-tests.py --buildoption-test
```

**To run unittests**

```bash
python tools/run-tests.py --unittests
```

**To run jerry-tests**

```bash
python tools/run-tests.py --jerry-tests
```

**To run signed-off check**

```bash
python tools/run-tests.py --check-signed-off
```

**To run cppcheck**

```bash
python tools/run-tests.py --check-cppcheck
```

**To run format check**

```bash
python tools/run-tests.py --check-format
```

**To get a list of all the available test options**

```bash
python tools/run-tests.py --help
```