Bug 680636 - Add support for running nsinstall natively under pymake and convert a bunch of cases over. r=ted

This commit is contained in:
Siddharth Agarwal 2012-07-03 12:13:30 +05:30
Родитель d5b849f4cf
Коммит f7e4ff2b1a
9 изменённых файлов: 89 добавлений и 53 удалений

Просмотреть файл

@ -634,6 +634,11 @@ PWD := $(CURDIR)
endif
NSINSTALL_PY := $(PYTHON) $(call core_abspath,$(topsrcdir)/config/nsinstall.py)
# For Pymake, wherever we use nsinstall.py we're also going to try to make it
# a native command where possible. Since native commands can't be used outside
# of single-line commands, we continue to provide INSTALL for general use.
# Single-line commands should be switched over to install_cmd.
NSINSTALL_NATIVECMD := %nsinstall nsinstall
ifdef NSINSTALL_BIN
NSINSTALL = $(NSINSTALL_BIN)
@ -651,7 +656,11 @@ endif # NSINSTALL_BIN
ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2, $(OS_ARCH)))
INSTALL = $(NSINSTALL) -t
INSTALL = $(NSINSTALL) -t
ifdef .PYMAKE
install_cmd = $(NSINSTALL_NATIVECMD) -t $(1)
endif # .PYMAKE
else
# This isn't laid out as conditional directives so that NSDISTMODE can be
@ -660,11 +669,17 @@ INSTALL = $(if $(filter copy, $(NSDISTMODE)), $(NSINSTALL) -t, $(if $(fi
endif # WINNT/OS2
# The default for install_cmd is simply INSTALL
install_cmd ?= $(INSTALL) $(1)
# Use nsinstall in copy mode to install files on the system
SYSINSTALL = $(NSINSTALL) -t
# This isn't necessarily true, just here
sysinstall_cmd = install_cmd
# Directory nsinstall.
DIR_INSTALL = $(INSTALL)
dir_install_cmd = install_cmd
#
# Localization build automation

Просмотреть файл

@ -46,13 +46,13 @@ xpidl-install-src-preqs=\
$(NULL)
xpidl-install-src: $(xpidl-install-src-preqs)
$(INSTALL) $(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val)))
$(call install_cmd,$(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val))))
xpidl-install-headers-preqs =\
$(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) \
$(call mkdir_deps,$(DIST)/include) \
$(NULL)
xpidl-install-headers: $(xpidl-install-headers-preqs)
$(INSTALL) $(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val)))
$(call install_cmd,$(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val))))
endif #} _xpidl-todo_

Просмотреть файл

@ -17,7 +17,7 @@ import sys
import shutil
import stat
def nsinstall(argv):
def _nsinstall_internal(argv):
usage = "usage: %prog [options] arg1 [arg2 ...] target-directory"
p = OptionParser(usage=usage)
@ -52,13 +52,6 @@ def nsinstall(argv):
help="Set group (NOT SUPPORTED)", metavar="group")
(options, args) = p.parse_args(argv)
# Switching to Unicode strings makes python use the wide Windows APIs, which is
# what we want here since the wide APIs normally do a better job at handling long
# paths and such.
if sys.stdin.encoding is None:
args = [unicode(arg) for arg in args]
else:
args = [unicode(arg, sys.stdin.encoding) for arg in args]
if options.m:
# mode is specified
@ -152,9 +145,16 @@ def nsinstall(argv):
copy_all_entries(args, target)
return 0
# nsinstall as a native command is always UTF-8
def nsinstall(argv):
return _nsinstall_internal([unicode(arg, "utf-8") for arg in argv])
if __name__ == '__main__':
# sys.argv corrupts characters outside the system code page on Windows
# <http://bugs.python.org/issue2128>. Use ctypes instead.
# <http://bugs.python.org/issue2128>. Use ctypes instead. This is also
# useful because switching to Unicode strings makes python use the wide
# Windows APIs, which is what we want here since the wide APIs normally do a
# better job at handling long paths and such.
if sys.platform == "win32":
import ctypes
from ctypes import wintypes
@ -168,9 +168,13 @@ if __name__ == '__main__':
argc = ctypes.c_int(0)
argv_arr = CommandLineToArgv(GetCommandLine(), ctypes.byref(argc))
# The first argument will be "python", the second will be the .py file
# The first argv will be "python", the second will be the .py file
argv = argv_arr[1:argc.value]
else:
argv = sys.argv
# For consistency, do it on Unix as well
if sys.stdin.encoding is not None:
argv = [unicode(arg, sys.stdin.encoding) for arg in sys.argv]
else:
argv = [unicode(arg) for arg in sys.argv]
sys.exit(nsinstall(argv[1:]))
sys.exit(_nsinstall_internal(argv[1:]))

