Bug 1633016 - Remove a bunch of references to PYTHON(2) in Makefiles r=glandium

Differential Revision: https://phabricator.services.mozilla.com/D72479
This commit is contained in:
Ricky Stewart 2020-04-30 15:25:22 +00:00
parent d990224458
commit bb4e86d85a
16 changed files with 51 additions and 49 deletions

View File

@ -220,7 +220,7 @@ endif
uploadsymbols: uploadsymbols:
ifdef MOZ_CRASHREPORTER ifdef MOZ_CRASHREPORTER
$(PYTHON) -u $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.py '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' $(PYTHON3) -u $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.py '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip'
endif endif
.PHONY: update-packaging .PHONY: update-packaging

View File

@ -78,7 +78,7 @@ LPROJ := Contents/Resources/$(LPROJ_ROOT).lproj
clean clobber repackage:: clean clobber repackage::
$(RM) -r $(dist_dest) $(RM) -r $(dist_dest)
MAC_BUNDLE_VERSION = $(shell $(PYTHON) $(srcdir)/macversion.py --version=$(MOZ_APP_VERSION) --buildid=$(DEPTH)/buildid.h) MAC_BUNDLE_VERSION = $(shell $(PYTHON3) $(srcdir)/macversion.py --version=$(MOZ_APP_VERSION) --buildid=$(DEPTH)/buildid.h)
.PHONY: repackage .PHONY: repackage
tools repackage:: $(DIST)/bin/$(MOZ_APP_NAME) tools repackage:: $(DIST)/bin/$(MOZ_APP_NAME)

View File

@ -3,23 +3,24 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function from __future__ import absolute_import, print_function, unicode_literals
import io
from optparse import OptionParser from optparse import OptionParser
import sys import sys
import re import re
o = OptionParser() o = OptionParser()
o.add_option("--buildid", dest="buildid") o.add_option('--buildid', dest='buildid')
o.add_option("--version", dest="version") o.add_option('--version', dest='version')
(options, args) = o.parse_args() (options, args) = o.parse_args()
if not options.buildid: if not options.buildid:
print >>sys.stderr, "--buildid is required" print('--buildid is required', file=sys.stderr)
sys.exit(1) sys.exit(1)
if not options.version: if not options.version:
print >>sys.stderr, "--version is required" print('--version is required', file=sys.stderr)
sys.exit(1) sys.exit(1)
# We want to build a version number that matches the format allowed for # We want to build a version number that matches the format allowed for
@ -28,7 +29,8 @@ if not options.version:
# builds), but also so that newly-built older versions (e.g. beta build) aren't # builds), but also so that newly-built older versions (e.g. beta build) aren't
# considered "newer" than previously-built newer versions (e.g. a trunk nightly) # considered "newer" than previously-built newer versions (e.g. a trunk nightly)
define, MOZ_BUILDID, buildid = open(options.buildid, 'r').read().split() define, MOZ_BUILDID, buildid = io.open(
options.buildid, 'r', encoding='utf-8').read().split()
# extract only the major version (i.e. "14" from "14.0b1") # extract only the major version (i.e. "14" from "14.0b1")
majorVersion = re.match(r'^(\d+)[^\d].*', options.version).group(1) majorVersion = re.match(r'^(\d+)[^\d].*', options.version).group(1)

View File

