1425bb815Sopenharmony_ci#!/usr/bin/env python
2425bb815Sopenharmony_ci
3425bb815Sopenharmony_ci# Copyright JS Foundation and other contributors, http://js.foundation
4425bb815Sopenharmony_ci#
5425bb815Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
6425bb815Sopenharmony_ci# you may not use this file except in compliance with the License.
7425bb815Sopenharmony_ci# You may obtain a copy of the License at
8425bb815Sopenharmony_ci#
9425bb815Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
10425bb815Sopenharmony_ci#
11425bb815Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
12425bb815Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS
13425bb815Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14425bb815Sopenharmony_ci# See the License for the specific language governing permissions and
15425bb815Sopenharmony_ci# limitations under the License.
16425bb815Sopenharmony_ci
17425bb815Sopenharmony_cifrom __future__ import print_function
18425bb815Sopenharmony_ci
19425bb815Sopenharmony_ciimport argparse
20425bb815Sopenharmony_ciimport multiprocessing
21425bb815Sopenharmony_ciimport os
22425bb815Sopenharmony_ciimport shutil
23425bb815Sopenharmony_ciimport subprocess
24425bb815Sopenharmony_ciimport sys
25425bb815Sopenharmony_ciimport settings
26425bb815Sopenharmony_ci
27425bb815Sopenharmony_cidef default_toolchain():
28425bb815Sopenharmony_ci    # We don't have default toolchain on Windows and os.uname() isn't supported.
29425bb815Sopenharmony_ci    if sys.platform == 'win32':
30425bb815Sopenharmony_ci        return None
31425bb815Sopenharmony_ci
32425bb815Sopenharmony_ci    (sysname, _, _, _, machine) = os.uname()
33425bb815Sopenharmony_ci    toolchain = os.path.join(settings.PROJECT_DIR,
34425bb815Sopenharmony_ci                             'cmake',
35425bb815Sopenharmony_ci                             'toolchain_%s_%s.cmake' % (sysname.lower(), machine.lower()))
36425bb815Sopenharmony_ci    return toolchain if os.path.isfile(toolchain) else None
37425bb815Sopenharmony_ci
38425bb815Sopenharmony_cidef get_arguments():
39425bb815Sopenharmony_ci    devhelp_preparser = argparse.ArgumentParser(add_help=False)
40425bb815Sopenharmony_ci    devhelp_preparser.add_argument('--devhelp', action='store_true', default=False,
41425bb815Sopenharmony_ci                                   help='show help with all options '
42425bb815Sopenharmony_ci                                        '(including those, which are useful for developers only)')
43425bb815Sopenharmony_ci
44425bb815Sopenharmony_ci    devhelp_arguments, args = devhelp_preparser.parse_known_args()
45425bb815Sopenharmony_ci    if devhelp_arguments.devhelp:
46425bb815Sopenharmony_ci        args.append('--devhelp')
47425bb815Sopenharmony_ci
48425bb815Sopenharmony_ci    def devhelp(helpstring):
49425bb815Sopenharmony_ci        return helpstring if devhelp_arguments.devhelp else argparse.SUPPRESS
50425bb815Sopenharmony_ci
51425bb815Sopenharmony_ci    parser = argparse.ArgumentParser(parents=[devhelp_preparser], epilog="""
52425bb815Sopenharmony_ci        This tool is a thin wrapper around cmake and make to help build the
53425bb815Sopenharmony_ci        project easily. All the real build logic is in the CMakeLists.txt files.
54425bb815Sopenharmony_ci        For most of the options, the defaults are also defined there.
55425bb815Sopenharmony_ci        """)
56425bb815Sopenharmony_ci
57425bb815Sopenharmony_ci    buildgrp = parser.add_argument_group('general build options')
58425bb815Sopenharmony_ci    buildgrp.add_argument('--builddir', metavar='DIR', default=os.path.join(settings.PROJECT_DIR, 'build'),
59425bb815Sopenharmony_ci                          help='specify build directory (default: %(default)s)')
60425bb815Sopenharmony_ci    buildgrp.add_argument('--clean', action='store_true', default=False,
61425bb815Sopenharmony_ci                          help='clean build')
62425bb815Sopenharmony_ci    buildgrp.add_argument('--cmake-param', metavar='OPT', action='append', default=[],
63425bb815Sopenharmony_ci                          help='add custom argument to CMake')
64425bb815Sopenharmony_ci    buildgrp.add_argument('--compile-flag', metavar='OPT', action='append', default=[],
65425bb815Sopenharmony_ci                          help='add custom compile flag')
66425bb815Sopenharmony_ci    buildgrp.add_argument('--debug', action='store_const', const='Debug', dest='build_type',
67425bb815Sopenharmony_ci                          default='MinSizeRel', help='debug build')
68425bb815Sopenharmony_ci    buildgrp.add_argument('--install', metavar='DIR', nargs='?', default=None, const=False,
69425bb815Sopenharmony_ci                          help='install after build (default: don\'t install; '
70425bb815Sopenharmony_ci                               'default directory if install: OS-specific)')
71425bb815Sopenharmony_ci    buildgrp.add_argument('-j', '--jobs', metavar='N', type=int, default=multiprocessing.cpu_count() + 1,
72425bb815Sopenharmony_ci                          help='number of parallel build jobs (default: %(default)s)')
73425bb815Sopenharmony_ci    buildgrp.add_argument('--link-lib', metavar='OPT', action='append', default=[],
74425bb815Sopenharmony_ci                          help='add custom library to be linked')
75425bb815Sopenharmony_ci    buildgrp.add_argument('--linker-flag', metavar='OPT', action='append', default=[],
76425bb815Sopenharmony_ci                          help='add custom linker flag')
77425bb815Sopenharmony_ci    buildgrp.add_argument('--lto', metavar='X', choices=['ON', 'OFF'], type=str.upper,
78425bb815Sopenharmony_ci                          help='enable link-time optimizations (%(choices)s)')
79425bb815Sopenharmony_ci    buildgrp.add_argument('--shared-libs', metavar='X', choices=['ON', 'OFF'], type=str.upper,
80425bb815Sopenharmony_ci                          help='enable building of shared libraries (%(choices)s)')
81425bb815Sopenharmony_ci    buildgrp.add_argument('--strip', metavar='X', choices=['ON', 'OFF'], type=str.upper,
82425bb815Sopenharmony_ci                          help='strip release binaries (%(choices)s)')
83425bb815Sopenharmony_ci    buildgrp.add_argument('--toolchain', metavar='FILE', default=default_toolchain(),
84425bb815Sopenharmony_ci                          help='specify toolchain file (default: %(default)s)')
85425bb815Sopenharmony_ci    buildgrp.add_argument('-v', '--verbose', action='store_const', const='ON',
86425bb815Sopenharmony_ci                          help='increase verbosity')
87425bb815Sopenharmony_ci
88425bb815Sopenharmony_ci    compgrp = parser.add_argument_group('optional components')
89425bb815Sopenharmony_ci    compgrp.add_argument('--doctests', metavar='X', choices=['ON', 'OFF'], type=str.upper,
90425bb815Sopenharmony_ci                         help=devhelp('build doctests (%(choices)s)'))
91425bb815Sopenharmony_ci    compgrp.add_argument('--jerry-cmdline', metavar='X', choices=['ON', 'OFF'], type=str.upper,
92425bb815Sopenharmony_ci                         help='build jerry command line tool (%(choices)s)')
93425bb815Sopenharmony_ci    compgrp.add_argument('--jerry-cmdline-snapshot', metavar='X', choices=['ON', 'OFF'], type=str.upper,
94425bb815Sopenharmony_ci                         help='build snapshot command line tool (%(choices)s)')
95425bb815Sopenharmony_ci    compgrp.add_argument('--jerry-cmdline-test', metavar='X', choices=['ON', 'OFF'], type=str.upper,
96425bb815Sopenharmony_ci                         help=devhelp('build test version of the jerry command line tool (%(choices)s)'))
97425bb815Sopenharmony_ci    compgrp.add_argument('--libfuzzer', metavar='X', choices=['ON', 'OFF'], type=str.upper,
98425bb815Sopenharmony_ci                         help=devhelp('build jerry with libfuzzer support (%(choices)s)'))
99425bb815Sopenharmony_ci    compgrp.add_argument('--jerry-ext', metavar='X', choices=['ON', 'OFF'], type=str.upper,
100425bb815Sopenharmony_ci                         help='build jerry-ext (%(choices)s)')
101425bb815Sopenharmony_ci    compgrp.add_argument('--jerry-libm', metavar='X', choices=['ON', 'OFF'], type=str.upper,
102425bb815Sopenharmony_ci                         help='build and use jerry-libm (%(choices)s)')
103425bb815Sopenharmony_ci    compgrp.add_argument('--jerry-port-default', metavar='X', choices=['ON', 'OFF'], type=str.upper,
104425bb815Sopenharmony_ci                         help='build default jerry port implementation (%(choices)s)')
105425bb815Sopenharmony_ci    compgrp.add_argument('--unittests', metavar='X', choices=['ON', 'OFF'], type=str.upper,
106425bb815Sopenharmony_ci                         help=devhelp('build unittests (%(choices)s)'))
107425bb815Sopenharmony_ci
108425bb815Sopenharmony_ci    coregrp = parser.add_argument_group('jerry-core options')
109425bb815Sopenharmony_ci    coregrp.add_argument('--all-in-one', metavar='X', choices=['ON', 'OFF'], type=str.upper,
110425bb815Sopenharmony_ci                         help='all-in-one build (%(choices)s)')
111425bb815Sopenharmony_ci    coregrp.add_argument('--cpointer-32bit', metavar='X', choices=['ON', 'OFF'], type=str.upper,
112425bb815Sopenharmony_ci                         help='enable 32 bit compressed pointers (%(choices)s)')
113425bb815Sopenharmony_ci    coregrp.add_argument('--error-messages', metavar='X', choices=['ON', 'OFF'], type=str.upper,
114425bb815Sopenharmony_ci                         help='enable error messages (%(choices)s)')
115425bb815Sopenharmony_ci    coregrp.add_argument('--external-context', metavar='X', choices=['ON', 'OFF'], type=str.upper,
116425bb815Sopenharmony_ci                         help='enable external context (%(choices)s)')
117425bb815Sopenharmony_ci    coregrp.add_argument('--jerry-debugger', metavar='X', choices=['ON', 'OFF'], type=str.upper,
118425bb815Sopenharmony_ci                         help='enable the jerry debugger (%(choices)s)')
119425bb815Sopenharmony_ci    coregrp.add_argument('--js-parser', metavar='X', choices=['ON', 'OFF'], type=str.upper,
120425bb815Sopenharmony_ci                         help='enable js-parser (%(choices)s)')
121425bb815Sopenharmony_ci    coregrp.add_argument('--line-info', metavar='X', choices=['ON', 'OFF'], type=str.upper,
122425bb815Sopenharmony_ci                         help='provide line info (%(choices)s)')
123425bb815Sopenharmony_ci    coregrp.add_argument('--logging', metavar='X', choices=['ON', 'OFF'], type=str.upper,
124425bb815Sopenharmony_ci                         help='enable logging (%(choices)s)')
125425bb815Sopenharmony_ci    coregrp.add_argument('--mem-heap', metavar='SIZE', type=int,
126425bb815Sopenharmony_ci                         help='size of memory heap (in kilobytes)')
127425bb815Sopenharmony_ci    coregrp.add_argument('--gc-limit', metavar='SIZE', type=int,
128425bb815Sopenharmony_ci                         help='memory usage limit to trigger garbage collection (in bytes)')
129425bb815Sopenharmony_ci    coregrp.add_argument('--stack-limit', metavar='SIZE', type=int,
130425bb815Sopenharmony_ci                         help='maximum stack usage (in kilobytes)')
131425bb815Sopenharmony_ci    coregrp.add_argument('--gc-mark-limit', metavar='SIZE', type=int,
132425bb815Sopenharmony_ci                         help='maximum depth of recursion during GC mark phase')
133425bb815Sopenharmony_ci    coregrp.add_argument('--mem-stats', metavar='X', choices=['ON', 'OFF'], type=str.upper,
134425bb815Sopenharmony_ci                         help=devhelp('enable memory statistics (%(choices)s)'))
135425bb815Sopenharmony_ci    coregrp.add_argument('--mem-stress-test', metavar='X', choices=['ON', 'OFF'], type=str.upper,
136425bb815Sopenharmony_ci                         help=devhelp('enable mem-stress test (%(choices)s)'))
137425bb815Sopenharmony_ci    coregrp.add_argument('--profile', metavar='FILE',
138425bb815Sopenharmony_ci                         help='specify profile file')
139425bb815Sopenharmony_ci    coregrp.add_argument('--regexp-strict-mode', metavar='X', choices=['ON', 'OFF'], type=str.upper,
140425bb815Sopenharmony_ci                         help=devhelp('enable regexp strict mode (%(choices)s)'))
141425bb815Sopenharmony_ci    coregrp.add_argument('--show-opcodes', metavar='X', choices=['ON', 'OFF'], type=str.upper,
142425bb815Sopenharmony_ci                         help=devhelp('enable parser byte-code dumps (%(choices)s)'))
143425bb815Sopenharmony_ci    coregrp.add_argument('--show-regexp-opcodes', metavar='X', choices=['ON', 'OFF'], type=str.upper,
144425bb815Sopenharmony_ci                         help=devhelp('enable regexp byte-code dumps (%(choices)s)'))
145425bb815Sopenharmony_ci    coregrp.add_argument('--snapshot-exec', metavar='X', choices=['ON', 'OFF'], type=str.upper,
146425bb815Sopenharmony_ci                         help='enable executing snapshot files (%(choices)s)')
147425bb815Sopenharmony_ci    coregrp.add_argument('--snapshot-save', metavar='X', choices=['ON', 'OFF'], type=str.upper,
148425bb815Sopenharmony_ci                         help='enable saving snapshot files (%(choices)s)')
149425bb815Sopenharmony_ci    coregrp.add_argument('--system-allocator', metavar='X', choices=['ON', 'OFF'], type=str.upper,
150425bb815Sopenharmony_ci                         help='enable system allocator (%(choices)s)')
151425bb815Sopenharmony_ci    coregrp.add_argument('--valgrind', metavar='X', choices=['ON', 'OFF'], type=str.upper,
152425bb815Sopenharmony_ci                         help=devhelp('enable Valgrind support (%(choices)s)'))
153425bb815Sopenharmony_ci    coregrp.add_argument('--vm-exec-stop', metavar='X', choices=['ON', 'OFF'], type=str.upper,
154425bb815Sopenharmony_ci                         help='enable VM execution stopping (%(choices)s)')
155425bb815Sopenharmony_ci
156425bb815Sopenharmony_ci    maingrp = parser.add_argument_group('jerry-main options')
157425bb815Sopenharmony_ci    maingrp.add_argument('--link-map', metavar='X', choices=['ON', 'OFF'], type=str.upper,
158425bb815Sopenharmony_ci                         help=devhelp('enable the generation of link map for jerry command line tool (%(choices)s)'))
159425bb815Sopenharmony_ci
160425bb815Sopenharmony_ci    arguments = parser.parse_args(args)
161425bb815Sopenharmony_ci    if arguments.devhelp:
162425bb815Sopenharmony_ci        parser.print_help()
163425bb815Sopenharmony_ci        sys.exit(0)
164425bb815Sopenharmony_ci
165425bb815Sopenharmony_ci    return arguments
166425bb815Sopenharmony_ci
167425bb815Sopenharmony_cidef generate_build_options(arguments):
168425bb815Sopenharmony_ci    build_options = []
169425bb815Sopenharmony_ci
170425bb815Sopenharmony_ci    def build_options_append(cmakeopt, cliarg):
171425bb815Sopenharmony_ci        if cliarg:
172425bb815Sopenharmony_ci            build_options.append('-D%s=%s' % (cmakeopt, cliarg))
173425bb815Sopenharmony_ci
174425bb815Sopenharmony_ci    # general build options
175425bb815Sopenharmony_ci    build_options_append('CMAKE_BUILD_TYPE', arguments.build_type)
176425bb815Sopenharmony_ci    build_options_append('EXTERNAL_COMPILE_FLAGS', ' '.join(arguments.compile_flag))
177425bb815Sopenharmony_ci    build_options_append('EXTERNAL_LINK_LIBS', ' '.join(arguments.link_lib))
178425bb815Sopenharmony_ci    build_options_append('EXTERNAL_LINKER_FLAGS', ' '.join(arguments.linker_flag))
179425bb815Sopenharmony_ci    build_options_append('ENABLE_LTO', arguments.lto)
180425bb815Sopenharmony_ci    build_options_append('BUILD_SHARED_LIBS', arguments.shared_libs)
181425bb815Sopenharmony_ci    build_options_append('ENABLE_STRIP', arguments.strip)
182425bb815Sopenharmony_ci    build_options_append('CMAKE_TOOLCHAIN_FILE', arguments.toolchain)
183425bb815Sopenharmony_ci    build_options_append('CMAKE_VERBOSE_MAKEFILE', arguments.verbose)
184425bb815Sopenharmony_ci
185425bb815Sopenharmony_ci    # optional components
186425bb815Sopenharmony_ci    build_options_append('DOCTESTS', arguments.doctests)
187425bb815Sopenharmony_ci    build_options_append('JERRY_CMDLINE', arguments.jerry_cmdline)
188425bb815Sopenharmony_ci    build_options_append('JERRY_CMDLINE_SNAPSHOT', arguments.jerry_cmdline_snapshot)
189425bb815Sopenharmony_ci    build_options_append('JERRY_CMDLINE_TEST', arguments.jerry_cmdline_test)
190425bb815Sopenharmony_ci    build_options_append('JERRY_LIBFUZZER', arguments.libfuzzer)
191425bb815Sopenharmony_ci    build_options_append('JERRY_EXT', arguments.jerry_ext)
192425bb815Sopenharmony_ci    build_options_append('JERRY_LIBM', arguments.jerry_libm)
193425bb815Sopenharmony_ci    build_options_append('JERRY_PORT_DEFAULT', arguments.jerry_port_default)
194425bb815Sopenharmony_ci    build_options_append('UNITTESTS', arguments.unittests)
195425bb815Sopenharmony_ci
196425bb815Sopenharmony_ci    # jerry-core options
197425bb815Sopenharmony_ci    build_options_append('ENABLE_ALL_IN_ONE', arguments.all_in_one)
198425bb815Sopenharmony_ci    build_options_append('JERRY_CPOINTER_32_BIT', arguments.cpointer_32bit)
199425bb815Sopenharmony_ci    build_options_append('JERRY_ERROR_MESSAGES', arguments.error_messages)
200425bb815Sopenharmony_ci    build_options_append('JERRY_EXTERNAL_CONTEXT', arguments.external_context)
201425bb815Sopenharmony_ci    build_options_append('JERRY_DEBUGGER', arguments.jerry_debugger)
202425bb815Sopenharmony_ci    build_options_append('JERRY_PARSER', arguments.js_parser)
203425bb815Sopenharmony_ci    build_options_append('JERRY_LINE_INFO', arguments.line_info)
204425bb815Sopenharmony_ci    build_options_append('JERRY_LOGGING', arguments.logging)
205425bb815Sopenharmony_ci    build_options_append('JERRY_GLOBAL_HEAP_SIZE', arguments.mem_heap)
206425bb815Sopenharmony_ci    build_options_append('JERRY_GC_LIMIT', arguments.gc_limit)
207425bb815Sopenharmony_ci    build_options_append('JERRY_STACK_LIMIT', arguments.stack_limit)
208425bb815Sopenharmony_ci    build_options_append('JERRY_MEM_STATS', arguments.mem_stats)
209425bb815Sopenharmony_ci    build_options_append('JERRY_MEM_GC_BEFORE_EACH_ALLOC', arguments.mem_stress_test)
210425bb815Sopenharmony_ci    build_options_append('JERRY_PROFILE', arguments.profile)
211425bb815Sopenharmony_ci    build_options_append('JERRY_REGEXP_STRICT_MODE', arguments.regexp_strict_mode)
212425bb815Sopenharmony_ci    build_options_append('JERRY_PARSER_DUMP_BYTE_CODE', arguments.show_opcodes)
213425bb815Sopenharmony_ci    build_options_append('JERRY_REGEXP_DUMP_BYTE_CODE', arguments.show_regexp_opcodes)
214425bb815Sopenharmony_ci    build_options_append('JERRY_SNAPSHOT_EXEC', arguments.snapshot_exec)
215425bb815Sopenharmony_ci    build_options_append('JERRY_SNAPSHOT_SAVE', arguments.snapshot_save)
216425bb815Sopenharmony_ci    build_options_append('JERRY_SYSTEM_ALLOCATOR', arguments.system_allocator)
217425bb815Sopenharmony_ci    build_options_append('JERRY_VALGRIND', arguments.valgrind)
218425bb815Sopenharmony_ci    build_options_append('JERRY_VM_EXEC_STOP', arguments.vm_exec_stop)
219425bb815Sopenharmony_ci
220425bb815Sopenharmony_ci    if arguments.gc_mark_limit is not None:
221425bb815Sopenharmony_ci        build_options.append('-D%s=%s' % ('JERRY_GC_MARK_LIMIT', arguments.gc_mark_limit))
222425bb815Sopenharmony_ci
223425bb815Sopenharmony_ci    # jerry-main options
224425bb815Sopenharmony_ci    build_options_append('ENABLE_LINK_MAP', arguments.link_map)
225425bb815Sopenharmony_ci
226425bb815Sopenharmony_ci    # general build options (final step)
227425bb815Sopenharmony_ci    if arguments.cmake_param:
228425bb815Sopenharmony_ci        build_options.extend(arguments.cmake_param)
229425bb815Sopenharmony_ci
230425bb815Sopenharmony_ci    return build_options
231425bb815Sopenharmony_ci
232425bb815Sopenharmony_cidef configure_output_dir(arguments):
233425bb815Sopenharmony_ci    if not os.path.isabs(arguments.builddir):
234425bb815Sopenharmony_ci        arguments.builddir = os.path.join(settings.PROJECT_DIR, arguments.builddir)
235425bb815Sopenharmony_ci
236425bb815Sopenharmony_ci    if arguments.clean and os.path.exists(arguments.builddir):
237425bb815Sopenharmony_ci        shutil.rmtree(arguments.builddir)
238425bb815Sopenharmony_ci
239425bb815Sopenharmony_ci    if not os.path.exists(arguments.builddir):
240425bb815Sopenharmony_ci        os.makedirs(arguments.builddir)
241425bb815Sopenharmony_ci
242425bb815Sopenharmony_cidef configure_jerry(arguments):
243425bb815Sopenharmony_ci    configure_output_dir(arguments)
244425bb815Sopenharmony_ci
245425bb815Sopenharmony_ci    build_options = generate_build_options(arguments)
246425bb815Sopenharmony_ci
247425bb815Sopenharmony_ci    cmake_cmd = ['cmake', '-B' + arguments.builddir, '-H' + settings.PROJECT_DIR]
248425bb815Sopenharmony_ci
249425bb815Sopenharmony_ci    if arguments.install:
250425bb815Sopenharmony_ci        cmake_cmd.append('-DCMAKE_INSTALL_PREFIX=%s' % arguments.install)
251425bb815Sopenharmony_ci
252425bb815Sopenharmony_ci    cmake_cmd.extend(build_options)
253425bb815Sopenharmony_ci
254425bb815Sopenharmony_ci    return subprocess.call(cmake_cmd)
255425bb815Sopenharmony_ci
256425bb815Sopenharmony_cidef make_jerry(arguments):
257425bb815Sopenharmony_ci    make_cmd = ['cmake', '--build', arguments.builddir, '--config', arguments.build_type]
258425bb815Sopenharmony_ci    env = dict(os.environ)
259425bb815Sopenharmony_ci    env['CMAKE_BUILD_PARALLEL_LEVEL'] = str(arguments.jobs)
260425bb815Sopenharmony_ci    env['MAKEFLAGS'] = '-j%d' % (arguments.jobs) # Workaround for CMake < 3.12
261425bb815Sopenharmony_ci    proc = subprocess.Popen(make_cmd, env=env)
262425bb815Sopenharmony_ci    proc.wait()
263425bb815Sopenharmony_ci
264425bb815Sopenharmony_ci    return proc.returncode
265425bb815Sopenharmony_ci
266425bb815Sopenharmony_cidef install_jerry(arguments):
267425bb815Sopenharmony_ci    install_target = 'INSTALL' if sys.platform == 'win32' else 'install'
268425bb815Sopenharmony_ci    make_cmd = ['cmake', '--build', arguments.builddir, '--config', arguments.build_type, '--target', install_target]
269425bb815Sopenharmony_ci    return subprocess.call(make_cmd)
270425bb815Sopenharmony_ci
271425bb815Sopenharmony_cidef print_result(ret):
272425bb815Sopenharmony_ci    print('=' * 30)
273425bb815Sopenharmony_ci    if ret:
274425bb815Sopenharmony_ci        print('Build failed with exit code: %s' % (ret))
275425bb815Sopenharmony_ci    else:
276425bb815Sopenharmony_ci        print('Build succeeded!')
277425bb815Sopenharmony_ci    print('=' * 30)
278425bb815Sopenharmony_ci
279425bb815Sopenharmony_cidef main():
280425bb815Sopenharmony_ci    arguments = get_arguments()
281425bb815Sopenharmony_ci
282425bb815Sopenharmony_ci    ret = configure_jerry(arguments)
283425bb815Sopenharmony_ci
284425bb815Sopenharmony_ci    if not ret:
285425bb815Sopenharmony_ci        ret = make_jerry(arguments)
286425bb815Sopenharmony_ci
287425bb815Sopenharmony_ci    if not ret and arguments.install is not None:
288425bb815Sopenharmony_ci        ret = install_jerry(arguments)
289425bb815Sopenharmony_ci
290425bb815Sopenharmony_ci    print_result(ret)
291425bb815Sopenharmony_ci    sys.exit(ret)
292425bb815Sopenharmony_ci
293425bb815Sopenharmony_ci
294425bb815Sopenharmony_ciif __name__ == "__main__":
295425bb815Sopenharmony_ci    main()
296