Exemple #1
0
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'])
Exemple #2
0
def adjust_options(options):
    # First fix some option inconsistencies.
    if options.target_os in ['nuttx', 'tizenrt']:
        options.buildlib = True
        if not options.sysroot:
            ex.fail('--sysroot needed for nuttx target')

        options.sysroot = fs.abspath(options.sysroot)
        if not fs.exists(options.sysroot):
            ex.fail('NuttX sysroot %s does not exist' % options.sysroot)

    if options.target_arch == 'x86':
        options.target_arch = 'i686'
    if options.target_arch == 'x64':
        options.target_arch = 'x86_64'

    if options.target_os == 'darwin':
        options.no_check_valgrind = True

    if options.target_board in ['rpi2', 'artik10', 'artik05x']:
        options.no_check_valgrind = True

    # Then add calculated options.
    options.host_tuple = '%s-%s' % (platform.arch(), platform.os())
    options.target_tuple = '%s-%s' % (options.target_arch, options.target_os)

    options.build_root = fs.join(path.PROJECT_ROOT, options.builddir,
                                 options.target_tuple, options.buildtype)

    cmake_path = fs.join(path.PROJECT_ROOT, 'cmake', 'config', '%s.cmake')
    options.cmake_toolchain_file = cmake_path % options.target_tuple

    # Specify the file of JerryScript profile.
    options.jerry_profile = fs.join(path.JERRY_PROFILE_ROOT,
                                    options.jerry_profile + '.profile')
Exemple #3
0
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'])
Exemple #4
0
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)
Exemple #5
0
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,
                                   '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')
Exemple #6
0
def resolve_modules(options):
    """ Resolve include/exclude module lists based on command line arguments
        and build config.
    """
    # Load all the supported modules
    supported = options.config['module']['supported']

    core_modules = set(supported['core'])
    basic_modules = set(supported['basic'])

    # By default the target included modules are:
    #  - 'core' module set from the build config
    #  - modules specified by the command line argument
    include_modules = set() | core_modules
    include_modules |= options.iotjs_include_module

    if not options.iotjs_minimal_profile:
        # Add 'basic' module to the target include modules
        include_modules |= basic_modules

    # Start to check exclude modules
    exclude_modules = options.iotjs_exclude_module

    # Check if there are any modules which are not allowed to be excluded
    impossible_to_exclude = exclude_modules & core_modules
    if impossible_to_exclude:
        ex.fail('Can not exclude modules which are in `core` modules: %s' %
                ', '.join(impossible_to_exclude))

    # Finally remove the excluded modules from the included modules set
    include_modules -= exclude_modules

    return include_modules, exclude_modules
Exemple #7
0
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'])
Exemple #8
0
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.nuttx_home)
        cmake_opt.append('-DOS=NUTTX')

    if options.target_os in ['linux', 'tizen']:
        cmake_opt.append('-DOS=LINUX')

    # 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)
Exemple #9
0
def build_host_jerry(options):
    print_progress('Build JerryScript for host')

    # Check if JerryScript submodule exists.
    if not fs.exists(path.JERRY_ROOT):
        ex.fail('JerryScript submodule does not exists!')

    # Move working directory to JerryScript build directory.
    build_home = fs.join(options.host_build_root, 'deps', 'jerry')

    # Set JerryScript cmake options.
    cmake_opt = [
        '-B%s' % build_home,
        '-H%s' % path.JERRY_ROOT,
        "-DCMAKE_TOOLCHAIN_FILE='%s'" % options.host_cmake_toolchain_file,
        # Turn off LTO for jerry bin to save build time.
        '-DENABLE_LTO=OFF',
    ]

    if options.buildtype == 'debug':
        cmake_opt.append('-DCMAKE_BUILD_TYPE=Debug')

    # Turn on snapshot
    if not options.no_snapshot:
        cmake_opt.append('-DFEATURE_SNAPSHOT_SAVE=ON')

    # Run cmake.
    ex.check_run_cmd('cmake', cmake_opt)

    run_make(options, build_home)
    copy_build_target('jerry', fs.join(build_home, 'bin'),
                      options.host_build_bins)