@ -62,14 +62,14 @@ $(CONFIG_DIR)/setup.exe::
$(INSTALL) $(addprefix $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/,$(BRANDING_FILES)) $(CONFIG_DIR) $(INSTALL) $(addprefix $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/,$(BRANDING_FILES)) $(CONFIG_DIR)
$(call py3_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \ $(call py3_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
$(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi) $(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi)
$(PYTHON) $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \ $(PYTHON3) $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
--preprocess-locale $(topsrcdir) \ --preprocess-locale $(topsrcdir) \
$(PPL_LOCALE_ARGS) $(AB_CD) $(CONFIG_DIR) $(PPL_LOCALE_ARGS) $(AB_CD) $(CONFIG_DIR)
$(PYTHON) $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \ $(PYTHON3) $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
--preprocess-single-file $(topsrcdir) \ --preprocess-single-file $(topsrcdir) \
$(PPL_LOCALE_ARGS) $(CONFIG_DIR) \ $(PPL_LOCALE_ARGS) $(CONFIG_DIR) \
nsisstrings.properties nsisstrings.nlf nsisstrings.properties nsisstrings.nlf
$(PYTHON) $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \ $(PYTHON3) $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
--convert-utf8-utf16le \ --convert-utf8-utf16le \
$(srcdir)/nsis/extensionsLocale.nsh $(CONFIG_DIR)/extensionsLocale.nsh $(srcdir)/nsis/extensionsLocale.nsh $(CONFIG_DIR)/extensionsLocale.nsh

View File

@ -146,8 +146,8 @@ if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -z "$DEVELOPER_OPTIONS"; then
if AC_TRY_COMMAND([${CC-cc} -o conftest.${ac_objext} $CFLAGS $MOZ_DEBUG_FLAGS -c conftest.${ac_ext} 1>&2]) && if AC_TRY_COMMAND([${CC-cc} -o conftest.${ac_objext} $CFLAGS $MOZ_DEBUG_FLAGS -c conftest.${ac_ext} 1>&2]) &&
AC_TRY_COMMAND([${CC-cc} -o conftest${ac_exeext} $LDFLAGS $MOZ_DEBUG_FLAGS -Wl,--gc-sections conftest.${ac_objext} $LIBS 1>&2]) && AC_TRY_COMMAND([${CC-cc} -o conftest${ac_exeext} $LDFLAGS $MOZ_DEBUG_FLAGS -Wl,--gc-sections conftest.${ac_objext} $LIBS 1>&2]) &&
test -s conftest${ac_exeext} -a -s conftest.${ac_objext}; then test -s conftest${ac_exeext} -a -s conftest.${ac_objext}; then
if test "`$PYTHON -m mozbuild.configure.check_debug_ranges conftest.${ac_objext} conftest.${ac_ext}`" = \ if test "`$PYTHON3 -m mozbuild.configure.check_debug_ranges conftest.${ac_objext} conftest.${ac_ext}`" = \
"`$PYTHON -m mozbuild.configure.check_debug_ranges conftest${ac_exeext} conftest.${ac_ext}`"; then "`$PYTHON3 -m mozbuild.configure.check_debug_ranges conftest${ac_exeext} conftest.${ac_ext}`"; then
GC_SECTIONS_BREAKS_DEBUG_RANGES=no GC_SECTIONS_BREAKS_DEBUG_RANGES=no
else else
GC_SECTIONS_BREAKS_DEBUG_RANGES=yes GC_SECTIONS_BREAKS_DEBUG_RANGES=yes

View File

@ -92,7 +92,7 @@ AUTOMATION_EXTRA_CMDLINE-check = --keep-going
# However, the target automation/buildsymbols will still be executed in this # However, the target automation/buildsymbols will still be executed in this
# case because it is a prerequisite of automation/upload. # case because it is a prerequisite of automation/upload.
define automation_commands define automation_commands
@+$(PYTHON) $(topsrcdir)/config/run-and-prefix.py $1 $(MAKE) $1 $(AUTOMATION_EXTRA_CMDLINE-$1) @+$(PYTHON3) $(topsrcdir)/config/run-and-prefix.py $1 $(MAKE) $1 $(AUTOMATION_EXTRA_CMDLINE-$1)
$(call BUILDSTATUS,TIER_FINISH $1) $(call BUILDSTATUS,TIER_FINISH $1)
endef endef

View File

@ -32,7 +32,7 @@ ifeq "$(CWD)" "/"
CWD := /. CWD := /.
endif endif
PYTHON ?= $(shell which python2.7 > /dev/null 2>&1 && echo python2.7 || echo python) PYTHON3 ?= python3
#################################### ####################################
# Load mozconfig Options # Load mozconfig Options
@ -46,7 +46,7 @@ endif
# Automatically add -jN to make flags if not defined. N defaults to number of cores. # Automatically add -jN to make flags if not defined. N defaults to number of cores.
ifeq (,$(findstring -j,$(MOZ_MAKE_FLAGS))) ifeq (,$(findstring -j,$(MOZ_MAKE_FLAGS)))
cores=$(shell $(PYTHON) -c 'import multiprocessing; print(multiprocessing.cpu_count())') cores=$(shell $(PYTHON3) -c 'import multiprocessing; print(multiprocessing.cpu_count())')
MOZ_MAKE_FLAGS += -j$(cores) MOZ_MAKE_FLAGS += -j$(cores)
endif endif

View File

@ -9,8 +9,7 @@
# JSErrorFormatString.format member should be in ASCII encoding. # JSErrorFormatString.format member should be in ASCII encoding.
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
from __future__ import absolute_import from __future__ import absolute_import, print_function, unicode_literals
from __future__ import print_function
import os import os
import sys import sys

View File

@ -2,8 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, print_function, unicode_literals
from __future__ import print_function
import os import os
import errno import errno

View File

@ -28,7 +28,7 @@ USE_AUTOTARGETS_MK = 1
include $(MOZILLA_DIR)/config/makefiles/makeutils.mk include $(MOZILLA_DIR)/config/makefiles/makeutils.mk
ifdef REBUILD_CHECK ifdef REBUILD_CHECK
REPORT_BUILD = $(info $(shell $(PYTHON) $(MOZILLA_DIR)/config/rebuild_check.py $@ $^)) REPORT_BUILD = $(info $(shell $(PYTHON3) $(MOZILLA_DIR)/config/rebuild_check.py $@ $^))
REPORT_BUILD_VERBOSE = $(REPORT_BUILD) REPORT_BUILD_VERBOSE = $(REPORT_BUILD)
else else
REPORT_BUILD = $(info $(relativesrcdir)/$(notdir $@)) REPORT_BUILD = $(info $(relativesrcdir)/$(notdir $@))
@ -66,10 +66,10 @@ INSTALL_TARGETS += CPP_UNIT_TESTS
endif endif
run-cppunittests:: run-cppunittests::
@$(PYTHON) $(MOZILLA_DIR)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(CPP_UNIT_TESTS) @$(PYTHON3) $(MOZILLA_DIR)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(CPP_UNIT_TESTS)
cppunittests-remote: cppunittests-remote:
$(PYTHON) -u $(MOZILLA_DIR)/testing/remotecppunittests.py \ $(PYTHON3) -u $(MOZILLA_DIR)/testing/remotecppunittests.py \
--xre-path=$(DEPTH)/dist/bin \ --xre-path=$(DEPTH)/dist/bin \
--localLib=$(DEPTH)/dist/$(MOZ_APP_NAME) \ --localLib=$(DEPTH)/dist/$(MOZ_APP_NAME) \
--deviceIP=${TEST_DEVICE} \ --deviceIP=${TEST_DEVICE} \

View File

@ -6,23 +6,22 @@
# This script runs a process and prefixes its output with. # This script runs a process and prefixes its output with.
# Usage: run-and-prefix.py prefix command arg0 argv1... # Usage: run-and-prefix.py prefix command arg0 argv1...
from __future__ import absolute_import, print_function from __future__ import absolute_import, print_function, unicode_literals
import os import os
import subprocess import subprocess
import sys import sys
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0)
sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0) sys.stderr = os.fdopen(sys.stderr.fileno(), 'wb', 0)
prefix = sys.argv[1] prefix = sys.argv[1].encode('utf-8')
args = sys.argv[2:] args = sys.argv[2:]
p = subprocess.Popen(args, bufsize=0, p = subprocess.Popen(args, bufsize=0,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
stdin=sys.stdin.fileno(), stdin=sys.stdin.fileno())
universal_newlines=True)
while True: while True:
data = p.stdout.readline() data = p.stdout.readline()
@ -30,6 +29,6 @@ while True:
if data == b'': if data == b'':
break break
print('%s> %s' % (prefix, data), end=b'') sys.stdout.write(b'%s> %s' % (prefix, data))
sys.exit(p.wait()) sys.exit(p.wait())

