Skip to content

Commit e456ab5

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

File tree

6 files changed

+202
-42
lines changed

6 files changed

+202
-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_x86_64.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ set(CMAKE_SYSTEM_PROCESSOR x86_64)
1717

1818
find_program(CMAKE_C_COMPILER NAMES x86_64-linux-gnu-gcc x86_64-unknown-linux-gnu-gcc)
1919
find_program(CMAKE_CXX_COMPILER NAMES x86_64-linux-gnu-g++ x86_64-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 x86_64-linux-gnu-strip x86_64-unknown-linux-gnu-strip strip)
20+
find_program(CMAKE_STRIP NAMES x86_64-linux-gnu-strip x86_64-unknown-linux-gnu-strip)
2221

2322
set(FLAGS_COMMON_ARCH -ffixed-rbp)

tools/precommit-full-testing.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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_PARSE_ONLY=$OUT_DIR/$TARGET/check_parse_only
29+
LOGS_PATH_FULL=$OUT_DIR/$TARGET/check
30+
31+
# Parse-only testing
32+
INDEX=0
33+
for TESTS_PATH in "./tests/benchmarks/jerry"
34+
do
35+
./tools/runners/run-precommit-check-for-target.sh $ENGINE $LOGS_PATH_PARSE_ONLY/$INDEX $TESTS_PATH --parse-only &
36+
RUN_IDS="$RUN_IDS $!";
37+
INDEX=$((INDEX + 1))
38+
done
39+
40+
# Full testing
41+
INDEX=0
42+
for TESTS_PATH in "./tests/jerry" "./tests/jerry-test-suite/precommit_test_list"
43+
do
44+
./tools/runners/run-precommit-check-for-target.sh $ENGINE $LOGS_PATH_FULL/$INDEX $TESTS_PATH &
45+
RUN_IDS="$RUN_IDS $!";
46+
INDEX=$((INDEX + 1))
47+
done
48+
done
49+
50+
RESULT_OK=1
51+
for RUN_ID in $RUN_IDS
52+
do
53+
wait $RUN_ID || RESULT_OK=0
54+
done;
55+
[ $RESULT_OK -eq 1 ] || exit 1
56+
57+
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: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
SCRIPT=$(readlink -f $0)
18+
BASE_DIR=`dirname ${SCRIPT}`
19+
20+
OUT_DIR=${BASE_DIR}/../.././build/bin
21+
TARGET=$1 #debug.linux release.linux
22+
TARGET_IP=$2
23+
TARGET_USER=$3
24+
TARGET_PASS=$4
25+
26+
export SSHPASS=${TARGET_PASS}
27+
28+
ENGINE=${OUT_DIR}/${TARGET}/jerry
29+
LOGS_PATH_PARSE_ONLY=${OUT_DIR}/${TARGET}/check_parse_only
30+
LOGS_PATH_FULL=${OUT_DIR}/${TARGET}/check
31+
32+
rm -rf ${LOGS_PATH_PARSE_ONLY}
33+
rm -rf ${LOGS_PATH_FULL}
34+
35+
mkdir -p ${LOGS_PATH_PARSE_ONLY}
36+
mkdir -p ${LOGS_PATH_FULL}
37+
38+
REMOTE_TMP_DIR=`sshpass -e ssh ${TARGET_USER}@${TARGET_IP} 'mktemp -d'`
39+
40+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "mkdir -p ${REMOTE_TMP_DIR}/build/bin/${TARGET}"
41+
sshpass -e scp ${ENGINE} ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}/build/bin/${TARGET}
42+
43+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "mkdir -p ${REMOTE_TMP_DIR}/build/bin/${TARGET}/check_parse_only"
44+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "mkdir -p ${REMOTE_TMP_DIR}/build/bin/${TARGET}/check"
45+
46+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "mkdir -p ${REMOTE_TMP_DIR}/tests/benchmarks"
47+
sshpass -e scp -r ${BASE_DIR}/../.././tests/benchmarks/* ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}/tests/benchmarks
48+
49+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "mkdir -p ${REMOTE_TMP_DIR}/tests/jerry"
50+
sshpass -e scp -r ${BASE_DIR}/../.././tests/jerry/* ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}/tests/jerry
51+
52+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "mkdir -p ${REMOTE_TMP_DIR}/tests/jerry-test-suite"
53+
sshpass -e scp -r ${BASE_DIR}/../.././tests/jerry-test-suite/* ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}/tests/jerry-test-suite
54+
55+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "mkdir -p ${REMOTE_TMP_DIR}/tools/runners"
56+
sshpass -e scp -r ${BASE_DIR}/../.././tools/runners/* ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}/tools/runners
57+
58+
sshpass -e scp -r ${BASE_DIR}/../.././tools/precommit-full-testing.sh ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}/tools
59+
60+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "cd ${REMOTE_TMP_DIR}; ./tools/precommit-full-testing.sh ./build/bin $TARGET > run.log 2>&1"
61+
62+
sshpass -e scp -r ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}/build/bin/${TARGET}/check_parse_only/* ${LOGS_PATH_PARSE_ONLY}
63+
sshpass -e scp -r ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}/build/bin/${TARGET}/check/* ${LOGS_PATH_FULL}
64+
sshpass -e scp ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}/run.log ${OUT_DIR}
65+
66+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "rm -rf ${REMOTE_TMP_DIR}"
67+
68+
if grep -q fail "${OUT_DIR}/run.log"; then
69+
echo "${ENGINE} testing failed"
70+
if grep -q check_parse_only "${OUT_DIR}/run.log"; then
71+
echo "See logs in ${LOGS_PATH_PARSE_ONLY} directory for details."
72+
fi
73+
if grep -q check\/ "${OUT_DIR}/run.log"; then
74+
echo "See logs in ${LOGS_PATH_FULL} directory for details."
75+
fi
76+
exit 1
77+
fi
78+
79+
rm -f ${OUT_DIR}/run.log

tools/runners/run-unittests-remote.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
SCRIPT=$(readlink -f $0)
18+
BASE_DIR=`dirname $SCRIPT`
19+
20+
OUT_DIR=${BASE_DIR}/../.././build/bin
21+
22+
rm -rf ${OUT_DIR}/unittests/check
23+
24+
mkdir -p ${OUT_DIR}/unittests/check
25+
26+
TARGET_IP=$1
27+
TARGET_USER=$2
28+
TARGET_PASS=$3
29+
30+
export SSHPASS=${TARGET_PASS}
31+
REMOTE_TMP_DIR=`sshpass -e ssh ${TARGET_USER}@${TARGET_IP} 'mktemp -d'`
32+
33+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "mkdir -p ${REMOTE_TMP_DIR}/check"
34+
sshpass -e scp ${BASE_DIR}/../../tools/runners/run-unittests.sh ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}
35+
sshpass -e scp -r ${OUT_DIR}/unittests/* ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}
36+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "${REMOTE_TMP_DIR}/run-unittests.sh ${REMOTE_TMP_DIR} \
37+
echo $? > ${REMOTE_TMP_DIR}/target_unittests_run.log"
38+
sshpass -e scp -r ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}/*.log ${OUT_DIR}/unittests
39+
sshpass -e scp -r ${TARGET_USER}@${TARGET_IP}:${REMOTE_TMP_DIR}/check ${OUT_DIR}/unittests
40+
sshpass -e ssh ${TARGET_USER}@${TARGET_IP} "rm -rf ${REMOTE_TMP_DIR}"
41+
42+
STATUS=`cat ${OUT_DIR}/unittests/target_unittests_run.log`
43+
44+
if [ ${STATUS} == 0 ] ; then
45+
echo "Unit tests run passed"
46+
exit 0
47+
else
48+
echo "Unit tests run failed. See ${OUT_DIR}/unittests/unit_tests_run.log for details."
49+
exit 1
50+
fi

0 commit comments

Comments
 (0)