Bug 786010 - create manifest as part of the clang build. r=rail.
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Mon, 27 Aug 2012 16:05:35 -0400
changeset 105639 dbeed4d1e2045bba919ea4284307bf2aac061893
parent 105638 8ac55d26cf220716f85cc55471b2eb5cbdc5069f
child 105640 104671eaadb84738adcb5b5b4a03379367ad9367
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersrail
bugs786010
milestone17.0a1
Bug 786010 - create manifest as part of the clang build. r=rail.
build/unix/build-clang/build-clang.py
build/unix/build-clang/create-manifest.py
--- a/build/unix/build-clang/build-clang.py
+++ b/build/unix/build-clang/build-clang.py
@@ -9,16 +9,18 @@ moz_version = "moz0"
 ##############################################
 
 import os
 import os.path
 import shutil
 import tarfile
 import subprocess
 import platform
+import sys
+import simplejson
 
 def check_run(args):
     r = subprocess.call(args)
     assert r == 0
 
 def run_in(path, args):
     d = os.getcwd()
     os.chdir(path)
@@ -65,16 +67,39 @@ llvm_source_dir = source_dir + "/llvm"
 clang_source_dir = source_dir + "/clang"
 compiler_rt_source_dir = source_dir + "/compiler-rt"
 
 def build_one_stage(env, stage_dir, is_stage_one):
     def f():
         build_one_stage_aux(stage_dir, is_stage_one)
     with_env(env, f)
 
+def build_tooltool_manifest():
+    def key_sort(item):
+        item = item[0]
+        if item == 'size':
+            return 0
+        if item == 'digest':
+            return 1
+        if item == 'algorithm':
+            return 3
+        return 4
+
+    basedir = os.path.split(os.path.realpath(sys.argv[0]))[0]
+    tooltool = basedir + '/tooltool.py'
+    setup = basedir + '/setup.sh'
+    manifest = 'clang.manifest'
+    check_run(['python', tooltool, '-m', 'clang.manifest', 'add',
+               setup, 'clang.tar.bz2'])
+    data = simplejson.load(file('clang.manifest'))
+    data = [{'clang_version' : 'r%s' % llvm_revision }] + data
+    out = file('clang.manifest','w')
+    simplejson.dump(data, out, indent=0, item_sort_key=key_sort)
+    out.write('\n')
+
 isDarwin = platform.system() == "Darwin"
 
 def build_one_stage_aux(stage_dir, is_stage_one):
     os.mkdir(stage_dir)
 
     build_dir = stage_dir + "/build"
     inst_dir = stage_dir + "/clang"
 
@@ -131,8 +156,9 @@ if not isDarwin:
     extra_cflags += " -fgnu89-inline"
 
 stage2_dir = build_dir + '/stage2'
 build_one_stage({"CC"  : stage1_inst_dir + "/bin/clang %s" % extra_cflags,
                  "CXX" : stage1_inst_dir + "/bin/clang++ %s" % extra_cxxflags},
                 stage2_dir, False)
 
 build_tar_package("tar", "clang.tar.bz2", stage2_dir, "clang")
+build_tooltool_manifest()
deleted file mode 100755
--- a/build/unix/build-clang/create-manifest.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/python
-
-import os
-import os.path
-import simplejson
-import sys
-import subprocess
-import urllib
-import glob
-
-def check_run(args):
-    r = subprocess.call(args)
-    assert r == 0
-
-old_files = glob.glob('*.manifest')
-for f in old_files:
-    try:
-        os.unlink(f)
-    except:
-        pass
-
-basedir = os.path.split(os.path.realpath(sys.argv[0]))[0]
-tooltool = basedir + '/tooltool.py'
-setup = basedir + '/setup.sh'
-
-check_run(['python', tooltool, '-m', 'linux32.manifest', 'add',
-           'clang-linux32.tar.bz2', setup])
-check_run(['python', tooltool, '-m', 'linux64.manifest', 'add',
-           'clang-linux64.tar.bz2', setup])
-check_run(['python', tooltool, '-m', 'darwin.manifest', 'add',
-           'clang-darwin.tar.bz2', setup])
-
-def key_sort(item):
-    item = item[0]
-    if item == 'size':
-        return 0
-    if item == 'digest':
-        return 1
-    if item == 'algorithm':
-        return 3
-    return 4
-
-rev = os.path.basename(os.getcwd()).split('-')[1]
-
-for platform in ['darwin', 'linux32', 'linux64']:
-    old_name = 'clang-' + platform + '.tar.bz2'
-    manifest = platform + '.manifest'
-    data = eval(file(manifest).read())
-    new_name = data[1]['digest']
-    data[1]['filename'] = 'clang.tar.bz2'
-    data = [{'clang_version' : 'r%s' % rev }] + data
-    out = file(manifest,'w')
-    simplejson.dump(data, out, indent=0, item_sort_key=key_sort)
-    out.write('\n')
-    os.rename(old_name, new_name)