Skip to content

Commit 444bd32

Browse files
committed
Add support of cross-compilation for linux-based targets.
Usage: - Cross compile: make debug.linux TOOLCHAIN=./build/configs/toolchain_linux_armv7l-el.cmake - Build unittests make unittests TOOLCHAIN=./build/configs/toolchain_linux_armv7l-el.cmake - Run unittests on target board ./tools/runners/run-unittests-remote.sh <ip> <login> <pass> - Run JavaScript test on target board ./tools/runners/run-tests-remote.sh debug.linux <ip> <login> <pass> JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin e.gavrin@samsung.com
1 parent be2de16 commit 444bd32

File tree

6 files changed

+211
-42
lines changed

6 files changed

+211
-42
lines changed

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,24 @@ export SHELL=/bin/bash
150150
all: precommit
151151

152152
$(BUILD_DIRS_NATIVE): prerequisites
153-
@ arch=`uname -m`; \
154-
if [ "$$arch" == "armv7l" ]; \
153+
@ if [ "$$TOOLCHAIN" == "" ]; \
155154
then \
156-
readelf -A /proc/self/exe | grep Tag_ABI_VFP_args && arch=$$arch"-hf" || arch=$$arch"-el";\
155+
arch=`uname -m`; \
156+
if [ "$$arch" == "armv7l" ]; \
157+
then \
158+
readelf -A /proc/self/exe | grep Tag_ABI_VFP_args && arch=$$arch"-hf" || arch=$$arch"-el"; \
159+
fi; \
160+
TOOLCHAIN="build/configs/toolchain_linux_$$arch.cmake"; \
157161
fi; \
162+
if [ -d "$@" ]; \
163+
then \
164+
grep -s -q "$$TOOLCHAIN" $@/toolchain.config || rm -rf $@ ; \
165+
fi; \
158166
mkdir -p $@ && \
159167
cd $@ && \
160-
cmake -DENABLE_VALGRIND=$(VALGRIND) -DENABLE_LOG=$(LOG) -DENABLE_LTO=$(LTO) -DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_linux_$$arch.cmake ../../.. &>cmake.log || \
161-
(echo "CMake run failed. See "`pwd`"/cmake.log for details."; exit 1;)
168+
cmake -DENABLE_VALGRIND=$(VALGRIND) -DENABLE_LOG=$(LOG) -DENABLE_LTO=$(LTO) -DCMAKE_TOOLCHAIN_FILE=$$TOOLCHAIN ../../.. &>cmake.log || \
169+
(echo "CMake run failed. See "`pwd`"/cmake.log for details."; exit 1;); \
170+
echo "$$TOOLCHAIN" > toolchain.config
162171

163172
$(BUILD_DIRS_NUTTX): prerequisites
164173
@ [ "$(EXTERNAL_LIBC_INTERFACE)" != "" ] && [ -x `which $(EXTERNAL_C_COMPILER)` ] && [ -x `which $(EXTERNAL_CXX_COMPILER)` ] || \

build/configs/toolchain_linux_i686.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@
1515
set(CMAKE_SYSTEM_NAME Linux)
1616
set(CMAKE_SYSTEM_PROCESSOR x86)
1717

18-
set(CMAKE_C_COMPILER i686-linux-gnu-gcc)
19-
set(CMAKE_CXX_COMPILER i686-linux-gnu-g++)
18+
find_program(CMAKE_C_COMPILER NAMES i686-linux-gnu-gcc i686-unknown-linux-gnu-gcc)
19+
find_program(CMAKE_CXX_COMPILER NAMES i686-linux-gnu-g++ i686-unknown-linux-gnu-g++)
20+
# FIXME: This could break cross compilation, when the strip is not for the target architecture
21+
find_program(CMAKE_STRIP NAMES i686-linux-gnu-strip i686-unknown-linux-gnu-strip strip)

tools/precommit-full-testing.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# Copyright 2015 Samsung Electronics Co., Ltd.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
OUT_DIR="$1"
18+
shift
19+
20+
TARGETS="$1"
21+
shift
22+
23+
RUN_IDS=""
24+
25+
for TARGET in ${TARGETS}
26+
do
27+
ENGINE=${OUT_DIR}/${TARGET}/jerry
28+
LOGS_PATH_FULL=${OUT_DIR}/${TARGET}/check
29+
30+
# Full testing
31+
INDEX=0
32+
for TESTS_PATH in "./tests/jerry" "./tests/jerry-test-suite/precommit_test_list"
33+
do
34+
./tools/runners/run-precommit-check-for-target.sh "${ENGINE}" "${LOGS_PATH_FULL}"/"${INDEX}" "${TESTS_PATH}" &
35+
RUN_IDS="${RUN_IDS} $!";
36+
INDEX=$((INDEX + 1))
37+
done
38+
done
39+
40+
RESULT_OK=1
41+
for RUN_ID in ${RUN_IDS}
42+
do
43+
wait "${RUN_ID}" || RESULT_OK=0
44+
done;
45+
[ ${RESULT_OK} -eq 1 ] || exit 1
46+
47+
echo -e "Full testing completed successfully\n\n================\n\n"