Exemple #10
0
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 resolve_modules(options):
    """ Resolve include/exclude module lists based on command line arguments
        and build config.
    """
    # Load the modules which are always enabled and the include/exclude sets
    build_modules_always = set(options.config['module']['always'])
    build_modules_includes = set(options.config['module']['include'])
    build_modules_excludes = set(options.config['module']['exclude']['all'])

    if options.target_os:
        system_os = options.target_os
        if system_os == 'tizen':
            system_os = 'linux'
        build_modules_excludes |= set(
            options.config['module']['exclude'][system_os])

    # By default the target included modules are:
    #  - always module set from the build config
    #  - modules specified by the command line argument
    include_modules = set()
    include_modules |= build_modules_always
    include_modules |= options.iotjs_include_module

    if not options.iotjs_minimal_profile:
        # In case of normal build (not minimal profile):
        # Check if there is any overlap between the included and excluded
        # module sets which are from the build config
        problem_modules = build_modules_includes & build_modules_excludes
        if problem_modules:
            print('Detected module(s) both in include and exclude list.',
                  end=' ')
            print('Module name(s): %s' % ', '.join(problem_modules))
            ex.fail('Inconsistency in build config file!')

        # Add the include set from the build config to
        # the target include modules set
        include_modules |= build_modules_includes

    # Check if there is any modules which are not allowed to be excluded
    impossible_to_exclude = options.iotjs_exclude_module & build_modules_always
    if impossible_to_exclude:
        ex.fail('Cannot exclude modules which are always enabled: %s' %
                ', '.join(impossible_to_exclude))

    # Remove any excluded modules (defined by the command line argument) from
    # the target include set
    include_modules -= options.iotjs_exclude_module

    # Finally build up the excluded module set:
    #  - use the command line exclude set
    #  - use the exclude set from the build config
    exclude_modules = options.iotjs_exclude_module | build_modules_excludes
    # Remove the included modules set from the excluded modules
    exclude_modules -= include_modules

    assert len(include_modules & exclude_modules) == 0, \
        'Module can NOT be both in include and exclude list'

    return include_modules, exclude_modules
Exemple #12
0
def resolve_modules(options):
    """ Resolve include/exclude module lists based on command line arguments
        and build config.
    """
    # Load the modules which are always enabled and the include/exclude sets
    build_modules_always = set(options.config['module']['always'])
    build_modules_includes = set(options.config['module']['include'])
    build_modules_excludes = set(options.config['module']['exclude']['all'])

    if options.target_os:
        system_os = options.target_os
        if system_os == 'tizen':
            system_os = 'linux'
        build_modules_excludes |= set(
            options.config['module']['exclude'][system_os])

    # By default the target included modules are:
    #  - always module set from the build config
    #  - modules specified by the command line argument
    include_modules = set()
    include_modules |= build_modules_always
    include_modules |= options.iotjs_include_module

    if not options.iotjs_minimal_profile:
        # In case of normal build (not minimal profile):
        # Check if there is any overlap between the included and excluded
        # module sets which are from the build config
        problem_modules = build_modules_includes & build_modules_excludes
        if problem_modules:
            print('Detected module(s) both in include and exclude list.',
                  end=' ')
            print('Module name(s): %s' % ', '.join(problem_modules))
            ex.fail('Inconsistency in build config file!')

        # Add the include set from the build config to
        # the target include modules set
        include_modules |= build_modules_includes

    # Check if there is any modules which are not allowed to be excluded
    impossible_to_exclude = options.iotjs_exclude_module & build_modules_always
    if impossible_to_exclude:
        ex.fail('Cannot exclude modules which are always enabled: %s' %
                ', '.join(impossible_to_exclude))

    # Remove any excluded modules (defined by the command line argument) from
    # the target include set
    include_modules -= options.iotjs_exclude_module

    # Finally build up the excluded module set:
    #  - use the command line exclude set
    #  - use the exclude set from the build config
    exclude_modules = options.iotjs_exclude_module | build_modules_excludes
    # Remove the included modules set from the excluded modules
    exclude_modules -= include_modules

    assert len(include_modules & exclude_modules) == 0, \
        'Module can NOT be both in include and exclude list'

    return include_modules, exclude_modules
