зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1675437 - Avoid using iconv to create InfoPlist.strings. r=firefox-build-system-reviewers,mhentges
Since python creates little-endian utf-16 consistently whether cross-compiling from Linux or compiling natively on macOS, we could write a small script that essentially replaces iconv. On the other hand, we're also doing some manual preprocessing on the InfoPlist.strings.in files, and we might as well use the preprocessor for that. So, we augment the preprocessor to allow an explicit output encoding other than utf-8, and use the preprocessor instead of `sed | iconv`. Differential Revision: https://phabricator.services.mozilla.com/D96013
This commit is contained in:
Родитель
60c444155f
Коммит
ead183252e
|
@ -87,7 +87,7 @@ tools repackage:: $(DIST)/bin/$(MOZ_APP_NAME) $(objdir)/macbuild/Contents/MacOS-
|
|||
rsync -a --exclude '*.in' $(srcdir)/macbuild/Contents '$(dist_dest)' --exclude English.lproj
|
||||
rsync -a --exclude '*.in' $(srcdir)/macbuild/Contents/Resources/English.lproj/ '$(dist_dest)/$(LPROJ)'
|
||||
sed -e 's/%APP_VERSION%/$(MOZ_APP_VERSION)/' -e 's/%MOZ_APP_NAME%/$(MOZ_APP_NAME)/' -e 's/%MAC_APP_NAME%/$(MAC_APP_NAME)/' -e 's/%MOZ_MACBUNDLE_ID%/$(MOZ_MACBUNDLE_ID)/' -e 's/%MAC_BUNDLE_VERSION%/$(MAC_BUNDLE_VERSION)/' -e 's|%MOZ_DEVELOPER_REPO_PATH%|$(topsrcdir)|' -e 's|%MOZ_DEVELOPER_OBJ_PATH%|$(topobjdir)|' $(srcdir)/macbuild/Contents/Info.plist.in > '$(dist_dest)/Contents/Info.plist'
|
||||
sed -e 's/%MAC_APP_NAME%/$(MAC_APP_NAME)/' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | iconv -f UTF-8 -t UTF-16 > '$(dist_dest)/$(LPROJ)/InfoPlist.strings'
|
||||
$(call py_action,preprocessor,-Fsubstitution --output-encoding utf-16 -DMAC_APP_NAME='$(MAC_APP_NAME)' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in -o '$(dist_dest)/$(LPROJ)/InfoPlist.strings')
|
||||
rsync -a --exclude-from='$(objdir)/macbuild/Contents/MacOS-files.txt' $(DIST)/bin/ '$(dist_dest)/Contents/Resources'
|
||||
rsync -a --include-from='$(objdir)/macbuild/Contents/MacOS-files.txt' --exclude '*' $(DIST)/bin/ '$(dist_dest)/Contents/MacOS'
|
||||
# MacOS-files-copy.in is a list of files that should be copies rather
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
* 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/. */
|
||||
|
||||
CFBundleName = "%MAC_APP_NAME%";
|
||||
CFBundleName = "@MAC_APP_NAME@";
|
||||
|
|
|
@ -30,8 +30,7 @@ libs::
|
|||
$(NSINSTALL) -D $(DIST)/bin/$(PROGRAM).app
|
||||
rsync -a -C --exclude '*.in' $(srcdir)/macbuild/Contents $(DIST)/bin/$(MOZ_CHILD_PROCESS_NAME).app
|
||||
sed -e 's/%PROGRAM%/$(MOZ_CHILD_PROCESS_NAME)/' -e 's|%MOZ_DEVELOPER_REPO_PATH%|$(topsrcdir)|' -e 's|%MOZ_DEVELOPER_OBJ_PATH%|$(topobjdir)|' $(srcdir)/macbuild/Contents/Info.plist.in > $(DIST)/bin/$(MOZ_CHILD_PROCESS_NAME).app/Contents/Info.plist
|
||||
sed -e 's/%APP_NAME%/$(MOZ_CHILD_PROCESS_BUNDLENAME)/' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | \
|
||||
iconv -f UTF-8 -t UTF-16 > $(DIST)/bin/$(MOZ_CHILD_PROCESS_NAME).app/Contents/Resources/English.lproj/InfoPlist.strings
|
||||
$(call py_action,preprocessor,-Fsubstitution --output-encoding utf-16 -DAPP_NAME='$(MOZ_CHILD_PROCESS_BUNDLENAME)' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in -o $(DIST)/bin/$(MOZ_CHILD_PROCESS_NAME).app/Contents/Resources/English.lproj/InfoPlist.strings)
|
||||
$(NSINSTALL) -D $(DIST)/bin/$(MOZ_CHILD_PROCESS_NAME).app/Contents/MacOS
|
||||
$(NSINSTALL) $(DIST)/bin/$(MOZ_CHILD_PROCESS_NAME) $(DIST)/bin/$(MOZ_CHILD_PROCESS_NAME).app/Contents/MacOS
|
||||
endif #}
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
|
||||
/* Localized versions of Info.plist keys */
|
||||
|
||||
CFBundleName = "%APP_NAME%";
|
||||
CFBundleName = "@APP_NAME@";
|
||||
|
|
|
@ -495,7 +495,9 @@ class Preprocessor:
|
|||
Uses OptionParser internally, no args mean sys.argv[1:].
|
||||
"""
|
||||
|
||||
def get_output_file(path):
|
||||
def get_output_file(path, encoding=None):
|
||||
if encoding is None:
|
||||
encoding = "utf-8"
|
||||
dir = os.path.dirname(path)
|
||||
if dir:
|
||||
try:
|
||||
|
@ -503,7 +505,7 @@ class Preprocessor:
|
|||
except OSError as error:
|
||||
if error.errno != errno.EEXIST:
|
||||
raise
|
||||
return io.open(path, "w", encoding="utf-8", newline="\n")
|
||||
return io.open(path, "w", encoding=encoding, newline="\n")
|
||||
|
||||
p = self.getCommandLineParser()
|
||||
options, args = p.parse_args(args=args)
|
||||
|
@ -511,7 +513,11 @@ class Preprocessor:
|
|||
depfile = None
|
||||
|
||||
if options.output:
|
||||
out = get_output_file(options.output)
|
||||
out = get_output_file(options.output, options.output_encoding)
|
||||
elif options.output_encoding:
|
||||
raise Preprocessor.Error(
|
||||
self, "--output-encoding doesn't work without --output", None
|
||||
)
|
||||
if defaultToStdin and len(args) == 0:
|
||||
args = [sys.stdin]
|
||||
if options.depend:
|
||||
|
@ -596,7 +602,7 @@ class Preprocessor:
|
|||
type="string",
|
||||
default=None,
|
||||
metavar="FILENAME",
|
||||
help="Output to the specified file " + "instead of stdout",
|
||||
help="Output to the specified file instead of stdout",
|
||||
)
|
||||
p.add_option(
|
||||
"--depend",
|
||||
|
@ -618,6 +624,13 @@ class Preprocessor:
|
|||
callback=handleSilenceDirectiveWarnings,
|
||||
help="Don't emit warnings about missing directives",
|
||||
)
|
||||
p.add_option(
|
||||
"--output-encoding",
|
||||
type="string",
|
||||
default=None,
|
||||
metavar="ENCODING",
|
||||
help="Encoding to use for the output",
|
||||
)
|
||||
return p
|
||||
|
||||
def handleLine(self, aLine):
|
||||
|
|
|
@ -13,8 +13,7 @@ ifeq ($(OS_ARCH),Darwin)
|
|||
libs::
|
||||
$(NSINSTALL) -D $(DIST)/bin/crashreporter.app
|
||||
rsync -a -C --exclude '*.in' $(srcdir)/macbuild/Contents $(DIST)/bin/crashreporter.app
|
||||
sed -e 's/%APP_NAME%/$(MOZ_APP_DISPLAYNAME)/' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | \
|
||||
iconv -f UTF-8 -t UTF-16 > $(DIST)/bin/crashreporter.app/Contents/Resources/English.lproj/InfoPlist.strings
|
||||
$(call py_action,preprocessor,-Fsubstitution --output-encoding utf-16 -DAPP_NAME='$(MOZ_APP_DISPLAYNAME)' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in -o $(DIST)/bin/crashreporter.app/Contents/Resources/English.lproj/InfoPlist.strings)
|
||||
$(NSINSTALL) -D $(DIST)/bin/crashreporter.app/Contents/MacOS
|
||||
$(NSINSTALL) $(DIST)/bin/crashreporter $(DIST)/bin/crashreporter.app/Contents/MacOS
|
||||
endif
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
/* Localized versions of Info.plist keys */
|
||||
|
||||
CFBundleName = "Crash Reporter";
|
||||
CFBundleDisplayName = "%APP_NAME% Crash Reporter";
|
||||
CFBundleDisplayName = "@APP_NAME@ Crash Reporter";
|
||||
|
|
|
@ -22,8 +22,7 @@ libs::
|
|||
$(NSINSTALL) -D $(DIST)/bin/updater.app
|
||||
rsync -a -C --exclude '*.in' $(srcdir)/macbuild/Contents $(DIST)/bin/updater.app
|
||||
rsync -a -C $(DIST)/bin/Info.plist $(DIST)/bin/updater.app/Contents
|
||||
sed -e 's/%APP_NAME%/$(MOZ_APP_DISPLAYNAME)/' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | \
|
||||
iconv -f UTF-8 -t UTF-16 > $(DIST)/bin/updater.app/Contents/Resources/English.lproj/InfoPlist.strings
|
||||
$(call py_action,preprocessor,-Fsubstitution --output-encoding utf-16 -DAPP_NAME='$(MOZ_APP_DISPLAYNAME)' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in -o $(DIST)/bin/updater.app/Contents/Resources/English.lproj/InfoPlist.strings)
|
||||
$(NSINSTALL) -D $(DIST)/bin/updater.app/Contents/MacOS
|
||||
$(NSINSTALL) $(DIST)/bin/org.mozilla.updater $(DIST)/bin/updater.app/Contents/MacOS
|
||||
endif
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
/* Localized versions of Info.plist keys */
|
||||
|
||||
CFBundleName = "Software Update";
|
||||
CFBundleDisplayName = "%APP_NAME% Software Update";
|
||||
CFBundleDisplayName = "@APP_NAME@ Software Update";
|
||||
|
|
|
@ -27,8 +27,7 @@ ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
|||
# Copy for xpcshell tests
|
||||
$(NSINSTALL) -D $(XPCSHELLTESTDIR)/data/updater-xpcshell.app
|
||||
rsync -a -C --exclude '*.in' $(srcdir)/../macbuild/Contents $(XPCSHELLTESTDIR)/data/updater-xpcshell.app
|
||||
sed -e 's/%APP_NAME%/$(MOZ_APP_DISPLAYNAME)/' $(srcdir)/../macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | \
|
||||
iconv -f UTF-8 -t UTF-16 > $(XPCSHELLTESTDIR)/data/updater-xpcshell.app/Contents/Resources/English.lproj/InfoPlist.strings
|
||||
$(call py_action,preprocessor,-Fsubstitution --output-encoding utf-16 -DAPP_NAME='$(MOZ_APP_DISPLAYNAME)' $(srcdir)/../macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in -o $(XPCSHELLTESTDIR)/data/updater-xpcshell.app/Contents/Resources/English.lproj/InfoPlist.strings)
|
||||
$(NSINSTALL) -D $(XPCSHELLTESTDIR)/data/updater-xpcshell.app/Contents/MacOS
|
||||
$(NSINSTALL) $(FINAL_TARGET)/updater-xpcshell $(XPCSHELLTESTDIR)/data/updater-xpcshell.app/Contents/MacOS
|
||||
rm -Rf $(XPCSHELLTESTDIR)/data/updater.app
|
||||
|
|
Загрузка…
Ссылка в новой задаче