tools/precommit.sh

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,38 +57,4 @@ echo -e "All targets were built successfully. Starting unit tests' run.\n"
5757
$MAKE unittests_run || exit 1
5858
echo -e "\nUnit tests completed successfully. Starting full testing.\n"
5959

60-
RUN_IDS=""
61-
62-
for TARGET in $TARGETS
63-
do
64-
ENGINE=$OUT_DIR/$TARGET/jerry
65-
LOGS_PATH_PARSE_ONLY=$OUT_DIR/$TARGET/check_parse_only
66-
LOGS_PATH_FULL=$OUT_DIR/$TARGET/check
67-
68-
# Parse-only testing
69-
INDEX=0
70-
for TESTS_PATH in "./tests/benchmarks/jerry"
71-
do
72-
./tools/runners/run-precommit-check-for-target.sh $ENGINE $LOGS_PATH_PARSE_ONLY/$INDEX $TESTS_PATH --parse-only &
73-
RUN_IDS="$RUN_IDS $!";
74-
INDEX=$((INDEX + 1))
75-
done
76-
77-
# Full testing
78-
INDEX=0
79-
for TESTS_PATH in "./tests/jerry" "./tests/jerry-test-suite/precommit_test_list"
80-
do
81-
./tools/runners/run-precommit-check-for-target.sh $ENGINE $LOGS_PATH_FULL/$INDEX $TESTS_PATH &
82-
RUN_IDS="$RUN_IDS $!";
83-
INDEX=$((INDEX + 1))
84-
done
85-
done
86-
87-
RESULT_OK=1
88-
for RUN_ID in $RUN_IDS
89-
do
90-
wait $RUN_ID || RESULT_OK=0
91-
done;
92-
[ $RESULT_OK -eq 1 ] || exit 1
93-
94-
echo -e "Full testing completed successfully\n\n================\n\n"
60+
./tools/precommit-full-testing.sh "${OUT_DIR}" "${TARGETS}" || exit 1

