def _build_jerryscript(self, profile, extra_flags): ''' Build JerryScript for NuttX target. ''' nuttx = self.env['modules']['nuttx'] jerry = self.env['modules']['jerryscript'] profiles = { 'minimal': jerry['paths']['minimal-profile'], 'target': jerry['paths']['es2015-subset-profile'] } build_flags = [ '--clean', '--lto=OFF', '--jerry-cmdline=OFF', '--jerry-libc=OFF', '--jerry-libm=ON', '--all-in-one=OFF', '--mem-heap=70', '--profile=%s' % profiles[profile], '--toolchain=%s' % jerry['paths']['stm32f4dis-toolchain'], '--compile-flag=-I%s' % jerry['paths']['stm32f4dis-target'], '--compile-flag=-isystem %s' % nuttx['paths']['include'] ] + extra_flags # NuttX requires the path of the used JerryScript folder. utils.define_environment('JERRYSCRIPT_ROOT_DIR', jerry['src']) utils.execute(jerry['src'], 'tools/build.py', build_flags)
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)
def _build_iotjs(self, profile, extra_flags): ''' Build IoT.js for NuttX target. ''' iotjs = self.env['modules']['iotjs'] nuttx = self.env['modules']['nuttx'] profiles = { 'minimal': iotjs['paths']['minimal-profile'], 'target': iotjs['paths']['nuttx-profile'] } build_flags = [ '--clean', '--no-parallel-build', '--no-init-submodule', '--target-arch=arm', '--target-os=nuttx', '--target-board=stm32f4dis', '--jerry-heaplimit=64', '--profile=%s' % profiles[profile], '--buildtype=%s' % self.env['info']['buildtype'], '--nuttx-home=%s' % nuttx['src'] ] + extra_flags # NuttX requires the path of the used IoT.js folder. utils.define_environment('IOTJS_ROOT_DIR', iotjs['src']) utils.execute(iotjs['src'], 'tools/build.py', build_flags)
def _build_jerryscript(self, profile, extra_flags): ''' Build JerryScript for TizenRT target. ''' tizenrt = self.env['modules']['tizenrt'] jerry = self.env['modules']['jerryscript'] profiles = { 'minimal': jerry['paths']['minimal-profile'], 'target': jerry['paths']['es2015-subset-profile'] } build_flags = [ '--clean', '--lto=OFF', '--jerry-cmdline=OFF', '--jerry-libc=OFF', '--jerry-libm=ON', '--all-in-one=OFF', '--mem-heap=70', '--profile=%s' % profiles[profile], '--toolchain=%s' % jerry['paths']['artik053-toolchain'], '--compile-flag=-isystem %s' % tizenrt['paths']['include'] ] + extra_flags if self.env['info']['buildtype'] == 'debug': build_flags.append('--debug') # TizenRT requires the path of the used JerryScript folder. utils.define_environment('JERRYSCRIPT_ROOT_DIR', jerry['src']) utils.execute(jerry['src'], 'tools/build.py', build_flags)
def mount_fs_writable(**params): ''' Remount the file system as writable. ''' addr = params['args'][0] port = params['args'][1] utils.execute('.', 'ssh', [addr, '-p %s' % port, 'mount -o remount,rw /'])
def reset(self): ''' Reset the device to create clean environment. ''' flasher = self.stlink['paths']['st-flash'] utils.execute('.', flasher, ['reset'], quiet=True) # Wait a moment to boot the device. time.sleep(5)
def reset(self): ''' Reset the device to create clean environment. ''' flags = ['download', 'reset'] utils.execute(self.tizenrt['paths']['os'], 'make', flags, quiet=True) # Wait a moment to boot the device. time.sleep(2)
def initialize(self): ''' Flash the device. ''' if self.env['info']['no_flash']: return tizenrt = self.env['modules']['tizenrt'] utils.execute(tizenrt['paths']['os'], 'make', ['download', 'ALL'])
def init_freya_config(**params): ''' Resolve the %{iotjs-dirname} symbol in the Freya configuration file. ''' iotjs_src = params['args'][0] build_dir = params['args'][1] pattern = 's/%%{iotjs-dirname}/%s/g' % utils.basename(iotjs_src) utils.execute(build_dir, 'sed', ['-i', pattern, 'iotjs-freya.config'])
def _build_tizenrt(self): ''' Build the TizenRT operating system. ''' tizenrt = self.env['modules']['tizenrt'] # Provide test files as ROMFS content. self._append_testfiles() utils.execute(tizenrt['paths']['os'], 'make', ['-j1'])
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()
def _build_stlink(self): ''' Build the ST-Link flasher tool. ''' stlink = self.env['modules']['stlink'] # Do not build if not necessary. if utils.exists(stlink['paths']['st-flash']): return utils.execute(stlink['src'], 'make', ['release'])
def __init__(self, environment): self.env = environment self.device = devices.create_device(environment) self.results = [] self.coverage_info = {} # Flash the device to be able to run the tests. self.device.initialize() self.skiplist = Skiplist(environment, self.device) utils.execute('.', 'mosquitto', ['-d'])
def reset(self): ''' Reset the device to create clean environment. ''' if self.env.options.emulate: return utils.execute(self.stlink.src, 'build/Release/st-flash', ['reset'], quiet=True) # Wait a moment to boot the device. time.sleep(5)
def reset(self): ''' Reset the device to create clean environment. ''' if self.env.options.emulate: return utils.execute(self.tizenrt.paths.os, 'make', ['download', 'reset'], quiet=True) # Wait a moment to boot the device. time.sleep(2)
def initialize(self): ''' Flash the device. ''' if self.env['info']['no_flash']: return stlink = self.env['modules']['stlink'] nuttx = self.env['modules']['nuttx'] flash_flags = ['write', nuttx['paths']['image'], '0x8000000'] utils.execute(stlink['src'], 'build/Release/st-flash', flash_flags)
def _build_nuttx(self): ''' Build the NuttX Operating System. ''' nuttx = self.env['modules']['nuttx'] buildtype = self.env['info']['buildtype'] utils.define_environment('R', int(buildtype == 'release')) utils.define_environment('EXTRA_LIBS', '-Map=nuttx.map') # Provide test files as ROMFS content. self._append_testfiles() utils.execute(nuttx['src'], 'make', ['-j1'])
def __init__(self, environment): self.env = environment # Do not initialize the members if testing is not enabled. if environment.options.no_test: return self.device = devices.create_device(environment) self.results = [] self.coverage_info = {} # Flash the device to be able to run the tests. self.skiplist = Skiplist(environment, self.device) utils.execute('.', 'mosquitto', ['-d'])
def _prebuild_nuttx(self): ''' Clean NuttX and configure it for serial communication. ''' nuttx = self.env['modules']['nuttx'] config = ['stm32f4discovery/usbnsh'] utils.execute(nuttx['src'], 'make', ['distclean']) utils.execute(nuttx['paths']['tools'], './configure.sh', config) utils.execute(nuttx['src'], 'make', ['clean']) utils.execute(nuttx['src'], 'make', ['context'])
def _prebuild_tizenrt(self): ''' Clean TizenRT and configure it for the appropriate application. ''' tizenrt = self.env['modules']['tizenrt'] config = 'artik053/%s' % self.env['info']['app'] utils.execute(tizenrt['paths']['os'], 'make', ['distclean']) utils.execute(tizenrt['paths']['tools'], './configure.sh', [config]) utils.execute(tizenrt['paths']['os'], 'make', ['clean']) utils.execute(tizenrt['paths']['os'], 'make', ['context'])
def _build_jerryscript(self, profile, extra_flags): ''' Build JerryScript for Linux target. ''' jerry = self.env['modules']['jerryscript'] profiles = { 'minimal': jerry['paths']['minimal-profile'], 'target': jerry['paths']['es2015-subset-profile'] } build_flags = [ '--clean', '--lto=OFF', '--jerry-libc=ON', '--jerry-libm=ON', '--all-in-one=OFF', '--linker-flag=-Wl,-Map=jerry.map', '--toolchain=%s' % jerry['paths']['rpi2-toolchain'], '--profile=%s' % profiles[profile] ] + extra_flags utils.execute(jerry['src'], 'tools/build.py', build_flags)
def _build_iotjs(self, profile, extra_flags): ''' Build IoT.js for Linux target. ''' iotjs = self.env['modules']['iotjs'] profiles = { 'minimal': iotjs['paths']['minimal-profile'], 'target': iotjs['paths']['rpi2-profile'] } build_flags = [ '--clean', '--no-parallel-build', '--no-init-submodule', '--target-arch=arm', '--target-os=linux', '--target-board=rpi2', '--profile=%s' % profiles[profile], '--buildtype=%s' % self.env['info']['buildtype'] ] + extra_flags utils.execute(iotjs['src'], 'tools/build.py', build_flags)
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])
def run_coverage_script(env): ''' Start the client script. ''' # Add latency because the start up of the debug server needs time. time.sleep(2) address = env['info']['coverage'] iotjs = env['modules']['iotjs'] coverage_client = iotjs['paths']['coverage-client'] device = env['info']['device'] app_name = env['info']['app'] 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) utils.mkdir(result_dir) utils.execute(paths.PROJECT_ROOT, coverage_client, ['--non-interactive', '--coverage-output=%s' % result_path, address])
def run_coverage_script(env): ''' Start the client script. ''' # Add latency because the start up of the debug server needs time. time.sleep(2) address = env.options.debugger iotjs = env.modules.iotjs coverage_client = iotjs.paths['coverage-client'] device = env.options.device app_name = env.options.app 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) utils.mkdir(result_dir) utils.execute(paths.PROJECT_ROOT, 'python', [coverage_client, '--coverage-output', result_path, address])
def read_objects_from_libs(libpath, liblist): ''' Read all the names of the object files that are located in the archive files. ''' objlist = [] for lib_file in os.listdir(libpath): if lib_file not in liblist: continue output, _ = utils.execute(libpath, 'ar', ['t', lib_file], quiet=True) objlist.extend(output.splitlines()) return objlist
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)
def generate_romfs(src, dst): ''' Create a romfs_img from the source directory that is converted to a header (byte array) file. Finally, add a `const` modifier to the byte array to be the data in the Read Only Memory. ''' romfs_img = utils.join(os.curdir, 'romfs_img') utils.execute(os.curdir, 'genromfs', ['-f', romfs_img, '-d', src]) utils.execute(os.curdir, 'xxd', ['-i', 'romfs_img', dst]) utils.execute(os.curdir, 'sed', ['-i', 's/unsigned/const\ unsigned/g', dst]) os.remove(romfs_img)
def fetch_modules(env): ''' Download all the required modules. ''' for module in env.modules.values(): # Skip if the module is already exist. if utils.exists(module['src']): continue fetch_url = module['url'] fetch_dir = module['src'] utils.execute('.', 'git', ['clone', fetch_url, fetch_dir]) utils.execute(module['src'], 'git', ['checkout', module['version']]) utils.execute(module['src'], 'git', ['submodule', 'update', '--init'])
def genromfs(**params): ''' Create a romfs_img from the source directory that is converted to a header (byte array) file. Finally, add a `const` modifier to the byte array to be the data in the Read Only Memory. ''' src = params['args'][0] dst = params['args'][1] romfs_img = utils.join(params['cwd'], 'romfs_img') utils.execute(params['cwd'], 'genromfs', ['-f', romfs_img, '-d', src]) utils.execute(params['cwd'], 'xxd', ['-i', 'romfs_img', dst]) utils.execute(params['cwd'], 'sed', ['-i', 's/unsigned/const\ unsigned/g', dst]) utils.remove_file(romfs_img)