Esempio n. 1
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
Esempio n. 2
0
def get_snapshot_contents(js_path, snapshot_tool):
    """ Convert the given module with the snapshot generator
        and return the resulting bytes.
    """
    wrapped_path = js_path + ".wrapped"
    snapshot_path = js_path + ".snapshot"
    module_name = os.path.splitext(os.path.basename(js_path))[0]

    with open(wrapped_path, 'w') as fwrapped, open(js_path, "r") as fmodule:
        if module_name != "iotjs":
            fwrapped.write("(function(exports, require, module, native) {\n")

        fwrapped.write(fmodule.read())

        if module_name != "iotjs":
            fwrapped.write("});\n")

    ret = subprocess.call([snapshot_tool,
                           "generate",
                           "--context", "eval",
                           "-o", snapshot_path,
                           wrapped_path])

    fs.remove(wrapped_path)
    if ret != 0:
        msg = "Failed to dump %s: - %d" % (js_path, ret)
        print("%s%s%s" % ("\033[1;31m", msg, "\033[0m"))
        fs.remove(snapshot_path)
        exit(1)

    return snapshot_path
Esempio n. 3
0
def get_snapshot_contents(js_path, snapshot_tool, literals=None):
    """ Convert the given module with the snapshot generator
        and return the resulting bytes.
    """
    wrapped_path = js_path + ".wrapped"
    snapshot_path = js_path + ".snapshot"
    module_name = os.path.splitext(os.path.basename(js_path))[0]

    with open(wrapped_path, 'w') as fwrapped, open(js_path, "r") as fmodule:
        if module_name != "iotjs":
            fwrapped.write("(function(exports, require, module, native) {\n")

        fwrapped.write(fmodule.read())

        if module_name != "iotjs":
            fwrapped.write("});\n")
    cmd = [snapshot_tool, "generate", "-o", snapshot_path]
    if literals:
        cmd.extend(["--static", "--load-literals-list-format", literals])
    ret = subprocess.call(cmd + [wrapped_path])

    fs.remove(wrapped_path)
    if ret != 0:
        if literals == None:
            msg = "Failed to dump %s: - %d" % (js_path, ret)
            print("%s%s%s" % ("\033[1;31m", msg, "\033[0m"))
            exit(1)
        else:
            print("Unable to create static snapshot from '%s'. Falling back "
                  "to normal snapshot." % js_path)

    return snapshot_path
Esempio n. 4
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'])
Esempio n. 5
0
def set_config_tizenrt(buildtype):
    exec_docker(DOCKER_ROOT_PATH, [
                'cp',
                fs.join(DOCKER_IOTJS_PATH,
                        'config/tizenrt/artik05x/configs/',
                        buildtype, 'defconfig'),
                fs.join(DOCKER_TIZENRT_OS_PATH, '.config')])
Esempio n. 6
0
def get_snapshot_contents(module_name, snapshot_generator):
    """ Convert the given module with the snapshot generator
        and return the resulting bytes.
    """
    js_path = fs.join(path.SRC_ROOT, 'js', module_name + '.js')
    wrapped_path = js_path + ".wrapped"
    snapshot_path = js_path + ".snapshot"

    with open(wrapped_path, 'w') as fwrapped, open(js_path, "r") as fmodule:
        if module_name != "iotjs":
            fwrapped.write("(function(exports, require, module) {\n")

        fwrapped.write(fmodule.read())

        if module_name != "iotjs":
            fwrapped.write("});\n")

    ret = subprocess.call([snapshot_generator,
                           "--save-snapshot-for-eval",
                           snapshot_path,
                           wrapped_path])
    if ret != 0:
        msg = "Failed to dump %s: - %d" % (js_path, ret)
        print("%s%s%s" % ("\033[1;31m", msg, "\033[0m"))
        exit(1)

    with open(snapshot_path, 'rb') as snapshot:
        code = snapshot.read()

    fs.remove(wrapped_path)
    fs.remove(snapshot_path)

    return code
Esempio n. 7
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')
Esempio n. 8
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.')
Esempio n. 9
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])
Esempio n. 10
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])
Esempio n. 11
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)
Esempio n. 12
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])
Esempio n. 13
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)
Esempio n. 14
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
Esempio n. 15
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)
Esempio n. 16
0
    def run_testset(self, testset, tests):
        Reporter.report_testset(testset)

        for test in tests:
            testfile = fs.join(path.TEST_ROOT, testset, test["name"])
            timeout = test.get("timeout", self.timeout)

            if self.skip_test(test):
                Reporter.report_skip(test["name"], test.get("reason"))
                self.results["skip"] += 1
                continue

            append_coverage_code(testfile, self.coverage)

            exitcode, output, runtime = self.run_test(testfile, timeout)
            expected_failure = test.get("expected-failure", False)

            remove_coverage_code(testfile, self.coverage)

            # Timeout happened.
            if exitcode == -1:
                Reporter.report_timeout(test["name"])
                self.results["timeout"] += 1
                continue

            # Show the output.
            if not self.quiet:
                print(output, end="")

            if not expected_failure or (expected_failure and exitcode <= 2):
                Reporter.report_pass(test["name"], runtime)
                self.results["pass"] += 1
            else:
                Reporter.report_fail(test["name"], runtime)
                self.results["fail"] += 1
