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.
This commit is contained in:
Nathan Froyd 2015-02-19 10:35:08 -05:00
parent aa2a1135c0
commit 80a9a7daa1
9 changed files with 44 additions and 80 deletions

View File

@ -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) $^ $@

View File

@ -25,13 +25,22 @@ 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',

View File

@ -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) $^ $@

View File

@ -64,6 +64,9 @@ RESOURCE_FILES += [
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']

View File

@ -4,36 +4,24 @@
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()
def main(header, propFile):
mappings = {}
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()
propFile.close()
keys = mappings.keys()
keys.sort()
keys = mappings.keys()
keys.sort()
header.write("// This is a generated file. Please do not edit.\n")
header.write("// Please edit the corresponding .properties file instead.\n")
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")
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()
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')

View File

@ -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) $^ $@

View File

@ -24,6 +24,10 @@ FINAL_LIBRARY = 'xul'
GENERATED_FILES = [
'unixcharset.properties.h',
]
unixcharset = GENERATED_FILES['unixcharset.properties.h']
unixcharset.script = '../props2arrays.py'
unixcharset.inputs = ['unixcharset.properties']
LOCAL_INCLUDES += [
'..',
]

View File

@ -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) $^ $@

View File

@ -16,6 +16,10 @@ FINAL_LIBRARY = 'xul'
GENERATED_FILES = [
'wincharset.properties.h',
]
wincharset = GENERATED_FILES['wincharset.properties.h']
wincharset.script = '../props2arrays.py'
wincharset.inputs = ['wincharset.properties']
LOCAL_INCLUDES += [
'..',
]