Просмотреть файл

@ -1190,14 +1190,14 @@ endif
ifndef NO_DIST_INSTALL
ifneq (,$(EXPORTS))
export:: $(EXPORTS)
$(INSTALL) $(IFLAGS1) $^ $(DIST)/include
$(call install_cmd,$(IFLAGS1) $^ $(DIST)/include)
endif
endif # NO_DIST_INSTALL
define EXPORT_NAMESPACE_RULE
ifndef NO_DIST_INSTALL
export:: $(EXPORTS_$(namespace))
$(INSTALL) $(IFLAGS1) $$^ $(DIST)/include/$(namespace)
$(call install_cmd,$(IFLAGS1) $$^ $(DIST)/include/$(namespace))
endif # NO_DIST_INSTALL
endef
@ -1246,7 +1246,7 @@ $(FINAL_TARGET)/defaults/autoconfig::
ifndef NO_DIST_INSTALL
export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
$(INSTALL) $(IFLAGS1) $^
$(call install_cmd,$(IFLAGS1) $^)
endif
endif
@ -1312,7 +1312,7 @@ endif # XPIDL_MODULE.xpt != XPIDLSRCS
libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
$(call install_cmd,$(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components)
ifndef NO_INTERFACES_MANIFEST
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/interfaces.manifest "interfaces $(XPIDL_MODULE).xpt"
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
@ -1340,7 +1340,7 @@ export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
ifneq ($(XPIDLSRCS),)
ifndef NO_DIST_INSTALL
export-idl:: $(XPIDLSRCS) $(IDL_DIR)
$(INSTALL) $(IFLAGS1) $^
$(call install_cmd,$(IFLAGS1) $^)
endif
endif
$(LOOP_OVER_PARALLEL_DIRS)
@ -1360,7 +1360,7 @@ endif
ifdef EXTRA_COMPONENTS
libs:: $(EXTRA_COMPONENTS)
ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/components
$(call install_cmd,$(IFLAGS1) $^ $(FINAL_TARGET)/components)
endif
endif
@ -1390,7 +1390,7 @@ endif
ifdef EXTRA_JS_MODULES
libs:: $(EXTRA_JS_MODULES)
ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/modules
$(call install_cmd,$(IFLAGS1) $^ $(FINAL_TARGET)/modules)
endif
endif
@ -1423,7 +1423,7 @@ GENERATED_DIRS += $(testmodulesdir)
libs:: $(TESTING_JS_MODULES)
ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS) $^ $(testmodulesdir)
$(call install_cmd,$(IFLAGS) $^ $(testmodulesdir))
endif
endif
@ -1437,7 +1437,7 @@ $(SDK_LIB_DIR)::
ifndef NO_DIST_INSTALL
libs:: $(SDK_LIBRARY) $(SDK_LIB_DIR)
$(INSTALL) $(IFLAGS2) $^
$(call install_cmd,$(IFLAGS2) $^)
endif
endif # SDK_LIBRARY
@ -1448,7 +1448,7 @@ $(SDK_BIN_DIR)::
ifndef NO_DIST_INSTALL
libs:: $(SDK_BINARY) $(SDK_BIN_DIR)
$(INSTALL) $(IFLAGS2) $^
$(call install_cmd,$(IFLAGS2) $^)
endif
endif # SDK_BINARY

Просмотреть файл