Esempio n. 17
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')
Esempio n. 18
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
Esempio n. 19
0
    def __call__(self, dir_path, file):
        if file in self._allowed_files:
            return True

        if file in self._skip_files:
            return False

        _, ext = fs.splitext(file)
        return ext in self._allowed_exts
Esempio n. 20
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
Esempio n. 21
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"
Esempio n. 22
0
def merge_snapshots(snapshot_infos, snapshot_tool):
    output_path = fs.join(path.SRC_ROOT, 'js','merged.modules')
    cmd = [snapshot_tool, "merge", "-o", output_path]
    cmd.extend([item['path'] for item in snapshot_infos])

    ret = subprocess.call(cmd)

    if ret != 0:
        msg = "Failed to merge %s: - %d" % (snapshot_infos, ret)
        print("%s%s%s" % ("\033[1;31m", msg, "\033[0m"))
        exit(1)

    for item in snapshot_infos:
        fs.remove(item['path'])

    with open(output_path, 'rb') as snapshot:
        code = snapshot.read()

    fs.remove(output_path)
    return code
Esempio n. 23
0
def get_js_contents(name, is_debug_mode=False):
    """ Read the contents of the given js module. """
    js_path = fs.join(path.SRC_ROOT, 'js', name + '.js')
    with open(js_path, "r") as f:
         code = f.read()

    # minimize code when in release mode
    if not is_debug_mode:
        code = remove_comments(code)
        code = remove_whitespaces(code)
    return code
Esempio n. 24
0
def append_coverage_code(testfile, coverage):
    if not coverage:
        return

    with open(testfile, 'r') as file_p:
        content = file_p.read()

    with open(testfile, 'w') as file_p:
        file_p.write(JS_COVERAGE_CODE.format(
            folder=JS_COVERAGE_FOLDER, file=fs.basename(testfile)))
        file_p.write(content)
Esempio n. 25
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
Esempio n. 26
0
def run_checktest(options):
    # IoT.js executable
    iotjs = fs.join(options.build_root, 'bin', 'iotjs')

    cmd = []
    args = []
    if options.test_driver == "js":
        cmd = iotjs
        args = [path.CHECKTEST_PATH]
        if options.run_test == "quiet":
            args.append('quiet=yes')

        # experimental
        if options.experimental:
            args.append('experimental=yes');
    else:
        cmd = fs.join(path.TOOLS_ROOT, 'testrunner.py')
        args = [iotjs]
        if options.run_test == "quiet":
            args.append('--quiet')


    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:
        if options.test_driver == "js":
            code = ex.run_cmd('valgrind', ['--leak-check=full',
                                           '--error-exitcode=5',
                                           '--undef-value-errors=no',
                                           cmd] + args)
            if code == 5:
                ex.fail('Failed to pass valgrind test')
            if code != 0:
                ex.fail('Failed to pass unit tests in valgrind environment')
        else:
            code = ex.run_cmd(cmd, ['--valgrind'] + args)
            if code != 0:
                ex.fail('Failed to pass unit tests in valgrind environment')
Esempio n. 27
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')
Esempio n. 28
0
def get_literals_from_snapshots(snapshot_tool, snapshot_list):
    literals_path = fs.join(path.SRC_ROOT, 'js', 'literals.list')
    cmd = [snapshot_tool, "litdump", "-o", literals_path]
    cmd.extend(snapshot_list)

    ret = subprocess.call(cmd)

    if ret != 0:
        msg = "Failed to dump the literals: - %d" % ret
        print("%s%s%s" % ("\033[1;31m", msg, "\033[0m"))
        exit(1)

    return literals_path
Esempio n. 29
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 = []
Esempio n. 30
0
def job_stm32f4dis():
    start_container()

    # Copy the application files to apps/system/iotjs.
    exec_docker(DOCKER_ROOT_PATH, [
                'cp', '-r',
                fs.join(DOCKER_IOTJS_PATH,'config/nuttx/stm32f4dis/app/'),
                fs.join(DOCKER_NUTTX_APPS_PATH, 'system/iotjs/')])

    exec_docker(DOCKER_ROOT_PATH, [
                'cp', '-r',
                fs.join(DOCKER_IOTJS_PATH,
                        'config/nuttx/stm32f4dis/config.travis'),
                fs.join(DOCKER_NUTTX_PATH,
                        'configs/stm32f4discovery/usbnsh/defconfig')])

    for buildtype in BUILDTYPES:
        exec_docker(DOCKER_NUTTX_PATH, ['make', 'distclean'])
        exec_docker(DOCKER_NUTTX_TOOLS_PATH,
                    ['./configure.sh', 'stm32f4discovery/usbnsh'])
        exec_docker(DOCKER_NUTTX_PATH, ['make', 'clean'])
        exec_docker(DOCKER_NUTTX_PATH, ['make', 'context'])
        # Build IoT.js
        build_iotjs(buildtype, [
                    '--target-arch=arm',
                    '--target-os=nuttx',
                    '--nuttx-home=' + DOCKER_NUTTX_PATH,
                    '--target-board=stm32f4dis',
                    '--jerry-heaplimit=78',
                    '--profile=test/profiles/nuttx.profile'])
        # Build Nuttx
        if buildtype == "release":
            rflag = 'R=1'
        else:
            rflag = 'R=0'
        exec_docker(DOCKER_NUTTX_PATH, [
                    'make', 'all',
                    'IOTJS_ROOT_DIR=' + DOCKER_IOTJS_PATH, rflag])
