From: Seunghwan, Lee Date: Fri, 15 Jul 2016 04:36:55 +0000 (+0900) Subject: Manual Strip Mode for generating Debug package & Stripped package X-Git-Url: http://review.tizen.org/git/?p=scm%2Fmeta%2Fabs.git;a=commitdiff_plain;h=16b57bba3e05f4399c5ac137009a40d676c4a973 Manual Strip Mode for generating Debug package & Stripped package Change-Id: Ie88a613e0ec80e96ff4c1ad8ee592b0b7485affd Signed-off-by: Seunghwan, Lee --- diff --git a/abs b/abs index a0d43be..d7b9d9c 100644 --- a/abs +++ b/abs @@ -337,7 +337,7 @@ class Sdk(object): myZipFile.close() return rsrc_zip - def build_native(self, source, rootstrap=None, arch=None, conf='Release'): + def build_native(self, source, rootstrap=None, arch=None, conf='Debug'): """SDK CLI build command""" _rootstrap = self.check_rootstrap(rootstrap) @@ -346,10 +346,10 @@ class Sdk(object): if rootstrap is None and arch is None: rootstrap = _rootstrap - arch = 'x86' + self.arch = 'x86' elif arch is None: - if 'emulator' in rootstrap: arch = 'x86' - elif 'device' in rootstrap: arch = 'arm' + if 'emulator' in rootstrap: self.arch = 'x86' + elif 'device' in rootstrap: self.arch = 'arm' elif rootstrap is None: if arch not in ['x86', 'arm']: raise LocalError('Architecture and rootstrap mismatch') @@ -357,7 +357,7 @@ class Sdk(object): if arch == 'arm': rootstrap = rootstrap.replace('emulator', 'device') for x in source.project_list: - out = self._run('build-native', ['-r', rootstrap, '-a', arch, '-C', conf, '--' , x['path']], checker=True) + out = self._run('build-native', ['-r', rootstrap, '-a', self.arch, '-C', conf, '--' , x['path']], checker=True) logpath = os.path.join(source.output_dir, \ 'build_%s_%s' % (rootstrap, os.path.basename(x['path']))) if not os.path.isdir(source.output_dir): @@ -418,6 +418,93 @@ class Sdk(object): #Copy tpk to output directory shutil.copy(final_app, source.output_dir) + def package_new(self, source, cert=None, pkg_type=None, conf=None, manual_strip=False): + """SDK CLI package command + IF Debug + Manual Strip off then generate package-name-debug.tpk + IF Debug + Manual Strip on then generate package-name.tpk with custom strip + IF Release then generate package-name.tpk with strip option + """ + + if cert is None: cert = 'ABS' + if pkg_type is None: pkg_type = 'tpk' + if conf is None: conf = 'Debug' + + final_app = '' + main_args = ['-t', pkg_type, '-s', cert] + out = '' #logfile + + # remove tpk or zip file on project path + package_list = [] + for i, x in enumerate(source.project_list): + package_list.extend(list_files(os.path.join(x['path'], conf), ext='tpk')) + package_list.extend(list_files(os.path.join(x['path'], conf), ext='zip')) + + for k in package_list : + print ' package list ' + k; + os.remove(k) + + # Manual strip + if manual_strip == True : + strip_cmd=''; + if self.arch == None: + raise LocalError('Architecture is Noen') + elif self.arch == 'x86' : + strip_cmd = os.path.join(os.path.dirname(self.tizen), '../../i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-strip') + elif self.arch == 'arm' : + strip_cmd = os.path.join(os.path.dirname(self.tizen), '../../arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-strip') + + print strip_cmd + + for i, x in enumerate(source.project_list): + dir = os.path.join(x['path'], conf) + files = [os.path.join(dir,f) for f in os.listdir(dir) if os.path.isfile(os.path.join(dir,f))] + for k in files: + cmdline = strip_cmd + ' ' + k; + #print 'my command line ' + cmdline; + Executor().run(cmdline, show=False) + elif conf == 'Release': + main_args.extend(['--strip', 'on']) + + for i, x in enumerate(source.project_list): + if x['type'] == 'app': + out = '%s\n%s' % (out, \ + self._run('package', main_args + ['--',os.path.join(x['path'],conf)])) + try: + final_app = list_files(os.path.join(x['path'], conf), ext='tpk')[0] + except: + raise LocalError('TPK file not generated for %s.' % x['APPNAME']) + x['out_package'] = final_app + elif x['type'] == 'sharedLib': + self._package_sharedlib(x['path'], conf, x['APPNAME']) + x['out_package'] = list_files(os.path.join(x['path'], conf), ext='zip')[0] + else: + raise LocalError('Not supported project type %s' % x['type']) + + if source.b_multi == True: + extra_args=[] + print 'THIS IS MULTI PROJECT' + for i, x in enumerate(source.project_list): + if x['out_package'] != final_app and x['type'] == 'app': + extra_args.extend(['-r', x['out_package']]) + elif x['type'] == 'sharedLib': + extra_args.extend(['-r', x['out_package']]) + + extra_args.extend(['--', final_app]) + out = self._run('package', main_args + extra_args) + + #TODO: signature validation check failed : Invalid file reference. An unsigned file was found. + print 'Packaging final step again!' + out = self._run('package', main_args + ['--', final_app]) + + #Copy tpk to output directory + if conf == 'Debug' and manual_strip == False : + basename = os.path.splitext(final_app)[0] + newname = basename +'-debug.tpk' + os.rename(final_app, newname) + shutil.copy(newname, source.output_dir) + else : + shutil.copy(final_app, source.output_dir) + def clean(self, source): """SDK CLI clean command""" @@ -499,7 +586,7 @@ def argument_parsing(argv): build.add_argument('-s', '--cert', action='store', dest='cert', \ help='(ex, ABS) Certificate profile name') build.add_argument('-c', '--conf', action='store',default='Release', dest='conf', \ - help='(Debug|Release) Build configuration') + help='(ex, Debug|Release) Build Configuration') build.add_argument('--sdkpath', action='store', dest='sdkpath', \ help='Specify Tizen SDK installation root (one time init).' \ ' ex) /home/yours/tizen-sdk/') @@ -513,11 +600,17 @@ def build_main(args): my_sdk = Sdk(sdkpath=args.sdkpath) my_sdk.clean(my_source) my_sdk.build_native(my_source, rootstrap=args.rootstrap, arch=args.arch, conf=args.conf) - my_sdk.package(my_source, pkg_type=args.type, cert=args.cert, conf=args.conf) + if args.conf == 'Debug' : + my_sdk.package_new(my_source, pkg_type=args.type, cert=args.cert, conf=args.conf) + my_sdk.package_new(my_source, pkg_type=args.type, cert=args.cert, conf=args.conf, manual_strip=True) + else : + my_sdk.package_new(my_source, pkg_type=args.type, cert=args.cert, conf=args.conf) def main(argv): """Script entry point.""" + print 'ABS SCRIPT FROM GIT' + args = argument_parsing(argv) if args.subcommands == 'build':