Exemple #13
0
def check_tidy(src_dir, options=None):
    allowed_exts = ['.c', '.h', '.js', '.py', '.sh', '.cmake']
    allowed_files = ['CMakeLists.txt']
    clang_format_exts = ['.c', '.h']
    skip_dirs = [
        'deps', 'build', '.git', 'node_modules', 'coverage', 'iotjs_modules',
        'IoTjsApp'
    ]
    skip_files = [
        'check_signed_off.sh', '__init__.py', 'iotjs_js.c', 'iotjs_js.h',
        'iotjs_string_ext.inl.h', "iotjs_module_inl.h", 'ble.js',
        'ble_hci_socket_acl_stream.js', 'ble_hci_socket_smp.js',
        'ble_hci_socket_hci.js', 'ble_hci_socket_gap.js',
        'ble_hci_socket_gatt.js', 'ble_hci_socket_mgmt.js',
        'ble_hci_socket_bindings.js', 'ble_characteristic.js',
        'test_ble_setservices.js', '.eslintrc.js', 'c_source_templates.py',
        'cpp_source_templates.py'
    ]

    style = StyleChecker()
    style.set_rules()
    clang = ClangFormat(clang_format_exts, skip_files, options)
    eslint = EslintChecker(options)

    file_filter = FileFilter(allowed_exts, allowed_files, skip_files)
    files = fs.files_under(src_dir, skip_dirs, file_filter)

    clang.check(files)
    style.check(files)
    eslint.check()

    if clang.error_count:
        print("Detected clang-format problems:")
        print("".join(clang.diffs))
        print()

    if style.error_count:
        print("Detected style problems:")
        print("\n".join(style.errors))
        print()

    if eslint.error_count:
        print("Detected eslint problems:")
        print("\n".join(eslint.errors))
        print()

    total_errors = style.error_count + clang.error_count + eslint.error_count
    print("* total lines of code: %d" % style.count_lines)
    print("* total non-blank lines of code: %d" % style.count_valid_lines)
    print("* style errors: %d" % style.error_count)
    print("* clang-format errors: %d" % clang.error_count)
    print("* eslint errors: %d" % eslint.error_count)

    msg_color = Terminal.red if total_errors > 0 else Terminal.green
    Terminal.pprint("* total errors: %d" % (total_errors), msg_color)
    print()

    if total_errors:
        ex.fail("Failed tidy check")
Exemple #14
0
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'])
Exemple #15
0
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), DOCKER_IMAGE_NAME
    ])
