Beispiel #1
0
    def build(self, app, buildtype, buildoptions, maketarget):
        '''
        Build the operating system.
        '''
        app_name = app.get_name()
        if app_name == 'iotjs':
            build_options = ['IOTJS_ROOT_DIR=' + paths.IOTJS_PATH]
            build_options.append('IOTJS_BUILD_OPTION=' +
                                 ' '.join(buildoptions))

            if buildtype == 'release':
                # Override the config file for release build.
                utils.copy_file(
                    utils.join(paths.CONFIG_PATH,
                               'iotjs-tizenrt-release.config'),
                    utils.join(paths.TIZENRT_OS_PATH, '.config'))

            tizenrt_patch = utils.join(paths.PATCHES_PATH,
                                       'iotjs-tizenrt-%s.diff' % buildtype)
            utils.patch(paths.IOTJS_PATH, tizenrt_patch, False)

            utils.execute(paths.TIZENRT_OS_PATH, 'make', build_options)

            utils.patch(paths.IOTJS_PATH, tizenrt_patch, True)

        elif app_name == 'jerryscript':
            utils.execute(paths.TIZENRT_OS_PATH, 'make')
Beispiel #2
0
    def run(self):
        '''
        Main method to run IoT.js or JerryScript tests.
        '''
        if self.env['info']['no_test']:
            return

        reporter.report_configuration(self.env)

        for testset, tests in read_testsets(self.env).items():
            self.run_testset(testset, tests)

        if self.env['info']['coverage']:
            device = self.env['info']['device']
            app_name = self.env['info']['app']

            if device in ['artik053', 'artik530', 'rpi2'
                          ] and app_name == 'iotjs':
                iotjs = self.env['modules']['iotjs']
                commit_info = utils.last_commit_info(iotjs['src'])
                result_name = 'cov-%s-%s.json' % (commit_info['commit'],
                                                  commit_info['date'])
                result_dir = utils.join(paths.RESULT_PATH,
                                        '%s/%s/' % (app_name, device))
                result_path = utils.join(result_dir, result_name)

            self.coverage_info = utils.parse_coverage_info(
                self.env, result_path)

            reporter.report_coverage(self.coverage_info)

        reporter.report_final(self.results)
    def __update_status_icon(self, app_name, device_type):
        '''
        Update the status icon.
        '''
        results_web_path = TEST_RESULTS_WEB_PATH[app_name]
        if not utils.exists(results_web_path):
            return

        utils.execute(results_web_path, 'git', ['pull', 'origin', 'gh-pages'])
        status = 'passing'
        for test in self.results:
            if test['result'] == 'fail':
                status = 'failing'
                break

        current_status_icon = utils.join(results_web_path, 'status',
                                         '%s.svg' % device_type)

        if not utils.exists(current_status_icon):
            return

        with open(current_status_icon) as file:
            if status in file.read():
                return

        image = 'pass.svg' if status is 'passing' else 'fail.svg'
        copied_status_icon = utils.join(results_web_path, 'img', image)
        utils.copy_file(copied_status_icon, current_status_icon)

        utils.execute(results_web_path, 'git', ['add', current_status_icon])
        utils.execute(results_web_path, 'git',
                      ['commit', '-m', 'Update the status badge.'])
        utils.execute(results_web_path, 'git', ['push'])
Beispiel #4
0
    def _build_iotjs(self, profile, extra_flags):
        '''
        Build IoT.js for Tizen target.
        '''
        iotjs = self.env['modules']['iotjs']

        profiles = {
            'minimal': 'profiles/minimal.profile',
            'target': 'test/profiles/tizen.profile'
        }

        build_flags = [
            '--clean', '--no-parallel-build', '--no-init-submodule',
            '--target-arch=noarch', '--target-os=tizen', '--target-board=rpi3',
            '--profile=%s' % profiles[profile],
            '--buildtype=%s' % self.env['info']['buildtype']
        ] + extra_flags

        iotjs_build_options = ' '.join(build_flags)
        # Note: these values should be defined for GBS, because
        #       it will compile the IoT.js itself.
        utils.define_environment('IOTJS_BUILD_OPTION', iotjs_build_options)

        args = ['--clean']

        if self.env['info']['buildtype'] == 'debug':
            args.append('--debug')

        utils.execute(iotjs['src'], 'config/tizen/gbsbuild.sh', args)

        tizen_build_dir = utils.join(paths.GBS_IOTJS_PATH, 'build')
        iotjs_build_dir = utils.join(iotjs['src'], 'build')
        # Copy the GBS created binaries to the iotjs build folder.
        # Note: GBS compiles iotjs in the GBS folder.
        utils.copy(tizen_build_dir, iotjs_build_dir)
