Bug 860860 - followup: fix json.dump call and be more explicit about object ordering; r=gps
authorNathan Froyd <froydnj@mozilla.com>
Thu, 11 Apr 2013 16:57:54 -0400
changeset 128513 ebcfc07b631511d2a5c9bd52abbe2ff76428a10f
parent 128512 c4c23b700b012d0546945b638e1c3c3f705d01e2
child 128514 55a6fc3b5f421070b6dff19645f8543fb6cef594
push id26354
push usernfroyd@mozilla.com
push dateThu, 11 Apr 2013 22:35:15 +0000
treeherdermozilla-inbound@ebcfc07b6315 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs860860
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 860860 - followup: fix json.dump call and be more explicit about object ordering; r=gps It turns out the simple s/simplejson/json/ didn't work because build_tooltool_manifest used item_sort_key to ensure that the objects read in were written out in the same order. This scheme was brittle, since it only understand a couple of keys from the manifest file, and it doesn't work with the stdlib json. Instead, use object_pairs_hook=collections.OrderedDict with json.load, which ensures that current objects get written out in the same order they were read in *and* that any future keys will be handled automagically. DONTBUILD because NPOTB
build/unix/build-clang/build-clang.py
--- a/build/unix/build-clang/build-clang.py
+++ b/build/unix/build-clang/build-clang.py
@@ -11,16 +11,17 @@ moz_version = "moz0"
 import os
 import os.path
 import shutil
 import tarfile
 import subprocess
 import platform
 import sys
 import json
+import collections
 
 def check_run(args):
     r = subprocess.call(args)
     assert r == 0
 
 def run_in(path, args):
     d = os.getcwd()
     os.chdir(path)
@@ -69,36 +70,26 @@ 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', manifest, 'add',
                setup, 'clang.tar.bz2'])
-    data = json.load(file(manifest))
+    data = json.load(file(manifest), object_pairs_hook=collections.OrderedDict)
     data = [{'clang_version' : 'r%s' % llvm_revision }] + data
     out = file(manifest,'w')
-    json.dump(data, out, indent=0, item_sort_key=key_sort)
+    json.dump(data, out, indent=0)
     out.write('\n')
 
     assert data[2]['filename'] == 'clang.tar.bz2'
     os.rename('clang.tar.bz2', data[2]['digest'])
 
 isDarwin = platform.system() == "Darwin"
 
 def build_one_stage_aux(stage_dir, is_stage_one):