Exemple #16
0
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)
Exemple #17
0
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])
Exemple #18
0
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])
Exemple #19
0
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
Exemple #20
0
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)
Exemple #21
0
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 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])
Exemple #23
0
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])
Exemple #24
0
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)
Exemple #25
0
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)
Exemple #26
0
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])
Exemple #27
0
def adjust_options(options):
    # First fix some option inconsistencies
    if options.target_os == 'nuttx':
        options.buildlib = True
        if not options.sysroot:
            ex.fail('--sysroot needed for nuttx target')

        options.sysroot = fs.abspath(options.sysroot)
        if not fs.exists(options.sysroot):
            ex.fail('Nuttx sysroot %s does not exist' % options.sysroot)

    if options.target_arch == 'x86':
        options.target_arch = 'i686'
    if options.target_arch == 'x64':
        options.target_arch = 'x86_64'

    if options.target_os == 'darwin':
        options.no_check_valgrind = True

    if options.target_board in ['rpi2', 'artik10']:
        options.no_check_valgrind = True
    elif options.target_board == 'none':
        options.target_board = None

    if options.iotjs_minimal_profile:
        options.no_check_test = True

    # Then add calculated options
    options.host_tuple = '%s-%s' % (platform.arch(), platform.os())
    options.target_tuple = '%s-%s' % (options.target_arch, options.target_os)
    arch_for_iotjs = 'arm' if options.target_arch[0:3] == 'arm' else \
        options.target_arch
    os_for_iotjs = 'linux' if options.target_os == 'tizen' else \
        options.target_os
    options.target_tuple_for_iotjs = '%s-%s' % (arch_for_iotjs, os_for_iotjs)

    options.host_build_root = fs.join(path.PROJECT_ROOT,
                                     options.builddir,
                                     'host',
                                     options.host_tuple,
                                     options.buildtype)
    options.host_build_bins = fs.join(options.host_build_root, 'bin')

    options.build_root = fs.join(path.PROJECT_ROOT,
                                 options.builddir,
                                 options.target_tuple,
                                 options.buildtype)
    options.build_bins = fs.join(options.build_root, 'bin')
    options.build_libs = fs.join(options.build_root, 'lib')

    cmake_path = fs.join(path.PROJECT_ROOT, 'cmake', 'config', '%s.cmake')
    options.cmake_toolchain_file = cmake_path % options.target_tuple
    options.host_cmake_toolchain_file = cmake_path % options.host_tuple
Exemple #28
0
def copy_build_target(target_name, src_dir, dst_dir, new_target_name=None):
    build_output = fs.join(src_dir, target_name)
    if not fs.exists(build_output):
        ex.fail('%s build failed - target not produced.' % target_name)

    if new_target_name:
        copy_target_name = new_target_name
    else:
        copy_target_name = target_name

    copy_target_path = fs.join(dst_dir, copy_target_name)
    fs.copy(build_output, copy_target_path)
Exemple #29
0
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)
Exemple #30
0
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)
Exemple #31
0
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)
Exemple #32
0
def adjust_options(options):
    # First fix some option inconsistencies
    if options.target_os in ['nuttx', 'tizenrt']:
        options.buildlib = True
        if not options.sysroot:
            ex.fail('--sysroot needed for nuttx target')

        options.sysroot = fs.abspath(options.sysroot)
        if not fs.exists(options.sysroot):
            ex.fail('Nuttx sysroot %s does not exist' % options.sysroot)

    if options.target_arch == 'x86':
        options.target_arch = 'i686'
    if options.target_arch == 'x64':
        options.target_arch = 'x86_64'

    if options.target_os == 'darwin':
        options.no_check_valgrind = True

    if options.target_board in ['rpi2', 'artik10', 'artik05x']:
        options.no_check_valgrind = True
    elif options.target_board == 'none':
        options.target_board = None

    if options.iotjs_minimal_profile:
        options.no_check_test = True

    # Then add calculated options
    options.host_tuple = '%s-%s' % (platform.arch(), platform.os())
    options.target_tuple = '%s-%s' % (options.target_arch, options.target_os)

    options.host_build_root = fs.join(path.PROJECT_ROOT,
                                     options.builddir,
                                     'host',
                                     options.host_tuple,
                                     options.buildtype)
    options.host_build_bins = fs.join(options.host_build_root, 'bin')

    options.build_root = fs.join(path.PROJECT_ROOT,
                                 options.builddir,
                                 options.target_tuple,
                                 options.buildtype)
    options.build_bins = fs.join(options.build_root, 'bin')
    options.build_libs = fs.join(options.build_root, 'lib')

    cmake_path = fs.join(path.PROJECT_ROOT, 'cmake', 'config', '%s.cmake')
    options.cmake_toolchain_file = cmake_path % options.target_tuple
    options.host_cmake_toolchain_file = cmake_path % options.host_tuple

    # Specify the file of JerryScript profile
    options.jerry_profile = fs.join(path.JERRY_PROFILE_ROOT,
                                    options.jerry_profile + '.profile')