Beispiel #5
0
    def _copy_build_files(self, target_module, builddir):
        '''
        Copy the created binaries, libs, linker map to the build folder.
        '''
        application = self.env['modules']['app']

        linker_map = utils.join(builddir, 'linker.map')
        lib_folder = utils.join(builddir, 'libs')

        utils.copy(application['paths']['libdir'], lib_folder)
        utils.copy(target_module['paths']['linker-map'], linker_map)
        utils.copy(target_module['paths']['image'], builddir)
Beispiel #6
0
    def __apply_stack_patches(self, device, revert=False):
        '''
        Apply stack patch to measure the stack consumption of IoT.js
        '''
        if device.get_type() == 'rpi2':
            iotjs_stack_patch = utils.join(paths.PATCHES_PATH,
                                           'iotjs-stack.diff')
            utils.patch(paths.IOTJS_PATH, iotjs_stack_patch, revert)

        if device.get_type() == 'stm32f4dis':
            iotjs_stack_nuttx_patch = utils.join(paths.PATCHES_PATH,
                                                 'iotjs-stack-nuttx.diff')
            utils.patch(paths.IOTJS_PATH, iotjs_stack_nuttx_patch, revert)
Beispiel #7
0
    def flash(self, app):
        '''
        Send the application and the testsuite to the device with SFTP.
        '''
        lpath_app = app.get_image()
        lpath_app_stack = app.get_image_stack()
        lpath_testsuite = utils.make_archive(app.get_test_dir(), 'tar')

        rpath_app = utils.join(self.remote_path, app.get_cmd())
        rpath_app_stack = utils.join(self.remote_path, app.get_cmd_stack())
        rpath_testsuite = utils.join(self.remote_path, 'test.tar')

        # Freya cross build.
        utils.copy_file(utils.join(paths.TOOLS_PATH, 'freya-cross-build.sh'),
                        paths.FREYA_PATH)
        utils.execute(paths.FREYA_PATH, './freya-cross-build.sh')

        freya_dir = utils.join(paths.FREYA_PATH, 'valgrind_freya')
        lpath_freya = utils.make_archive(freya_dir, 'tar')
        rpath_freya = utils.join(self.remote_path, 'valgrind_freya.tar')

        lpath_resources = utils.make_archive(paths.RESOURCES_PATH, 'tar')
        rpath_resources = utils.join(self.remote_path, 'resources.tar')

        self.ssh.open()

        # Clean up in the remote folder.
        self.ssh.exec_command('rm -f ' + rpath_app)
        self.ssh.exec_command('rm -f ' + rpath_testsuite)
        self.ssh.exec_command('rm -f ' + rpath_freya)
        self.ssh.exec_command('rm -f ' + rpath_resources)
        self.ssh.exec_command('rm -rf ' + self.get_test_path())

        # Send the application, the testsuite, the valgrind and the resource files.
        self.ssh.send_file(lpath_app, rpath_app)
        self.ssh.send_file(lpath_testsuite, rpath_testsuite)
        self.ssh.send_file(lpath_freya, rpath_freya)
        self.ssh.send_file(lpath_resources, rpath_resources)

        # Let the iotjs to be runnable and extract the tests and valgrind files.
        self.ssh.exec_command('chmod 770 ' + rpath_app)
        self.ssh.exec_command('mkdir ' + self.get_test_path())
        self.ssh.exec_command('mkdir ' +
                              utils.join(self.remote_path, 'valgrind_freya'))
        self.ssh.exec_command('tar -xmf ' + rpath_testsuite + ' -C ' +
                              self.get_test_path())
        self.ssh.exec_command('tar -xmf ' + rpath_freya + ' -C ' +
                              utils.join(self.remote_path, 'valgrind_freya'))
        self.ssh.exec_command('tar -xmf ' + rpath_resources + ' -C ' +
                              self.remote_path)

        # Note: stack measurement is only supported for iotjs.
        if app.get_name() == 'iotjs':
            self.ssh.exec_command('rm -f ' + rpath_app_stack)
            self.ssh.send_file(lpath_app_stack, rpath_app_stack)
            self.ssh.exec_command('chmod 770 ' + rpath_app_stack)
