Skip to content

Added travis script to build and run jerryscript with zephyr #1144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tools/apt-get-install-deps.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tools/apt-get-install-qemu-arm.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tools/brew-install-deps.sh; fi
- if [[ "$TARGET" == "build-zephyr" ]]; then tools/apt-get-install-zephyr-deps.sh; fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need a $TRAVIS_OS_NAME here?

Copy link
Author

@Akromx16 Akromx16 Jun 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 3rd build fails (the one with toolchain) if I choose TRAVIS_OS_NAME == linux. I think there are some conflicts in the packages installed.

Travis error is:
CMake Error at CMakeLists.txt:16 (project):
The CMAKE_C_COMPILER:
arm-linux-gnueabihf-gcc
is not a full path and was not found in the PATH.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.

Maybe I can change the order of the dependencies scripts...so that I call the install-zephyr.sh before all other scripts, perhaps this could fix the conflict....Although I thought it was better for that dependency script to be called only for the build in which it's actually building and running the zephyr with jerryscript.


install:

Expand All @@ -26,5 +27,8 @@ matrix:
env: TARGET="build.darwin test-js"
- os: osx
env: TARGET=test-unit
- os: linux
env: TARGET=build-zephyr
allow_failures:
- os: osx
- env: TARGET=build-zephyr
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ clean:
check-signed-off:
$(Q) ./tools/check-signed-off.sh

.PHONY: build-zephyr
build-zephyr:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still confused here. Is this only build or test it too? Release or debug?

Copy link
Author

@Akromx16 Akromx16 Jun 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what I should put there. I just followed the example of check-signed-off and did the same with build-zephyr. It basically builds and runs (to test) it.

$(Q) ./tools/build-zephyr.sh

.PHONY: check-vera
check-vera:
$(Q) $(call SHLOG,./tools/check-vera.sh,$(OUT_DIR)/vera.log,Vera++)
Expand Down
14 changes: 7 additions & 7 deletions targets/arduino_101/src/main-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,24 @@ static int shell_cmd_handler (int argc, char *argv[])

* (d - 1) = '\0';

if (flags & VERBOSE)
{
printf ("[%s] %lu\n", source_buffer, strlen (source_buffer));
}

jerry_completion_code_t ret_code;

ret_code = jerry_run_simple ((jerry_char_t *) source_buffer,
strlen (source_buffer),
JERRY_FLAG_EMPTY);

free (source_buffer);

if (ret_code != JERRY_COMPLETION_CODE_OK)
{
printf ("Failed to run JS\n");
}

if (flags & VERBOSE || ret_code != JERRY_COMPLETION_CODE_OK)
{
printf ("[%s] %lu\n", source_buffer, strlen (source_buffer));
}

free (source_buffer);

return 0;
} /* shell_cmd_handler */

Expand Down
20 changes: 20 additions & 0 deletions tools/apt-get-install-zephyr-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Copyright © 2016 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

sudo apt-get update -q
sudo apt-get install -q -y \
gcc gcc-multilib g++ g++-multilib libc6-dev-i386 \
python3-ply linux-libc-dev build-essential
82 changes: 82 additions & 0 deletions tools/build-zephyr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

# Copyright © 2016 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# clone zephyr repo
git clone https://gerrit.zephyrproject.org/r/zephyr
cd zephyr
git checkout tags/v1.4.0

# download the zephyr_sdk installer script
wget https://nexus.zephyrproject.org/content/repositories/releases/org/\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

wget https://nexus.zephyrproject.org/content/repositories/releases/org/ \
    zephyrproject/zephyr-sdk/0.8-i686/zephyr-sdk-0.8-i686-setup.run

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that wouldn't work. I tried looking into ways of splitting that as well as indenting, but couldn't find a nice looking one in bash...i am splitting it but i cannot indent it as well (afaik)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. If the whitespaces breaks the wget command then it is OK to write it in one long line. :)

zephyrproject/zephyr-sdk/0.8-i686/zephyr-sdk-0.8-i686-setup.run

# extract the zephyr-sdk installer
chmod +x zephyr-sdk-0.8-i686-setup.run
mkdir zephyr_sdk_installer && cd zephyr_sdk_installer
../zephyr-sdk-0.8-i686-setup.run --target $(pwd) --noexec

# install the zephyr_sdk
mkdir ../zephyr_sdk && cd ../zephyr_sdk
export ZEPHYR_SDK_INSTALL_DIR=$(pwd)
cd ../zephyr_sdk_installer
./setup.sh -d $ZEPHYR_SDK_INSTALL_DIR

# source the zephyr required environment variables
source ../zephyr-env.sh
export ZEPHYR_GCC_VARIANT=zephyr

# back to jerryscript dir
cd ../..

# link asm-generic to asm (otherwise there will be errors with include headers)
sudo ln -s /usr/include/asm-generic /usr/include/asm

# build jerryscript for qemu
make -f ./targets/arduino_101/Makefile.arduino_101 BOARD=qemu_x86

# create 2 named pipes to input jerryscript commands and evaluate the output
mkfifo path.in path.out

# run the qemu executable in background using the named pipes
./zephyr/zephyr_sdk/sysroots/i686-pokysdk-linux/usr/bin/qemu-system-i386 -m 32 \
-cpu qemu32 -no-reboot -nographic -vga none -display none -net none \
-clock dynticks -no-acpi -balloon none \
-L ./zephyr/zephyr_sdk/sysroots/i686-pokysdk-linux/usr/share/qemu \
-bios bios.bin -machine type=pc-0.14 -serial pipe:path \
-kernel ./build/qemu_x86/zephyr/zephyr.elf & sleep 5

# listen for any output and direct it to log for further checking
cat path.out > log.txt & sleep 5

# write the jerryscript "test" command in the input named pipe
printf "test\r\n" > path.in
sleep 5

# kill qemu executable process (which is marked as first job that runs in background)
kill %1

# show the log output and check if the string "Hi JS World!" is present there
cat log.txt
if grep "Hi JS World!" log.txt > /dev/null
then
echo -e "\n\nQapla'! (it means \"Success\" in Klingon)"
else
echo -e "\n\nScript has failed"
fi

# run the grep command again, so that in the case of not finding the string, the
# grep command will return a non 0 value, which will make travis fail the build
grep "Hi JS World!" log.txt > /dev/null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this file more readable. Add some comment and empty line, break long lines where you can, etc. I'd rename this file, because it not just builds zephyr (ex.: build-and-test-zephyr-target.sh).