Exemple #33
0
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)
Exemple #34
0
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])
Exemple #35
0
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)
Exemple #36
0
def test_cpp():
    test_dir = fs.join(os.path.dirname(__file__), 'test_cpp')
    test_cpp = fs.join(test_dir, 'test.cpp')

    # Compile test.c and make a static library
    print_blue('Compile C++ test module.')
    ex.check_run_cmd_output('c++', ['-c', test_cpp, '-o', test_dir + '/test.o'])
    ex.check_run_cmd_output('ar', ['-cr', test_dir + '/libtest.a',
                     test_dir + '/test.o'])

    # Generate test_module
    print_blue('Generate binding for C++ test module.')
    ex.check_run_cmd_output(generator_script, [test_dir, 'c++'])

    # Build iotjs
    print_blue('Build IoT.js.')
    module_dir = fs.join(module_generator_dir, 'output', 'test_cpp_module')
    args = [
    '--external-module=' + module_dir,
    '--cmake-param=-DENABLE_MODULE_TEST_CPP_MODULE=ON',
    '--jerry-profile=es2015-subset',
    '--clean'
    ]
    ex.check_run_cmd_output(build_script, args)

    run_test_js(test_dir)

    print_green('C++ test succeeded.')
Exemple #37
0
def test_cpp():
    test_dir = fs.join(os.path.dirname(__file__), 'test_cpp')
    test_cpp = fs.join(test_dir, 'test.cpp')

    # Compile test.c and make a static library
    print_blue('Compile C++ test module.')
    ex.check_run_cmd_output('c++',
                            ['-c', test_cpp, '-o', test_dir + '/test.o'])
    ex.check_run_cmd_output(
        'ar', ['-cr', test_dir + '/libtest.a', test_dir + '/test.o'])

    # Generate test_module
    print_blue('Generate binding for C++ test module.')
    ex.check_run_cmd_output(generator_script, [test_dir, 'c++'])

    # Build iotjs
    print_blue('Build IoT.js.')
    module_dir = fs.join(module_generator_dir, 'output', 'test_cpp_module')
    args = [
        '--external-module=' + module_dir,
        '--cmake-param=-DENABLE_MODULE_TEST_CPP_MODULE=ON',
        '--jerry-profile=es2015-subset', '--clean'
    ]
    ex.check_run_cmd_output(build_script, args)

    run_test_js(test_dir)

    print_green('C++ test succeeded.')
Exemple #38
0
def run_checktest(options):
    checktest_quiet = 'yes'
    if os.getenv('TRAVIS') == "true":
        checktest_quiet = 'no'

    # iot.js executable
    iotjs = fs.join(options.build_root, 'iotjs', 'iotjs')
    build_args = ['--', 'quiet=' + checktest_quiet]
    if options.iotjs_exclude_module:
        skip_module = ','.join(options.iotjs_exclude_module)
        build_args.append('skip-module=' + skip_module)

    fs.chdir(path.PROJECT_ROOT)
    code = ex.run_cmd(iotjs, [path.CHECKTEST_PATH] + build_args)
    if code != 0:
        ex.fail('Failed to pass unit tests')
    if not options.no_check_valgrind:
        code = ex.run_cmd('valgrind', ['--leak-check=full',
                                       '--error-exitcode=5',
                                       '--undef-value-errors=no',
                                       iotjs,
                                       path.CHECKTEST_PATH] + build_args)
        if code == 5:
            ex.fail('Failed to pass valgrind test')
        if code != 0:
            ex.fail('Failed to pass unit tests in valgrind environment')