Beispiel #8
0
    def get_romfs_file(self):
        '''
        Return the path of the generated ROMFS image.
        '''
        utils.generate_romfs(paths.IOTJS_PATH, paths.IOTJS_TEST_PATH)

        return utils.join(paths.IOTJS_PATH, 'nsh_romfsimg.h')
Beispiel #9
0
    def save(self):
        '''
        Save the current testresults into JSON format.
        '''
        if self.env['info']['no_test']:
            return

        build_file = self.env['paths']['build-json']
        build_info = utils.read_json_file(build_file)

        # Add the build information.
        test_info = {
            'date': build_info['last-commit-date'],
            'bin': build_info['bin'],
            'submodules': build_info['submodules']
        }

        # Specify a date named results file.
        result_dir = self.env['paths']['result']
        filename = utils.join(result_dir, build_info['build-date'])

        if self.env['info']['coverage']:
            # Add the coverage information.
            test_info['coverage_info'] = self.coverage_info
            filename += '_coverage'
        else:
            # Add the test results.
            test_info['tests'] = self.results

        # Save the results into the date named file.
        utils.write_json_file(filename + '.json', test_info)

        # Publish the results if necessary.
        utils.upload_data_to_firebase(self.env, test_info)
Beispiel #10
0
 def __apply_patches(self, app):
     '''
     Apply patch file.
     '''
     patch = utils.join(paths.PATCHES_PATH,
                        'tizenrt-%s.diff' % app.get_name())
     utils.execute(paths.TIZENRT_PATH, 'git', ['reset', '--hard'])
     utils.execute(paths.TIZENRT_PATH, 'git', ['apply', patch])
Beispiel #11
0
    def install_dependencies(self):
        '''
        Install dependencies of the board.
        '''
        if utils.exists(utils.join(paths.STLINK_BUILD_PATH, 'st-flash')):
            return

        utils.execute(paths.STLINK_PATH, 'make', ['release'])
Beispiel #12
0
    def __configure(self, app):
        '''
        Configuring TizenRT.
        '''

        # FIXME: now it supports artik053 device only
        configure_name = utils.join('artik053', app.get_name())
        utils.execute(paths.TIZENRT_TOOLS_PATH, './configure.sh',
                      [configure_name])
Beispiel #13
0
    def __apply_heap_patches(self, device, revert=False):
        '''
        Apply memstat patches to measure the memory consumption of IoT.js
        '''
        if device.get_type() in ['stm32f4dis', 'artik053']:
            iotjs_memstat_patch = utils.join(paths.PATCHES_PATH,
                                             'iotjs-memstat.diff')
            utils.patch(paths.IOTJS_PATH, iotjs_memstat_patch, revert)

            libtuv_memstat_patch = utils.join(paths.PATCHES_PATH,
                                              'libtuv-memstat.diff')
            utils.patch(paths.IOTJS_LIBTUV_PATH, libtuv_memstat_patch, revert)
            utils.execute(paths.IOTJS_LIBTUV_PATH, 'git', ['add', '-u'])

        jerry_memstat_patch = utils.join(paths.PATCHES_PATH,
                                         'jerry-memstat.diff')
        utils.patch(paths.IOTJS_JERRY_PATH, jerry_memstat_patch, revert)
        utils.execute(paths.IOTJS_JERRY_PATH, 'git', ['add', '-u'])
Beispiel #14
0
    def _build_freya(self):
        '''
        Cross-compile Valgrind and its Freya tool.
        '''
        build_dir = utils.join(self.env['paths']['build'], 'valgrind_freya')
        valgrind_files = [
            'vg-in-place',
            'coregrind/valgrind',
            '.in_place/freya-arm-linux',
            '.in_place/vgpreload_core-arm-linux.so',
            '.in_place/vgpreload_freya-arm-linux.so'
        ]

        # Check if a Freya build already exists, if yes, skip the build.
        if utils.exist_files(build_dir, valgrind_files):
            return

        freya = self.env['modules']['freya']

        utils.define_environment('LD', 'arm-linux-gnueabihf-ld')
        utils.define_environment('AR', 'arm-linux-gnueabihf-ar')
        utils.define_environment('CC', 'arm-linux-gnueabihf-gcc')
        utils.define_environment('CPP', 'arm-linux-gnueabihf-cpp')
        utils.define_environment('CXX', 'arm-linux-gnueabihf-g++')

        configure_options = ['--host=armv7-linux-gnueabihf']

        utils.execute(freya['src'], './autogen.sh')
        utils.execute(freya['src'], './configure', configure_options)
        utils.execute(freya['src'], 'make', ['clean'])
        utils.execute(freya['src'], 'make', ['TOOLS=freya'])

        utils.unset_environment('LD')
        utils.unset_environment('AR')
        utils.unset_environment('CC')
        utils.unset_environment('CPP')
        utils.unset_environment('CXX')

        # Copy necessary files into the output directory.
        for valgrind_file in valgrind_files:
            src = utils.join(freya['src'], valgrind_file)
            dst = utils.join(build_dir, valgrind_file)

            utils.copy(src, dst)
