Bug 1134633 - convert makefile rules with props2arrays.py to use moz.build GENERATED_FILES; r=mshal
authorNathan Froyd <froydnj@mozilla.com>
Thu, 19 Feb 2015 10:35:08 -0500
changeset 247491 0645b0eeb7202ee9e3aa0a0fe90b2affabbc79bc
parent 247490 9ba87714f5cfda74e6dd2eb8fd73678429a9b3e6
child 247492 00ea6409e912aac7552509669a8f0528595259ba
push id7677
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 18:11:24 +0000
treeherdermozilla-aurora@f531d838c055 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1134633
milestone38.0a1
Bug 1134633 - convert makefile rules with props2arrays.py to use moz.build GENERATED_FILES; r=mshal Now that GENERATED_FILES can generate makefile rules for generating files, we can start moving rules from Makefile.in's into moz.build.
dom/encoding/Makefile.in
dom/encoding/moz.build
intl/locale/Makefile.in
intl/locale/moz.build
intl/locale/props2arrays.py
intl/locale/unix/Makefile.in
intl/locale/unix/moz.build
intl/locale/windows/Makefile.in
intl/locale/windows/moz.build
deleted file mode 100644
--- a/dom/encoding/Makefile.in
+++ /dev/null
@@ -1,17 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-PROPS2ARRAYS = $(topsrcdir)/intl/locale/props2arrays.py
-labelsencodings.properties.h: $(PROPS2ARRAYS) labelsencodings.properties
-	$(PYTHON) $^ $@
-localesfallbacks.properties.h: $(PROPS2ARRAYS) localesfallbacks.properties
-	$(PYTHON) $^ $@
-domainsfallbacks.properties.h: $(PROPS2ARRAYS) domainsfallbacks.properties
-	$(PYTHON) $^ $@
-encodingsgroups.properties.h: $(PROPS2ARRAYS) encodingsgroups.properties
-	$(PYTHON) $^ $@
-nonparticipatingdomains.properties.h: $(PROPS2ARRAYS) nonparticipatingdomains.properties
-	$(PYTHON) $^ $@
--- a/dom/encoding/moz.build
+++ b/dom/encoding/moz.build
@@ -20,21 +20,30 @@ UNIFIED_SOURCES += [
 
 FAIL_ON_WARNINGS = True
 
 FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '/intl/locale',
 ]
 
-GENERATED_FILES += [
-    'domainsfallbacks.properties.h',
-    'encodingsgroups.properties.h',
-    'labelsencodings.properties.h',
-    'localesfallbacks.properties.h',
-    'nonparticipatingdomains.properties.h',
-]
+props2arrays = TOPSRCDIR + '/intl/locale/props2arrays.py'
+prefixes = (
+    'domainsfallbacks',
+    'encodingsgroups',
+    'labelsencodings',
+    'localesfallbacks',
+    'nonparticipatingdomains',
+)
+
+for prefix in prefixes:
+    input_file = prefix + '.properties'
+    header = prefix + '.properties.h'
+    GENERATED_FILES += [header]
+    props = GENERATED_FILES[header]
+    props.script = props2arrays
+    props.inputs = [input_file]
 
 MOCHITEST_MANIFESTS += [
     'test/mochitest.ini',
 ]
 MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
 XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
deleted file mode 100644
--- a/intl/locale/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-PROPS2ARRAYS = $(topsrcdir)/intl/locale/props2arrays.py
-langGroups.properties.h: $(PROPS2ARRAYS) langGroups.properties
-	$(PYTHON) $^ $@
--- a/intl/locale/moz.build
+++ b/intl/locale/moz.build
@@ -59,13 +59,16 @@ LOCAL_INCLUDES += [
 RESOURCE_FILES += [
     'langGroups.properties',
     'language.properties',
 ]
 
 GENERATED_FILES += [
     'langGroups.properties.h',
 ]
+langgroups = GENERATED_FILES['langGroups.properties.h']
+langgroups.script = 'props2arrays.py'
+langgroups.inputs = ['langGroups.properties']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
     CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
 
 FAIL_ON_WARNINGS = True
--- a/intl/locale/props2arrays.py
+++ b/intl/locale/props2arrays.py
@@ -1,39 +1,27 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import sys
 
-mappings = {}
-  
-propFile = open(sys.argv[1], "r");
-  
-for line in propFile:
-  line = line.strip()
-  if not line.startswith('#'):
-    parts = line.split("=", 1)
-    if len(parts) == 2 and len(parts[0]) > 0:
-      mappings[parts[0].strip()] = parts[1].strip()
- 
-propFile.close()
-
-keys = mappings.keys()
-keys.sort()
+def main(header, propFile):
+  mappings = {}
 
-hFile = open(sys.argv[2], "w");
-
-hFile.write("// This is a generated file. Please do not edit.\n")
-hFile.write("// Please edit the corresponding .properties file instead.\n")
+  with open(propFile, 'r') as f:
+    for line in f:
+      line = line.strip()
+      if not line.startswith('#'):
+        parts = line.split("=", 1)
+        if len(parts) == 2 and len(parts[0]) > 0:
+          mappings[parts[0].strip()] = parts[1].strip()
+ 
+  keys = mappings.keys()
+  keys.sort()
 
-first = 1
-for key in keys:
-  if first:
-    first = 0
-  else:
-    hFile.write(',\n')
-  hFile.write('{ "%s", "%s", (const char*)NS_INT32_TO_PTR(%d) }' 
-              % (key, mappings[key], len(mappings[key])));
-hFile.write('\n')
-hFile.flush()
-hFile.close()
+  header.write("// This is a generated file. Please do not edit.\n")
+  header.write("// Please edit the corresponding .properties file instead.\n")
 
+  entries = ['{ "%s", "%s", (const char*)NS_INT32_TO_PTR(%d) }'
+             % (key, mappings[key], len(mappings[key])) for key in keys]
+  header.write(',\n'.join(entries) + '\n')
+
deleted file mode 100644
--- a/intl/locale/unix/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-unixcharset.properties.h: $(srcdir)/../props2arrays.py unixcharset.properties
-	$(PYTHON) $^ $@
--- a/intl/locale/unix/moz.build
+++ b/intl/locale/unix/moz.build
@@ -19,16 +19,20 @@ else:
         'nsUNIXCharset.cpp',
     ]
 
 FINAL_LIBRARY = 'xul'
 
 GENERATED_FILES = [
     'unixcharset.properties.h',
 ]
+unixcharset = GENERATED_FILES['unixcharset.properties.h']
+unixcharset.script = '../props2arrays.py'
+unixcharset.inputs = ['unixcharset.properties']
+
 LOCAL_INCLUDES += [
     '..',
 ]
 
 
 # CODESET is not automatically defined on some older versions of Redhat.
 # Define _XOPEN_SOURCE so CODESET will get defined and thus allow
 # nl_langinfo(CODESET) to compile on these systems.
deleted file mode 100644
--- a/intl/locale/windows/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-wincharset.properties.h: $(srcdir)/../props2arrays.py wincharset.properties
-	$(PYTHON) $^ $@
--- a/intl/locale/windows/moz.build
+++ b/intl/locale/windows/moz.build
@@ -11,12 +11,16 @@ SOURCES += [
     'nsWinCharset.cpp',
 ]
 
 FINAL_LIBRARY = 'xul'
 
 GENERATED_FILES = [
     'wincharset.properties.h',
 ]
+wincharset = GENERATED_FILES['wincharset.properties.h']
+wincharset.script = '../props2arrays.py'
+wincharset.inputs = ['wincharset.properties']
+
 LOCAL_INCLUDES += [
     '..',
 ]