Exemple #39
0
def run_checktest(option):
    checktest_quiet = 'yes'
    if os.getenv('TRAVIS') == "true":
        checktest_quiet = 'no'

    # iot.js executable
    iotjs = fs.join(build_root, 'iotjs', 'iotjs')
    fs.chdir(path.PROJECT_ROOT)
    code = ex.run_cmd(iotjs, [path.CHECKTEST_PATH,
                              '--',
                              'quiet='+checktest_quiet])
    if code != 0:
        ex.fail('Failed to pass unit tests')
    if not option.no_check_valgrind:
        code = ex.run_cmd('valgrind', ['--leak-check=full',
                                       '--error-exitcode=5',
                                       '--undef-value-errors=no',
                                       iotjs,
                                       path.CHECKTEST_PATH,
                                       '--',
                                       'quiet='+checktest_quiet])
        if code == 5:
            ex.fail('Failed to pass valgrind test')
        if code != 0:
            ex.fail('Failed to pass unit tests in valgrind environment')
    return True
Exemple #40
0
def run_checktest(options):
    checktest_quiet = 'yes'
    if os.getenv('TRAVIS') == "true":
        checktest_quiet = 'no'

    # IoT.js executable
    iotjs = fs.join(options.build_root, 'bin', 'iotjs')
    build_args = ['quiet=' + checktest_quiet]

    # experimental
    if options.experimental:
        build_args.append('experimental=' + 'yes');

    fs.chdir(path.PROJECT_ROOT)
    code = ex.run_cmd(iotjs, [path.CHECKTEST_PATH] + build_args)
    if code != 0:
        ex.fail('Failed to pass unit tests')
    if not options.no_check_valgrind:
        code = ex.run_cmd('valgrind', ['--leak-check=full',
                                       '--error-exitcode=5',
                                       '--undef-value-errors=no',
                                       iotjs,
                                       path.CHECKTEST_PATH] + build_args)
        if code == 5:
            ex.fail('Failed to pass valgrind test')
        if code != 0:
            ex.fail('Failed to pass unit tests in valgrind environment')
Exemple #41
0
def run_checktest(options):
    checktest_quiet = 'yes'
    if os.getenv('TRAVIS') == "true":
        checktest_quiet = 'no'

    # iot.js executable
    iotjs = fs.join(options.build_root, 'bin', 'iotjs')
    build_args = ['--', 'quiet=' + checktest_quiet]
    if options.iotjs_exclude_module:
        skip_module = ','.join(options.iotjs_exclude_module)
        build_args.append('skip-module=' + skip_module)

    # experimental
    if options.experimental:
        build_args.append('experimental=' + 'yes');

    fs.chdir(path.PROJECT_ROOT)
    code = ex.run_cmd(iotjs, [path.CHECKTEST_PATH] + build_args)
    if code != 0:
        ex.fail('Failed to pass unit tests')
    if not options.no_check_valgrind:
        code = ex.run_cmd('valgrind', ['--leak-check=full',
                                       '--error-exitcode=5',
                                       '--undef-value-errors=no',
                                       iotjs,
                                       path.CHECKTEST_PATH] + build_args)
        if code == 5:
            ex.fail('Failed to pass valgrind test')
        if code != 0:
            ex.fail('Failed to pass unit tests in valgrind environment')
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)
Exemple #43
0
    def __init__(self, options):
        self._process_pool = multiprocessing.Pool(processes=1)
        self.iotjs = fs.abspath(options.iotjs)
        self.quiet = options.quiet
        self.platform = options.platform
        self.timeout = options.timeout
        self.valgrind = options.valgrind
        self.coverage = options.coverage
        self.n_api = options.n_api
        self.skip_modules = []
        self.results = {}
        self._msg_queue = multiprocessing.Queue(1)

        if options.skip_modules:
            self.skip_modules = options.skip_modules.split(",")

        # Process the iotjs build information.
        iotjs_output = Executor.check_run_cmd_output(self.iotjs,
                                                     [path.BUILD_INFO_PATH])
        build_info = json.loads(iotjs_output)

        self.builtins = set(build_info["builtins"])
        self.features = set(build_info["features"])
        self.stability = build_info["stability"]
        self.debug = build_info["debug"]
        if options.n_api:
            build_napi_test_module(self.debug)