Beispiel #15
0
    def __copy_app_files(self, app):
        '''
        Copy application files into the NuttX apps.
        '''
        utils.copy_files(app.get_home_dir(), app.get_install_dir())

        # Override the default romfs image file.
        utils.copy_file(
            app.get_romfs_file(),
            utils.join(paths.NUTTX_APPS_NSHLIB_PATH, 'nsh_romfsimg.h'))
Beispiel #16
0
    def __configure(self, app):
        '''
        Configuring NuttX.
        '''
        utils.execute(paths.NUTTX_TOOLS_PATH, './configure.sh',
                      ['stm32f4discovery/netnsh'])

        # Override the default config file with a prepared one.
        utils.copy_file(app.get_config_file(),
                        utils.join(paths.NUTTX_PATH, '.config'))
Beispiel #17
0
    def initialize(self):
        '''
        Flash the device.
        '''
        if self.env['info']['no_flash']:
            return

        target_app = self.env['modules']['app']
        build_path = self.env['paths']['build']

        test_src = target_app['paths']['tests']
        test_dst = utils.join(build_path, 'tests')

        # 1. Copy all the necessary files.
        # Copy applicaiton RPM package file.
        rpm_package_path = self.env['paths']['tizen-rpm-package']
        utils.copy(rpm_package_path, build_path)

        # Copy all the tests into the build folder.
        utils.copy(test_src, test_dst)

        utils.copy(paths.FREYA_TESTER, build_path)

        if not self.env['info']['no_memstat']:
            utils.copy(paths.FREYA_CONFIG, build_path)

            # Resolve the iotjs-dirname macro in the Freya configuration file.
            basename = utils.basename(paths.GBS_IOTJS_PATH)
            sed_flags = [
                '-i',
                's/%%{iotjs-dirname}/%s/g' % basename, 'iotjs-freya.config'
            ]
            utils.execute(build_path, 'sed', sed_flags)

        # 2. Deploy the build folder to the device.
        self.login()
        self.channel.exec_command('mount -o remount,rw /')

        shell_flags = 'ssh -p %s' % self.port
        rsync_flags = [
            '--rsh', shell_flags, '--recursive', '--compress', '--delete'
        ]
        # Note: slash character is required after the path.
        # In this case `rsync` copies the whole folder, not
        # the subcontents to the destination.
        src = self.env['paths']['build'] + '/'
        dst = '%s@%s:%s' % (self.user, self.ip, self.workdir)

        utils.execute('.', 'rsync', rsync_flags + [src, dst])

        # 3. Install rpm package
        template = 'rpm -ivh --force --nodeps %s/%s-1.0.0-0.armv7l.rpm'
        self.channel.exec_command(template % (self.workdir, self.app))

        self.logout()
Beispiel #18
0
    def read_testsets(self, device):
        '''
        Read all the tests
        '''

        # Read testsets
        testsets_file = utils.join(paths.IOTJS_TEST_PATH, 'testsets.json')
        testsets = {}

        with open(testsets_file, 'r') as testsets_p:
            testsets = json.load(testsets_p)

        # Read skip file
        skip_file = utils.join(paths.PROJECT_ROOT,
                               'API/testrunner/iotjs-skiplist.json')
        skip_list = self.get_skiplist(skip_file)
        skip_tests = skip_list[device.get_type()]['testfiles']
        skip_testsets = skip_list[device.get_type()]['testsets']

        os = device.get_os()
        os_name = os.get_name()

        # Update testset
        for testset in testsets:
            skip_testset = self.__in_dictlist('name', testset, skip_testsets)

            if skip_testset:
                for test in testsets[testset]:
                    self.__add_test_to_skip(os_name, test,
                                            skip_testset['reason'])

            else:
                for skip_test in skip_tests:
                    target_test = self.__in_dictlist('name', skip_test['name'],
                                                     testsets[testset])

                    if target_test:
                        self.__add_test_to_skip(os_name, target_test,
                                                skip_test['reason'])

        return testsets
