Adding armv7hl
[scm/meta/abs.git] / abs
diff --git a/abs b/abs
index 4f5b978..42488a2 100755 (executable)
--- a/abs
+++ b/abs
@@ -154,7 +154,7 @@ class _Rootstrap(object):
         cmdline = self.tizen + ' list rootstrap'
         ret = Executor().run(cmdline, show=False)
         for x in ret.splitlines():
-            if re.search('(mobile|wearable)-(2.4|3.0)-(device|emulator).core.*', x):
+            if re.search('(mobile|wearable)-(2.4|3.0|4.0)-(device|emulator|device64|emulator64).core.*', x):
                 if self.rootstrap_list == None:
                     self.rootstrap_list = []
                 self.rootstrap_list.append(x.split(' ')[0])
@@ -338,7 +338,7 @@ class Sdk(object):
         myZipFile.close()
         return rsrc_zip
 
-    def build_native(self, source, rootstrap=None, arch=None, conf='Debug'):
+    def build_native(self, source, rootstrap=None, arch=None, conf='Debug', jobs=None):
         """SDK CLI build command"""
 
         _rootstrap = self.check_rootstrap(rootstrap)
@@ -349,16 +349,24 @@ class Sdk(object):
             rootstrap = _rootstrap
             self.arch = 'x86'
         elif arch is None:
-            if 'emulator' in rootstrap: self.arch = 'x86'
+            if 'emulator64' in rootstrap: self.arch = 'x86_64'
+            elif 'device64' in rootstrap: self.arch = 'aarch64'
+            elif 'emulator' in rootstrap: self.arch = 'x86'
             elif 'device' in rootstrap: self.arch = 'arm'
         elif rootstrap is None:
-            if arch not in ['x86', 'arm']:
+            if arch not in ['x86', 'arm', 'aarch64', 'x86_64']:
                 raise LocalError('Architecture and rootstrap mismatch')
+
             rootstrap = _rootstrap
-            if arch == 'arm': rootstrap = rootstrap.replace('emulator', 'device')
+            if arch == 'x86_64': rootstrap = rootstrap.replace('emulator', 'emulator64')
+            elif arch == 'aarch64': rootstrap = rootstrap.replace('emulator', 'device64')
+            elif arch == 'arm': rootstrap = rootstrap.replace('emulator', 'device')
 
         for x in source.project_list:
-            out = self._run('build-native', ['-r', rootstrap, '-a', self.arch, '-C', conf, '--' , x['path']], checker=True)
+            b_args = ['-r', rootstrap, '-a', self.arch, '-C', conf, '-c', 'gcc']
+            if jobs is not None: b_args.extend(['-j', jobs])
+            b_args.extend(['--', x['path']])
+            out = self._run('build-native', b_args, 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):
@@ -366,9 +374,10 @@ class Sdk(object):
             with open(logpath, 'w') as lf:
                 lf.write(out)
             ret = self.error_parser.check(out)
-            if ret:
+            if True:
                 with open(logpath+'.log', 'w') as lf:
                     lf.write(out)
+            if ret:
                 raise LocalError(ret)
 
     def package(self, source, cert=None, pkg_type=None, conf=None):
@@ -453,6 +462,10 @@ class Sdk(object):
                 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')
+            elif self.arch == 'x86_64' :
+                strip_cmd = os.path.join(os.path.dirname(self.tizen), '../../x86_64-linux-gnu-gcc-4.9/bin/x86_64-linux-gnu-strip')
+            elif self.arch == 'aarch64' :
+                strip_cmd = os.path.join(os.path.dirname(self.tizen), '../../aarch64-linux-gnu-gcc-4.9/bin/aarch64-linux-gnu-strip')
 
             print strip_cmd
 
@@ -554,6 +567,17 @@ class Source(object):
         mydict['path'] = path
         return mydict
 
+    def set_user_options(self, c_opts=None, cpp_opts=None, link_opts=None):
+        if c_opts is not None:
+            os.environ['USER_C_OPTS'] = c_opts
+            print 'Set USER_C_OPTS=[%s]' % os.getenv('USER_C_OPTS')
+        if cpp_opts is not None:
+            os.environ['USER_CPP_OPTS'] = cpp_opts
+            print 'Set USER_CPP_OPTS=[%s]' % os.getenv('USER_CPP_OPTS')
+        if link_opts is not None:
+            os.environ['USER_LINK_OPTS'] = link_opts
+            print 'Set USER_LINK_OPTS=[%s]' % os.getenv('USER_LINK_OPTS')
+
     def pre_process(self):
 
         if os.path.isfile(os.path.join(self.workspace, self.multi_conf_file)):
@@ -581,16 +605,24 @@ def argument_parsing(argv):
     build.add_argument('-r', '--rootstrap', action='store', dest='rootstrap', \
                         help='(ex, mobile-3.0-device.core) rootstrap name')
     build.add_argument('-a', '--arch', action='store', dest='arch', \
-                        help='(x86|arm) Architecture to build')
+                        help='(x86|arm|x86_64|aarch64) Architecture to build')
     build.add_argument('-t', '--type', action='store', dest='type', \
                         help='(tpk|wgt) Packaging type')
     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='(ex, Debug|Release) Build Configuration')
+    build.add_argument('-j', '--jobs', action='store', dest='jobs', \
+                        help='(number of jobs) The number of parallel builds')
     build.add_argument('--sdkpath', action='store', dest='sdkpath', \
                         help='Specify Tizen SDK installation root (one time init).' \
                              ' ex) /home/yours/tizen-sdk/')
+    build.add_argument('--c-opts', action='store', dest='c_opts', \
+                        help='Extra compile options USER_C_OPTS')
+    build.add_argument('--cpp-opts', action='store', dest='cpp_opts', \
+                        help='Extra compile options USER_CPP_OPTS')
+    build.add_argument('--link-opts', action='store', dest='link_opts', \
+                        help='Extra linking options USER_LINK_OPTS')
 
     return parser.parse_args(argv[1:])
 
@@ -598,9 +630,10 @@ def build_main(args):
     """Command [build] entry point."""
 
     my_source = Source(src=args.workspace)
+    my_source.set_user_options(c_opts=args.c_opts, cpp_opts=args.cpp_opts, link_opts=args.link_opts)
     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.build_native(my_source, rootstrap=args.rootstrap, arch=args.arch, conf=args.conf, jobs=args.jobs)
     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)