View File

@ -32,13 +32,13 @@ check:: $(srcdir)/replay.log expected_output.log $(srcdir)/expected_output_minim
# command in replay.log) because starting with libstdc++ 5, a static # command in replay.log) because starting with libstdc++ 5, a static
# initializer in the STL allocates memory, which we obviously don't have # initializer in the STL allocates memory, which we obviously don't have
# in expected_output.log. # in expected_output.log.
MALLOC_LOG=1 $(LOGALLOC) ./$(PROGRAM) < $< | sed -n '/jemalloc_stats/,$$p' | $(PYTHON) $(srcdir)/logalloc_munge.py | diff -w - expected_output.log MALLOC_LOG=1 $(LOGALLOC) ./$(PROGRAM) < $< | sed -n '/jemalloc_stats/,$$p' | $(PYTHON3) $(srcdir)/logalloc_munge.py | diff -w - expected_output.log
# Test with MALLOC_LOG as a file name # Test with MALLOC_LOG as a file name
$(RM) test_output.log $(RM) test_output.log
MALLOC_LOG=test_output.log $(LOGALLOC) ./$(PROGRAM) < $< MALLOC_LOG=test_output.log $(LOGALLOC) ./$(PROGRAM) < $<
sed -n '/jemalloc_stats/,$$p' test_output.log | $(PYTHON) $(srcdir)/logalloc_munge.py | diff -w - expected_output.log sed -n '/jemalloc_stats/,$$p' test_output.log | $(PYTHON3) $(srcdir)/logalloc_munge.py | diff -w - expected_output.log
MALLOC_LOG=1 MALLOC_LOG_MINIMAL=1 $(LOGALLOC) ./$(PROGRAM) < $< | sed -n '/jemalloc_stats/,$$p' | $(PYTHON) $(srcdir)/logalloc_munge.py | diff -w - $(srcdir)/expected_output_minimal.log MALLOC_LOG=1 MALLOC_LOG_MINIMAL=1 $(LOGALLOC) ./$(PROGRAM) < $< | sed -n '/jemalloc_stats/,$$p' | $(PYTHON3) $(srcdir)/logalloc_munge.py | diff -w - $(srcdir)/expected_output_minimal.log
endif endif
endif endif