Beispiel #19
0
    def __copy_app_files(self, app):
        '''
        Copy application files into the NuttX apps.
        '''
        app_name = app.get_name()
        if app_name == 'jerryscript':
            # FIXME: now it supports artik053 device only
            app_config_dir = utils.join(
                paths.JERRY_TARGETS_PATH,
                '%s-%s' % (self.get_name(), 'artik053'))

            app_path = utils.join(app_config_dir, 'apps/jerryscript/')
            app_config_path = utils.join(app_config_dir,
                                         'configs/jerryscript/')

            tizenrt_app_path = utils.join(paths.TIZENRT_APP_SYSTEM_PATH,
                                          app_name)
            utils.copy_files(app_path, tizenrt_app_path)
            rt_config_path = utils.join(paths.TIZENRT_CONFIGS_PATH, 'artik053',
                                        app_name)
            utils.copy_files(app_config_path, rt_config_path)
Beispiel #20
0
    def _read_skiplist(self):
        '''
        Read the local skiplists.
        '''
        skiplists = {
            'iotjs': 'iotjs-skiplist.json',
            'jerryscript': 'jerryscript-skiplist.json'
        }

        skipfile = utils.join(paths.TESTRUNNER_PATH, skiplists[self.app])
        skiplist = utils.read_json_file(skipfile)

        return skiplist[self.device_type]
Beispiel #21
0
    def execute(self, app, args=[]):
        '''
        Run commands for the given app on the board.
        '''
        cmd = app.get_cmd()
        cmd_stack = app.get_cmd_stack()

        # Heap measurement
        command_template = 'python {root}/tester.py --cwd {cwd} --cmd {app} --testfile {file}'

        command = command_template.format(root=self.remote_path,
                                          cwd=self.get_test_path(),
                                          app=utils.join(
                                              self.remote_path, cmd),
                                          file=''.join(args))

        stdout = self.ssh.exec_command(command)

        # Since the stdout is a JSON text, parse it.
        result = json.loads(stdout)

        # Make HTML friendly stdout.
        result['output'] = result['output'].rstrip('\n').replace('\n', '<br>')
        result['stack_peak'] = 'n/a'

        # Note: stack measurement is only supported for iotjs.
        if app.get_name() == 'iotjs':
            # Stack usage measurement
            command = command_template.format(root=self.remote_path,
                                              cwd=self.get_test_path(),
                                              app=utils.join(
                                                  self.remote_path, cmd_stack),
                                              file=''.join(args))

            stdout_stack = self.ssh.exec_command(command)
            result_stack = json.loads(stdout_stack)
            result['stack_peak'] = result_stack['stack']

        return result
Beispiel #22
0
    def __run_test_on_device(self, app, device, testset, test):
        '''
        Execute the current test on the device.
        '''
        testfile = utils.join(device.get_test_path(), testset, test['name'])

        if device.get_type() in ['stm32f4dis', 'artik053']:
            if app.get_name() is "jerryscript":
                return device.execute(
                    app, [testfile, '--mem-stats', '--log-level 2'])
            elif app.get_name() is "iotjs":
                return device.execute(app, ['--memstat', testfile])

        return device.execute(app, [testfile])
