22#
33# Copyright (C) 2019 Ultimaker B.V.
44#
5- # SPDX-License-Identifier: LGPL-3.0+
65
76set -eu
87
@@ -15,11 +14,8 @@ BUILD_DIR_TEMPLATE="_build_${ARCH}"
1514BUILD_DIR=" ${BUILD_DIR:- ${SRC_DIR} / ${BUILD_DIR_TEMPLATE} } "
1615
1716run_env_check=" yes"
18- run_linters=" yes"
19- run_tests=" yes"
20-
21- # Run the make_docker.sh script here, within the context of the build_for_ultimaker.sh script
22- . ./make_docker.sh " "
17+ run_verification=" yes"
18+ action=" none"
2319
2420env_check ()
2521{
@@ -31,25 +27,11 @@ run_build()
3127 run_in_docker " ./build.sh" " ${@ } "
3228}
3329
34- deliver_pkg ()
35- {
36- run_in_docker chown -R " $( id -u) :$( id -g) " " ${DOCKER_WORK_DIR} "
37-
38- cp " ${BUILD_DIR} /" * " .deb" " ./"
39- }
40-
41- run_tests ()
30+ run_verification ()
4231{
4332 echo " Testing!"
44- # These tests should never fail! See .gitlab-ci.yml
45- ./run_style_analysis.sh || echo " Code Style Analaysis Failed!"
46- ./run_mypy.sh || echo " MYPY Analysis Failed!"
47- ./run_pytest.sh || echo " PyTest failed!"
48- }
49-
50- run_linters ()
51- {
52- run_shellcheck
33+ # These verifications should never fail! See .gitlab-ci.yml
34+ ./ci/local/run_all.sh
5335}
5436
5537run_shellcheck ()
@@ -67,27 +49,23 @@ usage()
6749 echo " Usage: ${0} [OPTIONS]"
6850 echo " -c Skip build environment checks"
6951 echo " -h Print usage"
70- echo " -l Skip code linting"
71- echo " -t Skip tests"
52+ echo " -s Skip code verification"
7253}
7354
74- while getopts " :chlst " options; do
55+ while getopts " :a:chls " options; do
7556 case " ${options} " in
57+ a)
58+ action=" ${OPTARG} "
59+ ;;
7660 c)
7761 run_env_check=" no"
7862 ;;
7963 h)
8064 usage
8165 exit 0
8266 ;;
83- l)
84- run_linters=" no"
85- ;;
86- t)
87- run_tests=" no"
88- ;;
8967 s)
90- # Ignore for compatibility with other build scripts
68+ run_verification= " no "
9169 ;;
9270 :)
9371 echo " Option -${OPTARG} requires an argument."
@@ -106,21 +84,40 @@ if ! command -V docker; then
10684 exit 1
10785fi
10886
87+ case " ${action} " in
88+ shellcheck)
89+ run_shellcheck
90+ exit 0
91+ ;;
92+ build)
93+ source ./docker_env/make_docker.sh " "
94+ run_build
95+ exit 0
96+ ;;
97+ build_docker_cache)
98+ DOCKER_BUILD_ONLY_CACHE=" yes"
99+ source ./docker_env/make_docker.sh " "
100+ exit 0
101+ ;;
102+ none)
103+ ;;
104+ ? )
105+ echo " Invalid action: -${OPTARG} "
106+ exit 1
107+ ;;
108+ esac
109+
110+ # Make sure to pass an empty argument to make_docker, else any arguments passed to build_for_ultimaker is passed to make_docker instead!
111+ source ./docker_env/make_docker.sh " "
109112
110113if [ " ${run_env_check} " = " yes" ]; then
111114 env_check
112115fi
113116
114- if [ " ${run_linters} " = " yes" ]; then
115- run_linters
116- fi
117-
118117run_build " ${@ } "
119118
120- if [ " ${run_tests } " = " yes" ]; then
121- run_tests
119+ if [ " ${run_verification } " = " yes" ]; then
120+ run_verification
122121fi
123122
124- deliver_pkg
125-
126123exit 0
0 commit comments