Esempio n. 31
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from common_py.system.filesystem import FileSystem as fs
from common_py.system.executor import Executor as ex
from common_py.system.platform import Platform
from check_tidy import check_tidy

platform = Platform()

DOCKER_ROOT_PATH = fs.join('/root')

# IoT.js path in travis
TRAVIS_BUILD_PATH = fs.join(os.environ['TRAVIS_BUILD_DIR'])

# IoT.js path in docker
DOCKER_IOTJS_PATH = fs.join(DOCKER_ROOT_PATH, 'work_space/iotjs')

# Node server path in docker
DOCKER_NODE_SERVER_PATH = fs.join(DOCKER_ROOT_PATH, 'work_space/node_server')

DOCKER_TIZENRT_PATH = fs.join(DOCKER_ROOT_PATH, 'TizenRT')
DOCKER_TIZENRT_OS_PATH = fs.join(DOCKER_TIZENRT_PATH, 'os')
DOCKER_TIZENRT_OS_TOOLS_PATH = fs.join(DOCKER_TIZENRT_OS_PATH, 'tools')

DOCKER_NUTTX_PATH = fs.join(DOCKER_ROOT_PATH, 'nuttx')
Esempio n. 32
0
import json
import os
import signal
import subprocess
import sys
import time

from collections import OrderedDict
from common_py import path
from common_py.system.filesystem import FileSystem as fs
from common_py.system.executor import Executor as ex
from common_py.system.platform import Platform

# Defines the folder that will contain the coverage info.
# The path must be consistent with the measure_coverage.sh script.
JS_COVERAGE_FOLDER = fs.join(path.PROJECT_ROOT, '.coverage_output')