@ -137,8 +137,7 @@ class TestNsinstall(unittest.TestCase):
self.assertEqual(nsinstall(["-d", testfile, destdir]), 0)
self.assert_(os.path.isdir(os.path.join(destdir, "testfile")))
# Disable this temporarily on Windows (will be re-enabled by bug 680636)
if RUN_NON_ASCII_TESTS and sys.platform != "win32":
if RUN_NON_ASCII_TESTS:
def test_nsinstall_non_ascii(self):
"Test that nsinstall handles non-ASCII files"
filename = u"\u2325\u3452\u2415\u5081"
@ -150,7 +149,6 @@ class TestNsinstall(unittest.TestCase):
destfile = os.path.join(testdir, filename)
self.assert_(os.path.isfile(destfile))
if RUN_NON_ASCII_TESTS:
def test_nsinstall_non_ascii_subprocess(self):
"Test that nsinstall as a subprocess handles non-ASCII files"
filename = u"\u2325\u3452\u2415\u5081"

Просмотреть файл

@ -634,6 +634,11 @@ PWD := $(CURDIR)
endif
NSINSTALL_PY := $(PYTHON) $(call core_abspath,$(topsrcdir)/config/nsinstall.py)
# For Pymake, wherever we use nsinstall.py we're also going to try to make it
# a native command where possible. Since native commands can't be used outside
# of single-line commands, we continue to provide INSTALL for general use.
# Single-line commands should be switched over to install_cmd.
NSINSTALL_NATIVECMD := %nsinstall nsinstall
ifdef NSINSTALL_BIN
NSINSTALL = $(NSINSTALL_BIN)
@ -651,7 +656,11 @@ endif # NSINSTALL_BIN
ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2, $(OS_ARCH)))
INSTALL = $(NSINSTALL) -t
INSTALL = $(NSINSTALL) -t
ifdef .PYMAKE
install_cmd = $(NSINSTALL_NATIVECMD) -t $(1)
endif # .PYMAKE
else
# This isn't laid out as conditional directives so that NSDISTMODE can be
@ -660,11 +669,17 @@ INSTALL = $(if $(filter copy, $(NSDISTMODE)), $(NSINSTALL) -t, $(if $(fi
endif # WINNT/OS2
# The default for install_cmd is simply INSTALL
install_cmd ?= $(INSTALL) $(1)
# Use nsinstall in copy mode to install files on the system
SYSINSTALL = $(NSINSTALL) -t
# This isn't necessarily true, just here
sysinstall_cmd = install_cmd
# Directory nsinstall.
DIR_INSTALL = $(INSTALL)
dir_install_cmd = install_cmd
#
# Localization build automation

Просмотреть файл

@ -46,13 +46,13 @@ xpidl-install-src-preqs=\
$(NULL)
xpidl-install-src: $(xpidl-install-src-preqs)
$(INSTALL) $(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val)))
$(call install_cmd,$(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val))))
xpidl-install-headers-preqs =\
$(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) \
$(call mkdir_deps,$(DIST)/include) \
$(NULL)
xpidl-install-headers: $(xpidl-install-headers-preqs)
$(INSTALL) $(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val)))
$(call install_cmd,$(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val))))
endif #} _xpidl-todo_

Просмотреть файл

@ -17,7 +17,7 @@ import sys
import shutil
import stat
def nsinstall(argv):
def _nsinstall_internal(argv):
usage = "usage: %prog [options] arg1 [arg2 ...] target-directory"
p = OptionParser(usage=usage)
@ -52,13 +52,6 @@ def nsinstall(argv):
help="Set group (NOT SUPPORTED)", metavar="group")
(options, args) = p.parse_args(argv)
# Switching to Unicode strings makes python use the wide Windows APIs, which is
# what we want here since the wide APIs normally do a better job at handling long
# paths and such.
if sys.stdin.encoding is None:
args = [unicode(arg) for arg in args]
else:
args = [unicode(arg, sys.stdin.encoding) for arg in args]
if options.m:
# mode is specified
@ -152,9 +145,16 @@ def nsinstall(argv):
copy_all_entries(args, target)
return 0
# nsinstall as a native command is always UTF-8
def nsinstall(argv):
return _nsinstall_internal([unicode(arg, "utf-8") for arg in argv])
if __name__ == '__main__':
# sys.argv corrupts characters outside the system code page on Windows
# <http://bugs.python.org/issue2128>. Use ctypes instead.
# <http://bugs.python.org/issue2128>. Use ctypes instead. This is also
# useful because switching to Unicode strings makes python use the wide
# Windows APIs, which is what we want here since the wide APIs normally do a
# better job at handling long paths and such.
if sys.platform == "win32":
import ctypes
from ctypes import wintypes
@ -168,9 +168,13 @@ if __name__ == '__main__':
argc = ctypes.c_int(0)
argv_arr = CommandLineToArgv(GetCommandLine(), ctypes.byref(argc))
# The first argument will be "python", the second will be the .py file
# The first argv will be "python", the second will be the .py file
argv = argv_arr[1:argc.value]
else:
argv = sys.argv
# For consistency, do it on Unix as well
if sys.stdin.encoding is not None:
argv = [unicode(arg, sys.stdin.encoding) for arg in sys.argv]
else:
argv = [unicode(arg) for arg in sys.argv]
sys.exit(nsinstall(argv[1:]))
sys.exit(_nsinstall_internal(argv[1:]))