Exemple #44
0
def adjust_options(options):
    # First fix some option inconsistencies.
    if options.target_os in ['nuttx', 'tizenrt']:
        options.buildlib = True
        if not options.sysroot:
            ex.fail('--sysroot needed for %s target' % options.target_os)

        options.sysroot = fs.abspath(options.sysroot)
        if not fs.exists(options.sysroot):
            ex.fail('NuttX sysroot %s does not exist' % options.sysroot)

    if options.target_arch == 'x86':
        options.target_arch = 'i686'
    if options.target_arch == 'x64':
        options.target_arch = 'x86_64'

    if options.target_os == 'darwin':
        options.no_check_valgrind = True

    if options.target_board in ['rpi2', 'rpi3', 'artik10', 'artik05x']:
        options.no_check_valgrind = True

    # Then add calculated options.
    options.host_tuple = '%s-%s' % (platform.arch(), platform.os())
    options.target_tuple = '%s-%s' % (options.target_arch, options.target_os)

    # Normalize the path of build directory.
    options.builddir = fs.normpath(options.builddir)

    options.build_root = fs.join(path.PROJECT_ROOT,
                                 options.builddir,
                                 options.target_tuple,
                                 options.buildtype)

    cmake_path = fs.join(path.PROJECT_ROOT, 'cmake', 'config', '%s.cmake')
    options.cmake_toolchain_file = cmake_path % options.target_tuple

    # Set the default value of '--js-backtrace' if it is not defined.
    if not options.js_backtrace:
        if options.buildtype == 'debug':
            options.js_backtrace = "ON"
        else:
            options.js_backtrace = "OFF"
Exemple #45
0
def build_nuttx(nuttx_root, buildtype):
    fs.chdir(fs.join(nuttx_root, 'nuttx'))
    try:
        code = 0
        if buildtype == "release":
            code = ex.run_cmd('make',
                              ['IOTJS_ROOT_DIR=' + path.PROJECT_ROOT, 'R=1'])
        else:
            code = ex.run_cmd('make',
                              ['IOTJS_ROOT_DIR=' + path.PROJECT_ROOT, 'R=0'])

        if code == 0:
            return True
        else:
            print 'Failed to build nuttx'
            return False
    except OSError as err:
        print 'Failed to build nuttx: %s' % err
        return False
Exemple #46
0
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
Exemple #47
0
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
Exemple #48
0
def analyze_module_dependency(include_modules, exclude_modules):
    analyze_queue = set(include_modules) # copy the set
    analyze_queue.add('iotjs')

    js_modules = { 'native' }
    native_modules = { 'process' }
    while analyze_queue:
        item = analyze_queue.pop()
        js_modules.add(item)
        js_module_path = fs.join(path.PROJECT_ROOT,
                                 'src', 'js', item + '.js')
        if not fs.exists(js_module_path):
            ex.fail('Cannot read file "%s"' % js_module_path)
        with open(js_module_path) as module:
            content = module.read()

        # Pretend to ignore comments in JavaScript
        re_js_comments = "\/\/.*|\/\*.*\*\/";
        content = re.sub(re_js_comments, "", content)

        # Get all required modules
        re_js_module = 'require\([\'\"](.*?)[\'\"]\)'
        required_modules = set(re.findall(re_js_module, content))
        # Check if there is any required modules in the exclude set
        problem_modules = required_modules & exclude_modules
        if problem_modules:
            ex.fail('Cannot exclude module(s) "%s" since "%s" requires them' %
                    (', '.join(problem_modules), item))

        # Add all modules to analytze queue which are not yet analyzed
        analyze_queue |= required_modules - js_modules

        # Get all native modules
        re_native_module = 'process.binding\(process.binding.(.*?)\)'
        native_modules |= set(re.findall(re_native_module, content))

    js_modules.remove('native')

    modules = {'js': sorted(js_modules), 'native': sorted(native_modules)}

    return modules