# This code should be applied to each testfile.
JS_COVERAGE_CODE = (
"""
process.on('exit', function() {{
  if (typeof __coverage__ == 'undefined')
    return;

  if (typeof fs == 'undefined')
    var fs = require('fs');

  if (!fs.existsSync('{folder}'))
    fs.mkdirSync('{folder}');

  var filename = '{folder}/{file}';
Esempio n. 33
0
def set_release_config_tizenrt():
    exec_docker(DOCKER_ROOT_PATH, [
        'cp', 'tizenrt_release_config',
        fs.join(DOCKER_TIZENRT_OS_PATH, '.config')
    ])
Esempio n. 34
0
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
        '-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)

    # --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)

    run_make(options, options.build_root)
Esempio n. 35
0
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import json

from common_py.system.filesystem import FileSystem as fs
from common_py.system.executor import Executor as ex

DOCKER_ROOT_PATH = fs.join('/root')

# IoT.js path in travis
TRAVIS_BUILD_PATH = fs.join(os.environ['TRAVIS_BUILD_DIR'])

# IoT.js path in docker
DOCKER_IOTJS_PATH = fs.join(DOCKER_ROOT_PATH, 'iotjs')

DOCKER_TIZENRT_PATH = fs.join(DOCKER_ROOT_PATH, 'TizenRT')
DOCKER_TIZENRT_OS_PATH = fs.join(DOCKER_TIZENRT_PATH, 'os')
DOCKER_TIZENRT_OS_TOOLS_PATH = fs.join(DOCKER_TIZENRT_OS_PATH, 'tools')

DOCKER_NAME = 'iotjs_docker'

BUILDTYPES = ['debug', 'release']
Esempio n. 36
0
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)
Esempio n. 37
0
def set_global_vars(option):
    global host_tuple
    host_tuple = '%s-%s' % (platform.arch(), platform.os())

    global host_build_root
    host_build_root = fs.join(path.PROJECT_ROOT, option.builddir, 'host',
                              host_tuple, option.buildtype)

    global host_build_bins
    host_build_bins = fs.join(host_build_root, 'bin')

    global target_tuple
    target_tuple = '%s-%s' % (option.target_arch, option.target_os)

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

    global build_bins
    build_bins = fs.join(build_root, 'bin')

    global build_libs
    build_libs = fs.join(build_root, 'lib')

    global build_jerry_deps
    build_jerry_deps = fs.join(build_root, 'deps', 'jerry')

    global build_jerry_deps_libs
    build_jerry_deps_libs = fs.join(build_jerry_deps, "lib")

    global libtuv_output_path
    libtuv_output_path = fs.join(build_libs, 'libtuv.a')

    global libhttpparser_output_path
    libhttpparser_output_path = fs.join(build_libs, 'libhttpparser.a')

    global jerry_output_path
    jerry_output_path = fs.join(host_build_bins, 'jerry')

    global libjerry_output_path
    libjerry_output_path = fs.join(build_libs, 'libjerrycore.a')

    global iotjs_output_path
    iotjs_output_path = fs.join(build_bins, 'iotjs')

    global libiotjs_output_path
    libiotjs_output_path = fs.join(build_libs, 'libiotjs.a')

    global libjerry_libc_output_path
    libjerry_libc_output_path = fs.join(build_jerry_deps_libs,
                                        'libjerry-libc.a')

    global libjerry_libm_output_path
    libjerry_libm_output_path = fs.join(build_jerry_deps_libs,
                                        'libjerry-libm.a')

    global cmake_toolchain_file
    cmake_toolchain_file = fs.join(path.PROJECT_ROOT, 'cmake', 'config',
                                   target_tuple + '.cmake')

    global host_cmake_toolchain_file
    host_cmake_toolchain_file = fs.join(path.PROJECT_ROOT, 'cmake', 'config',
                                        host_tuple + '.cmake')

    global platform_descriptor
    platform_descriptor = '%s-%s' % (option.target_arch, option.target_os)
Esempio n. 38
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')
Esempio n. 39
0
    return True


# Initialize build option object.
option = init_option()

adjust_option(option)

print_build_option(option)

set_global_vars(option)

# clean build directory.
if option.clean:
    print_progress('Clear build directory')
    fs.rmtree(build_root)
    fs.rmtree(host_build_root)

create_build_directories(option)

# Analyze module dependency
print_progress('Analyze module dependency')
if not analyze_module_dependency(option):
    ex.fail('Failed to analyze module dependency')

# Perform init-submodule.
print_progress('Initialize submodules')
if not option.no_init_submodule:
    init_submodule()

# make build directory.
Esempio n. 40
0
def apply_nuttx_patches(nuttx_root, use_patches=True):
    '''
    Apply memstat patches to measure the memory consumption of IoT.js.
    '''
    fs.chdir(path.PROJECT_ROOT)

    options = ['apply']
    if not use_patches:
        options.append('-R')
    else:
        ex.check_run_cmd('git', ['submodule', 'init'])
        ex.check_run_cmd('git', ['submodule', 'update'])

    patch_dir = fs.join(path.PROJECT_ROOT, 'config', 'nuttx', 'stm32f4dis')
    ex.check_run_cmd('git', options + [fs.join(patch_dir,
                                               'iotjs-memstat.diff')])
    fs.chdir(path.TUV_ROOT)
    ex.check_run_cmd('git', options + [fs.join(patch_dir,
                                               'libtuv-memstat.diff')])
    fs.chdir(path.JERRY_ROOT)
    ex.check_run_cmd('git', options + [fs.join(patch_dir,
                                               'jerry-memstat.diff')])
    fs.chdir(fs.join(nuttx_root, 'nuttx'))
    ex.check_run_cmd('git', options + [fs.join(patch_dir,
                                               'nuttx-7.19.diff')])
    fs.chdir(path.PROJECT_ROOT)
Esempio n. 41
0
def build(buildtype, args=[]):
    fs.chdir(path.PROJECT_ROOT)
    ex.check_run_cmd('./tools/build.py', ['--buildtype=' + buildtype] + args)
Esempio n. 42
0
def analyze_module_dependency(option):
    def print_warn(fmt, arg):
        print fmt % arg
        ex.fail('Failed to analyze module dependency')

    for name in option.config['module']['always']:
        if name in option.iotjs_include_module:
            print_warn('Module \"%s\" is already included', name)
        else:
            option.iotjs_include_module.append(name)

    if not option.iotjs_minimal_profile:
        for name in option.config['module']['optional']:
            if name in option.iotjs_include_module:
                print_warn('Module \"%s\" is already included', name)
            else:
                option.iotjs_include_module.append(name)

    for name in option.config['module']['exclude']:
        if name in option.iotjs_exclude_module:
            print_warn('Module \"%s\" is already excluded', name)
        else:
            option.iotjs_exclude_module.append(name)

    analyze_queue = set()
    for name in option.iotjs_include_module:
        analyze_queue.add(name)
    for name in option.iotjs_exclude_module:
        if name in option.config['module']['always']:
            print_warn('Cannot exclude mandatory module \"%s\"', name)
        else:
            if name in analyze_queue:
                analyze_queue.remove(name)
            else:
                print_warn('Cannot find module \"%s\" to exclude', name)

    js_modules = {'iotjs', 'native'}
    native_modules = {'process'}
    while len(analyze_queue) != 0:
        item = analyze_queue.pop()
        js_modules.add(item)

        content = open(fs.join(path.PROJECT_ROOT, 'src', 'js',
                               item + '.js')).read()

        re_js_module = 'require\([\'\"](.*)[\'\"]\)'
        for js_module in re.findall(re_js_module, content):
            if js_module in option.iotjs_exclude_module:
                print_warn('Cannot exclude \"%s\" since \"%s\" requires it',
                           (js_module, item))
            if js_module not in js_modules:
                analyze_queue.add(js_module)

        re_native_module = 'process.binding\(process.binding.(.*)\)'
        for native_module in re.findall(re_native_module, content):
            native_modules.add(native_module)

    js_modules.remove('native')

    option.js_modules = js_modules
    option.native_modules = native_modules

    print 'Building js modules: %s\nBuilding native modules: %s' \
          % (', '.join(js_modules), ', '.join(native_modules))
    print

    return True
Esempio n. 43
0
def js2c(buildtype, no_snapshot, js_modules, js_dumper, verbose=False):
    is_debug_mode = buildtype == "debug"
    magic_string_set = set()

    str_const_regex = re.compile('^#define IOTJS_MAGIC_STRING_\w+\s+"(\w+)"$')
    with open(fs.join(path.SRC_ROOT, 'iotjs_magic_strings.h'), 'r') as fin_h:
        for line in fin_h:
            result = str_const_regex.search(line)
            if result:
                magic_string_set.add(result.group(1))

    # generate the code for the modules
    with open(fs.join(path.SRC_ROOT, 'iotjs_js.h'), 'w') as fout_h, \
         open(fs.join(path.SRC_ROOT, 'iotjs_js.c'), 'w') as fout_c:

        fout_h.write(LICENSE)
        fout_h.write(HEADER1)
        fout_c.write(LICENSE)
        fout_c.write(HEADER2)

        for name in sorted(js_modules):
            if verbose:
                print('Processing module: %s' % name)

            if no_snapshot:
                code = get_js_contents(name, is_debug_mode)
            else:
                code = get_snapshot_contents(name, js_dumper)
                magic_string_set |= parse_literals(code)

            code_string = format_code(code, 1)

            fout_h.write(MODULE_VARIABLES_H.format(NAME=name))
            fout_c.write(
                MODULE_VARIABLES_C.format(NAME=name,
                                          NAME_UPPER=name.upper(),
                                          SIZE=len(code),
                                          CODE=code_string))

        fout_h.write(NATIVE_STRUCT_H)
        fout_h.write(FOOTER1)

        modules_struct = [
            '  {{ {0}_n, {0}_s, SIZE_{1} }},'.format(name, name.upper())
            for name in sorted(js_modules)
        ]
        modules_struct.append('  { NULL, NULL, 0 }')

        fout_c.write(NATIVE_STRUCT_C.format(MODULES="\n".join(modules_struct)))
        fout_c.write(EMPTY_LINE)

    # Write out the external magic strings
    magic_str_path = fs.join(path.SRC_ROOT, 'iotjs_string_ext.inl.h')
    with open(magic_str_path, 'w') as fout_magic_str:
        fout_magic_str.write(LICENSE)
        fout_magic_str.write(MAGIC_STRINGS_HEADER)

        sorted_strings = sorted(magic_string_set, key=lambda x: (len(x), x))
        for idx, magic_string in enumerate(sorted_strings):
            magic_text = repr(magic_string)[1:-1]

            fout_magic_str.write('  MAGICSTR_EX_DEF(MAGIC_STR_%d, "%s") \\\n' %
                                 (idx, magic_text))
        # an empty line is required to avoid compile warning
        fout_magic_str.write(EMPTY_LINE)
Esempio n. 44
0
    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')


if __name__ == '__main__':
    # Initialize build option object.
    options = init_options()
    adjust_options(options)

    if options.clean:
        print_progress('Clear build directories')
        test_build_root = fs.join(path.TEST_ROOT,
                                  'dynamicmodule',
                                  'build',
                                  options.target_os)
        fs.rmtree(test_build_root)
        fs.rmtree(options.build_root)

    # Perform init-submodule.
    if not options.no_init_submodule:
        print_progress('Initialize submodule')
        init_submodule()

    build_iotjs(options)

    Terminal.pprint("\nIoT.js Build Succeeded!!\n", Terminal.green)

    # Run tests.
    if options.run_test:
Esempio n. 45
0
 def is_checked_by_clang(self, file):
     _, ext = fs.splitext(file)
     return ext in self._extensions and file not in self._skip_files
Esempio n. 46
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'tools'))
from common_py import path
from common_py.system.executor import Executor as ex
from common_py.system.filesystem import FileSystem as fs

module_generator_dir = fs.join(path.TOOLS_ROOT, 'module_generator')
generator_script = fs.join(path.TOOLS_ROOT, 'iotjs-generate-module.py')
build_script = fs.join(path.TOOLS_ROOT, 'build.py')


def print_green(msg):
    print('\033[1;32m{}\033[00m'.format(msg))


def print_blue(msg):
    print('\033[1;34m{}\033[00m'.format(msg))


def test_c():
    test_dir = fs.join(os.path.dirname(__file__), 'test_c')
    test_c = fs.join(test_dir, 'test.c')
Esempio n. 47
0
def create_build_directories(option):
    fs.maybe_make_directory(build_root)
    fs.maybe_make_directory(build_bins)
    fs.maybe_make_directory(build_libs)
    fs.maybe_make_directory(host_build_root)
    fs.maybe_make_directory(host_build_bins)
Esempio n. 48
0
def js2c(buildtype, js_modules, snapshot_tool=None, verbose=False):
    is_debug_mode = (buildtype == "debug")
    no_snapshot = (snapshot_tool == None)
    magic_string_set = set()

    str_const_regex = re.compile('^#define IOTJS_MAGIC_STRING_\w+\s+"(\w+)"$')
    with open(fs.join(path.SRC_ROOT, 'iotjs_magic_strings.in'), 'r') as fin_h:
        for line in fin_h:
            result = str_const_regex.search(line)
            if result:
                magic_string_set.add(result.group(1))

    # generate the code for the modules
    with open(fs.join(path.SRC_ROOT, 'iotjs_js.h'), 'w') as fout_h, \
         open(fs.join(path.SRC_ROOT, 'iotjs_js.c'), 'w') as fout_c:

        fout_h.write(LICENSE)
        fout_h.write(HEADER1)
        fout_c.write(LICENSE)
        fout_c.write(HEADER2)

        snapshot_infos = []
        js_module_names = []
        for idx, module in enumerate(sorted(js_modules)):
            [name, js_path] = module.split('=', 1)
            js_module_names.append(name)
            if verbose:
                print('Processing module: %s' % name)

            if no_snapshot:
                code = get_js_contents(js_path, is_debug_mode)
                code_string = format_code(code, 1)

                fout_h.write(MODULE_VARIABLES_H.format(NAME=name))
                fout_c.write(
                    MODULE_VARIABLES_C.format(NAME=name,
                                              NAME_UPPER=name.upper(),
                                              SIZE=len(code),
                                              CODE=code_string))
            else:
                code_path = get_snapshot_contents(js_path, snapshot_tool)
                info = {'name': name, 'path': code_path, 'idx': idx}
                snapshot_infos.append(info)

                fout_h.write(MODULE_SNAPSHOT_VARIABLES_H.format(NAME=name))
                fout_c.write(
                    MODULE_SNAPSHOT_VARIABLES_C.format(NAME=name, IDX=idx))

        if no_snapshot:
            modules_struct = [
                '  {{ {0}_n, {0}_s, SIZE_{1} }},'.format(name, name.upper())
                for name in sorted(js_module_names)
            ]
            modules_struct.append('  { NULL, NULL, 0 }')
        else:
            code = merge_snapshots(snapshot_infos, snapshot_tool)
            code_string = format_code(code, 1)
            magic_string_set |= parse_literals(code)

            name = 'iotjs_js_modules'
            fout_h.write(MODULE_VARIABLES_H.format(NAME=name))
            fout_c.write(
                MODULE_VARIABLES_C.format(NAME=name,
                                          NAME_UPPER=name.upper(),
                                          SIZE=len(code),
                                          CODE=code_string))
            modules_struct = [
                '  {{ module_{0}, MODULE_{0}_IDX }},'.format(info['name'])
                for info in snapshot_infos
            ]
            modules_struct.append('  { NULL, 0 }')

        if no_snapshot:
            native_struct_h = NATIVE_STRUCT_H
        else:
            native_struct_h = NATIVE_SNAPSHOT_STRUCT_H

        fout_h.write(native_struct_h)
        fout_h.write(FOOTER1)

        fout_c.write(NATIVE_STRUCT_C.format(MODULES="\n".join(modules_struct)))
        fout_c.write(EMPTY_LINE)

    # Write out the external magic strings
    magic_str_path = fs.join(path.SRC_ROOT, 'iotjs_string_ext.inl.h')
    with open(magic_str_path, 'w') as fout_magic_str:
        fout_magic_str.write(LICENSE)
        fout_magic_str.write(MAGIC_STRINGS_HEADER)

        sorted_strings = sorted(magic_string_set, key=lambda x: (len(x), x))
        for idx, magic_string in enumerate(sorted_strings):
            magic_text = repr(magic_string)[1:-1]
            magic_text = magic_text.replace('"', '\"')

            fout_magic_str.write('  MAGICSTR_EX_DEF(MAGIC_STR_%d, "%s") \\\n' %
                                 (idx, magic_text))
        # an empty line is required to avoid compile warning
        fout_magic_str.write(EMPTY_LINE)
Esempio n. 49
0
def run_test_js(test_dir):
    # Run test.js
    print_blue('Run test.js file.')
    binary = fs.join(path.BUILD_ROOT, 'x86_64-linux', 'debug', 'bin', 'iotjs')
    test_js = fs.join(test_dir, 'test.js')
    ex.check_run_cmd_output(binary, [test_js])
Esempio n. 50
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')


if __name__ == '__main__':
    # Initialize build option object.
    options = init_options()
    adjust_options(options)

    if options.clean:
        print_progress('Clear build directory')
        fs.rmtree(options.build_root)

    # Perform init-submodule.
    if not options.no_init_submodule:
        print_progress('Initialize submodule')
        init_submodule()

    build_iotjs(options)

    print("\n%sIoT.js Build Succeeded!!%s\n" % (ex._TERM_GREEN, ex._TERM_EMPTY))

    # Run tests.
    if options.run_test:
        print_progress('Run tests')
        if options.buildlib:
            print("Skip unit tests - build target is library\n")
Esempio n. 51
0
option = parse_option()

for test in option.test:
    if test == "host":
        for buildtype in option.buildtype:
            build(buildtype)

    elif test == "rpi2":
        for buildtype in option.buildtype:
            build(buildtype, ['--target-arch=arm',
                              '--target-board=rpi2'])

    elif test == "nuttx":
        for buildtype in option.buildtype:
            nuttx_root=fs.join(path.PROJECT_ROOT, 'deps', 'nuttx')
            setup_nuttx_root(nuttx_root)
            build_nuttx(nuttx_root, buildtype)
            build(buildtype, ['--target-arch=arm',
                              '--target-os=nuttx',
                              '--nuttx-home=' + fs.join(nuttx_root, 'nuttx'),
                              '--target-board=stm32f4dis',
                              '--jerry-heaplimit=78'])
            if not build_nuttx(nuttx_root, buildtype):
                ex.fail('nuttx ' + buildtype + ' build failed')

    elif test == "misc":

        args = []
        if os.getenv('TRAVIS') != None:
            args = ['--travis']
Esempio n. 52
0
def analyze_module_dependency(option):
    def print_warn(fmt, arg):
        print(fmt % arg)
        ex.fail('Failed to analyze module dependency')

    for name in option.config['module']['always']:
        if not name in option.iotjs_include_module:
            option.iotjs_include_module.append(name)

    if not option.iotjs_minimal_profile:
        for name in option.config['module']['include']:
            if name in option.config['module']['exclude']:
                print_warn('Cannot have duplicate module \"%s\" ', name)
            if not name in option.iotjs_include_module:
                option.iotjs_include_module.append(name)

    for name in option.iotjs_exclude_module:
        if name in option.config['module']['always']:
            print_warn('Cannot exclude always module \"%s\"', name)
        if name in option.iotjs_include_module:
            option.iotjs_include_module.remove(name)

    for name in option.config['module']['exclude']:
        if (not name in option.iotjs_exclude_module
                and not name in option.iotjs_include_module):
            option.iotjs_exclude_module.append(name)

    analyze_queue = set()
    for name in option.iotjs_include_module:
        analyze_queue.add(name)

    js_modules = {'iotjs', 'native'}
    native_modules = {'process'}
    while len(analyze_queue) != 0:
        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):
            print_warn('Cannot read file \"%s\" ', js_module_path)
        content = open(js_module_path).read()

        re_js_module = 'require\([\'\"](.*?)[\'\"]\)'
        for js_module in re.findall(re_js_module, content):
            if js_module in option.iotjs_exclude_module:
                print_warn('Cannot exclude \"%s\" since \"%s\" requires it',
                           (js_module, item))
            if js_module not in js_modules:
                analyze_queue.add(js_module)

        re_native_module = 'process.binding\(process.binding.(.*?)\)'
        for native_module in re.findall(re_native_module, content):
            native_modules.add(native_module)

    js_modules.remove('native')

    option.js_modules = js_modules
    option.native_modules = native_modules

    print('Building js modules: %s\nBuilding native modules: %s\n' \
          % (', '.join(js_modules), ', '.join(native_modules)))

    return True
Esempio n. 53
0
def generate_module(args):
    directory = args.directory

    if fs.isdir(directory):
        # handle strings end with '/'
        if directory[-1] == '/':
            directory = directory[:-1]

        dirname = fs.basename(directory)
    else:
        sys.exit('Please give an existing directory.')

    if args.out_dir:
        output_dir = args.out_dir
    else:
        output_dir = fs.join(fs.join(path.TOOLS_ROOT, 'module_generator'),
                             'output')

    if not fs.isdir(output_dir):
        os.mkdir(output_dir)

    output_dir = fs.join(output_dir, dirname + '_module')

    if not fs.isdir(output_dir):
        os.mkdir(output_dir)

    src_dir = fs.join(output_dir, 'src')

    if not fs.isdir(src_dir):
        os.mkdir(src_dir)

    header_file = fs.join(src_dir, dirname + '_js_binding.h')
    header_text, api_headers = generate_header(directory)

    with open(header_file, 'w') as h:
        h.write(header_text)

    c_file = generate_c_source(header_file, api_headers, dirname, args)

    extension = 'cpp' if args.lang == 'c++' else 'c'
    with open(fs.join(src_dir, dirname + '_js_binding.' + extension), 'w') as c:
        c.write(c_file)

    library = search_for_lib(directory)

    if not library:
        print ('\033[93mWARNING: Cannot find library file. ' +
               'Only the binding layer source has generated.\033[00m')
        return

    lib_root, lib_name = library
    cmake_file = MODULE_CMAKE.format(NAME=dirname, LIBRARY=lib_name[3:-2])

    with open(fs.join(output_dir, 'module.cmake'), 'w') as cmake:
        cmake.write(cmake_file)

    fs.copyfile(fs.join(lib_root, lib_name), fs.join(output_dir, lib_name))

    json_file = MODULES_JSON.format(NAME=dirname, CMAKE='module.cmake')

    if args.lang == 'c++':
        cmake_lists = CMAKE_LISTS.format(NAME=dirname)
        with open(fs.join(src_dir, 'CMakeLists.txt'), 'w') as cmake:
            cmake.write(cmake_lists)

    with open(fs.join(output_dir, 'modules.json'), 'w') as json:
        json.write(json_file)
Esempio n. 54
0
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
Esempio n. 55
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
Esempio n. 56
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from common_py.system.filesystem import FileSystem as fs
from common_py.system.executor import Executor as ex
from common_py.system.platform import Platform
from check_tidy import check_tidy

platform = Platform()

DOCKER_ROOT_PATH = fs.join('/root')

# IoT.js path in travis
TRAVIS_BUILD_PATH = fs.join(os.environ['TRAVIS_BUILD_DIR'])

# IoT.js path in docker
DOCKER_IOTJS_PATH = fs.join(DOCKER_ROOT_PATH, 'iotjs')

DOCKER_TIZENRT_PATH = fs.join(DOCKER_ROOT_PATH, 'TizenRT')
DOCKER_TIZENRT_OS_PATH = fs.join(DOCKER_TIZENRT_PATH, 'os')
DOCKER_TIZENRT_OS_TOOLS_PATH = fs.join(DOCKER_TIZENRT_OS_PATH, 'tools')

DOCKER_NUTTX_PATH = fs.join(DOCKER_ROOT_PATH, 'nuttx')

DOCKER_NAME = 'iotjs_docker'
BUILDTYPES = ['debug', 'release']
Esempio n. 57
0
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' or option.target_os == 'tizen':
        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
Esempio n. 58
0
def printJSContents(fout_c, name, indent=0):

    global DUMPER
    global NO_SNAPSHOT
    global BUILDTYPE
    global MAGIC_STRING_SET

    js_path = fs.join(path.SRC_ROOT, 'js', name + '.js')

    if NO_SNAPSHOT is True:
        code = open(js_path, 'r').read() + '\0'

        # minimize code when release mode
        if BUILDTYPE != 'debug':
            code = removeComments(code)
            code = removeWhitespaces(code)

        for line in regroup(code, 10):
            buf = ', '.join(map(lambda ch: str(ord(ch)), line))
            if line[-1] != '\0':
                buf += ','
            writeLine(fout_c, buf, indent)

        length = len(code) - 1

    else:
        fmodule = open(js_path, 'r')
        module = fmodule.read()
        fmodule.close()

        fmodule_wrapped = open(js_path + '.wrapped', 'w')
        if name != 'iotjs':
            # fmodule_wrapped.write ("(function (a, b, c) {\n")
            fmodule_wrapped.write("(function(exports, require, module) {\n")

        fmodule_wrapped.write(module)

        if name != 'iotjs':
            fmodule_wrapped.write("});\n")
            # fmodule_wrapped.write ("wwwwrap(a, b, c); });\n")
        fmodule_wrapped.close()

        ret = subprocess.call([
            DUMPER, '--save-snapshot-for-eval', js_path + '.snapshot',
            js_path + '.wrapped'
        ])
        if ret != 0:
            msg = 'Failed to dump ' + js_path + (": - %d]" % (ret))
            print "%s%s%s" % ("\033[1;31m", msg, "\033[0m")
            exit(1)

        code = open(js_path + '.snapshot', 'r').read()

        fs.remove(js_path + '.wrapped')
        fs.remove(js_path + '.snapshot')

        for line in regroup(code, 8):
            buf = ', '.join(map(lambda ch: "0x{:02x}".format(ord(ch)), line))
            buf += ','
            writeLine(fout_c, buf, indent)

        length = len(code)

        MAGIC_STRING_SET = MAGIC_STRING_SET | parseLiterals(code)

    return length
Esempio n. 59
0
        if test == "host-linux":
            for buildtype in option.buildtype:
                build(buildtype, os_dependency_module['linux'] + build_args)

        if test == "host-darwin":
            for buildtype in option.buildtype:
                build(buildtype, os_dependency_module['darwin'] + build_args)

        elif test == "rpi2":
            for buildtype in option.buildtype:
                build(buildtype, ['--target-arch=arm', '--target-board=rpi2']
                                + os_dependency_module['linux'] + build_args)

        elif test == "artik10":
            for buildtype in option.buildtype:
                tizen_root = fs.join(path.PROJECT_ROOT, 'deps', 'tizen')
                setup_tizen_root(tizen_root)
                build(buildtype, ['--target-arch=arm',
                                '--target-os=tizen',
                                '--target-board=artik10',
                                '--compile-flag=--sysroot=' + tizen_root
                                ] + os_dependency_module['linux'] + build_args)

        elif test == "artik053":
            for buildtype in option.buildtype:
                tizenrt_root = fs.join(path.PROJECT_ROOT, 'deps', 'tizenrt')
                setup_tizenrt_repo(tizenrt_root)
                configure_trizenrt(tizenrt_root, buildtype)
                build(buildtype, ['--target-arch=arm',
                                '--target-os=tizenrt',
                                '--target-board=artik05x',
Esempio n. 60
0
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])