Просмотреть файл

@ -1190,14 +1190,14 @@ endif
ifndef NO_DIST_INSTALL
ifneq (,$(EXPORTS))
export:: $(EXPORTS)
$(INSTALL) $(IFLAGS1) $^ $(DIST)/include
$(call install_cmd,$(IFLAGS1) $^ $(DIST)/include)
endif
endif # NO_DIST_INSTALL
define EXPORT_NAMESPACE_RULE
ifndef NO_DIST_INSTALL
export:: $(EXPORTS_$(namespace))
$(INSTALL) $(IFLAGS1) $$^ $(DIST)/include/$(namespace)
$(call install_cmd,$(IFLAGS1) $$^ $(DIST)/include/$(namespace))
endif # NO_DIST_INSTALL
endef
@ -1246,7 +1246,7 @@ $(FINAL_TARGET)/defaults/autoconfig::
ifndef NO_DIST_INSTALL
export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
$(INSTALL) $(IFLAGS1) $^
$(call install_cmd,$(IFLAGS1) $^)
endif
endif
@ -1312,7 +1312,7 @@ endif # XPIDL_MODULE.xpt != XPIDLSRCS
libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
$(call install_cmd,$(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components)
ifndef NO_INTERFACES_MANIFEST
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/interfaces.manifest "interfaces $(XPIDL_MODULE).xpt"
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
@ -1340,7 +1340,7 @@ export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
ifneq ($(XPIDLSRCS),)
ifndef NO_DIST_INSTALL
export-idl:: $(XPIDLSRCS) $(IDL_DIR)
$(INSTALL) $(IFLAGS1) $^
$(call install_cmd,$(IFLAGS1) $^)
endif
endif
$(LOOP_OVER_PARALLEL_DIRS)
@ -1360,7 +1360,7 @@ endif
ifdef EXTRA_COMPONENTS
libs:: $(EXTRA_COMPONENTS)
ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/components
$(call install_cmd,$(IFLAGS1) $^ $(FINAL_TARGET)/components)
endif
endif
@ -1390,7 +1390,7 @@ endif
ifdef EXTRA_JS_MODULES
libs:: $(EXTRA_JS_MODULES)
ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/modules
$(call install_cmd,$(IFLAGS1) $^ $(FINAL_TARGET)/modules)
endif
endif
@ -1423,7 +1423,7 @@ GENERATED_DIRS += $(testmodulesdir)
libs:: $(TESTING_JS_MODULES)
ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS) $^ $(testmodulesdir)
$(call install_cmd,$(IFLAGS) $^ $(testmodulesdir))
endif
endif
@ -1437,7 +1437,7 @@ $(SDK_LIB_DIR)::
ifndef NO_DIST_INSTALL
libs:: $(SDK_LIBRARY) $(SDK_LIB_DIR)
$(INSTALL) $(IFLAGS2) $^
$(call install_cmd,$(IFLAGS2) $^)
endif
endif # SDK_LIBRARY
@ -1448,7 +1448,7 @@ $(SDK_BIN_DIR)::
ifndef NO_DIST_INSTALL
libs:: $(SDK_BINARY) $(SDK_BIN_DIR)
$(INSTALL) $(IFLAGS2) $^
$(call install_cmd,$(IFLAGS2) $^)
endif
endif # SDK_BINARY