Exemple #49
0
def adjust_option(option):
    if option.target_os.lower() == 'nuttx':
        option.buildlib = True
        if option.nuttx_home == '':
            ex.fail('--nuttx-home needed for nuttx target')
        else:
            option.nuttx_home = fs.abspath(option.nuttx_home)
            if not fs.exists(option.nuttx_home):
                ex.fail('--nuttx-home %s not exists' % option.nuttx_home)
    if option.target_arch == 'x86':
        option.target_arch = 'i686'
    if option.target_arch == 'x64':
        option.target_arch = 'x86_64'
    if option.target_board == 'rpi2':
        option.no_check_valgrind = True
    if option.cmake_param is None:
        option.cmake_param = []
    if option.compile_flag is None:
        option.compile_flag = []
    if option.link_flag is None:
        option.link_flag = []
    if option.external_include_dir is None:
        option.external_include_dir = []
    if option.external_static_lib is None:
        option.external_static_lib = []
    if option.external_shared_lib is None:
        option.external_shared_lib = []
    if option.iotjs_include_module is None:
        option.iotjs_include_module = []
    if option.iotjs_exclude_module is None:
        option.iotjs_exclude_module = []
    if option.iotjs_minimal_profile:
        option.no_check_test = True
    if option.jerry_cmake_param is None:
        option.jerry_cmake_param = []
    if option.jerry_compile_flag is None:
        option.jerry_compile_flag = []
    if option.jerry_link_flag is None:
        option.jerry_link_flag = []
Exemple #50
0
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
Exemple #51
0
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')
Exemple #52
0
    def check(self):
        self.error_count = 0

        if not self._node or not self._eslint:
            return
        args = ['src', '-f', 'codeframe']
        if self._options and self._options.autoedit:
             args.append('--fix')

        output = ex.run_cmd_output(self._eslint, args, quiet=True)
        match = re.search('(\d+) error', output)
        if match:
            self.error_count = int(match.group(1))

        # Delete unnecessary error messages.
        self.errors = output.split('\n')[:-4]
Exemple #53
0
    def check(self, files):
        if not self._clang_format:
            return

        for file in filter(self.is_checked_by_clang, files):
            args = ['-style=file', file]
            if self._options and self._options.autoedit:
                args.append('-i')
            output = ex.check_run_cmd_output(self._clang_format,
                                       args, quiet=True)

            if output:
                with tempfile.NamedTemporaryFile() as temp:
                    temp.write(output)
                    temp.flush() # just to be really safe
                    self._diff(file, temp.name)
Exemple #54
0
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)
Exemple #55
0
    def __init__(self, options):
        self.iotjs = fs.abspath(options.iotjs)
        self.quiet = options.quiet
        self.timeout = options.timeout
        self.valgrind = options.valgrind
        self.coverage = options.coverage
        self.skip_modules = []
        self.results = {}

        if options.skip_modules:
            self.skip_modules = options.skip_modules.split(",")

        # Process the iotjs build information.
        iotjs_output = ex.run_cmd_output(self.iotjs, [path.BUILD_INFO_PATH])
        build_info = json.loads(iotjs_output)

        self.builtins = build_info["builtins"]
        self.stability = build_info["stability"]

        # Define own alarm handler to handle timeout.
        signal.signal(signal.SIGALRM, alarm_handler)
Exemple #56
0
def run_checktest(options):
    # IoT.js executable
    iotjs = fs.join(options.build_root, 'bin', 'iotjs')

    cmd = fs.join(path.TOOLS_ROOT, 'testrunner.py')
    args = [iotjs, "--platform=%s" % options.target_os]

    if options.run_test == "quiet":
        args.append('--quiet')

    if options.n_api:
        args.append('--n-api')

    fs.chdir(path.PROJECT_ROOT)
    code = ex.run_cmd(cmd, args)
    if code != 0:
        ex.fail('Failed to pass unit tests')

    if not options.no_check_valgrind:
        code = ex.run_cmd(cmd, ['--valgrind'] + args)
        if code != 0:
            ex.fail('Failed to pass unit tests in valgrind environment')
Exemple #57
0
def git_remove_merge(merge_branch):
    return ex.run_cmd('git branch -D %s' % merge_branch)