View File

@ -6,7 +6,7 @@
# to a given compilation unit. This is used as a helper to find a bug in some # to a given compilation unit. This is used as a helper to find a bug in some
# versions of GNU ld. # versions of GNU ld.
from __future__ import absolute_import, print_function from __future__ import absolute_import, print_function, unicode_literals
import subprocess import subprocess
import sys import sys
@ -46,7 +46,8 @@ def get_range_length(range, debug_ranges):
def main(bin, compilation_unit): def main(bin, compilation_unit):
p = subprocess.Popen(['objdump', '-W', bin], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen(['objdump', '-W', bin], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, universal_newlines=True)
(out, err) = p.communicate() (out, err) = p.communicate()
sections = re.split('\n(Contents of the|The section) ', out) sections = re.split('\n(Contents of the|The section) ', out)
debug_info = [s for s in sections if s.startswith('.debug_info')] debug_info = [s for s in sections if s.startswith('.debug_info')]

View File

@ -72,7 +72,7 @@ if CONFIG['MOZ_BUILD_APP'].startswith('comm/'):
# We run shlibsign as part of packaging, not build. # We run shlibsign as part of packaging, not build.
gyp_vars['sign_libs'] = 0 gyp_vars['sign_libs'] = 0
gyp_vars['python'] = CONFIG['PYTHON'] gyp_vars['python'] = CONFIG['PYTHON3']
# The NSS gyp files do not have a default for this. # The NSS gyp files do not have a default for this.
gyp_vars['nss_dist_dir'] = '$PRODUCT_DIR/dist' gyp_vars['nss_dist_dir'] = '$PRODUCT_DIR/dist'
# NSS wants to put public headers in $nss_dist_dir/public/nss by default, # NSS wants to put public headers in $nss_dist_dir/public/nss by default,

View File

@ -101,7 +101,7 @@ $(CONFIG_DIR)/helper.exe: $(HELPER_DEPS)
$(INSTALL) $(addprefix $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/,$(BRANDING_FILES)) $(CONFIG_DIR) $(INSTALL) $(addprefix $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/,$(BRANDING_FILES)) $(CONFIG_DIR)
$(call py3_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \ $(call py3_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
$(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi) $(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi)
$(PYTHON) $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \ $(PYTHON3) $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
--preprocess-locale $(topsrcdir) \ --preprocess-locale $(topsrcdir) \
$(PPL_LOCALE_ARGS) $(AB_CD) $(CONFIG_DIR) $(PPL_LOCALE_ARGS) $(AB_CD) $(CONFIG_DIR)
$(INSTALL) $(addprefix $(MOZILLA_DIR)/toolkit/mozapps/installer/windows/nsis/,$(TOOLKIT_NSIS_FILES)) $(CONFIG_DIR) $(INSTALL) $(addprefix $(MOZILLA_DIR)/toolkit/mozapps/installer/windows/nsis/,$(TOOLKIT_NSIS_FILES)) $(CONFIG_DIR)
@ -120,7 +120,7 @@ maintenanceservice_installer::
$(INSTALL) $(addprefix $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/,$(BRANDING_FILES)) $(CONFIG_DIR) $(INSTALL) $(addprefix $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/,$(BRANDING_FILES)) $(CONFIG_DIR)
$(call py3_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \ $(call py3_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
$(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi) $(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi)
$(PYTHON) $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \ $(PYTHON3) $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
--preprocess-locale $(topsrcdir) \ --preprocess-locale $(topsrcdir) \
$(PPL_LOCALE_ARGS) $(AB_CD) $(CONFIG_DIR) $(PPL_LOCALE_ARGS) $(AB_CD) $(CONFIG_DIR)
$(INSTALL) $(addprefix $(MOZILLA_DIR)/toolkit/mozapps/installer/windows/nsis/,$(TOOLKIT_NSIS_FILES)) $(CONFIG_DIR) $(INSTALL) $(addprefix $(MOZILLA_DIR)/toolkit/mozapps/installer/windows/nsis/,$(TOOLKIT_NSIS_FILES)) $(CONFIG_DIR)

View File

@ -12,7 +12,9 @@
# --convert-utf8-utf16le. # --convert-utf8-utf16le.
from codecs import BOM_UTF16_LE from codecs import BOM_UTF16_LE
import io
from os.path import join, isfile from os.path import join, isfile
import six
import sys import sys
from optparse import OptionParser from optparse import OptionParser
@ -20,7 +22,7 @@ def open_utf16le_file(path):
""" """
Returns an opened file object with a a UTF-16LE byte order mark. Returns an opened file object with a a UTF-16LE byte order mark.
""" """
fp = open(path, "w+b") fp = io.open(path, "w+b")
fp.write(BOM_UTF16_LE) fp.write(BOM_UTF16_LE)
return fp return fp
@ -37,7 +39,7 @@ def get_locale_strings(path, prefix, middle, add_cr):
linefeeds when there isn't one already linefeeds when there isn't one already
""" """
output = "" output = ""
fp = open(path, "r") fp = io.open(path, "r", encoding="utf-8")
for line in fp: for line in fp:
line = line.strip() line = line.strip()
if line == "" or line[0] == "#": if line == "" or line[0] == "#":
@ -84,7 +86,7 @@ def preprocess_locale_files(config_dir, l10ndirs):
"LangString ^", "LangString ^",
" 0 ", " 0 ",
False) False)
fp.write(unicode(locale_strings, "utf-8").encode("utf-16-le")) fp.write(locale_strings.encode("utf-16-le"))
fp.close() fp.close()
# Create the Modern User Interface language file # Create the Modern User Interface language file
@ -97,7 +99,7 @@ def preprocess_locale_files(config_dir, l10ndirs):
""").encode("utf-16-le")) """).encode("utf-16-le"))
locale_strings = get_locale_strings(lookup("mui.properties", l10ndirs), locale_strings = get_locale_strings(lookup("mui.properties", l10ndirs),
"!define ", " ", True) "!define ", " ", True)
fp.write(unicode(locale_strings, "utf-8").encode("utf-16-le")) fp.write(locale_strings.encode("utf-16-le"))
fp.write(u"!insertmacro MOZ_MUI_LANGUAGEFILE_END\n".encode("utf-16-le")) fp.write(u"!insertmacro MOZ_MUI_LANGUAGEFILE_END\n".encode("utf-16-le"))
fp.close() fp.close()
@ -108,7 +110,7 @@ def preprocess_locale_files(config_dir, l10ndirs):
"LangString ", "LangString ",
" 0 ", " 0 ",
True) True)
fp.write(unicode(locale_strings, "utf-8").encode("utf-16-le")) fp.write(locale_strings.encode("utf-16-le"))
fp.close() fp.close()
def create_nlf_file(moz_dir, ab_cd, config_dir): def create_nlf_file(moz_dir, ab_cd, config_dir):
@ -123,9 +125,9 @@ def create_nlf_file(moz_dir, ab_cd, config_dir):
rtl = "-" rtl = "-"
# Check whether the locale is right to left from locales.nsi. # Check whether the locale is right to left from locales.nsi.
fp = open(join(moz_dir, fp = io.open(join(moz_dir,
"toolkit/mozapps/installer/windows/nsis/locales.nsi"), "toolkit/mozapps/installer/windows/nsis/locales.nsi"),
"r") "r", encoding='utf-8')
for line in fp: for line in fp:
line = line.strip() line = line.strip()
if line == "!define " + ab_cd + "_rtl": if line == "!define " + ab_cd + "_rtl":
@ -175,7 +177,7 @@ def preprocess_locale_file(config_dir,
"LangString ", "LangString ",
" 0 ", " 0 ",
True) True)
fp.write(unicode(locale_strings, "utf-8").encode("utf-16-le")) fp.write(locale_strings.encode("utf-16-le"))
fp.close() fp.close()
@ -187,9 +189,9 @@ def convert_utf8_utf16le(in_file_path, out_file_path):
in_file_path - the path to the UTF-8 source file to convert in_file_path - the path to the UTF-8 source file to convert
out_file_path - the path to the UTF-16LE destination file to create out_file_path - the path to the UTF-16LE destination file to create
""" """
in_fp = open(in_file_path, "r") in_fp = open(in_file_path, "r", encoding='utf-8')
out_fp = open_utf16le_file(out_file_path) out_fp = open_utf16le_file(out_file_path)
out_fp.write(unicode(in_fp.read(), "utf-8").encode("utf-16-le")) out_fp.write(in_fp.read().encode("utf-16-le"))
in_fp.close() in_fp.close()
out_fp.close() out_fp.close()