Beispiel #23
0
    def initialize(self):
        '''
        Flash the device.
        '''
        if self.env['info']['no_flash']:
            return

        # 1. Copy all the necessary files.
        target_app = self.env['modules']['app']
        build_path = self.env['paths']['build']

        test_src = target_app['paths']['tests']
        test_dst = utils.join(build_path, 'tests')

        # Copy all the tests into the build folder.
        utils.copy(test_src, test_dst)

        utils.copy(paths.FREYA_TESTER, build_path)

        if not self.env['info']['no_memstat']:
            # Copy Freya memory measurement files.
            utils.copy(paths.FREYA_CONFIG, build_path)

            # Resolve the iotjs-dirname macro in the Freya configuration file.
            basename = utils.basename(target_app['src'])
            sed_flags = [
                '-i',
                's/%%{iotjs-dirname}/%s/g' % basename, 'iotjs-freya.config'
            ]
            utils.execute(build_path, 'sed', sed_flags)

        # 2. Deploy the build folder to the device.
        shell_flags = 'ssh -p %s' % self.port
        rsync_flags = [
            '--rsh', shell_flags, '--recursive', '--compress', '--delete'
        ]
        # Note: slash character is required after the path.
        # In this case `rsync` copies the whole folder, not
        # the subcontents to the destination.
        src = self.env['paths']['build'] + '/'
        dst = '%s@%s:%s' % (self.user, self.ip, self.workdir)

        utils.execute('.', 'rsync', rsync_flags + [src, dst])
Beispiel #24
0
    def __save(self, app, device, is_publish):
        '''
        Save the testresults.
        '''

        os = device.get_os()
        device_type = device.get_type()

        # Create submodule information.
        submodules = {
            app.get_name(): utils.last_commit_info(app.get_home_dir()),
            os.get_name(): utils.last_commit_info(os.get_home_dir())
        }

        if os.get_name() is 'nuttx':
            submodules['apps'] = utils.last_commit_info(paths.NUTTX_APPS_PATH)

        # Create the result.
        bin_sizes = {}
        if app.get_name() == 'iotjs':
            target_profile_mapfile = app.get_target_profile_mapfile()
            minimal_profile_mapfile = app.get_minimal_profile_mapfile()

            target_bin_sizes = utils.get_section_sizes_from_map(
                target_profile_mapfile)
            minimal_bin_sizes = utils.get_section_sizes_from_map(
                minimal_profile_mapfile)

            bin_sizes = {
                'target_profile': target_bin_sizes,
                'minimal_profile': minimal_bin_sizes
            }

        else:
            bin_sizes = utils.get_section_sizes(app.get_minimal_image())

        result = {
            'bin': bin_sizes,
            'date': utils.get_standardized_date(),
            'tests': self.results,
            'submodules': submodules
        }

        device_dir = "stm32" if device_type == "stm32f4dis" else device_type

        # Save the results into a JSON file.

        result_dir = utils.join(paths.OUTPUT_PATH, app.get_name(), device_dir)

        if not utils.exists(result_dir):
            utils.mkdir(result_dir)

        result_file_name = result['date'] + '.json'
        result_file_name = result_file_name.replace(':', '.')
        result_file_path = utils.join(result_dir, result_file_name)

        utils.write_json_file(result_file_path, result)

        # Do not share the results if it not public.
        if not is_publish:
            return

        # Publish results to firebase

        user = utils.get_environment('FIREBASE_USER')
        pwd = utils.get_environment('FIREBASE_PWD')

        if not (pwd and user):
            return

        config = {
            "apiKey": "AIzaSyDMgyPr0V49Rdf5ODAU9nLY02ZGEUNoxiM",
            "authDomain": "remote-testrunner.firebaseapp.com",
            "databaseURL": "https://remote-testrunner.firebaseio.com",
            "storageBucket": "remote-testrunner.appspot.com",
        }

        firebase = pyrebase.initialize_app(config)
        auth = firebase.auth()
        db = firebase.database()

        user = auth.sign_in_with_email_and_password(user, pwd)

        with open(result_file_path) as result_file:
            result_data = json.load(result_file)
            db.child(app.get_name() + '/' + device_dir).push(
                result_data, user['idToken'])

            # Update the status icon after upload was successful.
            self.__update_status_icon(app.get_name(), device.get_type())
Beispiel #25
0
 def get_image(self):
     '''
     Return the path to the target application.
     '''
     return utils.join(paths.TIZENRT_BIN_PATH, 'tinyara.bin')
Beispiel #26
0
 def get_config_file(self):
     '''
     Return the path to OS configuration file.
     '''
     return utils.join(paths.CONFIG_PATH, 'iotjs.config')
Beispiel #27
0
 def get_install_dir(self):
     '''
     Return the path to where the application files should be copied.
     '''
     return utils.join(paths.NUTTX_APPS_SYSTEM_PATH, 'iotjs')
Beispiel #28
0
 def get_image_stack(self):
     '''
     Return the path to the stack binary.
     '''
     return utils.join(paths.IOTJS_BUILD_STACK_PATH,
                       'iotjs') % self.buildtype
