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
About
This folder contains files to run JerryScript on RIOT-OS with STM32F4-Discovery board.
How to build
1. Preface
1, Directory structure
Assume harmony as the path to the projects to build.
The folder tree related would look like this.
harmony
+ jerryscript
| + targets
| + riot-stm32f4
+ RIOT
2, Target board
Assume STM32F4-Discovery with BB as the target board.
2. Prepare RIOT-OS
Follow this page to get the RIOT-OS source.
Follow the Inroduction wiki site and also check that you can flash the stm32f4-board.
3. Build JerryScript for RIOT-OS
# assume you are in harmony folder
cd jerryscript
make -f ./targets/riot-stm32f4/Makefile.riot
This will generate the following libraries:
/build/bin/release.riotstm32f4/librelease.jerry-core.a
/build/bin/release.riotstm32f4/librelease.jerry-libm.lib.a
This will copy one library files to targets/riot-stm32f4/bin folder:
libjerrycore.a
This will create a hex file in the targets/riot-stm32f4/bin folder:
riot_jerry.elf
4. Flashing
make -f ./targets/riot-stm32f4/Makefile.riot flash
For how to flash the image with other alternative way can be found here: Alternative way to flash
5. Cleaning
To clean the build result:
make -f ./targets/riot-stm32f4/Makefile.riot clean
5. Running JerryScript Hello World! example
You may have to press RESET on the board after the flash.
You can use minicom for terminal program, and if the prompt shows like this:
main(): This is RIOT! (Version: ****)
You are running RIOT on a(n) stm32f4discovery board.
This board features a(n) stm32f4 MCU.
please set Add Carriage Ret option by CTRL-A > Z > U at the console, if you're using minicom.
Help will provide a list of commands:
> help
The test command will run the test example, which contains the following script code:
print ('Hello, World!');