tools/runners/run-tests-remote.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
# Copyright 2015 Samsung Electronics Co., Ltd.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
TARGET="$1" #debug.linux release.linux
18+
TARGET_IP="$2" # ip address of target board
19+
TARGET_USER="$3" # login
20+
TARGET_PASS="$4" # password
21+
22+
if [ $# -lt 4 ]
23+
then
24+
echo "This script runs ./jerry/* and ./jerry-test-suite/* tests on the remote board."
25+
echo ""
26+
echo "Usage:"
27+
echo " 1st parameter: target to be tested: {debug.linux, release.linux}"
28+
echo " 2nd parameter: ip address of target board: {110.110.110.110}"
29+
echo " 3rd parameter: ssh login to target board: {login}"
30+
echo " 4th parameter: ssh password to target board: {password}"
31+
echo ""
32+
echo "Example:"
33+
echo " ./tools/runners/run-tests-remote.sh debug.linux 110.110.110.110 login password"
34+
exit 1
35+
fi
36+
37+
BASE_DIR=$(dirname "$(readlink -f "$0")" )
38+
39+
OUT_DIR="${BASE_DIR}"/../.././build/bin
40+
LOGS_PATH_FULL="${OUT_DIR}"/"${TARGET}"/check
41+
42+
export SSHPASS="${TARGET_PASS}"
43+
44+
rm -rf "${LOGS_PATH_FULL}"
45+
46+
mkdir -p "${LOGS_PATH_FULL}"
47+
48+
REMOTE_TMP_DIR=$(sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" 'mktemp -d')
49+
REMOTE_TMP_TAR=$(sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" 'mktemp')
50+
LOCAL_TMP_TAR=$(mktemp)
51+
52+
tar -zcf "${LOCAL_TMP_TAR}" \
53+
"${BASE_DIR}"/../.././build/bin/"${TARGET}" \
54+
"${BASE_DIR}"/../.././tests/benchmarks \
55+
"${BASE_DIR}"/../.././tests/jerry \
56+
"${BASE_DIR}"/../.././tests/jerry-test-suite \
57+
"${BASE_DIR}"/../.././tools/runners \
58+
"${BASE_DIR}"/../.././tools/precommit-full-testing.sh > /dev/null 2>&1
59+
60+
sshpass -e scp "${LOCAL_TMP_TAR}" "${TARGET_USER}"@"${TARGET_IP}":"${REMOTE_TMP_TAR}"
61+
62+
sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" \
63+
"tar -zxf \"${REMOTE_TMP_TAR}\" -C \"${REMOTE_TMP_DIR}\"; rm \"${REMOTE_TMP_TAR}\";\
64+
cd \"${REMOTE_TMP_DIR}\"; \
65+
./tools/precommit-full-testing.sh ./build/bin \"$TARGET\" > ./build/bin/\"${TARGET}\"/check/run.log 2>&1; \
66+
echo \$? > ./build/bin/\"${TARGET}\"/check/IS_TEST_OK"
67+
68+
sshpass -e scp -r "${TARGET_USER}"@"${TARGET_IP}":"${REMOTE_TMP_DIR}"/build/bin/"${TARGET}"/check/* "${LOGS_PATH_FULL}"
69+
sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" "rm -rf \"${REMOTE_TMP_DIR}\""
70+
71+
STATUS=$(cat "${LOGS_PATH_FULL}"/IS_TEST_OK)
72+
73+
if [ "${STATUS}" == 0 ] ; then
74+
echo "${TARGET} testing passed."
75+
exit 0
76+
else
77+
echo "${TARGET} testing failed."
78+
echo "See logs in ${LOGS_PATH_FULL} directory for details."
79+
exit 1
80+
fi

tools/runners/run-unittests-remote.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
# Copyright 2015 Samsung Electronics Co., Ltd.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
TARGET_IP="$1"
18+
TARGET_USER="$2"
19+
TARGET_PASS="$3"
20+
21+
if [ $# -lt 3 ]
22+
then
23+
echo "This script runs unittests on the remote board."
24+
echo ""
25+
echo "Usage:"
26+
echo " 1st parameter: ip address of target board: {110.110.110.110}"
27+
echo " 2nd parameter: ssh login to target board: {login}"
28+
echo " 3rd parameter: ssh password to target board: {password}"
29+
echo ""
30+
echo "Example:"
31+
echo " ./tools/runners/run-unittests-remote.sh 110.110.110.110 login password"
32+
exit 1
33+
fi
34+
35+
BASE_DIR=$(dirname "$(readlink -f "$0")" )
36+
37+
OUT_DIR="${BASE_DIR}"/../.././build/bin
38+
39+
rm -rf "${OUT_DIR}"/unittests/check
40+
41+
mkdir -p "${OUT_DIR}"/unittests/check
42+
43+
export SSHPASS="${TARGET_PASS}"
44+
REMOTE_TMP_DIR=$(sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" 'mktemp -d')
45+
46+
sshpass -e scp "${BASE_DIR}"/../../tools/runners/run-unittests.sh "${TARGET_USER}"@"${TARGET_IP}":"${REMOTE_TMP_DIR}"
47+
sshpass -e scp -r "${OUT_DIR}"/unittests/* "${TARGET_USER}"@"${TARGET_IP}":"${REMOTE_TMP_DIR}"
48+
49+
sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" "mkdir -p \"${REMOTE_TMP_DIR}\"/check; \
50+
\"${REMOTE_TMP_DIR}\"/run-unittests.sh \"${REMOTE_TMP_DIR}\"; \
51+
echo \$? > \"${REMOTE_TMP_DIR}\"/check/IS_REMOTE_TEST_OK"
52+
53+
sshpass -e scp -r "${TARGET_USER}"@$"{TARGET_IP}":"${REMOTE_TMP_DIR}"/check "${OUT_DIR}"/unittests
54+
55+
sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" "rm -rf \"${REMOTE_TMP_DIR}\""
56+
57+
STATUS=$(cat "${OUT_DIR}"/unittests/check/IS_REMOTE_TEST_OK)
58+
59+
if [ "${STATUS}" == 0 ] ; then
60+
echo "Unit tests run passed."
61+
exit 0
62+
else
63+
echo "Unit tests run failed. See ${OUT_DIR}/unittests/unit_tests_run.log for details."
64+
exit 1
65+
fi

0 commit comments

Comments
 (0)