Beispiel #29
0
    def build(self, device):
        '''
        Build IoT.js for the target device/OS and for Raspberry Pi 2.
        '''

        # prebuild the OS
        os = device.get_os()
        os.prebuild(self)

        utils.rmtree(paths.IOTJS_MAP_DIR_PATH)
        utils.mkdir(paths.IOTJS_MAP_DIR_PATH)

        build_flags = [
            '--clean',
            '--buildtype=%s' % self.buildtype,
            '--target-arch=arm',
            '--target-os=%s' % os.get_name(),
        ]

        # Step 1: Set the appropriate build flags for the targets.
        if device.get_type() == 'stm32f4dis':
            build_flags.append('--target-board=%s' % device.get_type())
            build_flags.append('--jerry-heaplimit=56')
            build_flags.append('--no-parallel-build')
            build_flags.append('--nuttx-home=%s' % paths.NUTTX_PATH)

            profile = utils.join(paths.IOTJS_TEST_PROFILES_PATH,
                                 'nuttx.profile')
            mapfile = utils.join(paths.NUTTX_PATH, "arch/arm/src/nuttx.map")

        elif device.get_type() == 'rpi2':
            build_flags.append('--target-board=%s' % device.get_type())

            profile = utils.join(paths.IOTJS_TEST_PROFILES_PATH,
                                 'rpi2-linux.profile')
            mapfile = utils.join(paths.IOTJS_BUILD_PATH % self.buildtype,
                                 "../iotjs.map")

        elif device.get_type() == 'artik053':
            profile = utils.join(paths.IOTJS_TEST_PROFILES_PATH,
                                 'tizenrt.profile')
            mapfile = utils.join(paths.TIZENRT_BUILD_PATH,
                                 "output/bin/tinyara.map")

        else:
            console.fail('Non-minimal IoT.js build failed, unsupported '
                         'device (%s)!' % device.get_type())

        # Step 2: Create minimal profile build for the binary size measurement.
        build_flags.append('--profile=%s' % paths.IOTJS_MINIMAL_PROFILE_PATH)

        # Note: IoT.js is built by TizenRT in case of artik053.
        if device.get_type() in ['stm32f4dis', 'rpi2']:
            utils.execute(paths.IOTJS_PATH, 'tools/build.py', build_flags)

        os.build(self, self.buildtype, build_flags, 'all')
        utils.copy_file(mapfile, paths.IOTJS_MINIMAL_MAP_FILE_PATH)

        # Step 3: Create target specific profile build for the binary size measurement.
        os.prebuild(self)

        build_flags = build_flags[:-1]
        build_flags.append('--profile=%s' % profile)

        if device.get_type() in ['stm32f4dis', 'rpi2']:
            utils.execute(paths.IOTJS_PATH, 'tools/build.py', build_flags)

        os.build(self, self.buildtype, build_flags, 'all')
        utils.copy_file(mapfile, paths.IOTJS_TARGET_MAP_FILE_PATH)

        # Step 4: Create target specific profile with patches for the tests.
        self.__apply_heap_patches(device)

        if device.get_type() in ['stm32f4dis', 'artik053']:
            self.__apply_stack_patches(device)

        os.prebuild(self)

        build_flags_heap = list(build_flags)
        build_flags_heap.append('--jerry-memstat')
        if device.get_type() == 'rpi2':
            build_flags_heap.append('--compile-flag=-g')
            build_flags_heap.append('--jerry-compile-flag=-g')

        if device.get_type() in ['stm32f4dis', 'rpi2']:
            utils.execute(paths.IOTJS_PATH, 'tools/build.py', build_flags_heap)

        os.build(self, self.buildtype, build_flags_heap, 'all')

        # Revert all the memstat patches from the project.
        self.__apply_heap_patches(device, revert=True)

        # Build the application to stack consumption check
        if device.get_type() == 'rpi2':
            self.__apply_stack_patches(device)
            build_flags.append('--builddir=%s' % paths.IOTJS_BUILD_STACK_DIR)
            utils.execute(paths.IOTJS_PATH, 'tools/build.py', build_flags)

        self.__apply_stack_patches(device, revert=True)
Beispiel #30
0
 def get_image(self):
     '''
     Return the path to the image file.
     '''
     return utils.join(paths.NUTTX_PATH, 'nuttx.bin')