linux: optionaly allow building x64 targets with sysroot
authorRobo <hop2deep@gmail.com>
Thu, 3 Mar 2016 23:54:01 +0000 (05:24 +0530)
committerRobo <hop2deep@gmail.com>
Thu, 10 Mar 2016 12:04:42 +0000 (17:34 +0530)
.gitignore
script/bootstrap.py
script/install-sysroot.py
script/update.py
toolchain.gypi

index eb9aedb..a922398 100644 (file)
@@ -6,6 +6,7 @@
 /external_binaries/
 /out/
 /vendor/brightray/vendor/download/
+/vendor/debian_wheezy_amd64-sysroot/
 /vendor/debian_wheezy_arm-sysroot/
 /vendor/debian_wheezy_i386-sysroot/
 /vendor/python_26/
index 6eaf635..b09bc01 100755 (executable)
@@ -43,8 +43,8 @@ def main():
                       args.libcc_source_path, args.libcc_shared_library_path,
                       args.libcc_static_library_path)
 
-  if args.target_arch in ['arm', 'ia32'] and PLATFORM == 'linux':
-    download_sysroot(args.target_arch)
+  if PLATFORM == 'linux':
+    download_sysroot(args.target_arch, args.sysroot_url, args.sysroot_sha1sum)
 
   create_chrome_version_h()
   touch_config_gypi()
@@ -79,6 +79,10 @@ def parse_args():
                       help='The shared library path of libchromiumcontent.')
   parser.add_argument('--libcc_static_library_path', required=False,
                       help='The static library path of libchromiumcontent.')
+  parser.add_argument('--sysroot_url', required=False,
+                      help='The URL to download sysroot image.')
+  parser.add_argument('--sysroot_sha1sum', required=False,
+                      help='SHA1 hash of the sysroot image tarball.')
   return parser.parse_args()
 
 
@@ -163,11 +167,22 @@ def update_clang():
   execute_stdout([os.path.join(SOURCE_ROOT, 'script', 'update-clang.sh')])
 
 
-def download_sysroot(target_arch):
-  if target_arch == 'ia32':
-    target_arch = 'i386'
-  execute_stdout([os.path.join(SOURCE_ROOT, 'script', 'install-sysroot.py'),
-                  '--arch', target_arch])
+def download_sysroot(target_arch, url, sha1sum):
+  if url or target_arch in ['ia32', 'arm']:
+    os.environ['USE_SYSROOT'] = '1'
+    sysroot_script = os.path.join(SOURCE_ROOT, 'script', 'install-sysroot.py')
+    if target_arch == 'ia32':
+      target_arch = 'i386'
+    if target_arch == 'x64':
+      target_arch = 'amd64'
+    args = [
+      '--arch', target_arch
+    ]
+    if url:
+      args += ['--url', url]
+    if sha1sum:
+      args += ['--revision', sha1sum]
+    execute_stdout([sysroot_script] + args)
 
 
 def create_chrome_version_h():
index 69acfb1..6c7b8ad 100755 (executable)
@@ -134,7 +134,11 @@ def main():
     print 'Unknown architecture: %s' % target_arch
     assert(False)
 
-  url = '%s/%s/%s/%s' % (URL_PREFIX, URL_PATH, revision, tarball_filename)
+  if options.url:
+    url = options.url
+    tarball_sha1sum = options.revision
+  else:
+    url = '%s/%s/%s/%s' % (URL_PREFIX, URL_PATH, revision, tarball_filename)
 
   stamp = os.path.join(sysroot, '.stamp')
   if os.path.exists(stamp):
@@ -153,11 +157,12 @@ def main():
   sys.stdout.flush()
   sys.stderr.flush()
   subprocess.check_call(['curl', '--fail', '-L', url, '-o', tarball])
-  sha1sum = GetSha1(tarball)
-  if sha1sum != tarball_sha1sum:
-    print 'Tarball sha1sum is wrong.'
-    print 'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum)
-    return 1
+  if tarball_sha1sum:
+    sha1sum = GetSha1(tarball)
+    if sha1sum != tarball_sha1sum:
+      print 'Tarball sha1sum is wrong.'
+      print 'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum)
+      return 1
   subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot])
   os.remove(tarball)
 
@@ -173,5 +178,9 @@ if __name__ == '__main__':
                                         'Linux builds')
   parser.add_option('--arch', type='choice', choices=valid_archs,
                     help='Sysroot architecture: %s' % ', '.join(valid_archs))
+  parser.add_option('--url', default=None,
+                    help='The URL to download sysroot image.')
+  parser.add_option('--revision', default=None,
+                    help='SHA1 hash of the sysroot image tarball.')
   options, _ = parser.parse_args()
   sys.exit(main())
index e91e840..2388f16 100755 (executable)
@@ -60,12 +60,18 @@ def run_gyp(target_arch, component):
     mas_build = 1
   else:
     mas_build = 0
+  # Whether to use sysroot image.
+  if os.environ.has_key('USE_SYSROOT'):
+    use_sysroot = 1
+  else:
+    use_sysroot = 0
   defines = [
     '-Dlibchromiumcontent_component={0}'.format(component),
     '-Dtarget_arch={0}'.format(target_arch),
     '-Dhost_arch={0}'.format(get_host_arch()),
     '-Dlibrary=static_library',
     '-Dmas_build={0}'.format(mas_build),
+    '-Duse_sysroot={0}'.format(use_sysroot)
   ]
   return subprocess.call([python, gyp, '-f', 'ninja', '--depth', '.',
                           'atom.gyp', '-Icommon.gypi'] + defines, env=env)
index 23592d0..7215cb8 100644 (file)
     }],
 
     # Setup sysroot environment.
-    ['OS=="linux" and target_arch in ["arm", "ia32"]', {
+    ['OS=="linux" and target_arch in ["arm", "ia32", "x64"] and use_sysroot', {
       'variables': {
         'conditions': [
           ['target_arch=="arm"', {
           ['target_arch=="ia32"', {
             'sysroot': '<(source_root)/vendor/debian_wheezy_i386-sysroot',
           }],
+          ['target_arch=="x64"', {
+            'sysroot': '<(source_root)/vendor/debian_wheezy_amd64-sysroot',
+          }],
         ],
       },
       'target_defaults': {