def job_host_darwin(): for buildtype in BUILDTYPES: ex.check_run_cmd('./tools/build.py', [ '--run-test=full', '--buildtype=' + buildtype, '--clean', '--profile=test/profiles/host-darwin.profile'])
def configure_trizenrt(tizenrt_root, buildtype): # TODO: handle buildtype (build vs release) for tizenrt build tizenrt_tools = fs.join(tizenrt_root, 'os/tools') fs.chdir(tizenrt_tools) ex.check_run_cmd('./configure.sh', ['artik053/iotjs']) fs.chdir('..') ex.check_run_cmd('make', ['context'])
def run_make(options, build_home, *args): make_opt = ['-C', build_home] make_opt.extend(args) if not options.no_parallel_build: make_opt.append('-j') ex.check_run_cmd('make', make_opt)
def run_docker(): ex.check_run_cmd('docker', [ 'run', '-dit', '--privileged', '--name', DOCKER_NAME, '-v', '%s:%s' % (TRAVIS_BUILD_PATH, DOCKER_IOTJS_PATH), '--add-host', 'test.mosquitto.org:127.0.0.1', '--add-host', 'echo.websocket.org:127.0.0.1', '--add-host', 'httpbin.org:127.0.0.1', 'iotjs/ubuntu:0.9' ])
def build_napi_test_module(): node_gyp = fs.join(path.PROJECT_ROOT, 'node_modules', '.bin', 'node-gyp') print('==> Build N-API test module with node-gyp\n') project_root = fs.join(path.PROJECT_ROOT, 'test', 'napi') Executor.check_run_cmd(node_gyp, ['configure', 'rebuild'], cwd=project_root)
def build_nuttx(nuttx_root, buildtype, maketarget): fs.chdir(fs.join(nuttx_root, 'nuttx')) if buildtype == "release": rflag = 'R=1' else: rflag = 'R=0' ex.check_run_cmd('make', [maketarget, 'IOTJS_ROOT_DIR=' + path.PROJECT_ROOT, rflag])
def check_tidy(src_dir): count_lines = 0 count_empty_lines = 0 for (dirpath, dirnames, filenames) in os.walk(src_dir): if any(d in fs.relpath(dirpath, src_dir) for d in skip_dirs): continue files = [ fs.join(dirpath, name) for name in filenames if is_interesting(name) ] if not files: continue for file in files: if is_checked_by_clang(file): formatted = ex.run_cmd_output(' '.join( ['clang-format-3.8', '-style=file', file]), quiet=True) f = open(file + '.formatted', 'w') f.write(formatted) f.close() ex.check_run_cmd('diff', [file, file + '.formatted'], quiet=True) fs.remove(file + '.formatted') for line in fileinput.input(files): if '\t' in line: report_error('TAB character') if '\r' in line: report_error('CR character') if line.endswith(' \n') or line.endswith('\t\n'): report_error('trailing whitespace') if not line.endswith('\n'): report_error('line ends without NEW LINE character') if len(line) - 1 > column_limit: report_error('line exceeds %d characters' % column_limit) if fileinput.isfirstline(): if not CheckLicenser.check(fileinput.filename()): report_error_name_line(fileinput.filename(), None, 'incorrect license') count_lines += 1 if not line.strip(): count_empty_lines += 1 print "* total lines of code: %d" % count_lines print("* total non-blank lines of code: %d" % (count_lines - count_empty_lines)) print "%s* total errors: %d%s" % (TERM_RED if count_err > 0 else TERM_GREEN, count_err, TERM_EMPTY) print return count_err == 0
def setup_tizen_root(tizen_root): if fs.exists(tizen_root): fs.chdir(tizen_root) ex.check_run_cmd('git', ['pull']) fs.chdir(path.PROJECT_ROOT) else: ex.check_run_cmd('git', ['clone', 'https://github.com/pmarcinkiew/tizen3.0_rootstrap.git', tizen_root])
def exec_docker(cwd, cmd, env=[]): exec_cmd = 'cd %s && ' % cwd + ' '.join(cmd) docker_args = ['exec', '-it'] for e in env: docker_args.append('-e') docker_args.append(e) docker_args += [DOCKER_NAME, 'bash', '-c', exec_cmd] ex.check_run_cmd('docker', docker_args)
def run_docker(): ''' Create the Docker container where we will run the builds. ''' ex.check_run_cmd('docker', ['run', '-dit', '--privileged', '--name', DOCKER_NAME, '-v', '%s:%s' % (TRAVIS_BUILD_PATH, DOCKER_JSREMOTE_PATH), '--env', 'PYTHONPATH=%s:$PYTHONPATH' % DOCKER_JSREMOTE_PATH, DOCKER_IMAGE_NAME])
def run_docker(): ex.check_run_cmd('docker', ['pull', DOCKER_TAG]) ex.check_run_cmd('docker', ['run', '-dit', '--privileged', '--name', DOCKER_NAME, '-v', '%s:%s' % (TRAVIS_BUILD_PATH, DOCKER_IOTJS_PATH), '--add-host', 'test.mosquitto.org:127.0.0.1', '--add-host', 'echo.websocket.org:127.0.0.1', '--add-host', 'httpbin.org:127.0.0.1', DOCKER_TAG])
def build_napi_test_module(is_debug): node_gyp = fs.join(path.PROJECT_ROOT, 'node_modules', '.bin', 'node-gyp') print('==> Build N-API test module with node-gyp\n') project_root = fs.join(path.PROJECT_ROOT, 'test', 'napi') debug_cmd = '--debug' if is_debug else '--release' Executor.check_run_cmd(node_gyp, ['configure', debug_cmd, 'rebuild'], cwd=project_root)
def build_napi_test_module(options): node_gyp = fs.join(path.PROJECT_ROOT, 'node_modules', '.bin', 'node-gyp') print_progress('Build NAPI test module with %s' % node_gyp) project_root = fs.join(path.PROJECT_ROOT, 'test', 'napi') ex.check_run_cmd(node_gyp, ['configure'], cwd=project_root) ex.check_run_cmd(node_gyp, ['build'], cwd=project_root)
def setup_tizenrt_repo(tizenrt_root): if fs.exists(tizenrt_root): fs.chdir(tizenrt_root) ex.check_run_cmd('git', ['pull']) fs.chdir(path.PROJECT_ROOT) else: ex.check_run_cmd( 'git', ['clone', 'https://github.com/Samsung/TizenRT.git', tizenrt_root]) copy_tiznert_stuff(tizenrt_root, path.PROJECT_ROOT)
def copy_tiznert_stuff(tizenrt_root, iotjs_dir): tizenrt_iotjsapp_dir = fs.join(tizenrt_root, 'apps/system/iotjs') tizenrt_config_dir = fs.join(tizenrt_root, 'build/configs/artik053/iotjs') iotjs_tizenrt_appdir = fs.join(iotjs_dir, 'config/tizenrt/artik05x/app') iotjs_config_dir = \ fs.join(iotjs_dir, 'config/tizenrt/artik05x/configs') ex.check_run_cmd('cp', ['-rfu', iotjs_tizenrt_appdir, tizenrt_iotjsapp_dir]) ex.check_run_cmd('cp', ['-rfu', iotjs_config_dir, tizenrt_config_dir])
def build_addons_napi_gyp_modules(): node_gyp = fs.join(path.PROJECT_ROOT, 'node_modules', '.bin', 'node-gyp') print_progress('Build N-API test addons with %s' % node_gyp) dirs = glob.glob('test/addons-napi/*') dirs = [dir_name for dir_name in dirs if os.path.isdir(dir_name)] dirs = [ dir_name for dir_name in dirs if os.path.isfile(os.path.join(dir_name, 'binding.gyp')) ] for dir_name in dirs: ex.check_run_cmd(node_gyp, ['configure'], cwd=dir_name) ex.check_run_cmd(node_gyp, ['build'], cwd=dir_name)
def build_napi_test_module(is_debug): node_gyp = fs.join(path.PROJECT_ROOT, 'node_modules', '.bin', 'node-gyp') print('==> Build N-API test module with node-gyp\n') project_root = fs.join(path.PROJECT_ROOT, 'test', 'napi') debug_cmd = '--debug' if is_debug else '--release' Executor.check_run_cmd(node_gyp, ['configure', debug_cmd ,'rebuild'], cwd=project_root)
def flash_nuttx(nuttx_root): ''' Flash the NuttX binary onto the board. ''' setup_stlink() nuttx_bin = fs.join(nuttx_root, 'nuttx/nuttx.bin') if fs.exists(nuttx_bin): fs.chdir(fs.join(path.DEPS_ROOT, 'stlink/build/Release')) options = ['write', nuttx_bin, '0x8000000'] ex.check_run_cmd('./st-flash', options) fs.chdir(path.PROJECT_ROOT)
def exec_docker(cwd, cmd, env=[], is_background=False): exec_cmd = 'cd %s && ' % cwd + ' '.join(cmd) if is_background: docker_args = ['exec', '-dit'] else: docker_args = ['exec', '-it'] for e in env: docker_args.append('-e') docker_args.append(e) docker_args += [DOCKER_NAME, 'bash', '-c', exec_cmd] ex.check_run_cmd('docker', docker_args)
def exec_docker(cwd, cmd, env=[], is_background=False): exec_cmd = 'cd %s && ' % cwd + ' '.join(cmd) if is_background: docker_args = ['exec', '-dit'] else: docker_args = ['exec', '-it'] for e in env: docker_args.append('-e') docker_args.append(e) docker_args += [DOCKER_NAME, 'bash', '-c', exec_cmd] ex.check_run_cmd('docker', docker_args)
def copy_tiznert_stuff(tizenrt_root, iotjs_dir): tizenrt_iotjsapp_dir = fs.join(tizenrt_root, 'apps/system/iotjs') tizenrt_config_dir = fs.join(tizenrt_root, 'build/configs/artik053/iotjs') iotjs_tizenrt_appdir = fs.join(iotjs_dir, 'config/tizenrt/artik05x/app') iotjs_config_dir = \ fs.join(iotjs_dir, 'config/tizenrt/artik05x/configs') ex.check_run_cmd('cp', ['-rfu', iotjs_tizenrt_appdir, tizenrt_iotjsapp_dir]) ex.check_run_cmd('cp', ['-rfu', iotjs_config_dir, tizenrt_config_dir])
def build_tuv(option): # Check if libtuv submodule exists. if not fs.exists(path.TUV_ROOT): ex.fail('libtuv submodule not exists!') # Move working directory to libtuv build directory. build_home = fs.join(build_root, 'deps', 'libtuv') fs.maybe_make_directory(build_home) fs.chdir(build_home) # Set tuv cmake option. cmake_opt = [path.TUV_ROOT] cmake_opt.append('-DCMAKE_TOOLCHAIN_FILE=' + fs.join(path.TUV_ROOT, 'cmake', 'config', 'config_' + target_tuple + '.cmake')) cmake_opt.append('-DCMAKE_BUILD_TYPE=' + option.buildtype) cmake_opt.append('-DTARGET_PLATFORM=' + target_tuple) cmake_opt.append('-DLIBTUV_CUSTOM_LIB_OUT=' + build_home) cmake_opt.append('-DBUILDTESTER=no') cmake_opt.append('-DBUILDAPIEMULTESTER=no') if option.target_os == 'nuttx': cmake_opt.append('-DTARGET_SYSTEMROOT=' + option.nuttx_home) if option.target_board: cmake_opt.append('-DTARGET_BOARD=' + option.target_board) # inflate cmake option. inflate_cmake_option(cmake_opt, option) # Run cmake ex.check_run_cmd('cmake', cmake_opt) # Run make make_opt = [] if not option.no_parallel_build: make_opt.append('-j') ex.check_run_cmd('make', make_opt) # libtuv output output = fs.join(build_home, 'libtuv.a') if not fs.exists(output): ex.fail('libtuv build failed - target not produced.') # copy output to libs directory fs.maybe_make_directory(build_libs) fs.copy(output, libtuv_output_path) return True
def build_jerry(option): # Check if JerryScript submodule exists. if not fs.exists(path.JERRY_ROOT): ex.fail('JerryScript submodule not exists!') # Move working directory to JerryScript build directory. build_home = fs.join(host_build_root, 'deps', 'jerry') fs.maybe_make_directory(build_home) fs.chdir(build_home) # Set JerryScript cmake option. cmake_opt = [path.JERRY_ROOT] cmake_opt.append('-DCMAKE_TOOLCHAIN_FILE=' + host_cmake_toolchain_file) if option.buildtype == 'debug': cmake_opt.append('-DCMAKE_BUILD_TYPE=Debug') # Turn off LTO for jerry bin to save build time. cmake_opt.append('-DENABLE_LTO=OFF') # Turn on snapshot if not option.no_snapshot: cmake_opt.append('-DFEATURE_SNAPSHOT_SAVE=ON') # Run cmake. ex.check_run_cmd('cmake', cmake_opt) target_jerry = { 'target_name': 'jerry', 'output_path': fs.join(build_home, 'bin/jerry') } # Make option. make_opt = ['-C', build_home] if not option.no_parallel_build: make_opt.append('-j') # Run make for a target. ex.check_run_cmd('make', make_opt) # Check output output = target_jerry['output_path'] if not fs.exists(output): print output ex.fail('JerryScript build failed - target not produced.') # copy fs.copy(output, jerry_output_path) return True
def setup_stlink(): ''' Setup the stlink dependency. ''' fs.chdir(path.DEPS_ROOT) if not fs.exists('stlink'): ex.check_run_cmd('git', ['clone', 'https://github.com/texane/stlink.git']) if not fs.exists(fs.join(path.DEPS_ROOT, 'stlink/build/Release/st-flash')): fs.chdir(fs.join(path.DEPS_ROOT, 'stlink')) ex.check_run_cmd('make', ['release']) fs.chdir(path.PROJECT_ROOT)
def build_napi_test_module(self): node_gyp = fs.join(path.PROJECT_ROOT, 'node_modules', '.bin', 'node-gyp') print('==> Build N-API test module with node-gyp\n') project_root = fs.join(path.PROJECT_ROOT, 'test', 'napi') cmd = ['--debug'] if self.debug else ['--release'] if self.platform == 'windows': node_gyp += '.cmd' cmd.append('--arch=x64' if self.arch == 'x64' else '--arch=ia32') Executor.check_run_cmd(node_gyp, ['rebuild'] + cmd, cwd=project_root)
def main(): option = parse_option() if option.check_signoff: args = [] if os.getenv('TRAVIS') is not None: args = ['--travis'] ex.check_run_cmd('tools/check_signed_off.sh', args) if option.check_pylint: ex.check_run_cmd('python', ['tools/check_pylint.py']) if option.app and option.device: run_docker() build_app(option)
def build_libhttpparser(option): # Check if JerryScript submodule exists. if not fs.exists(path.HTTPPARSER_ROOT): ex.fail('libhttpparser submodule not exists!') return False # Move working directory to JerryScript build directory. build_home = fs.join(build_root, 'deps', 'httpparser') fs.maybe_make_directory(build_home) fs.chdir(build_home) # Set JerryScript cmake option. cmake_opt = [path.HTTPPARSER_ROOT] cmake_opt.append('-DCMAKE_TOOLCHAIN_FILE=' + cmake_toolchain_file) cmake_opt.append('-DBUILDTYPE=' + option.buildtype.capitalize()) if option.target_os == 'nuttx': cmake_opt.append('-DNUTTX_HOME=' + option.nuttx_home) cmake_opt.append('-DOS=NUTTX') if option.target_os == 'linux': cmake_opt.append('-DOS=LINUX') # inflate cmake option. inflate_cmake_option(cmake_opt, option) # Run cmake. ex.check_run_cmd('cmake', cmake_opt) # Set make option. make_opt = [] if not option.no_parallel_build: make_opt.append('-j') # Run make ex.check_run_cmd('make', make_opt) # Output output = fs.join(build_home, 'libhttpparser.a') if not fs.exists(output): ex.fail('libhttpparser build failed - target not produced.') # copy fs.copy(output, libhttpparser_output_path) return True
def build_napi_test_module(options): print_progress('Build NAPI test module') # Set NAPI test module cmake options. project_root = fs.join(path.PROJECT_ROOT, 'test', 'napi') build_root = fs.join(project_root, 'build') cmake_opt = [ '-B%s' % build_root, '-H%s' % project_root, "-DCMAKE_TOOLCHAIN_FILE='%s'" % options.cmake_toolchain_file, '-DCMAKE_BUILD_TYPE=%s' % options.buildtype.capitalize(), '-DTARGET_ARCH=%s' % options.target_arch, '-DTARGET_OS=%s' % options.target_os, '-DPLATFORM_DESCRIPTOR=%s' % options.target_tuple, '-DINSTALL_PREFIX=%s' % options.install_prefix, ] # Run cmake. ex.check_run_cmd('cmake', cmake_opt) run_make(options, build_root)
def build_tuv(options): print_progress('Build libtuv') # Check if libtuv submodule exists. if not fs.exists(path.TUV_ROOT): ex.fail('libtuv submodule does not exists!') # Move working directory to libtuv build directory. build_home = fs.join(options.build_root, 'deps', 'libtuv') # Set tuv cmake options. cmake_opt = [ '-B%s' % build_home, '-H%s' % path.TUV_ROOT, "-DCMAKE_TOOLCHAIN_FILE='%s'" % fs.join(path.TUV_ROOT, 'cmake', 'config', 'config_%s.cmake' % options.target_tuple), "-DCMAKE_BUILD_TYPE='%s'" % options.buildtype, "-DTARGET_PLATFORM='%s'" % options.target_tuple, "-DLIBTUV_CUSTOM_LIB_OUT='%s'" % build_home, '-DBUILDTESTER=NO', '-DBUILDAPIEMULTESTER=NO', ] if options.cross_compile: cmake_opt.append("-DCROSS_COMPILE='%s'" % options.cross_compile) if options.sysroot: cmake_opt.append("-DTARGET_SYSTEMROOT='%s'" % options.sysroot) cmake_opt.append("-DSYSROOT='%s'" % options.sysroot) if options.target_board: cmake_opt.append("-DTARGET_BOARD='%s'" % options.target_board) # Add common cmake options. cmake_opt.extend(build_cmake_args(options)) # Run cmake. ex.check_run_cmd('cmake', cmake_opt) run_make(options, build_home) copy_build_target('libtuv.a', build_home, options.build_libs)
def build_libhttpparser(options): print_progress('Build libhttpparser') # Check if JerryScript submodule exists. if not fs.exists(path.HTTPPARSER_ROOT): ex.fail('libhttpparser submodule does not exists!') # Move working directory to JerryScript build directory. build_home = fs.join(options.build_root, 'deps', 'httpparser') # Set JerryScript cmake options. cmake_opt = [ '-B%s' % build_home, '-H%s' % path.HTTPPARSER_ROOT, "-DCMAKE_TOOLCHAIN_FILE='%s'" % options.cmake_toolchain_file, '-DBUILDTYPE=%s' % options.buildtype.capitalize(), ] if options.target_os == 'nuttx': cmake_opt.append("-DNUTTX_HOME='%s'" % options.sysroot) cmake_opt.append('-DOS=NUTTX') if options.target_os in ['linux', 'tizen']: cmake_opt.append('-DOS=LINUX') if options.target_os == 'darwin': cmake_opt.append('-DOS=DARWIN') # Add common cmake options. cmake_opt.extend(build_cmake_args(options)) # Run cmake. ex.check_run_cmd('cmake', cmake_opt) run_make(options, build_home) copy_build_target('libhttpparser.a', build_home, options.build_libs)
def setup_nuttx_root(nuttx_root): # Step 1 fs.maybe_make_directory(nuttx_root) fs.chdir(nuttx_root) if not fs.exists('nuttx'): ex.check_run_cmd('git', ['clone', 'https://bitbucket.org/nuttx/nuttx.git']) fs.chdir('nuttx') ex.check_run_cmd('git', ['checkout', NUTTXTAG]) fs.chdir('..') if not fs.exists('apps'): ex.check_run_cmd('git', ['clone', 'https://bitbucket.org/nuttx/apps.git']) fs.chdir('apps') ex.check_run_cmd('git', ['checkout', NUTTXTAG]) fs.chdir('..') # Step 2 fs.maybe_make_directory(fs.join(nuttx_root, 'apps', 'system', 'iotjs')) for file in fs.listdir(fs.join(path.PROJECT_ROOT, 'config', 'nuttx', 'stm32f4dis','app')): fs.copy(fs.join(path.PROJECT_ROOT, 'config', 'nuttx', 'stm32f4dis', 'app', file), fs.join(nuttx_root, 'apps', 'system', 'iotjs')) # Step 3 fs.chdir(fs.join(nuttx_root, 'nuttx', 'tools')) ex.check_run_cmd('./configure.sh', ['stm32f4discovery/usbnsh']) fs.chdir('..') fs.copy(fs.join(path.PROJECT_ROOT, 'config', 'nuttx', 'stm32f4dis', '.config.travis'), '.config')
def setup_nuttx_root(nuttx_root): # Step 1 fs.maybe_make_directory(nuttx_root) fs.chdir(nuttx_root) if fs.exists('nuttx'): fs.chdir('nuttx') ex.check_run_cmd('git', ['pull']) fs.chdir('..') else: ex.check_run_cmd('git', ['clone', 'https://bitbucket.org/nuttx/nuttx.git']) if fs.exists('apps'): fs.chdir('apps') ex.check_run_cmd('git', ['pull']) fs.chdir('..') else: ex.check_run_cmd('git', ['clone', 'https://bitbucket.org/nuttx/apps.git']) # Step 2 fs.maybe_make_directory(fs.join(nuttx_root, 'apps', 'system', 'iotjs')) for file in fs.listdir(fs.join(path.PROJECT_ROOT, 'targets', 'nuttx-stm32f4', 'app')): fs.copy(fs.join(path.PROJECT_ROOT,'targets','nuttx-stm32f4','app',file), fs.join(nuttx_root, 'apps', 'system', 'iotjs')) # Step 3 fs.chdir(fs.join(nuttx_root, 'nuttx', 'tools')) ex.check_run_cmd('./configure.sh', ['stm32f4discovery/usbnsh']) fs.chdir('..') fs.copy(fs.join(path.PROJECT_ROOT, 'targets', 'nuttx-stm32f4', 'nuttx', '.config.travis'), '.config')
def setup_tizenrt_repo(tizenrt_root): if fs.exists(tizenrt_root): fs.chdir(tizenrt_root) ex.check_run_cmd('git', ['fetch', 'origin']) fs.chdir(path.PROJECT_ROOT) else: ex.check_run_cmd('git', ['clone', 'https://github.com/Samsung/TizenRT.git', tizenrt_root]) ex.check_run_cmd('git', ['--git-dir', tizenrt_root + '/.git/', '--work-tree', tizenrt_root, 'checkout', TIZENRT_COMMIT]) copy_tiznert_stuff(tizenrt_root, path.PROJECT_ROOT)
def generate_nuttx_romfs(nuttx_root): ''' Create a ROMFS image from the contents of the IoT.js test's root directory. ''' genromfs_flags = ['-f', 'romfs_img', '-d', path.TEST_ROOT] xxd_flags = ['-i', 'romfs_img', 'nsh_romfsimg.h'] sed_flags = ['-ie', 's/unsigned/const\ unsigned/g', 'nsh_romfsimg.h'] fs.chdir(fs.join(nuttx_root, 'apps/nshlib')) ex.check_run_cmd('genromfs', genromfs_flags) ex.check_run_cmd('xxd', xxd_flags) ex.check_run_cmd('sed', sed_flags) fs.chdir(path.PROJECT_ROOT)
def build_iotjs(options): print_progress('Build IoT.js') # Set IoT.js cmake options. cmake_opt = [ '-B%s' % options.build_root, '-H%s' % path.PROJECT_ROOT, "-DCMAKE_TOOLCHAIN_FILE='%s'" % options.cmake_toolchain_file, '-DCMAKE_BUILD_TYPE=%s' % options.buildtype.capitalize(), '-DTARGET_ARCH=%s' % options.target_arch, '-DTARGET_OS=%s' % options.target_os, '-DTARGET_BOARD=%s' % options.target_board, '-DPLATFORM_DESCRIPTOR=%s' % options.target_tuple, '-DENABLE_LTO=%s' % get_on_off(options.jerry_lto), # --jerry-lto '-DENABLE_SNAPSHOT=%s' % get_on_off(not options.no_snapshot), '-DBUILD_LIB_ONLY=%s' % get_on_off(options.buildlib), # --buildlib # --jerry-memstat '-DFEATURE_MEM_STATS=%s' % get_on_off(options.jerry_memstat), # --external-modules "-DEXTERNAL_MODULES='%s'" % ';'.join(options.external_modules), # --jerry-profile "-DFEATURE_PROFILE='%s'" % options.jerry_profile, ] if options.target_os in ['nuttx', 'tizenrt']: cmake_opt.append("-DEXTERNAL_LIBC_INTERFACE='%s'" % fs.join(options.sysroot, 'include')) cmake_opt.append("-DTARGET_SYSTEMROOT='%s'" % options.sysroot) cmake_opt.append("-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=arm") # --jerry-heaplimit if options.jerry_heaplimit: cmake_opt.append('-DMEM_HEAP_SIZE_KB=%d' % options.jerry_heaplimit) # --jerry-heap-section if options.jerry_heap_section: cmake_opt.append("-DJERRY_HEAP_SECTION_ATTR='%s'" % options.jerry_heap_section) # --jerry-debugger if options.jerry_debugger: cmake_opt.append('-DFEATURE_DEBUGGER=ON') # --cmake-param cmake_opt.extend(options.cmake_param) # --external-lib cmake_opt.append("-DEXTERNAL_LIBS='%s'" % (' '.join(options.external_lib))) # --jerry-cmake-param if options.jerry_cmake_param: cmake_opt.append("-DEXTRA_JERRY_CMAKE_PARAMS='%s'" % ' '.join(options.jerry_cmake_param)) # --experimental if options.experimental: cmake_opt.append('-DEXPERIMENTAL=ON') # --profile if options.profile: cmake_opt.append("-DIOTJS_PROFILE='%s'" % options.profile) # Add common cmake options. cmake_opt.extend(build_cmake_args(options)) # Run cmake. ex.check_run_cmd('cmake', cmake_opt) run_make(options, options.build_root)
def build_iotjs(option): # Run js2c fs.chdir(path.TOOLS_ROOT) js2c(option.buildtype, option.no_snapshot, option.js_modules, jerry_output_path) # Move working directory to IoT.js build directory. build_home = fs.join(build_root, 'iotjs') fs.maybe_make_directory(build_home) fs.chdir(build_home) # Set JerryScript cmake option. cmake_opt = [path.PROJECT_ROOT] cmake_opt.append('-DCMAKE_TOOLCHAIN_FILE=' + cmake_toolchain_file) cmake_opt.append('-DCMAKE_BUILD_TYPE=' + option.buildtype.capitalize()) cmake_opt.append('-DTARGET_OS=' + option.target_os) cmake_opt.append('-DPLATFORM_DESCRIPT=' + platform_descriptor) # IoT.js module list cmake_opt.append('-DIOTJS_MODULES=' + (' ').join(option.native_modules)) if not option.no_snapshot: option.compile_flag.append('-DENABLE_SNAPSHOT') if option.target_os == 'nuttx': cmake_opt.append('-DNUTTX_HOME=' + option.nuttx_home) option.buildlib = True # --build-lib if option.buildlib: cmake_opt.append('-DBUILD_TO_LIB=YES') # --cmake-param cmake_opt += option.cmake_param # --external_static_lib cmake_opt.append('-DEXTERNAL_STATIC_LIB=' + ' '.join(option.external_static_lib)) # --external_shared_lib config_shared_libs = option.config['shared_libs'] option.external_shared_lib += config_shared_libs['os'][option.target_os] cmake_opt.append('-DEXTERNAL_SHARED_LIB=' + ' '.join(option.external_shared_lib)) # inflate cmake option inflate_cmake_option(cmake_opt, option) # Run cmake. ex.check_run_cmd('cmake', cmake_opt) # Set make option. make_opt = [] if not option.no_parallel_build: make_opt.append('-j') # Run make ex.check_run_cmd('make', make_opt) # Output output = fs.join(build_home, 'liblibiotjs.a' if option.buildlib else 'iotjs') if not fs.exists(output): ex.fail('IoT.js build failed - target not produced.') # copy dest_path = libiotjs_output_path if option.buildlib else iotjs_output_path fs.copy(output, dest_path) return True
def job_misc(): ex.check_run_cmd('tools/check_signed_off.sh', ['--travis']) ex.check_run_cmd('tools/check_tidy.py')
def build_iotjs(options): print_progress('Build IoT.js') # Set IoT.js cmake options. cmake_opt = [ '-B%s' % options.build_root, '-H%s' % path.PROJECT_ROOT, "-DCMAKE_TOOLCHAIN_FILE='%s'" % options.cmake_toolchain_file, '-DCMAKE_BUILD_TYPE=%s' % options.buildtype.capitalize(), '-DTARGET_ARCH=%s' % options.target_arch, '-DTARGET_OS=%s' % options.target_os, '-DTARGET_BOARD=%s' % options.target_board, '-DPLATFORM_DESCRIPTOR=%s' % options.target_tuple, '-DENABLE_LTO=%s' % get_on_off(options.jerry_lto), # --jerry-lto '-DENABLE_SNAPSHOT=%s' % get_on_off(not options.no_snapshot), '-DBUILD_LIB_ONLY=%s' % get_on_off(options.buildlib), # --buildlib '-DBUILD_STATIC=%s' % get_on_off(options.static), '-DINSTALL_PREFIX=%s' % options.install_prefix, # --jerry-memstat '-DFEATURE_MEM_STATS=%s' % get_on_off(options.jerry_memstat), # --jerry-cpu-profiler '-DFEATURE_CPU_PROFILER=%s' % get_on_off(options.jerry_cpu_profiler), # --jerry-heap-profiler '-DFEATURE_HEAP_PROFILER=%s' % get_on_off(options.jerry_heap_profiler), # --external-modules "-DEXTERNAL_MODULES='%s'" % ';'.join(options.external_modules), # --jerry-profile "-DFEATURE_PROFILE='%s'" % options.jerry_profile, ] if options.G: cmake_opt.append('-G%s' % options.G) if options.target_os in ['nuttx', 'tizenrt']: cmake_opt.append("-DEXTERNAL_LIBC_INTERFACE='%s'" % fs.join(options.sysroot, 'include')) cmake_opt.append("-DTARGET_SYSTEMROOT='%s'" % options.sysroot) cmake_opt.append("-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=arm") # --jerry-heaplimit if options.jerry_heaplimit: cmake_opt.append('-DMEM_HEAP_SIZE_KB=%d' % options.jerry_heaplimit) # --jerry-heap-section if options.jerry_heap_section: cmake_opt.append("-DJERRY_HEAP_SECTION_ATTR='%s'" % options.jerry_heap_section) # --jerry-debugger if options.jerry_debugger: cmake_opt.append('-DFEATURE_DEBUGGER=ON') # --napi if options.napi: cmake_opt.append('-DENABLE_NAPI=ON') # --jerryx if options.jerryx: cmake_opt.append('-DENABLE_JERRYX=ON') # --cmake-param cmake_opt.extend(options.cmake_param) # --external-lib cmake_opt.append("-DEXTERNAL_LIBS='%s'" % (' '.join(options.external_lib))) # --jerry-cmake-param if options.jerry_cmake_param: cmake_opt.append("-DEXTRA_JERRY_CMAKE_PARAMS='%s'" % ' '.join(options.jerry_cmake_param)) # --experimental if options.experimental: options.compile_flag.append('-DEXPERIMENTAL') # --profile if options.profile: cmake_opt.append("-DIOTJS_PROFILE='%s'" % options.profile) # --disable-es2015 if options.disable_es2015: cmake_opt.append("-DISABLE_ES2015") # Add common cmake options. cmake_opt.extend(build_cmake_args(options)) # Run cmake. ex.check_run_cmd('cmake', cmake_opt) if options.install: run_make(options, options.build_root, 'install') else: run_make(options, options.build_root)
setup_nuttx_root(nuttx_root) build_nuttx(nuttx_root, buildtype, 'context') build(buildtype, ['--target-arch=arm', '--target-os=nuttx', '--nuttx-home=' + fs.join(nuttx_root, 'nuttx'), '--target-board=stm32f4dis', '--jerry-heaplimit=78'] + os_dependency_module['nuttx'] + build_args) build_nuttx(nuttx_root, buildtype, 'all') fs.chdir(current_dir) elif test == "misc": args = [] if os.getenv('TRAVIS') != None: args = ['--travis'] ex.check_run_cmd('tools/check_signed_off.sh', args) if not check_tidy(path.PROJECT_ROOT): ex.fail("Failed tidy check") build("debug", build_args) build("debug", ['--iotjs-minimal-profile'] + build_args) elif test == "no-snapshot": args = [] if os.getenv('TRAVIS') != None: args = ['--travis'] build("debug", ['--no-snapshot', '--jerry-lto'] + os_dependency_module['linux'] + build_args)
def build_iotjs(options): print_progress('Build IoT.js') # Set IoT.js cmake options. cmake_opt = [ '-B%s' % options.build_root, '-H%s' % path.PROJECT_ROOT, "-DCMAKE_TOOLCHAIN_FILE=%s" % options.cmake_toolchain_file, '-DCMAKE_BUILD_TYPE=%s' % options.buildtype.capitalize(), '-DTARGET_ARCH=%s' % options.target_arch, '-DTARGET_OS=%s' % options.target_os, '-DTARGET_BOARD=%s' % options.target_board, '-DENABLE_LTO=%s' % get_on_off(options.jerry_lto), # --jerry-lto '-DENABLE_MODULE_NAPI=%s' % get_on_off(options.n_api), # --n-api '-DENABLE_SNAPSHOT=%s' % get_on_off(not options.no_snapshot), '-DEXPOSE_GC=%s' % get_on_off(options.expose_gc), # --exposing gc '-DBUILD_LIB_ONLY=%s' % get_on_off(options.buildlib), # --buildlib '-DCREATE_SHARED_LIB=%s' % get_on_off(options.create_shared_lib), # --jerry-memstat '-DFEATURE_MEM_STATS=%s' % get_on_off(options.jerry_memstat), # --external-modules "-DEXTERNAL_MODULES='%s'" % ';'.join(options.external_modules), # --jerry-profile "-DFEATURE_PROFILE='%s'" % options.jerry_profile, ] if options.target_os in ['nuttx', 'tizenrt']: cmake_opt.append("-DEXTERNAL_LIBC_INTERFACE='%s'" % fs.join(options.sysroot, 'include')) cmake_opt.append("-DTARGET_SYSTEMROOT='%s'" % options.sysroot) cmake_opt.append("-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=arm") # --jerry-heaplimit if options.jerry_heaplimit: cmake_opt.append('-DMEM_HEAP_SIZE_KB=%d' % options.jerry_heaplimit) if options.jerry_heaplimit > 512: cmake_opt.append("-DEXTRA_JERRY_CMAKE_PARAMS='%s'" % "-DFEATURE_CPOINTER_32_BIT=ON") # --jerry-heap-section if options.jerry_heap_section: cmake_opt.append("-DJERRY_HEAP_SECTION_ATTR='%s'" % options.jerry_heap_section) # --jerry-debugger if options.jerry_debugger: cmake_opt.append("-DFEATURE_DEBUGGER=ON") # --js-backtrace cmake_opt.append("-DFEATURE_JS_BACKTRACE=%s" % options.js_backtrace) # --cmake-param cmake_opt.extend(options.cmake_param) # --external-lib cmake_opt.append("-DEXTERNAL_LIBS='%s'" % (' '.join(options.external_lib))) # --jerry-cmake-param if options.jerry_cmake_param: cmake_opt.append("-DEXTRA_JERRY_CMAKE_PARAMS='%s'" % ' '.join(options.jerry_cmake_param)) # --experimental if options.experimental: cmake_opt.append('-DEXPERIMENTAL=ON') # --profile if options.profile: cmake_opt.append("-DIOTJS_PROFILE='%s'" % options.profile) # Add common cmake options. cmake_opt.extend(build_cmake_args(options)) # Run cmake. ex.check_run_cmd('cmake', cmake_opt) if options.target_os == 'windows': print("\nPlease open the iot.js solution file in Visual Studio!") else: run_make(options, options.build_root)
def build(buildtype, args=[]): fs.chdir(path.PROJECT_ROOT) ex.check_run_cmd('./tools/build.py', ['--buildtype=' + buildtype] + args)
else: rflag = 'R=0' exec_docker(DOCKER_NUTTX_PATH, [ 'make', 'all', 'IOTJS_ROOT_DIR=' + DOCKER_IOTJS_PATH, rflag]) elif test == 'tizen': for buildtype in BUILDTYPES: if buildtype == "debug": exec_docker(DOCKER_IOTJS_PATH, ['config/tizen/gbsbuild.sh', '--debug']) else: exec_docker(DOCKER_IOTJS_PATH, ['config/tizen/gbsbuild.sh']) elif test == "misc": ex.check_run_cmd('tools/check_signed_off.sh', ['--travis']) exec_docker(DOCKER_IOTJS_PATH, ['tools/check_tidy.py']) elif test == "external-modules": for buildtype in BUILDTYPES: build_iotjs(buildtype, [ '--run-test=full', '--profile=test/profiles/host-linux.profile', '--external-modules=test/external_modules/' 'mymodule1,test/external_modules/mymodule2', '--cmake-param=-DENABLE_MODULE_MYMODULE1=ON', '--cmake-param=-DENABLE_MODULE_MYMODULE2=ON']) binary = fs.join('build', platform.arch() + '-' + platform.os(), buildtype, 'bin', 'iotjs')
def exec_docker(cwd, cmd): exec_cmd = 'cd %s && ' % cwd + ' '.join(cmd) ex.check_run_cmd('docker', [ 'exec', '-it', DOCKER_NAME, 'bash', '-c', exec_cmd])
def run_docker(): ex.check_run_cmd('docker', ['run', '-dit', '--privileged', '--name', DOCKER_NAME, '-v', '%s:%s' % (TRAVIS_BUILD_PATH, DOCKER_IOTJS_PATH), 'iotjs/ubuntu:0.5'])
def build_iotjs(options): print_progress('Build IoT.js') # Set IoT.js cmake options. cmake_opt = [ '-B%s' % options.build_root, '-H%s' % path.PROJECT_ROOT, "-DCMAKE_TOOLCHAIN_FILE='%s'" % options.cmake_toolchain_file, '-DCMAKE_BUILD_TYPE=%s' % options.buildtype.capitalize(), '-DTARGET_OS=%s' % options.target_os, '-DTARGET_BOARD=%s' % options.target_board, '-DPLATFORM_DESCRIPTOR=%s' % options.target_tuple, '-DENABLE_LTO=%s' % get_on_off(options.jerry_lto), # --jerry-lto '-DENABLE_SNAPSHOT=%s' % get_on_off(not options.no_snapshot), '-DBUILD_LIB_ONLY=%s' % get_on_off(options.buildlib), # --build-lib # --jerry-memstat '-DFEATURE_MEM_STATS=%s' % get_on_off(options.jerry_memstat), # --external-modules "-DEXTERNAL_MODULES='%s'" % ';'.join(options.external_modules), # --jerry-profile "-DFEATURE_PROFILE='%s'" % options.jerry_profile, ] if options.target_os in ['nuttx', 'tizenrt']: cmake_opt.append("-DEXTERNAL_LIBC_INTERFACE='%s'" % fs.join(options.sysroot, 'include')) cmake_opt.append("-DTARGET_SYSTEMROOT='%s'" % options.sysroot) cmake_opt.append("-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=arm") # --jerry-heaplimit if options.jerry_heaplimit: cmake_opt.append('-DMEM_HEAP_SIZE_KB=%d' % options.jerry_heaplimit) # --jerry-heap-section if options.jerry_heap_section: cmake_opt.append("-DJERRY_HEAP_SECTION_ATTR='%s'" % options.jerry_heap_section) # --jerry-debugger if options.jerry_debugger: cmake_opt.append('-DFEATURE_DEBUGGER=ON') # --cmake-param cmake_opt.extend(options.cmake_param) # --external-static-lib cmake_opt.append("-DEXTERNAL_STATIC_LIB='%s'" % (' '.join(options.external_static_lib))) # --external-shared-lib shared_libs = [] shared_libs.extend(options.external_shared_lib) shared_libs.extend(options.config['shared_libs']['os'][options.target_os]) cmake_opt.append("-DEXTERNAL_SHARED_LIB='%s'" % (' '.join(shared_libs))) # --jerry-cmake-param if options.jerry_cmake_param: cmake_opt.append("-DEXTRA_JERRY_CMAKE_PARAMS='%s'" % ' '.join(options.jerry_cmake_param)) # --experimental if options.experimental: options.compile_flag.append('-DEXPERIMENTAL') # --profile if options.profile: cmake_opt.append("-DIOTJS_PROFILE='%s'" % options.profile) # Add common cmake options. cmake_opt.extend(build_cmake_args(options)) # Run cmake. ex.check_run_cmd('cmake', cmake_opt) run_make(options, options.build_root)
def init_submodule(): ex.check_run_cmd('git', ['submodule', 'init']) ex.check_run_cmd('git', ['submodule', 'update'])
def exec_docker(cmd): ''' Execute the given command in Docker. ''' exec_cmd = ' '.join(cmd) ex.check_run_cmd('docker', ['exec', '-it', DOCKER_NAME, '/bin/bash', '-c', exec_cmd])
def build_tizenrt(tizenrt_root, iotjs_rootdir, buildtype): fs.chdir(fs.join(tizenrt_root, 'os')) iotjs_libdir = iotjs_rootdir + '/build/arm-tizenrt/' + buildtype + '/lib' ex.check_run_cmd('make', ['IOTJS_ROOT_DIR=' + iotjs_rootdir, 'IOTJS_LIB_DIR=' + iotjs_libdir])
def init_submodule(): ex.check_run_cmd('git', ['submodule', 'init']) ex.check_run_cmd('git', ['submodule', 'update'])
def build_libjerry(option): # Check if JerryScript submodule exists. if not fs.exists(path.JERRY_ROOT): ex.fail('JerryScript submodule not exists!') # Move working directory to JerryScript build directory. build_home = fs.join(build_root, 'deps', 'jerry') fs.maybe_make_directory(build_home) fs.chdir(build_home) # Set JerryScript cmake option. cmake_opt = [path.JERRY_ROOT] cmake_opt.append('-DCMAKE_TOOLCHAIN_FILE=' + cmake_toolchain_file) if option.buildtype == 'debug': cmake_opt.append('-DCMAKE_BUILD_TYPE=Debug') cmake_opt.append('-DFEATURE_ERROR_MESSAGES=On') if option.target_os == 'nuttx': cmake_opt.append('-DEXTERNAL_LIBC_INTERFACE=' + fs.join(option.nuttx_home, 'include')) if option.target_arch == 'arm': cmake_opt.append('-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=arm') if option.target_os == 'linux': cmake_opt.append('-DJERRY_LIBC=OFF') cmake_opt.append('-DJERRY_LIBM=OFF') # --jerry-heaplimit if option.jerry_heaplimit: cmake_opt.append('-DMEM_HEAP_SIZE_KB=' + str(option.jerry_heaplimit)) # --jerry-heap-section if option.jerry_heap_section: cmake_opt.append('-DJERRY_HEAP_SECTION_ATTR=' + str(option.jerry_heap_section)) # --jerry-lto cmake_opt.append('-DENABLE_LTO=%s' % ('ON' if option.jerry_lto else 'OFF')) if option.jerry_memstat: cmake_opt.append('-DFEATURE_MEM_STATS=ON') # Turn on snapshot cmake_opt.append('-DFEATURE_SNAPSHOT_SAVE=OFF') if not option.no_snapshot: cmake_opt.append('-DFEATURE_SNAPSHOT_EXEC=ON') # --jerry-cmake-param cmake_opt += option.jerry_cmake_param # inflate cmake option. inflate_cmake_option(cmake_opt, option, for_jerry=True) # Run cmake. ex.check_run_cmd('cmake', cmake_opt) # make target - libjerry target_libjerry_name = 'jerry-core' target_libjerry = { 'target_name': target_libjerry_name, 'output_path': fs.join(build_home, 'lib', 'lib%s.a' % target_libjerry_name), 'dest_path': libjerry_output_path } targets = [] targets.append(target_libjerry) # make the target. for target in targets: # Make option. make_opt = ['-C', build_home, target['target_name']] if not option.no_parallel_build: make_opt.append('-j') # Run make for a target. ex.check_run_cmd('make', make_opt) # Check output output = target['output_path'] if not fs.exists(output): print output ex.fail('JerryScript build failed - target not produced.') # copy fs.copy(output, target['dest_path']) return True
def job_coverity(): ex.check_run_cmd('./tools/build.py', ['--clean'])
def build_iotjs(options): print_progress('Build IoT.js') # Set JerryScript cmake options. cmake_opt = [ '-B%s' % options.build_root, '-H%s' % path.PROJECT_ROOT, "-DCMAKE_TOOLCHAIN_FILE='%s'" % options.cmake_toolchain_file, '-DCMAKE_BUILD_TYPE=%s' % options.buildtype.capitalize(), '-DTARGET_OS=%s' % options.target_os, '-DTARGET_BOARD=%s' % options.target_board, '-DPLATFORM_DESCRIPTOR=%s' % options.target_tuple, '-DENABLE_LTO=%s' % get_on_off(options.jerry_lto), # --jerry-lto '-DENABLE_SNAPSHOT=%s' % get_on_off(not options.no_snapshot), '-DENABLE_MINIMAL=%s' % get_on_off(options.iotjs_minimal_profile), '-DBUILD_LIB_ONLY=%s' % get_on_off(options.buildlib), # --build-lib # --jerry-memstat '-DFEATURE_MEM_STATS=%s' % get_on_off(options.jerry_memstat), # --iotjs-include-module "-DIOTJS_INCLUDE_MODULE='%s'" % ','.join(options.iotjs_include_module), # --iotjs-exclude-module "-DIOTJS_EXCLUDE_MODULE='%s'" % ','.join(options.iotjs_exclude_module), # --jerry-profile "-DFEATURE_PROFILE='%s'" % options.jerry_profile, ] if options.target_os in ['nuttx', 'tizenrt']: cmake_opt.append("-DEXTERNAL_LIBC_INTERFACE='%s'" % fs.join(options.sysroot, 'include')) cmake_opt.append("-DTARGET_SYSTEMROOT='%s'" % options.sysroot) cmake_opt.append("-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=arm") # --jerry-heaplimit if options.jerry_heaplimit: cmake_opt.append('-DMEM_HEAP_SIZE_KB=%d' % options.jerry_heaplimit) # --jerry-heap-section if options.jerry_heap_section: cmake_opt.append("-DJERRY_HEAP_SECTION_ATTR='%s'" % options.jerry_heap_section) # --jerry-debugger if options.jerry_debugger: cmake_opt.append('-DFEATURE_DEBUGGER=ON') cmake_opt.append('-DFEATURE_DEBUGGER_PORT=%d' % options.jerry_debugger_port) # --cmake-param cmake_opt.extend(options.cmake_param) # --external-static-lib cmake_opt.append("-DEXTERNAL_STATIC_LIB='%s'" % (' '.join(options.external_static_lib))) # --external-shared-lib shared_libs = [] shared_libs.extend(options.external_shared_lib) shared_libs.extend(options.config['shared_libs']['os'][options.target_os]) cmake_opt.append("-DEXTERNAL_SHARED_LIB='%s'" % (' '.join(shared_libs))) # --jerry-cmake-param if options.jerry_cmake_param: cmake_opt.append("-DEXTRA_JERRY_CMAKE_PARAMS='%s'" % ' '.join(options.jerry_cmake_param)) # --experimental if options.experimental: options.compile_flag.append('-DEXPERIMENTAL') # Add common cmake options. cmake_opt.extend(build_cmake_args(options)) # Run cmake. ex.check_run_cmd('cmake', cmake_opt) run_make(options, options.build_root)