diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py index 26b584e90532f17ecc774fb02db08aaad5b9cb1e..16ec74c9d09347a3c9599a996a43f9cdec3f2418 100644 --- a/.ycm_extra_conf.py +++ b/.ycm_extra_conf.py @@ -12,55 +12,56 @@ import sys old_bytecode = sys.dont_write_bytecode sys.dont_write_bytecode = True -path = os.path.abspath(os.path.join(os.path.dirname(__file__), "mach")) +path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'mach')) # If mach is not here, we're on the objdir go to the srcdir. if not os.path.exists(path): - with open(os.path.join(os.path.dirname(__file__), "mozinfo.json")) as info: + with open(os.path.join(os.path.dirname(__file__), 'mozinfo.json')) as info: config = json.loads(info.read()) - path = os.path.join(config["topsrcdir"], "mach") + path = os.path.join(config['topsrcdir'], 'mach') sys.dont_write_bytecode = old_bytecode - def _is_likely_cpp_header(filename): - if not filename.endswith(".h"): + if not filename.endswith('.h'): return False - if filename.endswith("Inlines.h") or filename.endswith("-inl.h"): + if filename.endswith('Inlines.h') or filename.endswith('-inl.h'): return True - cpp_file = filename[:-1] + "cpp" + cpp_file = filename[:-1] + 'cpp' return os.path.exists(cpp_file) def Settings(**kwargs): - if kwargs["language"] == "cfamily": - return FlagsForFile(kwargs["filename"]) + if kwargs[ 'language' ] == 'cfamily': + return FlagsForFile(kwargs['filename']) # This is useful for generic language server protocols, like rust-analyzer, # to discover the right project root instead of guessing based on where the # closest Cargo.toml is. return { - "project_directory": ".", + 'project_directory': '.', } def FlagsForFile(filename): - output = subprocess.check_output([path, "compileflags", filename]) - output = output.decode("utf-8") + output = subprocess.check_output([path, 'compileflags', filename]) + output = output.decode('utf-8') flag_list = shlex.split(output) # This flag is added by Fennec for android build and causes ycmd to fail to parse the file. # Removing this flag is a workaround until ycmd starts to handle this flag properly. # https://github.com/Valloric/YouCompleteMe/issues/1490 - final_flags = [x for x in flag_list if not x.startswith("-march=armv")] + final_flags = [x for x in flag_list if not x.startswith('-march=armv')] if _is_likely_cpp_header(filename): final_flags += ["-x", "c++"] - return {"flags": final_flags, "do_cache": True} - + return { + 'flags': final_flags, + 'do_cache': True + } -if __name__ == "__main__": +if __name__ == '__main__': print(FlagsForFile(sys.argv[1])) diff --git a/accessible/android/moz.build b/accessible/android/moz.build index 456a9d7ec642da03f2cfbf39039e167cd4d3421b..7cb195352caf1af40887bb29265aba72b70ceadb 100644 --- a/accessible/android/moz.build +++ b/accessible/android/moz.build @@ -4,39 +4,38 @@ # 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/. -EXPORTS.mozilla.a11y += [ - "AccessibleWrap.h", - "HyperTextAccessibleWrap.h", - "SessionAccessibility.h", - "TraversalRule.h", +EXPORTS.mozilla.a11y += ['AccessibleWrap.h', + 'HyperTextAccessibleWrap.h', + 'SessionAccessibility.h', + 'TraversalRule.h', ] SOURCES += [ - "AccessibleWrap.cpp", - "DocAccessibleWrap.cpp", - "Platform.cpp", - "ProxyAccessibleWrap.cpp", - "RootAccessibleWrap.cpp", - "SessionAccessibility.cpp", - "TraversalRule.cpp", + 'AccessibleWrap.cpp', + 'DocAccessibleWrap.cpp', + 'Platform.cpp', + 'ProxyAccessibleWrap.cpp', + 'RootAccessibleWrap.cpp', + 'SessionAccessibility.cpp', + 'TraversalRule.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/html", - "/accessible/ipc", - "/accessible/ipc/other", - "/accessible/xpcom", - "/accessible/xul", - "/dom/base", - "/widget", - "/widget/android", + '/accessible/base', + '/accessible/generic', + '/accessible/html', + '/accessible/ipc', + '/accessible/ipc/other', + '/accessible/xpcom', + '/accessible/xul', + '/dom/base', + '/widget', + '/widget/android', ] -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -if CONFIG["CC_TYPE"] in ("clang", "gcc"): - CXXFLAGS += ["-Wno-error=shadow"] +if CONFIG['CC_TYPE'] in ('clang', 'gcc'): + CXXFLAGS += ['-Wno-error=shadow'] diff --git a/accessible/aom/moz.build b/accessible/aom/moz.build index 88b941435ee8e51d8e86d9530f9707fc77a0dc4e..15bdeeaa792ca637e046daccd1e15de2626042cf 100644 --- a/accessible/aom/moz.build +++ b/accessible/aom/moz.build @@ -5,40 +5,40 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXPORTS.mozilla.dom += [ - "AccessibleNode.h", + 'AccessibleNode.h', ] UNIFIED_SOURCES += [ - "AccessibleNode.cpp", + 'AccessibleNode.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", + '/accessible/base', + '/accessible/generic', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': LOCAL_INCLUDES += [ - "/accessible/atk", + '/accessible/atk', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': LOCAL_INCLUDES += [ - "/accessible/windows/ia2", - "/accessible/windows/msaa", + '/accessible/windows/ia2', + '/accessible/windows/msaa', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': LOCAL_INCLUDES += [ - "/accessible/mac", + '/accessible/mac', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': LOCAL_INCLUDES += [ - "/accessible/android", + '/accessible/android', ] else: LOCAL_INCLUDES += [ - "/accessible/other", + '/accessible/other', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' diff --git a/accessible/atk/moz.build b/accessible/atk/moz.build index 67fb1b9bc2c76a31412a6ba4666ade00b77eec25..1029db426923781c5a7bc1ef678df3fd264da751 100644 --- a/accessible/atk/moz.build +++ b/accessible/atk/moz.build @@ -5,61 +5,61 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXPORTS.mozilla.a11y += [ - "AccessibleWrap.h", - "HyperTextAccessibleWrap.h", + 'AccessibleWrap.h', + 'HyperTextAccessibleWrap.h', ] SOURCES += [ - "AccessibleWrap.cpp", - "ApplicationAccessibleWrap.cpp", - "AtkSocketAccessible.cpp", - "DocAccessibleWrap.cpp", - "DOMtoATK.cpp", - "nsMaiHyperlink.cpp", - "nsMaiInterfaceAction.cpp", - "nsMaiInterfaceComponent.cpp", - "nsMaiInterfaceDocument.cpp", - "nsMaiInterfaceEditableText.cpp", - "nsMaiInterfaceHyperlinkImpl.cpp", - "nsMaiInterfaceHypertext.cpp", - "nsMaiInterfaceImage.cpp", - "nsMaiInterfaceSelection.cpp", - "nsMaiInterfaceTable.cpp", - "nsMaiInterfaceTableCell.cpp", - "nsMaiInterfaceText.cpp", - "nsMaiInterfaceValue.cpp", - "Platform.cpp", - "RootAccessibleWrap.cpp", - "UtilInterface.cpp", + 'AccessibleWrap.cpp', + 'ApplicationAccessibleWrap.cpp', + 'AtkSocketAccessible.cpp', + 'DocAccessibleWrap.cpp', + 'DOMtoATK.cpp', + 'nsMaiHyperlink.cpp', + 'nsMaiInterfaceAction.cpp', + 'nsMaiInterfaceComponent.cpp', + 'nsMaiInterfaceDocument.cpp', + 'nsMaiInterfaceEditableText.cpp', + 'nsMaiInterfaceHyperlinkImpl.cpp', + 'nsMaiInterfaceHypertext.cpp', + 'nsMaiInterfaceImage.cpp', + 'nsMaiInterfaceSelection.cpp', + 'nsMaiInterfaceTable.cpp', + 'nsMaiInterfaceTableCell.cpp', + 'nsMaiInterfaceText.cpp', + 'nsMaiInterfaceValue.cpp', + 'Platform.cpp', + 'RootAccessibleWrap.cpp', + 'UtilInterface.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/html", - "/accessible/ipc", - "/accessible/ipc/other", - "/accessible/xpcom", - "/accessible/xul", - "/other-licenses/atk-1.0", + '/accessible/base', + '/accessible/generic', + '/accessible/html', + '/accessible/ipc', + '/accessible/ipc/other', + '/accessible/xpcom', + '/accessible/xul', + '/other-licenses/atk-1.0', ] -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": - CFLAGS += CONFIG["TK_CFLAGS"] - CXXFLAGS += CONFIG["TK_CFLAGS"] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': + CFLAGS += CONFIG['TK_CFLAGS'] + CXXFLAGS += CONFIG['TK_CFLAGS'] -if CONFIG["MOZ_ENABLE_DBUS"]: - CXXFLAGS += CONFIG["MOZ_DBUS_CFLAGS"] +if CONFIG['MOZ_ENABLE_DBUS']: + CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS'] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -if CONFIG["CC_TYPE"] in ("clang", "gcc"): +if CONFIG['CC_TYPE'] in ('clang', 'gcc'): # Used in G_DEFINE_TYPE_EXTENDED macro, probably fixed in newer glib / # gobject headers. See bug 1243331 comment 3. CXXFLAGS += [ - "-Wno-error=unused-function", - "-Wno-error=shadow", - "-Wno-unused-local-typedefs", + '-Wno-error=unused-function', + '-Wno-error=shadow', + '-Wno-unused-local-typedefs', ] diff --git a/accessible/base/moz.build b/accessible/base/moz.build index 6eb2d96b04a4a8a5c7d339c82e2d1daaf145afce..e577a4af13183e15e1900eae8b24fb3342865501 100644 --- a/accessible/base/moz.build +++ b/accessible/base/moz.build @@ -4,114 +4,117 @@ # 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/. -EXPORTS += ["AccEvent.h", "nsAccessibilityService.h"] +EXPORTS += [ + 'AccEvent.h', + 'nsAccessibilityService.h' +] EXPORTS.mozilla.a11y += [ - "AccTypes.h", - "DocManager.h", - "FocusManager.h", - "IDSet.h", - "Platform.h", - "RelationType.h", - "Role.h", - "SelectionManager.h", - "States.h", + 'AccTypes.h', + 'DocManager.h', + 'FocusManager.h', + 'IDSet.h', + 'Platform.h', + 'RelationType.h', + 'Role.h', + 'SelectionManager.h', + 'States.h', ] -if CONFIG["MOZ_DEBUG"]: +if CONFIG['MOZ_DEBUG']: EXPORTS.mozilla.a11y += [ - "Logging.h", + 'Logging.h', ] UNIFIED_SOURCES += [ - "AccessibleOrProxy.cpp", - "AccEvent.cpp", - "AccGroupInfo.cpp", - "AccIterator.cpp", - "ARIAMap.cpp", - "ARIAStateMap.cpp", - "Asserts.cpp", - "DocManager.cpp", - "EmbeddedObjCollector.cpp", - "EventQueue.cpp", - "EventTree.cpp", - "Filters.cpp", - "FocusManager.cpp", - "NotificationController.cpp", - "nsAccessibilityService.cpp", - "nsAccessiblePivot.cpp", - "nsAccUtils.cpp", - "nsCoreUtils.cpp", - "nsEventShell.cpp", - "nsTextEquivUtils.cpp", - "Pivot.cpp", - "SelectionManager.cpp", - "StyleInfo.cpp", - "TextAttrs.cpp", - "TextRange.cpp", - "TextUpdater.cpp", - "TreeWalker.cpp", + 'AccessibleOrProxy.cpp', + 'AccEvent.cpp', + 'AccGroupInfo.cpp', + 'AccIterator.cpp', + 'ARIAMap.cpp', + 'ARIAStateMap.cpp', + 'Asserts.cpp', + 'DocManager.cpp', + 'EmbeddedObjCollector.cpp', + 'EventQueue.cpp', + 'EventTree.cpp', + 'Filters.cpp', + 'FocusManager.cpp', + 'NotificationController.cpp', + 'nsAccessibilityService.cpp', + 'nsAccessiblePivot.cpp', + 'nsAccUtils.cpp', + 'nsCoreUtils.cpp', + 'nsEventShell.cpp', + 'nsTextEquivUtils.cpp', + 'Pivot.cpp', + 'SelectionManager.cpp', + 'StyleInfo.cpp', + 'TextAttrs.cpp', + 'TextRange.cpp', + 'TextUpdater.cpp', + 'TreeWalker.cpp', ] -if CONFIG["A11Y_LOG"]: +if CONFIG['A11Y_LOG']: UNIFIED_SOURCES += [ - "Logging.cpp", + 'Logging.cpp', ] LOCAL_INCLUDES += [ - "/accessible/generic", - "/accessible/html", - "/accessible/ipc", - "/dom/base", - "/dom/xul", + '/accessible/generic', + '/accessible/html', + '/accessible/ipc', + '/dom/base', + '/dom/xul', ] -if CONFIG["OS_ARCH"] == "WINNT": +if CONFIG['OS_ARCH'] == 'WINNT': LOCAL_INCLUDES += [ - "/accessible/ipc/win", + '/accessible/ipc/win', ] else: LOCAL_INCLUDES += [ - "/accessible/ipc/other", + '/accessible/ipc/other', ] LOCAL_INCLUDES += [ - "/accessible/xpcom", - "/accessible/xul", - "/dom/base", - "/ipc/chromium/src", - "/layout/generic", - "/layout/style", - "/layout/xul", - "/layout/xul/tree/", + '/accessible/xpcom', + '/accessible/xul', + '/dom/base', + '/ipc/chromium/src', + '/layout/generic', + '/layout/style', + '/layout/xul', + '/layout/xul/tree/', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': LOCAL_INCLUDES += [ - "/accessible/atk", + '/accessible/atk', ] - CXXFLAGS += CONFIG["MOZ_CAIRO_CFLAGS"] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": + CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS'] +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': LOCAL_INCLUDES += [ - "/accessible/windows/ia2", - "/accessible/windows/msaa", + '/accessible/windows/ia2', + '/accessible/windows/msaa', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': LOCAL_INCLUDES += [ - "/accessible/mac", + '/accessible/mac', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': LOCAL_INCLUDES += [ - "/accessible/android", + '/accessible/android', ] else: LOCAL_INCLUDES += [ - "/accessible/other", + '/accessible/other', ] -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -if CONFIG["CC_TYPE"] in ("clang", "gcc"): - CXXFLAGS += ["-Wno-error=shadow"] +if CONFIG['CC_TYPE'] in ('clang', 'gcc'): + CXXFLAGS += ['-Wno-error=shadow'] diff --git a/accessible/generic/moz.build b/accessible/generic/moz.build index 8612b7d6f66104c23013e1feddc2f573082ff1b9..7c0899dc409de59226372f1cee5c1e2ebe6f63a7 100644 --- a/accessible/generic/moz.build +++ b/accessible/generic/moz.build @@ -5,73 +5,73 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXPORTS.mozilla.a11y += [ - "Accessible.h", - "DocAccessible.h", - "HyperTextAccessible.h", - "OuterDocAccessible.h", + 'Accessible.h', + 'DocAccessible.h', + 'HyperTextAccessible.h', + 'OuterDocAccessible.h', ] UNIFIED_SOURCES += [ - "Accessible.cpp", - "ApplicationAccessible.cpp", - "ARIAGridAccessible.cpp", - "BaseAccessibles.cpp", - "DocAccessible.cpp", - "FormControlAccessible.cpp", - "HyperTextAccessible.cpp", - "ImageAccessible.cpp", - "OuterDocAccessible.cpp", - "RootAccessible.cpp", - "TableAccessible.cpp", - "TableCellAccessible.cpp", - "TextLeafAccessible.cpp", + 'Accessible.cpp', + 'ApplicationAccessible.cpp', + 'ARIAGridAccessible.cpp', + 'BaseAccessibles.cpp', + 'DocAccessible.cpp', + 'FormControlAccessible.cpp', + 'HyperTextAccessible.cpp', + 'ImageAccessible.cpp', + 'OuterDocAccessible.cpp', + 'RootAccessible.cpp', + 'TableAccessible.cpp', + 'TableCellAccessible.cpp', + 'TextLeafAccessible.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/html", - "/accessible/xpcom", - "/accessible/xul", - "/dom/base", - "/dom/xul", - "/layout/generic", - "/layout/xul", + '/accessible/base', + '/accessible/html', + '/accessible/xpcom', + '/accessible/xul', + '/dom/base', + '/dom/xul', + '/layout/generic', + '/layout/xul', ] -if CONFIG["OS_ARCH"] == "WINNT": +if CONFIG['OS_ARCH'] == 'WINNT': LOCAL_INCLUDES += [ - "/accessible/ipc/win", + '/accessible/ipc/win', ] else: LOCAL_INCLUDES += [ - "/accessible/ipc/other", + '/accessible/ipc/other', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': LOCAL_INCLUDES += [ - "/accessible/atk", + '/accessible/atk', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': LOCAL_INCLUDES += [ - "/accessible/windows/ia2", - "/accessible/windows/msaa", + '/accessible/windows/ia2', + '/accessible/windows/msaa', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': LOCAL_INCLUDES += [ - "/accessible/mac", + '/accessible/mac', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': LOCAL_INCLUDES += [ - "/accessible/android", + '/accessible/android', ] else: LOCAL_INCLUDES += [ - "/accessible/other", + '/accessible/other', ] -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -if CONFIG["CC_TYPE"] in ("clang", "gcc"): - CXXFLAGS += ["-Wno-error=shadow"] +if CONFIG['CC_TYPE'] in ('clang', 'gcc'): + CXXFLAGS += ['-Wno-error=shadow'] diff --git a/accessible/html/moz.build b/accessible/html/moz.build index 5b74f6741fb6b6a5beaf8225936979ea0c2900d7..3f778b11a6a027a1dd26728c1d5cf4a13ac8be02 100644 --- a/accessible/html/moz.build +++ b/accessible/html/moz.build @@ -5,51 +5,51 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. UNIFIED_SOURCES += [ - "HTMLCanvasAccessible.cpp", - "HTMLElementAccessibles.cpp", - "HTMLFormControlAccessible.cpp", - "HTMLImageMapAccessible.cpp", - "HTMLLinkAccessible.cpp", - "HTMLListAccessible.cpp", - "HTMLSelectAccessible.cpp", - "HTMLTableAccessible.cpp", + 'HTMLCanvasAccessible.cpp', + 'HTMLElementAccessibles.cpp', + 'HTMLFormControlAccessible.cpp', + 'HTMLImageMapAccessible.cpp', + 'HTMLLinkAccessible.cpp', + 'HTMLListAccessible.cpp', + 'HTMLSelectAccessible.cpp', + 'HTMLTableAccessible.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/xpcom", - "/layout/forms", - "/layout/generic", - "/layout/tables", - "/layout/xul", + '/accessible/base', + '/accessible/generic', + '/accessible/xpcom', + '/layout/forms', + '/layout/generic', + '/layout/tables', + '/layout/xul', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': LOCAL_INCLUDES += [ - "/accessible/atk", + '/accessible/atk', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': LOCAL_INCLUDES += [ - "/accessible/windows/ia2", - "/accessible/windows/msaa", + '/accessible/windows/ia2', + '/accessible/windows/msaa', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': LOCAL_INCLUDES += [ - "/accessible/mac", + '/accessible/mac', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': LOCAL_INCLUDES += [ - "/accessible/android", + '/accessible/android', ] else: LOCAL_INCLUDES += [ - "/accessible/other", + '/accessible/other', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' -if CONFIG["CC_TYPE"] in ("clang", "gcc"): - CXXFLAGS += ["-Wno-error=shadow"] +if CONFIG['CC_TYPE'] in ('clang', 'gcc'): + CXXFLAGS += ['-Wno-error=shadow'] diff --git a/accessible/interfaces/gecko/moz.build b/accessible/interfaces/gecko/moz.build index bc0ecb3ef2209fad81284fcb5c363f43e4f9ddc4..ea953ab41d87631e7c0bc9bf2d9e7f560618d164 100644 --- a/accessible/interfaces/gecko/moz.build +++ b/accessible/interfaces/gecko/moz.build @@ -4,36 +4,30 @@ # 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/. -GeneratedFile( - "IGeckoCustom.h", - "IGeckoCustom_p.c", - "IGeckoCustom_i.c", - "IGeckoCustom_dlldata.c", - "IGeckoCustom.tlb", - inputs=["IGeckoCustom.idl"], - script="/build/midl.py", - entry_point="midl", - flags=["-dlldata", OBJDIR + "/IGeckoCustom_dlldata.c"], -) +GeneratedFile('IGeckoCustom.h', 'IGeckoCustom_p.c', 'IGeckoCustom_i.c', + 'IGeckoCustom_dlldata.c', 'IGeckoCustom.tlb', + inputs=['IGeckoCustom.idl'], + script='/build/midl.py', entry_point='midl', + flags=['-dlldata', OBJDIR + '/IGeckoCustom_dlldata.c']) SOURCES += [ - "!IGeckoCustom_dlldata.c", - "!IGeckoCustom_i.c", - "!IGeckoCustom_p.c", + '!IGeckoCustom_dlldata.c', + '!IGeckoCustom_i.c', + '!IGeckoCustom_p.c', ] EXPORTS += [ - "!IGeckoCustom.h", - "!IGeckoCustom_i.c", + '!IGeckoCustom.h', + '!IGeckoCustom_i.c', ] -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' # Suppress warnings from the MIDL generated code. -if CONFIG["CC_TYPE"] == "clang-cl": +if CONFIG['CC_TYPE'] == 'clang-cl': CFLAGS += [ - "-Wno-extern-initializer", - "-Wno-incompatible-pointer-types", - "-Wno-missing-braces", - "-Wno-unused-const-variable", + '-Wno-extern-initializer', + '-Wno-incompatible-pointer-types', + '-Wno-missing-braces', + '-Wno-unused-const-variable', ] diff --git a/accessible/interfaces/ia2/moz.build b/accessible/interfaces/ia2/moz.build index e3861a2fa2c1ebb7f4234550752bb294e3e18bf7..00ad4add0cb205678f4b20684ffd752c215187b2 100644 --- a/accessible/interfaces/ia2/moz.build +++ b/accessible/interfaces/ia2/moz.build @@ -4,128 +4,94 @@ # 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/. -GeckoSharedLibrary("IA2Marshal", linkage=None) +GeckoSharedLibrary('IA2Marshal', linkage=None) -DEFINES["REGISTER_PROXY_DLL"] = True +DEFINES['REGISTER_PROXY_DLL'] = True -DEFFILE = "IA2Marshal.def" +DEFFILE = 'IA2Marshal.def' OS_LIBS += [ - "uuid", - "kernel32", - "rpcrt4", - "ole32", - "oleaut32", + 'uuid', + 'kernel32', + 'rpcrt4', + 'ole32', + 'oleaut32', ] midl_enums = [ - "AccessibleEventId", - "AccessibleRole", - "AccessibleStates", - "IA2CommonTypes", + 'AccessibleEventId', + 'AccessibleRole', + 'AccessibleStates', + 'IA2CommonTypes', ] midl_interfaces = [ - "Accessible2", - "Accessible2_2", - "Accessible2_3", - "AccessibleAction", - "AccessibleApplication", - "AccessibleComponent", - "AccessibleDocument", - "AccessibleEditableText", - "AccessibleHyperlink", - "AccessibleHypertext", - "AccessibleHypertext2", - "AccessibleImage", - "AccessibleRelation", - "AccessibleTable", - "AccessibleTable2", - "AccessibleTableCell", - "AccessibleText", - "AccessibleText2", - "AccessibleValue", + 'Accessible2', + 'Accessible2_2', + 'Accessible2_3', + 'AccessibleAction', + 'AccessibleApplication', + 'AccessibleComponent', + 'AccessibleDocument', + 'AccessibleEditableText', + 'AccessibleHyperlink', + 'AccessibleHypertext', + 'AccessibleHypertext2', + 'AccessibleImage', + 'AccessibleRelation', + 'AccessibleTable', + 'AccessibleTable2', + 'AccessibleTableCell', + 'AccessibleText', + 'AccessibleText2', + 'AccessibleValue', ] for enum in midl_enums: - GeneratedFile( - enum + ".h", - inputs=["/other-licenses/ia2/" + enum + ".idl"], - script="/build/midl.py", - entry_point="midl", - flags=["-app_config", "-I", TOPSRCDIR + "/other-licenses/ia2"], - ) + GeneratedFile(enum + '.h', inputs=['/other-licenses/ia2/' + enum + '.idl'], + script='/build/midl.py', entry_point='midl', + flags=['-app_config', '-I', TOPSRCDIR + '/other-licenses/ia2']) - EXPORTS += ["!" + enum + ".h"] + EXPORTS += ['!' + enum + '.h'] for iface in midl_interfaces: - GeneratedFile( - iface + ".h", - iface + "_p.c", - iface + "_i.c", - iface + "_dlldata.c", - inputs=["/other-licenses/ia2/" + iface + ".idl"], - script="/build/midl.py", - entry_point="midl", - flags=[ - "-app_config", - "-I", - TOPSRCDIR + "/other-licenses/ia2", - "-dlldata", - OBJDIR + "/" + iface + "_dlldata.c", - ], - ) - - EXPORTS += ["!" + iface + ".h", "!" + iface + "_i.c"] - - for p in [iface + "_p.c", iface + "_i.c"]: - SOURCES += ["!%s" % p] + GeneratedFile(iface + '.h', iface + '_p.c', iface + '_i.c', iface + '_dlldata.c', + inputs=['/other-licenses/ia2/' + iface + '.idl'], + script='/build/midl.py', entry_point='midl', + flags=['-app_config', '-I', TOPSRCDIR + '/other-licenses/ia2', + '-dlldata', OBJDIR + '/' + iface + '_dlldata.c']) + + EXPORTS += ['!' + iface + '.h', '!' + iface + '_i.c'] + + for p in [iface + '_p.c', iface + '_i.c']: + SOURCES += ['!%s' % p] # Give some symbols a unique name in each translation unit, to avoid # collisions caused by https://llvm.org/pr41817. - if CONFIG["CC_TYPE"] == "clang-cl": - SOURCES["!%s" % p].flags += [ - "-DObject_StubDesc=Object_StubDesc__%s" % p[:-2] - ] - SOURCES["!%s" % p].flags += [ - "-DUserMarshalRoutines=UserMarshalRoutines__%s" % p[:-2] - ] + if CONFIG['CC_TYPE'] == 'clang-cl': + SOURCES['!%s' % p].flags += ['-DObject_StubDesc=Object_StubDesc__%s' % p[:-2]] + SOURCES['!%s' % p].flags += ['-DUserMarshalRoutines=UserMarshalRoutines__%s' % p[:-2]] # Warning: the build system doesn't know about the dependency of IA2Marshal.rc on # IA2Typelib.tlb. We rely on the IA2Typelib.h output forcing the command to run # during export, before rc files are treated during compile. -GeneratedFile( - "IA2Typelib.h", - "IA2Typelib_i.c", - "IA2Typelib.tlb", - inputs=["IA2Typelib.idl"], - script="/build/midl.py", - entry_point="midl", - flags=[ - "-app_config", - "-I", - TOPSRCDIR + "/other-licenses/ia2", - "-D", - "_MIDL_DECLARE_WIREM_HANDLE", - ], -) - -GeneratedFile( - "dlldata.c", - inputs=["!" + iface + "_dlldata.c" for iface in midl_interfaces], - script="/build/midl.py", - entry_point="merge_dlldata", -) - -SOURCES += ["!dlldata.c"] - -RCINCLUDE = "IA2Marshal.rc" +GeneratedFile('IA2Typelib.h', 'IA2Typelib_i.c', 'IA2Typelib.tlb', + inputs=['IA2Typelib.idl'], script='/build/midl.py', entry_point='midl', + flags=['-app_config', '-I', TOPSRCDIR + '/other-licenses/ia2', + '-D', '_MIDL_DECLARE_WIREM_HANDLE']) + +GeneratedFile('dlldata.c', inputs=['!' + iface + '_dlldata.c' for iface in midl_interfaces], + script='/build/midl.py', entry_point='merge_dlldata') + +SOURCES += ['!dlldata.c'] + +RCINCLUDE = 'IA2Marshal.rc' # Suppress warnings from the MIDL generated code. -if CONFIG["CC_TYPE"] == "clang-cl": +if CONFIG['CC_TYPE'] == 'clang-cl': CFLAGS += [ - "-Wno-extern-initializer", - "-Wno-incompatible-pointer-types", - "-Wno-missing-braces", - "-Wno-unused-const-variable", + '-Wno-extern-initializer', + '-Wno-incompatible-pointer-types', + '-Wno-missing-braces', + '-Wno-unused-const-variable', ] diff --git a/accessible/interfaces/moz.build b/accessible/interfaces/moz.build index c5b6be6347d3cc27178b69bb56e9fe247bd1f473..093b7d9eeb4230b6573154adf04ca9d5ee692346 100644 --- a/accessible/interfaces/moz.build +++ b/accessible/interfaces/moz.build @@ -4,42 +4,42 @@ # 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/. -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows" and CONFIG["COMPILE_ENVIRONMENT"]: - DIRS += ["gecko", "msaa", "ia2"] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows' and CONFIG['COMPILE_ENVIRONMENT']: + DIRS += ['gecko', 'msaa', 'ia2'] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": - XPIDL_SOURCES += ["nsIAccessibleMacInterface.idl"] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': + XPIDL_SOURCES += ['nsIAccessibleMacInterface.idl'] XPIDL_SOURCES += [ - "nsIAccessibilityService.idl", - "nsIAccessible.idl", - "nsIAccessibleAnnouncementEvent.idl", - "nsIAccessibleApplication.idl", - "nsIAccessibleCaretMoveEvent.idl", - "nsIAccessibleDocument.idl", - "nsIAccessibleEditableText.idl", - "nsIAccessibleEvent.idl", - "nsIAccessibleHideEvent.idl", - "nsIAccessibleHyperLink.idl", - "nsIAccessibleHyperText.idl", - "nsIAccessibleImage.idl", - "nsIAccessibleObjectAttributeChangedEvent.idl", - "nsIAccessiblePivot.idl", - "nsIAccessibleRelation.idl", - "nsIAccessibleRole.idl", - "nsIAccessibleScrollingEvent.idl", - "nsIAccessibleSelectable.idl", - "nsIAccessibleStateChangeEvent.idl", - "nsIAccessibleStates.idl", - "nsIAccessibleTable.idl", - "nsIAccessibleTableChangeEvent.idl", - "nsIAccessibleText.idl", - "nsIAccessibleTextChangeEvent.idl", - "nsIAccessibleTextRange.idl", - "nsIAccessibleTextSelectionChangeEvent.idl", - "nsIAccessibleTypes.idl", - "nsIAccessibleValue.idl", - "nsIAccessibleVirtualCursorChangeEvent.idl", + 'nsIAccessibilityService.idl', + 'nsIAccessible.idl', + 'nsIAccessibleAnnouncementEvent.idl', + 'nsIAccessibleApplication.idl', + 'nsIAccessibleCaretMoveEvent.idl', + 'nsIAccessibleDocument.idl', + 'nsIAccessibleEditableText.idl', + 'nsIAccessibleEvent.idl', + 'nsIAccessibleHideEvent.idl', + 'nsIAccessibleHyperLink.idl', + 'nsIAccessibleHyperText.idl', + 'nsIAccessibleImage.idl', + 'nsIAccessibleObjectAttributeChangedEvent.idl', + 'nsIAccessiblePivot.idl', + 'nsIAccessibleRelation.idl', + 'nsIAccessibleRole.idl', + 'nsIAccessibleScrollingEvent.idl', + 'nsIAccessibleSelectable.idl', + 'nsIAccessibleStateChangeEvent.idl', + 'nsIAccessibleStates.idl', + 'nsIAccessibleTable.idl', + 'nsIAccessibleTableChangeEvent.idl', + 'nsIAccessibleText.idl', + 'nsIAccessibleTextChangeEvent.idl', + 'nsIAccessibleTextRange.idl', + 'nsIAccessibleTextSelectionChangeEvent.idl', + 'nsIAccessibleTypes.idl', + 'nsIAccessibleValue.idl', + 'nsIAccessibleVirtualCursorChangeEvent.idl', ] -XPIDL_MODULE = "accessibility" +XPIDL_MODULE = 'accessibility' diff --git a/accessible/interfaces/msaa/moz.build b/accessible/interfaces/msaa/moz.build index 7a1053317a37e576e771437afeb26b192b773cce..72468dd00c5d5ca8b1bbd757c27aa92690a02e2c 100644 --- a/accessible/interfaces/msaa/moz.build +++ b/accessible/interfaces/msaa/moz.build @@ -4,54 +4,48 @@ # 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/. -GeckoSharedLibrary("AccessibleMarshal", linkage=None) +GeckoSharedLibrary('AccessibleMarshal', linkage=None) # Missing here, is the notion that changes to the idl files included by # ISimpleDOM.idl (e.g. ISimpleDOMNode.idl) should rebuild the outputs. -GeneratedFile( - "ISimpleDOM.h", - "ISimpleDOM_p.c", - "ISimpleDOM_i.c", - "ISimpleDOM_dlldata.c", - "ISimpleDOM.tlb", - inputs=["ISimpleDOM.idl"], - script="/build/midl.py", - entry_point="midl", - flags=["-I", SRCDIR, "-robust", "-dlldata", OBJDIR + "/ISimpleDOM_dlldata.c"], -) +GeneratedFile('ISimpleDOM.h', 'ISimpleDOM_p.c', 'ISimpleDOM_i.c', + 'ISimpleDOM_dlldata.c', 'ISimpleDOM.tlb', + inputs=['ISimpleDOM.idl'], + script='/build/midl.py', entry_point='midl', + flags=['-I', SRCDIR, '-robust', '-dlldata', OBJDIR + '/ISimpleDOM_dlldata.c']) SOURCES += [ - "!ISimpleDOM_dlldata.c", - "!ISimpleDOM_i.c", - "!ISimpleDOM_p.c", - "AccessibleMarshalThunk.c", + '!ISimpleDOM_dlldata.c', + '!ISimpleDOM_i.c', + '!ISimpleDOM_p.c', + 'AccessibleMarshalThunk.c', ] EXPORTS += [ - "!ISimpleDOM.h", - "!ISimpleDOM_i.c", + '!ISimpleDOM.h', + '!ISimpleDOM_i.c', ] -DEFINES["REGISTER_PROXY_DLL"] = True +DEFINES['REGISTER_PROXY_DLL'] = True # The following line is required to preserve compatibility with older versions # of AccessibleMarshal.dll. -DEFINES["PROXY_CLSID"] = "IID_ISimpleDOMNode" +DEFINES['PROXY_CLSID'] = 'IID_ISimpleDOMNode' -DEFFILE = "AccessibleMarshal.def" +DEFFILE = 'AccessibleMarshal.def' OS_LIBS += [ - "kernel32", - "rpcrt4", - "oleaut32", + 'kernel32', + 'rpcrt4', + 'oleaut32', ] -RCINCLUDE = "AccessibleMarshal.rc" +RCINCLUDE = 'AccessibleMarshal.rc' # Suppress warnings from the MIDL generated code. -if CONFIG["CC_TYPE"] == "clang-cl": +if CONFIG['CC_TYPE'] == 'clang-cl': CFLAGS += [ - "-Wno-extern-initializer", - "-Wno-incompatible-pointer-types", - "-Wno-missing-braces", - "-Wno-unused-const-variable", + '-Wno-extern-initializer', + '-Wno-incompatible-pointer-types', + '-Wno-missing-braces', + '-Wno-unused-const-variable', ] diff --git a/accessible/ipc/extension/android/moz.build b/accessible/ipc/extension/android/moz.build index 50871e326bce724ee51d6d0c500d34b0fb04a9e1..ad4cbd6889a38e15b794007f25a776e6fcd6f017 100644 --- a/accessible/ipc/extension/android/moz.build +++ b/accessible/ipc/extension/android/moz.build @@ -4,26 +4,26 @@ # 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/. -if CONFIG["ACCESSIBILITY"]: - IPDL_SOURCES += ["PDocAccessiblePlatformExt.ipdl"] +if CONFIG['ACCESSIBILITY']: + IPDL_SOURCES += ['PDocAccessiblePlatformExt.ipdl'] EXPORTS.mozilla.a11y += [ - "DocAccessiblePlatformExtChild.h", - "DocAccessiblePlatformExtParent.h", + 'DocAccessiblePlatformExtChild.h', + 'DocAccessiblePlatformExtParent.h', ] SOURCES += [ - "DocAccessiblePlatformExtChild.cpp", - "DocAccessiblePlatformExtParent.cpp", + 'DocAccessiblePlatformExtChild.cpp', + 'DocAccessiblePlatformExtParent.cpp', ] LOCAL_INCLUDES += [ - "/accessible/android", - "/accessible/generic", - "/accessible/ipc/other", - "/widget/android", + '/accessible/android', + '/accessible/generic', + '/accessible/ipc/other', + '/widget/android', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' diff --git a/accessible/ipc/extension/mac/moz.build b/accessible/ipc/extension/mac/moz.build index e7a7bf3bf8de6fa1028f2435362b06cfa3078a5c..b3b75e12474f1437cec2c38aaa0a2529a4d7bca6 100644 --- a/accessible/ipc/extension/mac/moz.build +++ b/accessible/ipc/extension/mac/moz.build @@ -4,25 +4,25 @@ # 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/. -if CONFIG["ACCESSIBILITY"]: - IPDL_SOURCES += ["PDocAccessiblePlatformExt.ipdl"] +if CONFIG['ACCESSIBILITY']: + IPDL_SOURCES += ['PDocAccessiblePlatformExt.ipdl'] EXPORTS.mozilla.a11y += [ - "DocAccessiblePlatformExtChild.h", - "DocAccessiblePlatformExtParent.h", + 'DocAccessiblePlatformExtChild.h', + 'DocAccessiblePlatformExtParent.h', ] SOURCES += [ - "DocAccessiblePlatformExtChild.cpp", + 'DocAccessiblePlatformExtChild.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/ipc/other", - "/accessible/mac", + '/accessible/base', + '/accessible/generic', + '/accessible/ipc/other', + '/accessible/mac', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' diff --git a/accessible/ipc/extension/moz.build b/accessible/ipc/extension/moz.build index 3c82fd90b400b28909e0252e0988b1f2308071f4..c532dfc83be82926549046d37ee53981ed7cb344 100644 --- a/accessible/ipc/extension/moz.build +++ b/accessible/ipc/extension/moz.build @@ -4,11 +4,11 @@ # 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/. -toolkit = CONFIG["MOZ_WIDGET_TOOLKIT"] +toolkit = CONFIG['MOZ_WIDGET_TOOLKIT'] -if toolkit == "android": - DIRS += ["android"] -elif toolkit == "cocoa": - DIRS += ["mac"] +if toolkit == 'android': + DIRS += ['android'] +elif toolkit == 'cocoa': + DIRS += ['mac'] else: - DIRS += ["other"] + DIRS += ['other'] diff --git a/accessible/ipc/extension/other/moz.build b/accessible/ipc/extension/other/moz.build index dbbc98702c4ab5cc4d79b56f8307d3985beaff48..1a4030e4f45cf819fccb9841b3caa80afa28b306 100644 --- a/accessible/ipc/extension/other/moz.build +++ b/accessible/ipc/extension/other/moz.build @@ -4,14 +4,14 @@ # 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/. -if CONFIG["ACCESSIBILITY"]: - IPDL_SOURCES += ["PDocAccessiblePlatformExt.ipdl"] +if CONFIG['ACCESSIBILITY']: + IPDL_SOURCES += ['PDocAccessiblePlatformExt.ipdl'] EXPORTS.mozilla.a11y += [ - "DocAccessiblePlatformExtChild.h", - "DocAccessiblePlatformExtParent.h", + 'DocAccessiblePlatformExtChild.h', + 'DocAccessiblePlatformExtParent.h', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' diff --git a/accessible/ipc/moz.build b/accessible/ipc/moz.build index b50625e40ee00721c33e798748e88f0f365437a6..57d7310050264eca4ca2ec3a98f5c46259969914 100644 --- a/accessible/ipc/moz.build +++ b/accessible/ipc/moz.build @@ -4,65 +4,65 @@ # 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/. -if CONFIG["OS_ARCH"] == "WINNT": - DIRS += ["win"] +if CONFIG['OS_ARCH'] == 'WINNT': + DIRS += ['win'] LOCAL_INCLUDES += [ - "/accessible/ipc/win", - "/accessible/windows/ia2", - "/accessible/windows/msaa", + '/accessible/ipc/win', + '/accessible/windows/ia2', + '/accessible/windows/msaa', ] else: - DIRS += ["other", "extension"] + DIRS += ['other', 'extension'] LOCAL_INCLUDES += [ - "/accessible/ipc/other", + '/accessible/ipc/other', ] - if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': LOCAL_INCLUDES += [ - "/accessible/atk", + '/accessible/atk', ] - elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": + elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': LOCAL_INCLUDES += [ - "/accessible/mac", + '/accessible/mac', ] - elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": + elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': LOCAL_INCLUDES += [ - "/accessible/android", + '/accessible/android', ] else: LOCAL_INCLUDES += [ - "/accessible/other", + '/accessible/other', ] EXPORTS.mozilla.a11y += [ - "IPCTypes.h", + 'IPCTypes.h', ] -if CONFIG["CC_TYPE"] in ("clang", "gcc"): - CXXFLAGS += ["-Wno-error=shadow"] +if CONFIG['CC_TYPE'] in ('clang', 'gcc'): + CXXFLAGS += ['-Wno-error=shadow'] -if CONFIG["ACCESSIBILITY"]: +if CONFIG['ACCESSIBILITY']: EXPORTS.mozilla.a11y += [ - "DocAccessibleChildBase.h", - "DocAccessibleParent.h", - "ProxyAccessibleBase.h", - "ProxyAccessibleShared.h", + 'DocAccessibleChildBase.h', + 'DocAccessibleParent.h', + 'ProxyAccessibleBase.h', + 'ProxyAccessibleShared.h', ] UNIFIED_SOURCES += [ - "DocAccessibleChildBase.cpp", - "DocAccessibleParent.cpp", - "ProxyAccessibleBase.cpp", + 'DocAccessibleChildBase.cpp', + 'DocAccessibleParent.cpp', + 'ProxyAccessibleBase.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/xpcom", + '/accessible/base', + '/accessible/generic', + '/accessible/xpcom', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' # Add libFuzzer configuration directives -include("/tools/fuzzing/libfuzzer-config.mozbuild") +include('/tools/fuzzing/libfuzzer-config.mozbuild') diff --git a/accessible/ipc/other/moz.build b/accessible/ipc/other/moz.build index db386c6eb3e5e22fdb2706fa1c19d795f1350fc1..129b9dffee3d6395144af51157690d9d1ad53bac 100644 --- a/accessible/ipc/other/moz.build +++ b/accessible/ipc/other/moz.build @@ -5,48 +5,48 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. -if CONFIG["ACCESSIBILITY"]: - IPDL_SOURCES += ["PDocAccessible.ipdl"] +if CONFIG['ACCESSIBILITY']: + IPDL_SOURCES += ['PDocAccessible.ipdl'] EXPORTS.mozilla.a11y += [ - "DocAccessibleChild.h", - "ProxyAccessible.h", + 'DocAccessibleChild.h', + 'ProxyAccessible.h', ] SOURCES += [ - "DocAccessibleChild.cpp", - "ProxyAccessible.cpp", + 'DocAccessibleChild.cpp', + 'ProxyAccessible.cpp', ] LOCAL_INCLUDES += [ - "../../base", - "../../generic", - "../../xpcom", + '../../base', + '../../generic', + '../../xpcom', ] - if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': LOCAL_INCLUDES += [ - "/accessible/atk", + '/accessible/atk', ] - elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": + elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': LOCAL_INCLUDES += [ - "/accessible/mac", + '/accessible/mac', ] - elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": + elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': LOCAL_INCLUDES += [ - "/accessible/android", + '/accessible/android', ] else: LOCAL_INCLUDES += [ - "/accessible/other", + '/accessible/other', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') # Add libFuzzer configuration directives -include("/tools/fuzzing/libfuzzer-config.mozbuild") +include('/tools/fuzzing/libfuzzer-config.mozbuild') -if CONFIG["CC_TYPE"] in ("clang", "gcc"): - CXXFLAGS += ["-Wno-error=shadow"] +if CONFIG['CC_TYPE'] in ('clang', 'gcc'): + CXXFLAGS += ['-Wno-error=shadow'] -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' diff --git a/accessible/ipc/win/handler/moz.build b/accessible/ipc/win/handler/moz.build index 1c57026012dd813cb38f96c3c1261f75fe2c4c9b..4e13b363ca6a124f71f8ccc1245c0dc345e9711d 100644 --- a/accessible/ipc/win/handler/moz.build +++ b/accessible/ipc/win/handler/moz.build @@ -4,16 +4,16 @@ # 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/. -SharedLibrary("AccessibleHandler") +SharedLibrary('AccessibleHandler') EXPORTS.mozilla.a11y += [ - "AccessibleHandler.h", - "HandlerDataCleanup.h", + 'AccessibleHandler.h', + 'HandlerDataCleanup.h', ] LOCAL_INCLUDES += [ - "/accessible/interfaces/ia2", - "/ipc/mscom/oop", + '/accessible/interfaces/ia2', + '/ipc/mscom/oop', ] # We want to generate distinct UUIDs on a per-channel basis, so we need @@ -21,103 +21,79 @@ LOCAL_INCLUDES += [ # These defines allow us to separate local builds from automated builds, # as well as separate beta from release. flags = [] -if CONFIG["MOZ_UPDATE_CHANNEL"] == "default": - flags += ["-DUSE_LOCAL_UUID"] -elif CONFIG["MOZ_UPDATE_CHANNEL"] == "beta": - flags += ["-DUSE_BETA_UUID"] - -GeneratedFile( - "HandlerData.h", - "HandlerData_p.c", - "HandlerData_i.c", - "HandlerData_c.c", - "HandlerData_dlldata.c", - "HandlerData.tlb", - inputs=["HandlerData.idl"], - script="/build/midl.py", - entry_point="midl", - flags=flags - + [ - "-I", - TOPOBJDIR, - "-I", - TOPOBJDIR + "/dist/include", - "-I", - TOPSRCDIR + "/other-licenses/ia2", - "-I", - SRCDIR, - "-acf", - SRCDIR + "/HandlerData.acf", - "-dlldata", - OBJDIR + "/HandlerData_dlldata.c", - ], -) +if CONFIG['MOZ_UPDATE_CHANNEL'] == 'default': + flags += ['-DUSE_LOCAL_UUID'] +elif CONFIG['MOZ_UPDATE_CHANNEL'] == 'beta': + flags += ['-DUSE_BETA_UUID'] + +GeneratedFile('HandlerData.h', 'HandlerData_p.c', 'HandlerData_i.c', 'HandlerData_c.c', + 'HandlerData_dlldata.c', 'HandlerData.tlb', + inputs=['HandlerData.idl'], + script='/build/midl.py', entry_point='midl', + flags=flags + ['-I', TOPOBJDIR, '-I', TOPOBJDIR + '/dist/include', + '-I', TOPSRCDIR + '/other-licenses/ia2', '-I', SRCDIR, + '-acf', SRCDIR + '/HandlerData.acf', + '-dlldata', OBJDIR + '/HandlerData_dlldata.c']) SOURCES += [ - "!HandlerData_c.c", - "!HandlerData_dlldata.c", - "!HandlerData_i.c", - "!HandlerData_p.c", - "AccessibleHandler.cpp", - "AccessibleHandlerControl.cpp", - "HandlerChildEnumerator.cpp", - "HandlerRelation.cpp", - "HandlerTextLeaf.cpp", + '!HandlerData_c.c', + '!HandlerData_dlldata.c', + '!HandlerData_i.c', + '!HandlerData_p.c', + 'AccessibleHandler.cpp', + 'AccessibleHandlerControl.cpp', + 'HandlerChildEnumerator.cpp', + 'HandlerRelation.cpp', + 'HandlerTextLeaf.cpp', ] EXPORTS += [ - "!HandlerData.h", - "!HandlerData_i.c", + '!HandlerData.h', + '!HandlerData_i.c', ] # Give some symbols a unique name in each translation unit, to avoid # collisions caused by https://llvm.org/pr41817. -if CONFIG["CC_TYPE"] == "clang-cl": - SOURCES["!HandlerData_p.c"].flags += [ - "-DHandlerData__MIDL_ProcFormatString=HandlerData__MIDL_ProcFormatString__HandlerData_p" - ] - SOURCES["!HandlerData_p.c"].flags += [ - "-DHandlerData__MIDL_TypeFormatString=HandlerData__MIDL_TypeFormatString__HandlerData_p" - ] - for p in ("dlldata", "c", "i", "p"): - SOURCES["!HandlerData_%s.c" % p].flags += [ - "-DUserMarshalRoutines=UserMarshalRoutines__HandlerData_%s" % p - ] +if CONFIG['CC_TYPE'] == 'clang-cl': + SOURCES['!HandlerData_p.c'].flags += ['-DHandlerData__MIDL_ProcFormatString=HandlerData__MIDL_ProcFormatString__HandlerData_p'] + SOURCES['!HandlerData_p.c'].flags += ['-DHandlerData__MIDL_TypeFormatString=HandlerData__MIDL_TypeFormatString__HandlerData_p'] + for p in ('dlldata', 'c', 'i', 'p'): + SOURCES['!HandlerData_%s.c' % p].flags += ['-DUserMarshalRoutines=UserMarshalRoutines__HandlerData_%s' % p] -DEFFILE = "AccessibleHandler.def" +DEFFILE = 'AccessibleHandler.def' USE_LIBS += [ - "mscom_oop", + 'mscom_oop', ] OS_LIBS += [ - "rpcrt4", - "oleacc", + 'rpcrt4', + 'oleacc', ] -RCINCLUDE = "AccessibleHandler.rc" +RCINCLUDE = 'AccessibleHandler.rc' # Suppress warnings from the MIDL generated code. -if CONFIG["CC_TYPE"] == "clang-cl": +if CONFIG['CC_TYPE'] == 'clang-cl': CFLAGS += [ - "-Wno-extern-initializer", - "-Wno-incompatible-pointer-types", - "-Wno-missing-braces", - "-Wno-unused-const-variable", + '-Wno-extern-initializer', + '-Wno-incompatible-pointer-types', + '-Wno-missing-braces', + '-Wno-unused-const-variable', ] # Since we are defining our own COM entry points (DllRegisterServer et al), # but we still want to be able to delegate some work to the generated code, # we add the prefix "Proxy" to all of the generated counterparts. -DEFINES["ENTRY_PREFIX"] = "Proxy" -DEFINES["REGISTER_PROXY_DLL"] = True -LIBRARY_DEFINES["MOZ_MSCOM_REMARSHAL_NO_HANDLER"] = True +DEFINES['ENTRY_PREFIX'] = 'Proxy' +DEFINES['REGISTER_PROXY_DLL'] = True +LIBRARY_DEFINES['MOZ_MSCOM_REMARSHAL_NO_HANDLER'] = True # This DLL may be loaded into other processes, so we need static libs for # Windows 7 and Windows 8. USE_STATIC_LIBS = True -LIBRARY_DEFINES["UNICODE"] = True -LIBRARY_DEFINES["_UNICODE"] = True -LIBRARY_DEFINES["MOZ_NO_MOZALLOC"] = True +LIBRARY_DEFINES['UNICODE'] = True +LIBRARY_DEFINES['_UNICODE'] = True +LIBRARY_DEFINES['MOZ_NO_MOZALLOC'] = True DisableStlWrapping() diff --git a/accessible/ipc/win/moz.build b/accessible/ipc/win/moz.build index ab6b3beb7836e702a202b952fb829371c6c233e3..acc640b7292c906cf7dd48fcaf6b80c22bf74ddd 100644 --- a/accessible/ipc/win/moz.build +++ b/accessible/ipc/win/moz.build @@ -4,69 +4,67 @@ # 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/. -if CONFIG["COMPILE_ENVIRONMENT"] and CONFIG["ACCESSIBILITY"]: +if CONFIG['COMPILE_ENVIRONMENT'] and CONFIG['ACCESSIBILITY']: DIRS += [ - "handler", - "typelib", + 'handler', + 'typelib', ] -if CONFIG["ACCESSIBILITY"]: - IPDL_SOURCES += ["PDocAccessible.ipdl"] +if CONFIG['ACCESSIBILITY']: + IPDL_SOURCES += ['PDocAccessible.ipdl'] - if not CONFIG["HAVE_64BIT_BUILD"]: + if not CONFIG['HAVE_64BIT_BUILD']: EXPORTS += [ - "IAccessible32.manifest", + 'IAccessible32.manifest', ] EXPORTS += [ - "IAccessible64.manifest", + 'IAccessible64.manifest', ] EXPORTS.mozilla.a11y += [ - "COMPtrTypes.h", - "DocAccessibleChild.h", - "HandlerProvider.h", - "PlatformChild.h", - "ProxyAccessible.h", + 'COMPtrTypes.h', + 'DocAccessibleChild.h', + 'HandlerProvider.h', + 'PlatformChild.h', + 'ProxyAccessible.h' ] SOURCES += [ - "!./handler/HandlerData_c.c", - "COMPtrTypes.cpp", - "DocAccessibleChild.cpp", - "HandlerProvider.cpp", - "PlatformChild.cpp", - "ProxyAccessible.cpp", + '!./handler/HandlerData_c.c', + 'COMPtrTypes.cpp', + 'DocAccessibleChild.cpp', + 'HandlerProvider.cpp', + 'PlatformChild.cpp', + 'ProxyAccessible.cpp', ] # Give some symbols a unique name in each translation unit, to avoid # collisions caused by https://llvm.org/pr41817. - if CONFIG["CC_TYPE"] == "clang-cl": - SOURCES["!./handler/HandlerData_c.c"].flags += [ - "-DUserMarshalRoutines=UserMarshalRoutines__HandlerData_c" - ] + if CONFIG['CC_TYPE'] == 'clang-cl': + SOURCES['!./handler/HandlerData_c.c'].flags += ['-DUserMarshalRoutines=UserMarshalRoutines__HandlerData_c'] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/windows/ia2", - "/accessible/windows/msaa", - "/accessible/xpcom", + '/accessible/base', + '/accessible/generic', + '/accessible/windows/ia2', + '/accessible/windows/msaa', + '/accessible/xpcom', ] # Suppress warnings from the MIDL generated code. - if CONFIG["CC_TYPE"] == "clang-cl": + if CONFIG['CC_TYPE'] == 'clang-cl': CFLAGS += [ - "-Wno-extern-initializer", - "-Wno-incompatible-pointer-types", - "-Wno-missing-braces", - "-Wno-unused-const-variable", + '-Wno-extern-initializer', + '-Wno-incompatible-pointer-types', + '-Wno-missing-braces', + '-Wno-unused-const-variable', ] CXXFLAGS += [ - "-Wno-missing-braces", + '-Wno-missing-braces', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' diff --git a/accessible/ipc/win/typelib/moz.build b/accessible/ipc/win/typelib/moz.build index 2992deda1a5b351e4fffed667a7ae178641731a8..5d5496b81e75580bfc62b248157bdb59202ff223 100644 --- a/accessible/ipc/win/typelib/moz.build +++ b/accessible/ipc/win/typelib/moz.build @@ -5,12 +5,9 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. FINAL_TARGET_FILES += [ - "!Accessible.tlb", + '!Accessible.tlb', ] -GeneratedFile( - "Accessible.tlb", - inputs=["Accessible.idl"], - script="/build/midl.py", - entry_point="midl", -) +GeneratedFile('Accessible.tlb', + inputs=['Accessible.idl'], + script='/build/midl.py', entry_point='midl') diff --git a/accessible/mac/SelectorMapGen.py b/accessible/mac/SelectorMapGen.py index 5864120fbc4167816ab9d12d667730b3b5fae4d8..65ca1e3a15a6cfbcbc7d506bcbbad9dd3dea9a05 100755 --- a/accessible/mac/SelectorMapGen.py +++ b/accessible/mac/SelectorMapGen.py @@ -28,9 +28,8 @@ def gen_mm(fd, protocol_file): fd.write("#import \n\n") fd.write("namespace mozilla {\nnamespace a11y {\nnamespace mac {\n\n") - sections = re.findall( - r"#pragma mark - (\w+)\n(.*?)(?=(?:#pragma mark|@end))", protocol, re.DOTALL - ) + sections = re.findall(r"#pragma mark - (\w+)\n(.*?)(?=(?:#pragma mark|@end))", + protocol, re.DOTALL) for name, text in sections: write_map(fd, name, text) @@ -39,9 +38,8 @@ def gen_mm(fd, protocol_file): def gen_h(fd, protocol_file): protocol = open(protocol_file).read() - sections = re.findall( - r"#pragma mark - (\w+)\n(.*?)(?=(?:#pragma mark|@end))", protocol, re.DOTALL - ) + sections = re.findall(r"#pragma mark - (\w+)\n(.*?)(?=(?:#pragma mark|@end))", + protocol, re.DOTALL) fd.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n") fd.write("#ifndef _MacSelectorMap_H_\n") @@ -57,7 +55,6 @@ def gen_h(fd, protocol_file): # For debugging if __name__ == "__main__": import sys - gen_mm(sys.stdout, "accessible/mac/MOXAccessibleProtocol.h") gen_h(sys.stdout, "accessible/mac/MOXAccessibleProtocol.h") diff --git a/accessible/mac/moz.build b/accessible/mac/moz.build index 7fafafee1986791b53bf6813683398e9eb5b58bc..8f39d28b98f51ba57b4482602b3bba95484e5b10 100644 --- a/accessible/mac/moz.build +++ b/accessible/mac/moz.build @@ -5,69 +5,63 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXPORTS += [ - "mozAccessibleProtocol.h", + 'mozAccessibleProtocol.h', ] EXPORTS.mozilla.a11y += [ - "AccessibleWrap.h", - "HyperTextAccessibleWrap.h", - "RangeTypes.h", + 'AccessibleWrap.h', + 'HyperTextAccessibleWrap.h', + 'RangeTypes.h', ] UNIFIED_SOURCES += [ - "AccessibleWrap.mm", - "DocAccessibleWrap.mm", - "GeckoTextMarker.mm", - "HyperTextAccessibleWrap.mm", - "MacUtils.mm", - "MOXAccessibleBase.mm", - "MOXLandmarkAccessibles.mm", - "MOXMathAccessibles.mm", - "MOXSearchInfo.mm", - "MOXTextMarkerDelegate.mm", - "MOXWebAreaAccessible.mm", - "mozAccessible.mm", - "mozActionElements.mm", - "mozHTMLAccessible.mm", - "mozRootAccessible.mm", - "mozSelectableElements.mm", - "mozTableAccessible.mm", - "mozTextAccessible.mm", - "Platform.mm", - "RootAccessibleWrap.mm", - "RotorRules.mm", + 'AccessibleWrap.mm', + 'DocAccessibleWrap.mm', + 'GeckoTextMarker.mm', + 'HyperTextAccessibleWrap.mm', + 'MacUtils.mm', + 'MOXAccessibleBase.mm', + 'MOXLandmarkAccessibles.mm', + 'MOXMathAccessibles.mm', + 'MOXSearchInfo.mm', + 'MOXTextMarkerDelegate.mm', + 'MOXWebAreaAccessible.mm', + 'mozAccessible.mm', + 'mozActionElements.mm', + 'mozHTMLAccessible.mm', + 'mozRootAccessible.mm', + 'mozSelectableElements.mm', + 'mozTableAccessible.mm', + 'mozTextAccessible.mm', + 'Platform.mm', + 'RootAccessibleWrap.mm', + 'RotorRules.mm', ] SOURCES += [ - "!MacSelectorMap.mm", + '!MacSelectorMap.mm', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/html", - "/accessible/ipc", - "/accessible/ipc/other", - "/accessible/xul", - "/layout/generic", - "/layout/xul", - "/widget", - "/widget/cocoa", + '/accessible/base', + '/accessible/generic', + '/accessible/html', + '/accessible/ipc', + '/accessible/ipc/other', + '/accessible/xul', + '/layout/generic', + '/layout/xul', + '/widget', + '/widget/cocoa', ] -GeneratedFile( - "MacSelectorMap.h", - script="/accessible/mac/SelectorMapGen.py", - entry_point="gen_h", - inputs=["MOXAccessibleProtocol.h"], -) -GeneratedFile( - "MacSelectorMap.mm", - script="/accessible/mac/SelectorMapGen.py", - entry_point="gen_mm", - inputs=["MOXAccessibleProtocol.h"], -) +GeneratedFile('MacSelectorMap.h', + script='/accessible/mac/SelectorMapGen.py', entry_point='gen_h', + inputs=['MOXAccessibleProtocol.h']) +GeneratedFile('MacSelectorMap.mm', + script='/accessible/mac/SelectorMapGen.py', entry_point='gen_mm', + inputs=['MOXAccessibleProtocol.h']) -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') diff --git a/accessible/moz.build b/accessible/moz.build index f0ddf25cb39612e1fa66583a12a5ddde8ab55c45..2fc823a6781f87839d82df6f41f475c85cfd3bd1 100644 --- a/accessible/moz.build +++ b/accessible/moz.build @@ -4,39 +4,46 @@ # 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/. -toolkit = CONFIG["MOZ_WIDGET_TOOLKIT"] +toolkit = CONFIG['MOZ_WIDGET_TOOLKIT'] -if toolkit == "gtk": - DIRS += ["atk"] -elif toolkit == "windows": - DIRS += ["windows"] -elif toolkit == "cocoa": - DIRS += ["mac"] -elif toolkit == "android": - DIRS += ["android"] +if toolkit == 'gtk': + DIRS += ['atk'] +elif toolkit == 'windows': + DIRS += ['windows'] +elif toolkit == 'cocoa': + DIRS += ['mac'] +elif toolkit == 'android': + DIRS += ['android'] else: - DIRS += ["other"] + DIRS += ['other'] -DIRS += ["aom", "base", "generic", "html", "interfaces", "ipc", "xpcom"] +DIRS += [ 'aom', + 'base', + 'generic', + 'html', + 'interfaces', + 'ipc', + 'xpcom' +] -if CONFIG["MOZ_XUL"]: - DIRS += ["xul"] +if CONFIG['MOZ_XUL']: + DIRS += ['xul'] -TEST_DIRS += ["tests/mochitest"] +TEST_DIRS += ['tests/mochitest'] BROWSER_CHROME_MANIFESTS += [ - "tests/browser/bounds/browser.ini", - "tests/browser/browser.ini", - "tests/browser/e10s/browser.ini", - "tests/browser/events/browser.ini", - "tests/browser/fission/browser.ini", - "tests/browser/general/browser.ini", - "tests/browser/hittest/browser.ini", - "tests/browser/mac/browser.ini", - "tests/browser/scroll/browser.ini", - "tests/browser/states/browser.ini", - "tests/browser/telemetry/browser.ini", - "tests/browser/tree/browser.ini", + 'tests/browser/bounds/browser.ini', + 'tests/browser/browser.ini', + 'tests/browser/e10s/browser.ini', + 'tests/browser/events/browser.ini', + 'tests/browser/fission/browser.ini', + 'tests/browser/general/browser.ini', + 'tests/browser/hittest/browser.ini', + 'tests/browser/mac/browser.ini', + 'tests/browser/scroll/browser.ini', + 'tests/browser/states/browser.ini', + 'tests/browser/telemetry/browser.ini', + 'tests/browser/tree/browser.ini' ] with Files("**"): diff --git a/accessible/other/moz.build b/accessible/other/moz.build index 1e4fc8cabc3bfe288411d447778c284237ffab9b..4887a4abb6970186c2746013426c3480ad9f81bc 100644 --- a/accessible/other/moz.build +++ b/accessible/other/moz.build @@ -5,23 +5,23 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXPORTS.mozilla.a11y += [ - "AccessibleWrap.h", - "HyperTextAccessibleWrap.h", + 'AccessibleWrap.h', + 'HyperTextAccessibleWrap.h', ] SOURCES += [ - "AccessibleWrap.cpp", - "Platform.cpp", + 'AccessibleWrap.cpp', + 'Platform.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/html", - "/accessible/xul", + '/accessible/base', + '/accessible/generic', + '/accessible/html', + '/accessible/xul', ] -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' -if CONFIG["CC_TYPE"] in ("clang", "gcc"): - CXXFLAGS += ["-Wno-error=shadow"] +if CONFIG['CC_TYPE'] in ('clang', 'gcc'): + CXXFLAGS += ['-Wno-error=shadow'] diff --git a/accessible/tests/mochitest/moz.build b/accessible/tests/mochitest/moz.build index d3efffb62b927222b84e7d45b7e66e705734566f..ad92136301ffdefcb9251f2a09625fdbe1a7b227 100644 --- a/accessible/tests/mochitest/moz.build +++ b/accessible/tests/mochitest/moz.build @@ -5,33 +5,33 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. A11Y_MANIFESTS += [ - "a11y.ini", - "actions/a11y.ini", - "aom/a11y.ini", - "attributes/a11y.ini", - "bounds/a11y.ini", - "editabletext/a11y.ini", - "elm/a11y.ini", - "events/a11y.ini", - "events/docload/a11y.ini", - "focus/a11y.ini", - "hittest/a11y.ini", - "hyperlink/a11y.ini", - "hypertext/a11y.ini", - "name/a11y.ini", - "pivot/a11y.ini", - "relations/a11y.ini", - "role/a11y.ini", - "scroll/a11y.ini", - "selectable/a11y.ini", - "states/a11y.ini", - "table/a11y.ini", - "text/a11y.ini", - "textattrs/a11y.ini", - "textcaret/a11y.ini", - "textrange/a11y.ini", - "textselection/a11y.ini", - "tree/a11y.ini", - "treeupdate/a11y.ini", - "value/a11y.ini", + 'a11y.ini', + 'actions/a11y.ini', + 'aom/a11y.ini', + 'attributes/a11y.ini', + 'bounds/a11y.ini', + 'editabletext/a11y.ini', + 'elm/a11y.ini', + 'events/a11y.ini', + 'events/docload/a11y.ini', + 'focus/a11y.ini', + 'hittest/a11y.ini', + 'hyperlink/a11y.ini', + 'hypertext/a11y.ini', + 'name/a11y.ini', + 'pivot/a11y.ini', + 'relations/a11y.ini', + 'role/a11y.ini', + 'scroll/a11y.ini', + 'selectable/a11y.ini', + 'states/a11y.ini', + 'table/a11y.ini', + 'text/a11y.ini', + 'textattrs/a11y.ini', + 'textcaret/a11y.ini', + 'textrange/a11y.ini', + 'textselection/a11y.ini', + 'tree/a11y.ini', + 'treeupdate/a11y.ini', + 'value/a11y.ini', ] diff --git a/accessible/windows/ia2/moz.build b/accessible/windows/ia2/moz.build index 7357fe48a87102b5ad04987f305bf3a8a3e7d458..ed8096178fbe594565cd86b6f3ab0556d76bea47 100644 --- a/accessible/windows/ia2/moz.build +++ b/accessible/windows/ia2/moz.build @@ -5,54 +5,54 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXPORTS += [ - "ia2Accessible.h", - "ia2AccessibleAction.h", - "ia2AccessibleComponent.h", - "ia2AccessibleEditableText.h", - "ia2AccessibleHyperlink.h", - "ia2AccessibleHypertext.h", - "ia2AccessibleText.h", - "ia2AccessibleValue.h", + 'ia2Accessible.h', + 'ia2AccessibleAction.h', + 'ia2AccessibleComponent.h', + 'ia2AccessibleEditableText.h', + 'ia2AccessibleHyperlink.h', + 'ia2AccessibleHypertext.h', + 'ia2AccessibleText.h', + 'ia2AccessibleValue.h', ] UNIFIED_SOURCES += [ - "ia2Accessible.cpp", - "ia2AccessibleAction.cpp", - "ia2AccessibleComponent.cpp", - "ia2AccessibleEditableText.cpp", - "ia2AccessibleHyperlink.cpp", - "ia2AccessibleHypertext.cpp", - "ia2AccessibleImage.cpp", - "ia2AccessibleRelation.cpp", - "ia2AccessibleText.cpp", - "ia2AccessibleValue.cpp", + 'ia2Accessible.cpp', + 'ia2AccessibleAction.cpp', + 'ia2AccessibleComponent.cpp', + 'ia2AccessibleEditableText.cpp', + 'ia2AccessibleHyperlink.cpp', + 'ia2AccessibleHypertext.cpp', + 'ia2AccessibleImage.cpp', + 'ia2AccessibleRelation.cpp', + 'ia2AccessibleText.cpp', + 'ia2AccessibleValue.cpp', ] # These files cannot be built in unified mode because they both include # AccessibleTable2_i.c. SOURCES += [ - "ia2AccessibleTable.cpp", - "ia2AccessibleTableCell.cpp", + 'ia2AccessibleTable.cpp', + 'ia2AccessibleTableCell.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/html", - "/accessible/windows", - "/accessible/windows/msaa", - "/accessible/xpcom", - "/accessible/xul", + '/accessible/base', + '/accessible/generic', + '/accessible/html', + '/accessible/windows', + '/accessible/windows/msaa', + '/accessible/xpcom', + '/accessible/xul', ] -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' # The Windows MIDL code generator creates things like: # # #endif !_MIDL_USE_GUIDDEF_ # # which clang-cl complains about. MSVC doesn't, so turn this warning off. -if CONFIG["CC_TYPE"] == "clang-cl": - CXXFLAGS += ["-Wno-extra-tokens"] +if CONFIG['CC_TYPE'] == 'clang-cl': + CXXFLAGS += ['-Wno-extra-tokens'] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') diff --git a/accessible/windows/moz.build b/accessible/windows/moz.build index c5c2f9ff2fed7d293719b49f96c72ceb7995b41a..4a62560a43c3cb94cea74d040e44ece291fc1b2c 100644 --- a/accessible/windows/moz.build +++ b/accessible/windows/moz.build @@ -4,8 +4,8 @@ # 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/. -DIRS += ["msaa", "ia2", "sdn", "uia"] +DIRS += ['msaa', 'ia2', 'sdn', 'uia'] EXPORTS.mozilla.a11y += [ - "ProxyWrappers.h", + 'ProxyWrappers.h', ] diff --git a/accessible/windows/msaa/moz.build b/accessible/windows/msaa/moz.build index 5b8163f2fd940753856a3331b7066af5c3ce37e3..9b91e0f6cd1b13d97c517574e32de4df50da3848 100644 --- a/accessible/windows/msaa/moz.build +++ b/accessible/windows/msaa/moz.build @@ -5,71 +5,71 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXPORTS += [ - "IUnknownImpl.h", + 'IUnknownImpl.h', ] EXPORTS.mozilla.a11y += [ - "AccessibleWrap.h", - "Compatibility.h", - "HyperTextAccessibleWrap.h", - "LazyInstantiator.h", - "MsaaIdGenerator.h", - "nsWinUtils.h", + 'AccessibleWrap.h', + 'Compatibility.h', + 'HyperTextAccessibleWrap.h', + 'LazyInstantiator.h', + 'MsaaIdGenerator.h', + 'nsWinUtils.h', ] UNIFIED_SOURCES += [ - "AccessibleWrap.cpp", - "ApplicationAccessibleWrap.cpp", - "ARIAGridAccessibleWrap.cpp", - "Compatibility.cpp", - "CompatibilityUIA.cpp", - "DocAccessibleWrap.cpp", - "EnumVariant.cpp", - "GeckoCustom.cpp", - "HTMLTableAccessibleWrap.cpp", - "HTMLWin32ObjectAccessible.cpp", - "HyperTextAccessibleWrap.cpp", - "ImageAccessibleWrap.cpp", - "IUnknownImpl.cpp", - "MsaaIdGenerator.cpp", - "nsWinUtils.cpp", - "Platform.cpp", - "RootAccessibleWrap.cpp", - "TextLeafAccessibleWrap.cpp", + 'AccessibleWrap.cpp', + 'ApplicationAccessibleWrap.cpp', + 'ARIAGridAccessibleWrap.cpp', + 'Compatibility.cpp', + 'CompatibilityUIA.cpp', + 'DocAccessibleWrap.cpp', + 'EnumVariant.cpp', + 'GeckoCustom.cpp', + 'HTMLTableAccessibleWrap.cpp', + 'HTMLWin32ObjectAccessible.cpp', + 'HyperTextAccessibleWrap.cpp', + 'ImageAccessibleWrap.cpp', + 'IUnknownImpl.cpp', + 'MsaaIdGenerator.cpp', + 'nsWinUtils.cpp', + 'Platform.cpp', + 'RootAccessibleWrap.cpp', + 'TextLeafAccessibleWrap.cpp', ] SOURCES += [ # This file cannot be built in unified mode because it redefines _WIN32_WINNT - "LazyInstantiator.cpp", + 'LazyInstantiator.cpp', # This file cannot be built in unified mode because it includes ISimpleDOMNode_i.c. - "ServiceProvider.cpp", + 'ServiceProvider.cpp', ] OS_LIBS += [ - "ntdll", + 'ntdll', ] -if CONFIG["MOZ_XUL"]: +if CONFIG['MOZ_XUL']: UNIFIED_SOURCES += [ - "XULListboxAccessibleWrap.cpp", - "XULMenuAccessibleWrap.cpp", - "XULTreeGridAccessibleWrap.cpp", + 'XULListboxAccessibleWrap.cpp', + 'XULMenuAccessibleWrap.cpp', + 'XULTreeGridAccessibleWrap.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/html", - "/accessible/ipc", - "/accessible/ipc/win", - "/accessible/windows", - "/accessible/windows/ia2", - "/accessible/windows/sdn", - "/accessible/windows/uia", - "/accessible/xpcom", - "/accessible/xul", - "/dom/base", - "/layout/style", + '/accessible/base', + '/accessible/generic', + '/accessible/html', + '/accessible/ipc', + '/accessible/ipc/win', + '/accessible/windows', + '/accessible/windows/ia2', + '/accessible/windows/sdn', + '/accessible/windows/uia', + '/accessible/xpcom', + '/accessible/xul', + '/dom/base', + '/layout/style', ] # The Windows MIDL code generator creates things like: @@ -77,9 +77,9 @@ LOCAL_INCLUDES += [ # #endif !_MIDL_USE_GUIDDEF_ # # which clang-cl complains about. MSVC doesn't, so turn this warning off. -if CONFIG["CC_TYPE"] == "clang-cl": - CXXFLAGS += ["-Wno-extra-tokens"] +if CONFIG['CC_TYPE'] == 'clang-cl': + CXXFLAGS += ['-Wno-extra-tokens'] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' diff --git a/accessible/windows/sdn/moz.build b/accessible/windows/sdn/moz.build index 8d76b7482ef355a0d49bede14a33b05b2728293e..ae0d5e20dcb0c579fac78551a06796742b148521 100644 --- a/accessible/windows/sdn/moz.build +++ b/accessible/windows/sdn/moz.build @@ -5,20 +5,20 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. UNIFIED_SOURCES += [ - "sdnAccessible.cpp", - "sdnDocAccessible.cpp", - "sdnTextAccessible.cpp", + 'sdnAccessible.cpp', + 'sdnDocAccessible.cpp', + 'sdnTextAccessible.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/html", - "/accessible/windows/msaa", - "/accessible/xpcom", - "/accessible/xul", + '/accessible/base', + '/accessible/generic', + '/accessible/html', + '/accessible/windows/msaa', + '/accessible/xpcom', + '/accessible/xul', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' diff --git a/accessible/windows/uia/moz.build b/accessible/windows/uia/moz.build index 058aacc579efa2f1d0a3980314918c0b7666f117..afc150e11989dbbfe054d5c0ac7d5a9832a018ba 100644 --- a/accessible/windows/uia/moz.build +++ b/accessible/windows/uia/moz.build @@ -5,18 +5,18 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. SOURCES += [ - "uiaRawElmProvider.cpp", + 'uiaRawElmProvider.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/html", - "/accessible/windows/msaa", - "/accessible/xpcom", - "/accessible/xul", + '/accessible/base', + '/accessible/generic', + '/accessible/html', + '/accessible/windows/msaa', + '/accessible/xpcom', + '/accessible/xul', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' diff --git a/accessible/xpcom/AccEventGen.py b/accessible/xpcom/AccEventGen.py index ef253bd2a91491393fda1c326d4425dcc1a85a2e..633063031dc1cbb393265d5af81fc02ff5c3a5b8 100755 --- a/accessible/xpcom/AccEventGen.py +++ b/accessible/xpcom/AccEventGen.py @@ -14,13 +14,8 @@ from xpidl import xpidl # Load the webidl configuration file. glbl = {} -exec( - open( - mozpath.join(buildconfig.topsrcdir, "dom", "bindings", "Bindings.conf") - ).read(), - glbl, -) -webidlconfig = glbl["DOMInterfaces"] +exec(open(mozpath.join(buildconfig.topsrcdir, 'dom', 'bindings', 'Bindings.conf')).read(), glbl) +webidlconfig = glbl['DOMInterfaces'] # Instantiate the parser. p = xpidl.IDLParser() @@ -31,14 +26,13 @@ def findIDL(includePath, interfaceFileName): path = mozpath.join(d, interfaceFileName) if os.path.exists(path): return path - raise BaseException( - "No IDL file found for interface %s " - "in include path %r" % (interfaceFileName, includePath) - ) + raise BaseException("No IDL file found for interface %s " + "in include path %r" + % (interfaceFileName, includePath)) def loadEventIDL(parser, includePath, eventname): - eventidl = "nsIAccessible%s.idl" % eventname + eventidl = ("nsIAccessible%s.idl" % eventname) idlFile = findIDL(includePath, eventidl) idl = p.parse(open(idlFile).read(), idlFile) idl.resolve(includePath, p, webidlconfig) @@ -49,7 +43,7 @@ class Configuration: def __init__(self, filename): config = {} exec(open(filename).read(), config) - self.simple_events = config.get("simple_events", []) + self.simple_events = config.get('simple_events', []) def firstCap(str): @@ -57,28 +51,26 @@ def firstCap(str): def writeAttributeParams(a): - return "%s a%s" % (a.realtype.nativeType("in"), firstCap(a.name)) + return ("%s a%s" % (a.realtype.nativeType('in'), firstCap(a.name))) def print_header_file(fd, conf, incdirs): idl_paths = set() fd.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n") - fd.write( - "#ifndef _mozilla_a11y_generated_AccEvents_h_\n" - "#define _mozilla_a11y_generated_AccEvents_h_\n\n" - ) - fd.write('#include "nscore.h"\n') - fd.write('#include "nsCOMPtr.h"\n') - fd.write('#include "nsCycleCollectionParticipant.h"\n') - fd.write('#include "nsString.h"\n') + fd.write("#ifndef _mozilla_a11y_generated_AccEvents_h_\n" + "#define _mozilla_a11y_generated_AccEvents_h_\n\n") + fd.write("#include \"nscore.h\"\n") + fd.write("#include \"nsCOMPtr.h\"\n") + fd.write("#include \"nsCycleCollectionParticipant.h\"\n") + fd.write("#include \"nsString.h\"\n") for e in conf.simple_events: - fd.write('#include "nsIAccessible%s.h"\n' % e) + fd.write("#include \"nsIAccessible%s.h\"\n" % e) for e in conf.simple_events: idl, idl_path = loadEventIDL(p, incdirs, e) idl_paths.add(idl_path) for iface in filter(lambda p: p.kind == "interface", idl.productions): - classname = "xpcAcc%s" % e + classname = ("xpcAcc%s" % e) baseinterfaces = interfaces(iface) fd.write("\nclass %s final : public %s\n" % (classname, iface.name)) @@ -122,7 +114,7 @@ def interfaceAttributeTypes(idl): def print_cpp(idl, fd, conf, eventname): for p in idl.productions: - if p.kind == "interface": + if p.kind == 'interface': write_cpp(eventname, p, fd) @@ -143,7 +135,7 @@ def print_cpp_file(fd, conf, incdirs): types.extend(interfaceAttributeTypes(idl)) for c in types: - fd.write('#include "%s.h"\n' % c) + fd.write("#include \"%s.h\"\n" % c) fd.write("\n") for e in conf.simple_events: @@ -155,40 +147,37 @@ def print_cpp_file(fd, conf, incdirs): def attributeVariableTypeAndName(a): - if a.realtype.nativeType("in").endswith("*"): - l = [ - "nsCOMPtr<%s> m%s;" - % (a.realtype.nativeType("in").strip("* "), firstCap(a.name)) - ] - elif a.realtype.nativeType("in").count("nsAString"): + if a.realtype.nativeType('in').endswith('*'): + l = ["nsCOMPtr<%s> m%s;" % (a.realtype.nativeType('in').strip('* '), + firstCap(a.name))] + elif a.realtype.nativeType('in').count("nsAString"): l = ["nsString m%s;" % firstCap(a.name)] - elif a.realtype.nativeType("in").count("nsACString"): + elif a.realtype.nativeType('in').count("nsACString"): l = ["nsCString m%s;" % firstCap(a.name)] else: - l = ["%sm%s;" % (a.realtype.nativeType("in"), firstCap(a.name))] + l = ["%sm%s;" % (a.realtype.nativeType('in'), + firstCap(a.name))] return ", ".join(l) def writeAttributeGetter(fd, classname, a): fd.write("NS_IMETHODIMP\n") fd.write("%s::Get%s(" % (classname, firstCap(a.name))) - if a.realtype.nativeType("in").endswith("*"): - fd.write( - "%s** a%s" % (a.realtype.nativeType("in").strip("* "), firstCap(a.name)) - ) - elif a.realtype.nativeType("in").count("nsAString"): + if a.realtype.nativeType('in').endswith('*'): + fd.write("%s** a%s" % (a.realtype.nativeType('in').strip('* '), firstCap(a.name))) + elif a.realtype.nativeType('in').count("nsAString"): fd.write("nsAString& a%s" % firstCap(a.name)) - elif a.realtype.nativeType("in").count("nsACString"): + elif a.realtype.nativeType('in').count("nsACString"): fd.write("nsACString& a%s" % firstCap(a.name)) else: - fd.write("%s*a%s" % (a.realtype.nativeType("in"), firstCap(a.name))) + fd.write("%s*a%s" % (a.realtype.nativeType('in'), firstCap(a.name))) fd.write(")\n") fd.write("{\n") - if a.realtype.nativeType("in").endswith("*"): + if a.realtype.nativeType('in').endswith('*'): fd.write(" NS_IF_ADDREF(*a%s = m%s);\n" % (firstCap(a.name), firstCap(a.name))) - elif a.realtype.nativeType("in").count("nsAString"): + elif a.realtype.nativeType('in').count("nsAString"): fd.write(" a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name))) - elif a.realtype.nativeType("in").count("nsACString"): + elif a.realtype.nativeType('in').count("nsACString"): fd.write(" a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name))) else: fd.write(" *a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name))) @@ -218,9 +207,7 @@ def allAttributes(iface): def write_cpp(eventname, iface, fd): classname = "xpcAcc%s" % eventname attributes = allAttributes(iface) - ccattributes = filter( - lambda m: m.realtype.nativeType("in").endswith("*"), attributes - ) + ccattributes = filter(lambda m: m.realtype.nativeType('in').endswith('*'), attributes) fd.write("NS_IMPL_CYCLE_COLLECTION(%s" % classname) for c in ccattributes: fd.write(", m%s" % firstCap(c.name)) @@ -241,8 +228,8 @@ def write_cpp(eventname, iface, fd): def get_conf(conf_file): conf = Configuration(conf_file) inc_dir = [ - mozpath.join(buildconfig.topsrcdir, "accessible", "interfaces"), - mozpath.join(buildconfig.topsrcdir, "xpcom", "base"), + mozpath.join(buildconfig.topsrcdir, 'accessible', 'interfaces'), + mozpath.join(buildconfig.topsrcdir, 'xpcom', 'base'), ] return conf, inc_dir @@ -251,8 +238,6 @@ def gen_files(fd, conf_file): deps = set() conf, inc_dir = get_conf(conf_file) deps.update(print_header_file(fd, conf, inc_dir)) - with open( - os.path.join(os.path.dirname(fd.name), "xpcAccEvents.cpp"), "w" - ) as cpp_fd: + with open(os.path.join(os.path.dirname(fd.name), 'xpcAccEvents.cpp'), 'w') as cpp_fd: deps.update(print_cpp_file(cpp_fd, conf, inc_dir)) return deps diff --git a/accessible/xpcom/moz.build b/accessible/xpcom/moz.build index f45f3abcb2307c155ca0288a6fe14981c3d7351a..97d906eb72a24db1dd91c6757344284d08a49b64 100644 --- a/accessible/xpcom/moz.build +++ b/accessible/xpcom/moz.build @@ -5,77 +5,76 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. UNIFIED_SOURCES += [ - "nsAccessibleRelation.cpp", - "xpcAccessibilityService.cpp", - "xpcAccessible.cpp", - "xpcAccessibleApplication.cpp", - "xpcAccessibleDocument.cpp", - "xpcAccessibleGeneric.cpp", - "xpcAccessibleHyperLink.cpp", - "xpcAccessibleHyperText.cpp", - "xpcAccessibleImage.cpp", - "xpcAccessibleSelectable.cpp", - "xpcAccessibleTable.cpp", - "xpcAccessibleTableCell.cpp", - "xpcAccessibleTextRange.cpp", - "xpcAccessibleValue.cpp", + 'nsAccessibleRelation.cpp', + 'xpcAccessibilityService.cpp', + 'xpcAccessible.cpp', + 'xpcAccessibleApplication.cpp', + 'xpcAccessibleDocument.cpp', + 'xpcAccessibleGeneric.cpp', + 'xpcAccessibleHyperLink.cpp', + 'xpcAccessibleHyperText.cpp', + 'xpcAccessibleImage.cpp', + 'xpcAccessibleSelectable.cpp', + 'xpcAccessibleTable.cpp', + 'xpcAccessibleTableCell.cpp', + 'xpcAccessibleTextRange.cpp', + 'xpcAccessibleValue.cpp', ] SOURCES += [ - "!xpcAccEvents.cpp", + '!xpcAccEvents.cpp', ] EXPORTS += [ - "!xpcAccEvents.h", - "xpcAccessibilityService.h", + '!xpcAccEvents.h', + 'xpcAccessibilityService.h', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", + '/accessible/base', + '/accessible/generic', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': LOCAL_INCLUDES += [ - "/accessible/atk", + '/accessible/atk', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': LOCAL_INCLUDES += [ - "/accessible/windows/msaa", + '/accessible/windows/msaa', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': LOCAL_INCLUDES += [ - "/accessible/ipc", - "/accessible/ipc/other", - "/accessible/mac", + '/accessible/ipc', + '/accessible/ipc/other', + '/accessible/mac', + ] + UNIFIED_SOURCES += [ + 'xpcAccessibleMacInterface.mm' ] - UNIFIED_SOURCES += ["xpcAccessibleMacInterface.mm"] EXPORTS += [ - "xpcAccessibleMacInterface.h", + 'xpcAccessibleMacInterface.h', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': LOCAL_INCLUDES += [ - "/accessible/android", + '/accessible/android', ] else: LOCAL_INCLUDES += [ - "/accessible/other", + '/accessible/other', ] GeneratedFile( - "xpcAccEvents.h", - "xpcAccEvents.cpp", - script="AccEventGen.py", - entry_point="gen_files", + 'xpcAccEvents.h', 'xpcAccEvents.cpp', + script='AccEventGen.py', entry_point='gen_files', inputs=[ - "AccEvents.conf", - ], -) + 'AccEvents.conf', + ]) -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -if CONFIG["CC_TYPE"] in ("clang", "gcc"): - CXXFLAGS += ["-Wno-error=shadow"] +if CONFIG['CC_TYPE'] in ('clang', 'gcc'): + CXXFLAGS += ['-Wno-error=shadow'] diff --git a/accessible/xul/moz.build b/accessible/xul/moz.build index 72a55cccea083bfe12a8aab6889ebb413114321f..aa816eef0513f64ba148cda790b7ef42a6d1bc02 100644 --- a/accessible/xul/moz.build +++ b/accessible/xul/moz.build @@ -5,55 +5,55 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. UNIFIED_SOURCES += [ - "XULAlertAccessible.cpp", - "XULComboboxAccessible.cpp", - "XULElementAccessibles.cpp", - "XULFormControlAccessible.cpp", - "XULListboxAccessible.cpp", - "XULMenuAccessible.cpp", - "XULSelectControlAccessible.cpp", - "XULTabAccessible.cpp", - "XULTreeAccessible.cpp", - "XULTreeGridAccessible.cpp", + 'XULAlertAccessible.cpp', + 'XULComboboxAccessible.cpp', + 'XULElementAccessibles.cpp', + 'XULFormControlAccessible.cpp', + 'XULListboxAccessible.cpp', + 'XULMenuAccessible.cpp', + 'XULSelectControlAccessible.cpp', + 'XULTabAccessible.cpp', + 'XULTreeAccessible.cpp', + 'XULTreeGridAccessible.cpp', ] LOCAL_INCLUDES += [ - "/accessible/base", - "/accessible/generic", - "/accessible/html", - "/accessible/xpcom", - "/dom/base", - "/dom/xul", - "/layout/generic", - "/layout/xul", - "/layout/xul/tree", + '/accessible/base', + '/accessible/generic', + '/accessible/html', + '/accessible/xpcom', + '/dom/base', + '/dom/xul', + '/layout/generic', + '/layout/xul', + '/layout/xul/tree', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': LOCAL_INCLUDES += [ - "/accessible/atk", + '/accessible/atk', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': LOCAL_INCLUDES += [ - "/accessible/windows/ia2", - "/accessible/windows/msaa", + '/accessible/windows/ia2', + '/accessible/windows/msaa', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': LOCAL_INCLUDES += [ - "/accessible/mac", + '/accessible/mac', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': LOCAL_INCLUDES += [ - "/accessible/android", + '/accessible/android', ] else: LOCAL_INCLUDES += [ - "/accessible/other", + '/accessible/other', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' -if CONFIG["CC_TYPE"] in ("clang", "gcc"): - CXXFLAGS += ["-Wno-error=shadow"] +if CONFIG['CC_TYPE'] in ('clang', 'gcc'): + CXXFLAGS += ['-Wno-error=shadow'] diff --git a/browser/actors/moz.build b/browser/actors/moz.build index 1f9f8ef1c032f8aaa9225571532b7fdcfcca66a7..f00621df222ebd02952838db84238a49780d9049 100644 --- a/browser/actors/moz.build +++ b/browser/actors/moz.build @@ -29,61 +29,61 @@ with Files("WebRTCChild.jsm"): BUG_COMPONENT = ("Firefox", "Site Permissions") FINAL_TARGET_FILES.actors += [ - "AboutNewInstallChild.jsm", - "AboutNewInstallParent.jsm", - "AboutNewTabChild.jsm", - "AboutNewTabParent.jsm", - "AboutPluginsChild.jsm", - "AboutPluginsParent.jsm", - "AboutPrivateBrowsingChild.jsm", - "AboutPrivateBrowsingParent.jsm", - "AboutProtectionsChild.jsm", - "AboutProtectionsParent.jsm", - "AboutReaderChild.jsm", - "AboutReaderParent.jsm", - "AboutTabCrashedChild.jsm", - "AboutTabCrashedParent.jsm", - "BlockedSiteChild.jsm", - "BlockedSiteParent.jsm", - "BrowserProcessChild.jsm", - "BrowserTabChild.jsm", - "BrowserTabParent.jsm", - "ClickHandlerChild.jsm", - "ClickHandlerParent.jsm", - "ContentMetaChild.jsm", - "ContentMetaParent.jsm", - "ContentSearchChild.jsm", - "ContentSearchParent.jsm", - "ContextMenuChild.jsm", - "ContextMenuParent.jsm", - "DecoderDoctorChild.jsm", - "DecoderDoctorParent.jsm", - "DOMFullscreenChild.jsm", - "DOMFullscreenParent.jsm", - "EncryptedMediaChild.jsm", - "EncryptedMediaParent.jsm", - "FormValidationChild.jsm", - "FormValidationParent.jsm", - "LightweightThemeChild.jsm", - "LinkHandlerChild.jsm", - "LinkHandlerParent.jsm", - "NetErrorChild.jsm", - "NetErrorParent.jsm", - "PageInfoChild.jsm", - "PageStyleChild.jsm", - "PageStyleParent.jsm", - "PluginChild.jsm", - "PluginParent.jsm", - "PointerLockChild.jsm", - "PointerLockParent.jsm", - "PromptParent.jsm", - "RefreshBlockerChild.jsm", - "RefreshBlockerParent.jsm", - "RFPHelperChild.jsm", - "RFPHelperParent.jsm", - "SearchTelemetryChild.jsm", - "SearchTelemetryParent.jsm", - "SwitchDocumentDirectionChild.jsm", - "WebRTCChild.jsm", - "WebRTCParent.jsm", + 'AboutNewInstallChild.jsm', + 'AboutNewInstallParent.jsm', + 'AboutNewTabChild.jsm', + 'AboutNewTabParent.jsm', + 'AboutPluginsChild.jsm', + 'AboutPluginsParent.jsm', + 'AboutPrivateBrowsingChild.jsm', + 'AboutPrivateBrowsingParent.jsm', + 'AboutProtectionsChild.jsm', + 'AboutProtectionsParent.jsm', + 'AboutReaderChild.jsm', + 'AboutReaderParent.jsm', + 'AboutTabCrashedChild.jsm', + 'AboutTabCrashedParent.jsm', + 'BlockedSiteChild.jsm', + 'BlockedSiteParent.jsm', + 'BrowserProcessChild.jsm', + 'BrowserTabChild.jsm', + 'BrowserTabParent.jsm', + 'ClickHandlerChild.jsm', + 'ClickHandlerParent.jsm', + 'ContentMetaChild.jsm', + 'ContentMetaParent.jsm', + 'ContentSearchChild.jsm', + 'ContentSearchParent.jsm', + 'ContextMenuChild.jsm', + 'ContextMenuParent.jsm', + 'DecoderDoctorChild.jsm', + 'DecoderDoctorParent.jsm', + 'DOMFullscreenChild.jsm', + 'DOMFullscreenParent.jsm', + 'EncryptedMediaChild.jsm', + 'EncryptedMediaParent.jsm', + 'FormValidationChild.jsm', + 'FormValidationParent.jsm', + 'LightweightThemeChild.jsm', + 'LinkHandlerChild.jsm', + 'LinkHandlerParent.jsm', + 'NetErrorChild.jsm', + 'NetErrorParent.jsm', + 'PageInfoChild.jsm', + 'PageStyleChild.jsm', + 'PageStyleParent.jsm', + 'PluginChild.jsm', + 'PluginParent.jsm', + 'PointerLockChild.jsm', + 'PointerLockParent.jsm', + 'PromptParent.jsm', + 'RefreshBlockerChild.jsm', + 'RefreshBlockerParent.jsm', + 'RFPHelperChild.jsm', + 'RFPHelperParent.jsm', + 'SearchTelemetryChild.jsm', + 'SearchTelemetryParent.jsm', + 'SwitchDocumentDirectionChild.jsm', + 'WebRTCChild.jsm', + 'WebRTCParent.jsm', ] diff --git a/browser/app/macbuild/Contents/moz.build b/browser/app/macbuild/Contents/moz.build index b8b28926de4600aacf744996585252d6cec193d3..daf51c25cbf552c593114143dc8e69c83f920fb3 100644 --- a/browser/app/macbuild/Contents/moz.build +++ b/browser/app/macbuild/Contents/moz.build @@ -6,20 +6,14 @@ defs = [] -for s in ( - "MOZ_GECKODRIVER", - "MOZ_ASAN", - "MOZ_TSAN", - "MOZ_CRASHREPORTER", - "MOZ_APP_NAME", -): +for s in ('MOZ_GECKODRIVER', 'MOZ_ASAN', 'MOZ_TSAN', 'MOZ_CRASHREPORTER', + 'MOZ_APP_NAME'): if CONFIG[s]: - defs.append("-D%s=%s" % (s, "1" if CONFIG[s] is True else CONFIG[s])) + defs.append('-D%s=%s' % (s, '1' if CONFIG[s] is True else CONFIG[s])) GeneratedFile( - "MacOS-files.txt", - script="/python/mozbuild/mozbuild/action/preprocessor.py", - entry_point="generate", - inputs=["MacOS-files.in"], - flags=defs, -) + 'MacOS-files.txt', + script='/python/mozbuild/mozbuild/action/preprocessor.py', + entry_point='generate', + inputs=['MacOS-files.in'], + flags=defs) diff --git a/browser/app/macversion.py b/browser/app/macversion.py index 3d9aaaa94ac54566917a6a88df96475f54cef1fc..f57b5dc85f0db09d254819fb26f3462879a26bdf 100644 --- a/browser/app/macversion.py +++ b/browser/app/macversion.py @@ -10,17 +10,17 @@ import sys import re o = OptionParser() -o.add_option("--buildid", dest="buildid") -o.add_option("--version", dest="version") +o.add_option('--buildid', dest='buildid') +o.add_option('--version', dest='version') (options, args) = o.parse_args() if not options.buildid: - print("--buildid is required", file=sys.stderr) + print('--buildid is required', file=sys.stderr) sys.exit(1) if not options.version: - print("--version is required", file=sys.stderr) + print('--version is required', file=sys.stderr) sys.exit(1) # We want to build a version number that matches the format allowed for @@ -29,19 +29,18 @@ if not options.version: # 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) -define, MOZ_BUILDID, buildid = ( - io.open(options.buildid, "r", encoding="utf-8").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") -majorVersion = re.match(r"^(\d+)[^\d].*", options.version).group(1) +majorVersion = re.match(r'^(\d+)[^\d].*', options.version).group(1) # last two digits of the year twodigityear = buildid[2:4] month = buildid[4:6] -if month[0] == "0": +if month[0] == '0': month = month[1] day = buildid[6:8] -if day[0] == "0": +if day[0] == '0': day = day[1] -print("%s.%s.%s" % (majorVersion + twodigityear, month, day)) +print('%s.%s.%s' % (majorVersion + twodigityear, month, day)) diff --git a/browser/app/moz.build b/browser/app/moz.build index 9da2da337663a59ad4bea58733abab897a630415..d6b25cbd92ab373cc1e151ddfbbb6d06e55f71cc 100644 --- a/browser/app/moz.build +++ b/browser/app/moz.build @@ -29,90 +29,90 @@ with Files("profile/channel-prefs.js"): with Files("profile/firefox.js"): BUG_COMPONENT = ("Firefox", "General") -if CONFIG["MOZ_MACBUNDLE_NAME"]: - DIRS += ["macbuild/Contents"] +if CONFIG['MOZ_MACBUNDLE_NAME']: + DIRS += ['macbuild/Contents'] -if CONFIG["MOZ_NO_PIE_COMPAT"]: - GeckoProgram(CONFIG["MOZ_APP_NAME"] + "-bin") +if CONFIG['MOZ_NO_PIE_COMPAT']: + GeckoProgram(CONFIG['MOZ_APP_NAME'] + '-bin') - DIRS += ["no-pie"] + DIRS += ['no-pie'] else: - GeckoProgram(CONFIG["MOZ_APP_NAME"]) + GeckoProgram(CONFIG['MOZ_APP_NAME']) SOURCES += [ - "nsBrowserApp.cpp", + 'nsBrowserApp.cpp', ] # Neither channel-prefs.js nor firefox.exe want to end up in dist/bin/browser. DIST_SUBDIR = "" LOCAL_INCLUDES += [ - "!/build", - "/toolkit/xre", - "/xpcom/base", - "/xpcom/build", + '!/build', + '/toolkit/xre', + '/xpcom/base', + '/xpcom/build', ] -if CONFIG["LIBFUZZER"]: - USE_LIBS += ["fuzzer"] +if CONFIG['LIBFUZZER']: + USE_LIBS += [ 'fuzzer' ] LOCAL_INCLUDES += [ - "/tools/fuzzing/libfuzzer", + '/tools/fuzzing/libfuzzer', ] -if CONFIG["ENABLE_GECKODRIVER"]: - DEFINES["MOZ_GECKODRIVER"] = True +if CONFIG['ENABLE_GECKODRIVER']: + DEFINES['MOZ_GECKODRIVER'] = True -if CONFIG["CC_TYPE"] == "clang-cl": +if CONFIG['CC_TYPE'] == 'clang-cl': # Always enter a Windows program through wmain, whether or not we're # a console application. - WIN32_EXE_LDFLAGS += ["-ENTRY:wmainCRTStartup"] + WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup'] -if CONFIG["OS_ARCH"] == "WINNT": - RCINCLUDE = "splash.rc" +if CONFIG['OS_ARCH'] == 'WINNT': + RCINCLUDE = 'splash.rc' DIRS += [ - "winlauncher", + 'winlauncher', ] USE_LIBS += [ - "winlauncher", + 'winlauncher', ] LOCAL_INCLUDES += [ - "/browser/app/winlauncher", + '/browser/app/winlauncher', ] DELAYLOAD_DLLS += [ - "oleaut32.dll", - "ole32.dll", - "rpcrt4.dll", - "version.dll", + 'oleaut32.dll', + 'ole32.dll', + 'rpcrt4.dll', + 'version.dll', ] - if CONFIG["CC_TYPE"] == "clang-cl": - libpath_flag = "-LIBPATH:" + if CONFIG['CC_TYPE'] == 'clang-cl': + libpath_flag = '-LIBPATH:' else: - libpath_flag = "-L" + libpath_flag = '-L' WIN32_EXE_LDFLAGS += [ - libpath_flag + OBJDIR + "/winlauncher/freestanding", + libpath_flag + OBJDIR + '/winlauncher/freestanding', ] -if CONFIG["MOZ_SANDBOX"] and CONFIG["OS_ARCH"] == "Darwin": +if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'Darwin': USE_LIBS += [ - "mozsandbox", + 'mozsandbox', ] -if CONFIG["MOZ_SANDBOX"] and CONFIG["OS_ARCH"] == "WINNT": +if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT': # For sandbox includes and the include dependencies those have LOCAL_INCLUDES += [ - "/security/sandbox/chromium", - "/security/sandbox/chromium-shim", + '/security/sandbox/chromium', + '/security/sandbox/chromium-shim', ] USE_LIBS += [ - "sandbox_s", + 'sandbox_s', ] DELAYLOAD_DLLS += [ - "winmm.dll", - "user32.dll", + 'winmm.dll', + 'user32.dll', ] # Control the default heap size. @@ -123,29 +123,23 @@ if CONFIG["MOZ_SANDBOX"] and CONFIG["OS_ARCH"] == "WINNT": # The heap will grow if need be. # # Set it to 256k. See bug 127069. -if CONFIG["OS_ARCH"] == "WINNT" and CONFIG["CC_TYPE"] not in ("clang", "gcc"): - LDFLAGS += ["/HEAP:0x40000"] +if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CC_TYPE'] not in ('clang', 'gcc'): + LDFLAGS += ['/HEAP:0x40000'] DisableStlWrapping() -if CONFIG["HAVE_CLOCK_MONOTONIC"]: - OS_LIBS += CONFIG["REALTIME_LIBS"] +if CONFIG['HAVE_CLOCK_MONOTONIC']: + OS_LIBS += CONFIG['REALTIME_LIBS'] -if CONFIG["MOZ_LINUX_32_SSE2_STARTUP_ERROR"]: - DEFINES["MOZ_LINUX_32_SSE2_STARTUP_ERROR"] = True - COMPILE_FLAGS["OS_CXXFLAGS"] = [ - f - for f in COMPILE_FLAGS.get("OS_CXXFLAGS", []) - if not f.startswith("-march=") and f not in ("-msse", "-msse2", "-mfpmath=sse") +if CONFIG['MOZ_LINUX_32_SSE2_STARTUP_ERROR']: + DEFINES['MOZ_LINUX_32_SSE2_STARTUP_ERROR'] = True + COMPILE_FLAGS['OS_CXXFLAGS'] = [ + f for f in COMPILE_FLAGS.get('OS_CXXFLAGS', []) + if not f.startswith('-march=') and f not in ('-msse', '-msse2', '-mfpmath=sse') ] + [ - "-mno-sse", - "-mno-sse2", - "-mfpmath=387", + '-mno-sse', '-mno-sse2', '-mfpmath=387', ] -for icon in ("firefox", "document", "newwindow", "newtab", "pbmode"): - DEFINES[icon.upper() + "_ICO"] = '"%s/%s/%s.ico"' % ( - TOPSRCDIR, - CONFIG["MOZ_BRANDING_DIRECTORY"], - icon, - ) +for icon in ('firefox', 'document', 'newwindow', 'newtab', 'pbmode'): + DEFINES[icon.upper() + '_ICO'] = '"%s/%s/%s.ico"' % ( + TOPSRCDIR, CONFIG['MOZ_BRANDING_DIRECTORY'], icon) diff --git a/browser/app/no-pie/moz.build b/browser/app/no-pie/moz.build index 74aa89409d19ee640e5792a1af3b78c92d82d880..4c9c884327c300f84cd2db97782933f6da291389 100644 --- a/browser/app/no-pie/moz.build +++ b/browser/app/no-pie/moz.build @@ -4,21 +4,25 @@ # 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/. -Program(CONFIG["MOZ_APP_NAME"]) +Program(CONFIG['MOZ_APP_NAME']) SOURCES += [ - "NoPie.c", + 'NoPie.c', ] # For some reason, LTO messes things up. We don't care anyways. CFLAGS += [ - "-fno-lto", + '-fno-lto', ] # Use OS_LIBS instead of LDFLAGS to "force" the flag to come after -pie # from MOZ_PROGRAM_LDFLAGS. -if CONFIG["CC_TYPE"] == "clang": +if CONFIG['CC_TYPE'] == 'clang': # clang < 5.0 doesn't support -no-pie. - OS_LIBS += ["-nopie"] + OS_LIBS += [ + '-nopie' + ] else: - OS_LIBS += ["-no-pie"] + OS_LIBS += [ + '-no-pie' + ] diff --git a/browser/app/winlauncher/freestanding/gen_ntdll_freestanding_lib.py b/browser/app/winlauncher/freestanding/gen_ntdll_freestanding_lib.py index a69261cc3ae309a7725ce57050f13b5bd6421648..6a91f63fbce710bc9244ccf5f83b0d9336e8a656 100644 --- a/browser/app/winlauncher/freestanding/gen_ntdll_freestanding_lib.py +++ b/browser/app/winlauncher/freestanding/gen_ntdll_freestanding_lib.py @@ -20,11 +20,11 @@ def main(output_fd, def_file, llvm_dlltool, *llvm_dlltool_args): try: cmd = [llvm_dlltool] cmd.extend(llvm_dlltool_args) - cmd += ["-d", def_file, "-l", tmp_output] + cmd += ['-d', def_file, '-l', tmp_output] subprocess.check_call(cmd) - with open(tmp_output, "rb") as tmplib: + with open(tmp_output, 'rb') as tmplib: output_fd.write(tmplib.read()) finally: os.remove(tmp_output) diff --git a/browser/app/winlauncher/freestanding/moz.build b/browser/app/winlauncher/freestanding/moz.build index 5e2dac70ea1ed8bfe4354f6cc7195ee82b3047bb..460f8ec4cb0bbf8c545f50ad69322ee5b1b13735 100644 --- a/browser/app/winlauncher/freestanding/moz.build +++ b/browser/app/winlauncher/freestanding/moz.build @@ -4,7 +4,7 @@ # 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/. -Library("winlauncher-freestanding") +Library('winlauncher-freestanding') FORCE_STATIC_LIB = True @@ -14,43 +14,43 @@ FORCE_STATIC_LIB = True NO_PGO = True UNIFIED_SOURCES += [ - "DllBlocklist.cpp", - "FunctionTableResolver.cpp", - "LoaderPrivateAPI.cpp", - "ModuleLoadFrame.cpp", + 'DllBlocklist.cpp', + 'FunctionTableResolver.cpp', + 'LoaderPrivateAPI.cpp', + 'ModuleLoadFrame.cpp', ] # This library must be compiled in a freestanding environment, as its code must # not assume that it has access to any runtime libraries. -if CONFIG["CC_TYPE"] == "clang-cl": - CXXFLAGS += ["-Xclang"] +if CONFIG['CC_TYPE'] == 'clang-cl': + CXXFLAGS += ['-Xclang'] CXXFLAGS += [ - "-ffreestanding", + '-ffreestanding', ] # Forcibly include Freestanding.h into all source files in this library. -if CONFIG["CC_TYPE"] == "clang-cl": - CXXFLAGS += ["-FI"] +if CONFIG['CC_TYPE'] == 'clang-cl': + CXXFLAGS += ['-FI'] else: - CXXFLAGS += ["-include"] + CXXFLAGS += ['-include'] -CXXFLAGS += [SRCDIR + "/Freestanding.h"] +CXXFLAGS += [ SRCDIR + '/Freestanding.h' ] OS_LIBS += [ - "ntdll", - "ntdll_freestanding", + 'ntdll', + 'ntdll_freestanding', ] -if CONFIG["COMPILE_ENVIRONMENT"] and CONFIG["LLVM_DLLTOOL"]: +if CONFIG['COMPILE_ENVIRONMENT'] and CONFIG['LLVM_DLLTOOL']: GeneratedFile( - "%sntdll_freestanding.%s" % (CONFIG["LIB_PREFIX"], CONFIG["LIB_SUFFIX"]), - script="gen_ntdll_freestanding_lib.py", - inputs=["ntdll_freestanding.def"], - flags=[CONFIG["LLVM_DLLTOOL"]] + CONFIG["LLVM_DLLTOOL_FLAGS"], - ) + '%sntdll_freestanding.%s' % (CONFIG['LIB_PREFIX'], + CONFIG['LIB_SUFFIX']), + script='gen_ntdll_freestanding_lib.py', + inputs=['ntdll_freestanding.def'], + flags=[CONFIG['LLVM_DLLTOOL']] + CONFIG['LLVM_DLLTOOL_FLAGS']) DisableStlWrapping() -with Files("**"): - BUG_COMPONENT = ("Firefox", "Launcher Process") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Launcher Process') diff --git a/browser/app/winlauncher/moz.build b/browser/app/winlauncher/moz.build index 585e8835473115ae82fb18e18406bdfce6cc50e6..499396b3774b57be2d39d02c26b41e753000f70f 100644 --- a/browser/app/winlauncher/moz.build +++ b/browser/app/winlauncher/moz.build @@ -4,48 +4,48 @@ # 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/. -Library("winlauncher") +Library('winlauncher') FORCE_STATIC_LIB = True UNIFIED_SOURCES += [ - "/ipc/mscom/ProcessRuntime.cpp", - "/widget/windows/WindowsConsole.cpp", - "DllBlocklistInit.cpp", - "ErrorHandler.cpp", - "LauncherProcessWin.cpp", - "LaunchUnelevated.cpp", - "NtLoaderAPI.cpp", + '/ipc/mscom/ProcessRuntime.cpp', + '/widget/windows/WindowsConsole.cpp', + 'DllBlocklistInit.cpp', + 'ErrorHandler.cpp', + 'LauncherProcessWin.cpp', + 'LaunchUnelevated.cpp', + 'NtLoaderAPI.cpp', ] OS_LIBS += [ - "oleaut32", - "ole32", - "rpcrt4", - "version", + 'oleaut32', + 'ole32', + 'rpcrt4', + 'version', ] DIRS += [ - "freestanding", + 'freestanding', ] USE_LIBS += [ - "winlauncher-freestanding", + 'winlauncher-freestanding', ] TEST_DIRS += [ - "test", + 'test', ] -if CONFIG["MOZ_LAUNCHER_PROCESS"]: +if CONFIG['MOZ_LAUNCHER_PROCESS']: UNIFIED_SOURCES += [ - "/toolkit/xre/LauncherRegistryInfo.cpp", - "/toolkit/xre/WinTokenUtils.cpp", + '/toolkit/xre/LauncherRegistryInfo.cpp', + '/toolkit/xre/WinTokenUtils.cpp', ] - for var in ("MOZ_APP_BASENAME", "MOZ_APP_VENDOR"): + for var in ('MOZ_APP_BASENAME', 'MOZ_APP_VENDOR'): DEFINES[var] = '"%s"' % CONFIG[var] DisableStlWrapping() -with Files("**"): - BUG_COMPONENT = ("Firefox", "Launcher Process") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Launcher Process') diff --git a/browser/app/winlauncher/test/moz.build b/browser/app/winlauncher/test/moz.build index 0416be16c0559151e5eeb222d9a5928cf646a5b5..e53a113279d67591f82767cbeb78bdb1065e1c8d 100644 --- a/browser/app/winlauncher/test/moz.build +++ b/browser/app/winlauncher/test/moz.build @@ -8,22 +8,22 @@ DisableStlWrapping() GeckoCppUnitTests( [ - "TestSafeThreadLocal", - "TestSameBinary", + 'TestSafeThreadLocal', + 'TestSameBinary', ], - linkage=None, + linkage=None ) LOCAL_INCLUDES += [ - "/browser/app/winlauncher", + '/browser/app/winlauncher', ] OS_LIBS += [ - "ntdll", + 'ntdll', ] -if CONFIG["CC_TYPE"] in ("gcc", "clang"): +if CONFIG['CC_TYPE'] in ('gcc', 'clang'): # This allows us to use wmain as the entry point on mingw LDFLAGS += [ - "-municode", + '-municode', ] diff --git a/browser/base/gen_aboutneterror_codes.py b/browser/base/gen_aboutneterror_codes.py index a333d206fa155c2309434ba9b68beb432d5751ff..572a6c821bbf7f8595472eaace9d21f97539b829 100644 --- a/browser/base/gen_aboutneterror_codes.py +++ b/browser/base/gen_aboutneterror_codes.py @@ -11,10 +11,8 @@ import sys def find_error_ids(filename, known_strings): - with open(filename, "r", encoding="utf-8") as f: - known_strings += [ - m.id.name for m in parse(f.read()).body if isinstance(m, Message) - ] + with open(filename, 'r', encoding="utf-8") as f: + known_strings += [m.id.name for m in parse(f.read()).body if isinstance(m, Message)] def main(output, *filenames): @@ -22,11 +20,11 @@ def main(output, *filenames): for filename in filenames: find_error_ids(filename, known_strings) - output.write("const KNOWN_ERROR_MESSAGE_IDS = new Set([\n") + output.write('const KNOWN_ERROR_MESSAGE_IDS = new Set([\n') for known_string in known_strings: output.write(' "{}",\n'.format(known_string)) - output.write("]);\n") + output.write(']);\n') -if __name__ == "__main__": +if __name__ == '__main__': sys.exit(main(sys.stdout, *sys.argv[1:])) diff --git a/browser/base/moz.build b/browser/base/moz.build index 393ec02bf30a6f2229b5b27e6f6e28eaf5512019..fdfa93d4623a8214557ea550e87069394acc51c6 100644 --- a/browser/base/moz.build +++ b/browser/base/moz.build @@ -7,80 +7,80 @@ with Files("**"): BUG_COMPONENT = ("Firefox", "General") -SPHINX_TREES["sslerrorreport"] = "content/docs/sslerrorreport" -SPHINX_TREES["tabbrowser"] = "content/docs/tabbrowser" +SPHINX_TREES['sslerrorreport'] = 'content/docs/sslerrorreport' +SPHINX_TREES['tabbrowser'] = 'content/docs/tabbrowser' -with Files("content/docs/sslerrorreport/**"): - SCHEDULES.exclusive = ["docs"] +with Files('content/docs/sslerrorreport/**'): + SCHEDULES.exclusive = ['docs'] MOCHITEST_CHROME_MANIFESTS += [ - "content/test/chrome/chrome.ini", + 'content/test/chrome/chrome.ini', ] BROWSER_CHROME_MANIFESTS += [ - "content/test/about/browser.ini", - "content/test/alerts/browser.ini", - "content/test/backforward/browser.ini", - "content/test/caps/browser.ini", - "content/test/captivePortal/browser.ini", - "content/test/contextMenu/browser.ini", - "content/test/favicons/browser.ini", - "content/test/forms/browser.ini", - "content/test/fullscreen/browser.ini", - "content/test/general/browser.ini", - "content/test/historySwipeAnimation/browser.ini", - "content/test/keyboard/browser.ini", - "content/test/menubar/browser.ini", - "content/test/metaTags/browser.ini", - "content/test/outOfProcess/browser.ini", - "content/test/pageActions/browser.ini", - "content/test/pageinfo/browser.ini", - "content/test/pageStyle/browser.ini", - "content/test/performance/browser.ini", - "content/test/performance/hidpi/browser.ini", - "content/test/performance/io/browser.ini", - "content/test/performance/lowdpi/browser.ini", - "content/test/permissions/browser.ini", - "content/test/plugins/browser.ini", - "content/test/popupNotifications/browser.ini", - "content/test/popups/browser.ini", - "content/test/protectionsUI/browser.ini", - "content/test/referrer/browser.ini", - "content/test/sanitize/browser.ini", - "content/test/sidebar/browser.ini", - "content/test/siteIdentity/browser.ini", - "content/test/static/browser.ini", - "content/test/statuspanel/browser.ini", - "content/test/sync/browser.ini", - "content/test/tabcrashed/browser.ini", - "content/test/tabdialogs/browser.ini", - "content/test/tabMediaIndicator/browser.ini", - "content/test/tabPrompts/browser.ini", - "content/test/tabs/browser.ini", - "content/test/touch/browser.ini", - "content/test/webextensions/browser.ini", - "content/test/webrtc/browser.ini", - "content/test/webrtc/legacyIndicator/browser.ini", - "content/test/zoom/browser.ini", + 'content/test/about/browser.ini', + 'content/test/alerts/browser.ini', + 'content/test/backforward/browser.ini', + 'content/test/caps/browser.ini', + 'content/test/captivePortal/browser.ini', + 'content/test/contextMenu/browser.ini', + 'content/test/favicons/browser.ini', + 'content/test/forms/browser.ini', + 'content/test/fullscreen/browser.ini', + 'content/test/general/browser.ini', + 'content/test/historySwipeAnimation/browser.ini', + 'content/test/keyboard/browser.ini', + 'content/test/menubar/browser.ini', + 'content/test/metaTags/browser.ini', + 'content/test/outOfProcess/browser.ini', + 'content/test/pageActions/browser.ini', + 'content/test/pageinfo/browser.ini', + 'content/test/pageStyle/browser.ini', + 'content/test/performance/browser.ini', + 'content/test/performance/hidpi/browser.ini', + 'content/test/performance/io/browser.ini', + 'content/test/performance/lowdpi/browser.ini', + 'content/test/permissions/browser.ini', + 'content/test/plugins/browser.ini', + 'content/test/popupNotifications/browser.ini', + 'content/test/popups/browser.ini', + 'content/test/protectionsUI/browser.ini', + 'content/test/referrer/browser.ini', + 'content/test/sanitize/browser.ini', + 'content/test/sidebar/browser.ini', + 'content/test/siteIdentity/browser.ini', + 'content/test/static/browser.ini', + 'content/test/statuspanel/browser.ini', + 'content/test/sync/browser.ini', + 'content/test/tabcrashed/browser.ini', + 'content/test/tabdialogs/browser.ini', + 'content/test/tabMediaIndicator/browser.ini', + 'content/test/tabPrompts/browser.ini', + 'content/test/tabs/browser.ini', + 'content/test/touch/browser.ini', + 'content/test/webextensions/browser.ini', + 'content/test/webrtc/browser.ini', + 'content/test/webrtc/legacyIndicator/browser.ini', + 'content/test/zoom/browser.ini', ] -PERFTESTS_MANIFESTS += ["content/test/perftest.ini"] +PERFTESTS_MANIFESTS += [ + 'content/test/perftest.ini' +] + +DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION'] +DEFINES['MOZ_APP_VERSION_DISPLAY'] = CONFIG['MOZ_APP_VERSION_DISPLAY'] -DEFINES["MOZ_APP_VERSION"] = CONFIG["MOZ_APP_VERSION"] -DEFINES["MOZ_APP_VERSION_DISPLAY"] = CONFIG["MOZ_APP_VERSION_DISPLAY"] +DEFINES['APP_LICENSE_BLOCK'] = '%s/content/overrides/app-license.html' % SRCDIR -DEFINES["APP_LICENSE_BLOCK"] = "%s/content/overrides/app-license.html" % SRCDIR +if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk', 'cocoa'): + DEFINES['CONTEXT_COPY_IMAGE_CONTENTS'] = 1 -if CONFIG["MOZ_WIDGET_TOOLKIT"] in ("windows", "gtk", "cocoa"): - DEFINES["CONTEXT_COPY_IMAGE_CONTENTS"] = 1 +if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk'): + DEFINES['MENUBAR_CAN_AUTOHIDE'] = 1 -if CONFIG["MOZ_WIDGET_TOOLKIT"] in ("windows", "gtk"): - DEFINES["MENUBAR_CAN_AUTOHIDE"] = 1 +JAR_MANIFESTS += ['jar.mn'] -JAR_MANIFESTS += ["jar.mn"] +GeneratedFile('content/aboutNetErrorCodes.js', script='gen_aboutneterror_codes.py', + inputs=['/browser/locales/en-US/browser/nsserrors.ftl']) -GeneratedFile( - "content/aboutNetErrorCodes.js", - script="gen_aboutneterror_codes.py", - inputs=["/browser/locales/en-US/browser/nsserrors.ftl"], -) diff --git a/browser/branding/aurora/content/moz.build b/browser/branding/aurora/content/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..eb4454d28f88bf1075c4e70e38a0f7943b6ffb1f 100644 --- a/browser/branding/aurora/content/moz.build +++ b/browser/branding/aurora/content/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/browser/branding/aurora/locales/moz.build b/browser/branding/aurora/locales/moz.build index fff7035065b0aed628d4f5eb5677cac8b59ea588..8bad13124d5a4a65068af44a5ae3cd87cacd569c 100644 --- a/browser/branding/aurora/locales/moz.build +++ b/browser/branding/aurora/locales/moz.build @@ -4,6 +4,6 @@ # 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/. -DEFINES["MOZ_DISTRIBUTION_ID_UNQUOTED"] = CONFIG["MOZ_DISTRIBUTION_ID"] +DEFINES['MOZ_DISTRIBUTION_ID_UNQUOTED'] = CONFIG['MOZ_DISTRIBUTION_ID'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/browser/branding/aurora/moz.build b/browser/branding/aurora/moz.build index dd081ac44496d19d2e8d73a0a10f3d1ad81266b6..9045cee11bb858092868cd8900c4e8f8e641c3b2 100644 --- a/browser/branding/aurora/moz.build +++ b/browser/branding/aurora/moz.build @@ -4,10 +4,10 @@ # 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/. -DIRS += ["content", "locales"] +DIRS += ['content', 'locales'] -DIST_SUBDIR = "browser" -export("DIST_SUBDIR") +DIST_SUBDIR = 'browser' +export('DIST_SUBDIR') -include("../branding-common.mozbuild") +include('../branding-common.mozbuild') FirefoxBranding() diff --git a/browser/branding/nightly/content/moz.build b/browser/branding/nightly/content/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..eb4454d28f88bf1075c4e70e38a0f7943b6ffb1f 100644 --- a/browser/branding/nightly/content/moz.build +++ b/browser/branding/nightly/content/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/browser/branding/nightly/locales/moz.build b/browser/branding/nightly/locales/moz.build index fff7035065b0aed628d4f5eb5677cac8b59ea588..8bad13124d5a4a65068af44a5ae3cd87cacd569c 100644 --- a/browser/branding/nightly/locales/moz.build +++ b/browser/branding/nightly/locales/moz.build @@ -4,6 +4,6 @@ # 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/. -DEFINES["MOZ_DISTRIBUTION_ID_UNQUOTED"] = CONFIG["MOZ_DISTRIBUTION_ID"] +DEFINES['MOZ_DISTRIBUTION_ID_UNQUOTED'] = CONFIG['MOZ_DISTRIBUTION_ID'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/browser/branding/nightly/moz.build b/browser/branding/nightly/moz.build index dd081ac44496d19d2e8d73a0a10f3d1ad81266b6..9045cee11bb858092868cd8900c4e8f8e641c3b2 100644 --- a/browser/branding/nightly/moz.build +++ b/browser/branding/nightly/moz.build @@ -4,10 +4,10 @@ # 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/. -DIRS += ["content", "locales"] +DIRS += ['content', 'locales'] -DIST_SUBDIR = "browser" -export("DIST_SUBDIR") +DIST_SUBDIR = 'browser' +export('DIST_SUBDIR') -include("../branding-common.mozbuild") +include('../branding-common.mozbuild') FirefoxBranding() diff --git a/browser/branding/official/content/moz.build b/browser/branding/official/content/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..eb4454d28f88bf1075c4e70e38a0f7943b6ffb1f 100644 --- a/browser/branding/official/content/moz.build +++ b/browser/branding/official/content/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/browser/branding/official/locales/moz.build b/browser/branding/official/locales/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..eb4454d28f88bf1075c4e70e38a0f7943b6ffb1f 100644 --- a/browser/branding/official/locales/moz.build +++ b/browser/branding/official/locales/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/browser/branding/official/moz.build b/browser/branding/official/moz.build index dd081ac44496d19d2e8d73a0a10f3d1ad81266b6..9045cee11bb858092868cd8900c4e8f8e641c3b2 100644 --- a/browser/branding/official/moz.build +++ b/browser/branding/official/moz.build @@ -4,10 +4,10 @@ # 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/. -DIRS += ["content", "locales"] +DIRS += ['content', 'locales'] -DIST_SUBDIR = "browser" -export("DIST_SUBDIR") +DIST_SUBDIR = 'browser' +export('DIST_SUBDIR') -include("../branding-common.mozbuild") +include('../branding-common.mozbuild') FirefoxBranding() diff --git a/browser/branding/unofficial/content/moz.build b/browser/branding/unofficial/content/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..eb4454d28f88bf1075c4e70e38a0f7943b6ffb1f 100644 --- a/browser/branding/unofficial/content/moz.build +++ b/browser/branding/unofficial/content/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/browser/branding/unofficial/locales/moz.build b/browser/branding/unofficial/locales/moz.build index fff7035065b0aed628d4f5eb5677cac8b59ea588..8bad13124d5a4a65068af44a5ae3cd87cacd569c 100644 --- a/browser/branding/unofficial/locales/moz.build +++ b/browser/branding/unofficial/locales/moz.build @@ -4,6 +4,6 @@ # 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/. -DEFINES["MOZ_DISTRIBUTION_ID_UNQUOTED"] = CONFIG["MOZ_DISTRIBUTION_ID"] +DEFINES['MOZ_DISTRIBUTION_ID_UNQUOTED'] = CONFIG['MOZ_DISTRIBUTION_ID'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/browser/branding/unofficial/moz.build b/browser/branding/unofficial/moz.build index dd081ac44496d19d2e8d73a0a10f3d1ad81266b6..9045cee11bb858092868cd8900c4e8f8e641c3b2 100644 --- a/browser/branding/unofficial/moz.build +++ b/browser/branding/unofficial/moz.build @@ -4,10 +4,10 @@ # 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/. -DIRS += ["content", "locales"] +DIRS += ['content', 'locales'] -DIST_SUBDIR = "browser" -export("DIST_SUBDIR") +DIST_SUBDIR = 'browser' +export('DIST_SUBDIR') -include("../branding-common.mozbuild") +include('../branding-common.mozbuild') FirefoxBranding() diff --git a/browser/components/about/moz.build b/browser/components/about/moz.build index 9be34f57b927d66509c6c9cdcba097016b24e705..a178cd21d2e84ea07849abceab8ed40dabf0d40b 100644 --- a/browser/components/about/moz.build +++ b/browser/components/about/moz.build @@ -8,25 +8,25 @@ with Files("**"): BUG_COMPONENT = ("Firefox", "General") EXPORTS.mozilla.browser += [ - "AboutRedirector.h", + 'AboutRedirector.h', ] -XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] SOURCES += [ - "AboutRedirector.cpp", + 'AboutRedirector.cpp', ] XPCOM_MANIFESTS += [ - "components.conf", + 'components.conf', ] -FINAL_LIBRARY = "browsercomps" +FINAL_LIBRARY = 'browsercomps' LOCAL_INCLUDES += [ - "../build", - "/dom/base", - "/ipc/chromium/src", + '../build', + '/dom/base', + '/ipc/chromium/src', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') diff --git a/browser/components/aboutconfig/moz.build b/browser/components/aboutconfig/moz.build index 47182555bb720e350f639633cd2dd72273f13b2c..7ff4b7ef8522e653c6dfb3b366254e38116c8552 100644 --- a/browser/components/aboutconfig/moz.build +++ b/browser/components/aboutconfig/moz.build @@ -4,6 +4,6 @@ # 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/. -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] diff --git a/browser/components/aboutlogins/moz.build b/browser/components/aboutlogins/moz.build index ef815d60998662144a38df13b75b6cd38459e085..d912a6f407b78e2a13e4dcfdf05e94594c991a8a 100644 --- a/browser/components/aboutlogins/moz.build +++ b/browser/components/aboutlogins/moz.build @@ -4,20 +4,20 @@ # 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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] -with Files("**"): - BUG_COMPONENT = ("Firefox", "about:logins") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'about:logins') EXTRA_JS_MODULES += [ - "LoginBreaches.jsm", + 'LoginBreaches.jsm', ] FINAL_TARGET_FILES.actors += [ - "AboutLoginsChild.jsm", - "AboutLoginsParent.jsm", + 'AboutLoginsChild.jsm', + 'AboutLoginsParent.jsm', ] -BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"] -MOCHITEST_CHROME_MANIFESTS += ["tests/chrome/chrome.ini"] -XPCSHELL_TESTS_MANIFESTS += ["tests/unit/xpcshell.ini"] +BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini'] +MOCHITEST_CHROME_MANIFESTS += ['tests/chrome/chrome.ini'] +XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini'] diff --git a/browser/components/attribution/moz.build b/browser/components/attribution/moz.build index 9d8a560eda802ffffae63da229f6adee0837d653..1cd9952495ae9bb33bd977e5117ba01503f60382 100644 --- a/browser/components/attribution/moz.build +++ b/browser/components/attribution/moz.build @@ -7,31 +7,31 @@ with Files("**"): BUG_COMPONENT = ("Toolkit", "Telemetry") -XPCSHELL_TESTS_MANIFESTS += ["test/xpcshell/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini'] -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] EXTRA_JS_MODULES += [ - "AttributionCode.jsm", + 'AttributionCode.jsm', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': XPIDL_SOURCES += [ - "nsIMacAttribution.idl", + 'nsIMacAttribution.idl', ] - XPIDL_MODULE = "attribution" + XPIDL_MODULE = 'attribution' EXPORTS += [ - "nsMacAttribution.h", + 'nsMacAttribution.h', ] SOURCES += [ - "nsMacAttribution.cpp", + 'nsMacAttribution.cpp', ] - FINAL_LIBRARY = "browsercomps" + FINAL_LIBRARY = 'browsercomps' EXTRA_JS_MODULES += [ - "MacAttribution.jsm", + 'MacAttribution.jsm', ] diff --git a/browser/components/build/moz.build b/browser/components/build/moz.build index 901c6ddfed8dcf11cace4f7bb44ec5f9deb1356d..170f181bf871f02d77aa0f3dc24cd3d9e4b18d00 100644 --- a/browser/components/build/moz.build +++ b/browser/components/build/moz.build @@ -8,15 +8,15 @@ with Files("**"): BUG_COMPONENT = ("Firefox Build System", "General") XPCOM_MANIFESTS += [ - "components.conf", + 'components.conf', ] -Library("browsercomps") -FINAL_LIBRARY = "xul" +Library('browsercomps') +FINAL_LIBRARY = 'xul' LOCAL_INCLUDES += [ - "../about", - "../migration", - "../sessionstore", - "../shell", + '../about', + '../migration', + '../sessionstore', + '../shell', ] diff --git a/browser/components/contextualidentity/moz.build b/browser/components/contextualidentity/moz.build index 4101066ad3c88874aba290956787e702d320d71e..9364d1f2e5e3bb2e419313a8a6ba20872864b165 100644 --- a/browser/components/contextualidentity/moz.build +++ b/browser/components/contextualidentity/moz.build @@ -5,10 +5,10 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. BROWSER_CHROME_MANIFESTS += [ - "test/browser/browser.ini", + 'test/browser/browser.ini', ] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] -with Files("**"): - BUG_COMPONENT = ("Core", "DOM: Security") +with Files('**'): + BUG_COMPONENT = ('Core', 'DOM: Security') diff --git a/browser/components/customizableui/content/moz.build b/browser/components/customizableui/content/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..eb4454d28f88bf1075c4e70e38a0f7943b6ffb1f 100644 --- a/browser/components/customizableui/content/moz.build +++ b/browser/components/customizableui/content/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/browser/components/customizableui/moz.build b/browser/components/customizableui/moz.build index e5cc2498e7c3c8ae19ba64459eca0ce38d0ce4fa..98c4b06ad3135ecd26250e0ee6b730152dbebf47 100644 --- a/browser/components/customizableui/moz.build +++ b/browser/components/customizableui/moz.build @@ -5,23 +5,23 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DIRS += [ - "content", + 'content', ] -BROWSER_CHROME_MANIFESTS += ["test/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser.ini'] TESTING_JS_MODULES += [ - "test/CustomizableUITestUtils.jsm", + 'test/CustomizableUITestUtils.jsm', ] EXTRA_JS_MODULES += [ - "CustomizableUI.jsm", - "CustomizableWidgets.jsm", - "CustomizeMode.jsm", - "DragPositionManager.jsm", - "PanelMultiView.jsm", - "SearchWidgetTracker.jsm", + 'CustomizableUI.jsm', + 'CustomizableWidgets.jsm', + 'CustomizeMode.jsm', + 'DragPositionManager.jsm', + 'PanelMultiView.jsm', + 'SearchWidgetTracker.jsm', ] -with Files("**"): - BUG_COMPONENT = ("Firefox", "Toolbars and Customization") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Toolbars and Customization') diff --git a/browser/components/doh/moz.build b/browser/components/doh/moz.build index 0cdc2dff92617d9d0502e4889e00b7e2d10d34e1..c3de603a2f71b853ced3989436b6453922f8954e 100644 --- a/browser/components/doh/moz.build +++ b/browser/components/doh/moz.build @@ -4,15 +4,15 @@ # 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/. -with Files("**"): - BUG_COMPONENT = ("Firefox", "Security") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Security') EXTRA_JS_MODULES += [ - "DoHConfig.jsm", - "DoHController.jsm", - "DoHHeuristics.jsm", - "TRRPerformance.jsm", + 'DoHConfig.jsm', + 'DoHController.jsm', + 'DoHHeuristics.jsm', + 'TRRPerformance.jsm', ] -XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] +XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] diff --git a/browser/components/downloads/moz.build b/browser/components/downloads/moz.build index b98c027fd897744aea417905b8dbc6691bf77559..8ec54f33a1dd6205acfc7ebba334adc1e20ba20b 100644 --- a/browser/components/downloads/moz.build +++ b/browser/components/downloads/moz.build @@ -4,27 +4,27 @@ # 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/. -with Files("*"): - BUG_COMPONENT = ("Firefox", "Downloads Panel") +with Files('*'): + BUG_COMPONENT = ('Firefox', 'Downloads Panel') -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] EXTRA_JS_MODULES += [ - "DownloadsCommon.jsm", - "DownloadsSubview.jsm", - "DownloadsTaskbar.jsm", - "DownloadsViewableInternally.jsm", - "DownloadsViewUI.jsm", + 'DownloadsCommon.jsm', + 'DownloadsSubview.jsm', + 'DownloadsTaskbar.jsm', + 'DownloadsViewableInternally.jsm', + 'DownloadsViewUI.jsm', ] -toolkit = CONFIG["MOZ_WIDGET_TOOLKIT"] +toolkit = CONFIG['MOZ_WIDGET_TOOLKIT'] -if toolkit == "cocoa": - EXTRA_JS_MODULES += ["DownloadsMacFinderProgress.jsm"] +if toolkit == 'cocoa': + EXTRA_JS_MODULES += ['DownloadsMacFinderProgress.jsm'] -with Files("**"): - BUG_COMPONENT = ("Firefox", "Downloads Panel") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Downloads Panel') -XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] diff --git a/browser/components/enterprisepolicies/helpers/moz.build b/browser/components/enterprisepolicies/helpers/moz.build index 648745cd3fbf028a65aa018b37a1c8f9b9c98ac2..947d92c31d84e9ea623e4e7de00498bbaaf58260 100644 --- a/browser/components/enterprisepolicies/helpers/moz.build +++ b/browser/components/enterprisepolicies/helpers/moz.build @@ -8,7 +8,7 @@ with Files("**"): BUG_COMPONENT = ("Firefox", "Enterprise Policies") EXTRA_JS_MODULES.policies += [ - "BookmarksPolicies.jsm", - "ProxyPolicies.jsm", - "WebsiteFilter.jsm", + 'BookmarksPolicies.jsm', + 'ProxyPolicies.jsm', + 'WebsiteFilter.jsm', ] diff --git a/browser/components/enterprisepolicies/moz.build b/browser/components/enterprisepolicies/moz.build index e7ae4b19c5b746141119f0b5b06c3c73a4631ed2..165bcb0eb97d39358575920bd9dda0068647ce14 100644 --- a/browser/components/enterprisepolicies/moz.build +++ b/browser/components/enterprisepolicies/moz.build @@ -7,19 +7,21 @@ with Files("**"): BUG_COMPONENT = ("Firefox", "Enterprise Policies") -SPHINX_TREES["docs"] = "docs" +SPHINX_TREES['docs'] = 'docs' DIRS += [ - "helpers", - "schemas", + 'helpers', + 'schemas', ] -TEST_DIRS += ["tests"] +TEST_DIRS += [ + 'tests' +] EXTRA_JS_MODULES.policies += [ - "Policies.jsm", + 'Policies.jsm', ] -FINAL_LIBRARY = "browsercomps" +FINAL_LIBRARY = 'browsercomps' -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] diff --git a/browser/components/enterprisepolicies/schemas/moz.build b/browser/components/enterprisepolicies/schemas/moz.build index 19e17705e798c9cdcbcb3bea2e242485341926df..54c07f17316945812ac92748e74a836de8668802 100644 --- a/browser/components/enterprisepolicies/schemas/moz.build +++ b/browser/components/enterprisepolicies/schemas/moz.build @@ -8,5 +8,5 @@ with Files("**"): BUG_COMPONENT = ("Firefox", "Enterprise Policies") EXTRA_PP_JS_MODULES.policies += [ - "schema.jsm", + 'schema.jsm', ] diff --git a/browser/components/enterprisepolicies/tests/moz.build b/browser/components/enterprisepolicies/tests/moz.build index abb21770236d8fee4869987b2e71467dfca21daf..023442ca994962f17df5a1fa58f9f8f99c022a91 100644 --- a/browser/components/enterprisepolicies/tests/moz.build +++ b/browser/components/enterprisepolicies/tests/moz.build @@ -5,14 +5,14 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. BROWSER_CHROME_MANIFESTS += [ - "browser/browser.ini", - "browser/disable_app_update/browser.ini", - "browser/disable_default_bookmarks/browser.ini", - "browser/disable_developer_tools/browser.ini", - "browser/disable_forget_button/browser.ini", - "browser/disable_fxscreenshots/browser.ini", - "browser/hardware_acceleration/browser.ini", - "browser/managedbookmarks/browser.ini", + 'browser/browser.ini', + 'browser/disable_app_update/browser.ini', + 'browser/disable_default_bookmarks/browser.ini', + 'browser/disable_developer_tools/browser.ini', + 'browser/disable_forget_button/browser.ini', + 'browser/disable_fxscreenshots/browser.ini', + 'browser/hardware_acceleration/browser.ini', + 'browser/managedbookmarks/browser.ini', ] -XPCSHELL_TESTS_MANIFESTS += ["xpcshell/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['xpcshell/xpcshell.ini'] diff --git a/browser/components/extensions/moz.build b/browser/components/extensions/moz.build index 5c1ac44fc569175f72aec49a8d34b65e0ce3f55d..e25ba29dcbc757c0a06ae67d3274b202022f80de 100644 --- a/browser/components/extensions/moz.build +++ b/browser/components/extensions/moz.build @@ -7,25 +7,25 @@ with Files("**"): BUG_COMPONENT = ("WebExtensions", "Untriaged") -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] EXTRA_COMPONENTS += [ - "extensions-browser.manifest", + 'extensions-browser.manifest', ] EXTRA_JS_MODULES += [ - "ExtensionControlledPopup.jsm", - "ExtensionPopups.jsm", + 'ExtensionControlledPopup.jsm', + 'ExtensionPopups.jsm', ] -DIRS += ["schemas"] +DIRS += ['schemas'] BROWSER_CHROME_MANIFESTS += [ - "test/browser/browser-private.ini", - "test/browser/browser.ini", + 'test/browser/browser-private.ini', + 'test/browser/browser.ini', ] -MOCHITEST_MANIFESTS += ["test/mochitest/mochitest.ini"] +MOCHITEST_MANIFESTS += ['test/mochitest/mochitest.ini'] XPCSHELL_TESTS_MANIFESTS += [ - "test/xpcshell/xpcshell.ini", + 'test/xpcshell/xpcshell.ini', ] diff --git a/browser/components/extensions/schemas/moz.build b/browser/components/extensions/schemas/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..aac3a838c4c23967e486fa9b2f0f92ec7ef45fae 100644 --- a/browser/components/extensions/schemas/moz.build +++ b/browser/components/extensions/schemas/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] diff --git a/browser/components/fxmonitor/moz.build b/browser/components/fxmonitor/moz.build index 1315cd4f5b072a08fb56934669baed4eceb74173..9ecbb6d368297920a76da925a530dc24c75a05c1 100644 --- a/browser/components/fxmonitor/moz.build +++ b/browser/components/fxmonitor/moz.build @@ -4,13 +4,14 @@ # 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/. -with Files("**"): - BUG_COMPONENT = ("Firefox", "Firefox Monitor") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Firefox Monitor') EXTRA_JS_MODULES += [ - "FirefoxMonitor.jsm", + 'FirefoxMonitor.jsm', ] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] + +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] diff --git a/browser/components/installerprefs/moz.build b/browser/components/installerprefs/moz.build index 853f2d888a806cbd6fd47bec99e0a8af46be1804..064c580224cde40e29150b76a5d9bd06eed24112 100644 --- a/browser/components/installerprefs/moz.build +++ b/browser/components/installerprefs/moz.build @@ -4,15 +4,15 @@ # 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/. -with Files("**"): - BUG_COMPONENT = ("Firefox", "Installer") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Installer') -XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] EXTRA_JS_MODULES += [ - "InstallerPrefs.jsm", + 'InstallerPrefs.jsm', ] XPCOM_MANIFESTS += [ - "components.conf", + 'components.conf', ] diff --git a/browser/components/ion/moz.build b/browser/components/ion/moz.build index 24736258a6f2939ec5d30af7a7b76fe98e75c0cb..44c5110bbde1b65570a2e66e22634e1be7b96938 100644 --- a/browser/components/ion/moz.build +++ b/browser/components/ion/moz.build @@ -4,14 +4,14 @@ # 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/. -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] -with Files("**"): - BUG_COMPONENT = ("Firefox", "General") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'General') TESTING_JS_MODULES += [ - "schemas/IonContentSchema.json", - "schemas/IonStudyAddonsSchema.json", + 'schemas/IonContentSchema.json', + 'schemas/IonStudyAddonsSchema.json', ] diff --git a/browser/components/migration/moz.build b/browser/components/migration/moz.build index 778c7f938bf2992bd2303a006f1c1c0de8cc0882..e56a3329dc17b4af53e3783d7b0266ba28dfff78 100644 --- a/browser/components/migration/moz.build +++ b/browser/components/migration/moz.build @@ -4,64 +4,64 @@ # 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/. -XPCSHELL_TESTS_MANIFESTS += ["tests/unit/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini'] -MARIONETTE_UNIT_MANIFESTS += ["tests/marionette/manifest.ini"] +MARIONETTE_UNIT_MANIFESTS += ['tests/marionette/manifest.ini'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] XPIDL_SOURCES += [ - "nsIBrowserProfileMigrator.idl", + 'nsIBrowserProfileMigrator.idl', ] -XPIDL_MODULE = "migration" +XPIDL_MODULE = 'migration' EXTRA_JS_MODULES += [ - "ChromeMigrationUtils.jsm", - "ChromeProfileMigrator.jsm", - "FirefoxProfileMigrator.jsm", - "MigrationUtils.jsm", - "ProfileMigrator.jsm", + 'ChromeMigrationUtils.jsm', + 'ChromeProfileMigrator.jsm', + 'FirefoxProfileMigrator.jsm', + 'MigrationUtils.jsm', + 'ProfileMigrator.jsm', ] -if CONFIG["OS_ARCH"] == "WINNT": - if CONFIG["ENABLE_TESTS"]: +if CONFIG['OS_ARCH'] == 'WINNT': + if CONFIG['ENABLE_TESTS']: DIRS += [ - "tests/unit/insertIEHistory", + 'tests/unit/insertIEHistory', ] SOURCES += [ - "nsIEHistoryEnumerator.cpp", + 'nsIEHistoryEnumerator.cpp', ] EXTRA_JS_MODULES += [ - "360seProfileMigrator.jsm", - "ChromeWindowsLoginCrypto.jsm", - "EdgeProfileMigrator.jsm", - "ESEDBReader.jsm", - "IEProfileMigrator.jsm", - "MSMigrationUtils.jsm", + '360seProfileMigrator.jsm', + 'ChromeWindowsLoginCrypto.jsm', + 'EdgeProfileMigrator.jsm', + 'ESEDBReader.jsm', + 'IEProfileMigrator.jsm', + 'MSMigrationUtils.jsm', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': EXPORTS += [ - "nsKeychainMigrationUtils.h", + 'nsKeychainMigrationUtils.h', ] EXTRA_JS_MODULES += [ - "ChromeMacOSLoginCrypto.jsm", - "SafariProfileMigrator.jsm", + 'ChromeMacOSLoginCrypto.jsm', + 'SafariProfileMigrator.jsm', ] SOURCES += [ - "nsKeychainMigrationUtils.mm", + 'nsKeychainMigrationUtils.mm', ] XPIDL_SOURCES += [ - "nsIKeychainMigrationUtils.idl", + 'nsIKeychainMigrationUtils.idl', ] XPCOM_MANIFESTS += [ - "components.conf", + 'components.conf', ] -FINAL_LIBRARY = "browsercomps" +FINAL_LIBRARY = 'browsercomps' -with Files("**"): - BUG_COMPONENT = ("Firefox", "Migration") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Migration') diff --git a/browser/components/migration/tests/unit/insertIEHistory/moz.build b/browser/components/migration/tests/unit/insertIEHistory/moz.build index 33c261c74688e2bd3f282887e6beaca71a45e7c1..76ac757fb221e3ea50ef2c7d09df21fe66e18d38 100644 --- a/browser/components/migration/tests/unit/insertIEHistory/moz.build +++ b/browser/components/migration/tests/unit/insertIEHistory/moz.build @@ -4,14 +4,14 @@ # 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/. -FINAL_TARGET = "_tests/xpcshell/browser/components/migration/tests/unit" +FINAL_TARGET = '_tests/xpcshell/browser/components/migration/tests/unit' -Program("InsertIEHistory") +Program('InsertIEHistory') OS_LIBS += [ - "ole32", + 'ole32', ] SOURCES += [ - "InsertIEHistory.cpp", + 'InsertIEHistory.cpp', ] NO_PGO = True diff --git a/browser/components/moz.build b/browser/components/moz.build index ba617de9d82f2e165b50411c31acd90c71243636..d9906d053f6b685dc9764594e67e05d270360e7a 100644 --- a/browser/components/moz.build +++ b/browser/components/moz.build @@ -22,86 +22,88 @@ with Files("tests/unit/test_distribution.js"): with Files("safebrowsing/**"): BUG_COMPONENT = ("Toolkit", "Safe Browsing") -with Files("controlcenter/**"): - BUG_COMPONENT = ("Firefox", "General") +with Files('controlcenter/**'): + BUG_COMPONENT = ('Firefox', 'General') DIRS += [ - "about", - "aboutconfig", - "aboutlogins", - "attribution", - "contextualidentity", - "customizableui", - "doh", - "downloads", - "enterprisepolicies", - "extensions", - "fxmonitor", - "migration", - "newtab", - "originattributes", - "ion", - "places", - "pocket", - "preferences", - "privatebrowsing", - "prompts", - "protections", - "protocolhandler", - "resistfingerprinting", - "search", - "sessionstore", - "shell", - "ssb", - "syncedtabs", - "uitour", - "urlbar", - "translation", + 'about', + 'aboutconfig', + 'aboutlogins', + 'attribution', + 'contextualidentity', + 'customizableui', + 'doh', + 'downloads', + 'enterprisepolicies', + 'extensions', + 'fxmonitor', + 'migration', + 'newtab', + 'originattributes', + 'ion', + 'places', + 'pocket', + 'preferences', + 'privatebrowsing', + 'prompts', + 'protections', + 'protocolhandler', + 'resistfingerprinting', + 'search', + 'sessionstore', + 'shell', + 'ssb', + 'syncedtabs', + 'uitour', + 'urlbar', + 'translation', ] -DIRS += ["build"] +DIRS += ['build'] -if CONFIG["NIGHTLY_BUILD"]: +if CONFIG['NIGHTLY_BUILD']: DIRS += [ - "payments", + 'payments', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": - DIRS += ["touchbar"] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": - DIRS += ["installerprefs"] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': + DIRS += ['touchbar'] +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + DIRS += ['installerprefs'] XPIDL_SOURCES += [ - "nsIBrowserHandler.idl", + 'nsIBrowserHandler.idl', ] -XPIDL_MODULE = "browsercompsbase" +XPIDL_MODULE = 'browsercompsbase' XPCOM_MANIFESTS += [ - "components.conf", + 'components.conf', ] EXTRA_COMPONENTS += [ - "BrowserComponents.manifest", - "tests/startupRecorder.js", - "tests/testComponents.manifest", + 'BrowserComponents.manifest', + 'tests/startupRecorder.js', + 'tests/testComponents.manifest', ] EXTRA_JS_MODULES += [ - "BrowserContentHandler.jsm", - "BrowserGlue.jsm", - "distribution.js", + 'BrowserContentHandler.jsm', + 'BrowserGlue.jsm', + 'distribution.js', ] BROWSER_CHROME_MANIFESTS += [ - "safebrowsing/content/test/browser.ini", - "tests/browser/browser.ini", + 'safebrowsing/content/test/browser.ini', + 'tests/browser/browser.ini', ] -if CONFIG["MOZ_UPDATER"]: +if CONFIG['MOZ_UPDATER']: BROWSER_CHROME_MANIFESTS += [ - "tests/browser/whats_new_page/browser.ini", + 'tests/browser/whats_new_page/browser.ini', ] -XPCSHELL_TESTS_MANIFESTS += ["tests/unit/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += [ + 'tests/unit/xpcshell.ini' +] diff --git a/browser/components/newtab/moz.build b/browser/components/newtab/moz.build index 73a6d512841eda66a19ce57436ce23d883e23a92..8b2d7476c40c30d0463d9f68bfaf188d20cda636 100644 --- a/browser/components/newtab/moz.build +++ b/browser/components/newtab/moz.build @@ -8,36 +8,36 @@ with Files("**"): BUG_COMPONENT = ("Firefox", "New Tab Page") BROWSER_CHROME_MANIFESTS += [ - "test/browser/abouthomecache/browser.ini", - "test/browser/browser.ini", + 'test/browser/abouthomecache/browser.ini', + 'test/browser/browser.ini', ] -SPHINX_TREES["docs"] = "docs" -SPHINX_TREES["content-src/asrouter/docs"] = "content-src/asrouter/docs" +SPHINX_TREES['docs'] = 'docs' +SPHINX_TREES['content-src/asrouter/docs'] = 'content-src/asrouter/docs' XPCSHELL_TESTS_MANIFESTS += [ - "test/xpcshell/xpcshell.ini", + 'test/xpcshell/xpcshell.ini', ] XPIDL_SOURCES += [ - "nsIAboutNewTabService.idl", + 'nsIAboutNewTabService.idl', ] -XPIDL_MODULE = "browser-newtab" +XPIDL_MODULE = 'browser-newtab' EXTRA_JS_MODULES += [ - "AboutNewTabService.jsm", + 'AboutNewTabService.jsm', ] FINAL_TARGET_FILES.actors += [ - "aboutwelcome/AboutWelcomeChild.jsm", - "aboutwelcome/AboutWelcomeParent.jsm", - "actors/ASRouterChild.jsm", - "actors/ASRouterParent.jsm", + 'aboutwelcome/AboutWelcomeChild.jsm', + 'aboutwelcome/AboutWelcomeParent.jsm', + 'actors/ASRouterChild.jsm', + 'actors/ASRouterParent.jsm', ] XPCOM_MANIFESTS += [ - "components.conf", + 'components.conf', ] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] diff --git a/browser/components/originattributes/moz.build b/browser/components/originattributes/moz.build index 707d61ce1a12591867eddca494b114a6c14eba4f..502e5f2b1d6cd83c3c434d884693826519f3635c 100644 --- a/browser/components/originattributes/moz.build +++ b/browser/components/originattributes/moz.build @@ -5,10 +5,12 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. BROWSER_CHROME_MANIFESTS += [ - "test/browser/browser.ini", + 'test/browser/browser.ini', ] -MOCHITEST_MANIFESTS += ["test/mochitest/mochitest.ini"] +MOCHITEST_MANIFESTS += [ + 'test/mochitest/mochitest.ini' +] -with Files("**"): - BUG_COMPONENT = ("Core", "DOM: Security") +with Files('**'): + BUG_COMPONENT = ('Core', 'DOM: Security') diff --git a/browser/components/payments/moz.build b/browser/components/payments/moz.build index 6c764f85fa99f101884acf395755e5bab38593c6..1b4604c754dbaa781c3d13e11ce8285e911de021 100644 --- a/browser/components/payments/moz.build +++ b/browser/components/payments/moz.build @@ -4,33 +4,33 @@ # 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/. -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] -with Files("**"): - BUG_COMPONENT = ("Firefox", "WebPayments UI") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'WebPayments UI') EXTRA_JS_MODULES += [ - "PaymentUIService.jsm", + 'PaymentUIService.jsm', ] XPCOM_MANIFESTS += [ - "components.conf", + 'components.conf', ] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] MOCHITEST_MANIFESTS += [ - "test/mochitest/formautofill/mochitest.ini", - "test/mochitest/mochitest.ini", + 'test/mochitest/formautofill/mochitest.ini', + 'test/mochitest/mochitest.ini', ] -SPHINX_TREES["docs"] = "docs" +SPHINX_TREES['docs'] = 'docs' -with Files("docs/**"): - SCHEDULES.exclusive = ["docs"] +with Files('docs/**'): + SCHEDULES.exclusive = ['docs'] TESTING_JS_MODULES += [ - "test/PaymentTestUtils.jsm", + 'test/PaymentTestUtils.jsm', ] -XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] diff --git a/browser/components/payments/server.py b/browser/components/payments/server.py index 7cb8380260a0d8a2877a8d0a07fd91e90a1da956..9b85bd0b572f89e4b470f5f152b3e7d509c4cb3b 100644 --- a/browser/components/payments/server.py +++ b/browser/components/payments/server.py @@ -11,13 +11,14 @@ class RequestHandler(SimpleHTTPRequestHandler, object): def translate_path(self, path): # Map autofill paths to their own directory autofillPath = "/formautofill" - if path.startswith(autofillPath): - path = "browser/extensions/formautofill/content" + path[len(autofillPath) :] + if (path.startswith(autofillPath)): + path = "browser/extensions/formautofill/content" + \ + path[len(autofillPath):] else: path = "browser/components/payments/res" + path return super(RequestHandler, self).translate_path(path) -if __name__ == "__main__": +if __name__ == '__main__': BaseHTTPServer.test(RequestHandler, BaseHTTPServer.HTTPServer) diff --git a/browser/components/places/moz.build b/browser/components/places/moz.build index ee7920749860ffe7ccb0b71cb651470beb1a3906..e6f88b318c9d0d6710eb5a6aeaf7b5d493699021 100644 --- a/browser/components/places/moz.build +++ b/browser/components/places/moz.build @@ -4,15 +4,15 @@ # 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/. -XPCSHELL_TESTS_MANIFESTS += ["tests/unit/xpcshell.ini"] -MOCHITEST_CHROME_MANIFESTS += ["tests/chrome/chrome.ini"] -BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"] +XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini'] +MOCHITEST_CHROME_MANIFESTS += ['tests/chrome/chrome.ini'] +BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] EXTRA_JS_MODULES += [ - "PlacesUIUtils.jsm", + 'PlacesUIUtils.jsm', ] -with Files("**"): - BUG_COMPONENT = ("Firefox", "Bookmarks & History") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Bookmarks & History') diff --git a/browser/components/pocket/moz.build b/browser/components/pocket/moz.build index fb823da11c7dfa3b6991e2c9504505c08c4a75c1..f6e00831eee201e78702d5d144fd30c9c08a7bf3 100644 --- a/browser/components/pocket/moz.build +++ b/browser/components/pocket/moz.build @@ -7,6 +7,6 @@ with Files("**"): BUG_COMPONENT = ("Firefox", "Pocket") -BROWSER_CHROME_MANIFESTS += ["test/browser.ini", "test/unit/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser.ini', 'test/unit/browser.ini'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] diff --git a/browser/components/preferences/dialogs/moz.build b/browser/components/preferences/dialogs/moz.build index 603c56050521d95a782fb39544c7e42a3f2a632b..5045224be3c27f2c80ff3c29b690f3846e2bcc67 100644 --- a/browser/components/preferences/dialogs/moz.build +++ b/browser/components/preferences/dialogs/moz.build @@ -4,10 +4,10 @@ # 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/. -for var in ("MOZ_APP_NAME", "MOZ_MACBUNDLE_NAME"): +for var in ('MOZ_APP_NAME', 'MOZ_MACBUNDLE_NAME'): DEFINES[var] = CONFIG[var] -if CONFIG["MOZ_WIDGET_TOOLKIT"] in ("windows", "gtk", "cocoa"): - DEFINES["HAVE_SHELL_SERVICE"] = 1 +if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk', 'cocoa'): + DEFINES['HAVE_SHELL_SERVICE'] = 1 -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] diff --git a/browser/components/preferences/moz.build b/browser/components/preferences/moz.build index 67163934c72fdc23dbc6e8c7101765ad35dcb532..76c619ccea19c4bdc3de26050046587641e06841 100644 --- a/browser/components/preferences/moz.build +++ b/browser/components/preferences/moz.build @@ -4,17 +4,22 @@ # 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/. -DIRS += ["dialogs"] +DIRS += [ + 'dialogs' +] -BROWSER_CHROME_MANIFESTS += ["tests/browser.ini", "tests/siteData/browser.ini"] +BROWSER_CHROME_MANIFESTS += [ + 'tests/browser.ini', + 'tests/siteData/browser.ini' +] -for var in ("MOZ_APP_NAME", "MOZ_MACBUNDLE_NAME"): +for var in ('MOZ_APP_NAME', 'MOZ_MACBUNDLE_NAME'): DEFINES[var] = CONFIG[var] -if CONFIG["MOZ_WIDGET_TOOLKIT"] in ("windows", "gtk", "cocoa"): - DEFINES["HAVE_SHELL_SERVICE"] = 1 +if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk', 'cocoa'): + DEFINES['HAVE_SHELL_SERVICE'] = 1 -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] -with Files("**"): - BUG_COMPONENT = ("Firefox", "Preferences") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Preferences') diff --git a/browser/components/privatebrowsing/moz.build b/browser/components/privatebrowsing/moz.build index 7078f7e4db17151c5cca5b01cbf90def6074e30d..486737a7f3c46d9a9a14d3baa9ede29572c4c7cc 100644 --- a/browser/components/privatebrowsing/moz.build +++ b/browser/components/privatebrowsing/moz.build @@ -5,10 +5,10 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. BROWSER_CHROME_MANIFESTS += [ - "test/browser/browser.ini", + 'test/browser/browser.ini', ] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] -with Files("**"): - BUG_COMPONENT = ("Firefox", "Private Browsing") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Private Browsing') diff --git a/browser/components/prompts/moz.build b/browser/components/prompts/moz.build index 4c6d33af909506be35d5dac765cd58c9f0c4972f..21d5d2418e0ac786e1641e4b837b93255d538873 100644 --- a/browser/components/prompts/moz.build +++ b/browser/components/prompts/moz.build @@ -6,9 +6,9 @@ with Files("**"): BUG_COMPONENT = ("Toolkit", "Notifications and Alerts") EXTRA_JS_MODULES += [ - "PromptCollection.jsm", + 'PromptCollection.jsm', ] XPCOM_MANIFESTS += [ - "components.conf", + 'components.conf', ] diff --git a/browser/components/protections/moz.build b/browser/components/protections/moz.build index 57bd0a917fa9ba8aaeddba12407769badd3c18c6..8cb4f4bca5705f67aab72202840ab1059aebdef9 100644 --- a/browser/components/protections/moz.build +++ b/browser/components/protections/moz.build @@ -4,9 +4,9 @@ # 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/. -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] -with Files("**"): - BUG_COMPONENT = ("Firefox", "Protections UI") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Protections UI') diff --git a/browser/components/protocolhandler/moz.build b/browser/components/protocolhandler/moz.build index 6e23e023cf0e0093896d23d0a2694354c8e224e7..b06afbfa9c8d1270aabd0b7439828df36dbacc66 100644 --- a/browser/components/protocolhandler/moz.build +++ b/browser/components/protocolhandler/moz.build @@ -4,15 +4,15 @@ # 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/. -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] EXTRA_JS_MODULES += [ - "WebProtocolHandlerRegistrar.jsm", + 'WebProtocolHandlerRegistrar.jsm', ] XPCOM_MANIFESTS += [ - "components.conf", + 'components.conf', ] -with Files("**"): - BUG_COMPONENT = ("Firefox", "General") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'General') diff --git a/browser/components/resistfingerprinting/moz.build b/browser/components/resistfingerprinting/moz.build index c99c2f8f94b6d2e4d726e31097162298520c56c9..953cc416a024db163afd9876dbb93bb3eb629a8b 100644 --- a/browser/components/resistfingerprinting/moz.build +++ b/browser/components/resistfingerprinting/moz.build @@ -8,13 +8,13 @@ with Files("**"): BUG_COMPONENT = ("Core", "Security") BROWSER_CHROME_MANIFESTS += [ - "test/browser/browser.ini", + 'test/browser/browser.ini', ] MOCHITEST_MANIFESTS += [ - "test/mochitest/mochitest.ini", + 'test/mochitest/mochitest.ini', ] MOCHITEST_CHROME_MANIFESTS += [ - "test/chrome/chrome.ini", -] + 'test/chrome/chrome.ini', +] \ No newline at end of file diff --git a/browser/components/search/moz.build b/browser/components/search/moz.build index efb73b82fe902a1bff52e483df5df0e1e6dee8d1..18653c878cdc3b25869aba17253ac36a0aac2cb4 100644 --- a/browser/components/search/moz.build +++ b/browser/components/search/moz.build @@ -5,21 +5,21 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXTRA_JS_MODULES += [ - "SearchOneOffs.jsm", - "SearchTelemetry.jsm", - "SearchUIUtils.jsm", + 'SearchOneOffs.jsm', + 'SearchTelemetry.jsm', + 'SearchUIUtils.jsm', ] BROWSER_CHROME_MANIFESTS += [ - "test/browser/browser.ini", - "test/browser/google_codes/browser.ini", + 'test/browser/browser.ini', + 'test/browser/google_codes/browser.ini', ] -MARIONETTE_LAYOUT_MANIFESTS += ["test/marionette/manifest.ini"] +MARIONETTE_LAYOUT_MANIFESTS += ['test/marionette/manifest.ini'] -XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] -with Files("**"): - BUG_COMPONENT = ("Firefox", "Search") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Search') diff --git a/browser/components/search/test/marionette/test_engines_on_restart.py b/browser/components/search/test/marionette/test_engines_on_restart.py index 5f9bfe63340028813fdb9c7bfe9edff269573225..6a657245df32e17066c9559dfe33d8f8e87de7a7 100644 --- a/browser/components/search/test/marionette/test_engines_on_restart.py +++ b/browser/components/search/test/marionette/test_engines_on_restart.py @@ -10,13 +10,12 @@ from marionette_harness.marionette_test import MarionetteTestCase class TestEnginesOnRestart(MarionetteTestCase): + def setUp(self): super(TestEnginesOnRestart, self).setUp() - self.marionette.enforce_gecko_prefs( - { - "browser.search.log": True, - } - ) + self.marionette.enforce_gecko_prefs({ + 'browser.search.log': True, + }) def get_default_search_engine(self): """Retrieve the identifier of the default search engine.""" diff --git a/browser/components/sessionstore/moz.build b/browser/components/sessionstore/moz.build index cdbdba2b3197778b910b8766f1790a2a4a729f0c..07006d8d06b28d7275f984bf9f21775df158df64 100644 --- a/browser/components/sessionstore/moz.build +++ b/browser/components/sessionstore/moz.build @@ -4,31 +4,31 @@ # 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/. -XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] -BROWSER_CHROME_MANIFESTS += ["test/browser.ini"] +XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] +BROWSER_CHROME_MANIFESTS += ['test/browser.ini'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] EXTRA_JS_MODULES.sessionstore = [ - "ContentRestore.jsm", - "ContentSessionStore.jsm", - "GlobalState.jsm", - "RecentlyClosedTabsAndWindowsMenuUtils.jsm", - "RunState.jsm", - "SessionCookies.jsm", - "SessionFile.jsm", - "SessionMigration.jsm", - "SessionSaver.jsm", - "SessionStartup.jsm", - "SessionStore.jsm", - "SessionWorker.js", - "SessionWorker.jsm", - "StartupPerformance.jsm", - "TabAttributes.jsm", - "TabState.jsm", - "TabStateCache.jsm", - "TabStateFlusher.jsm", + 'ContentRestore.jsm', + 'ContentSessionStore.jsm', + 'GlobalState.jsm', + 'RecentlyClosedTabsAndWindowsMenuUtils.jsm', + 'RunState.jsm', + 'SessionCookies.jsm', + 'SessionFile.jsm', + 'SessionMigration.jsm', + 'SessionSaver.jsm', + 'SessionStartup.jsm', + 'SessionStore.jsm', + 'SessionWorker.js', + 'SessionWorker.jsm', + 'StartupPerformance.jsm', + 'TabAttributes.jsm', + 'TabState.jsm', + 'TabStateCache.jsm', + 'TabStateFlusher.jsm', ] -with Files("**"): - BUG_COMPONENT = ("Firefox", "Session Restore") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Session Restore') diff --git a/browser/components/shell/moz.build b/browser/components/shell/moz.build index eec5f0a879c409cc62eada1a71ff2e434d950135..fb4dea0b4277eea75f7660d1b8de8d79120d4dde 100644 --- a/browser/components/shell/moz.build +++ b/browser/components/shell/moz.build @@ -5,75 +5,77 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # For BinaryPath::GetLong for Windows -LOCAL_INCLUDES += ["/xpcom/build"] +LOCAL_INCLUDES += [ + '/xpcom/build' +] -BROWSER_CHROME_MANIFESTS += ["test/browser.ini"] -MOCHITEST_CHROME_MANIFESTS += ["test/chrome.ini"] -XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser.ini'] +MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini'] +XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] XPIDL_SOURCES += [ - "nsIShellService.idl", + 'nsIShellService.idl', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': XPIDL_SOURCES += [ - "nsIMacShellService.idl", + 'nsIMacShellService.idl', ] SOURCES += [ - "nsMacShellService.cpp", + 'nsMacShellService.cpp', ] LOCAL_INCLUDES += [ # For CocoaFileUtils - "/xpcom/io" + '/xpcom/io' ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': XPIDL_SOURCES += [ - "nsIGNOMEShellService.idl", + 'nsIGNOMEShellService.idl', ] SOURCES += [ - "nsGNOMEShellService.cpp", + 'nsGNOMEShellService.cpp', ] - if CONFIG["MOZ_ENABLE_DBUS"]: + if CONFIG['MOZ_ENABLE_DBUS']: SOURCES += [ - "nsGNOMEShellDBusHelper.cpp", - "nsGNOMEShellSearchProvider.cpp", + 'nsGNOMEShellDBusHelper.cpp', + 'nsGNOMEShellSearchProvider.cpp', ] - include("/ipc/chromium/chromium-config.mozbuild") + include('/ipc/chromium/chromium-config.mozbuild') -elif CONFIG["OS_ARCH"] == "WINNT": +elif CONFIG['OS_ARCH'] == 'WINNT': XPIDL_SOURCES += [ - "nsIWindowsShellService.idl", + 'nsIWindowsShellService.idl', ] SOURCES += [ - "nsWindowsShellService.cpp", - "WindowsDefaultBrowser.cpp", + 'nsWindowsShellService.cpp', + 'WindowsDefaultBrowser.cpp', ] LOCAL_INCLUDES += [ - "../../../other-licenses/nsis/Contrib/CityHash/cityhash", + '../../../other-licenses/nsis/Contrib/CityHash/cityhash', ] -XPIDL_MODULE = "shellservice" +XPIDL_MODULE = 'shellservice' if SOURCES: - FINAL_LIBRARY = "browsercomps" + FINAL_LIBRARY = 'browsercomps' EXTRA_JS_MODULES += [ - "HeadlessShell.jsm", - "ScreenshotChild.jsm", - "ShellService.jsm", + 'HeadlessShell.jsm', + 'ScreenshotChild.jsm', + 'ShellService.jsm', ] -for var in ("MOZ_APP_NAME", "MOZ_APP_VERSION"): +for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION'): DEFINES[var] = '"%s"' % CONFIG[var] -CXXFLAGS += CONFIG["TK_CFLAGS"] -if CONFIG["MOZ_ENABLE_DBUS"]: - CXXFLAGS += CONFIG["MOZ_DBUS_GLIB_CFLAGS"] +CXXFLAGS += CONFIG['TK_CFLAGS'] +if CONFIG['MOZ_ENABLE_DBUS']: + CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS'] -with Files("**"): - BUG_COMPONENT = ("Firefox", "Shell Integration") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Shell Integration') diff --git a/browser/components/shell/test/mac_desktop_image.py b/browser/components/shell/test/mac_desktop_image.py index ca7bc0b29726634558e8b44c6d42ec7e44203781..0d3c9cb15957f524ce30c67a9911e1bd1d3f511c 100755 --- a/browser/components/shell/test/mac_desktop_image.py +++ b/browser/components/shell/test/mac_desktop_image.py @@ -34,40 +34,24 @@ import sys def main(): - parser = argparse.ArgumentParser( - description="Utility to print, set, or " - + "check the path to image being used as " - + "the desktop background image. By " - + "default, prints the path to the " - + "current desktop background image." - ) - parser.add_argument( - "-v", - "--verbose", - action="store_true", - help="print verbose debugging information", - default=False, - ) + parser = argparse.ArgumentParser(description="Utility to print, set, or " + + "check the path to image being used as " + + "the desktop background image. By " + + "default, prints the path to the " + + "current desktop background image.") + parser.add_argument("-v", "--verbose", action="store_true", + help="print verbose debugging information", + default=False) group = parser.add_mutually_exclusive_group() - group.add_argument( - "-s", - "--set-background-image", - dest="newBackgroundImagePath", - required=False, - help="path to the new background image to set. A zero " - + "exit code indicates no errors occurred.", - default=None, - ) - group.add_argument( - "-c", - "--check-background-image", - dest="checkBackgroundImagePath", - required=False, - help="check if the provided background image path " - + "matches the provided path. A zero exit code " - + "indicates the paths match.", - default=None, - ) + group.add_argument("-s", "--set-background-image", + dest='newBackgroundImagePath', required=False, + help="path to the new background image to set. A zero " + + "exit code indicates no errors occurred.", default=None) + group.add_argument("-c", "--check-background-image", + dest='checkBackgroundImagePath', required=False, + help="check if the provided background image path " + + "matches the provided path. A zero exit code " + + "indicates the paths match.", default=None) args = parser.parse_args() # Using logging for verbose output @@ -75,14 +59,12 @@ def main(): logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.CRITICAL) - logger = logging.getLogger("desktopImage") + logger = logging.getLogger('desktopImage') # Print what we're going to do if args.checkBackgroundImagePath is not None: - logger.debug( - "checking provided desktop image %s matches current " - "image" % args.checkBackgroundImagePath - ) + logger.debug("checking provided desktop image %s matches current " + "image" % args.checkBackgroundImagePath) elif args.newBackgroundImagePath is not None: logger.debug("setting image to %s " % args.newBackgroundImagePath) else: @@ -139,8 +121,7 @@ def main(): status = False (status, error) = ws.setDesktopImageURL_forScreen_options_error_( - newImageURL, focussedScreen, None, None - ) + newImageURL, focussedScreen, None, None) if not status: raise RuntimeError("setDesktopImageURL error") @@ -164,7 +145,7 @@ def getCurrentDesktopImageURL(focussedScreen, workspace, logger): return imageURL -if __name__ == "__main__": +if __name__ == '__main__': if not main(): sys.exit(1) else: diff --git a/browser/components/ssb/moz.build b/browser/components/ssb/moz.build index d686475dcb43c6516b5bab43efe21a7912810178..b799f00f053cf8daa06fe788ee03305fd98626f6 100644 --- a/browser/components/ssb/moz.build +++ b/browser/components/ssb/moz.build @@ -4,28 +4,28 @@ # 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/. -JAR_MANIFESTS += ["content/jar.mn"] -BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"] -XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"] +JAR_MANIFESTS += ['content/jar.mn'] +BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini'] +XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini'] XPCOM_MANIFESTS += [ - "components.conf", + 'components.conf', ] EXTRA_JS_MODULES += [ - "SiteSpecificBrowserService.jsm", + 'SiteSpecificBrowserService.jsm', ] EXTRA_JS_MODULES.ssb += [ - "ImageTools.jsm", + 'ImageTools.jsm', ] FINAL_TARGET_FILES.actors += [ - "SiteSpecificBrowserChild.jsm", - "SiteSpecificBrowserParent.jsm", + 'SiteSpecificBrowserChild.jsm', + 'SiteSpecificBrowserParent.jsm', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': EXTRA_JS_MODULES.ssb += [ - "WindowsSupport.jsm", + 'WindowsSupport.jsm', ] diff --git a/browser/components/syncedtabs/moz.build b/browser/components/syncedtabs/moz.build index 710477a6458afc36349e9ae45acc1a5e10b426b9..cdee0c283a811fda1dfc556613f986c184eee238 100644 --- a/browser/components/syncedtabs/moz.build +++ b/browser/components/syncedtabs/moz.build @@ -2,22 +2,23 @@ # 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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] -XPCSHELL_TESTS_MANIFESTS += ["test/xpcshell/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini'] EXTRA_JS_MODULES.syncedtabs += [ - "EventEmitter.jsm", - "SyncedTabsDeckComponent.js", - "SyncedTabsDeckStore.js", - "SyncedTabsDeckView.js", - "SyncedTabsListStore.js", - "TabListComponent.js", - "TabListView.js", - "util.js", + 'EventEmitter.jsm', + 'SyncedTabsDeckComponent.js', + 'SyncedTabsDeckStore.js', + 'SyncedTabsDeckView.js', + 'SyncedTabsListStore.js', + 'TabListComponent.js', + 'TabListView.js', + 'util.js', ] -with Files("**"): - BUG_COMPONENT = ("Firefox", "Sync") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Sync') + diff --git a/browser/components/touchbar/moz.build b/browser/components/touchbar/moz.build index 25b669b033859981282849237be4e6a7767a2fa4..f9099cfad1684267cffc2ff8994f0956546b9a76 100644 --- a/browser/components/touchbar/moz.build +++ b/browser/components/touchbar/moz.build @@ -2,14 +2,14 @@ # 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/. -with Files("**"): - BUG_COMPONENT = ("Core", "Widget: Cocoa") +with Files('**'): + BUG_COMPONENT = ('Core', 'Widget: Cocoa') -BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini'] EXTRA_COMPONENTS += [ - "MacTouchBar.js", - "MacTouchBar.manifest", + 'MacTouchBar.js', + 'MacTouchBar.manifest', ] -SPHINX_TREES["/browser/touchbar"] = "docs" +SPHINX_TREES['/browser/touchbar'] = 'docs' diff --git a/browser/components/translation/content/moz.build b/browser/components/translation/content/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..eb4454d28f88bf1075c4e70e38a0f7943b6ffb1f 100644 --- a/browser/components/translation/content/moz.build +++ b/browser/components/translation/content/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/browser/components/translation/moz.build b/browser/components/translation/moz.build index 99217d9e828fbaed72f04d4fa73bd5a27463be60..5d4c61eb15c92196c01f7b2e86302911c6f4f008 100644 --- a/browser/components/translation/moz.build +++ b/browser/components/translation/moz.build @@ -3,24 +3,28 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DIRS += [ - "content", + 'content', ] with Files("**"): BUG_COMPONENT = ("Firefox", "Translation") EXTRA_JS_MODULES.translation = [ - "BingTranslator.jsm", - "cld2/cld-worker.js", - "cld2/cld-worker.js.mem", - "GoogleTranslator.jsm", - "LanguageDetector.jsm", - "TranslationChild.jsm", - "TranslationDocument.jsm", - "TranslationParent.jsm", - "YandexTranslator.jsm", + 'BingTranslator.jsm', + 'cld2/cld-worker.js', + 'cld2/cld-worker.js.mem', + 'GoogleTranslator.jsm', + 'LanguageDetector.jsm', + 'TranslationChild.jsm', + 'TranslationDocument.jsm', + 'TranslationParent.jsm', + 'YandexTranslator.jsm' ] -BROWSER_CHROME_MANIFESTS += ["test/browser.ini"] +BROWSER_CHROME_MANIFESTS += [ + 'test/browser.ini' +] -XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += [ + 'test/unit/xpcshell.ini' +] diff --git a/browser/components/uitour/moz.build b/browser/components/uitour/moz.build index e98ce45ae8b3c395e601f549498e36531d297269..5a2b3e8aeb432c334457565a73dcea0c5f3cda06 100644 --- a/browser/components/uitour/moz.build +++ b/browser/components/uitour/moz.build @@ -2,13 +2,17 @@ # 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/. -EXTRA_JS_MODULES += ["UITour.jsm", "UITourChild.jsm", "UITourParent.jsm"] +EXTRA_JS_MODULES += [ + 'UITour.jsm', + 'UITourChild.jsm', + 'UITourParent.jsm' +] BROWSER_CHROME_MANIFESTS += [ - "test/browser.ini", + 'test/browser.ini', ] -SPHINX_TREES["docs"] = "docs" +SPHINX_TREES['docs'] = 'docs' -with Files("**"): - BUG_COMPONENT = ("Firefox", "Tours") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Tours') diff --git a/browser/components/urlbar/moz.build b/browser/components/urlbar/moz.build index cdade1db67fc4c8cc038b172f82dd3c3c10da038..8da3bc9e5f5ab33e10339a03fd243e24f4aa0266 100644 --- a/browser/components/urlbar/moz.build +++ b/browser/components/urlbar/moz.build @@ -6,42 +6,42 @@ with Files("**"): BUG_COMPONENT = ("Firefox", "Address Bar") EXTRA_JS_MODULES += [ - "UrlbarController.jsm", - "UrlbarEventBufferer.jsm", - "UrlbarInput.jsm", - "UrlbarMuxerUnifiedComplete.jsm", - "UrlbarPrefs.jsm", - "UrlbarProviderAutofill.jsm", - "UrlbarProviderExtension.jsm", - "UrlbarProviderHeuristicFallback.jsm", - "UrlbarProviderInterventions.jsm", - "UrlbarProviderOmnibox.jsm", - "UrlbarProviderOpenTabs.jsm", - "UrlbarProviderPrivateSearch.jsm", - "UrlbarProviderSearchSuggestions.jsm", - "UrlbarProviderSearchTips.jsm", - "UrlbarProvidersManager.jsm", - "UrlbarProviderTabToSearch.jsm", - "UrlbarProviderTokenAliasEngines.jsm", - "UrlbarProviderTopSites.jsm", - "UrlbarProviderUnifiedComplete.jsm", - "UrlbarResult.jsm", - "UrlbarSearchOneOffs.jsm", - "UrlbarSearchUtils.jsm", - "UrlbarTokenizer.jsm", - "UrlbarUtils.jsm", - "UrlbarValueFormatter.jsm", - "UrlbarView.jsm", + 'UrlbarController.jsm', + 'UrlbarEventBufferer.jsm', + 'UrlbarInput.jsm', + 'UrlbarMuxerUnifiedComplete.jsm', + 'UrlbarPrefs.jsm', + 'UrlbarProviderAutofill.jsm', + 'UrlbarProviderExtension.jsm', + 'UrlbarProviderHeuristicFallback.jsm', + 'UrlbarProviderInterventions.jsm', + 'UrlbarProviderOmnibox.jsm', + 'UrlbarProviderOpenTabs.jsm', + 'UrlbarProviderPrivateSearch.jsm', + 'UrlbarProviderSearchSuggestions.jsm', + 'UrlbarProviderSearchTips.jsm', + 'UrlbarProvidersManager.jsm', + 'UrlbarProviderTabToSearch.jsm', + 'UrlbarProviderTokenAliasEngines.jsm', + 'UrlbarProviderTopSites.jsm', + 'UrlbarProviderUnifiedComplete.jsm', + 'UrlbarResult.jsm', + 'UrlbarSearchOneOffs.jsm', + 'UrlbarSearchUtils.jsm', + 'UrlbarTokenizer.jsm', + 'UrlbarUtils.jsm', + 'UrlbarValueFormatter.jsm', + 'UrlbarView.jsm', ] TESTING_JS_MODULES += [ - "tests/UrlbarTestUtils.jsm", + 'tests/UrlbarTestUtils.jsm', ] BROWSER_CHROME_MANIFESTS += [ - "tests/browser-tips/browser.ini", - "tests/browser/browser.ini", - "tests/ext/browser/browser.ini", + 'tests/browser-tips/browser.ini', + 'tests/browser/browser.ini', + 'tests/ext/browser/browser.ini', ] -XPCSHELL_TESTS_MANIFESTS += ["tests/unit/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini'] -SPHINX_TREES["/browser/urlbar"] = "docs" +SPHINX_TREES['/browser/urlbar'] = 'docs' diff --git a/browser/extensions/doh-rollout/moz.build b/browser/extensions/doh-rollout/moz.build index bce8283117de8419c7960f4c8b9227db6816e5ea..b3a78fc1be5af5e295ef0d5ec00e945cfb4669ec 100644 --- a/browser/extensions/doh-rollout/moz.build +++ b/browser/extensions/doh-rollout/moz.build @@ -4,11 +4,13 @@ # 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/. -DEFINES["MOZ_APP_VERSION"] = CONFIG["MOZ_APP_VERSION"] -DEFINES["MOZ_APP_MAXVERSION"] = CONFIG["MOZ_APP_MAXVERSION"] +DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION'] +DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION'] -FINAL_TARGET_FILES.features["doh-rollout@mozilla.org"] += ["manifest.json"] +FINAL_TARGET_FILES.features['doh-rollout@mozilla.org'] += [ + 'manifest.json' +] -with Files("**"): - BUG_COMPONENT = ("Firefox", "Security") +with Files('**'): + BUG_COMPONENT = ('Firefox', 'Security') diff --git a/browser/extensions/formautofill/locales/moz.build b/browser/extensions/formautofill/locales/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..aac3a838c4c23967e486fa9b2f0f92ec7ef45fae 100644 --- a/browser/extensions/formautofill/locales/moz.build +++ b/browser/extensions/formautofill/locales/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] diff --git a/browser/extensions/formautofill/moz.build b/browser/extensions/formautofill/moz.build index ef46740c3c93c13f20e5203b312ad94bac7cf9d1..46e92f430988bb9bb93aab3408abe6329a2f1970 100644 --- a/browser/extensions/formautofill/moz.build +++ b/browser/extensions/formautofill/moz.build @@ -4,50 +4,50 @@ # 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/. -DEFINES["MOZ_APP_VERSION"] = CONFIG["MOZ_APP_VERSION"] -DEFINES["MOZ_APP_MAXVERSION"] = CONFIG["MOZ_APP_MAXVERSION"] +DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION'] +DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION'] -DIRS += ["locales"] +DIRS += ['locales'] -FINAL_TARGET_FILES.features["formautofill@mozilla.org"] += [ - "api.js", - "background.js", - "manifest.json", - "schema.json", +FINAL_TARGET_FILES.features['formautofill@mozilla.org'] += [ + 'api.js', + 'background.js', + 'manifest.json', + 'schema.json', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": - FINAL_TARGET_FILES.features["formautofill@mozilla.org"].chrome.content.skin += [ - "skin/linux/autocomplete-item.css", - "skin/linux/editDialog.css", +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': + FINAL_TARGET_FILES.features['formautofill@mozilla.org'].chrome.content.skin += [ + 'skin/linux/autocomplete-item.css', + 'skin/linux/editDialog.css', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": - FINAL_TARGET_FILES.features["formautofill@mozilla.org"].chrome.content.skin += [ - "skin/osx/autocomplete-item.css", - "skin/osx/editDialog.css", +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': + FINAL_TARGET_FILES.features['formautofill@mozilla.org'].chrome.content.skin += [ + 'skin/osx/autocomplete-item.css', + 'skin/osx/editDialog.css', ] -elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": - FINAL_TARGET_FILES.features["formautofill@mozilla.org"].chrome.content.skin += [ - "skin/windows/autocomplete-item.css", - "skin/windows/editDialog.css", +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + FINAL_TARGET_FILES.features['formautofill@mozilla.org'].chrome.content.skin += [ + 'skin/windows/autocomplete-item.css', + 'skin/windows/editDialog.css', ] BROWSER_CHROME_MANIFESTS += [ - "test/browser/browser.ini", - "test/browser/creditCard/browser.ini", - "test/browser/focus-leak/browser.ini", + 'test/browser/browser.ini', + 'test/browser/creditCard/browser.ini', + 'test/browser/focus-leak/browser.ini', ] -XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] MOCHITEST_MANIFESTS += [ - "test/mochitest/creditCard/mochitest.ini", - "test/mochitest/mochitest.ini", + 'test/mochitest/creditCard/mochitest.ini', + 'test/mochitest/mochitest.ini', ] -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] -SPHINX_TREES["docs"] = "docs" +SPHINX_TREES['docs'] = 'docs' -with Files("**"): - BUG_COMPONENT = ("Toolkit", "Form Autofill") +with Files('**'): + BUG_COMPONENT = ('Toolkit', 'Form Autofill') diff --git a/browser/extensions/moz.build b/browser/extensions/moz.build index 0eb3c53e76c2e040676b99b9caec14e0ee6b678f..f71ece63c42da3884eb48fff00bcc21baec489be 100644 --- a/browser/extensions/moz.build +++ b/browser/extensions/moz.build @@ -4,4 +4,10 @@ # 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/. -DIRS += ["doh-rollout", "formautofill", "screenshots", "webcompat", "report-site-issue"] +DIRS += [ + 'doh-rollout', + 'formautofill', + 'screenshots', + 'webcompat', + 'report-site-issue' +] diff --git a/browser/extensions/report-site-issue/locales/moz.build b/browser/extensions/report-site-issue/locales/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..eb4454d28f88bf1075c4e70e38a0f7943b6ffb1f 100644 --- a/browser/extensions/report-site-issue/locales/moz.build +++ b/browser/extensions/report-site-issue/locales/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/browser/extensions/report-site-issue/moz.build b/browser/extensions/report-site-issue/moz.build index e3e92a33198fbc588287b5c8acd3005134dddb8a..466c38f723bd1eff46995c8964012d83d733f162 100644 --- a/browser/extensions/report-site-issue/moz.build +++ b/browser/extensions/report-site-issue/moz.build @@ -4,38 +4,38 @@ # 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/. -DEFINES["MOZ_APP_VERSION"] = CONFIG["MOZ_APP_VERSION"] -DEFINES["MOZ_APP_MAXVERSION"] = CONFIG["MOZ_APP_MAXVERSION"] +DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION'] +DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION'] -DIRS += ["locales"] +DIRS += ['locales'] -FINAL_TARGET_FILES.features["webcompat-reporter@mozilla.org"] += [ - "background.js", - "manifest.json", +FINAL_TARGET_FILES.features['webcompat-reporter@mozilla.org'] += [ + 'background.js', + 'manifest.json' ] -FINAL_TARGET_FILES.features["webcompat-reporter@mozilla.org"].experimentalAPIs += [ - "experimentalAPIs/aboutConfigPrefs.js", - "experimentalAPIs/aboutConfigPrefs.json", - "experimentalAPIs/browserInfo.js", - "experimentalAPIs/browserInfo.json", - "experimentalAPIs/l10n.js", - "experimentalAPIs/l10n.json", - "experimentalAPIs/pageActionExtras.js", - "experimentalAPIs/pageActionExtras.json", - "experimentalAPIs/tabExtras.js", - "experimentalAPIs/tabExtras.json", +FINAL_TARGET_FILES.features['webcompat-reporter@mozilla.org'].experimentalAPIs += [ + 'experimentalAPIs/aboutConfigPrefs.js', + 'experimentalAPIs/aboutConfigPrefs.json', + 'experimentalAPIs/browserInfo.js', + 'experimentalAPIs/browserInfo.json', + 'experimentalAPIs/l10n.js', + 'experimentalAPIs/l10n.json', + 'experimentalAPIs/pageActionExtras.js', + 'experimentalAPIs/pageActionExtras.json', + 'experimentalAPIs/tabExtras.js', + 'experimentalAPIs/tabExtras.json' ] -FINAL_TARGET_FILES.features[ - "webcompat-reporter@mozilla.org" -].experimentalAPIs.actors += ["experimentalAPIs/actors/tabExtrasActor.jsm"] +FINAL_TARGET_FILES.features['webcompat-reporter@mozilla.org'].experimentalAPIs.actors += [ + 'experimentalAPIs/actors/tabExtrasActor.jsm' +] -FINAL_TARGET_FILES.features["webcompat-reporter@mozilla.org"].icons += [ - "icons/lightbulb.svg" +FINAL_TARGET_FILES.features['webcompat-reporter@mozilla.org'].icons += [ + 'icons/lightbulb.svg' ] -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] -with Files("**"): - BUG_COMPONENT = ("Web Compatibility", "Tooling & Investigations") +with Files('**'): + BUG_COMPONENT = ('Web Compatibility', 'Tooling & Investigations') diff --git a/browser/extensions/screenshots/moz.build b/browser/extensions/screenshots/moz.build index 3a1b161357282e4eafb295b184cdadb57246f9e6..10f01f690c4dea06fe91ba13bdf347318db619ee 100644 --- a/browser/extensions/screenshots/moz.build +++ b/browser/extensions/screenshots/moz.build @@ -9,73 +9,76 @@ with Files("**"): # This file list is automatically generated by Screenshots' export scripts. # AUTOMATIC INSERTION START -FINAL_TARGET_FILES.features["screenshots@mozilla.org"] += [ - "assertIsBlankDocument.js", - "assertIsTrusted.js", - "blank.html", - "blobConverters.js", - "catcher.js", - "clipboard.js", - "domainFromUrl.js", - "log.js", - "makeUuid.js", - "manifest.json", - "moz.build", - "randomString.js", - "sitehelper.js", +FINAL_TARGET_FILES.features['screenshots@mozilla.org'] += [ + 'assertIsBlankDocument.js', + 'assertIsTrusted.js', + 'blank.html', + 'blobConverters.js', + 'catcher.js', + 'clipboard.js', + 'domainFromUrl.js', + 'log.js', + 'makeUuid.js', + 'manifest.json', + 'moz.build', + 'randomString.js', + 'sitehelper.js' ] -FINAL_TARGET_FILES.features["screenshots@mozilla.org"]["background"] += [ - "background/analytics.js", - "background/auth.js", - "background/communication.js", - "background/deviceInfo.js", - "background/main.js", - "background/selectorLoader.js", - "background/senderror.js", - "background/startBackground.js", - "background/takeshot.js", +FINAL_TARGET_FILES.features['screenshots@mozilla.org']["background"] += [ + 'background/analytics.js', + 'background/auth.js', + 'background/communication.js', + 'background/deviceInfo.js', + 'background/main.js', + 'background/selectorLoader.js', + 'background/senderror.js', + 'background/startBackground.js', + 'background/takeshot.js' ] -FINAL_TARGET_FILES.features["screenshots@mozilla.org"]["build"] += [ - "build/buildSettings.js", - "build/inlineSelectionCss.js", - "build/raven.js", - "build/selection.js", - "build/shot.js", - "build/thumbnailGenerator.js", +FINAL_TARGET_FILES.features['screenshots@mozilla.org']["build"] += [ + 'build/buildSettings.js', + 'build/inlineSelectionCss.js', + 'build/raven.js', + 'build/selection.js', + 'build/shot.js', + 'build/thumbnailGenerator.js' ] -FINAL_TARGET_FILES.features["screenshots@mozilla.org"]["experiments"][ - "screenshots" -] += ["experiments/screenshots/api.js", "experiments/screenshots/schema.json"] +FINAL_TARGET_FILES.features['screenshots@mozilla.org']["experiments"]["screenshots"] += [ + 'experiments/screenshots/api.js', + 'experiments/screenshots/schema.json' +] -FINAL_TARGET_FILES.features["screenshots@mozilla.org"]["icons"] += [ - "icons/cancel.svg", - "icons/cloud.svg", - "icons/copied-notification.svg", - "icons/copy.svg", - "icons/download-white.svg", - "icons/download.svg", - "icons/help-16.svg", - "icons/icon-highlight-32-v2.svg", - "icons/icon-v2.svg", - "icons/icon-welcome-face-without-eyes.svg", - "icons/menu-fullpage.svg", - "icons/menu-myshot-white.svg", - "icons/menu-myshot.svg", - "icons/menu-visible.svg", +FINAL_TARGET_FILES.features['screenshots@mozilla.org']["icons"] += [ + 'icons/cancel.svg', + 'icons/cloud.svg', + 'icons/copied-notification.svg', + 'icons/copy.svg', + 'icons/download-white.svg', + 'icons/download.svg', + 'icons/help-16.svg', + 'icons/icon-highlight-32-v2.svg', + 'icons/icon-v2.svg', + 'icons/icon-welcome-face-without-eyes.svg', + 'icons/menu-fullpage.svg', + 'icons/menu-myshot-white.svg', + 'icons/menu-myshot.svg', + 'icons/menu-visible.svg', ] -FINAL_TARGET_FILES.features["screenshots@mozilla.org"]["selector"] += [ - "selector/callBackground.js", - "selector/documentMetadata.js", - "selector/shooter.js", - "selector/ui.js", - "selector/uicontrol.js", - "selector/util.js", +FINAL_TARGET_FILES.features['screenshots@mozilla.org']["selector"] += [ + 'selector/callBackground.js', + 'selector/documentMetadata.js', + 'selector/shooter.js', + 'selector/ui.js', + 'selector/uicontrol.js', + 'selector/util.js' ] # AUTOMATIC INSERTION END -BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += [ + 'test/browser/browser.ini' +] diff --git a/browser/extensions/webcompat/moz.build b/browser/extensions/webcompat/moz.build index 87320a05c25b643e0f934b636bab17c0d2fa7ba2..fccc7aac1bb3147dacd5138f152f0a992a151280 100644 --- a/browser/extensions/webcompat/moz.build +++ b/browser/extensions/webcompat/moz.build @@ -4,120 +4,120 @@ # 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/. -DEFINES["MOZ_APP_VERSION"] = CONFIG["MOZ_APP_VERSION"] -DEFINES["MOZ_APP_MAXVERSION"] = CONFIG["MOZ_APP_MAXVERSION"] +DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION'] +DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION'] -FINAL_TARGET_FILES.features["webcompat@mozilla.org"] += [ - "manifest.json", - "run.js", +FINAL_TARGET_FILES.features['webcompat@mozilla.org'] += [ + 'manifest.json', + 'run.js', ] -FINAL_TARGET_FILES.features["webcompat@mozilla.org"]["about-compat"] += [ - "about-compat/aboutCompat.css", - "about-compat/aboutCompat.html", - "about-compat/aboutCompat.js", - "about-compat/AboutCompat.jsm", - "about-compat/aboutPage.js", - "about-compat/aboutPage.json", - "about-compat/aboutPageProcessScript.js", +FINAL_TARGET_FILES.features['webcompat@mozilla.org']['about-compat'] += [ + 'about-compat/aboutCompat.css', + 'about-compat/aboutCompat.html', + 'about-compat/aboutCompat.js', + 'about-compat/AboutCompat.jsm', + 'about-compat/aboutPage.js', + 'about-compat/aboutPage.json', + 'about-compat/aboutPageProcessScript.js', ] -FINAL_TARGET_FILES.features["webcompat@mozilla.org"]["data"] += [ - "data/injections.js", - "data/picture_in_picture_overrides.js", - "data/shims.js", - "data/ua_overrides.js", +FINAL_TARGET_FILES.features['webcompat@mozilla.org']['data'] += [ + 'data/injections.js', + 'data/picture_in_picture_overrides.js', + 'data/shims.js', + 'data/ua_overrides.js', ] -FINAL_TARGET_FILES.features["webcompat@mozilla.org"]["experiment-apis"] += [ - "experiment-apis/aboutConfigPrefs.js", - "experiment-apis/aboutConfigPrefs.json", - "experiment-apis/appConstants.js", - "experiment-apis/appConstants.json", - "experiment-apis/experiments.js", - "experiment-apis/experiments.json", - "experiment-apis/matchPatterns.js", - "experiment-apis/matchPatterns.json", - "experiment-apis/pictureInPicture.js", - "experiment-apis/pictureInPicture.json", - "experiment-apis/sharedPreferences.js", - "experiment-apis/sharedPreferences.json", - "experiment-apis/systemManufacturer.js", - "experiment-apis/systemManufacturer.json", - "experiment-apis/trackingProtection.js", - "experiment-apis/trackingProtection.json", +FINAL_TARGET_FILES.features['webcompat@mozilla.org']['experiment-apis'] += [ + 'experiment-apis/aboutConfigPrefs.js', + 'experiment-apis/aboutConfigPrefs.json', + 'experiment-apis/appConstants.js', + 'experiment-apis/appConstants.json', + 'experiment-apis/experiments.js', + 'experiment-apis/experiments.json', + 'experiment-apis/matchPatterns.js', + 'experiment-apis/matchPatterns.json', + 'experiment-apis/pictureInPicture.js', + 'experiment-apis/pictureInPicture.json', + 'experiment-apis/sharedPreferences.js', + 'experiment-apis/sharedPreferences.json', + 'experiment-apis/systemManufacturer.js', + 'experiment-apis/systemManufacturer.json', + 'experiment-apis/trackingProtection.js', + 'experiment-apis/trackingProtection.json', ] -FINAL_TARGET_FILES.features["webcompat@mozilla.org"]["injections"]["css"] += [ - "injections/css/bug0000000-testbed-css-injection.css", - "injections/css/bug1561371-mail.google.com-allow-horizontal-scrolling.css", - "injections/css/bug1570119-teamcoco.com-scrollbar-width.css", - "injections/css/bug1570328-developer-apple.com-transform-scale.css", - "injections/css/bug1575000-apply.lloydsbank.co.uk-radio-buttons-fix.css", - "injections/css/bug1577297-kitkat.com.au-slider-width-fix.css", - "injections/css/bug1605611-maps.google.com-directions-time.css", - "injections/css/bug1610016-gaana.com-input-position-fix.css", - "injections/css/bug1610344-directv.com.co-hide-unsupported-message.css", - "injections/css/bug1632019-everyman.co-gallery-width-fix.css", - "injections/css/bug1644830-missingmail.usps.com-checkboxes-not-visible.css", - "injections/css/bug1645064-s-kanava.fi-invisible-charts.css", - "injections/css/bug1651917-teletrader.com.body-transform-origin.css", - "injections/css/bug1653075-livescience.com-scrollbar-width.css", - "injections/css/bug1654865-sports.ndtv.com-float-fix.css", - "injections/css/bug1654877-preev.com-moz-appearance-fix.css", - "injections/css/bug1654907-reactine.ca-hide-unsupported.css", - "injections/css/bug1655049-dev.to-unclickable-button-fix.css", - "injections/css/bug1666771-zilow-map-overdraw.css", +FINAL_TARGET_FILES.features['webcompat@mozilla.org']['injections']['css'] += [ + 'injections/css/bug0000000-testbed-css-injection.css', + 'injections/css/bug1561371-mail.google.com-allow-horizontal-scrolling.css', + 'injections/css/bug1570119-teamcoco.com-scrollbar-width.css', + 'injections/css/bug1570328-developer-apple.com-transform-scale.css', + 'injections/css/bug1575000-apply.lloydsbank.co.uk-radio-buttons-fix.css', + 'injections/css/bug1577297-kitkat.com.au-slider-width-fix.css', + 'injections/css/bug1605611-maps.google.com-directions-time.css', + 'injections/css/bug1610016-gaana.com-input-position-fix.css', + 'injections/css/bug1610344-directv.com.co-hide-unsupported-message.css', + 'injections/css/bug1632019-everyman.co-gallery-width-fix.css', + 'injections/css/bug1644830-missingmail.usps.com-checkboxes-not-visible.css', + 'injections/css/bug1645064-s-kanava.fi-invisible-charts.css', + 'injections/css/bug1651917-teletrader.com.body-transform-origin.css', + 'injections/css/bug1653075-livescience.com-scrollbar-width.css', + 'injections/css/bug1654865-sports.ndtv.com-float-fix.css', + 'injections/css/bug1654877-preev.com-moz-appearance-fix.css', + 'injections/css/bug1654907-reactine.ca-hide-unsupported.css', + 'injections/css/bug1655049-dev.to-unclickable-button-fix.css', + 'injections/css/bug1666771-zilow-map-overdraw.css', ] -FINAL_TARGET_FILES.features["webcompat@mozilla.org"]["injections"]["js"] += [ - "injections/js/bug0000000-testbed-js-injection.js", - "injections/js/bug1452707-window.controllers-shim-ib.absa.co.za.js", - "injections/js/bug1457335-histography.io-ua-change.js", - "injections/js/bug1472075-bankofamerica.com-ua-change.js", - "injections/js/bug1570856-medium.com-menu-isTier1.js", - "injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js", - "injections/js/bug1605611-maps.google.com-directions-time.js", - "injections/js/bug1610358-pcloud.com-appVersion-change.js", +FINAL_TARGET_FILES.features['webcompat@mozilla.org']['injections']['js'] += [ + 'injections/js/bug0000000-testbed-js-injection.js', + 'injections/js/bug1452707-window.controllers-shim-ib.absa.co.za.js', + 'injections/js/bug1457335-histography.io-ua-change.js', + 'injections/js/bug1472075-bankofamerica.com-ua-change.js', + 'injections/js/bug1570856-medium.com-menu-isTier1.js', + 'injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js', + 'injections/js/bug1605611-maps.google.com-directions-time.js', + 'injections/js/bug1610358-pcloud.com-appVersion-change.js', ] -FINAL_TARGET_FILES.features["webcompat@mozilla.org"]["shims"] += [ - "shims/adsafeprotected-ima.js", - "shims/bmauth.js", - "shims/eluminate.js", - "shims/empty-script.js", - "shims/facebook-sdk.js", - "shims/google-analytics-ecommerce-plugin.js", - "shims/google-analytics-legacy.js", - "shims/google-analytics-tag-manager.js", - "shims/google-analytics.js", - "shims/google-publisher-tags.js", - "shims/live-test-shim.js", - "shims/mochitest-shim-1.js", - "shims/mochitest-shim-2.js", - "shims/mochitest-shim-3.js", - "shims/rambler-authenticator.js", - "shims/rich-relevance.js", +FINAL_TARGET_FILES.features['webcompat@mozilla.org']['shims'] += [ + 'shims/adsafeprotected-ima.js', + 'shims/bmauth.js', + 'shims/eluminate.js', + 'shims/empty-script.js', + 'shims/facebook-sdk.js', + 'shims/google-analytics-ecommerce-plugin.js', + 'shims/google-analytics-legacy.js', + 'shims/google-analytics-tag-manager.js', + 'shims/google-analytics.js', + 'shims/google-publisher-tags.js', + 'shims/live-test-shim.js', + 'shims/mochitest-shim-1.js', + 'shims/mochitest-shim-2.js', + 'shims/mochitest-shim-3.js', + 'shims/rambler-authenticator.js', + 'shims/rich-relevance.js', ] -FINAL_TARGET_FILES.features["webcompat@mozilla.org"]["lib"] += [ - "lib/about_compat_broker.js", - "lib/custom_functions.js", - "lib/injections.js", - "lib/intervention_helpers.js", - "lib/messaging_helper.js", - "lib/module_shim.js", - "lib/picture_in_picture_overrides.js", - "lib/shim_messaging_helper.js", - "lib/shims.js", - "lib/ua_overrides.js", +FINAL_TARGET_FILES.features['webcompat@mozilla.org']['lib'] += [ + 'lib/about_compat_broker.js', + 'lib/custom_functions.js', + 'lib/injections.js', + 'lib/intervention_helpers.js', + 'lib/messaging_helper.js', + 'lib/module_shim.js', + 'lib/picture_in_picture_overrides.js', + 'lib/shim_messaging_helper.js', + 'lib/shims.js', + 'lib/ua_overrides.js', ] XPCOM_MANIFESTS += [ - "components.conf", + 'components.conf', ] -BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"] +BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini'] -with Files("**"): - BUG_COMPONENT = ("Web Compatibility", "Tooling & Investigations") +with Files('**'): + BUG_COMPONENT = ('Web Compatibility', 'Tooling & Investigations') diff --git a/browser/fonts/moz.build b/browser/fonts/moz.build index 7b9cb08f48e6ba977441fe7d4973694e2225b4dd..308dcabacececf647b195a48a6afe90cece7e42f 100644 --- a/browser/fonts/moz.build +++ b/browser/fonts/moz.build @@ -4,6 +4,8 @@ # 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/. -if CONFIG["MOZ_WIDGET_TOOLKIT"] in ("windows", "gtk"): - DIST_SUBDIR = "" - FINAL_TARGET_FILES.fonts += ["TwemojiMozilla.ttf"] +if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk'): + DIST_SUBDIR = '' + FINAL_TARGET_FILES.fonts += [ + 'TwemojiMozilla.ttf' + ] diff --git a/browser/fxr/moz.build b/browser/fxr/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..aac3a838c4c23967e486fa9b2f0f92ec7ef45fae 100644 --- a/browser/fxr/moz.build +++ b/browser/fxr/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] diff --git a/browser/installer/windows/moz.build b/browser/installer/windows/moz.build index 30d4c23bba093c133804c07f90fab0cee717d4b4..f0987ef9c3f4e212fe6dc79e76245e7e6f06fdf3 100644 --- a/browser/installer/windows/moz.build +++ b/browser/installer/windows/moz.build @@ -4,13 +4,13 @@ # 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/. -DEFINES["APP_VERSION"] = CONFIG["MOZ_APP_VERSION"] +DEFINES['APP_VERSION'] = CONFIG['MOZ_APP_VERSION'] -DEFINES["MOZ_APP_NAME"] = CONFIG["MOZ_APP_NAME"] -DEFINES["MOZ_APP_DISPLAYNAME"] = CONFIG["MOZ_APP_DISPLAYNAME"] -DEFINES["MOZILLA_VERSION"] = CONFIG["MOZILLA_VERSION"] +DEFINES['MOZ_APP_NAME'] = CONFIG['MOZ_APP_NAME'] +DEFINES['MOZ_APP_DISPLAYNAME'] = CONFIG['MOZ_APP_DISPLAYNAME'] +DEFINES['MOZILLA_VERSION'] = CONFIG['MOZILLA_VERSION'] -if CONFIG["MOZ_DEFAULT_BROWSER_AGENT"]: - DEFINES["MOZ_DEFAULT_BROWSER_AGENT"] = CONFIG["MOZ_DEFAULT_BROWSER_AGENT"] +if CONFIG['MOZ_DEFAULT_BROWSER_AGENT']: + DEFINES['MOZ_DEFAULT_BROWSER_AGENT'] = CONFIG['MOZ_DEFAULT_BROWSER_AGENT'] -SPHINX_TREES["installer"] = "docs" +SPHINX_TREES['installer'] = 'docs' diff --git a/browser/locales/filter.py b/browser/locales/filter.py index bb2e992e2e72edd6e50f3285b2be92b39369c8a1..1fc9b14e7c870a06c4198108cc27664cf488c884 100644 --- a/browser/locales/filter.py +++ b/browser/locales/filter.py @@ -7,25 +7,17 @@ from __future__ import absolute_import def test(mod, path, entity=None): import re - # ignore anything but Firefox - if mod not in ( - "netwerk", - "dom", - "toolkit", - "security/manager", - "devtools/client", - "devtools/shared", - "devtools/startup", - "browser", - "browser/extensions/formautofill", - "browser/extensions/fxmonitor", - "browser/extensions/report-site-issue", - "extensions/spellcheck", - "other-licenses/branding/firefox", - "browser/branding/official", - "services/sync", - ): + if mod not in ("netwerk", "dom", "toolkit", "security/manager", + "devtools/client", "devtools/shared", "devtools/startup", + "browser", + "browser/extensions/formautofill", + "browser/extensions/fxmonitor", + "browser/extensions/report-site-issue", + "extensions/spellcheck", + "other-licenses/branding/firefox", + "browser/branding/official", + "services/sync"): return "ignore" if mod not in ("browser", "extensions/spellcheck"): # we only have exceptions for browser and extensions/spellcheck @@ -43,13 +35,9 @@ def test(mod, path, entity=None): if mod == "browser" and path == "chrome/browser-region/region.properties": # only region.properties exceptions remain, compare all others - return ( - "ignore" - if ( - re.match(r"browser\.contentHandlers\.types\.[0-5]", entity) - or re.match(r"gecko\.handlerService\.schemes\.", entity) - or re.match(r"gecko\.handlerService\.defaultHandlersVersion", entity) - ) - else "error" - ) + return ("ignore" + if (re.match(r"browser\.contentHandlers\.types\.[0-5]", entity) or + re.match(r"gecko\.handlerService\.schemes\.", entity) or + re.match(r"gecko\.handlerService\.defaultHandlersVersion", entity)) + else "error") return "error" diff --git a/browser/locales/generate_bookmarks.py b/browser/locales/generate_bookmarks.py index 1b2002fcf9ca039643eb6519a78cf925c9f98b87..583a4dc49883b7f5940eb6b4d5c97963e383bdec 100644 --- a/browser/locales/generate_bookmarks.py +++ b/browser/locales/generate_bookmarks.py @@ -15,7 +15,7 @@ from mozbuild import preprocessor def main(output, bookmarks_html_in, bookmarks_inc, locale=None): if not locale: - raise ValueError("locale must be specified!") + raise ValueError('locale must be specified!') CONFIG = buildconfig.substs @@ -25,19 +25,19 @@ def main(output, bookmarks_html_in, bookmarks_inc, locale=None): # anything but #define), so it's safe to restrict the set of defines to # what's used in mozilla-central directly. defines = {} - defines["AB_CD"] = locale - if defines["AB_CD"] == "ja-JP-mac": - defines["AB_CD"] = "ja" + defines['AB_CD'] = locale + if defines['AB_CD'] == 'ja-JP-mac': + defines['AB_CD'] = 'ja' - defines["BOOKMARKS_INCLUDE_PATH"] = bookmarks_inc + defines['BOOKMARKS_INCLUDE_PATH'] = bookmarks_inc - for var in ("NIGHTLY_BUILD",): + for var in ('NIGHTLY_BUILD',): if var in CONFIG: defines[var] = CONFIG[var] - includes = preprocessor.preprocess( - includes=[bookmarks_html_in], defines=defines, output=output - ) + includes = preprocessor.preprocess(includes=[bookmarks_html_in], + defines=defines, + output=output) return includes diff --git a/browser/locales/generate_ini.py b/browser/locales/generate_ini.py index 2f2724dd96cb8639cdb0a89b95f4c759732cf2c2..e7488788e7deaa6f20a221b760da2ac3eb28ec09 100644 --- a/browser/locales/generate_ini.py +++ b/browser/locales/generate_ini.py @@ -14,16 +14,15 @@ import shutil def main(output, ini, ini_append=None, locale=None): - fixup_re = re.compile("^(Info|Title)Text=") + fixup_re = re.compile('^(Info|Title)Text=') # Input INI is always utf-8. - with codecs.open(ini, "rb", "utf_8") as f: + with codecs.open(ini, 'rb', 'utf_8') as f: for line in f: - line = fixup_re.sub(r"\1=", line) - line = line.replace( - "%MOZ_APP_DISPLAYNAME%", buildconfig.substs["MOZ_APP_DISPLAYNAME"] - ) + line = fixup_re.sub(r'\1=', line) + line = line.replace('%MOZ_APP_DISPLAYNAME%', + buildconfig.substs['MOZ_APP_DISPLAYNAME']) output.write(line) - if ini_append and buildconfig.substs["OS_TARGET"] == "WINNT": + if ini_append and buildconfig.substs['OS_TARGET'] == 'WINNT': # Also append the contents of `ini_append`. - with codecs.open(ini_append, "rb", "utf_8") as f: + with codecs.open(ini_append, 'rb', 'utf_8') as f: shutil.copyfileobj(f, output) diff --git a/browser/locales/moz.build b/browser/locales/moz.build index e1c27c75499d0c719b3f8377b80cfe05be7c3c08..90ae99d83fa7c355fe5b04b31e38d34750c5146c 100644 --- a/browser/locales/moz.build +++ b/browser/locales/moz.build @@ -4,35 +4,35 @@ # 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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] # If DIST_SUBDIR ever gets unset in browser this path might be wrong due to PREF_DIR changing. -LOCALIZED_PP_FILES.defaults.preferences += ["en-US/firefox-l10n.js"] +LOCALIZED_PP_FILES.defaults.preferences += ['en-US/firefox-l10n.js'] -if CONFIG["MOZ_CRASHREPORTER"]: - LOCALIZED_FILES += ["en-US/crashreporter/crashreporter-override.ini"] +if CONFIG['MOZ_CRASHREPORTER']: + LOCALIZED_FILES += ['en-US/crashreporter/crashreporter-override.ini'] -if CONFIG["MOZ_UPDATER"]: - LOCALIZED_GENERATED_FILES += ["updater.ini"] - updater = LOCALIZED_GENERATED_FILES["updater.ini"] - updater.script = "generate_ini.py" +if CONFIG['MOZ_UPDATER']: + LOCALIZED_GENERATED_FILES += ['updater.ini'] + updater = LOCALIZED_GENERATED_FILES['updater.ini'] + updater.script = 'generate_ini.py' updater.inputs = [ - "en-US/updater/updater.ini", - "../installer/windows/nsis/updater_append.ini", + 'en-US/updater/updater.ini', + '../installer/windows/nsis/updater_append.ini', ] # Yes, this is weird, but what can you do? This file doesn't want to be in the DIST_SUBDIR, # but we can't really move it to a different directory until we change how locale repacks # work. - LOCALIZED_FILES[".."] += ["!updater.ini"] + LOCALIZED_FILES['..'] += ['!updater.ini'] -LOCALIZED_GENERATED_FILES += ["bookmarks.html"] -bookmarks = LOCALIZED_GENERATED_FILES["bookmarks.html"] -bookmarks.script = "generate_bookmarks.py" +LOCALIZED_GENERATED_FILES += ['bookmarks.html'] +bookmarks = LOCALIZED_GENERATED_FILES['bookmarks.html'] +bookmarks.script = 'generate_bookmarks.py' bookmarks.inputs = [ # This input will not be considered for localization. - "generic/profile/bookmarks.html.in", + 'generic/profile/bookmarks.html.in', # The `locales/en-US/` will be rewritten to the locale-specific path. - "en-US/profile/bookmarks.inc", + 'en-US/profile/bookmarks.inc', ] with Files("**"): diff --git a/browser/modules/moz.build b/browser/modules/moz.build index 932d02fb8338d77954c2695d897400e0d3e04961..e60199812cec5d7b99b856b67b7cefc4082ea7ac 100644 --- a/browser/modules/moz.build +++ b/browser/modules/moz.build @@ -43,11 +43,11 @@ with Files("AboutNewTab.jsm"): with Files("AsanReporter.jsm"): BUG_COMPONENT = ("Firefox Build System", "General") -with Files("AsyncTabSwitcher.jsm"): - BUG_COMPONENT = ("Firefox", "Tabbed Browser") +with Files('AsyncTabSwitcher.jsm'): + BUG_COMPONENT = ('Firefox', 'Tabbed Browser') -with Files("NewTabPagePreloading.jsm"): - BUG_COMPONENT = ("Firefox", "Tabbed Browser") +with Files('NewTabPagePreloading.jsm'): + BUG_COMPONENT = ('Firefox', 'Tabbed Browser') with Files("BrowserWindowTracker.jsm"): BUG_COMPONENT = ("Firefox", "General") @@ -77,7 +77,7 @@ with Files("PartnerLinkAttribution.jsm"): BUG_COMPONENT = ("Firefox", "Search") with Files("PermissionUI.jsm"): - BUG_COMPONENT = ("Firefox", "Site Permissions") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("ProcessHangMonitor.jsm"): BUG_COMPONENT = ("Core", "DOM: Content Processes") @@ -119,52 +119,52 @@ with Files("ZoomUI.jsm"): BUG_COMPONENT = ("Firefox", "Toolbars and Customization") BROWSER_CHROME_MANIFESTS += [ - "test/browser/browser.ini", - "test/browser/formValidation/browser.ini", + 'test/browser/browser.ini', + 'test/browser/formValidation/browser.ini', ] -XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] EXTRA_JS_MODULES += [ - "AboutNewTab.jsm", - "AppUpdater.jsm", - "AsyncTabSwitcher.jsm", - "BrowserUsageTelemetry.jsm", - "BrowserWindowTracker.jsm", - "ContentCrashHandlers.jsm", - "Discovery.jsm", - "EveryWindow.jsm", - "ExtensionsUI.jsm", - "FaviconLoader.jsm", - "HomePage.jsm", - "LaterRun.jsm", - "LiveBookmarkMigrator.jsm", - "NewTabPagePreloading.jsm", - "OpenInTabsUtils.jsm", - "PageActions.jsm", - "PartnerLinkAttribution.jsm", - "PermissionUI.jsm", - "PingCentre.jsm", - "ProcessHangMonitor.jsm", - "Sanitizer.jsm", - "SelectionChangedMenulist.jsm", - "SiteDataManager.jsm", - "SitePermissions.jsm", - "TabsList.jsm", - "TabUnloader.jsm", - "ThemeVariableMap.jsm", - "TransientPrefs.jsm", - "webrtcUI.jsm", - "ZoomUI.jsm", + 'AboutNewTab.jsm', + 'AppUpdater.jsm', + 'AsyncTabSwitcher.jsm', + 'BrowserUsageTelemetry.jsm', + 'BrowserWindowTracker.jsm', + 'ContentCrashHandlers.jsm', + 'Discovery.jsm', + 'EveryWindow.jsm', + 'ExtensionsUI.jsm', + 'FaviconLoader.jsm', + 'HomePage.jsm', + 'LaterRun.jsm', + 'LiveBookmarkMigrator.jsm', + 'NewTabPagePreloading.jsm', + 'OpenInTabsUtils.jsm', + 'PageActions.jsm', + 'PartnerLinkAttribution.jsm', + 'PermissionUI.jsm', + 'PingCentre.jsm', + 'ProcessHangMonitor.jsm', + 'Sanitizer.jsm', + 'SelectionChangedMenulist.jsm', + 'SiteDataManager.jsm', + 'SitePermissions.jsm', + 'TabsList.jsm', + 'TabUnloader.jsm', + 'ThemeVariableMap.jsm', + 'TransientPrefs.jsm', + 'webrtcUI.jsm', + 'ZoomUI.jsm', ] -if CONFIG["MOZ_ASAN_REPORTER"]: +if CONFIG['MOZ_ASAN_REPORTER']: EXTRA_JS_MODULES += [ - "AsanReporter.jsm", + 'AsanReporter.jsm', ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': EXTRA_JS_MODULES += [ - "Windows8WindowFrameColor.jsm", - "WindowsJumpLists.jsm", - "WindowsPreviewPerTab.jsm", + 'Windows8WindowFrameColor.jsm', + 'WindowsJumpLists.jsm', + 'WindowsPreviewPerTab.jsm', ] diff --git a/browser/moz.build b/browser/moz.build index ca88ad0a94f7339621e236d64776a3b306371aa4..8cbf30a938ec88ed262cff22457993839dd7efc5 100644 --- a/browser/moz.build +++ b/browser/moz.build @@ -4,62 +4,62 @@ # 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/. -CONFIGURE_SUBST_FILES += ["installer/Makefile"] +CONFIGURE_SUBST_FILES += ['installer/Makefile'] -SPHINX_TREES["/browser"] = "docs" +SPHINX_TREES['/browser'] = 'docs' EXTRA_COMPONENTS += [ - "l10n-registry.manifest", + 'l10n-registry.manifest', ] DIRS += [ - "actors", - "base", - "components", - "fonts", - "fxr", - "locales", - "modules", - "themes", - "extensions", + 'actors', + 'base', + 'components', + 'fonts', + 'fxr', + 'locales', + 'modules', + 'themes', + 'extensions', ] DIRS += [ - "app", + 'app', ] -if CONFIG["MAKENSISU"]: - DIRS += ["installer/windows"] +if CONFIG['MAKENSISU']: + DIRS += ['installer/windows'] TEST_DIRS += [ - "tools/mozscreenshots", + 'tools/mozscreenshots', ] -DIST_SUBDIR = "browser" -export("DIST_SUBDIR") +DIST_SUBDIR = 'browser' +export('DIST_SUBDIR') # These defines are read in firefox.js -DEFINES["APP_VERSION"] = CONFIG["MOZ_APP_VERSION"] +DEFINES['APP_VERSION'] = CONFIG['MOZ_APP_VERSION'] -for cdm in CONFIG["MOZ_EME_MODULES"]: - DEFINES["MOZ_%s_EME" % cdm.upper()] = True +for cdm in CONFIG['MOZ_EME_MODULES']: + DEFINES['MOZ_%s_EME' % cdm.upper()] = True -if CONFIG["MOZ_GPSD"]: - DEFINES["MOZ_GPSD"] = True +if CONFIG['MOZ_GPSD']: + DEFINES['MOZ_GPSD'] = True # These files are specified in this moz.build to pick up DIST_SUBDIR as set in # this directory, which is un-set in browser/app. JS_PREFERENCE_PP_FILES += [ - "app/profile/firefox.js", + 'app/profile/firefox.js', ] -FINAL_TARGET_FILES.defaults += ["app/permissions"] +FINAL_TARGET_FILES.defaults += ['app/permissions'] with Files("**"): BUG_COMPONENT = ("Firefox", "General") - SCHEDULES.exclusive = ["linux", "macosx", "windows"] + SCHEDULES.exclusive = ['linux', 'macosx', 'windows'] -with Files("docs/**"): - SCHEDULES.exclusive = ["docs"] +with Files('docs/**'): + SCHEDULES.exclusive = ['docs'] with Files("Makefile.in"): BUG_COMPONENT = ("Firefox Build System", "General") @@ -103,5 +103,5 @@ with Files("installer/**"): with Files("tools/**"): BUG_COMPONENT = ("Firefox", "General") -with Files("l10n-registry.manifest"): - BUG_COMPONENT = ("Core", "Localization") +with Files('l10n-registry.manifest'): + BUG_COMPONENT = ('Core', 'Localization') diff --git a/browser/moz.configure b/browser/moz.configure index 8653bcbb165da86ad0cc615c6539a744ba99c280..a251050feb9b03287a9a051a8c16ff9eb132e4de 100644 --- a/browser/moz.configure +++ b/browser/moz.configure @@ -4,16 +4,18 @@ # 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/. -imply_option("MOZ_PLACES", True) -imply_option("MOZ_SERVICES_HEALTHREPORT", True) -imply_option("MOZ_SERVICES_SYNC", True) -imply_option("MOZ_DEDICATED_PROFILES", True) -imply_option("MOZ_BLOCK_PROFILE_DOWNGRADE", True) -imply_option("MOZ_NORMANDY", True) +imply_option('MOZ_PLACES', True) +imply_option('MOZ_SERVICES_HEALTHREPORT', True) +imply_option('MOZ_SERVICES_SYNC', True) +imply_option('MOZ_DEDICATED_PROFILES', True) +imply_option('MOZ_BLOCK_PROFILE_DOWNGRADE', True) +imply_option('MOZ_NORMANDY', True) with only_when(target_is_linux & compile_environment): - option(env="MOZ_NO_PIE_COMPAT", help="Enable non-PIE wrapper") + option(env='MOZ_NO_PIE_COMPAT', + help='Enable non-PIE wrapper') - set_config("MOZ_NO_PIE_COMPAT", depends_if("MOZ_NO_PIE_COMPAT")(lambda _: True)) + set_config('MOZ_NO_PIE_COMPAT', + depends_if('MOZ_NO_PIE_COMPAT')(lambda _: True)) -include("../toolkit/moz.configure") +include('../toolkit/moz.configure') diff --git a/browser/themes/addons/moz.build b/browser/themes/addons/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..aac3a838c4c23967e486fa9b2f0f92ec7ef45fae 100644 --- a/browser/themes/addons/moz.build +++ b/browser/themes/addons/moz.build @@ -4,4 +4,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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] diff --git a/browser/themes/linux/moz.build b/browser/themes/linux/moz.build index 20e4e3af75f52306a87562f97528392de81daf89..5f26f477c3daf331cdb33f137282ef5acb9381de 100644 --- a/browser/themes/linux/moz.build +++ b/browser/themes/linux/moz.build @@ -4,6 +4,7 @@ # 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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] + +DEFINES['MENUBAR_CAN_AUTOHIDE'] = 1 -DEFINES["MENUBAR_CAN_AUTOHIDE"] = 1 diff --git a/browser/themes/moz.build b/browser/themes/moz.build index 0e706766c5027e42e7fdb2a4d4b60536242f84f5..9ca868304245d482eac2a0279c4b9448f6e4ccab 100644 --- a/browser/themes/moz.build +++ b/browser/themes/moz.build @@ -7,24 +7,24 @@ with Files("**"): BUG_COMPONENT = ("Firefox", "Theme") -toolkit = CONFIG["MOZ_WIDGET_TOOLKIT"] +toolkit = CONFIG['MOZ_WIDGET_TOOLKIT'] -if toolkit == "cocoa": - DIRS += ["osx"] -elif toolkit == "gtk": - DIRS += ["linux"] +if toolkit == 'cocoa': + DIRS += ['osx'] +elif toolkit == 'gtk': + DIRS += ['linux'] else: - DIRS += ["windows"] + DIRS += ['windows'] DIRS += [ - "addons", + 'addons', ] -with Files("osx/**"): - SCHEDULES.exclusive = ["macosx"] +with Files('osx/**'): + SCHEDULES.exclusive = ['macosx'] -with Files("linux/**"): - SCHEDULES.exclusive = ["linux"] +with Files('linux/**'): + SCHEDULES.exclusive = ['linux'] -with Files("windows/**"): - SCHEDULES.exclusive = ["windows"] +with Files('windows/**'): + SCHEDULES.exclusive = ['windows'] diff --git a/browser/themes/osx/moz.build b/browser/themes/osx/moz.build index d988c0ff9b162c1f83ac1fbaf05ae59d090aa8b7..7daa419f1faa08efe66a352414715d94dc4ef8d3 100644 --- a/browser/themes/osx/moz.build +++ b/browser/themes/osx/moz.build @@ -4,4 +4,5 @@ # 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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] + diff --git a/browser/themes/windows/moz.build b/browser/themes/windows/moz.build index 20e4e3af75f52306a87562f97528392de81daf89..5f26f477c3daf331cdb33f137282ef5acb9381de 100644 --- a/browser/themes/windows/moz.build +++ b/browser/themes/windows/moz.build @@ -4,6 +4,7 @@ # 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/. -JAR_MANIFESTS += ["jar.mn"] +JAR_MANIFESTS += ['jar.mn'] + +DEFINES['MENUBAR_CAN_AUTOHIDE'] = 1 -DEFINES["MENUBAR_CAN_AUTOHIDE"] = 1 diff --git a/browser/tools/mozscreenshots/moz.build b/browser/tools/mozscreenshots/moz.build index a95940a208ecc2ea81e471aa5a532d2cd9f2b211..a0405fc562ce2def15fb03d5305f3c00325bab53 100644 --- a/browser/tools/mozscreenshots/moz.build +++ b/browser/tools/mozscreenshots/moz.build @@ -22,16 +22,16 @@ with Files("preferences/**"): BROWSER_CHROME_MANIFESTS += [ # Each test is in it's own directory so it gets run in a clean profile with # run-by-dir. - "controlCenter/browser.ini", - "devtools/browser.ini", - "permissionPrompts/browser.ini", - "preferences/browser.ini", - "primaryUI/browser.ini", - "tests/browser/browser.ini", + 'controlCenter/browser.ini', + 'devtools/browser.ini', + 'permissionPrompts/browser.ini', + 'preferences/browser.ini', + 'primaryUI/browser.ini', + 'tests/browser/browser.ini', ] TEST_DIRS += [ - "mozscreenshots/extension", + 'mozscreenshots/extension', ] -XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"] +XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini'] diff --git a/browser/tools/mozscreenshots/mozscreenshots/extension/moz.build b/browser/tools/mozscreenshots/mozscreenshots/extension/moz.build index 3b96b08ee1ab833b1372466294076d51b6a1a17d..dff4fc998a4cac26eab18bc4420c33a6bd72748e 100644 --- a/browser/tools/mozscreenshots/mozscreenshots/extension/moz.build +++ b/browser/tools/mozscreenshots/mozscreenshots/extension/moz.build @@ -4,55 +4,55 @@ # 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/. -XPI_NAME = "mozscreenshots" +XPI_NAME = 'mozscreenshots' USE_EXTENSION_MANIFEST = True FINAL_TARGET_FILES += [ - "api.js", - "manifest.json", - "schema.json", + 'api.js', + 'manifest.json', + 'schema.json', ] FINAL_TARGET_FILES.resources += [ - "Screenshot.jsm", - "TestRunner.jsm", + 'Screenshot.jsm', + 'TestRunner.jsm', ] FINAL_TARGET_FILES.resources.configurations += [ - "configurations/AppMenu.jsm", - "configurations/Buttons.jsm", - "configurations/ControlCenter.jsm", - "configurations/CustomizeMode.jsm", - "configurations/DevTools.jsm", - "configurations/LightweightThemes.jsm", - "configurations/PermissionPrompts.jsm", - "configurations/Preferences.jsm", - "configurations/Tabs.jsm", - "configurations/TabsInTitlebar.jsm", - "configurations/Toolbars.jsm", - "configurations/UIDensities.jsm", - "configurations/WindowSize.jsm", + 'configurations/AppMenu.jsm', + 'configurations/Buttons.jsm', + 'configurations/ControlCenter.jsm', + 'configurations/CustomizeMode.jsm', + 'configurations/DevTools.jsm', + 'configurations/LightweightThemes.jsm', + 'configurations/PermissionPrompts.jsm', + 'configurations/Preferences.jsm', + 'configurations/Tabs.jsm', + 'configurations/TabsInTitlebar.jsm', + 'configurations/Toolbars.jsm', + 'configurations/UIDensities.jsm', + 'configurations/WindowSize.jsm', ] FINAL_TARGET_FILES.resources.lib += [ - "lib/borderify.xpi", - "lib/mozscreenshots-script.js", - "lib/mozscreenshots-style.css", - "lib/mozscreenshots.html", - "lib/permissionPrompts.html", - "lib/robot.png", - "lib/robot_center.png", - "lib/robot_cropped_diagonal.png", - "lib/robot_diagonal.png", - "lib/robot_uncropped.png", - "lib/robot_upperleft.png", + 'lib/borderify.xpi', + 'lib/mozscreenshots-script.js', + 'lib/mozscreenshots-style.css', + 'lib/mozscreenshots.html', + 'lib/permissionPrompts.html', + 'lib/robot.png', + 'lib/robot_center.png', + 'lib/robot_cropped_diagonal.png', + 'lib/robot_diagonal.png', + 'lib/robot_uncropped.png', + 'lib/robot_upperleft.png', ] FINAL_TARGET_FILES.resources.lib.controlCenter += [ - "lib/controlCenter/mixed.html", - "lib/controlCenter/mixed_active.html", - "lib/controlCenter/mixed_passive.html", - "lib/controlCenter/password.html", - "lib/controlCenter/tracking.html", + 'lib/controlCenter/mixed.html', + 'lib/controlCenter/mixed_active.html', + 'lib/controlCenter/mixed_passive.html', + 'lib/controlCenter/password.html', + 'lib/controlCenter/tracking.html', ] diff --git a/build/RunCbindgen.py b/build/RunCbindgen.py index 0c941eaaca2138639c697f439dcbbd3482f5f674..d40683ad8589bd38021ffc11bfecb8c9588d7af7 100644 --- a/build/RunCbindgen.py +++ b/build/RunCbindgen.py @@ -26,8 +26,8 @@ CARGO_TOML = mozpath.join(buildconfig.topsrcdir, "Cargo.toml") def _run_process(args): env = os.environ.copy() - env["CARGO"] = str(buildconfig.substs["CARGO"]) - env["RUSTC"] = str(buildconfig.substs["RUSTC"]) + env['CARGO'] = str(buildconfig.substs['CARGO']) + env['RUSTC'] = str(buildconfig.substs['RUSTC']) p = subprocess.Popen(args, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -41,17 +41,15 @@ def _run_process(args): def generate_metadata(output, cargo_config): - stdout, returncode = _run_process( - [ - buildconfig.substs["CARGO"], - "metadata", - "--all-features", - "--format-version", - "1", - "--manifest-path", - CARGO_TOML, - ] - ) + stdout, returncode = _run_process([ + buildconfig.substs['CARGO'], + "metadata", + "--all-features", + "--format-version", + "1", + "--manifest-path", + CARGO_TOML + ]) if returncode != 0: return returncode @@ -64,19 +62,17 @@ def generate_metadata(output, cargo_config): def generate(output, metadata_path, cbindgen_crate_path, *in_tree_dependencies): - stdout, returncode = _run_process( - [ - buildconfig.substs["CBINDGEN"], - buildconfig.topsrcdir, - "--lockfile", - CARGO_LOCK, - "--crate", - _get_crate_name(cbindgen_crate_path), - "--metadata", - metadata_path, - "--cpp-compat", - ] - ) + stdout, returncode = _run_process([ + buildconfig.substs['CBINDGEN'], + buildconfig.topsrcdir, + "--lockfile", + CARGO_LOCK, + "--crate", + _get_crate_name(cbindgen_crate_path), + "--metadata", + metadata_path, + "--cpp-compat" + ]) if returncode != 0: return returncode diff --git a/build/appini_header.py b/build/appini_header.py index 08bd22721df92e83334748649fcf348310ff84ae..1cbfe90e202875a5eab7034c610641c6fb35e71b 100644 --- a/build/appini_header.py +++ b/build/appini_header.py @@ -2,8 +2,8 @@ # 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/. -"""Parses a given application.ini file and outputs the corresponding - StaticXREAppData structure as a C++ header file""" +'''Parses a given application.ini file and outputs the corresponding + StaticXREAppData structure as a C++ header file''' import configparser import sys @@ -14,54 +14,40 @@ def main(output, file): config.read(file) flags = set() try: - if config.getint("XRE", "EnableProfileMigrator") == 1: - flags.add("NS_XRE_ENABLE_PROFILE_MIGRATOR") + if config.getint('XRE', 'EnableProfileMigrator') == 1: + flags.add('NS_XRE_ENABLE_PROFILE_MIGRATOR') except Exception: pass try: - if config.getint("Crash Reporter", "Enabled") == 1: - flags.add("NS_XRE_ENABLE_CRASH_REPORTER") + if config.getint('Crash Reporter', 'Enabled') == 1: + flags.add('NS_XRE_ENABLE_CRASH_REPORTER') except Exception: pass - appdata = dict( - ("%s:%s" % (s, o), config.get(s, o)) - for s in config.sections() - for o in config.options(s) - ) - appdata["flags"] = " | ".join(sorted(flags)) if flags else "0" - appdata["App:profile"] = ( - '"%s"' % appdata["App:profile"] if "App:profile" in appdata else "NULL" - ) - expected = ( - "App:vendor", - "App:name", - "App:remotingname", - "App:version", - "App:buildid", - "App:id", - "Gecko:minversion", - "Gecko:maxversion", - ) + appdata = dict(("%s:%s" % (s, o), config.get(s, o)) + for s in config.sections() for o in config.options(s)) + appdata['flags'] = ' | '.join(sorted(flags)) if flags else '0' + appdata['App:profile'] = ('"%s"' % appdata['App:profile'] + if 'App:profile' in appdata else 'NULL') + expected = ('App:vendor', 'App:name', 'App:remotingname', 'App:version', 'App:buildid', + 'App:id', 'Gecko:minversion', 'Gecko:maxversion') missing = [var for var in expected if var not in appdata] if missing: - print("Missing values in %s: %s" % (file, ", ".join(missing)), file=sys.stderr) + print("Missing values in %s: %s" % (file, ', '.join(missing)), + file=sys.stderr) sys.exit(1) - if "Crash Reporter:serverurl" not in appdata: - appdata["Crash Reporter:serverurl"] = "" + if 'Crash Reporter:serverurl' not in appdata: + appdata['Crash Reporter:serverurl'] = '' - if "App:sourcerepository" in appdata and "App:sourcestamp" in appdata: - appdata["App:sourceurl"] = ( - '"%(App:sourcerepository)s/rev/%(App:sourcestamp)s"' % appdata - ) + if 'App:sourcerepository' in appdata and 'App:sourcestamp' in appdata: + appdata['App:sourceurl'] = '"%(App:sourcerepository)s/rev/%(App:sourcestamp)s"' % appdata else: - appdata["App:sourceurl"] = "NULL" + appdata['App:sourceurl'] = 'NULL' - if "AppUpdate:url" not in appdata: - appdata["AppUpdate:url"] = "" + if 'AppUpdate:url' not in appdata: + appdata['AppUpdate:url'] = '' - output.write( - """#include "mozilla/XREAppData.h" + output.write('''#include "mozilla/XREAppData.h" static const mozilla::StaticXREAppData sAppData = { "%(App:vendor)s", "%(App:name)s", @@ -78,13 +64,12 @@ def main(output, file): NULL, // UAName %(App:sourceurl)s, "%(AppUpdate:url)s" - };""" - % appdata - ) + };''' % appdata) -if __name__ == "__main__": +if __name__ == '__main__': if len(sys.argv) != 1: main(sys.stdout, sys.argv[1]) else: - print("Usage: %s /path/to/application.ini" % sys.argv[0], file=sys.stderr) + print("Usage: %s /path/to/application.ini" % sys.argv[0], + file=sys.stderr) diff --git a/build/build-clang/build-clang.py b/build/build-clang/build-clang.py index a4d6d93f3142fda28418a9eb273f9e0adc69c494..86af69dba6174d2c80291c6e4b6c94abbe7302a4 100755 --- a/build/build-clang/build-clang.py +++ b/build/build-clang/build-clang.py @@ -38,8 +38,8 @@ def symlink(source, link_name): def check_run(args): - print(" ".join(args), file=sys.stderr, flush=True) - if args[0] == "cmake": + print(' '.join(args), file=sys.stderr, flush=True) + if args[0] == 'cmake': # CMake `message(STATUS)` messages, as appearing in failed source code # compiles, appear on stdout, so we only capture that. p = subprocess.Popen(args, stdout=subprocess.PIPE) @@ -50,8 +50,8 @@ def check_run(args): sys.stdout.flush() r = p.wait() if r != 0: - cmake_output_re = re.compile(b'See also "(.*/CMakeOutput.log)"') - cmake_error_re = re.compile(b'See also "(.*/CMakeError.log)"') + cmake_output_re = re.compile(b"See also \"(.*/CMakeOutput.log)\"") + cmake_error_re = re.compile(b"See also \"(.*/CMakeError.log)\"") def find_first_match(re): for l in lines: @@ -63,10 +63,9 @@ def check_run(args): error_match = find_first_match(cmake_error_re) def dump_file(log): - with open(log, "rb") as f: + with open(log, 'rb') as f: print("\nContents of", log, "follow\n", file=sys.stderr) print(f.read(), file=sys.stderr) - if output_match: dump_file(output_match.group(1)) if error_match: @@ -95,18 +94,20 @@ def chdir(path): def patch(patch, srcdir): patch = os.path.realpath(patch) - check_run(["patch", "-d", srcdir, "-p1", "-i", patch, "--fuzz=0", "-s"]) + check_run(['patch', '-d', srcdir, '-p1', '-i', patch, '--fuzz=0', + '-s']) def import_clang_tidy(source_dir, build_clang_tidy_alpha, build_clang_tidy_external): - clang_plugin_path = os.path.join(os.path.dirname(sys.argv[0]), "..", "clang-plugin") - clang_tidy_path = os.path.join(source_dir, "clang-tools-extra/clang-tidy") + clang_plugin_path = os.path.join(os.path.dirname(sys.argv[0]), + '..', 'clang-plugin') + clang_tidy_path = os.path.join(source_dir, + 'clang-tools-extra/clang-tidy') sys.path.append(clang_plugin_path) from import_mozilla_checks import do_import - import_options = { - "alpha": build_clang_tidy_alpha, - "external": build_clang_tidy_external, + "alpha": build_clang_tidy_alpha, + "external": build_clang_tidy_external } do_import(clang_plugin_path, clang_tidy_path, import_options) @@ -137,7 +138,7 @@ def updated_env(env): def build_tar_package(name, base, directory): name = os.path.realpath(name) - print("tarring {} from {}/{}".format(name, base, directory), file=sys.stderr) + print('tarring {} from {}/{}'.format(name, base, directory), file=sys.stderr) assert name.endswith(".tar.zst") cctx = zstandard.ZstdCompressor() @@ -166,7 +167,7 @@ def delete(path): def install_libgcc(gcc_dir, clang_dir, is_final_stage): - gcc_bin_dir = os.path.join(gcc_dir, "bin") + gcc_bin_dir = os.path.join(gcc_dir, 'bin') # Copy over gcc toolchain bits that clang looks for, to ensure that # clang is using a consistent version of ld, since the system ld may @@ -177,22 +178,17 @@ def install_libgcc(gcc_dir, clang_dir, is_final_stage): # Only install this for the bootstrap process; we expect any consumers of # the newly-built toolchain to provide an appropriate ld themselves. if not is_final_stage: - x64_bin_dir = os.path.join(clang_dir, "x86_64-unknown-linux-gnu", "bin") + x64_bin_dir = os.path.join(clang_dir, 'x86_64-unknown-linux-gnu', 'bin') mkdir_p(x64_bin_dir) - shutil.copy2(os.path.join(gcc_bin_dir, "ld"), x64_bin_dir) + shutil.copy2(os.path.join(gcc_bin_dir, 'ld'), x64_bin_dir) - out = subprocess.check_output( - [os.path.join(gcc_bin_dir, "gcc"), "-print-libgcc-file-name"] - ) + out = subprocess.check_output([os.path.join(gcc_bin_dir, "gcc"), + '-print-libgcc-file-name']) libgcc_dir = os.path.dirname(out.decode().rstrip()) - clang_lib_dir = os.path.join( - clang_dir, - "lib", - "gcc", - "x86_64-unknown-linux-gnu", - os.path.basename(libgcc_dir), - ) + clang_lib_dir = os.path.join(clang_dir, "lib", "gcc", + "x86_64-unknown-linux-gnu", + os.path.basename(libgcc_dir)) mkdir_p(clang_lib_dir) copy_tree(libgcc_dir, clang_lib_dir, preserve_symlinks=True) libgcc_dir = os.path.join(gcc_dir, "lib64") @@ -207,16 +203,14 @@ def install_libgcc(gcc_dir, clang_dir, is_final_stage): def install_import_library(build_dir, clang_dir): - shutil.copy2( - os.path.join(build_dir, "lib", "clang.lib"), os.path.join(clang_dir, "lib") - ) + shutil.copy2(os.path.join(build_dir, "lib", "clang.lib"), + os.path.join(clang_dir, "lib")) def install_asan_symbols(build_dir, clang_dir): lib_path_pattern = os.path.join("lib", "clang", "*.*.*", "lib", "windows") - src_path = glob.glob( - os.path.join(build_dir, lib_path_pattern, "clang_rt.asan_dynamic-*.pdb") - ) + src_path = glob.glob(os.path.join(build_dir, lib_path_pattern, + "clang_rt.asan_dynamic-*.pdb")) dst_path = glob.glob(os.path.join(clang_dir, lib_path_pattern)) if len(src_path) != 1: @@ -240,33 +234,14 @@ def is_windows(): return platform.system() == "Windows" -def build_one_stage( - cc, - cxx, - asm, - ld, - ar, - ranlib, - libtool, - src_dir, - stage_dir, - package_name, - build_libcxx, - osx_cross_compile, - build_type, - assertions, - python_path, - gcc_dir, - libcxx_include_dir, - build_wasm, - compiler_rt_source_dir=None, - runtimes_source_link=None, - compiler_rt_source_link=None, - is_final_stage=False, - android_targets=None, - extra_targets=None, - pgo_phase=None, -): +def build_one_stage(cc, cxx, asm, ld, ar, ranlib, libtool, + src_dir, stage_dir, package_name, build_libcxx, + osx_cross_compile, build_type, assertions, + python_path, gcc_dir, libcxx_include_dir, build_wasm, + compiler_rt_source_dir=None, runtimes_source_link=None, + compiler_rt_source_link=None, + is_final_stage=False, android_targets=None, + extra_targets=None, pgo_phase=None): if is_final_stage and (android_targets or extra_targets): # Linking compiler-rt under "runtimes" activates LLVM_RUNTIME_TARGETS # and related arguments. @@ -284,7 +259,7 @@ def build_one_stage( # cmake doesn't deal well with backslashes in paths. def slashify_path(path): - return path.replace("\\", "/") + return path.replace('\\', '/') def cmake_base_args(cc, cxx, asm, ld, ar, ranlib, libtool, inst_dir): machine_targets = "X86;ARM;AArch64" if is_final_stage else "X86" @@ -295,11 +270,11 @@ def build_one_stage( "-DCMAKE_ASM_COMPILER=%s" % slashify_path(asm[0]), "-DCMAKE_LINKER=%s" % slashify_path(ld[0]), "-DCMAKE_AR=%s" % slashify_path(ar), - "-DCMAKE_C_FLAGS=%s" % " ".join(cc[1:]), - "-DCMAKE_CXX_FLAGS=%s" % " ".join(cxx[1:]), - "-DCMAKE_ASM_FLAGS=%s" % " ".join(asm[1:]), - "-DCMAKE_EXE_LINKER_FLAGS=%s" % " ".join(ld[1:]), - "-DCMAKE_SHARED_LINKER_FLAGS=%s" % " ".join(ld[1:]), + "-DCMAKE_C_FLAGS=%s" % ' '.join(cc[1:]), + "-DCMAKE_CXX_FLAGS=%s" % ' '.join(cxx[1:]), + "-DCMAKE_ASM_FLAGS=%s" % ' '.join(asm[1:]), + "-DCMAKE_EXE_LINKER_FLAGS=%s" % ' '.join(ld[1:]), + "-DCMAKE_SHARED_LINKER_FLAGS=%s" % ' '.join(ld[1:]), "-DCMAKE_BUILD_TYPE=%s" % build_type, "-DCMAKE_INSTALL_PREFIX=%s" % inst_dir, "-DLLVM_TARGETS_TO_BUILD=%s" % machine_targets, @@ -341,7 +316,7 @@ def build_one_stage( "-DCMAKE_OSX_ARCHITECTURES=x86_64", "-DDARWIN_osx_ARCHS=x86_64", "-DDARWIN_osx_SYSROOT=%s" % slashify_path(os.getenv("CROSS_SYSROOT")), - "-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-apple-darwin", + "-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-apple-darwin" ] # Starting in LLVM 11 (which requires SDK 10.12) the build tries to # detect the SDK version by calling xcrun. Cross-compiles don't have @@ -405,9 +380,8 @@ def build_one_stage( android_include_dirs = cfg["ndk_includes"] api_level = cfg["api_level"] - android_flags = [ - "-isystem %s" % d.format(**os.environ) for d in android_include_dirs - ] + android_flags = ["-isystem %s" % d.format(**os.environ) + for d in android_include_dirs] android_flags += ["--gcc-toolchain=%s" % android_gcc_dir] android_flags += ["-D__ANDROID_API__=%s" % api_level] @@ -417,21 +391,24 @@ def build_one_stage( rt_cxx_flags = " ".join(cxx[1:] + android_flags) rt_asm_flags = " ".join(asm[1:] + android_flags) - for kind in ("BUILTINS", "RUNTIMES"): + for kind in ('BUILTINS', 'RUNTIMES'): for var, arg in ( - ("ANDROID", "1"), - ("CMAKE_ASM_FLAGS", rt_asm_flags), - ("CMAKE_CXX_FLAGS", rt_cxx_flags), - ("CMAKE_C_FLAGS", rt_c_flags), - ("CMAKE_EXE_LINKER_FLAGS", android_link_flags), - ("CMAKE_SHARED_LINKER_FLAGS", android_link_flags), - ("CMAKE_SYSROOT", sysroot_dir), - ("ANDROID_NATIVE_API_LEVEL", api_level), + ('ANDROID', '1'), + ('CMAKE_ASM_FLAGS', rt_asm_flags), + ('CMAKE_CXX_FLAGS', rt_cxx_flags), + ('CMAKE_C_FLAGS', rt_c_flags), + ('CMAKE_EXE_LINKER_FLAGS', android_link_flags), + ('CMAKE_SHARED_LINKER_FLAGS', android_link_flags), + ('CMAKE_SYSROOT', sysroot_dir), + ('ANDROID_NATIVE_API_LEVEL', api_level), ): - cmake_args += ["-D%s_%s_%s=%s" % (kind, target, var, arg)] + cmake_args += ['-D%s_%s_%s=%s' % (kind, target, var, arg)] - cmake_args += cmake_base_args(cc, cxx, asm, ld, ar, ranlib, libtool, inst_dir) - cmake_args += [src_dir] + cmake_args += cmake_base_args( + cc, cxx, asm, ld, ar, ranlib, libtool, inst_dir) + cmake_args += [ + src_dir + ] build_package(build_dir, cmake_args) if is_linux(): @@ -448,40 +425,35 @@ def build_one_stage( # 64-bits, which we detect through the contents of the LIB # environment variable, which we also adjust for a 32-bits build # at the same time. - old_lib = os.environ["LIB"] + old_lib = os.environ['LIB'] new_lib = [] for l in old_lib.split(os.pathsep): - if l.endswith("x64"): - l = l[:-3] + "x86" + if l.endswith('x64'): + l = l[:-3] + 'x86' build_32_bit = True - elif l.endswith("amd64"): + elif l.endswith('amd64'): l = l[:-5] build_32_bit = True new_lib.append(l) if build_32_bit: - os.environ["LIB"] = os.pathsep.join(new_lib) - compiler_rt_build_dir = stage_dir + "/compiler-rt" - compiler_rt_inst_dir = inst_dir + "/lib/clang/" + os.environ['LIB'] = os.pathsep.join(new_lib) + compiler_rt_build_dir = stage_dir + '/compiler-rt' + compiler_rt_inst_dir = inst_dir + '/lib/clang/' subdirs = os.listdir(compiler_rt_inst_dir) assert len(subdirs) == 1 compiler_rt_inst_dir += subdirs[0] cmake_args = cmake_base_args( - [os.path.join(inst_dir, "bin", "clang-cl.exe"), "-m32"] + cc[1:], - [os.path.join(inst_dir, "bin", "clang-cl.exe"), "-m32"] + cxx[1:], - [os.path.join(inst_dir, "bin", "clang-cl.exe"), "-m32"] + asm[1:], - ld, - ar, - ranlib, - libtool, - compiler_rt_inst_dir, - ) + [os.path.join(inst_dir, 'bin', 'clang-cl.exe'), '-m32'] + cc[1:], + [os.path.join(inst_dir, 'bin', 'clang-cl.exe'), '-m32'] + cxx[1:], + [os.path.join(inst_dir, 'bin', 'clang-cl.exe'), '-m32'] + asm[1:], + ld, ar, ranlib, libtool, compiler_rt_inst_dir) cmake_args += [ - "-DLLVM_CONFIG_PATH=%s" - % slashify_path(os.path.join(inst_dir, "bin", "llvm-config")), - os.path.join(src_dir, "projects", "compiler-rt"), + '-DLLVM_CONFIG_PATH=%s' % slashify_path( + os.path.join(inst_dir, 'bin', 'llvm-config')), + os.path.join(src_dir, 'projects', 'compiler-rt'), ] build_package(compiler_rt_build_dir, cmake_args) - os.environ["LIB"] = old_lib + os.environ['LIB'] = old_lib if is_final_stage: install_import_library(build_dir, inst_dir) install_asan_symbols(build_dir, inst_dir) @@ -540,16 +512,7 @@ def get_tool(config, key): # run-clang-tidy.py def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile): # Make sure we only have what we expect. - dirs = [ - "bin", - "include", - "lib", - "lib32", - "libexec", - "msbuild-bin", - "share", - "tools", - ] + dirs = ["bin", "include", "lib", "lib32", "libexec", "msbuild-bin", "share", "tools"] if is_linux(): dirs.append("x86_64-unknown-linux-gnu") for f in glob.glob("%s/*" % final_dir): @@ -558,7 +521,7 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile): if not os.path.isdir(f): raise Exception("Expected %s to be a directory" % f) - kept_binaries = ["clang-apply-replacements", "clang-format", "clang-tidy", "clangd"] + kept_binaries = ['clang-apply-replacements', 'clang-format', 'clang-tidy', 'clangd'] re_clang_tidy = re.compile(r"^(" + "|".join(kept_binaries) + r")(\.exe)?$", re.I) for f in glob.glob("%s/bin/*" % final_dir): if re_clang_tidy.search(os.path.basename(f)) is None: @@ -577,12 +540,10 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile): name = os.path.basename(f) if name == "clang": continue - if osx_cross_compile and name in ["libLLVM.dylib", "libclang-cpp.dylib"]: + if osx_cross_compile and name in ['libLLVM.dylib', 'libclang-cpp.dylib']: continue - if is_linux() and ( - fnmatch.fnmatch(name, "libLLVM*.so") - or fnmatch.fnmatch(name, "libclang-cpp.so*") - ): + if is_linux() and (fnmatch.fnmatch(name, 'libLLVM*.so') or + fnmatch.fnmatch(name, 'libclang-cpp.so*')): continue delete(f) for f in glob.glob("%s/lib/clang/*" % final_dir): @@ -611,35 +572,24 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile): if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument( - "-c", - "--config", - required=True, - type=argparse.FileType("r"), - help="Clang configuration file", - ) - parser.add_argument( - "--clean", required=False, action="store_true", help="Clean the build directory" - ) - parser.add_argument( - "--skip-tar", - required=False, - action="store_true", - help="Skip tar packaging stage", - ) - parser.add_argument( - "--skip-checkout", - required=False, - action="store_true", - help="Do not checkout/revert source", - ) + parser.add_argument('-c', '--config', required=True, + type=argparse.FileType('r'), + help="Clang configuration file") + parser.add_argument('--clean', required=False, + action='store_true', + help="Clean the build directory") + parser.add_argument('--skip-tar', required=False, + action='store_true', + help="Skip tar packaging stage") + parser.add_argument('--skip-checkout', required=False, + action='store_true', + help="Do not checkout/revert source") args = parser.parse_args() - if not os.path.exists("llvm/LLVMBuild.txt"): - raise Exception( - "The script must be run from the root directory of the " "llvm-project tree" - ) + if not os.path.exists('llvm/LLVMBuild.txt'): + raise Exception('The script must be run from the root directory of the ' + 'llvm-project tree') source_dir = os.getcwd() build_dir = source_dir + "/build" @@ -684,10 +634,8 @@ if __name__ == "__main__": if "build_type" in config: build_type = config["build_type"] if build_type not in ("Release", "Debug", "RelWithDebInfo", "MinSizeRel"): - raise ValueError( - "We only know how to do Release, Debug, RelWithDebInfo or " - "MinSizeRel builds" - ) + raise ValueError("We only know how to do Release, Debug, RelWithDebInfo or " + "MinSizeRel builds") build_libcxx = False if "build_libcxx" in config: build_libcxx = config["build_libcxx"] @@ -708,17 +656,13 @@ if __name__ == "__main__": if build_clang_tidy and "build_clang_tidy_alpha" in config: build_clang_tidy_alpha = config["build_clang_tidy_alpha"] if build_clang_tidy_alpha not in (True, False): - raise ValueError( - "Only boolean values are accepted for build_clang_tidy_alpha." - ) + raise ValueError("Only boolean values are accepted for build_clang_tidy_alpha.") build_clang_tidy_external = False # check for build_clang_tidy_external only if build_clang_tidy is true if build_clang_tidy and "build_clang_tidy_external" in config: build_clang_tidy_external = config["build_clang_tidy_external"] if build_clang_tidy_external not in (True, False): - raise ValueError( - "Only boolean values are accepted for build_clang_tidy_external." - ) + raise ValueError("Only boolean values are accepted for build_clang_tidy_external.") osx_cross_compile = False if "osx_cross_compile" in config: osx_cross_compile = config["osx_cross_compile"] @@ -747,10 +691,8 @@ if __name__ == "__main__": for attr in ("ndk_toolchain", "ndk_sysroot", "ndk_includes", "api_level"): for target, cfg in android_targets.items(): if attr not in cfg: - raise ValueError( - "must specify '%s' as a key for android target: %s" - % (attr, target) - ) + raise ValueError("must specify '%s' as a key for android target: %s" % + (attr, target)) extra_targets = None if "extra_targets" in config: extra_targets = config["extra_targets"] @@ -763,7 +705,7 @@ if __name__ == "__main__": raise ValueError("Config file needs to set gcc_dir") if is_darwin() or osx_cross_compile: - os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.11" + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.11' cc = get_tool(config, "cc") cxx = get_tool(config, "cxx") @@ -783,14 +725,17 @@ if __name__ == "__main__": compiler_rt_source_link = llvm_source_dir + "/projects/compiler-rt" - symlinks = [ - (clang_source_dir, llvm_source_dir + "/tools/clang"), - (extra_source_dir, llvm_source_dir + "/tools/clang/tools/extra"), - (lld_source_dir, llvm_source_dir + "/tools/lld"), - (compiler_rt_source_dir, compiler_rt_source_link), - (libcxx_source_dir, llvm_source_dir + "/projects/libcxx"), - (libcxxabi_source_dir, llvm_source_dir + "/projects/libcxxabi"), - ] + symlinks = [(clang_source_dir, + llvm_source_dir + "/tools/clang"), + (extra_source_dir, + llvm_source_dir + "/tools/clang/tools/extra"), + (lld_source_dir, + llvm_source_dir + "/tools/lld"), + (compiler_rt_source_dir, compiler_rt_source_link), + (libcxx_source_dir, + llvm_source_dir + "/projects/libcxx"), + (libcxxabi_source_dir, + llvm_source_dir + "/projects/libcxxabi")] for l in symlinks: # On Windows, we have to re-copy the whole directory every time. if not is_windows() and os.path.islink(l[1]): @@ -807,10 +752,11 @@ if __name__ == "__main__": if not os.path.exists(build_dir): os.makedirs(build_dir) - libcxx_include_dir = os.path.join(llvm_source_dir, "projects", "libcxx", "include") + libcxx_include_dir = os.path.join(llvm_source_dir, "projects", + "libcxx", "include") - stage1_dir = build_dir + "/stage1" - stage1_inst_dir = stage1_dir + "/" + package_name + stage1_dir = build_dir + '/stage1' + stage1_inst_dir = stage1_dir + '/' + package_name final_stage_dir = stage1_dir final_inst_dir = stage1_inst_dir @@ -829,31 +775,24 @@ if __name__ == "__main__": # up whatever headers were installed from the gcc we used to build stage1, # always, rather than the system headers. Providing -gcc-toolchain # encourages clang to do that. - extra_cflags2 = ["-fPIC", "-gcc-toolchain", stage1_inst_dir] + extra_cflags2 = ["-fPIC", '-gcc-toolchain', stage1_inst_dir] # Silence clang's warnings about arguments not being used in compilation. - extra_cxxflags2 = [ - "-fPIC", - "-Qunused-arguments", - "-gcc-toolchain", - stage1_inst_dir, - ] + extra_cxxflags2 = ["-fPIC", '-Qunused-arguments', '-gcc-toolchain', stage1_inst_dir] extra_asmflags = [] # Avoid libLLVM internal function calls going through the PLT. - extra_ldflags = ["-Wl,-Bsymbolic-functions"] + extra_ldflags = ['-Wl,-Bsymbolic-functions'] # For whatever reason, LLVM's build system will set things up to turn # on -ffunction-sections and -fdata-sections, but won't turn on the # corresponding option to strip unused sections. We do it explicitly # here. LLVM's build system is also picky about turning on ICF, so # we do that explicitly here, too. - extra_ldflags += ["-fuse-ld=gold", "-Wl,--gc-sections", "-Wl,--icf=safe"] + extra_ldflags += ['-fuse-ld=gold', '-Wl,--gc-sections', '-Wl,--icf=safe'] - if "LD_LIBRARY_PATH" in os.environ: - os.environ["LD_LIBRARY_PATH"] = "%s/lib64/:%s" % ( - gcc_dir, - os.environ["LD_LIBRARY_PATH"], - ) + if 'LD_LIBRARY_PATH' in os.environ: + os.environ['LD_LIBRARY_PATH'] = ('%s/lib64/:%s' % + (gcc_dir, os.environ['LD_LIBRARY_PATH'])) else: - os.environ["LD_LIBRARY_PATH"] = "%s/lib64/" % gcc_dir + os.environ['LD_LIBRARY_PATH'] = '%s/lib64/' % gcc_dir elif is_windows(): extra_cflags = [] extra_cxxflags = [] @@ -861,11 +800,7 @@ if __name__ == "__main__": # by looking at an MSVC install, but we don't really have that here. # Force things on. extra_cflags2 = [] - extra_cxxflags2 = [ - "-fms-compatibility-version=19.13.26128", - "-Xclang", - "-std=c++14", - ] + extra_cxxflags2 = ['-fms-compatibility-version=19.13.26128', '-Xclang', '-std=c++14'] extra_asmflags = [] extra_ldflags = [] @@ -876,186 +811,124 @@ if __name__ == "__main__": extra_cxxflags = ["-stdlib=libc++"] extra_cxxflags2 = ["-stdlib=libc++"] - extra_flags = [ - "-target", - "x86_64-apple-darwin", - "-mlinker-version=137", - "-B", - "%s/bin" % os.getenv("CROSS_CCTOOLS_PATH"), - "-isysroot", - os.getenv("CROSS_SYSROOT"), - # technically the sysroot flag there should be enough to deduce this, - # but clang needs some help to figure this out. - "-I%s/usr/include" % os.getenv("CROSS_SYSROOT"), - "-iframework", - "%s/System/Library/Frameworks" % os.getenv("CROSS_SYSROOT"), - ] + extra_flags = ["-target", "x86_64-apple-darwin", "-mlinker-version=137", + "-B", "%s/bin" % os.getenv("CROSS_CCTOOLS_PATH"), + "-isysroot", os.getenv("CROSS_SYSROOT"), + # technically the sysroot flag there should be enough to deduce this, + # but clang needs some help to figure this out. + "-I%s/usr/include" % os.getenv("CROSS_SYSROOT"), + "-iframework", "%s/System/Library/Frameworks" % os.getenv("CROSS_SYSROOT")] extra_cflags += extra_flags extra_cxxflags += extra_flags extra_cflags2 += extra_flags extra_cxxflags2 += extra_flags extra_asmflags += extra_flags - extra_ldflags = [ - "-Wl,-syslibroot,%s" % os.getenv("CROSS_SYSROOT"), - "-Wl,-dead_strip", - ] + extra_ldflags = ["-Wl,-syslibroot,%s" % os.getenv("CROSS_SYSROOT"), + "-Wl,-dead_strip"] - upload_dir = os.getenv("UPLOAD_DIR") + upload_dir = os.getenv('UPLOAD_DIR') if assertions and upload_dir: - extra_cflags2 += ["-fcrash-diagnostics-dir=%s" % upload_dir] - extra_cxxflags2 += ["-fcrash-diagnostics-dir=%s" % upload_dir] + extra_cflags2 += ['-fcrash-diagnostics-dir=%s' % upload_dir] + extra_cxxflags2 += ['-fcrash-diagnostics-dir=%s' % upload_dir] build_one_stage( [cc] + extra_cflags, [cxx] + extra_cxxflags, [asm] + extra_asmflags, [ld] + extra_ldflags, - ar, - ranlib, - libtool, - llvm_source_dir, - stage1_dir, - package_name, - build_libcxx, - osx_cross_compile, - build_type, - assertions, - python_path, - gcc_dir, - libcxx_include_dir, - build_wasm, - is_final_stage=(stages == 1), - ) + ar, ranlib, libtool, + llvm_source_dir, stage1_dir, package_name, build_libcxx, osx_cross_compile, + build_type, assertions, python_path, gcc_dir, libcxx_include_dir, build_wasm, + is_final_stage=(stages == 1)) runtimes_source_link = llvm_source_dir + "/runtimes/compiler-rt" if stages >= 2: - stage2_dir = build_dir + "/stage2" - stage2_inst_dir = stage2_dir + "/" + package_name + stage2_dir = build_dir + '/stage2' + stage2_inst_dir = stage2_dir + '/' + package_name final_stage_dir = stage2_dir final_inst_dir = stage2_inst_dir pgo_phase = "gen" if pgo else None build_one_stage( - [stage1_inst_dir + "/bin/%s%s" % (cc_name, exe_ext)] + extra_cflags2, - [stage1_inst_dir + "/bin/%s%s" % (cxx_name, exe_ext)] + extra_cxxflags2, - [stage1_inst_dir + "/bin/%s%s" % (cc_name, exe_ext)] + extra_asmflags, + [stage1_inst_dir + "/bin/%s%s" % + (cc_name, exe_ext)] + extra_cflags2, + [stage1_inst_dir + "/bin/%s%s" % + (cxx_name, exe_ext)] + extra_cxxflags2, + [stage1_inst_dir + "/bin/%s%s" % + (cc_name, exe_ext)] + extra_asmflags, [ld] + extra_ldflags, - ar, - ranlib, - libtool, - llvm_source_dir, - stage2_dir, - package_name, - build_libcxx, - osx_cross_compile, - build_type, - assertions, - python_path, - gcc_dir, - libcxx_include_dir, - build_wasm, - compiler_rt_source_dir, - runtimes_source_link, - compiler_rt_source_link, - is_final_stage=(stages == 2), - android_targets=android_targets, - extra_targets=extra_targets, - pgo_phase=pgo_phase, - ) + ar, ranlib, libtool, + llvm_source_dir, stage2_dir, package_name, build_libcxx, osx_cross_compile, + build_type, assertions, python_path, gcc_dir, libcxx_include_dir, build_wasm, + compiler_rt_source_dir, runtimes_source_link, compiler_rt_source_link, + is_final_stage=(stages == 2), android_targets=android_targets, + extra_targets=extra_targets, pgo_phase=pgo_phase) if stages >= 3: - stage3_dir = build_dir + "/stage3" - stage3_inst_dir = stage3_dir + "/" + package_name + stage3_dir = build_dir + '/stage3' + stage3_inst_dir = stage3_dir + '/' + package_name final_stage_dir = stage3_dir final_inst_dir = stage3_inst_dir build_one_stage( - [stage2_inst_dir + "/bin/%s%s" % (cc_name, exe_ext)] + extra_cflags2, - [stage2_inst_dir + "/bin/%s%s" % (cxx_name, exe_ext)] + extra_cxxflags2, - [stage2_inst_dir + "/bin/%s%s" % (cc_name, exe_ext)] + extra_asmflags, + [stage2_inst_dir + "/bin/%s%s" % + (cc_name, exe_ext)] + extra_cflags2, + [stage2_inst_dir + "/bin/%s%s" % + (cxx_name, exe_ext)] + extra_cxxflags2, + [stage2_inst_dir + "/bin/%s%s" % + (cc_name, exe_ext)] + extra_asmflags, [ld] + extra_ldflags, - ar, - ranlib, - libtool, - llvm_source_dir, - stage3_dir, - package_name, - build_libcxx, - osx_cross_compile, - build_type, - assertions, - python_path, - gcc_dir, - libcxx_include_dir, - build_wasm, - compiler_rt_source_dir, - runtimes_source_link, - compiler_rt_source_link, - (stages == 3), - extra_targets=extra_targets, - ) + ar, ranlib, libtool, + llvm_source_dir, stage3_dir, package_name, build_libcxx, osx_cross_compile, + build_type, assertions, python_path, gcc_dir, libcxx_include_dir, build_wasm, + compiler_rt_source_dir, runtimes_source_link, compiler_rt_source_link, + (stages == 3), extra_targets=extra_targets) if stages >= 4: - stage4_dir = build_dir + "/stage4" - stage4_inst_dir = stage4_dir + "/" + package_name + stage4_dir = build_dir + '/stage4' + stage4_inst_dir = stage4_dir + '/' + package_name final_stage_dir = stage4_dir final_inst_dir = stage4_inst_dir pgo_phase = None if pgo: pgo_phase = "use" llvm_profdata = stage3_inst_dir + "/bin/llvm-profdata%s" % exe_ext - merge_cmd = [llvm_profdata, "merge", "-o", "merged.profdata"] - profraw_files = glob.glob( - os.path.join(stage2_dir, "build", "profiles", "*.profraw") - ) + merge_cmd = [llvm_profdata, 'merge', '-o', 'merged.profdata'] + profraw_files = glob.glob(os.path.join(stage2_dir, 'build', + 'profiles', '*.profraw')) if not os.path.exists(stage4_dir): os.mkdir(stage4_dir) run_in(stage4_dir, merge_cmd + profraw_files) build_one_stage( - [stage3_inst_dir + "/bin/%s%s" % (cc_name, exe_ext)] + extra_cflags2, - [stage3_inst_dir + "/bin/%s%s" % (cxx_name, exe_ext)] + extra_cxxflags2, - [stage3_inst_dir + "/bin/%s%s" % (cc_name, exe_ext)] + extra_asmflags, + [stage3_inst_dir + "/bin/%s%s" % + (cc_name, exe_ext)] + extra_cflags2, + [stage3_inst_dir + "/bin/%s%s" % + (cxx_name, exe_ext)] + extra_cxxflags2, + [stage3_inst_dir + "/bin/%s%s" % + (cc_name, exe_ext)] + extra_asmflags, [ld] + extra_ldflags, - ar, - ranlib, - libtool, - llvm_source_dir, - stage4_dir, - package_name, - build_libcxx, - osx_cross_compile, - build_type, - assertions, - python_path, - gcc_dir, - libcxx_include_dir, - build_wasm, - compiler_rt_source_dir, - runtimes_source_link, - compiler_rt_source_link, - (stages == 4), - extra_targets=extra_targets, - pgo_phase=pgo_phase, - ) + ar, ranlib, libtool, + llvm_source_dir, stage4_dir, package_name, build_libcxx, osx_cross_compile, + build_type, assertions, python_path, gcc_dir, libcxx_include_dir, build_wasm, + compiler_rt_source_dir, runtimes_source_link, compiler_rt_source_link, + (stages == 4), extra_targets=extra_targets, pgo_phase=pgo_phase) if build_clang_tidy: - prune_final_dir_for_clang_tidy( - os.path.join(final_stage_dir, package_name), osx_cross_compile - ) + prune_final_dir_for_clang_tidy(os.path.join(final_stage_dir, package_name), + osx_cross_compile) # Copy the wasm32 builtins to the final_inst_dir if the archive is present. if "wasi-sysroot" in config: sysroot = config["wasi-sysroot"].format(**os.environ) if os.path.isdir(sysroot): for srcdir in glob.glob( - os.path.join(sysroot, "lib", "clang", "*", "lib", "wasi") - ): + os.path.join(sysroot, "lib", "clang", "*", "lib", "wasi")): print("Copying from wasi-sysroot srcdir %s" % srcdir) # Copy the contents of the "lib/wasi" subdirectory to the # appropriate location in final_inst_dir. - version = os.path.basename(os.path.dirname(os.path.dirname(srcdir))) - destdir = os.path.join( - final_inst_dir, "lib", "clang", version, "lib", "wasi" - ) + version = os.path.basename(os.path.dirname(os.path.dirname( + srcdir))) + destdir = os.path.join(final_inst_dir, "lib", "clang", version, + "lib", "wasi") mkdir_p(destdir) copy_tree(srcdir, destdir) diff --git a/build/build-infer/build-infer.py b/build/build-infer/build-infer.py index e9a4804ce08f66c6e4c8570f803fa1bf201b3a9c..9226ed86038f9b81bc071a84003ce5f0e501191b 100755 --- a/build/build-infer/build-infer.py +++ b/build/build-infer/build-infer.py @@ -13,14 +13,14 @@ from functools import reduce def check_run(args, path): - print(" ".join(args) + " in " + path, file=sys.stderr) + print(' '.join(args) + ' in ' + path, file=sys.stderr) subprocess.run(args, cwd=path, check=True) def run_in(path, args, extra_env=None): - """ + ''' Runs the given commands in the directory specified by . - """ + ''' env = dict(os.environ) env.update(extra_env or {}) check_run(args, path) @@ -29,50 +29,43 @@ def run_in(path, args, extra_env=None): def build_tar_package(tar, name, base, directories): name = os.path.realpath(name) - run_in( - base, - [tar, "-c", "-%s" % ("J" if ".xz" in name else "j"), "-f", name] + directories, - ) + run_in(base, [tar, + '-c', + '-%s' % ('J' if '.xz' in name else 'j'), + '-f', + name] + directories) def is_git_repo(dir): - """Check whether the given directory is a git repository.""" + '''Check whether the given directory is a git repository.''' from subprocess import CalledProcessError - try: - check_run(["git", "rev-parse"], dir) + check_run(['git', 'rev-parse'], dir) return True except CalledProcessError: return False def git_clone(main_dir, url, clone_dir, commit): - """ + ''' Clones the repository from into , and brings the repository to the state of . - """ - run_in(main_dir, ["git", "clone", url, clone_dir]) - run_in(clone_dir, ["git", "checkout", commit]) + ''' + run_in(main_dir, ['git', 'clone', url, clone_dir]) + run_in(clone_dir, ['git', 'checkout', commit]) -if __name__ == "__main__": +if __name__ == '__main__': parser = argparse.ArgumentParser() - parser.add_argument( - "-c", - "--config", - required=True, - type=argparse.FileType("r"), - help="Infer configuration file", - ) - parser.add_argument( - "-b", "--base-dir", help="Base directory for code and build artifacts" - ) - parser.add_argument( - "--clean", action="store_true", help="Clean the build directory" - ) - parser.add_argument( - "--skip-tar", action="store_true", help="Skip tar packaging stage" - ) + parser.add_argument('-c', '--config', required=True, + type=argparse.FileType('r'), + help='Infer configuration file') + parser.add_argument('-b', '--base-dir', + help="Base directory for code and build artifacts") + parser.add_argument('--clean', action='store_true', + help='Clean the build directory') + parser.add_argument('--skip-tar', action='store_true', + help='Skip tar packaging stage') args = parser.parse_args() @@ -82,20 +75,20 @@ if __name__ == "__main__": if args.base_dir: base_dir = args.base_dir else: - base_dir = reduce( - os.path.join, [os.sep + "builds", "worker", "workspace", "moz-toolchain"] - ) - infer_dir = os.path.join(base_dir, "infer") - source_dir = os.path.join(infer_dir, "src") - build_dir = os.path.join(infer_dir, "build") + base_dir = reduce(os.path.join, + [os.sep + 'builds', 'worker', + 'workspace', 'moz-toolchain']) + infer_dir = os.path.join(base_dir, 'infer') + source_dir = os.path.join(infer_dir, 'src') + build_dir = os.path.join(infer_dir, 'build') if args.clean: shutil.rmtree(build_dir) os.sys.exit(0) config = json.load(args.config) - infer_revision = config["infer_revision"] - infer_repo = config["infer_repo"] + infer_revision = config['infer_revision'] + infer_repo = config['infer_repo'] for folder in [infer_dir, source_dir, build_dir]: os.makedirs(folder, exist_ok=True) @@ -109,44 +102,31 @@ if __name__ == "__main__": # apply a few patches dir_path = os.path.dirname(os.path.realpath(__file__)) # clean the git directory by reseting all changes - git_commands = [["clean", "-f"], ["reset", "--hard"]] + git_commands = [['clean', '-f'], ['reset', '--hard']] for command in git_commands: - run_in(source_dir, ["git"] + command) - for p in config.get("patches", []): - run_in(source_dir, ["git", "apply", os.path.join(dir_path, p)]) + run_in(source_dir, ['git']+command) + for p in config.get('patches', []): + run_in(source_dir, ['git', 'apply', os.path.join(dir_path, p)]) # configure opam - run_in(source_dir, ["opam", "init", "--no-setup", "--disable-sandboxing"]) + run_in(source_dir, ['opam', 'init', '--no-setup', '--disable-sandboxing']) # build infer - run_in(source_dir, ["./build-infer.sh", "java"], extra_env={"NO_CMAKE_STRIP": "1"}) + run_in(source_dir, ['./build-infer.sh', 'java'], + extra_env={'NO_CMAKE_STRIP': '1'}) - package_name = "infer" + package_name = 'infer' infer_package = os.path.join(os.getcwd(), package_name) # We need to create a package with all of the depended libraries injected in it - run_in( - source_dir, - [ - "make", - "install-with-libs", - "BUILD_MODE=opt", - "PATCHELF=patchelf", - "DESTDIR={}".format(infer_package), - "libdir_relative_to_bindir=../lib", - ], - ) - - infer_package_with_pref = os.path.join(infer_package, "usr") + run_in(source_dir, ['make', 'install-with-libs', 'BUILD_MODE=opt', + 'PATCHELF=patchelf', 'DESTDIR={}'.format(infer_package), + 'libdir_relative_to_bindir=../lib']) + + + infer_package_with_pref = os.path.join(infer_package, 'usr') if not args.skip_tar: - os.rename( - os.path.join(infer_package_with_pref, "local"), - os.path.join(infer_package_with_pref, "infer"), - ) - build_tar_package( - "tar", - "%s.tar.xz" % (package_name), - infer_package_with_pref, - [ - os.path.join("infer", "bin"), - os.path.join("infer", "lib"), - os.path.join("infer", "share"), - ], - ) + os.rename(os.path.join(infer_package_with_pref, 'local'), + os.path.join(infer_package_with_pref, 'infer')) + build_tar_package('tar', '%s.tar.xz' % (package_name), + infer_package_with_pref, + [os.path.join('infer', 'bin'), + os.path.join('infer', 'lib'), + os.path.join('infer', 'share')]) diff --git a/build/buildconfig.py b/build/buildconfig.py index 3fcc82ffdb5d0ef72d86759773a53ce27f73bdb5..63f5d590663ed92e1bf3c4e8e8d520807ade5f04 100644 --- a/build/buildconfig.py +++ b/build/buildconfig.py @@ -9,10 +9,10 @@ from mozbuild.backend.configenvironment import PartialConfigEnvironment config = MozbuildObject.from_environment() partial_config = PartialConfigEnvironment(config.topobjdir) -for var in ("topsrcdir", "topobjdir"): +for var in ('topsrcdir', 'topobjdir'): value = getattr(config, var) setattr(sys.modules[__name__], var, value) -for var in ("defines", "substs", "get_dependencies"): +for var in ('defines', 'substs', 'get_dependencies'): value = getattr(partial_config, var) setattr(sys.modules[__name__], var, value) diff --git a/build/checksums.py b/build/checksums.py index d82c7211175ff4e553eb79affe5f14dcb3ec9606..08524deebd53120e5fe8211fb8f795f5712beea5 100755 --- a/build/checksums.py +++ b/build/checksums.py @@ -10,35 +10,35 @@ import hashlib import logging import os -logger = logging.getLogger("checksums.py") +logger = logging.getLogger('checksums.py') def digest_file(filename, digest, chunk_size=131072): - """Produce a checksum for the file specified by 'filename'. 'filename' + '''Produce a checksum for the file specified by 'filename'. 'filename' is a string path to a file that is opened and read in this function. The checksum algorithm is specified by 'digest' and is a valid OpenSSL algorithm. If the digest used is not valid or Python's hashlib doesn't work, the None object will be returned instead. The size of blocks that this function will read from the file object it opens based on - 'filename' can be specified by 'chunk_size', which defaults to 1K""" - assert not os.path.isdir(filename), "this function only works with files" + 'filename' can be specified by 'chunk_size', which defaults to 1K''' + assert not os.path.isdir(filename), 'this function only works with files' - logger.debug("Creating new %s object" % digest) + logger.debug('Creating new %s object' % digest) h = hashlib.new(digest) - with open(filename, "rb") as f: + with open(filename, 'rb') as f: while True: data = f.read(chunk_size) if not data: - logger.debug("Finished reading in file") + logger.debug('Finished reading in file') break h.update(data) hash = h.hexdigest() - logger.debug("Hash for %s is %s" % (filename, hash)) + logger.debug('Hash for %s is %s' % (filename, hash)) return hash def process_files(dirs, output_filename, digests): - """This function takes a list of directory names, 'drs'. It will then + '''This function takes a list of directory names, 'drs'. It will then compute the checksum for each of the files in these by by opening the files. Once each file is read and its checksum is computed, this function will write the information to the file specified by 'output_filename'. @@ -51,13 +51,14 @@ def process_files(dirs, output_filename, digests): Example: d1fa09ae4220 sha1 14250744 firefox-4.0b6pre.en-US.mac64.dmg - """ + ''' if os.path.exists(output_filename): - logger.debug('Overwriting existing checksums file "%s"' % output_filename) + logger.debug('Overwriting existing checksums file "%s"' % + output_filename) else: logger.debug('Creating a new checksums file "%s"' % output_filename) - with open(output_filename, "w+") as output: + with open(output_filename, 'w+') as output: for d in dirs: for root, dirs, files in os.walk(d): for f in files: @@ -67,21 +68,21 @@ def process_files(dirs, output_filename, digests): for digest in digests: hash = digest_file(full, digest) - output.write( - "%s %s %s %s\n" % (hash, digest, os.path.getsize(full), rel) - ) + output.write('%s %s %s %s\n' % ( + hash, digest, os.path.getsize(full), rel)) def setup_logging(level=logging.DEBUG): - """This function sets up the logging module using a speficiable logging + '''This function sets up the logging module using a speficiable logging module logging level. The default log level is DEBUG. The output is in the format: - Example: - DEBUG - Finished reading in file""" + DEBUG - Finished reading in file +''' - logger = logging.getLogger("checksums.py") + logger = logging.getLogger('checksums.py') logger.setLevel(logging.DEBUG) handler = logging.StreamHandler() handler.setLevel(level) @@ -91,41 +92,19 @@ def setup_logging(level=logging.DEBUG): def main(): - """This is a main function that parses arguments, sets up logging - and generates a checksum file""" + '''This is a main function that parses arguments, sets up logging + and generates a checksum file''' # Parse command line arguments parser = OptionParser() - parser.add_option( - "-d", - "--digest", - help="checksum algorithm to use", - action="append", - dest="digests", - ) - parser.add_option( - "-o", - "--output", - help="output file to use", - action="store", - dest="outfile", - default="checksums", - ) - parser.add_option( - "-v", - "--verbose", - help="Be noisy (takes precedence over quiet)", - action="store_true", - dest="verbose", - default=False, - ) - parser.add_option( - "-q", - "--quiet", - help="Be quiet", - action="store_true", - dest="quiet", - default=False, - ) + parser.add_option('-d', '--digest', help='checksum algorithm to use', + action='append', dest='digests') + parser.add_option('-o', '--output', help='output file to use', + action='store', dest='outfile', default='checksums') + parser.add_option('-v', '--verbose', + help='Be noisy (takes precedence over quiet)', + action='store_true', dest='verbose', default=False) + parser.add_option('-q', '--quiet', help='Be quiet', action='store_true', + dest='quiet', default=False) options, args = parser.parse_args() @@ -142,15 +121,15 @@ def main(): # Validate the digest type to use if not options.digests: - options.digests = ["sha1"] + options.digests = ['sha1'] for i in args: if not os.path.isdir(i): - logger.error("%s is not a directory" % i) + logger.error('%s is not a directory' % i) exit(1) process_files(args, options.outfile, options.digests) -if __name__ == "__main__": +if __name__ == '__main__': main() diff --git a/build/clang-plugin/ThirdPartyPaths.py b/build/clang-plugin/ThirdPartyPaths.py index caaa919d43f280dea4c17cfec31fb8661c304863..d004577c10718c8e33f92f293c2ad08096013bd4 100644 --- a/build/clang-plugin/ThirdPartyPaths.py +++ b/build/clang-plugin/ThirdPartyPaths.py @@ -18,13 +18,12 @@ def generate(output, *input_paths): for line in lines: line = line.strip() - if line.endswith("/"): + if line.endswith('/'): line = line[:-1] tpp_list.append(line) - tpp_strings = ",\n ".join([json.dumps(tpp) for tpp in sorted(tpp_list)]) + tpp_strings = ',\n '.join([json.dumps(tpp) for tpp in sorted(tpp_list)]) - output.write( - """\ + output.write("""\ /* THIS FILE IS GENERATED BY ThirdPartyPaths.py - DO NOT EDIT */ #include @@ -35,6 +34,4 @@ const char* MOZ_THIRD_PARTY_PATHS[] = { extern const uint32_t MOZ_THIRD_PARTY_PATHS_COUNT = %d; -""" - % (tpp_strings, len(tpp_list)) - ) +""" % (tpp_strings, len(tpp_list))) diff --git a/build/clang-plugin/ThreadAllows.py b/build/clang-plugin/ThreadAllows.py index e45f6292546640629ac5ec77098ecc3b23834340..2cf6502ab0ea43152032817e1cae289f57e591bd 100644 --- a/build/clang-plugin/ThreadAllows.py +++ b/build/clang-plugin/ThreadAllows.py @@ -3,19 +3,19 @@ # You can obtain one at http://mozilla.org/MPL/2.0/. import json -FIRST_LINE = "// This file was generated by generate_thread_allows.py. DO NOT EDIT." +FIRST_LINE = '// This file was generated by generate_thread_allows.py. DO NOT EDIT.' def generate_allows(input_paths): """ - This script reads in the ThreadAllows.txt and ThreadFileAllows.txt lists - and generates a header file containing a two arrays of allowed threads. - These can be the following formats: - -Files which the checker should ignore - These files either contain definitions of NS_NewNamedThread or - use args which the plugin can't cast (such as func args). - -Thread names which the checker should ignore - Specifies which individual thread names to ignore. + This script reads in the ThreadAllows.txt and ThreadFileAllows.txt lists + and generates a header file containing a two arrays of allowed threads. + These can be the following formats: + -Files which the checker should ignore + These files either contain definitions of NS_NewNamedThread or + use args which the plugin can't cast (such as func args). + -Thread names which the checker should ignore + Specifies which individual thread names to ignore. """ file_list = [] name_list = [] @@ -27,19 +27,17 @@ def generate_allows(input_paths): for line in sorted(lines): """ - We are assuming lines ending in .cpp, .h are files. Threads should - NOT have names containing filenames. Please don't do that. + We are assuming lines ending in .cpp, .h are files. Threads should + NOT have names containing filenames. Please don't do that. """ line = line.strip() - if line.endswith(".cpp") or line.endswith(".h"): + if line.endswith('.cpp') or line.endswith('.h'): file_list.append(line) else: name_list.append(line) - file_list_s = ",\n ".join(json.dumps(elem) for elem in file_list) - name_list_s = ",\n ".join(json.dumps(elem) for elem in name_list) - output_string = ( - FIRST_LINE - + """ + file_list_s = ',\n '.join(json.dumps(elem) for elem in file_list) + name_list_s = ',\n '.join(json.dumps(elem) for elem in name_list) + output_string = FIRST_LINE + """ static const char *allow_thread_files[] = { %s @@ -49,9 +47,7 @@ static const char *allow_thread_names[] = { %s }; - """ - % (file_list_s, name_list_s) - ) + """ % (file_list_s, name_list_s) return output_string diff --git a/build/clang-plugin/import_mozilla_checks.py b/build/clang-plugin/import_mozilla_checks.py index 2c2c5a42b9630a8389b497d266d6062fd05d1dc5..b4a4e002c0a9966e8a68ea3d320d7b1b8179bd95 100755 --- a/build/clang-plugin/import_mozilla_checks.py +++ b/build/clang-plugin/import_mozilla_checks.py @@ -30,27 +30,22 @@ def copy_dir_contents(src, dest): os.remove(destname) shutil.copy2(f, destname) else: - raise Exception("Directory not copied. Error: %s" % e) + raise Exception('Directory not copied. Error: %s' % e) def write_cmake(module_path, import_options): - names = [" " + os.path.basename(f) for f in glob.glob("%s/*.cpp" % module_path)] + names = [' ' + os.path.basename(f) for f in glob.glob("%s/*.cpp" % module_path)] if import_options["external"]: - names += [ - " " + os.path.join("external", os.path.basename(f)) - for f in glob.glob("%s/external/*.cpp" % (module_path)) - ] + names += [' ' + os.path.join("external", os.path.basename(f)) + for f in glob.glob("%s/external/*.cpp" % (module_path))] if import_options["alpha"]: - names += [ - " " + os.path.join("alpha", os.path.basename(f)) - for f in glob.glob("%s/alpha/*.cpp" % (module_path)) - ] + names += [' ' + os.path.join("alpha", os.path.basename(f)) + for f in glob.glob("%s/alpha/*.cpp" % (module_path))] - with open(os.path.join(module_path, "CMakeLists.txt"), "w") as f: - f.write( - """set(LLVM_LINK_COMPONENTS support) + with open(os.path.join(module_path, 'CMakeLists.txt'), 'w') as f: + f.write("""set(LLVM_LINK_COMPONENTS support) add_definitions( -DCLANG_TIDY ) @@ -67,43 +62,47 @@ add_clang_library(clangTidyMozillaModule clangTidyReadabilityModule clangTidyUtils clangTidyMPIModule - )""" - % {"names": "\n".join(names)} - ) + )""" % {'names': "\n".join(names)}) def add_moz_module(cmake_path): - with open(cmake_path, "r") as f: + with open(cmake_path, 'r') as f: lines = f.readlines() f.close() try: - idx = lines.index("set(ALL_CLANG_TIDY_CHECKS\n") - lines.insert(idx + 1, " clangTidyMozillaModule\n") + idx = lines.index('set(ALL_CLANG_TIDY_CHECKS\n') + lines.insert(idx + 1, ' clangTidyMozillaModule\n') - with open(cmake_path, "w") as f: + with open(cmake_path, 'w') as f: for line in lines: f.write(line) except ValueError: - raise Exception("Unable to find ALL_CLANG_TIDY_CHECKS in {}".format(cmake_path)) + raise Exception('Unable to find ALL_CLANG_TIDY_CHECKS in {}'.format(cmake_path)) def write_third_party_paths(mozilla_path, module_path): - tpp_txt = os.path.join(mozilla_path, "../../tools/rewriting/ThirdPartyPaths.txt") - generated_txt = os.path.join(mozilla_path, "../../tools/rewriting/Generated.txt") - with open(os.path.join(module_path, "ThirdPartyPaths.cpp"), "w") as f: + tpp_txt = os.path.join( + mozilla_path, '../../tools/rewriting/ThirdPartyPaths.txt') + generated_txt = os.path.join( + mozilla_path, '../../tools/rewriting/Generated.txt') + with open(os.path.join(module_path, 'ThirdPartyPaths.cpp'), 'w') as f: ThirdPartyPaths.generate(f, tpp_txt, generated_txt) def generate_thread_allows(mozilla_path, module_path): - names = os.path.join(mozilla_path, "../../build/clang-plugin/ThreadAllows.txt") - files = os.path.join(mozilla_path, "../../build/clang-plugin/ThreadFileAllows.txt") - with open(os.path.join(module_path, "ThreadAllows.h"), "w") as f: + names = os.path.join( + mozilla_path, '../../build/clang-plugin/ThreadAllows.txt' + ) + files = os.path.join( + mozilla_path, '../../build/clang-plugin/ThreadFileAllows.txt' + ) + with open(os.path.join(module_path, 'ThreadAllows.h'), 'w') as f: f.write(ThreadAllows.generate_allows({files, names})) def do_import(mozilla_path, clang_tidy_path, import_options): - module = "mozilla" + module = 'mozilla' module_path = os.path.join(clang_tidy_path, module) try: os.makedirs(module_path) @@ -115,20 +114,18 @@ def do_import(mozilla_path, clang_tidy_path, import_options): write_third_party_paths(mozilla_path, module_path) generate_thread_allows(mozilla_path, module_path) write_cmake(module_path, import_options) - add_moz_module(os.path.join(module_path, "..", "CMakeLists.txt")) - with open(os.path.join(module_path, "..", "CMakeLists.txt"), "a") as f: - f.write("add_subdirectory(%s)\n" % module) + add_moz_module(os.path.join(module_path, '..', 'CMakeLists.txt')) + with open(os.path.join(module_path, '..', 'CMakeLists.txt'), 'a') as f: + f.write('add_subdirectory(%s)\n' % module) # A better place for this would be in `ClangTidyForceLinker.h` but `ClangTidyMain.cpp` # is also OK. - with open(os.path.join(module_path, "..", "tool", "ClangTidyMain.cpp"), "a") as f: - f.write( - """ + with open(os.path.join(module_path, '..', 'tool', 'ClangTidyMain.cpp'), 'a') as f: + f.write(''' // This anchor is used to force the linker to link the MozillaModule. extern volatile int MozillaModuleAnchorSource; static int LLVM_ATTRIBUTE_UNUSED MozillaModuleAnchorDestination = MozillaModuleAnchorSource; -""" - ) +''') def main(): @@ -136,24 +133,18 @@ def main(): parser = argparse.ArgumentParser( usage="import_mozilla_checks.py [option]", - description="Imports the Mozilla static analysis checks into a clang-tidy source tree.", - ) - parser.add_argument( - "mozilla_path", help="Full path to mozilla-central/build/clang-plugin" - ) - parser.add_argument( - "clang_tidy_path", help="Full path to llvm-project/clang-tools-extra/clang-tidy" - ) - parser.add_argument( - "--import-alpha", - help="Enable import of in-tree alpha checks", - action="store_true", - ) - parser.add_argument( - "--import-external", - help="Enable import of in-tree external checks", - action="store_true", + description="Imports the Mozilla static analysis checks into a clang-tidy source tree." ) + parser.add_argument('mozilla_path', + help="Full path to mozilla-central/build/clang-plugin") + parser.add_argument('clang_tidy_path', + help="Full path to llvm-project/clang-tools-extra/clang-tidy") + parser.add_argument('--import-alpha', + help="Enable import of in-tree alpha checks", + action="store_true") + parser.add_argument('--import-external', + help="Enable import of in-tree external checks", + action="store_true") args = parser.parse_args() if not os.path.isdir(args.mozilla_path): @@ -162,10 +153,13 @@ def main(): if not os.path.isdir(args.clang_tidy_path): print("Invalid path to clang-tidy source directory") - import_options = {"alpha": args.import_alpha, "external": args.import_external} + import_options = { + "alpha": args.import_alpha, + "external": args.import_external + } do_import(args.mozilla_path, args.clang_tidy_path, import_options) -if __name__ == "__main__": +if __name__ == '__main__': main() diff --git a/build/clang-plugin/moz.build b/build/clang-plugin/moz.build index 47d780054c996d7d209f07bec94a210ef6b92a6f..00e20cc162bceb1ae460e9c369ba4d5a1cf97aad 100644 --- a/build/clang-plugin/moz.build +++ b/build/clang-plugin/moz.build @@ -4,119 +4,111 @@ # 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/. -HostSharedLibrary("clang-plugin") +HostSharedLibrary('clang-plugin') -HOST_SOURCES += ["!ThirdPartyPaths.cpp"] +HOST_SOURCES += ['!ThirdPartyPaths.cpp'] HOST_SOURCES += [ - "ArithmeticArgChecker.cpp", - "AssertAssignmentChecker.cpp", - "CanRunScriptChecker.cpp", - "CustomAttributes.cpp", - "CustomTypeAnnotation.cpp", - "DanglingOnTemporaryChecker.cpp", - "DiagnosticsMatcher.cpp", - "ExplicitImplicitChecker.cpp", - "ExplicitOperatorBoolChecker.cpp", - "KungFuDeathGripChecker.cpp", - "MozCheckAction.cpp", - "MustOverrideChecker.cpp", - "MustReturnFromCallerChecker.cpp", - "MustUseChecker.cpp", - "NaNExprChecker.cpp", - "NeedsNoVTableTypeChecker.cpp", - "NoAddRefReleaseOnReturnChecker.cpp", - "NoAutoTypeChecker.cpp", - "NoDuplicateRefCntMemberChecker.cpp", - "NoExplicitMoveConstructorChecker.cpp", - "NoNewThreadsChecker.cpp", - "NonMemMovableMemberChecker.cpp", - "NonMemMovableTemplateArgChecker.cpp", - "NonParamInsideFunctionDeclChecker.cpp", - "NonTrivialTypeInFfiChecker.cpp", - "NoPrincipalGetURI.cpp", - "NoUsingNamespaceMozillaJavaChecker.cpp", - "OverrideBaseCallChecker.cpp", - "OverrideBaseCallUsageChecker.cpp", - "ParamTraitsEnumChecker.cpp", - "RefCountedCopyConstructorChecker.cpp", - "RefCountedInsideLambdaChecker.cpp", - "ScopeChecker.cpp", - "SprintfLiteralChecker.cpp", - "TemporaryLifetimeBoundChecker.cpp", - "TrivialCtorDtorChecker.cpp", - "TrivialDtorChecker.cpp", - "VariableUsageHelpers.cpp", + 'ArithmeticArgChecker.cpp', + 'AssertAssignmentChecker.cpp', + 'CanRunScriptChecker.cpp', + 'CustomAttributes.cpp', + 'CustomTypeAnnotation.cpp', + 'DanglingOnTemporaryChecker.cpp', + 'DiagnosticsMatcher.cpp', + 'ExplicitImplicitChecker.cpp', + 'ExplicitOperatorBoolChecker.cpp', + 'KungFuDeathGripChecker.cpp', + 'MozCheckAction.cpp', + 'MustOverrideChecker.cpp', + 'MustReturnFromCallerChecker.cpp', + 'MustUseChecker.cpp', + 'NaNExprChecker.cpp', + 'NeedsNoVTableTypeChecker.cpp', + 'NoAddRefReleaseOnReturnChecker.cpp', + 'NoAutoTypeChecker.cpp', + 'NoDuplicateRefCntMemberChecker.cpp', + 'NoExplicitMoveConstructorChecker.cpp', + 'NoNewThreadsChecker.cpp', + 'NonMemMovableMemberChecker.cpp', + 'NonMemMovableTemplateArgChecker.cpp', + 'NonParamInsideFunctionDeclChecker.cpp', + 'NonTrivialTypeInFfiChecker.cpp', + 'NoPrincipalGetURI.cpp', + 'NoUsingNamespaceMozillaJavaChecker.cpp', + 'OverrideBaseCallChecker.cpp', + 'OverrideBaseCallUsageChecker.cpp', + 'ParamTraitsEnumChecker.cpp', + 'RefCountedCopyConstructorChecker.cpp', + 'RefCountedInsideLambdaChecker.cpp', + 'ScopeChecker.cpp', + 'SprintfLiteralChecker.cpp', + 'TemporaryLifetimeBoundChecker.cpp', + 'TrivialCtorDtorChecker.cpp', + 'TrivialDtorChecker.cpp', + 'VariableUsageHelpers.cpp', ] # Ideally, we wouldn't have compile-time choices wrt checkes. bug 1617153. -if CONFIG["OS_ARCH"] == "WINNT": - HOST_DEFINES["TARGET_IS_WINDOWS"] = True +if CONFIG['OS_ARCH'] == 'WINNT': + HOST_DEFINES['TARGET_IS_WINDOWS'] = True HOST_SOURCES += [ - "FopenUsageChecker.cpp", - "LoadLibraryUsageChecker.cpp", + 'FopenUsageChecker.cpp', + 'LoadLibraryUsageChecker.cpp', ] -if CONFIG["ENABLE_MOZSEARCH_PLUGIN"]: +if CONFIG['ENABLE_MOZSEARCH_PLUGIN']: HOST_SOURCES += [ - "mozsearch-plugin/FileOperations.cpp", - "mozsearch-plugin/JSONFormatter.cpp", - "mozsearch-plugin/MozsearchIndexer.cpp", - "mozsearch-plugin/StringOperations.cpp", + 'mozsearch-plugin/FileOperations.cpp', + 'mozsearch-plugin/JSONFormatter.cpp', + 'mozsearch-plugin/MozsearchIndexer.cpp', + 'mozsearch-plugin/StringOperations.cpp', ] -GeneratedFile( - "ThirdPartyPaths.cpp", - script="ThirdPartyPaths.py", - entry_point="generate", - inputs=[ - "/tools/rewriting/ThirdPartyPaths.txt", - "/tools/rewriting/Generated.txt", - ], -) - -GeneratedFile( - "ThreadAllows.h", - script="ThreadAllows.py", - entry_point="generate_file", - inputs=[ - "/build/clang-plugin/ThreadAllows.txt", - "/build/clang-plugin/ThreadFileAllows.txt", - ], -) - -HOST_COMPILE_FLAGS["STL"] = [] -HOST_COMPILE_FLAGS["VISIBILITY"] = [] +GeneratedFile('ThirdPartyPaths.cpp', script="ThirdPartyPaths.py", + entry_point="generate", inputs=[ + '/tools/rewriting/ThirdPartyPaths.txt', + '/tools/rewriting/Generated.txt', + ]) + +GeneratedFile('ThreadAllows.h', script="ThreadAllows.py", + entry_point="generate_file", inputs=[ + '/build/clang-plugin/ThreadAllows.txt', + '/build/clang-plugin/ThreadFileAllows.txt' + ]) + +HOST_COMPILE_FLAGS['STL'] = [] +HOST_COMPILE_FLAGS['VISIBILITY'] = [] # libc++ is required to build plugins against clang on OS X. -if CONFIG["HOST_OS_ARCH"] == "Darwin": - HOST_CXXFLAGS += ["-stdlib=libc++"] +if CONFIG['HOST_OS_ARCH'] == 'Darwin': + HOST_CXXFLAGS += ['-stdlib=libc++'] # As of clang 8, llvm-config doesn't output the flags used to build clang # itself, so we don't end up with -fPIC as a side effect. llvm.org/PR8220 -if CONFIG["HOST_OS_ARCH"] != "WINNT": - HOST_CXXFLAGS += ["-fPIC"] +if CONFIG['HOST_OS_ARCH'] != 'WINNT': + HOST_CXXFLAGS += ['-fPIC'] DIRS += [ - "tests", + 'tests', ] -include("external/sources.mozbuild") +include('external/sources.mozbuild') -if CONFIG["ENABLE_CLANG_PLUGIN_ALPHA"]: +if CONFIG['ENABLE_CLANG_PLUGIN_ALPHA']: HOST_DEFINES["MOZ_CLANG_PLUGIN_ALPHA"] = "1" - include("alpha/sources.mozbuild") + include('alpha/sources.mozbuild') # In the current moz.build world, we need to override essentially every # variable to limit ourselves to what we need to build the clang plugin. -if CONFIG["HOST_OS_ARCH"] == "WINNT": - extra_cxxflags = ["-GR-", "-EHsc"] +if CONFIG['HOST_OS_ARCH'] == 'WINNT': + extra_cxxflags = ['-GR-', '-EHsc'] else: - extra_cxxflags = ["-fno-rtti", "-fno-exceptions"] + extra_cxxflags = ['-fno-rtti', '-fno-exceptions'] -if CONFIG["LLVM_CXXFLAGS"]: - HOST_COMPILE_FLAGS["HOST_CXXFLAGS"] = CONFIG["LLVM_CXXFLAGS"] + extra_cxxflags +if CONFIG['LLVM_CXXFLAGS']: + HOST_COMPILE_FLAGS['HOST_CXXFLAGS'] = CONFIG['LLVM_CXXFLAGS'] + extra_cxxflags # Avoid -DDEBUG=1 on the command line, which conflicts with a #define # DEBUG(...) in llvm headers. -DEFINES["DEBUG"] = False +DEFINES['DEBUG'] = False diff --git a/build/clang-plugin/tests/moz.build b/build/clang-plugin/tests/moz.build index f826d74d45699ccd003218be4d5bd096a03cd21c..bb0d533adfd28eb92735c4c1ec4ed48a82b725f5 100644 --- a/build/clang-plugin/tests/moz.build +++ b/build/clang-plugin/tests/moz.build @@ -5,86 +5,81 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # dummy library name to avoid skipping building the sources here. -Library("clang-plugin-tests") +Library('clang-plugin-tests') SOURCES += [ - "TestAssertWithAssignment.cpp", - "TestBadImplicitConversionCtor.cpp", - "TestCanRunScript.cpp", - "TestCustomHeap.cpp", - "TestDanglingOnTemporary.cpp", - "TestExplicitOperatorBool.cpp", - "TestGlobalClass.cpp", - "TestHeapClass.cpp", - "TestInheritTypeAnnotationsFromTemplateArgs.cpp", - "TestKungFuDeathGrip.cpp", - "TestMultipleAnnotations.cpp", - "TestMustOverride.cpp", - "TestMustReturnFromCaller.cpp", - "TestMustUse.cpp", - "TestNANTestingExpr.cpp", - "TestNANTestingExprC.c", - "TestNeedsNoVTableType.cpp", - "TestNoAddRefReleaseOnReturn.cpp", - "TestNoArithmeticExprInArgument.cpp", - "TestNoAutoType.cpp", - "TestNoDuplicateRefCntMember.cpp", - "TestNoExplicitMoveConstructor.cpp", - "TestNoNewThreadsChecker.cpp", - "TestNonHeapClass.cpp", - "TestNonMemMovable.cpp", - "TestNonMemMovableStd.cpp", - "TestNonMemMovableStdAtomic.cpp", - "TestNonParameterChecker.cpp", - "TestNonTemporaryClass.cpp", - "TestNonTrivialTypeInFfi.cpp", - "TestNoPrincipalGetUri.cpp", - "TestNoRefcountedInsideLambdas.cpp", - "TestNoUsingNamespaceMozillaJava.cpp", - "TestOverrideBaseCall.cpp", - "TestOverrideBaseCallAnnotation.cpp", - "TestParamTraitsEnum.cpp", - "TestRefCountedCopyConstructor.cpp", - "TestSprintfLiteral.cpp", - "TestStackClass.cpp", - "TestStaticLocalClass.cpp", - "TestTemporaryClass.cpp", - "TestTemporaryLifetimeBound.cpp", - "TestTrivialCtorDtor.cpp", - "TestTrivialDtor.cpp", + 'TestAssertWithAssignment.cpp', + 'TestBadImplicitConversionCtor.cpp', + 'TestCanRunScript.cpp', + 'TestCustomHeap.cpp', + 'TestDanglingOnTemporary.cpp', + 'TestExplicitOperatorBool.cpp', + 'TestGlobalClass.cpp', + 'TestHeapClass.cpp', + 'TestInheritTypeAnnotationsFromTemplateArgs.cpp', + 'TestKungFuDeathGrip.cpp', + 'TestMultipleAnnotations.cpp', + 'TestMustOverride.cpp', + 'TestMustReturnFromCaller.cpp', + 'TestMustUse.cpp', + 'TestNANTestingExpr.cpp', + 'TestNANTestingExprC.c', + 'TestNeedsNoVTableType.cpp', + 'TestNoAddRefReleaseOnReturn.cpp', + 'TestNoArithmeticExprInArgument.cpp', + 'TestNoAutoType.cpp', + 'TestNoDuplicateRefCntMember.cpp', + 'TestNoExplicitMoveConstructor.cpp', + 'TestNoNewThreadsChecker.cpp', + 'TestNonHeapClass.cpp', + 'TestNonMemMovable.cpp', + 'TestNonMemMovableStd.cpp', + 'TestNonMemMovableStdAtomic.cpp', + 'TestNonParameterChecker.cpp', + 'TestNonTemporaryClass.cpp', + 'TestNonTrivialTypeInFfi.cpp', + 'TestNoPrincipalGetUri.cpp', + 'TestNoRefcountedInsideLambdas.cpp', + 'TestNoUsingNamespaceMozillaJava.cpp', + 'TestOverrideBaseCall.cpp', + 'TestOverrideBaseCallAnnotation.cpp', + 'TestParamTraitsEnum.cpp', + 'TestRefCountedCopyConstructor.cpp', + 'TestSprintfLiteral.cpp', + 'TestStackClass.cpp', + 'TestStaticLocalClass.cpp', + 'TestTemporaryClass.cpp', + 'TestTemporaryLifetimeBound.cpp', + 'TestTrivialCtorDtor.cpp', + 'TestTrivialDtor.cpp', ] -if CONFIG["OS_ARCH"] == "WINNT": +if CONFIG['OS_ARCH'] == 'WINNT': SOURCES += [ - "TestFopenUsage.cpp", - "TestLoadLibraryUsage.cpp", + 'TestFopenUsage.cpp', + 'TestLoadLibraryUsage.cpp', ] -include("../external/tests/sources.mozbuild") +include('../external/tests/sources.mozbuild') -if CONFIG["ENABLE_CLANG_PLUGIN_ALPHA"]: +if CONFIG['ENABLE_CLANG_PLUGIN_ALPHA']: DEFINES["MOZ_CLANG_PLUGIN_ALPHA"] = "1" - include("../alpha/tests/sources.mozbuild") + include('../alpha/tests/sources.mozbuild') DisableStlWrapping() NoVisibilityFlags() # Build without any warning flags, and with clang verify flag for a # syntax-only build (no codegen), without a limit on the number of errors. -COMPILE_FLAGS["OS_CXXFLAGS"] = [ - f for f in COMPILE_FLAGS.get("OS_CXXFLAGS", []) if not f.startswith("-W") -] + ["-fsyntax-only", "-Xclang", "-verify", "-ferror-limit=0", "-Wno-invalid-noreturn"] -COMPILE_FLAGS["OS_CFLAGS"] = [ - f for f in COMPILE_FLAGS.get("OS_CFLAGS", []) if not f.startswith("-W") -] + [ - "-fsyntax-only", - "-Xclang", - "-verify", - "-ferror-limit=0", - "-Xclang", - "-std=c11", - "-Wno-invalid-noreturn", -] +COMPILE_FLAGS['OS_CXXFLAGS'] = ( + [f for f in COMPILE_FLAGS.get('OS_CXXFLAGS', []) if not f.startswith('-W')] + + ['-fsyntax-only', '-Xclang', '-verify', '-ferror-limit=0', '-Wno-invalid-noreturn'] +) +COMPILE_FLAGS['OS_CFLAGS'] = ( + [f for f in COMPILE_FLAGS.get('OS_CFLAGS', []) if not f.startswith('-W')] + + ['-fsyntax-only', '-Xclang', '-verify', '-ferror-limit=0', '-Xclang', '-std=c11', + '-Wno-invalid-noreturn'] +) # Don't reflect WARNINGS_CFLAGS into CFLAGS, as the warnings flags should be # as specified in OS_CFLAGS above. diff --git a/build/compare-mozconfig/compare-mozconfigs.py b/build/compare-mozconfig/compare-mozconfigs.py index 7e39d9c071c52220a5a0a4cb5492bbe0618b7b00..396d196d57093e5d21c4ea99e5f1e5765ac8d49c 100644 --- a/build/compare-mozconfig/compare-mozconfigs.py +++ b/build/compare-mozconfig/compare-mozconfigs.py @@ -19,12 +19,12 @@ FAILURE_CODE = 1 SUCCESS_CODE = 0 PLATFORMS = ( - "linux32", - "linux64", - "macosx64", - "win32", - "win64", - "win64-aarch64", + 'linux32', + 'linux64', + 'macosx64', + 'win32', + 'win64', + 'win64-aarch64', ) log = logging.getLogger(__name__) @@ -37,12 +37,11 @@ class ConfigError(Exception): def readConfig(configfile): c = {} execfile(configfile, c) - return c["whitelist"] + return c['whitelist'] -def verify_mozconfigs( - mozconfig_pair, nightly_mozconfig_pair, platform, mozconfigWhitelist -): +def verify_mozconfigs(mozconfig_pair, nightly_mozconfig_pair, platform, + mozconfigWhitelist): """Compares mozconfig to nightly_mozconfig and compare to an optional whitelist of known differences. mozconfig_pair and nightly_mozconfig_pair are pairs containing the mozconfig's identifier and the list of lines in @@ -60,64 +59,61 @@ def verify_mozconfigs( success = True diff_instance = difflib.Differ() - diff_result = diff_instance.compare(mozconfig_lines, nightly_mozconfig_lines) + diff_result = diff_instance.compare( + mozconfig_lines, nightly_mozconfig_lines) diff_list = list(diff_result) for line in diff_list: clean_line = line[1:].strip() - if (line[0] == "-" or line[0] == "+") and len(clean_line) > 1: + if (line[0] == '-' or line[0] == '+') and len(clean_line) > 1: # skip comment lines - if clean_line.startswith("#"): + if clean_line.startswith('#'): continue # compare to whitelist message = "" - if line[0] == "-": + if line[0] == '-': # handle lines that move around in diff - if "+" + line[1:] in diff_list: + if '+' + line[1:] in diff_list: continue - if platform in mozconfigWhitelist.get("release", {}): - if clean_line in mozconfigWhitelist["release"][platform]: + if platform in mozconfigWhitelist.get('release', {}): + if clean_line in \ + mozconfigWhitelist['release'][platform]: continue - elif line[0] == "+": - if "-" + line[1:] in diff_list: + elif line[0] == '+': + if '-' + line[1:] in diff_list: continue - if platform in mozconfigWhitelist.get("nightly", {}): - if clean_line in mozconfigWhitelist["nightly"][platform]: + if platform in mozconfigWhitelist.get('nightly', {}): + if clean_line in \ + mozconfigWhitelist['nightly'][platform]: continue else: - log.warning( - "%s not in %s %s!" - % ( - clean_line, - platform, - mozconfigWhitelist["nightly"][platform], - ) - ) + log.warning("%s not in %s %s!" % ( + clean_line, platform, + mozconfigWhitelist['nightly'][platform])) else: log.error("Skipping line %s!" % line) continue message = "found in %s but not in %s: %s" - if line[0] == "-": - log.error( - message % (mozconfig_name, nightly_mozconfig_name, clean_line) - ) + if line[0] == '-': + log.error(message % (mozconfig_name, + nightly_mozconfig_name, clean_line)) else: - log.error( - message % (nightly_mozconfig_name, mozconfig_name, clean_line) - ) + log.error(message % (nightly_mozconfig_name, + mozconfig_name, clean_line)) success = False return success def get_mozconfig(path): """Consumes a path and returns a list of lines from the mozconfig file.""" - with open(path, "rb") as fh: + with open(path, 'rb') as fh: return fh.readlines() def compare(topsrcdir): - app = os.path.join(topsrcdir, "browser") - whitelist = readConfig(os.path.join(app, "config", "mozconfigs", "whitelist")) + app = os.path.join(topsrcdir, 'browser') + whitelist = readConfig(os.path.join(app, 'config', 'mozconfigs', + 'whitelist')) success = True @@ -125,13 +121,13 @@ def compare(topsrcdir): return {l.strip() for l in lines} for platform in PLATFORMS: - log.info("Comparing platform %s" % platform) + log.info('Comparing platform %s' % platform) - mozconfigs_path = os.path.join(app, "config", "mozconfigs", platform) + mozconfigs_path = os.path.join(app, 'config', 'mozconfigs', platform) - nightly_path = os.path.join(mozconfigs_path, "nightly") - beta_path = os.path.join(mozconfigs_path, "beta") - release_path = os.path.join(mozconfigs_path, "release") + nightly_path = os.path.join(mozconfigs_path, 'nightly') + beta_path = os.path.join(mozconfigs_path, 'beta') + release_path = os.path.join(mozconfigs_path, 'release') nightly_lines = get_mozconfig(nightly_path) beta_lines = get_mozconfig(beta_path) @@ -139,28 +135,28 @@ def compare(topsrcdir): # Validate that entries in whitelist['nightly'][platform] are actually # present. - whitelist_normalized = normalize_lines(whitelist["nightly"].get(platform, [])) + whitelist_normalized = normalize_lines( + whitelist['nightly'].get(platform, [])) nightly_normalized = normalize_lines(nightly_lines) for line in sorted(whitelist_normalized - nightly_normalized): - log.error("extra line in nightly whitelist: %s" % line) + log.error('extra line in nightly whitelist: %s' % line) success = False - log.info("Comparing beta and nightly mozconfigs") - passed = verify_mozconfigs( - (beta_path, beta_lines), (nightly_path, nightly_lines), platform, whitelist - ) + log.info('Comparing beta and nightly mozconfigs') + passed = verify_mozconfigs((beta_path, beta_lines), + (nightly_path, nightly_lines), + platform, + whitelist) if not passed: success = False - log.info("Comparing release and nightly mozconfigs") - passed = verify_mozconfigs( - (release_path, release_lines), - (nightly_path, nightly_lines), - platform, - whitelist, - ) + log.info('Comparing release and nightly mozconfigs') + passed = verify_mozconfigs((release_path, release_lines), + (nightly_path, nightly_lines), + platform, + whitelist) if not passed: success = False @@ -169,10 +165,10 @@ def compare(topsrcdir): class TestCompareMozconfigs(unittest.TestCase): def test_compare_mozconfigs(self): - topsrcdir = buildconfig.substs["top_srcdir"] + topsrcdir = buildconfig.substs['top_srcdir'] self.assertTrue(compare(topsrcdir)) -if __name__ == "__main__": +if __name__ == '__main__': logging.basicConfig(level=logging.INFO) mozunit.main() diff --git a/build/gen_symverscript.py b/build/gen_symverscript.py index f32554abc800d648bb01324d08983e27d5af7b4a..677eea754c0cd0515515f0107af4c4c005cd36bc 100644 --- a/build/gen_symverscript.py +++ b/build/gen_symverscript.py @@ -10,14 +10,12 @@ from mozbuild.preprocessor import Preprocessor def main(output, input_file, version): pp = Preprocessor() - pp.context.update( - { - "VERSION": version, - } - ) + pp.context.update({ + 'VERSION': version, + }) pp.out = output pp.do_include(input_file) -if __name__ == "__main__": +if __name__ == '__main__': main(*sys.agv[1:]) diff --git a/build/gen_test_packages_manifest.py b/build/gen_test_packages_manifest.py index b6f2353684b97e070ec98f707aeac287a0d36571..75f8ee9982229f5bbfc4fd2e52b3d7f9d57567c4 100644 --- a/build/gen_test_packages_manifest.py +++ b/build/gen_test_packages_manifest.py @@ -9,88 +9,68 @@ import json from argparse import ArgumentParser ALL_HARNESSES = [ - "common", # Harnesses without a specific package will look here. - "condprof", - "mochitest", - "reftest", - "xpcshell", - "cppunittest", - "jittest", - "mozbase", - "web-platform", - "talos", - "raptor", - "awsy", - "gtest", - "updater-dep", - "jsreftest", - "perftests", + 'common', # Harnesses without a specific package will look here. + 'condprof', + 'mochitest', + 'reftest', + 'xpcshell', + 'cppunittest', + 'jittest', + 'mozbase', + 'web-platform', + 'talos', + 'raptor', + 'awsy', + 'gtest', + 'updater-dep', + 'jsreftest', + 'perftests', ] PACKAGE_SPECIFIED_HARNESSES = [ - "condprof", - "cppunittest", - "mochitest", - "reftest", - "xpcshell", - "web-platform", - "talos", - "raptor", - "awsy", - "updater-dep", - "jittest", - "jsreftest", - "perftests", + 'condprof', + 'cppunittest', + 'mochitest', + 'reftest', + 'xpcshell', + 'web-platform', + 'talos', + 'raptor', + 'awsy', + 'updater-dep', + 'jittest', + 'jsreftest', + 'perftests', ] # These packages are not present for every build configuration. OPTIONAL_PACKAGES = [ - "gtest", + 'gtest', ] def parse_args(): parser = ArgumentParser( description="Generate a test_packages.json file to tell automation which harnesses " - "require which test packages." - ) - parser.add_argument( - "--common", - required=True, - action="store", - dest="tests_common", - help='Name of the "common" archive, a package to be used by all ' "harnesses.", - ) - parser.add_argument( - "--jsshell", - required=True, - action="store", - dest="jsshell", - help="Name of the jsshell zip.", - ) + "require which test packages.") + parser.add_argument("--common", required=True, + action="store", dest="tests_common", + help="Name of the \"common\" archive, a package to be used by all " + "harnesses.") + parser.add_argument("--jsshell", required=True, + action="store", dest="jsshell", + help="Name of the jsshell zip.") for harness in PACKAGE_SPECIFIED_HARNESSES: - parser.add_argument( - "--%s" % harness, - required=True, - action="store", - dest=harness, - help="Name of the %s zip." % harness, - ) + parser.add_argument("--%s" % harness, required=True, + action="store", dest=harness, + help="Name of the %s zip." % harness) for harness in OPTIONAL_PACKAGES: - parser.add_argument( - "--%s" % harness, - required=False, - action="store", - dest=harness, - help="Name of the %s zip." % harness, - ) - parser.add_argument( - "--dest-file", - required=True, - action="store", - dest="destfile", - help="Path to the output file to be written.", - ) + parser.add_argument("--%s" % harness, required=False, + action="store", dest=harness, + help="Name of the %s zip." % harness) + parser.add_argument("--dest-file", required=True, + action="store", dest="destfile", + help="Path to the output file to be written.") return parser.parse_args() @@ -105,8 +85,8 @@ def generate_package_data(args): jsshell = args.jsshell harness_requirements = dict([(k, [tests_common]) for k in ALL_HARNESSES]) - harness_requirements["jittest"].append(jsshell) - harness_requirements["jsreftest"].append(args.reftest) + harness_requirements['jittest'].append(jsshell) + harness_requirements['jsreftest'].append(args.reftest) for harness in PACKAGE_SPECIFIED_HARNESSES + OPTIONAL_PACKAGES: pkg_name = getattr(args, harness, None) if pkg_name is None: @@ -115,8 +95,8 @@ def generate_package_data(args): return harness_requirements -if __name__ == "__main__": +if __name__ == '__main__': args = parse_args() packages_data = generate_package_data(args) - with open(args.destfile, "w") as of: + with open(args.destfile, 'w') as of: json.dump(packages_data, of, indent=4) diff --git a/build/mach_bootstrap.py b/build/mach_bootstrap.py index ce193f6c55309348b9522412aeb49b9e87efc89d..d92958a5fdcebc0f0a8718dca631fd3807f68d43 100644 --- a/build/mach_bootstrap.py +++ b/build/mach_bootstrap.py @@ -21,7 +21,7 @@ else: from types import ModuleType -STATE_DIR_FIRST_RUN = """ +STATE_DIR_FIRST_RUN = ''' mach and the build system store shared state in a common directory on the filesystem. The following directory will be created: @@ -33,142 +33,142 @@ use and re-run mach. For this change to take effect forever, you'll likely want to export this environment variable from your shell's init scripts. Press ENTER/RETURN to continue or CTRL+c to abort. -""".lstrip() +'''.lstrip() # Individual files providing mach commands. MACH_MODULES = [ - "build/valgrind/mach_commands.py", - "devtools/shared/css/generated/mach_commands.py", - "dom/bindings/mach_commands.py", - "js/src/devtools/rootAnalysis/mach_commands.py", - "layout/tools/reftest/mach_commands.py", - "mobile/android/mach_commands.py", - "python/mach/mach/commands/commandinfo.py", - "python/mach/mach/commands/settings.py", - "python/mach_commands.py", - "python/mozboot/mozboot/mach_commands.py", - "python/mozbuild/mozbuild/artifact_commands.py", - "python/mozbuild/mozbuild/backend/mach_commands.py", - "python/mozbuild/mozbuild/build_commands.py", - "python/mozbuild/mozbuild/code_analysis/mach_commands.py", - "python/mozbuild/mozbuild/compilation/codecomplete.py", - "python/mozbuild/mozbuild/frontend/mach_commands.py", - "python/mozbuild/mozbuild/vendor/mach_commands.py", - "python/mozbuild/mozbuild/mach_commands.py", - "python/mozperftest/mozperftest/mach_commands.py", - "python/mozrelease/mozrelease/mach_commands.py", - "remote/mach_commands.py", - "taskcluster/mach_commands.py", - "testing/awsy/mach_commands.py", - "testing/condprofile/mach_commands.py", - "testing/firefox-ui/mach_commands.py", - "testing/geckodriver/mach_commands.py", - "testing/mach_commands.py", - "testing/marionette/mach_commands.py", - "testing/mochitest/mach_commands.py", - "testing/mozharness/mach_commands.py", - "testing/raptor/mach_commands.py", - "testing/talos/mach_commands.py", - "testing/tps/mach_commands.py", - "testing/web-platform/mach_commands.py", - "testing/xpcshell/mach_commands.py", - "toolkit/components/telemetry/tests/marionette/mach_commands.py", - "tools/browsertime/mach_commands.py", - "tools/compare-locales/mach_commands.py", - "tools/lint/mach_commands.py", - "tools/mach_commands.py", - "tools/moztreedocs/mach_commands.py", - "tools/phabricator/mach_commands.py", - "tools/power/mach_commands.py", - "tools/tryselect/mach_commands.py", - "tools/vcs/mach_commands.py", + 'build/valgrind/mach_commands.py', + 'devtools/shared/css/generated/mach_commands.py', + 'dom/bindings/mach_commands.py', + 'js/src/devtools/rootAnalysis/mach_commands.py', + 'layout/tools/reftest/mach_commands.py', + 'mobile/android/mach_commands.py', + 'python/mach/mach/commands/commandinfo.py', + 'python/mach/mach/commands/settings.py', + 'python/mach_commands.py', + 'python/mozboot/mozboot/mach_commands.py', + 'python/mozbuild/mozbuild/artifact_commands.py', + 'python/mozbuild/mozbuild/backend/mach_commands.py', + 'python/mozbuild/mozbuild/build_commands.py', + 'python/mozbuild/mozbuild/code_analysis/mach_commands.py', + 'python/mozbuild/mozbuild/compilation/codecomplete.py', + 'python/mozbuild/mozbuild/frontend/mach_commands.py', + 'python/mozbuild/mozbuild/vendor/mach_commands.py', + 'python/mozbuild/mozbuild/mach_commands.py', + 'python/mozperftest/mozperftest/mach_commands.py', + 'python/mozrelease/mozrelease/mach_commands.py', + 'remote/mach_commands.py', + 'taskcluster/mach_commands.py', + 'testing/awsy/mach_commands.py', + 'testing/condprofile/mach_commands.py', + 'testing/firefox-ui/mach_commands.py', + 'testing/geckodriver/mach_commands.py', + 'testing/mach_commands.py', + 'testing/marionette/mach_commands.py', + 'testing/mochitest/mach_commands.py', + 'testing/mozharness/mach_commands.py', + 'testing/raptor/mach_commands.py', + 'testing/talos/mach_commands.py', + 'testing/tps/mach_commands.py', + 'testing/web-platform/mach_commands.py', + 'testing/xpcshell/mach_commands.py', + 'toolkit/components/telemetry/tests/marionette/mach_commands.py', + 'tools/browsertime/mach_commands.py', + 'tools/compare-locales/mach_commands.py', + 'tools/lint/mach_commands.py', + 'tools/mach_commands.py', + 'tools/moztreedocs/mach_commands.py', + 'tools/phabricator/mach_commands.py', + 'tools/power/mach_commands.py', + 'tools/tryselect/mach_commands.py', + 'tools/vcs/mach_commands.py', ] CATEGORIES = { - "build": { - "short": "Build Commands", - "long": "Interact with the build system", - "priority": 80, + 'build': { + 'short': 'Build Commands', + 'long': 'Interact with the build system', + 'priority': 80, }, - "post-build": { - "short": "Post-build Commands", - "long": "Common actions performed after completing a build.", - "priority": 70, + 'post-build': { + 'short': 'Post-build Commands', + 'long': 'Common actions performed after completing a build.', + 'priority': 70, }, - "testing": { - "short": "Testing", - "long": "Run tests.", - "priority": 60, + 'testing': { + 'short': 'Testing', + 'long': 'Run tests.', + 'priority': 60, }, - "ci": { - "short": "CI", - "long": "Taskcluster commands", - "priority": 59, + 'ci': { + 'short': 'CI', + 'long': 'Taskcluster commands', + 'priority': 59, }, - "devenv": { - "short": "Development Environment", - "long": "Set up and configure your development environment.", - "priority": 50, + 'devenv': { + 'short': 'Development Environment', + 'long': 'Set up and configure your development environment.', + 'priority': 50, }, - "build-dev": { - "short": "Low-level Build System Interaction", - "long": "Interact with specific parts of the build system.", - "priority": 20, + 'build-dev': { + 'short': 'Low-level Build System Interaction', + 'long': 'Interact with specific parts of the build system.', + 'priority': 20, }, - "misc": { - "short": "Potpourri", - "long": "Potent potables and assorted snacks.", - "priority": 10, + 'misc': { + 'short': 'Potpourri', + 'long': 'Potent potables and assorted snacks.', + 'priority': 10, }, - "release": { - "short": "Release automation", - "long": "Commands for used in release automation.", - "priority": 5, + 'release': { + 'short': 'Release automation', + 'long': 'Commands for used in release automation.', + 'priority': 5, }, - "disabled": { - "short": "Disabled", - "long": "The disabled commands are hidden by default. Use -v to display them. " - "These commands are unavailable for your current context, " + 'disabled': { + 'short': 'Disabled', + 'long': 'The disabled commands are hidden by default. Use -v to display them. ' + 'These commands are unavailable for your current context, ' 'run "mach " to see why.', - "priority": 0, + 'priority': 0, }, } def search_path(mozilla_dir, packages_txt): with open(os.path.join(mozilla_dir, packages_txt)) as f: - packages = [line.rstrip().split(":") for line in f] + packages = [line.rstrip().split(':') for line in f] def handle_package(package): - if package[0] == "optional": + if package[0] == 'optional': try: for path in handle_package(package[1:]): yield path except Exception: pass - if package[0] in ("windows", "!windows"): - for_win = not package[0].startswith("!") - is_win = sys.platform == "win32" + if package[0] in ('windows', '!windows'): + for_win = not package[0].startswith('!') + is_win = sys.platform == 'win32' if is_win == for_win: for path in handle_package(package[1:]): yield path - if package[0] in ("python2", "python3"): - for_python3 = package[0].endswith("3") + if package[0] in ('python2', 'python3'): + for_python3 = package[0].endswith('3') is_python3 = sys.version_info[0] > 2 if is_python3 == for_python3: for path in handle_package(package[1:]): yield path - if package[0] == "packages.txt": + if package[0] == 'packages.txt': assert len(package) == 2 for p in search_path(mozilla_dir, package[1]): yield os.path.join(mozilla_dir, p) - if package[0].endswith(".pth"): + if package[0].endswith('.pth'): assert len(package) == 2 yield os.path.join(mozilla_dir, package[1]) @@ -186,8 +186,8 @@ def bootstrap(topsrcdir, mozilla_dir=None): # on module import. major, minor = sys.version_info[:2] if (major == 2 and minor < 7) or (major == 3 and minor < 5): - print("Python 2.7 or Python 3.5+ is required to run mach.") - print("You are running Python", platform.python_version()) + print('Python 2.7 or Python 3.5+ is required to run mach.') + print('You are running Python', platform.python_version()) sys.exit(1) # Global build system and mach state is stored in a central directory. By @@ -200,8 +200,8 @@ def bootstrap(topsrcdir, mozilla_dir=None): # like surprises. sys.path[0:0] = [ os.path.join(mozilla_dir, path) - for path in search_path(mozilla_dir, "build/mach_virtualenv_packages.txt") - ] + for path in search_path(mozilla_dir, + 'build/mach_virtualenv_packages.txt')] import mach.base import mach.main from mach.util import setenv @@ -227,13 +227,12 @@ def bootstrap(topsrcdir, mozilla_dir=None): # This code mimics the code in taskcluster/scripts/run-task. try: import resource - # Keep the hard limit the same, though, allowing processes to change # their soft limit if they need to (Firefox does, for instance). (soft, hard) = resource.getrlimit(resource.RLIMIT_NOFILE) # Permit people to override our default limit if necessary via # MOZ_LIMIT_NOFILE, which is the same variable `run-task` uses. - limit = os.environ.get("MOZ_LIMIT_NOFILE") + limit = os.environ.get('MOZ_LIMIT_NOFILE') if limit: limit = int(limit) else: @@ -249,7 +248,6 @@ def bootstrap(topsrcdir, mozilla_dir=None): pass from mozbuild.util import patch_main - patch_main() def resolve_repository(): @@ -260,7 +258,8 @@ def bootstrap(topsrcdir, mozilla_dir=None): # If we ever need to use the VCS binary here, consider something # more robust. return mozversioncontrol.get_repository_object(path=mozilla_dir) - except (mozversioncontrol.InvalidRepoPath, mozversioncontrol.MissingVCSTool): + except (mozversioncontrol.InvalidRepoPath, + mozversioncontrol.MissingVCSTool): return None def pre_dispatch_handler(context, handler, args): @@ -268,30 +267,25 @@ def bootstrap(topsrcdir, mozilla_dir=None): # the build, tests will be disabled. Instead of trying to run # nonexistent tests then reporting a failure, this will prevent mach # from progressing beyond this point. - if handler.category == "testing" and not handler.ok_if_tests_disabled: + if handler.category == 'testing' and not handler.ok_if_tests_disabled: from mozbuild.base import BuildEnvironmentNotFoundException - try: from mozbuild.base import MozbuildObject - # all environments should have an instance of build object. build = MozbuildObject.from_environment() - if build is not None and hasattr(build, "mozconfig"): - ac_options = build.mozconfig["configure_args"] - if ac_options and "--disable-tests" in ac_options: - print( - "Tests have been disabled by mozconfig with the flag " - + '"ac_add_options --disable-tests".\n' - + "Remove the flag, and re-compile to enable tests." - ) + if build is not None and hasattr(build, 'mozconfig'): + ac_options = build.mozconfig['configure_args'] + if ac_options and '--disable-tests' in ac_options: + print('Tests have been disabled by mozconfig with the flag ' + + '"ac_add_options --disable-tests".\n' + + 'Remove the flag, and re-compile to enable tests.') sys.exit(1) except BuildEnvironmentNotFoundException: # likely automation environment, so do nothing. pass - def post_dispatch_handler( - context, handler, instance, success, start_time, end_time, depth, args - ): + def post_dispatch_handler(context, handler, instance, success, + start_time, end_time, depth, args): """Perform global operations after command dispatch. @@ -303,60 +297,56 @@ def bootstrap(topsrcdir, mozilla_dir=None): if depth != 1: return - _finalize_telemetry_glean( - context.telemetry, handler.name == "bootstrap", success - ) - _finalize_telemetry_legacy( - context, instance, handler, success, start_time, end_time, topsrcdir - ) + _finalize_telemetry_glean(context.telemetry, handler.name == 'bootstrap', + success) + _finalize_telemetry_legacy(context, instance, handler, success, start_time, + end_time, topsrcdir) def populate_context(key=None): if key is None: return - if key == "state_dir": + if key == 'state_dir': state_dir = get_state_dir() - if state_dir == os.environ.get("MOZBUILD_STATE_PATH"): + if state_dir == os.environ.get('MOZBUILD_STATE_PATH'): if not os.path.exists(state_dir): - print( - "Creating global state directory from environment variable: %s" - % state_dir - ) + print('Creating global state directory from environment variable: %s' + % state_dir) os.makedirs(state_dir, mode=0o770) else: if not os.path.exists(state_dir): - if not os.environ.get("MOZ_AUTOMATION"): + if not os.environ.get('MOZ_AUTOMATION'): print(STATE_DIR_FIRST_RUN.format(userdir=state_dir)) try: sys.stdin.readline() except KeyboardInterrupt: sys.exit(1) - print("\nCreating default state directory: %s" % state_dir) + print('\nCreating default state directory: %s' % state_dir) os.makedirs(state_dir, mode=0o770) return state_dir - if key == "local_state_dir": + if key == 'local_state_dir': return get_state_dir(srcdir=True) - if key == "topdir": + if key == 'topdir': return topsrcdir - if key == "pre_dispatch_handler": + if key == 'pre_dispatch_handler': return pre_dispatch_handler - if key == "post_dispatch_handler": + if key == 'post_dispatch_handler': return post_dispatch_handler - if key == "repository": + if key == 'repository': return resolve_repository() raise AttributeError(key) # Note which process is top-level so that recursive mach invocations can avoid writing # telemetry data. - if "MACH_MAIN_PID" not in os.environ: - setenv("MACH_MAIN_PID", str(os.getpid())) + if 'MACH_MAIN_PID' not in os.environ: + setenv('MACH_MAIN_PID', str(os.getpid())) driver = mach.main.Mach(os.getcwd()) driver.populate_context_handler = populate_context @@ -368,7 +358,8 @@ def bootstrap(topsrcdir, mozilla_dir=None): driver.settings_paths.append(mozilla_dir) for category, meta in CATEGORIES.items(): - driver.define_category(category, meta["short"], meta["long"], meta["priority"]) + driver.define_category(category, meta['short'], meta['long'], + meta['priority']) repo = resolve_repository() @@ -384,9 +375,8 @@ def bootstrap(topsrcdir, mozilla_dir=None): return driver -def _finalize_telemetry_legacy( - context, instance, handler, success, start_time, end_time, topsrcdir -): +def _finalize_telemetry_legacy(context, instance, handler, success, start_time, + end_time, topsrcdir): """Record and submit legacy telemetry. Parameterized by the raw gathered telemetry, this function handles persisting and @@ -398,80 +388,66 @@ def _finalize_telemetry_legacy( from mozboot.util import get_state_dir from mozbuild.base import MozbuildObject from mozbuild.telemetry import gather_telemetry - from mach.telemetry import is_telemetry_enabled, is_applicable_telemetry_environment + from mach.telemetry import ( + is_telemetry_enabled, + is_applicable_telemetry_environment + ) - if not ( - is_applicable_telemetry_environment() and is_telemetry_enabled(context.settings) - ): + if not (is_applicable_telemetry_environment() + and is_telemetry_enabled(context.settings)): return if not isinstance(instance, MozbuildObject): instance = MozbuildObject.from_environment() - command_attrs = getattr(context, "command_attrs", {}) + command_attrs = getattr(context, 'command_attrs', {}) # We gather telemetry for every operation. - data = gather_telemetry( - command=handler.name, - success=success, - start_time=start_time, - end_time=end_time, - mach_context=context, - instance=instance, - command_attrs=command_attrs, - ) + data = gather_telemetry(command=handler.name, success=success, + start_time=start_time, end_time=end_time, + mach_context=context, instance=instance, + command_attrs=command_attrs) if data: - telemetry_dir = os.path.join(get_state_dir(), "telemetry") + telemetry_dir = os.path.join(get_state_dir(), 'telemetry') try: os.mkdir(telemetry_dir) except OSError as e: if e.errno != errno.EEXIST: raise - outgoing_dir = os.path.join(telemetry_dir, "outgoing") + outgoing_dir = os.path.join(telemetry_dir, 'outgoing') try: os.mkdir(outgoing_dir) except OSError as e: if e.errno != errno.EEXIST: raise - with open(os.path.join(outgoing_dir, str(uuid.uuid4()) + ".json"), "w") as f: + with open(os.path.join(outgoing_dir, str(uuid.uuid4()) + '.json'), + 'w') as f: json.dump(data, f, sort_keys=True) # The user is performing a maintenance command, skip the upload - if handler.name in ( - "bootstrap", - "doctor", - "mach-commands", - "vcs-setup", - "create-mach-environment", - "install-moz-phab", - # We call mach environment in client.mk which would cause the - # data submission to block the forward progress of make. - "environment", - ): + if handler.name in ('bootstrap', 'doctor', 'mach-commands', 'vcs-setup', + 'create-mach-environment', 'install-moz-phab', + # We call mach environment in client.mk which would cause the + # data submission to block the forward progress of make. + 'environment'): return False - if "TEST_MACH_TELEMETRY_NO_SUBMIT" in os.environ: + if 'TEST_MACH_TELEMETRY_NO_SUBMIT' in os.environ: # In our telemetry tests, we want telemetry to be collected for analysis, but # we don't want it submitted. return False state_dir = get_state_dir() - machpath = os.path.join(instance.topsrcdir, "mach") - with open(os.devnull, "wb") as devnull: - subprocess.Popen( - [ - sys.executable, - machpath, - "python", - "--no-virtualenv", - os.path.join(topsrcdir, "build", "submit_telemetry_data.py"), - state_dir, - ], - stdout=devnull, - stderr=devnull, - ) + machpath = os.path.join(instance.topsrcdir, 'mach') + with open(os.devnull, 'wb') as devnull: + subprocess.Popen([sys.executable, machpath, 'python', + '--no-virtualenv', + os.path.join(topsrcdir, 'build', + 'submit_telemetry_data.py'), + state_dir], + stdout=devnull, stderr=devnull) def _finalize_telemetry_glean(telemetry, is_bootstrap, success): @@ -496,9 +472,8 @@ def _finalize_telemetry_glean(telemetry, is_bootstrap, success): system_metrics.logical_cores.add(logical_cores) system_metrics.physical_cores.add(physical_cores) if memory_total is not None: - system_metrics.memory.accumulate( - int(math.ceil(float(memory_total) / (1024 * 1024 * 1024))) - ) + system_metrics.memory.accumulate(int( + math.ceil(float(memory_total) / (1024 * 1024 * 1024)))) telemetry.submit(is_bootstrap) @@ -512,15 +487,12 @@ class ImportHook(object): self._original_import = original_import # Assume the source directory is the parent directory of the one # containing this file. - self._source_dir = ( - os.path.normcase( - os.path.abspath(os.path.dirname(os.path.dirname(__file__))) - ) - + os.sep - ) + self._source_dir = os.path.normcase(os.path.abspath( + os.path.dirname(os.path.dirname(__file__)))) + os.sep self._modules = set() - def __call__(self, name, globals=None, locals=None, fromlist=None, level=-1): + def __call__(self, name, globals=None, locals=None, fromlist=None, + level=-1): if sys.version_info[0] >= 3 and level < 0: level = 0 @@ -541,14 +513,14 @@ class ImportHook(object): self._modules.add(resolved_name) # Builtin modules don't have a __file__ attribute. - if not getattr(module, "__file__", None): + if not getattr(module, '__file__', None): return module # Note: module.__file__ is not always absolute. path = os.path.normcase(os.path.abspath(module.__file__)) # Note: we could avoid normcase and abspath above for non pyc/pyo # files, but those are actually rare, so it doesn't really matter. - if not path.endswith((".pyc", ".pyo")): + if not path.endswith(('.pyc', '.pyo')): return module # Ignore modules outside our source directory diff --git a/build/midl.py b/build/midl.py index add17006d61c1921e5c3eff516f7af5b4046dba3..3f2a08c4f9db7e82659dcb8ee15ddf55f5ab4406 100644 --- a/build/midl.py +++ b/build/midl.py @@ -12,11 +12,11 @@ def relativize(path, base=None): # For absolute path in Unix builds, we need relative paths because # Windows programs run via Wine don't like these Unix absolute paths # (they look like command line arguments). - if path.startswith("/"): + if path.startswith('/'): return os.path.relpath(path, base) # For Windows absolute paths, we can just use the unmodified path. # And if the path starts with '-', it's a command line argument. - if os.path.isabs(path) or path.startswith("-"): + if os.path.isabs(path) or path.startswith('-'): return path # Remaining case is relative paths, which may be relative to a different # directory (os.getcwd()) than the needed `base`, so we "rebase" it. @@ -25,18 +25,18 @@ def relativize(path, base=None): def midl(out, input, *flags): out.avoid_writing_to_file() - midl = buildconfig.substs["MIDL"] - wine = buildconfig.substs.get("WINE") - base = os.path.dirname(out.name) or "." - if midl.lower().endswith(".exe") and wine: + midl = buildconfig.substs['MIDL'] + wine = buildconfig.substs.get('WINE') + base = os.path.dirname(out.name) or '.' + if midl.lower().endswith('.exe') and wine: command = [wine, midl] else: command = [midl] - command.extend(buildconfig.substs["MIDL_FLAGS"]) + command.extend(buildconfig.substs['MIDL_FLAGS']) command.extend([relativize(f, base) for f in flags]) - command.append("-Oicf") + command.append('-Oicf') command.append(relativize(input, base)) - print("Executing:", " ".join(command)) + print('Executing:', ' '.join(command)) result = subprocess.run(command, cwd=base) return result.returncode @@ -49,9 +49,7 @@ def merge_dlldata(out, *inputs): inputs = [open(i) for i in inputs] read_a_line = [True] * len(inputs) while True: - lines = [ - f.readline() if read_a_line[n] else lines[n] for n, f in enumerate(inputs) - ] + lines = [f.readline() if read_a_line[n] else lines[n] for n, f in enumerate(inputs)] unique_lines = set(lines) if len(unique_lines) == 1: # All the lines are identical @@ -59,10 +57,7 @@ def merge_dlldata(out, *inputs): break out.write(lines[0]) read_a_line = [True] * len(inputs) - elif ( - len(unique_lines) == 2 - and len([l for l in unique_lines if "#define" in l]) == 1 - ): + elif len(unique_lines) == 2 and len([l for l in unique_lines if '#define' in l]) == 1: # Most lines are identical. When they aren't, it's typically because some # files have an extra #define that others don't. When that happens, we # print out the #define, and get a new input line from the files that had @@ -72,18 +67,16 @@ def merge_dlldata(out, *inputs): # defines across different files, except when there's a different one # for each file, in which case it's handled further below. a = unique_lines.pop() - if "#define" in a: + if '#define' in a: out.write(a) else: out.write(unique_lines.pop()) - read_a_line = ["#define" in l for l in lines] + read_a_line = ['#define' in l for l in lines] elif len(unique_lines) != len(lines): # If for some reason, we don't get lines that are entirely different # from each other, we have some unexpected input. - print( - "Error while merging dlldata. Last lines read: {}".format(lines), - file=sys.stderr, - ) + print('Error while merging dlldata. Last lines read: {}'.format(lines), + file=sys.stderr) return 1 else: for line in lines: diff --git a/build/mobile/remoteautomation.py b/build/mobile/remoteautomation.py index 60d8d952fa1fbbe078e990d638b3d96dd3dbadaa..8d98f9ba2522fc2b94f8cec7da11edaeb018af93 100644 --- a/build/mobile/remoteautomation.py +++ b/build/mobile/remoteautomation.py @@ -35,17 +35,15 @@ _log = logging.getLogger() resetGlobalLog(sys.stdout) # signatures for logcat messages that we don't care about much -fennecLogcatFilters = [ - "The character encoding of the HTML document was not declared", - "Use of Mutation Events is deprecated. Use MutationObserver instead.", - "Unexpected value from nativeGetEnabledTags: 0", -] +fennecLogcatFilters = ["The character encoding of the HTML document was not declared", + "Use of Mutation Events is deprecated. Use MutationObserver instead.", + "Unexpected value from nativeGetEnabledTags: 0"] class RemoteAutomation(object): - def __init__( - self, device, appName="", remoteProfile=None, remoteLog=None, processArgs=None - ): + + def __init__(self, device, appName='', remoteProfile=None, remoteLog=None, + processArgs=None): super(RemoteAutomation, self).__init__() self.device = device self.appName = appName @@ -55,22 +53,9 @@ class RemoteAutomation(object): self.lastTestSeen = "remoteautomation.py" self.log = _log - def runApp( - self, - testURL, - env, - app, - profileDir, - extraArgs, - utilityPath=None, - xrePath=None, - debuggerInfo=None, - symbolsPath=None, - timeout=-1, - maxTime=None, - e10s=True, - **kwargs - ): + def runApp(self, testURL, env, app, profileDir, extraArgs, + utilityPath=None, xrePath=None, debuggerInfo=None, symbolsPath=None, + timeout=-1, maxTime=None, e10s=True, **kwargs): """ Run the app, log the duration it took to execute, return the status code. Kills the app if it runs for longer than |maxTime| seconds, or outputs nothing @@ -84,26 +69,19 @@ class RemoteAutomation(object): timeout = self.DEFAULT_TIMEOUT self.utilityPath = utilityPath - cmd, args = self.buildCommandLine( - app, debuggerInfo, profileDir, testURL, extraArgs - ) + cmd, args = self.buildCommandLine(app, debuggerInfo, profileDir, testURL, extraArgs) startTime = datetime.datetime.now() self.lastTestSeen = "remoteautomation.py" - self.launchApp( - [cmd] + args, - env=self.environment(env=env, crashreporter=not debuggerInfo), - e10s=e10s, - **self.processArgs - ) + self.launchApp([cmd] + args, + env=self.environment(env=env, crashreporter=not debuggerInfo), + e10s=e10s, **self.processArgs) self.log.info("remoteautomation.py | Application pid: %d" % self.pid) status = self.waitForFinish(timeout, maxTime) - self.log.info( - "remoteautomation.py | Application ran for: %s" - % str(datetime.datetime.now() - startTime) - ) + self.log.info("remoteautomation.py | Application ran for: %s" % + str(datetime.datetime.now() - startTime)) crashed = self.checkForCrashes(symbolsPath) if crashed: @@ -119,36 +97,36 @@ class RemoteAutomation(object): env = {} if crashreporter: - env["MOZ_CRASHREPORTER_NO_REPORT"] = "1" - env["MOZ_CRASHREPORTER"] = "1" - env["MOZ_CRASHREPORTER_SHUTDOWN"] = "1" + env['MOZ_CRASHREPORTER_NO_REPORT'] = '1' + env['MOZ_CRASHREPORTER'] = '1' + env['MOZ_CRASHREPORTER_SHUTDOWN'] = '1' else: - env["MOZ_CRASHREPORTER_DISABLE"] = "1" + env['MOZ_CRASHREPORTER_DISABLE'] = '1' # Crash on non-local network connections by default. # MOZ_DISABLE_NONLOCAL_CONNECTIONS can be set to "0" to temporarily # enable non-local connections for the purposes of local testing. # Don't override the user's choice here. See bug 1049688. - env.setdefault("MOZ_DISABLE_NONLOCAL_CONNECTIONS", "1") + env.setdefault('MOZ_DISABLE_NONLOCAL_CONNECTIONS', '1') # Send an env var noting that we are in automation. Passing any # value except the empty string will declare the value to exist. # # This may be used to disabled network connections during testing, e.g. # Switchboard & telemetry uploads. - env.setdefault("MOZ_IN_AUTOMATION", "1") + env.setdefault('MOZ_IN_AUTOMATION', '1') # Set WebRTC logging in case it is not set yet. - env.setdefault("R_LOG_LEVEL", "6") - env.setdefault("R_LOG_DESTINATION", "stderr") - env.setdefault("R_LOG_VERBOSE", "1") + env.setdefault('R_LOG_LEVEL', '6') + env.setdefault('R_LOG_DESTINATION', 'stderr') + env.setdefault('R_LOG_VERBOSE', '1') return env def waitForFinish(self, timeout, maxTime): - """Wait for tests to finish. - If maxTime seconds elapse or no output is detected for timeout - seconds, kill the process and fail the test. + """ Wait for tests to finish. + If maxTime seconds elapse or no output is detected for timeout + seconds, kill the process and fail the test. """ # maxTime is used to override the default timeout, we should honor that status = self.wait(timeout=maxTime, noOutputTimeout=timeout) @@ -159,44 +137,38 @@ class RemoteAutomation(object): self.kill(True) if status == 1: if maxTime: - self.log.error( - "TEST-UNEXPECTED-FAIL | %s | " - "application ran for longer than allowed maximum time " - "of %s seconds" % (self.lastTestSeen, maxTime) - ) + self.log.error("TEST-UNEXPECTED-FAIL | %s | " + "application ran for longer than allowed maximum time " + "of %s seconds" % (self.lastTestSeen, maxTime)) else: - self.log.error( - "TEST-UNEXPECTED-FAIL | %s | " - "application ran for longer than allowed maximum time" - % self.lastTestSeen - ) + self.log.error("TEST-UNEXPECTED-FAIL | %s | " + "application ran for longer than allowed maximum time" + % self.lastTestSeen) if status == 2: - self.log.error( - "TEST-UNEXPECTED-FAIL | %s | " - "application timed out after %d seconds with no output" - % (self.lastTestSeen, int(timeout)) - ) + self.log.error("TEST-UNEXPECTED-FAIL | %s | " + "application timed out after %d seconds with no output" + % (self.lastTestSeen, int(timeout))) return status def checkForCrashes(self, symbolsPath): try: dumpDir = tempfile.mkdtemp() - remoteCrashDir = posixpath.join(self.remoteProfile, "minidumps") + remoteCrashDir = posixpath.join(self.remoteProfile, 'minidumps') if not self.device.is_dir(remoteCrashDir): return False self.device.pull(remoteCrashDir, dumpDir) logger = get_default_logger() crashed = mozcrash.log_crashes( - logger, dumpDir, symbolsPath, test=self.lastTestSeen - ) + logger, dumpDir, symbolsPath, test=self.lastTestSeen) finally: try: shutil.rmtree(dumpDir) except Exception as e: - print("WARNING: unable to remove directory %s: %s" % (dumpDir, str(e))) + print("WARNING: unable to remove directory %s: %s" % ( + dumpDir, str(e))) return crashed def buildCommandLine(self, app, debuggerInfo, profileDir, testURL, extraArgs): @@ -206,7 +178,7 @@ class RemoteAutomation(object): # Hack for robocop, if app is "am" and extraArgs contains the rest of the stuff, lets # assume extraArgs is all we need - if app == "am" and extraArgs[0] in ("instrument", "start"): + if app == "am" and extraArgs[0] in ('instrument', 'start'): return app, extraArgs cmd = os.path.abspath(app) @@ -226,7 +198,7 @@ class RemoteAutomation(object): args.extend(extraArgs) try: - args.remove("-foreground") + args.remove('-foreground') except Exception: pass return app, args @@ -236,19 +208,17 @@ class RemoteAutomation(object): self.stdoutlen = 0 if self.appName and self.device.process_exist(self.appName): - print( - "remoteautomation.py %s is already running. Stopping..." % self.appName - ) + print("remoteautomation.py %s is already running. Stopping..." % self.appName) self.device.stop_application(self.appName) self.counts = counts if self.counts is not None: - self.counts["pass"] = 0 - self.counts["fail"] = 0 - self.counts["todo"] = 0 + self.counts['pass'] = 0 + self.counts['fail'] = 0 + self.counts['todo'] = 0 - if cmd[0] == "am": - cmd = " ".join(cmd) + if cmd[0] == 'am': + cmd = ' '.join(cmd) self.procName = self.appName if not self.device.shell_bool(cmd): print("remoteautomation.py failed to launch %s" % cmd) @@ -258,25 +228,17 @@ class RemoteAutomation(object): if args[0] == self.appName: args = args[1:] url = args[-1:][0] - if url.startswith("/"): + if url.startswith('/'): # this is probably a reftest profile directory, not a url url = None else: args = args[:-1] - if "geckoview" in self.appName: + if 'geckoview' in self.appName: activity = "TestRunnerActivity" - self.device.launch_activity( - self.appName, - activity_name=activity, - e10s=e10s, - moz_env=env, - extra_args=args, - url=url, - ) + self.device.launch_activity(self.appName, activity_name=activity, e10s=e10s, + moz_env=env, extra_args=args, url=url) else: - self.device.launch_fennec( - self.appName, moz_env=env, extra_args=args, url=url - ) + self.device.launch_fennec(self.appName, moz_env=env, extra_args=args, url=url) # Setting timeout at 1 hour since on a remote device this takes much longer. # Temporarily increased to 110 minutes because no more chunks can be created. @@ -306,15 +268,13 @@ class RemoteAutomation(object): except ADBTimeoutError: raise except Exception as e: - self.log.exception( - "remoteautomation.py | exception reading log: %s" % str(e) - ) + self.log.exception("remoteautomation.py | exception reading log: %s" % str(e)) return False if not newLogContent: return False self.stdoutlen += len(newLogContent) - newLogContent = six.ensure_str(newLogContent, errors="replace") + newLogContent = six.ensure_str(newLogContent, errors='replace') if self.messageLogger is None: testStartFilenames = re.findall(r"TEST-START \| ([^\s]*)", newLogContent) @@ -324,11 +284,11 @@ class RemoteAutomation(object): return True self.logBuffer += newLogContent - lines = self.logBuffer.split("\n") + lines = self.logBuffer.split('\n') lines = [l for l in lines if l] if lines: - if self.logBuffer.endswith("\n"): + if self.logBuffer.endswith('\n'): # all lines are complete; no need to buffer self.logBuffer = "" else: @@ -343,35 +303,33 @@ class RemoteAutomation(object): # This passes the line to the logger (to be logged or buffered) if isinstance(line, six.text_type): # if line is unicode - let's encode it to bytes - parsed_messages = self.messageLogger.write( - line.encode("UTF-8", "replace") - ) + parsed_messages = self.messageLogger.write(line.encode('UTF-8', 'replace')) else: # if line is bytes type, write it as it is parsed_messages = self.messageLogger.write(line) for message in parsed_messages: if isinstance(message, dict): - if message.get("action") == "test_start": - self.lastTestSeen = message["test"] - elif message.get("action") == "test_end": - self.lastTestSeen = "{} (finished)".format(message["test"]) - elif message.get("action") == "suite_end": + if message.get('action') == 'test_start': + self.lastTestSeen = message['test'] + elif message.get('action') == 'test_end': + self.lastTestSeen = '{} (finished)'.format(message['test']) + elif message.get('action') == 'suite_end': self.lastTestSeen = "Last test finished" - elif message.get("action") == "log": - line = message["message"].strip() + elif message.get('action') == 'log': + line = message['message'].strip() if self.counts: m = re.match(".*:\s*(\d*)", line) if m: try: val = int(m.group(1)) if "Passed:" in line: - self.counts["pass"] += val + self.counts['pass'] += val self.lastTestSeen = "Last test finished" elif "Failed:" in line: - self.counts["fail"] += val + self.counts['fail'] += val elif "Todo:" in line: - self.counts["todo"] += val + self.counts['todo'] += val except ADBTimeoutError: raise except Exception: @@ -412,13 +370,11 @@ class RemoteAutomation(object): if (not slowLog) or (timer % 60 == 0): startRead = datetime.datetime.now() hasOutput = self.read_stdout() - if (datetime.datetime.now() - startRead) > datetime.timedelta( - seconds=5 - ): + if (datetime.datetime.now() - startRead) > datetime.timedelta(seconds=5): slowLog = True if hasOutput: noOutputTimer = 0 - if self.counts and "pass" in self.counts and self.counts["pass"] > 0: + if self.counts and 'pass' in self.counts and self.counts['pass'] > 0: interval = 0.5 time.sleep(interval) timer += interval @@ -426,7 +382,7 @@ class RemoteAutomation(object): if datetime.datetime.now() > endTime: status = 1 break - if noOutputTimeout and noOutputTimer > noOutputTimeout: + if (noOutputTimeout and noOutputTimer > noOutputTimeout): status = 2 break if not hasOutput: @@ -446,7 +402,7 @@ class RemoteAutomation(object): # they rarely work well with Firefox on the Android # emulator. dump_screen provides an effective # screenshot of the emulator and its host desktop. - if not self.device._device_serial.startswith("emulator-"): + if not self.device._device_serial.startswith('emulator-'): dump_device_screen(self.device, get_default_logger()) elif self.utilityPath: dump_screen(self.utilityPath, get_default_logger()) @@ -503,5 +459,5 @@ class RemoteAutomation(object): @staticmethod def elf_arm(filename): - data = open(filename, "rb").read(20) + data = open(filename, 'rb').read(20) return data[:4] == "\x7fELF" and ord(data[18]) == 40 # EM_ARM diff --git a/build/moz.build b/build/moz.build index 3d7aed0d56517c79e6c51147f84a1658cd65acc5..43b253722752879aec0c9eb0e2058b55a8075b69 100644 --- a/build/moz.build +++ b/build/moz.build @@ -4,126 +4,114 @@ # 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/. -with Files("**"): - BUG_COMPONENT = ("Firefox Build System", "General") +with Files('**'): + BUG_COMPONENT = ('Firefox Build System', 'General') # This cannot be named "build" because of bug 922191. -SPHINX_TREES["buildsystem"] = "docs" +SPHINX_TREES['buildsystem'] = 'docs' -with Files("docs/**"): - SCHEDULES.exclusive = ["docs"] +with Files('docs/**'): + SCHEDULES.exclusive = ['docs'] -if CONFIG["OS_ARCH"] == "WINNT": - DIRS += ["win32"] +if CONFIG['OS_ARCH'] == 'WINNT': + DIRS += ['win32'] else: - DIRS += ["unix"] + DIRS += ['unix'] CRAMTEST_MANIFESTS += [ - "tests/cram/cram.ini", + 'tests/cram/cram.ini', ] -DEFINES["ACCEPTED_MAR_CHANNEL_IDS"] = CONFIG["ACCEPTED_MAR_CHANNEL_IDS"] +DEFINES['ACCEPTED_MAR_CHANNEL_IDS'] = CONFIG['ACCEPTED_MAR_CHANNEL_IDS'] -if CONFIG["MOZ_BUILD_APP"] == "browser": +if CONFIG['MOZ_BUILD_APP'] == 'browser': PYTHON_UNITTEST_MANIFESTS += [ - "compare-mozconfig/python.ini", + 'compare-mozconfig/python.ini', ] -if CONFIG["ENABLE_TESTS"] or CONFIG["MOZ_DMD"]: - FINAL_TARGET_FILES += ["/tools/rb/fix_stacks.py"] +if CONFIG['ENABLE_TESTS'] or CONFIG['MOZ_DMD']: + FINAL_TARGET_FILES += ['/tools/rb/fix_stacks.py'] -if CONFIG["MOZ_DMD"]: - FINAL_TARGET_FILES += ["/memory/replace/dmd/dmd.py"] +if CONFIG['MOZ_DMD']: + FINAL_TARGET_FILES += ['/memory/replace/dmd/dmd.py'] # Put a useful .gdbinit and .gdbinit.py in $objdir/build, to be picked up # automatically by GDB via either libxul.so-gdb.py or js-gdb.py. -OBJDIR_PP_FILES.build += [".gdbinit.py.in"] -OBJDIR_FILES.build += [".gdbinit.loader"] -OBJDIR_FILES.build += [".gdbinit"] +OBJDIR_PP_FILES.build += ['.gdbinit.py.in'] +OBJDIR_FILES.build += ['.gdbinit.loader'] +OBJDIR_FILES.build += ['.gdbinit'] # Install the clang-cl runtime library for ASAN next to the binaries we produce. -if CONFIG["MOZ_ASAN"] and CONFIG["CC_TYPE"] == "clang-cl": - FINAL_TARGET_FILES += ["%" + CONFIG["MOZ_CLANG_RT_ASAN_LIB_PATH"]] - FINAL_TARGET_FILES += [ - "%" + CONFIG["MOZ_CLANG_RT_ASAN_LIB_PATH"].replace(".dll", ".pdb") - ] +if CONFIG['MOZ_ASAN'] and CONFIG['CC_TYPE'] == 'clang-cl': + FINAL_TARGET_FILES += ['%' + CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']] + FINAL_TARGET_FILES += ['%' + CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH'].replace(".dll", ".pdb")] # Install the clang runtime library for ASAN next to the binaries we produce. -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android" and CONFIG["MOZ_ASAN"]: - FINAL_TARGET_FILES += ["%" + CONFIG["MOZ_CLANG_RT_ASAN_LIB_PATH"]] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android' and CONFIG['MOZ_ASAN']: + FINAL_TARGET_FILES += ['%' + CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']] -if CONFIG["LLVM_SYMBOLIZER"]: - FINAL_TARGET_FILES += ["/" + CONFIG["LLVM_SYMBOLIZER"]] +if CONFIG['LLVM_SYMBOLIZER']: + FINAL_TARGET_FILES += ['/' + CONFIG['LLVM_SYMBOLIZER']] -if CONFIG["MOZ_APP_BASENAME"]: +if CONFIG['MOZ_APP_BASENAME']: appini_defines = { - "TOPOBJDIR": TOPOBJDIR, + 'TOPOBJDIR': TOPOBJDIR, } - for var in ( - "GRE_MILESTONE", - "MOZ_APP_VERSION", - "MOZ_APP_BASENAME", - "MOZ_APP_VENDOR", - "MOZ_APP_ID", - "MAR_CHANNEL_ID", - "MOZ_APP_REMOTINGNAME", - ): + for var in ('GRE_MILESTONE', 'MOZ_APP_VERSION', 'MOZ_APP_BASENAME', + 'MOZ_APP_VENDOR', 'MOZ_APP_ID', 'MAR_CHANNEL_ID', + 'MOZ_APP_REMOTINGNAME'): appini_defines[var] = CONFIG[var] - if CONFIG["MOZ_APP_DISPLAYNAME"] != CONFIG["MOZ_APP_BASENAME"]: - appini_defines["MOZ_APP_DISPLAYNAME"] = CONFIG["MOZ_APP_DISPLAYNAME"] + if CONFIG['MOZ_APP_DISPLAYNAME'] != CONFIG['MOZ_APP_BASENAME']: + appini_defines['MOZ_APP_DISPLAYNAME'] = CONFIG['MOZ_APP_DISPLAYNAME'] - if CONFIG["MOZ_BUILD_APP"] == "browser": - appini_defines["MOZ_BUILD_APP_IS_BROWSER"] = True + if CONFIG['MOZ_BUILD_APP'] == 'browser': + appini_defines['MOZ_BUILD_APP_IS_BROWSER'] = True - if CONFIG["MOZ_APP_PROFILE"]: - appini_defines["MOZ_APP_PROFILE"] = CONFIG["MOZ_APP_PROFILE"] + if CONFIG['MOZ_APP_PROFILE']: + appini_defines['MOZ_APP_PROFILE'] = CONFIG['MOZ_APP_PROFILE'] - for var in ("MOZ_CRASHREPORTER", "MOZ_PROFILE_MIGRATOR", "MOZ_UPDATER"): + for var in ('MOZ_CRASHREPORTER', 'MOZ_PROFILE_MIGRATOR', 'MOZ_UPDATER'): if CONFIG[var]: appini_defines[var] = True - appini_defines["MOZ_APPUPDATE_HOST"] = "aus5.mozilla.org" - if CONFIG["MOZ_APPUPDATE_HOST"]: - appini_defines["MOZ_APPUPDATE_HOST"] = CONFIG["MOZ_APPUPDATE_HOST"] + appini_defines['MOZ_APPUPDATE_HOST'] = 'aus5.mozilla.org' + if CONFIG['MOZ_APPUPDATE_HOST']: + appini_defines['MOZ_APPUPDATE_HOST'] = CONFIG['MOZ_APPUPDATE_HOST'] GeneratedFile( - "application.ini", - script="../python/mozbuild/mozbuild/action/preprocessor.py", - entry_point="generate", - inputs=["application.ini.in"], - flags=[ - "-D%s=%s" % (k, "1" if v is True else v) - for k, v in sorted(appini_defines.items(), key=lambda t: t[0]) - ], - ) - - FINAL_TARGET_FILES += ["!application.ini"] - if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android" and CONFIG["MOZ_UPDATER"]: - FINAL_TARGET_PP_FILES += ["update-settings.ini"] + 'application.ini', + script='../python/mozbuild/mozbuild/action/preprocessor.py', + entry_point='generate', + inputs=['application.ini.in'], + flags=['-D%s=%s' % (k, '1' if v is True else v) + for k, v in sorted(appini_defines.items(), key=lambda t: t[0])]) - GeneratedFile( - "application.ini.h", script="appini_header.py", inputs=["!application.ini"] - ) + FINAL_TARGET_FILES += ['!application.ini'] + if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android' and CONFIG['MOZ_UPDATER']: + FINAL_TARGET_PP_FILES += ['update-settings.ini'] + + GeneratedFile('application.ini.h', script='appini_header.py', + inputs=['!application.ini']) # Put a .lldbinit in the bin directory and the objdir, to be picked up # automatically by LLDB when we debug executables using either of those two # directories as the current working directory. The .lldbinit file will # load $(topsrcdir)/.lldbinit, which is where the actual debugging commands are. -DEFINES["topsrcdir"] = TOPSRCDIR -DEFINES["topobjdir"] = TOPOBJDIR -FINAL_TARGET_PP_FILES += [".lldbinit.in"] -OBJDIR_FILES += ["!/dist/bin/.lldbinit"] +DEFINES['topsrcdir'] = TOPSRCDIR +DEFINES['topobjdir'] = TOPOBJDIR +FINAL_TARGET_PP_FILES += ['.lldbinit.in'] +OBJDIR_FILES += ['!/dist/bin/.lldbinit'] # Put the .ycm_extra_conf.py file at the root of the objdir. It is used by # the vim plugin YouCompleteMe. -OBJDIR_FILES += ["/.ycm_extra_conf.py"] +OBJDIR_FILES += ['/.ycm_extra_conf.py'] -if CONFIG["MOZ_VALGRIND"]: +if CONFIG['MOZ_VALGRIND']: OBJDIR_FILES._valgrind += [ - "valgrind/cross-architecture.sup", - "valgrind/i386-pc-linux-gnu.sup", - "valgrind/x86_64-pc-linux-gnu.sup", + 'valgrind/cross-architecture.sup', + 'valgrind/i386-pc-linux-gnu.sup', + 'valgrind/x86_64-pc-linux-gnu.sup', ] diff --git a/build/moz.configure/android-ndk.configure b/build/moz.configure/android-ndk.configure index b6d198b149e34c07f857c7cfbdf790e11263f45f..dd12b53573369451aa15eead8e79b1d45027f3ac 100644 --- a/build/moz.configure/android-ndk.configure +++ b/build/moz.configure/android-ndk.configure @@ -5,95 +5,85 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. -@depends(mozbuild_state_path, "--help") -@imports(_from="os.path", _import="isdir") -@imports(_from="mozboot.android", _import="NDK_VERSION") +@depends(mozbuild_state_path, '--help') +@imports(_from='os.path', _import='isdir') +@imports(_from='mozboot.android', _import='NDK_VERSION') def default_android_ndk_root(mozbuild_state_path, _): - path = os.path.join(mozbuild_state_path, "android-ndk-%s" % NDK_VERSION) + path = os.path.join(mozbuild_state_path, 'android-ndk-%s' % NDK_VERSION) if isdir(path): return path -option( - "--with-android-ndk", - nargs=1, - default=default_android_ndk_root, - help="location where the Android NDK can be found{|}", -) +option('--with-android-ndk', nargs=1, + default=default_android_ndk_root, + help='location where the Android NDK can be found{|}') -option("--with-android-toolchain", nargs=1, help="location of the Android toolchain") +option('--with-android-toolchain', nargs=1, + help='location of the Android toolchain') -option( - "--with-android-googlevr-sdk", nargs=1, help="location of the Android GoogleVR SDK" -) +option('--with-android-googlevr-sdk', nargs=1, + help='location of the Android GoogleVR SDK') @depends(target) def min_android_version(target): - if target.cpu in ["aarch64", "x86_64"]: + if target.cpu in ['aarch64', 'x86_64']: # 64-bit support was added in API 21. - return "21" - return "16" + return '21' + return '16' -option( - "--with-android-version", - nargs=1, - help="android platform version{|}", - default=min_android_version, -) +option('--with-android-version', + nargs=1, + help='android platform version{|}', + default=min_android_version) -@depends("--with-android-version", min_android_version) -@imports(_from="__builtin__", _import="ValueError") +@depends('--with-android-version', min_android_version) +@imports(_from='__builtin__', _import='ValueError') def android_version(value, min_version): if not value: # Someone has passed --without-android-version. - die("--with-android-version cannot be disabled.") + die('--with-android-version cannot be disabled.') try: version = int(value[0]) except ValueError: - die("--with-android-version expects an integer value") + die('--with-android-version expects an integer value') if version < int(min_version): - die( - "--with-android-version must be at least %s (got %s)", min_version, value[0] - ) + die('--with-android-version must be at least %s (got %s)', + min_version, value[0]) return version -add_old_configure_assignment("android_version", android_version) +add_old_configure_assignment('android_version', android_version) -@depends("--with-android-ndk") -@imports(_from="os.path", _import="isdir") +@depends('--with-android-ndk') +@imports(_from='os.path', _import='isdir') def ndk(value): if value: if not isdir(value[0]): - die( - "The path you specified with --with-android-ndk (%s) is not " - "a directory" % value[0] - ) + die("The path you specified with --with-android-ndk (%s) is not " + "a directory" % value[0]) return value[0] - die( - "You must specify --with-android-ndk=/path/to/ndk when targeting Android, " - "or try |mach bootstrap|." - ) + die('You must specify --with-android-ndk=/path/to/ndk when targeting Android, ' + 'or try |mach bootstrap|.') -set_config("ANDROID_NDK", ndk) -add_old_configure_assignment("android_ndk", ndk) +set_config('ANDROID_NDK', ndk) +add_old_configure_assignment('android_ndk', ndk) @depends(ndk) -@checking("for android ndk version") -@imports(_from="__builtin__", _import="open") -@imports(_from="mozboot.android", _import="NDK_VERSION") -@imports(_from="mozboot.android", _import="get_ndk_version") -@imports(_from="mozboot.android", _import="GetNdkVersionError") +@checking('for android ndk version') +@imports(_from='__builtin__', _import='open') +@imports(_from='mozboot.android', _import='NDK_VERSION') +@imports(_from='mozboot.android', _import='get_ndk_version') +@imports(_from='mozboot.android', _import='GetNdkVersionError') def ndk_version(ndk): if not ndk: # Building 'js/src' for non-Android. @@ -105,30 +95,28 @@ def ndk_version(ndk): die(str(e)) if NDK_VERSION != human: - die( - "The only supported version of the NDK is %s (have %s)\n" - "Please run |mach bootstrap| " - "to install the correct NDK." % (NDK_VERSION, human) - ) + die('The only supported version of the NDK is %s (have %s)\n' + 'Please run |mach bootstrap| ' + 'to install the correct NDK.' % (NDK_VERSION, human)) return namespace( major=major, minor=minor, ) -set_config("ANDROID_NDK_MAJOR_VERSION", ndk_version.major) -set_config("ANDROID_NDK_MINOR_VERSION", ndk_version.minor) +set_config('ANDROID_NDK_MAJOR_VERSION', ndk_version.major) +set_config('ANDROID_NDK_MINOR_VERSION', ndk_version.minor) @depends(target, android_version, ndk) -@checking("for android platform directory") -@imports(_from="os.path", _import="isdir") +@checking('for android platform directory') +@imports(_from='os.path', _import='isdir') def android_platform(target, android_version, ndk): - if target.os != "Android": + if target.os != 'Android': return - if "aarch64" == target.cpu: - target_dir_name = "arm64" + if 'aarch64' == target.cpu: + target_dir_name = 'arm64' else: target_dir_name = target.cpu @@ -141,63 +129,60 @@ def android_platform(target, android_version, ndk): else: platform_version = android_version - platform_dir = os.path.join( - ndk, "platforms", "android-%s" % platform_version, "arch-%s" % target_dir_name - ) + platform_dir = os.path.join(ndk, + 'platforms', + 'android-%s' % platform_version, + 'arch-%s' % target_dir_name) if not isdir(platform_dir): - die( - "Android platform directory not found. With the current " - "configuration, it should be in %s" % platform_dir - ) + die("Android platform directory not found. With the current " + "configuration, it should be in %s" % platform_dir) return platform_dir -add_old_configure_assignment("android_platform", android_platform) -set_config("ANDROID_PLATFORM", android_platform) +add_old_configure_assignment('android_platform', android_platform) +set_config('ANDROID_PLATFORM', android_platform) @depends(android_platform, ndk, target) -@checking("for android sysroot directory") -@imports(_from="os.path", _import="isdir") +@checking('for android sysroot directory') +@imports(_from='os.path', _import='isdir') def android_sysroot(android_platform, ndk, target): - if target.os != "Android": + if target.os != 'Android': return # NDK r15 has both unified and non-unified headers, but we only support # non-unified for that NDK, so look for that first. search_dirs = [ # (, ) - (os.path.join(android_platform, "usr", "include"), android_platform), - (os.path.join(ndk, "sysroot"), os.path.join(ndk, "sysroot")), + (os.path.join(android_platform, 'usr', 'include'), android_platform), + (os.path.join(ndk, 'sysroot'), os.path.join(ndk, 'sysroot')), ] for test_dir, sysroot_dir in search_dirs: if isdir(test_dir): return sysroot_dir - die( - "Android sysroot directory not found in %s." - % str([sysroot_dir for test_dir, sysroot_dir in search_dirs]) - ) + die("Android sysroot directory not found in %s." % + str([sysroot_dir for test_dir, sysroot_dir in search_dirs])) -add_old_configure_assignment("android_sysroot", android_sysroot) +add_old_configure_assignment('android_sysroot', android_sysroot) @depends(android_platform, ndk, target) -@checking("for android system directory") -@imports(_from="os.path", _import="isdir") +@checking('for android system directory') +@imports(_from='os.path', _import='isdir') def android_system(android_platform, ndk, target): - if target.os != "Android": + if target.os != 'Android': return # NDK r15 has both unified and non-unified headers, but we only support # non-unified for that NDK, so look for that first. search_dirs = [ - os.path.join(android_platform, "usr", "include"), - os.path.join(ndk, "sysroot", "usr", "include", target.toolchain), + os.path.join(android_platform, 'usr', 'include'), + os.path.join(ndk, 'sysroot', 'usr', 'include', target.toolchain), ] for system_dir in search_dirs: @@ -207,85 +192,86 @@ def android_system(android_platform, ndk, target): die("Android system directory not found in %s." % str(search_dirs)) -add_old_configure_assignment("android_system", android_system) +add_old_configure_assignment('android_system', android_system) -@depends(target, host, ndk, "--with-android-toolchain") -@checking("for the Android toolchain directory", lambda x: x or "not found") -@imports(_from="os.path", _import="isdir") -@imports(_from="mozbuild.shellutil", _import="quote") +@depends(target, host, ndk, '--with-android-toolchain') +@checking('for the Android toolchain directory', lambda x: x or 'not found') +@imports(_from='os.path', _import='isdir') +@imports(_from='mozbuild.shellutil', _import='quote') def android_toolchain(target, host, ndk, toolchain): if not ndk: return if toolchain: return toolchain[0] else: - if target.cpu == "arm" and target.endianness == "little": - target_base = "arm-linux-androideabi" - elif target.cpu == "x86": - target_base = "x86" - elif target.cpu == "x86_64": - target_base = "x86_64" - elif target.cpu == "aarch64" and target.endianness == "little": - target_base = "aarch64-linux-android" + if target.cpu == 'arm' and target.endianness == 'little': + target_base = 'arm-linux-androideabi' + elif target.cpu == 'x86': + target_base = 'x86' + elif target.cpu == 'x86_64': + target_base = 'x86_64' + elif target.cpu == 'aarch64' and target.endianness == 'little': + target_base = 'aarch64-linux-android' else: - die("Target cpu is not supported.") - - toolchain_format = "%s/toolchains/%s-4.9/prebuilt/%s-%s" - host_kernel = "windows" if host.kernel == "WINNT" else host.kernel.lower() - - toolchain = toolchain_format % (ndk, target_base, host_kernel, host.cpu) - log.debug("Trying %s" % quote(toolchain)) - if not isdir(toolchain) and host.cpu == "x86_64": - toolchain = toolchain_format % (ndk, target_base, host_kernel, "x86") - log.debug("Trying %s" % quote(toolchain)) + die('Target cpu is not supported.') + + toolchain_format = '%s/toolchains/%s-4.9/prebuilt/%s-%s' + host_kernel = 'windows' if host.kernel == 'WINNT' else host.kernel.lower() + + toolchain = toolchain_format % (ndk, target_base, + host_kernel, host.cpu) + log.debug('Trying %s' % quote(toolchain)) + if not isdir(toolchain) and host.cpu == 'x86_64': + toolchain = toolchain_format % (ndk, target_base, + host_kernel, 'x86') + log.debug('Trying %s' % quote(toolchain)) if isdir(toolchain): return toolchain - die("You have to specify --with-android-toolchain=" "/path/to/ndk/toolchain.") + die('You have to specify --with-android-toolchain=' + '/path/to/ndk/toolchain.') -set_config("ANDROID_TOOLCHAIN", android_toolchain) +set_config('ANDROID_TOOLCHAIN', android_toolchain) @depends(target) def android_toolchain_prefix_base(target): - if target.cpu == "x86": + if target.cpu == 'x86': # Ideally, the --target should just have the right x86 variant # in the first place. - return "i686-linux-android" + return 'i686-linux-android' return target.toolchain -option( - env="STLPORT_CPPFLAGS", - nargs=1, - help="Options compiler should pass for standard C++ library", -) +option(env='STLPORT_CPPFLAGS', + nargs=1, + help='Options compiler should pass for standard C++ library') -@depends("STLPORT_CPPFLAGS", ndk) -@imports(_from="os.path", _import="isdir") +@depends('STLPORT_CPPFLAGS', ndk) +@imports(_from='os.path', _import='isdir') def stlport_cppflags(value, ndk): if value and len(value): return value.split() if not ndk: return - ndk_base = os.path.join(ndk, "sources", "cxx-stl") - cxx_base = os.path.join(ndk_base, "llvm-libc++") - cxx_include = os.path.join(cxx_base, "libcxx", "include") - cxxabi_base = os.path.join(ndk_base, "llvm-libc++abi") - cxxabi_include = os.path.join(cxxabi_base, "libcxxabi", "include") + ndk_base = os.path.join(ndk, 'sources', 'cxx-stl') + cxx_base = os.path.join(ndk_base, 'llvm-libc++') + cxx_include = os.path.join(cxx_base, 'libcxx', 'include') + cxxabi_base = os.path.join(ndk_base, 'llvm-libc++abi') + cxxabi_include = os.path.join(cxxabi_base, 'libcxxabi', 'include') if not isdir(cxx_include): # NDK r13 removes the inner "libcxx" directory. - cxx_include = os.path.join(cxx_base, "include") + cxx_include = os.path.join(cxx_base, 'include') if not isdir(cxx_include): die("Couldn't find path to libc++ includes in the android ndk") if not isdir(cxxabi_include): # NDK r13 removes the inner "libcxxabi" directory. - cxxabi_include = os.path.join(cxxabi_base, "include") + cxxabi_include = os.path.join(cxxabi_base, 'include') if not isdir(cxxabi_include): die("Couldn't find path to libc++abi includes in the android ndk") @@ -298,99 +284,87 @@ def stlport_cppflags(value, ndk): # Using -stdlib=libc++ and removing some of the -I below also doesn't # work because not everything that is in cxx_include comes in the C++ # header directory that comes with clang. - "-stdlib=libstdc++", - "-I%s" % cxx_include, - "-I%s" % os.path.join(ndk, "sources", "android", "support", "include"), - "-I%s" % cxxabi_include, - ] + '-stdlib=libstdc++', + '-I%s' % cxx_include, + '-I%s' % os.path.join(ndk, 'sources', 'android', 'support', 'include'), + '-I%s' % cxxabi_include] -add_old_configure_assignment("stlport_cppflags", stlport_cppflags) +add_old_configure_assignment('stlport_cppflags', stlport_cppflags) @depends(android_system, android_sysroot, android_toolchain, android_version) -def extra_toolchain_flags( - android_system, android_sysroot, toolchain_dir, android_version -): +def extra_toolchain_flags(android_system, android_sysroot, toolchain_dir, + android_version): if not android_sysroot: return [] - flags = [ - "-isystem", - android_system, - "-isystem", - os.path.join(android_sysroot, "usr", "include"), - "-gcc-toolchain", - toolchain_dir, - "-D__ANDROID_API__=%d" % android_version, - ] + flags = ['-isystem', + android_system, + '-isystem', + os.path.join(android_sysroot, 'usr', 'include'), + '-gcc-toolchain', + toolchain_dir, + '-D__ANDROID_API__=%d' % android_version] return flags @depends(android_toolchain_prefix_base, android_toolchain) def android_toolchain_prefix(prefix_base, toolchain): if toolchain: - return "%s/bin/%s-" % (toolchain, prefix_base) + return '%s/bin/%s-' % (toolchain, prefix_base) -imply_option( - "--with-toolchain-prefix", android_toolchain_prefix, reason="--with-android-ndk" -) +imply_option('--with-toolchain-prefix', android_toolchain_prefix, + reason='--with-android-ndk') -@depends( - extra_toolchain_flags, - stlport_cppflags, - android_toolchain, - android_toolchain_prefix_base, -) -@imports(_from="os.path", _import="isdir") -def bindgen_cflags_android(toolchain_flags, stlport_flags, toolchain, toolchain_prefix): +@depends(extra_toolchain_flags, stlport_cppflags, android_toolchain, + android_toolchain_prefix_base) +@imports(_from='os.path', _import='isdir') +def bindgen_cflags_android(toolchain_flags, stlport_flags, toolchain, + toolchain_prefix): if not toolchain_flags: return - gcc_include = os.path.join(toolchain, "lib", "gcc", toolchain_prefix, "4.9.x") + gcc_include = os.path.join( + toolchain, 'lib', 'gcc', toolchain_prefix, '4.9.x') if not isdir(gcc_include): - gcc_include = os.path.join(toolchain, "lib", "gcc", toolchain_prefix, "4.9") - - return ( - toolchain_flags - + stlport_flags - + [ - "-I%s" % os.path.join(gcc_include, "include"), - "-I%s" % os.path.join(gcc_include, "include-fixed"), - ] - ) + gcc_include = os.path.join( + toolchain, 'lib', 'gcc', toolchain_prefix, '4.9') + return toolchain_flags + stlport_flags + [ + '-I%s' % os.path.join(gcc_include, 'include'), + '-I%s' % os.path.join(gcc_include, 'include-fixed'), + ] -@depends("--with-android-googlevr-sdk", target) -@checking("for GoogleVR SDK", lambda x: x.result) -@imports(_from="os.path", _import="exists") -@imports(_from="os.path", _import="abspath") + +@depends('--with-android-googlevr-sdk', target) +@checking('for GoogleVR SDK', lambda x: x.result) +@imports(_from='os.path', _import='exists') +@imports(_from='os.path', _import='abspath') def googlevr_sdk(value, target): if not value: - return namespace(result="Not specified") + return namespace( + result='Not specified' + ) path = abspath(value[0]) if not exists(path): - die("Could not find GoogleVR SDK %s", path) - include = "%s/libraries/headers/" % path - if "arm" == target.cpu: - arch = "armeabi-v7a" - elif "aarch64" == target.cpu: - arch = "arm64-v8a" - elif "x86" == target.cpu: - arch = "x86" + die('Could not find GoogleVR SDK %s', path) + include = '%s/libraries/headers/' % path + if 'arm' == target.cpu: + arch = 'armeabi-v7a' + elif 'aarch64' == target.cpu: + arch = 'arm64-v8a' + elif 'x86' == target.cpu: + arch = 'x86' else: - die("Unsupported GoogleVR cpu architecture %s" % target.cpu) + die('Unsupported GoogleVR cpu architecture %s' % target.cpu) - libs = "{0}/libraries/jni/{1}/".format(path, arch) + libs = '{0}/libraries/jni/{1}/'.format(path, arch) if not exists(libs): - die( - "Could not find GoogleVR NDK at %s. Did you try running " - "'./gradlew :extractNdk' in %s?", - libs, - path, - ) + die('Could not find GoogleVR NDK at %s. Did you try running ' + '\'./gradlew :extractNdk\' in %s?', libs, path) return namespace( result=path, @@ -400,7 +374,7 @@ def googlevr_sdk(value, target): ) -set_define("MOZ_ANDROID_GOOGLE_VR", googlevr_sdk.enabled) -set_config("MOZ_ANDROID_GOOGLE_VR", googlevr_sdk.enabled) -set_config("MOZ_ANDROID_GOOGLE_VR_INCLUDE", googlevr_sdk.include) -set_config("MOZ_ANDROID_GOOGLE_VR_LIBS", googlevr_sdk.libs) +set_define('MOZ_ANDROID_GOOGLE_VR', googlevr_sdk.enabled) +set_config('MOZ_ANDROID_GOOGLE_VR', googlevr_sdk.enabled) +set_config('MOZ_ANDROID_GOOGLE_VR_INCLUDE', googlevr_sdk.include) +set_config('MOZ_ANDROID_GOOGLE_VR_LIBS', googlevr_sdk.libs) diff --git a/build/moz.configure/android-sdk.configure b/build/moz.configure/android-sdk.configure index 8f12de584973d60dffc65db8965871e51e2db943..2eb4c8ceae09ff94e33fc88b85652522ca5ca82a 100644 --- a/build/moz.configure/android-sdk.configure +++ b/build/moz.configure/android-sdk.configure @@ -7,13 +7,13 @@ # Ensure Android SDK and build-tools versions depending on mobile target. -@depends(host, mozbuild_state_path, "--help") -@imports(_from="os.path", _import="isdir") +@depends(host, mozbuild_state_path, '--help') +@imports(_from='os.path', _import='isdir') def default_android_sdk_root(host, mozbuild_state_path, _): sdk_basename = { - "Darwin": "android-sdk-macosx", - "Linux": "android-sdk-linux", - "WINNT": "android-sdk-windows", + 'Darwin': 'android-sdk-macosx', + 'Linux': 'android-sdk-linux', + 'WINNT': 'android-sdk-windows', }.get(host.kernel) if sdk_basename: path = os.path.join(mozbuild_state_path, sdk_basename) @@ -21,61 +21,52 @@ def default_android_sdk_root(host, mozbuild_state_path, _): return path -option( - "--with-android-sdk", - nargs=1, - default=default_android_sdk_root, - help="location where the Android SDK can be found (like ~/.mozbuild/android-sdk-linux){|}", -) +option('--with-android-sdk', nargs=1, + default=default_android_sdk_root, + help='location where the Android SDK can be found (like ~/.mozbuild/android-sdk-linux){|}') -@depends("--with-android-sdk") -@imports(_from="os.path", _import="isdir") +@depends('--with-android-sdk') +@imports(_from='os.path', _import='isdir') def android_sdk_root(value): if value: if not isdir(value[0]): - die( - "The path you specified with --with-android-sdk (%s) is not " - "a directory" % value[0] - ) + die("The path you specified with --with-android-sdk (%s) is not " + "a directory" % value[0]) return value[0] - die( - "You must specify --with-android-sdk=/path/to/sdk when targeting Android, " - "or try |mach bootstrap|." - ) + die("You must specify --with-android-sdk=/path/to/sdk when targeting Android, " + "or try |mach bootstrap|.") -@depends("--help") +@depends('--help') def android_sdk_version(_): - return namespace(build_tools_version="29.0.3", target_sdk_version="29") + return namespace(build_tools_version='29.0.3', target_sdk_version='29') @depends(android_sdk_root, android_sdk_version) -@checking("for Android build-tools") -@imports(_from="os.path", _import="exists") -@imports(_from="os.path", _import="isdir") +@checking('for Android build-tools') +@imports(_from='os.path', _import='exists') +@imports(_from='os.path', _import='isdir') def android_build_tools(sdk_root, sdk_version): - android_build_tools_base = os.path.join(sdk_root, "build-tools") + android_build_tools_base = os.path.join(sdk_root, 'build-tools') version = sdk_version.build_tools_version if isdir(os.path.join(android_build_tools_base, version)): tools = os.path.join(android_build_tools_base, version) - for zipalign in ("zipalign", "zipalign.exe"): + for zipalign in ('zipalign', 'zipalign.exe'): if exists(os.path.join(tools, zipalign)): return [tools] - die( - "You must install the Android build-tools version %s. " - "Try |mach bootstrap|. (Looked for %s/%s)" - % (version, android_build_tools_base, version) - ) + die("You must install the Android build-tools version %s. " + "Try |mach bootstrap|. (Looked for %s/%s)" % + (version, android_build_tools_base, version)) @depends(android_sdk_root) -@checking("for Android tools") -@imports(_from="os.path", _import="isdir") +@checking('for Android tools') +@imports(_from='os.path', _import='isdir') def android_tools(sdk_root): - tools = os.path.join(sdk_root, "tools") + tools = os.path.join(sdk_root, 'tools') if isdir(tools): return tools @@ -83,50 +74,45 @@ def android_tools(sdk_root): @depends(android_sdk_root) -@checking("for Android platform-tools") -@imports(_from="os.path", _import="exists") -@imports(_from="os.path", _import="isdir") +@checking('for Android platform-tools') +@imports(_from='os.path', _import='exists') +@imports(_from='os.path', _import='isdir') def android_platform_tools(sdk_root): - tools = os.path.join(sdk_root, "platform-tools") - for adb in ("adb", "adb.exe"): + tools = os.path.join(sdk_root, 'platform-tools') + for adb in ('adb', 'adb.exe'): if exists(os.path.join(tools, adb)): return [tools] - die( - "You must install the Android platform-tools. Try |mach bootstrap|. (Looked for %s)" - % tools - ) + die("You must install the Android platform-tools. Try |mach bootstrap|. (Looked for %s)" % + tools) @depends(android_sdk_root) def android_emulator_path(sdk_root): - return [os.path.join(sdk_root, "emulator")] + return [os.path.join(sdk_root, 'emulator')] @template def check_android_tools(tool, tool_dir): - check = check_prog( - tool.upper(), (tool, tool + ".exe"), paths=tool_dir, allow_missing=True - ) + check = check_prog(tool.upper(), (tool, tool + '.exe'), paths=tool_dir, + allow_missing=True) @depends(check) def require_tool(result): if result is None: - die("The program %s was not found. Try |mach bootstrap|" % tool) + die('The program %s was not found. Try |mach bootstrap|' % tool) return result return require_tool -check_android_tools("zipalign", android_build_tools) -check_android_tools("adb", android_platform_tools) -check_android_tools("emulator", android_emulator_path) +check_android_tools('zipalign', android_build_tools) +check_android_tools('adb', android_platform_tools) +check_android_tools('emulator', android_emulator_path) -set_config("ANDROID_SDK_ROOT", android_sdk_root) -set_config("ANDROID_TOOLS", android_tools) +set_config('ANDROID_SDK_ROOT', android_sdk_root) +set_config('ANDROID_TOOLS', android_tools) -set_config("ANDROID_BUILD_TOOLS_VERSION", android_sdk_version.build_tools_version) -set_config("ANDROID_TARGET_SDK", android_sdk_version.target_sdk_version) -add_old_configure_assignment( - "ANDROID_TARGET_SDK", android_sdk_version.target_sdk_version -) +set_config('ANDROID_BUILD_TOOLS_VERSION', android_sdk_version.build_tools_version) +set_config('ANDROID_TARGET_SDK', android_sdk_version.target_sdk_version) +add_old_configure_assignment('ANDROID_TARGET_SDK', android_sdk_version.target_sdk_version) diff --git a/build/moz.configure/arm.configure b/build/moz.configure/arm.configure index 2082fa640f498c2b6ee9a828fa70c4b15e61f88b..d767fb8d99f730ee6ad57c1560d74597b4aaeca9 100644 --- a/build/moz.configure/arm.configure +++ b/build/moz.configure/arm.configure @@ -4,16 +4,15 @@ # 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/. - -@depends(target.os, "--help") +@depends(target.os, '--help') def arm_option_defaults(os, _): - if os == "Android": - arch = "armv7-a" - thumb = "yes" - fpu = "neon" - float_abi = "softfp" + if os == 'Android': + arch = 'armv7-a' + thumb = 'yes' + fpu = 'neon' + float_abi = 'softfp' else: - arch = thumb = fpu = float_abi = "toolchain-default" + arch = thumb = fpu = float_abi = 'toolchain-default' return namespace( arch=arch, thumb=thumb, @@ -27,154 +26,124 @@ def arm_option_defaults(os, _): # default is always returned. The lint is fooled by this file being # conditional. If it weren't conditional, the lint wouldn't ask for '{|}' to # be there. -option( - "--with-arch", - nargs=1, - default=arm_option_defaults.arch, - help="{Use specific CPU features (-march=type). Resets thumb, fpu, " - "float-abi, etc. defaults when set|}", -) +option('--with-arch', nargs=1, + default=arm_option_defaults.arch, + help='{Use specific CPU features (-march=type). Resets thumb, fpu, ' + 'float-abi, etc. defaults when set|}') -@depends("--with-arch") +@depends('--with-arch') def arch_option(value): if value: - if value[0] != "toolchain-default": - return ["-march={}".format(value[0])] + if value[0] != 'toolchain-default': + return ['-march={}'.format(value[0])] return [] -option( - "--with-thumb", - choices=("yes", "no", "toolchain-default"), - default=arm_option_defaults.thumb, - nargs="?", - help="{Use Thumb instruction set (-mthumb)|}", -) +option('--with-thumb', choices=('yes', 'no', 'toolchain-default'), + default=arm_option_defaults.thumb, + nargs='?', help='{Use Thumb instruction set (-mthumb)|}') def normalize_arm_option(value): if value: if len(value): - if value[0] == "yes": + if value[0] == 'yes': return True - elif value[0] == "no": + elif value[0] == 'no': return False else: return value[0] return True return False - -@depends("--with-thumb") +@depends('--with-thumb') def thumb_option(value): value = normalize_arm_option(value) if value is True: - return ["-mthumb"] + return ['-mthumb'] if value is False: - return ["-marm"] + return ['-marm'] return [] -option( - "--with-thumb-interwork", - choices=("yes", "no", "toolchain-default"), - default="toolchain-default", - nargs="?", - help="Use Thumb/ARM instuctions interwork (-mthumb-interwork)", -) +option('--with-thumb-interwork', choices=('yes', 'no', 'toolchain-default'), + default='toolchain-default', + nargs='?', help='Use Thumb/ARM instuctions interwork (-mthumb-interwork)') -@depends("--with-thumb-interwork") +@depends('--with-thumb-interwork') def thumb_interwork_option(value): value = normalize_arm_option(value) if value is True: - return ["-mthumb-interwork"] + return ['-mthumb-interwork'] if value is False: - return ["-mno-thumb-interwork"] + return ['-mno-thumb-interwork'] return [] -option( - "--with-fpu", - nargs=1, - default=arm_option_defaults.fpu, - help="{Use specific FPU type (-mfpu=type)|}", -) +option('--with-fpu', nargs=1, + default=arm_option_defaults.fpu, + help='{Use specific FPU type (-mfpu=type)|}') -@depends("--with-fpu") +@depends('--with-fpu') def fpu_option(value): if value: - if value[0] != "toolchain-default": - return ["-mfpu={}".format(value[0])] + if value[0] != 'toolchain-default': + return ['-mfpu={}'.format(value[0])] return [] -option( - "--with-float-abi", - nargs=1, - default=arm_option_defaults.float_abi, - help="{Use specific arm float ABI (-mfloat-abi=type)|}", -) +option('--with-float-abi', nargs=1, + default=arm_option_defaults.float_abi, + help='{Use specific arm float ABI (-mfloat-abi=type)|}') -@depends("--with-float-abi") +@depends('--with-float-abi') def float_abi_option(value): if value: - if value[0] != "toolchain-default": - return ["-mfloat-abi={}".format(value[0])] + if value[0] != 'toolchain-default': + return ['-mfloat-abi={}'.format(value[0])] return [] -option( - "--with-soft-float", - choices=("yes", "no", "toolchain-default"), - default="toolchain-default", - nargs="?", - help="Use soft float library (-msoft-float)", -) +option('--with-soft-float', choices=('yes', 'no', 'toolchain-default'), + default='toolchain-default', + nargs='?', help='Use soft float library (-msoft-float)') -@depends("--with-soft-float") +@depends('--with-soft-float') def soft_float_option(value): value = normalize_arm_option(value) if value is True: - return ["-msoft-float"] + return ['-msoft-float'] if value is False: - return ["-mno-soft-float"] + return ['-mno-soft-float'] return [] -check_and_add_gcc_flag( - "-mno-unaligned-access", when=depends(target.os)(lambda os: os == "Android") -) +check_and_add_gcc_flag('-mno-unaligned-access', + when=depends(target.os)(lambda os: os == 'Android')) -@depends( - arch_option, - thumb_option, - thumb_interwork_option, - fpu_option, - float_abi_option, - soft_float_option, -) +@depends(arch_option, thumb_option, thumb_interwork_option, fpu_option, + float_abi_option, soft_float_option) def all_flags(arch, thumb, interwork, fpu, float_abi, soft_float): return arch + thumb + interwork + fpu + float_abi + soft_float -add_old_configure_assignment("_ARM_FLAGS", all_flags) -add_old_configure_assignment("_THUMB_FLAGS", thumb_option) +add_old_configure_assignment('_ARM_FLAGS', all_flags) +add_old_configure_assignment('_THUMB_FLAGS', thumb_option) @depends(c_compiler, all_flags) -@checking("ARM version support in compiler", lambda x: x.arm_arch) -@imports(_from="textwrap", _import="dedent") +@checking('ARM version support in compiler', lambda x: x.arm_arch) +@imports(_from='textwrap', _import='dedent') def arm_target(compiler, all_flags): # We're going to preprocess the following source to figure out some details # about the arm target options we have enabled. - source = dedent( - """\ + source = dedent('''\ %ARM_ARCH __ARM_ARCH #if __thumb2__ %THUMB2 yes @@ -203,58 +172,54 @@ def arm_target(compiler, all_flags): #elif __ARM_FPV5__ %FPU fp-armv8 #endif - """ - ) + ''') result = try_invoke_compiler( compiler.wrapper + [compiler.compiler] + compiler.flags, compiler.language, source, - ["-E"] + all_flags, + ['-E'] + all_flags, ) # Metadata emitted by preprocessors such as GCC with LANG=ja_JP.utf-8 may # have non-ASCII characters. Treat the output as bytearray. - data = {"fpu": None} # fpu may not get a value from the preprocessor. + data = {'fpu': None} # fpu may not get a value from the preprocessor. for line in result.splitlines(): - if line.startswith("%"): - k, _, v = line.partition(" ") - k = k.lstrip("%").lower() - if k == "arm_arch": + if line.startswith('%'): + k, _, v = line.partition(' ') + k = k.lstrip('%').lower() + if k == 'arm_arch': data[k] = int(v) else: data[k] = { - "yes": True, - "no": False, + 'yes': True, + 'no': False, }.get(v, v) - log.debug("%s = %s", k, data[k]) + log.debug('%s = %s', k, data[k]) return namespace(**data) -@depends(arm_target.arm_arch, when=depends(target.os)(lambda os: os == "Android")) +@depends(arm_target.arm_arch, when=depends(target.os)(lambda os: os == 'Android')) def armv7(arch): if arch < 7: - die("Android/armv6 and earlier are not supported") + die('Android/armv6 and earlier are not supported') -set_config("MOZ_THUMB2", True, when=arm_target.thumb2) -set_define("MOZ_THUMB2", True, when=arm_target.thumb2) -add_old_configure_assignment("MOZ_THUMB2", True, when=arm_target.thumb2) +set_config('MOZ_THUMB2', True, when=arm_target.thumb2) +set_define('MOZ_THUMB2', True, when=arm_target.thumb2) +add_old_configure_assignment('MOZ_THUMB2', True, when=arm_target.thumb2) -have_arm_simd = c_compiler.try_compile( - body='asm("uqadd8 r1, r1, r2");', check_msg="for ARM SIMD support in compiler" -) +have_arm_simd = c_compiler.try_compile(body='asm("uqadd8 r1, r1, r2");', + check_msg='for ARM SIMD support in compiler') -set_config("HAVE_ARM_SIMD", have_arm_simd) -set_define("HAVE_ARM_SIMD", have_arm_simd) +set_config('HAVE_ARM_SIMD', have_arm_simd) +set_define('HAVE_ARM_SIMD', have_arm_simd) -have_arm_neon = c_compiler.try_compile( - body='asm(".fpu neon\\n vadd.i8 d0, d0, d0");', - check_msg="for ARM NEON support in compiler", -) +have_arm_neon = c_compiler.try_compile(body='asm(".fpu neon\\n vadd.i8 d0, d0, d0");', + check_msg='for ARM NEON support in compiler') -set_config("HAVE_ARM_NEON", have_arm_neon) -set_define("HAVE_ARM_NEON", have_arm_neon) +set_config('HAVE_ARM_NEON', have_arm_neon) +set_define('HAVE_ARM_NEON', have_arm_neon) # We don't need to build NEON support if we're targetting a non-NEON device. @@ -264,13 +229,13 @@ def build_arm_neon(arm_arch): return arm_arch >= 7 -set_config("BUILD_ARM_NEON", build_arm_neon) -set_define("BUILD_ARM_NEON", build_arm_neon) +set_config('BUILD_ARM_NEON', build_arm_neon) +set_define('BUILD_ARM_NEON', build_arm_neon) -set_config("ARM_ARCH", depends(arm_target.arm_arch)(lambda x: str(x))) -add_old_configure_assignment("ARM_ARCH", depends(arm_target.arm_arch)(lambda x: str(x))) -set_config("MOZ_FPU", arm_target.fpu) +set_config('ARM_ARCH', depends(arm_target.arm_arch)(lambda x: str(x))) +add_old_configure_assignment('ARM_ARCH', depends(arm_target.arm_arch)(lambda x: str(x))) +set_config('MOZ_FPU', arm_target.fpu) @depends(arm_target.float_abi) @@ -283,10 +248,10 @@ def neon_flags(float_abi): # we can safely mix code built with both ABIs. So, if we detect # that compiling uses the "softfloat" ABI, force the use of the # "softfp" ABI instead. - flags = ["-mfpu=neon"] - if float_abi == "soft": - flags.append("-mfloat-abi=softfp") + flags = ['-mfpu=neon'] + if float_abi == 'soft': + flags.append('-mfloat-abi=softfp') return tuple(flags) -set_config("NEON_FLAGS", neon_flags) +set_config('NEON_FLAGS', neon_flags) diff --git a/build/moz.configure/bindgen.configure b/build/moz.configure/bindgen.configure index da8a5d57af1db9db9ce5b30897c124fb7bbdc3f6..79e1c3b14dcb593ec6e0d08baab7e8001218ba62 100644 --- a/build/moz.configure/bindgen.configure +++ b/build/moz.configure/bindgen.configure @@ -4,52 +4,45 @@ # 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/. - -@depends(build_project, "--enable-smoosh") +@depends(build_project, '--enable-smoosh') def cbindgen_is_needed(build_project, js_enable_smoosh): - if build_project != "js": + if build_project != 'js': # cbindgen is needed by the style system build and webrender. return True # cbindgen is needed by SmooshMonkey. return js_enable_smoosh - -option(env="CBINDGEN", nargs=1, when=cbindgen_is_needed, help="Path to cbindgen") +option(env='CBINDGEN', nargs=1, when=cbindgen_is_needed, + help='Path to cbindgen') -@imports(_from="textwrap", _import="dedent") +@imports(_from='textwrap', _import='dedent') def check_cbindgen_version(cbindgen, fatal=False): log.debug("trying cbindgen: %s" % cbindgen) - cbindgen_min_version = Version("0.15.0") + cbindgen_min_version = Version('0.15.0') # cbindgen x.y.z - version = Version(check_cmd_output(cbindgen, "--version").strip().split(" ")[1]) + version = Version(check_cmd_output(cbindgen, '--version').strip().split(" ")[1]) log.debug("%s has version %s" % (cbindgen, version)) if version >= cbindgen_min_version: return True if not fatal: return False - die( - dedent( - """\ + die(dedent('''\ cbindgen version {} is too old. At least version {} is required. Please update using 'cargo install cbindgen --force' or running './mach bootstrap', after removing the existing executable located at {}. - """.format( - version, cbindgen_min_version, cbindgen - ) - ) - ) + '''.format(version, cbindgen_min_version, cbindgen))) -@depends_if("CBINDGEN", toolchain_search_path, when=cbindgen_is_needed) -@checking("for cbindgen") -@imports(_from="textwrap", _import="dedent") +@depends_if('CBINDGEN', toolchain_search_path, when=cbindgen_is_needed) +@checking('for cbindgen') +@imports(_from='textwrap', _import='dedent') def cbindgen(cbindgen_override, toolchain_search_path): if cbindgen_override: check_cbindgen_version(cbindgen_override[0], fatal=True) @@ -57,7 +50,7 @@ def cbindgen(cbindgen_override, toolchain_search_path): candidates = [] for path in toolchain_search_path: - candidate = find_program("cbindgen", [path]) + candidate = find_program('cbindgen', [path]) if not candidate: continue if check_cbindgen_version(candidate): @@ -65,136 +58,104 @@ def cbindgen(cbindgen_override, toolchain_search_path): candidates.append(candidate) if not candidates: - raise FatalCheckError( - dedent( - """\ + raise FatalCheckError(dedent('''\ Cannot find cbindgen. Please run `mach bootstrap`, `cargo install cbindgen`, ensure that `cbindgen` is on your PATH, or point at an executable with `CBINDGEN`. - """ - ) - ) + ''')) check_cbindgen_version(candidates[0], fatal=True) - -set_config("CBINDGEN", cbindgen) +set_config('CBINDGEN', cbindgen) # Bindgen can use rustfmt to format Rust file, but it's not required. -option(env="RUSTFMT", nargs=1, help="Path to the rustfmt program") - -rustfmt = check_prog( - "RUSTFMT", - ["rustfmt"], - paths=toolchain_search_path, - input="RUSTFMT", - allow_missing=True, -) - - -option( - "--with-libclang-path", - nargs=1, - help="Absolute path to a directory containing Clang/LLVM libraries for bindgen (version 3.9.x or above)", -) -option( - "--with-clang-path", - nargs=1, - help="Absolute path to a Clang binary for bindgen (version 3.9.x or above)", -) - - -@depends( - "--with-clang-path", - c_compiler, - cxx_compiler, - toolchain_search_path, - target, - macos_sdk, -) -@checking("for clang for bindgen", lambda x: x.path if x else "not found") -def bindgen_clang_compiler( - clang_path, c_compiler, cxx_compiler, toolchain_search_path, target, macos_sdk -): +option(env='RUSTFMT', nargs=1, help='Path to the rustfmt program') + +rustfmt = check_prog('RUSTFMT', ['rustfmt'], paths=toolchain_search_path, + input='RUSTFMT', allow_missing=True) + + +option('--with-libclang-path', nargs=1, + help='Absolute path to a directory containing Clang/LLVM libraries for bindgen (version 3.9.x or above)') +option('--with-clang-path', nargs=1, + help='Absolute path to a Clang binary for bindgen (version 3.9.x or above)') + + +@depends('--with-clang-path', c_compiler, cxx_compiler, toolchain_search_path, + target, macos_sdk) +@checking('for clang for bindgen', lambda x: x.path if x else 'not found') +def bindgen_clang_compiler(clang_path, c_compiler, cxx_compiler, + toolchain_search_path, target, macos_sdk): # When the target compiler is clang, use that, including flags. - if cxx_compiler.type == "clang": - if clang_path and clang_path[0] not in ( - c_compiler.compiler, - cxx_compiler.compiler, - ): - die( - "--with-clang-path is not valid when the target compiler is %s", - cxx_compiler.type, - ) + if cxx_compiler.type == 'clang': + if clang_path and clang_path[0] not in (c_compiler.compiler, + cxx_compiler.compiler): + die('--with-clang-path is not valid when the target compiler is %s', + cxx_compiler.type) return namespace( path=cxx_compiler.compiler, flags=cxx_compiler.flags, ) # When the target compiler is clang-cl, use clang in the same directory, # and figure the right flags to use. - if cxx_compiler.type == "clang-cl": - if clang_path and os.path.dirname(clang_path[0]) != os.path.dirname( - cxx_compiler.compiler - ): - die( - "--with-clang-path must point to clang in the same directory " - "as the target compiler" - ) + if cxx_compiler.type == 'clang-cl': + if clang_path and os.path.dirname(clang_path[0]) != \ + os.path.dirname(cxx_compiler.compiler): + die('--with-clang-path must point to clang in the same directory ' + 'as the target compiler') if not clang_path: - clang_path = [os.path.join(os.path.dirname(cxx_compiler.compiler), "clang")] + clang_path = [os.path.join(os.path.dirname(cxx_compiler.compiler), + 'clang')] - clang_path = find_program( - clang_path[0] if clang_path else "clang++", toolchain_search_path - ) + clang_path = find_program(clang_path[0] if clang_path else 'clang++', + toolchain_search_path) if not clang_path: return # Hack before bug 1617793: if the compiler is clang-cl, hack the target - if cxx_compiler.type == "clang-cl": - target = split_triplet("%s-pc-windows-msvc" % target.raw_cpu, allow_msvc=True) + if cxx_compiler.type == 'clang-cl': + target = split_triplet('%s-pc-windows-msvc' % target.raw_cpu, allow_msvc=True) flags = prepare_flags(target, macos_sdk) - info = check_compiler([clang_path] + flags, "C++", target) + info = check_compiler([clang_path] + flags, 'C++', target) return namespace( path=clang_path, flags=flags + info.flags, ) -@depends("--with-libclang-path", bindgen_clang_compiler, host_library_name_info, host) -@checking("for libclang for bindgen", lambda x: x if x else "not found") -@imports("glob") -@imports(_from="os", _import="pathsep") -@imports(_from="os.path", _import="split", _as="pathsplit") -@imports("re") +@depends('--with-libclang-path', bindgen_clang_compiler, + host_library_name_info, host) +@checking('for libclang for bindgen', lambda x: x if x else 'not found') +@imports('glob') +@imports(_from='os', _import='pathsep') +@imports(_from='os.path', _import='split', _as='pathsplit') +@imports('re') def bindgen_libclang_path(libclang_path, clang, library_name_info, host): if not clang: if libclang_path: - die( - "--with-libclang-path is not valid without a clang compiler " - "for bindgen" - ) + die('--with-libclang-path is not valid without a clang compiler ' + 'for bindgen') return # Try to ensure that the clang shared library that bindgen is going # to look for is actually present. The files that we search for # mirror the logic in clang-sys/build.rs. libclang_choices = [] - if host.os == "WINNT": - libclang_choices.append("libclang.dll") - libclang_choices.append( - "%sclang%s" % (library_name_info.dll.prefix, library_name_info.dll.suffix) - ) - if host.kernel == "Linux": - libclang_choices.append("libclang.so.*") + if host.os == 'WINNT': + libclang_choices.append('libclang.dll') + libclang_choices.append('%sclang%s' % (library_name_info.dll.prefix, + library_name_info.dll.suffix)) + if host.kernel == 'Linux': + libclang_choices.append('libclang.so.*') - if host.os == "OpenBSD": - libclang_choices.append("libclang.so.*.*") + if host.os == 'OpenBSD': + libclang_choices.append('libclang.so.*.*') candidates = [] if not libclang_path: # Try to find libclang_path based on clang search dirs. - clang_search_dirs = check_cmd_output(clang.path, "-print-search-dirs") + clang_search_dirs = check_cmd_output(clang.path, '-print-search-dirs') for line in clang_search_dirs.splitlines(): - name, _, value = line.partition(": =") - if host.os == "WINNT" and name == "programs": + name, _, value = line.partition(': =') + if host.os == 'WINNT' and name == 'programs': # On Windows, libclang.dll is in bin/ rather than lib/, # so scan the programs search dirs. # To make matters complicated, clang before version 9 uses `:` @@ -202,22 +163,22 @@ def bindgen_libclang_path(libclang_path, clang, library_name_info, host): if pathsep in value: candidates.extend(value.split(pathsep)) else: - for part in value.split(":"): + for part in value.split(':'): # Assume that if previous "candidate" was of length 1, # it's a drive letter and the current part is the rest of # the corresponding full path. if candidates and len(candidates[-1]) == 1: - candidates[-1] += ":" + part + candidates[-1] += ':' + part else: candidates.append(part) - elif host.os != "WINNT" and name == "libraries": + elif host.os != 'WINNT' and name == 'libraries': # On other platforms, use the directories from the libraries # search dirs that looks like $something/clang/$version. for dir in value.split(pathsep): dir, version = pathsplit(dir) - if re.match(r"[0-9.]+", version): + if re.match(r'[0-9.]+', version): dir, name = pathsplit(dir) - if name == "clang": + if name == 'clang': candidates.append(dir) else: candidates.append(libclang_path[0]) @@ -237,20 +198,16 @@ def bindgen_config_paths(clang, libclang, build_project): # Actually, we don't want to force an error if we're not building the # browser generally. We therefore whitelist the projects that require # bindgen facilities at this point and leave it at that. - if build_project in ("browser", "mobile/android"): + if build_project in ('browser', 'mobile/android'): if not clang: - die( - "Could not find clang to generate run bindings for C/C++. " - "Please install the necessary packages, run `mach bootstrap`, " - "or use --with-clang-path to give the location of clang." - ) + die('Could not find clang to generate run bindings for C/C++. ' + 'Please install the necessary packages, run `mach bootstrap`, ' + 'or use --with-clang-path to give the location of clang.') if not libclang: - die( - "Could not find libclang to generate rust bindings for C/C++. " - "Please install the necessary packages, run `mach bootstrap`, " - "or use --with-libclang-path to give the path containing it." - ) + die('Could not find libclang to generate rust bindings for C/C++. ' + 'Please install the necessary packages, run `mach bootstrap`, ' + 'or use --with-libclang-path to give the path containing it.') if clang and libclang: return namespace( @@ -262,9 +219,9 @@ def bindgen_config_paths(clang, libclang, build_project): @depends(bindgen_config_paths.libclang, when=bindgen_config_paths) -@checking("that libclang is new enough", lambda s: "yes" if s else "no") -@imports(_from="ctypes", _import="CDLL") -@imports(_from="textwrap", _import="dedent") +@checking('that libclang is new enough', lambda s: 'yes' if s else 'no') +@imports(_from='ctypes', _import='CDLL') +@imports(_from='textwrap', _import='dedent') def min_libclang_version(libclang): try: lib = CDLL(libclang) @@ -273,94 +230,77 @@ def min_libclang_version(libclang): fun = lib.clang_getAddressSpace return True except: - die( - dedent( - """\ + die(dedent('''\ The libclang located at {} is too old (need at least 5.0). Please make sure to update it or point to a newer libclang using --with-libclang-path. - """.format( - libclang - ) - ) - ) + '''.format(libclang))) return False -set_config("MOZ_LIBCLANG_PATH", bindgen_config_paths.libclang_path) -set_config("MOZ_CLANG_PATH", bindgen_config_paths.clang_path) +set_config('MOZ_LIBCLANG_PATH', bindgen_config_paths.libclang_path) +set_config('MOZ_CLANG_PATH', bindgen_config_paths.clang_path) -@depends( - target, - target_is_unix, - cxx_compiler, - bindgen_cflags_android, - bindgen_config_paths.clang_flags, -) -def basic_bindgen_cflags(target, is_unix, compiler_info, android_cflags, clang_flags): +@depends(target, target_is_unix, cxx_compiler, bindgen_cflags_android, + bindgen_config_paths.clang_flags) +def basic_bindgen_cflags(target, is_unix, compiler_info, android_cflags, + clang_flags): args = [ - "-x", - "c++", - "-fno-sized-deallocation", - "-fno-aligned-new", - "-DTRACING=1", - "-DIMPL_LIBXUL", - "-DMOZILLA_INTERNAL_API", - "-DRUST_BINDGEN", + '-x', 'c++', '-fno-sized-deallocation', '-fno-aligned-new', + '-DTRACING=1', '-DIMPL_LIBXUL', '-DMOZILLA_INTERNAL_API', + '-DRUST_BINDGEN' ] if is_unix: - args += ["-DOS_POSIX=1"] + args += ['-DOS_POSIX=1'] - if target.os == "Android": + if target.os == 'Android': args += android_cflags args += { - "Android": ["-DOS_ANDROID=1"], - "DragonFly": ["-DOS_BSD=1", "-DOS_DRAGONFLY=1"], - "FreeBSD": ["-DOS_BSD=1", "-DOS_FREEBSD=1"], - "GNU": ["-DOS_LINUX=1"], - "NetBSD": ["-DOS_BSD=1", "-DOS_NETBSD=1"], - "OpenBSD": ["-DOS_BSD=1", "-DOS_OPENBSD=1"], - "OSX": ["-DOS_MACOSX=1", "-stdlib=libc++"], - "SunOS": ["-DOS_SOLARIS=1"], - "WINNT": [ - "-DOS_WIN=1", - "-DWIN32=1", + 'Android': ['-DOS_ANDROID=1'], + 'DragonFly': ['-DOS_BSD=1', '-DOS_DRAGONFLY=1'], + 'FreeBSD': ['-DOS_BSD=1', '-DOS_FREEBSD=1'], + 'GNU': ['-DOS_LINUX=1'], + 'NetBSD': ['-DOS_BSD=1', '-DOS_NETBSD=1'], + 'OpenBSD': ['-DOS_BSD=1', '-DOS_OPENBSD=1'], + 'OSX': ['-DOS_MACOSX=1', '-stdlib=libc++'], + 'SunOS': ['-DOS_SOLARIS=1'], + 'WINNT': [ + '-DOS_WIN=1', + '-DWIN32=1', ], }.get(target.os, []) - if compiler_info.type == "clang-cl": + if compiler_info.type == 'clang-cl': args += [ # To enable the builtin __builtin_offsetof so that CRT wouldn't # use reinterpret_cast in offsetof() which is not allowed inside # static_assert(). - "-D_CRT_USE_BUILTIN_OFFSETOF", + '-D_CRT_USE_BUILTIN_OFFSETOF', # Enable hidden attribute (which is not supported by MSVC and # thus not enabled by default with a MSVC-compatibile build) # to exclude hidden symbols from the generated file. - "-DHAVE_VISIBILITY_HIDDEN_ATTRIBUTE=1", + '-DHAVE_VISIBILITY_HIDDEN_ATTRIBUTE=1', ] return args + (clang_flags or []) -option( - env="BINDGEN_CFLAGS", - nargs=1, - help="Options bindgen should pass to the C/C++ parser", -) +option(env='BINDGEN_CFLAGS', + nargs=1, + help='Options bindgen should pass to the C/C++ parser') -@depends(basic_bindgen_cflags, "BINDGEN_CFLAGS") -@checking("bindgen cflags", lambda s: s if s else "no") +@depends(basic_bindgen_cflags, 'BINDGEN_CFLAGS') +@checking('bindgen cflags', lambda s: s if s else 'no') def bindgen_cflags(base_flags, extra_flags): flags = base_flags if extra_flags and len(extra_flags): flags += extra_flags[0].split() - return " ".join(flags) + return ' '.join(flags) -add_old_configure_assignment("_BINDGEN_CFLAGS", bindgen_cflags) +add_old_configure_assignment('_BINDGEN_CFLAGS', bindgen_cflags) diff --git a/build/moz.configure/checks.configure b/build/moz.configure/checks.configure index cfff05933a5a8609998772e23c98ef9244592ebb..5bb026dfdfa110d7fcf182a595b1642eecc0f8fc 100644 --- a/build/moz.configure/checks.configure +++ b/build/moz.configure/checks.configure @@ -14,14 +14,13 @@ @template -@imports(_from="__builtin__", _import="Exception") +@imports(_from='__builtin__', _import='Exception') def _declare_exceptions(): class FatalCheckError(Exception): - """An exception to throw from a function decorated with @checking. + '''An exception to throw from a function decorated with @checking. It will result in calling die() with the given message. Debugging messages emitted from the decorated function will also be - printed out.""" - + printed out.''' return (FatalCheckError,) @@ -52,7 +51,7 @@ del _declare_exceptions def checking(what, callback=None): def decorator(func): def wrapped(*args, **kwargs): - log.info("checking %s... ", what) + log.info('checking %s... ', what) with log.queue_debug(): error, ret = None, None try: @@ -61,17 +60,15 @@ def checking(what, callback=None): error = str(e) display_ret = callback(ret) if callback else ret if display_ret is True: - log.info("yes") + log.info('yes') elif display_ret is False or display_ret is None: - log.info("no") + log.info('no') else: log.info(display_ret) if error is not None: die(error) return ret - return wrapped - return decorator @@ -104,17 +101,9 @@ def checking(what, callback=None): # it can find. If PROG is already set from the environment or command line, # use that value instead. @template -@imports(_from="mozbuild.shellutil", _import="quote") -def check_prog( - var, - progs, - what=None, - input=None, - allow_missing=False, - paths=None, - paths_have_priority=False, - when=None, -): +@imports(_from='mozbuild.shellutil', _import='quote') +def check_prog(var, progs, what=None, input=None, allow_missing=False, + paths=None, paths_have_priority=False, when=None): if input is not None: # Wrap input with type checking and normalization. @depends(input, when=when) @@ -125,18 +114,11 @@ def check_prog( return (value,) if isinstance(value, (tuple, list)) and len(value) == 1: return value - configure_error( - "input must resolve to a tuple or a list with a " - "single element, or a string" - ) - + configure_error('input must resolve to a tuple or a list with a ' + 'single element, or a string') else: - option( - env=var, - nargs=1, - when=when, - help="Path to %s" % (what or "the %s program" % var.lower()), - ) + option(env=var, nargs=1, when=when, + help='Path to %s' % (what or 'the %s program' % var.lower())) input = var what = what or var.lower() @@ -156,12 +138,12 @@ def check_prog( progs = () if not isinstance(progs, (tuple, list)): - configure_error("progs must resolve to a list or tuple!") + configure_error('progs must resolve to a list or tuple!') return namespace(value=input, progs=progs, paths=paths) @depends(inputs, allow_missing, when=inputs) - @checking("for %s" % what, lambda x: quote(x) if x else "not found") + @checking('for %s' % what, lambda x: quote(x) if x else 'not found') def check(inputs, allow_missing): value = inputs.value progs = inputs.progs @@ -170,19 +152,19 @@ def check_prog( if paths_have_priority: for path in paths: for prog in value or progs: - log.debug("%s: Trying %s", var.lower(), quote(prog)) + log.debug('%s: Trying %s', var.lower(), quote(prog)) result = find_program(prog, [path]) if result: return result else: for prog in value or progs: - log.debug("%s: Trying %s", var.lower(), quote(prog)) + log.debug('%s: Trying %s', var.lower(), quote(prog)) result = find_program(prog, paths) if result: return result if not allow_missing or value: - raise FatalCheckError("Cannot find %s" % what) + raise FatalCheckError('Cannot find %s' % what) set_config(var, check) diff --git a/build/moz.configure/compile-checks.configure b/build/moz.configure/compile-checks.configure index 25e4f80bf5b7fd554dbd7e141fdf3381bd060dc7..b795c23c58d2a633628f1a07041f3b761218287b 100755 --- a/build/moz.configure/compile-checks.configure +++ b/build/moz.configure/compile-checks.configure @@ -18,23 +18,14 @@ # - `check_msg` is the message to be printed to accompany compiling the test # program. @template -def try_compile( - includes=None, - body="", - language="C++", - flags=None, - check_msg=None, - when=None, - onerror=lambda: None, -): +def try_compile(includes=None, body='', language='C++', flags=None, check_msg=None, + when=None, onerror=lambda: None): compiler = { - "C": c_compiler, - "C++": cxx_compiler, + 'C': c_compiler, + 'C++': cxx_compiler, }[language] - return compiler.try_compile( - includes, body, flags, check_msg, when=when, onerror=onerror - ) + return compiler.try_compile(includes, body, flags, check_msg, when=when, onerror=onerror) # Checks for the presence of the given header on the target system by compiling @@ -53,9 +44,8 @@ def try_compile( # - `when` is a depends function that if present will make performing the check # conditional on the value of that function. @template -def check_header( - header, language="C++", flags=None, includes=None, when=None, onerror=lambda: None -): +def check_header(header, language='C++', flags=None, includes=None, when=None, + onerror=lambda: None): if when is None: when = always @@ -65,21 +55,15 @@ def check_header( includes = [] includes.append(header) - have_header = try_compile( - includes=includes, - language=language, - flags=flags, - check_msg="for %s" % header, - when=when, - onerror=onerror, - ) - header_var = "HAVE_%s" % ( - header.upper().replace("-", "_").replace("/", "_").replace(".", "_") - ) + have_header = try_compile(includes=includes, language=language, flags=flags, + check_msg='for %s' % header, when=when, onerror=onerror) + header_var = 'HAVE_%s' % (header.upper() + .replace('-', '_') + .replace('/', '_') + .replace('.', '_')) set_define(header_var, have_header) return have_header - # A convenience wrapper for check_header for checking multiple headers. # returns an array of the resulting checks in order corresponding to the # provided headers. @@ -99,28 +83,28 @@ def check_headers(*headers, **kwargs): # a test program. The return value of the template is a check function # returning True if the symbol can be found, and None if it is not. @template -def check_symbol(symbol, language="C", flags=None, when=None, onerror=lambda: None): +def check_symbol(symbol, language='C', flags=None, when=None, onerror=lambda: None): if when is None: when = always compiler = { - "C": c_compiler, - "C++": cxx_compiler, + 'C': c_compiler, + 'C++': cxx_compiler, }[language] # Stolen from autoconf 2.13 ; might be irrelevant now, but it doesn't hurt to # keep using a char return type. comment = [ - "/* Override any gcc2 internal prototype to avoid an error. */", - "/* We use char because int might match the return type of a gcc2", - " builtin and then its argument prototype would still apply. */", + '/* Override any gcc2 internal prototype to avoid an error. */', + '/* We use char because int might match the return type of a gcc2', + ' builtin and then its argument prototype would still apply. */', ] return compiler.try_run( - header=comment + ["char %s();" % symbol], - body="%s();" % symbol, + header=comment + ['char %s();' % symbol], + body='%s();' % symbol, flags=flags, - check_msg="for %s" % symbol, + check_msg='for %s' % symbol, when=when, onerror=onerror, ) @@ -142,9 +126,8 @@ def check_symbol(symbol, language="C", flags=None, when=None, onerror=lambda: No # - `check`, when not set, skips checking whether the flag is supported and # adds it to the list of flags unconditionally. @template -def check_and_add_flags( - flag, flags_collection, test_flags, compiler=None, when=None, check=True -): +def check_and_add_flags(flag, flags_collection, test_flags, + compiler=None, when=None, check=True): if compiler is not None: compilers = (compiler,) else: @@ -161,34 +144,32 @@ def check_and_add_flags( flags = [flag] for c in compilers: - assert c in {c_compiler, cxx_compiler, host_c_compiler, host_cxx_compiler} + assert c in {c_compiler, cxx_compiler, + host_c_compiler, host_cxx_compiler} lang, list_of_flags = { - c_compiler: ("C", flags_collection.cflags), - cxx_compiler: ("C++", flags_collection.cxxflags), - host_c_compiler: ("host C", flags_collection.host_cflags), - host_cxx_compiler: ("host C++", flags_collection.host_cxxflags), + c_compiler: ('C', flags_collection.cflags), + cxx_compiler: ('C++', flags_collection.cxxflags), + host_c_compiler: ('host C', flags_collection.host_cflags), + host_cxx_compiler: ('host C++', flags_collection.host_cxxflags), }[c] @depends(c, when) def result(c, when): - if when and c.type in ("clang", "gcc"): + if when and c.type in ('clang', 'gcc'): return True if check: - @depends(c, dependable(flags)) def flags(c, flags): # Don't error out just because clang complains about other things. - if c.type == "clang": - flags += ["-Wno-error=unused-command-line-argument"] + if c.type == 'clang': + flags += ['-Wno-error=unused-command-line-argument'] return flags result = c.try_compile( - flags=flags, - when=result, - check_msg="whether the %s compiler supports %s" % (lang, flag), - ) + flags=flags, when=result, + check_msg='whether the %s compiler supports %s' % (lang, flag)) @depends(result, list_of_flags) def maybe_add_flag(result, list_of_flags): @@ -223,16 +204,15 @@ def check_and_add_gcc_warning(warning, compiler=None, when=None, check=True): # warning option like -Wno-foobar. So when we are checking for support # of a negated warning option, we actually test the positive form, but # add the negated form to the flags variable. - if warning.startswith("-Wno-") and not warning.startswith("-Wno-error="): - flags = ["-Werror", "-W" + warning[5:]] - elif warning.startswith("-Werror="): + if warning.startswith('-Wno-') and not warning.startswith('-Wno-error='): + flags = ['-Werror', '-W' + warning[5:]] + elif warning.startswith('-Werror='): flags = [warning] else: - flags = ["-Werror", warning] + flags = ['-Werror', warning] - return check_and_add_flags( - warning, warnings_flags, flags, compiler=compiler, when=when, check=check - ) + return check_and_add_flags(warning, warnings_flags, flags, + compiler=compiler, when=when, check=check) # Add the given warning to the list of warning flags for the build. @@ -268,11 +248,10 @@ def compilation_flags(): # add_gcc_flag(). @template def check_and_add_gcc_flag(flag, compiler=None, when=None, check=True): - flags = ["-Werror", flag] + flags = ['-Werror', flag] - return check_and_add_flags( - flag, compilation_flags, flags, compiler=compiler, when=when, check=check - ) + return check_and_add_flags(flag, compilation_flags, flags, + compiler=compiler, when=when, check=check) # Add the given flag to the list of flags for the build. diff --git a/build/moz.configure/compilers-util.configure b/build/moz.configure/compilers-util.configure index 1d8930347f58ef365c031d1be925ac10388ac724..501855c5c8419844f2d96bc9be31b076cf1e9608 100644 --- a/build/moz.configure/compilers-util.configure +++ b/build/moz.configure/compilers-util.configure @@ -6,8 +6,8 @@ @template -@imports("textwrap") -@imports(_from="mozbuild.configure", _import="SandboxDependsFunction") +@imports('textwrap') +@imports(_from='mozbuild.configure', _import='SandboxDependsFunction') def compiler_class(compiler, host_or_target): is_target = host_or_target is target @@ -24,34 +24,22 @@ def compiler_class(compiler, host_or_target): # `-c`. # - `check_msg` is the message to be printed to accompany compiling the # test program. - def try_compile( - self, - includes=None, - body="", - flags=None, - check_msg=None, - when=None, - onerror=lambda: None, - ): + def try_compile(self, includes=None, body='', flags=None, + check_msg=None, when=None, onerror=lambda: None): @depends(dependable(flags)) def flags(flags): flags = list(flags or []) - flags.append("-c") + flags.append('-c') return flags @depends(dependable(includes)) def header(includes): includes = includes or [] - return ["#include <%s>" % f for f in includes] + return ['#include <%s>' % f for f in includes] return self.try_run( - header=header, - body=body, - flags=flags, - check_msg=check_msg, - when=when, - onerror=onerror, - ) + header=header, body=body, flags=flags, check_msg=check_msg, + when=when, onerror=onerror) # Generates a test program and run the compiler against it. In case of # failure, the resulting check will return None. @@ -64,17 +52,9 @@ def compiler_class(compiler, host_or_target): # - `check_msg` is the message to be printed to accompany compiling the # test program. # - `onerror` is a function called when the check fails. - def try_run( - self, - header=None, - body="", - flags=None, - check_msg=None, - when=None, - onerror=lambda: None, - ): - source = textwrap.dedent( - """\ + def try_run(self, header=None, body='', flags=None, + check_msg=None, when=None, onerror=lambda: None): + source = textwrap.dedent('''\ int main(void) { @@ -82,51 +62,35 @@ def compiler_class(compiler, host_or_target): ; return 0; } - """ - % body - ) + ''' % body) if check_msg: - def checking_fn(fn): return checking(check_msg)(fn) - else: - def checking_fn(fn): return fn - @depends( - self, - dependable(flags), - extra_toolchain_flags, - stlport_cppflags, - dependable(header), - when=when, - ) + @depends(self, dependable(flags), extra_toolchain_flags, + stlport_cppflags, dependable(header), when=when) @checking_fn def func(compiler, flags, extra_flags, stlport_flags, header): flags = list(flags or []) if is_target: flags += extra_flags or [] - if compiler.language == "C++": + if compiler.language == 'C++': flags += stlport_flags or [] - header = header or "" + header = header or '' if isinstance(header, (list, tuple)): - header = "\n".join(header) + header = '\n'.join(header) if header: - header += "\n" + header += '\n' - if ( - try_invoke_compiler( - compiler.wrapper + [compiler.compiler] + compiler.flags, - compiler.language, - header + source, - flags, - onerror=onerror, - ) - is not None - ): + if try_invoke_compiler( + compiler.wrapper + + [compiler.compiler] + compiler.flags, + compiler.language, header + source, flags, + onerror=onerror) is not None: return True return func diff --git a/build/moz.configure/flags.configure b/build/moz.configure/flags.configure index e8bf6157b743f0e0e5776156249ea29716d203b0..a499470e554218a2b098b1a7843eb22b1cfee7e7 100644 --- a/build/moz.configure/flags.configure +++ b/build/moz.configure/flags.configure @@ -6,73 +6,60 @@ # We support C++14, but we don't want to enable the sized deallocation # facilities in C++14 yet. -check_and_add_gcc_flag("-fno-sized-deallocation", compiler=cxx_compiler) +check_and_add_gcc_flag('-fno-sized-deallocation', compiler=cxx_compiler) # Likewise for C++17 and aligned allocation. It's not immediately obvious # from the clang and GCC documentation, but they both support this. -check_and_add_gcc_flag("-fno-aligned-new", compiler=cxx_compiler) +check_and_add_gcc_flag('-fno-aligned-new', compiler=cxx_compiler) # Please keep these last in this file. -add_old_configure_assignment("_COMPILATION_CFLAGS", compilation_flags.cflags) -add_old_configure_assignment("_COMPILATION_CXXFLAGS", compilation_flags.cxxflags) -add_old_configure_assignment("_COMPILATION_HOST_CFLAGS", compilation_flags.host_cflags) +add_old_configure_assignment('_COMPILATION_CFLAGS', compilation_flags.cflags) add_old_configure_assignment( - "_COMPILATION_HOST_CXXFLAGS", compilation_flags.host_cxxflags -) + '_COMPILATION_CXXFLAGS', compilation_flags.cxxflags) +add_old_configure_assignment( + '_COMPILATION_HOST_CFLAGS', compilation_flags.host_cflags) +add_old_configure_assignment( + '_COMPILATION_HOST_CXXFLAGS', compilation_flags.host_cxxflags) @depends(rust_compile_flags, rust_warning_flags) def rust_flags(compile_flags, warning_flags): return compile_flags + warning_flags - -set_config("MOZ_RUST_DEFAULT_FLAGS", rust_flags) +set_config('MOZ_RUST_DEFAULT_FLAGS', rust_flags) -option( - "--disable-new-pass-manager", - help="Use the legacy LLVM pass manager in clang builds", -) +option('--disable-new-pass-manager', + help='Use the legacy LLVM pass manager in clang builds') - -@depends( - "--enable-new-pass-manager", - c_compiler, - host, - target, - "MOZ_PGO", - lto.enabled, - enable_fuzzing, - ubsan, -) -def new_pass_manager_flags( - enabled, compiler, host, target, pgo, lto, enable_fuzzing, ubsan -): - if host.os == "OSX": +@depends('--enable-new-pass-manager', c_compiler, host, target, 'MOZ_PGO', + lto.enabled, enable_fuzzing, ubsan) +def new_pass_manager_flags(enabled, compiler, host, target, pgo, lto, + enable_fuzzing, ubsan): + if host.os == 'OSX': # Some native Mac builds hang with the new pass manager. Given the # inability to test in CI, don't take the risk of further breakage. return None - if target.os == "OSX" and not pgo: + if target.os == 'OSX' and not pgo: # Also disable when cross-compiling to Mac, because plain-ish opt # builds hang. Variants like asan and ccov work fine, but it would be # too tedious to test them all here. PGO is the only thing that matters # enough to make an exception for. return None - if target.os == "WINNT" and target.cpu == "aarch64" and not lto: + if target.os == 'WINNT' and target.cpu == 'aarch64' and not lto: # Building without LTO on aarch64-windows fails on some large functions # because clang doesn't know how to split SEH unwind info. return None - if enable_fuzzing and compiler.version < "10.0.0": + if enable_fuzzing and compiler.version < '10.0.0': # Clang 9 does not seem to play well with libFuzzer return None - if ubsan and compiler.version >= "10.0.0": + if ubsan and compiler.version >= '10.0.0': # Temporary until https://bugs.llvm.org/show_bug.cgi?id=45835 gets a # real fix: clang 10 hangs with some ubsan-inserted code constructs. return None - if enabled and compiler.version >= "9.0.0": - if compiler.type == "clang": - return ["-fexperimental-new-pass-manager"] - elif compiler.type == "clang-cl": - return ["-Xclang", "-fexperimental-new-pass-manager"] - + if enabled and compiler.version >= '9.0.0': + if compiler.type == 'clang': + return ['-fexperimental-new-pass-manager'] + elif compiler.type == 'clang-cl': + return ['-Xclang', '-fexperimental-new-pass-manager'] -set_config("MOZ_NEW_PASS_MANAGER_FLAGS", new_pass_manager_flags) +set_config('MOZ_NEW_PASS_MANAGER_FLAGS', new_pass_manager_flags) diff --git a/build/moz.configure/headers.configure b/build/moz.configure/headers.configure index 843f5ad1052d9b1a65b620a2e6f3b0d83c686809..9445f10a4d538fad787542e49630a59497d173cc 100644 --- a/build/moz.configure/headers.configure +++ b/build/moz.configure/headers.configure @@ -5,97 +5,89 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # Check for headers defining standard int types. -check_header("stdint.h") -have_inttypes = check_header("inttypes.h") +check_header('stdint.h') +have_inttypes = check_header('inttypes.h') # Assume we have ansi C header files available. -set_define("STDC_HEADERS", True) +set_define('STDC_HEADERS', True) -set_config("HAVE_INTTYPES_H", have_inttypes) +set_config('HAVE_INTTYPES_H', have_inttypes) -building_linux = depends(target)(lambda target: target.kernel == "Linux") +building_linux = depends(target)(lambda target: target.kernel == 'Linux') -have_malloc = check_header("malloc.h") +have_malloc = check_header('malloc.h') -check_header("alloca.h") +check_header('alloca.h') -add_old_configure_assignment("HAVE_MALLOC_H", have_malloc) +add_old_configure_assignment('HAVE_MALLOC_H', have_malloc) check_headers( - "sys/byteorder.h", - "getopt.h", - "unistd.h", - "nl_types.h", - "cpuid.h", - "fts.h", + 'sys/byteorder.h', + 'getopt.h', + 'unistd.h', + 'nl_types.h', + 'cpuid.h', + 'fts.h', ) # These are all the places some variant of statfs can be hiding. check_headers( - "sys/statvfs.h", - "sys/statfs.h", - "sys/vfs.h", - "sys/mount.h", + 'sys/statvfs.h', + 'sys/statfs.h', + 'sys/vfs.h', + 'sys/mount.h', ) # Quota support # Check for both the header and quotactl() because Android headers can have the # header but not quotactl(). -set_define( - "HAVE_SYS_QUOTA_H", - try_compile( - includes=["sys/quota.h"], - body="quotactl(0, nullptr, 0, (caddr_t)nullptr);", - check_msg="for sys/quota.h", - ), -) -check_header("linux/quota.h", includes=["sys/socket.h"], when=building_linux) +set_define('HAVE_SYS_QUOTA_H', + try_compile(includes=['sys/quota.h'], + body='quotactl(0, nullptr, 0, (caddr_t)nullptr);', + check_msg='for sys/quota.h')) +check_header('linux/quota.h', + includes=['sys/socket.h'], + when=building_linux) # SCTP support - needs various network include headers check_headers( - "linux/if_addr.h", - "linux/rtnetlink.h", - includes=["sys/socket.h"], + 'linux/if_addr.h', + 'linux/rtnetlink.h', + includes=['sys/socket.h'], when=building_linux, ) -check_header("sys/queue.h") +check_header('sys/queue.h') check_headers( - "sys/types.h", - "netinet/in.h", - "byteswap.h", + 'sys/types.h', + 'netinet/in.h', + 'byteswap.h', ) # TODO: Move these checks to file specific to --enable-project=js. -have_perf_event_h = check_header("linux/perf_event.h", when=building_linux) +have_perf_event_h = check_header('linux/perf_event.h', + when=building_linux) -option( - "--with-linux-headers", - help="location where the Linux kernel headers can be found", - nargs=1, -) +option('--with-linux-headers', + help='location where the Linux kernel headers can be found', + nargs=1) -passed_linux_header_flags = depends_if("--with-linux-headers")( - lambda v: ["-I%s" % v[0]] -) +passed_linux_header_flags = depends_if( + '--with-linux-headers')(lambda v: ['-I%s' % v[0]]) -@depends( - try_compile( - includes=["asm/unistd.h"], - body="return sizeof(__NR_perf_event_open);", - flags=passed_linux_header_flags, - check_msg="for perf_event_open system call", - ), - when=have_perf_event_h, -) +@depends(try_compile(includes=['asm/unistd.h'], + body='return sizeof(__NR_perf_event_open);', + flags=passed_linux_header_flags, + check_msg='for perf_event_open system call'), + when=have_perf_event_h) def have_perf_event_open(have_perf_event_open): if have_perf_event_open: return True -set_config("HAVE_LINUX_PERF_EVENT_H", have_perf_event_open) +set_config('HAVE_LINUX_PERF_EVENT_H', have_perf_event_open) @depends(passed_linux_header_flags, have_perf_event_open) @@ -104,4 +96,4 @@ def linux_headers_includes(passed_linux_header_flags, have_perf_event_open): return passed_linux_header_flags[0] -set_config("LINUX_HEADERS_INCLUDES", linux_headers_includes) +set_config('LINUX_HEADERS_INCLUDES', linux_headers_includes) diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure index 4c6d73ee92f66dd5107dc97d4ab7ae7fba8b43b4..e9c9d2f0d5c304bcdaf8751c2bfabbc08f64d701 100644 --- a/build/moz.configure/init.configure +++ b/build/moz.configure/init.configure @@ -4,8 +4,8 @@ # 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("util.configure") -include("checks.configure") +include('util.configure') +include('checks.configure') # Make `toolkit` available when toolkit/moz.configure is not included. toolkit = dependable(None) @@ -13,23 +13,24 @@ toolkit = dependable(None) # build/moz.configure/bindgen.configure is not included. bindgen_config_paths = dependable(None) -option(env="DIST", nargs=1, help="DIST directory") +option(env='DIST', nargs=1, help='DIST directory') # Do not allow objdir == srcdir builds. # ============================================================== -@depends("--help", "DIST") -@imports(_from="__builtin__", _import="open") -@imports(_from="os.path", _import="exists") -@imports(_from="six", _import="ensure_text") +@depends('--help', 'DIST') +@imports(_from='__builtin__', _import='open') +@imports(_from='os.path', _import='exists') +@imports(_from='six', _import='ensure_text') def check_build_environment(help, dist): - topobjdir = os.path.realpath(".") - topsrcdir = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..")) + topobjdir = os.path.realpath('.') + topsrcdir = os.path.realpath( + os.path.join(os.path.dirname(__file__), '..', '..')) if dist: dist = normsep(dist[0]) else: - dist = os.path.join(topobjdir, "dist") + dist = os.path.join(topobjdir, 'dist') result = namespace( topsrcdir=topsrcdir, @@ -49,86 +50,87 @@ def check_build_environment(help, dist): # backend will make this limitation go away. But there is likely a long tail # of things that will need fixing due to e.g. lack of proper path quoting. if len(topsrcdir.split()) > 1: - die("Source directory cannot be located in a path with spaces: %s" % topsrcdir) + die('Source directory cannot be located in a path with spaces: %s' % + topsrcdir) if len(topobjdir.split()) > 1: - die("Object directory cannot be located in a path with spaces: %s" % topobjdir) + die('Object directory cannot be located in a path with spaces: %s' % + topobjdir) if topsrcdir == topobjdir: - die( - " ***\n" - " * Building directly in the main source directory is not allowed.\n" - " *\n" - " * To build, you must run configure from a separate directory\n" - " * (referred to as an object directory).\n" - " *\n" - " * If you are building with a mozconfig, you will need to change your\n" - " * mozconfig to point to a different object directory.\n" - " ***" - ) + die(' ***\n' + ' * Building directly in the main source directory is not allowed.\n' + ' *\n' + ' * To build, you must run configure from a separate directory\n' + ' * (referred to as an object directory).\n' + ' *\n' + ' * If you are building with a mozconfig, you will need to change your\n' + ' * mozconfig to point to a different object directory.\n' + ' ***' + ) # Check for CRLF line endings. - with open(os.path.join(topsrcdir, "configure.py"), "r") as fh: + with open(os.path.join(topsrcdir, 'configure.py'), 'r') as fh: data = ensure_text(fh.read()) - if "\r" in data: - die( - "\n ***\n" - " * The source tree appears to have Windows-style line endings.\n" - " *\n" - " * If using Git, Git is likely configured to use Windows-style\n" - " * line endings.\n" - " *\n" - " * To convert the working copy to UNIX-style line endings, run\n" - " * the following:\n" - " *\n" - " * $ git config core.autocrlf false\n" - " * $ git config core.eof lf\n" - " * $ git rm --cached -r .\n" - " * $ git reset --hard\n" - " *\n" - " * If not using Git, the tool you used to obtain the source\n" - " * code likely converted files to Windows line endings. See\n" - " * usage information for that tool for more.\n" - " ***" - ) + if '\r' in data: + die('\n ***\n' + ' * The source tree appears to have Windows-style line endings.\n' + ' *\n' + ' * If using Git, Git is likely configured to use Windows-style\n' + ' * line endings.\n' + ' *\n' + ' * To convert the working copy to UNIX-style line endings, run\n' + ' * the following:\n' + ' *\n' + ' * $ git config core.autocrlf false\n' + ' * $ git config core.eof lf\n' + ' * $ git rm --cached -r .\n' + ' * $ git reset --hard\n' + ' *\n' + ' * If not using Git, the tool you used to obtain the source\n' + ' * code likely converted files to Windows line endings. See\n' + ' * usage information for that tool for more.\n' + ' ***') # Check for a couple representative files in the source tree conflict_files = [ - "* %s" % f - for f in ("Makefile", "config/autoconf.mk") + '* %s' % f for f in ('Makefile', 'config/autoconf.mk') if exists(os.path.join(topsrcdir, f)) ] if conflict_files: - die( - " ***\n" - " * Your source tree contains these files:\n" - " %s\n" - " * This indicates that you previously built in the source tree.\n" - " * A source tree build can confuse the separate objdir build.\n" - " *\n" - " * To clean up the source tree:\n" - " * 1. cd %s\n" - " * 2. gmake distclean\n" - " ***" % ("\n ".join(conflict_files), topsrcdir) - ) + die(' ***\n' + ' * Your source tree contains these files:\n' + ' %s\n' + ' * This indicates that you previously built in the source tree.\n' + ' * A source tree build can confuse the separate objdir build.\n' + ' *\n' + ' * To clean up the source tree:\n' + ' * 1. cd %s\n' + ' * 2. gmake distclean\n' + ' ***' + % ('\n '.join(conflict_files), topsrcdir) + ) return result -set_config("TOPSRCDIR", check_build_environment.topsrcdir) -set_config("TOPOBJDIR", check_build_environment.topobjdir) -set_config("DIST", check_build_environment.dist) +set_config('TOPSRCDIR', check_build_environment.topsrcdir) +set_config('TOPOBJDIR', check_build_environment.topobjdir) +set_config('DIST', check_build_environment.dist) -add_old_configure_assignment("_topsrcdir", check_build_environment.topsrcdir) -add_old_configure_assignment("_objdir", check_build_environment.topobjdir) -add_old_configure_assignment("DIST", check_build_environment.dist) +add_old_configure_assignment( + '_topsrcdir', check_build_environment.topsrcdir) +add_old_configure_assignment( + '_objdir', check_build_environment.topobjdir) +add_old_configure_assignment( + 'DIST', check_build_environment.dist) -option(env="MOZ_AUTOMATION", help="Enable options for automated builds") -set_config("MOZ_AUTOMATION", depends_if("MOZ_AUTOMATION")(lambda x: True)) +option(env='MOZ_AUTOMATION', help='Enable options for automated builds') +set_config('MOZ_AUTOMATION', depends_if('MOZ_AUTOMATION')(lambda x: True)) -option(env="OLD_CONFIGURE", nargs=1, help="Path to the old configure script") +option(env='OLD_CONFIGURE', nargs=1, help='Path to the old configure script') -option(env="MOZCONFIG", nargs=1, help="Mozconfig location") +option(env='MOZCONFIG', nargs=1, help='Mozconfig location') # Read user mozconfig @@ -138,12 +140,13 @@ option(env="MOZCONFIG", nargs=1, help="Mozconfig location") # be called when --help is passed, and the mozconfig wouldn't be read. -@depends("MOZCONFIG", "OLD_CONFIGURE", check_build_environment, "--help") -@imports(_from="mozbuild.mozconfig", _import="MozconfigLoader") -@imports(_from="mozboot.mozconfig", _import="find_mozconfig") +@depends('MOZCONFIG', 'OLD_CONFIGURE', check_build_environment, + '--help') +@imports(_from='mozbuild.mozconfig', _import='MozconfigLoader') +@imports(_from='mozboot.mozconfig', _import='find_mozconfig') def mozconfig(mozconfig, old_configure, build_env, help): if not old_configure and not help: - die("The OLD_CONFIGURE environment variable must be set") + die('The OLD_CONFIGURE environment variable must be set') # Don't read the mozconfig for the js configure (yay backwards # compatibility) @@ -161,53 +164,52 @@ def mozconfig(mozconfig, old_configure, build_env, help): # OLD_CONFIGURE path, which points to js/src/old-configure. # I expect we'll have figured things out for mozconfigs well before # old-configure dies. - if old_configure and os.path.dirname(os.path.abspath(old_configure[0])).endswith( - "/js/src" - ): - return {"path": None} + if old_configure and os.path.dirname(os.path.abspath(old_configure[0])).endswith('/js/src'): + return {'path': None} topsrcdir = build_env.topsrcdir loader = MozconfigLoader(topsrcdir) mozconfig = mozconfig[0] if mozconfig else None - mozconfig = find_mozconfig(topsrcdir, env={"MOZCONFIG": mozconfig}) + mozconfig = find_mozconfig(topsrcdir, env={'MOZCONFIG': mozconfig}) mozconfig = loader.read_mozconfig(mozconfig) return mozconfig -set_config("MOZCONFIG", depends(mozconfig)(lambda m: m["path"])) +set_config('MOZCONFIG', depends(mozconfig)(lambda m: m['path'])) # Mozilla-Build # ============================================================== -option(env="MOZILLABUILD", nargs=1, help="Path to Mozilla Build (Windows-only)") +option(env='MOZILLABUILD', nargs=1, + help='Path to Mozilla Build (Windows-only)') -option(env="CONFIG_SHELL", nargs=1, help="Path to a POSIX shell") +option(env='CONFIG_SHELL', nargs=1, help='Path to a POSIX shell') # It feels dirty replicating this from python/mozbuild/mozbuild/mozconfig.py, # but the end goal being that the configure script would go away... -@depends("CONFIG_SHELL", "MOZILLABUILD") -@checking("for a shell") -@imports("sys") +@depends('CONFIG_SHELL', 'MOZILLABUILD') +@checking('for a shell') +@imports('sys') def shell(value, mozillabuild): if value: return find_program(value[0]) - shell = "sh" + shell = 'sh' if mozillabuild: - shell = mozillabuild[0] + "/msys/bin/sh" - if sys.platform == "win32": - shell = shell + ".exe" + shell = mozillabuild[0] + '/msys/bin/sh' + if sys.platform == 'win32': + shell = shell + '.exe' return find_program(shell) # This defines a reasonable shell for when running with --help. # If one was passed in the environment, though, fall back to that. -@depends("--help", "CONFIG_SHELL") +@depends('--help', 'CONFIG_SHELL') def help_shell(help, shell): if help and not shell: - return "sh" + return 'sh' shell = help_shell | shell @@ -216,28 +218,25 @@ shell = help_shell | shell # Python 3 # ======== -option(env="PYTHON3", nargs=1, help="Python 3 interpreter (3.6 or later)") - -option( - env="VIRTUALENV_NAME", - nargs=1, - default="init_py3", - help="Name of the in-objdir virtualenv", -) - - -@depends("PYTHON3", "VIRTUALENV_NAME", check_build_environment, mozconfig, "--help") -@imports(_from="__builtin__", _import="Exception") -@imports("os") -@imports("sys") -@imports("subprocess") -@imports("distutils.sysconfig") -@imports(_from="mozbuild.configure.util", _import="LineIO") -@imports(_from="mozbuild.virtualenv", _import="VirtualenvManager") -@imports(_from="mozbuild.virtualenv", _import="verify_python_version") -@imports(_from="mozbuild.pythonutil", _import="find_python3_executable") -@imports(_from="mozbuild.pythonutil", _import="python_executable_version") -@imports(_from="six", _import="ensure_text") +option(env='PYTHON3', nargs=1, help='Python 3 interpreter (3.6 or later)') + +option(env='VIRTUALENV_NAME', nargs=1, default='init_py3', + help='Name of the in-objdir virtualenv') + + +@depends('PYTHON3', 'VIRTUALENV_NAME', check_build_environment, mozconfig, + '--help') +@imports(_from='__builtin__', _import='Exception') +@imports('os') +@imports('sys') +@imports('subprocess') +@imports('distutils.sysconfig') +@imports(_from='mozbuild.configure.util', _import='LineIO') +@imports(_from='mozbuild.virtualenv', _import='VirtualenvManager') +@imports(_from='mozbuild.virtualenv', _import='verify_python_version') +@imports(_from='mozbuild.pythonutil', _import='find_python3_executable') +@imports(_from='mozbuild.pythonutil', _import='python_executable_version') +@imports(_from='six', _import='ensure_text') def virtualenv_python3(env_python, virtualenv_name, build_env, mozconfig, help): # Avoid re-executing python when running configure --help. if help: @@ -262,15 +261,15 @@ def virtualenv_python3(env_python, virtualenv_name, build_env, mozconfig, help): # Ideally we'd rely on the mozconfig injection from mozconfig_options, # but we'd rather avoid the verbosity when we need to reexecute with # a different python. - if mozconfig["path"]: - if "PYTHON3" in mozconfig["env"]["added"]: - python = mozconfig["env"]["added"]["PYTHON3"] - elif "PYTHON3" in mozconfig["env"]["modified"]: - python = mozconfig["env"]["modified"]["PYTHON3"][1] - elif "PYTHON3" in mozconfig["vars"]["added"]: - python = mozconfig["vars"]["added"]["PYTHON3"] - elif "PYTHON3" in mozconfig["vars"]["modified"]: - python = mozconfig["vars"]["modified"]["PYTHON3"][1] + if mozconfig['path']: + if 'PYTHON3' in mozconfig['env']['added']: + python = mozconfig['env']['added']['PYTHON3'] + elif 'PYTHON3' in mozconfig['env']['modified']: + python = mozconfig['env']['modified']['PYTHON3'][1] + elif 'PYTHON3' in mozconfig['vars']['added']: + python = mozconfig['vars']['added']['PYTHON3'] + elif 'PYTHON3' in mozconfig['vars']['modified']: + python = mozconfig['vars']['modified']['PYTHON3'][1] log.debug("python3: executable from configuration: %r" % python) @@ -285,27 +284,25 @@ def virtualenv_python3(env_python, virtualenv_name, build_env, mozconfig, help): # See mozilla-central changeset d2cce982a7c809815d86d5daecefe2e7a563ecca # Bug 784841 topsrcdir, topobjdir = build_env.topsrcdir, build_env.topobjdir - if topobjdir.endswith("/js/src"): + if topobjdir.endswith('/js/src'): topobjdir = topobjdir[:-7] - virtualenvs_root = os.path.join(topobjdir, "_virtualenvs") - with LineIO(lambda l: log.info(l), "replace") as out: + virtualenvs_root = os.path.join(topobjdir, '_virtualenvs') + with LineIO(lambda l: log.info(l), 'replace') as out: manager = VirtualenvManager( topsrcdir, - os.path.join(virtualenvs_root, virtualenv_name), - out, - os.path.join(topsrcdir, "build", "build_virtualenv_packages.txt"), - ) + os.path.join(virtualenvs_root, virtualenv_name), out, + os.path.join(topsrcdir, 'build', 'build_virtualenv_packages.txt')) # If we're not in the virtualenv, we need to update the path to include some # necessary modules for find_program. - if "MOZBUILD_VIRTUALENV" in os.environ: + if 'MOZBUILD_VIRTUALENV' in os.environ: python = sys.executable else: - sys.path.insert(0, os.path.join(topsrcdir, "testing", "mozbase", "mozfile")) sys.path.insert( - 0, os.path.join(topsrcdir, "third_party", "python", "backports") - ) + 0, os.path.join(topsrcdir, 'testing', 'mozbase', 'mozfile')) + sys.path.insert( + 0, os.path.join(topsrcdir, 'third_party', 'python', 'backports')) # If we know the Python executable the caller is asking for then verify its # version. If the caller did not ask for a specific executable then find @@ -313,44 +310,37 @@ def virtualenv_python3(env_python, virtualenv_name, build_env, mozconfig, help): if python: found_python = find_program(python) if not found_python: - die( - "The PYTHON3 environment variable does not contain " - "a valid path. Cannot find %s", - python, - ) + die('The PYTHON3 environment variable does not contain ' + 'a valid path. Cannot find %s', python) python = found_python try: version = python_executable_version(python).version except Exception as e: - raise FatalCheckError( - "could not determine version of PYTHON3 " "(%s): %s" % (python, e) - ) + raise FatalCheckError('could not determine version of PYTHON3 ' + '(%s): %s' % (python, e)) else: # Fall back to the search routine. - python, version = find_python3_executable(min_version="3.6.0") + python, version = find_python3_executable(min_version='3.6.0') # The API returns a bytes whereas everything in configure is unicode. if python: python = ensure_text(python) if not python: - raise FatalCheckError( - "Python 3.6 or newer is required to build. " - "Ensure a `python3.x` executable is in your " - "PATH or define PYTHON3 to point to a Python " - "3.6 executable." - ) + raise FatalCheckError('Python 3.6 or newer is required to build. ' + 'Ensure a `python3.x` executable is in your ' + 'PATH or define PYTHON3 to point to a Python ' + '3.6 executable.') if version < (3, 6, 0): - raise FatalCheckError( - "Python 3.6 or newer is required to build; " - "%s is Python %d.%d" % (python, version[0], version[1]) - ) + raise FatalCheckError('Python 3.6 or newer is required to build; ' + '%s is Python %d.%d' % (python, version[0], + version[1])) log.debug("python3: found executable: %r" % python) if not manager.up_to_date(python): - log.info("Creating Python 3 environment") + log.info('Creating Python 3 environment') manager.build(python) else: log.debug("python3: venv is up to date") @@ -358,35 +348,33 @@ def virtualenv_python3(env_python, virtualenv_name, build_env, mozconfig, help): python = normsep(manager.python_path) if not normsep(sys.executable).startswith(normsep(virtualenvs_root)): - log.debug( - "python3: executing as %s, should be running as %s" - % (sys.executable, manager.python_path) - ) - log.info("Re-executing in the virtualenv") + log.debug("python3: executing as %s, should be running as %s" % ( + sys.executable, manager.python_path)) + log.info('Re-executing in the virtualenv') if env_python: - del os.environ["PYTHON3"] + del os.environ['PYTHON3'] # Homebrew on macOS will change Python's sys.executable to a custom # value which messes with mach's virtualenv handling code. Override # Homebrew's changes with the correct sys.executable value. - os.environ["PYTHONEXECUTABLE"] = python + os.environ['PYTHONEXECUTABLE'] = python # Another quirk on macOS, with the system python, the virtualenv is # not fully operational (missing entries in sys.path) if # __PYVENV_LAUNCHER__ is set. - os.environ.pop("__PYVENV_LAUNCHER__", None) + os.environ.pop('__PYVENV_LAUNCHER__', None) # One would prefer to use os.execl, but that's completely borked on # Windows. sys.exit(subprocess.call([python] + sys.argv)) # We are now in the virtualenv if not distutils.sysconfig.get_python_lib(): - die("Could not determine python site packages directory") + die('Could not determine python site packages directory') # We may have set PYTHONEXECUTABLE above, and that affects python # subprocesses we may invoke as part of configure (e.g. hg), so # unset it. - os.environ.pop("PYTHONEXECUTABLE", None) + os.environ.pop('PYTHONEXECUTABLE', None) - str_version = ".".join(str(v) for v in version) + str_version = '.'.join(str(v) for v in version) return namespace( path=python, @@ -396,14 +384,14 @@ def virtualenv_python3(env_python, virtualenv_name, build_env, mozconfig, help): @depends(virtualenv_python3) -@checking("for Python 3", callback=lambda x: "%s (%s)" % (x.path, x.str_version)) +@checking('for Python 3', callback=lambda x: '%s (%s)' % (x.path, x.str_version)) def virtualenv_python3(venv): return venv -set_config("PYTHON3", virtualenv_python3.path) -set_config("PYTHON3_VERSION", virtualenv_python3.str_version) -add_old_configure_assignment("PYTHON3", virtualenv_python3.path) +set_config('PYTHON3', virtualenv_python3.path) +set_config('PYTHON3_VERSION', virtualenv_python3.str_version) +add_old_configure_assignment('PYTHON3', virtualenv_python3.path) # Inject mozconfig options @@ -414,64 +402,61 @@ add_old_configure_assignment("PYTHON3", virtualenv_python3.path) @template def early_options(): - @depends("--help") - @imports("__sandbox__") - @imports(_from="six", _import="itervalues") + @depends('--help') + @imports('__sandbox__') + @imports(_from='six', _import='itervalues') def early_options(_): return set( - option.env for option in itervalues(__sandbox__._options) if option.env + option.env + for option in itervalues(__sandbox__._options) + if option.env ) - return early_options early_options = early_options() -@depends(mozconfig, early_options, "MOZ_AUTOMATION", "--help") +@depends(mozconfig, early_options, 'MOZ_AUTOMATION', '--help') # This gives access to the sandbox. Don't copy this blindly. -@imports("__sandbox__") -@imports("os") -@imports("six") +@imports('__sandbox__') +@imports('os') +@imports('six') def mozconfig_options(mozconfig, early_options, automation, help): - if mozconfig["path"]: - if "MOZ_AUTOMATION_MOZCONFIG" in mozconfig["env"]["added"]: + if mozconfig['path']: + if 'MOZ_AUTOMATION_MOZCONFIG' in mozconfig['env']['added']: if not automation: - log.error( - "%s directly or indirectly includes an in-tree " "mozconfig.", - mozconfig["path"], - ) - log.error( - "In-tree mozconfigs make strong assumptions about " - "and are only meant to be used by Mozilla " - "automation." - ) + log.error('%s directly or indirectly includes an in-tree ' + 'mozconfig.', mozconfig['path']) + log.error('In-tree mozconfigs make strong assumptions about ' + 'and are only meant to be used by Mozilla ' + 'automation.') die("Please don't use them.") helper = __sandbox__._helper - log.info("Adding configure options from %s" % mozconfig["path"]) - for arg in mozconfig["configure_args"]: - log.info(" %s" % arg) + log.info('Adding configure options from %s' % mozconfig['path']) + for arg in mozconfig['configure_args']: + log.info(' %s' % arg) # We could be using imply_option() here, but it has other # contraints that don't really apply to the command-line # emulation that mozconfig provides. - helper.add(arg, origin="mozconfig", args=helper._args) + helper.add(arg, origin='mozconfig', args=helper._args) def add(key, value): if key.isupper(): - arg = "%s=%s" % (key, value) - log.info(" %s" % arg) + arg = '%s=%s' % (key, value) + log.info(' %s' % arg) if key not in early_options: - helper.add(arg, origin="mozconfig", args=helper._args) + helper.add(arg, origin='mozconfig', args=helper._args) - for key, value in six.iteritems(mozconfig["env"]["added"]): + for key, value in six.iteritems(mozconfig['env']['added']): add(key, value) os.environ[key] = value - for key, (_, value) in six.iteritems(mozconfig["env"]["modified"]): + for key, (_, value) in six.iteritems(mozconfig['env']['modified']): add(key, value) os.environ[key] = value - for key, value in six.iteritems(mozconfig["vars"]["added"]): + for key, value in six.iteritems(mozconfig['vars']['added']): add(key, value) - for key, (_, value) in six.iteritems(mozconfig["vars"]["modified"]): + for key, (_, value) in six.iteritems(mozconfig['vars']['modified']): add(key, value) @@ -479,199 +464,179 @@ def mozconfig_options(mozconfig, early_options, automation, help): # ================================================ -@depends(check_build_environment, "MOZ_AUTOMATION", "--help") -@checking("for vcs source checkout") -@imports("os") +@depends(check_build_environment, 'MOZ_AUTOMATION', '--help') +@checking('for vcs source checkout') +@imports('os') def vcs_checkout_type(build_env, automation, help): - if os.path.exists(os.path.join(build_env.topsrcdir, ".hg")): - return "hg" - elif os.path.exists(os.path.join(build_env.topsrcdir, ".git")): - return "git" + if os.path.exists(os.path.join(build_env.topsrcdir, '.hg')): + return 'hg' + elif os.path.exists(os.path.join(build_env.topsrcdir, '.git')): + return 'git' elif automation and not help: - raise FatalCheckError( - "unable to resolve VCS type; must run " - "from a source checkout when MOZ_AUTOMATION " - "is set" - ) - + raise FatalCheckError('unable to resolve VCS type; must run ' + 'from a source checkout when MOZ_AUTOMATION ' + 'is set') # Resolve VCS binary for detected repository type. # TODO remove hg.exe once bug 1382940 addresses ambiguous executables case. -hg = check_prog( - "HG", - ( - "hg.exe", - "hg", - ), - allow_missing=True, - when=depends(vcs_checkout_type)(lambda x: x == "hg"), -) -git = check_prog( - "GIT", - ("git",), - allow_missing=True, - when=depends(vcs_checkout_type)(lambda x: x == "git"), -) +hg = check_prog('HG', ('hg.exe', 'hg',), allow_missing=True, + when=depends(vcs_checkout_type)(lambda x: x == 'hg')) +git = check_prog('GIT', ('git',), allow_missing=True, + when=depends(vcs_checkout_type)(lambda x: x == 'git')) @depends_if(hg) -@checking("for Mercurial version") -@imports("os") -@imports("re") +@checking('for Mercurial version') +@imports('os') +@imports('re') def hg_version(hg): # HGPLAIN in Mercurial 1.5+ forces stable output, regardless of set # locale or encoding. env = dict(os.environ) - env["HGPLAIN"] = "1" + env['HGPLAIN'] = '1' - out = check_cmd_output(hg, "--version", env=env) + out = check_cmd_output(hg, '--version', env=env) - match = re.search(r"Mercurial Distributed SCM \(version ([^\)]+)", out) + match = re.search(r'Mercurial Distributed SCM \(version ([^\)]+)', out) if not match: - raise FatalCheckError("unable to determine Mercurial version: %s" % out) + raise FatalCheckError( + 'unable to determine Mercurial version: %s' % out) # The version string may be "unknown" for Mercurial run out of its own # source checkout or for bad builds. But LooseVersion handles it. return Version(match.group(1)) - # Resolve Mercurial config items so other checks have easy access. # Do NOT set this in the config because it may contain sensitive data # like API keys. @depends_all(check_build_environment, hg, hg_version) -@imports("os") +@imports('os') def hg_config(build_env, hg, version): env = dict(os.environ) - env["HGPLAIN"] = "1" + env['HGPLAIN'] = '1' # Warnings may get sent to stderr. But check_cmd_output() ignores # stderr if exit code is 0. And the command should always succeed if # `hg version` worked. - out = check_cmd_output(hg, "config", env=env, cwd=build_env.topsrcdir) + out = check_cmd_output(hg, 'config', env=env, cwd=build_env.topsrcdir) config = {} for line in out.strip().splitlines(): - key, value = [s.strip() for s in line.split("=", 1)] + key, value = [s.strip() for s in line.split('=', 1)] config[key] = value return config @depends_if(git) -@checking("for Git version") -@imports("re") +@checking('for Git version') +@imports('re') def git_version(git): - out = check_cmd_output(git, "--version").rstrip() + out = check_cmd_output(git, '--version').rstrip() - match = re.search("git version (.*)$", out) + match = re.search('git version (.*)$', out) if not match: - raise FatalCheckError("unable to determine Git version: %s" % out) + raise FatalCheckError('unable to determine Git version: %s' % out) return Version(match.group(1)) - # Only set VCS_CHECKOUT_TYPE if we resolved the VCS binary. # Require resolved VCS info when running in automation so automation's # environment is more well-defined. -@depends(vcs_checkout_type, hg_version, git_version, "MOZ_AUTOMATION") +@depends(vcs_checkout_type, hg_version, git_version, 'MOZ_AUTOMATION') def exposed_vcs_checkout_type(vcs_checkout_type, hg, git, automation): - if vcs_checkout_type == "hg": + if vcs_checkout_type == 'hg': if hg: - return "hg" + return 'hg' if automation: - raise FatalCheckError("could not resolve Mercurial binary info") + raise FatalCheckError('could not resolve Mercurial binary info') - elif vcs_checkout_type == "git": + elif vcs_checkout_type == 'git': if git: - return "git" + return 'git' if automation: - raise FatalCheckError("could not resolve Git binary info") + raise FatalCheckError('could not resolve Git binary info') elif vcs_checkout_type: - raise FatalCheckError("unhandled VCS type: %s" % vcs_checkout_type) + raise FatalCheckError('unhandled VCS type: %s' % vcs_checkout_type) -set_config("VCS_CHECKOUT_TYPE", exposed_vcs_checkout_type) +set_config('VCS_CHECKOUT_TYPE', exposed_vcs_checkout_type) # Obtain a Repository interface for the current VCS repository. @depends(check_build_environment, exposed_vcs_checkout_type, hg, git) -@imports(_from="mozversioncontrol", _import="get_repository_object") +@imports(_from='mozversioncontrol', _import='get_repository_object') def vcs_repository(build_env, vcs_checkout_type, hg, git): - if vcs_checkout_type == "hg": + if vcs_checkout_type == 'hg': return get_repository_object(build_env.topsrcdir, hg=hg) - elif vcs_checkout_type == "git": + elif vcs_checkout_type == 'git': return get_repository_object(build_env.topsrcdir, git=git) elif vcs_checkout_type: - raise FatalCheckError("unhandled VCS type: %s" % vcs_checkout_type) + raise FatalCheckError('unhandled VCS type: %s' % vcs_checkout_type) @depends_if(vcs_repository) -@checking("for sparse checkout") +@checking('for sparse checkout') def vcs_sparse_checkout(repo): return repo.sparse_checkout_present() -set_config("VCS_SPARSE_CHECKOUT", vcs_sparse_checkout) +set_config('VCS_SPARSE_CHECKOUT', vcs_sparse_checkout) # The application/project to build # ============================================================== -option( - "--enable-application", - nargs=1, - env="MOZ_BUILD_APP", - help="Application to build. Same as --enable-project.", -) +option('--enable-application', nargs=1, env='MOZ_BUILD_APP', + help='Application to build. Same as --enable-project.') -@depends("--enable-application") +@depends('--enable-application') def application(app): if app: return app -imply_option("--enable-project", application) +imply_option('--enable-project', application) @depends(check_build_environment) def default_project(build_env): - if build_env.topobjdir.endswith("/js/src"): - return "js" - return "browser" + if build_env.topobjdir.endswith('/js/src'): + return 'js' + return 'browser' -option("--enable-project", nargs=1, default=default_project, help="Project to build") +option('--enable-project', nargs=1, default=default_project, + help='Project to build') # Host and target systems # ============================================================== -option("--host", nargs=1, help="Define the system type performing the build") +option('--host', nargs=1, help='Define the system type performing the build') -option( - "--target", - nargs=1, - help="Define the system type where the resulting executables will be " "used", -) +option('--target', nargs=1, + help='Define the system type where the resulting executables will be ' + 'used') -@imports(_from="mozbuild.configure.constants", _import="CPU") -@imports(_from="mozbuild.configure.constants", _import="CPU_bitness") -@imports(_from="mozbuild.configure.constants", _import="Endianness") -@imports(_from="mozbuild.configure.constants", _import="Kernel") -@imports(_from="mozbuild.configure.constants", _import="OS") -@imports(_from="__builtin__", _import="ValueError") +@imports(_from='mozbuild.configure.constants', _import='CPU') +@imports(_from='mozbuild.configure.constants', _import='CPU_bitness') +@imports(_from='mozbuild.configure.constants', _import='Endianness') +@imports(_from='mozbuild.configure.constants', _import='Kernel') +@imports(_from='mozbuild.configure.constants', _import='OS') +@imports(_from='__builtin__', _import='ValueError') def split_triplet(triplet, allow_msvc=False): # The standard triplet is defined as # CPU_TYPE-VENDOR-OPERATING_SYSTEM @@ -681,8 +646,8 @@ def split_triplet(triplet, allow_msvc=False): # Additionally, some may omit "unknown" when the vendor # is not specified and emit # CPU_TYPE-OPERATING_SYSTEM - vendor = "unknown" - parts = triplet.split("-", 2) + vendor = 'unknown' + parts = triplet.split('-', 2) if len(parts) == 3: cpu, vendor, os = parts elif len(parts) == 2: @@ -699,101 +664,101 @@ def split_triplet(triplet, allow_msvc=False): # which can probably be improved/cleaned up because they are based on a # mix of uname and config.guess output, while we now only use the latter, # which presumably has a cleaner and leaner output. Let's refine later. - os = os.replace("/", "_") - if "android" in os: - canonical_os = "Android" - canonical_kernel = "Linux" - elif os.startswith("linux"): - canonical_os = "GNU" - canonical_kernel = "Linux" - elif os.startswith("kfreebsd") and os.endswith("-gnu"): - canonical_os = "GNU" - canonical_kernel = "kFreeBSD" - elif os.startswith("gnu"): - canonical_os = canonical_kernel = "GNU" - elif os.startswith("mingw") or (allow_msvc and os == "windows-msvc"): + os = os.replace('/', '_') + if 'android' in os: + canonical_os = 'Android' + canonical_kernel = 'Linux' + elif os.startswith('linux'): + canonical_os = 'GNU' + canonical_kernel = 'Linux' + elif os.startswith('kfreebsd') and os.endswith('-gnu'): + canonical_os = 'GNU' + canonical_kernel = 'kFreeBSD' + elif os.startswith('gnu'): + canonical_os = canonical_kernel = 'GNU' + elif os.startswith('mingw') or (allow_msvc and os == 'windows-msvc'): # windows-msvc is only opt-in for the caller of this function until # full support in bug 1617793. - canonical_os = canonical_kernel = "WINNT" - elif os.startswith("darwin"): - canonical_kernel = "Darwin" - canonical_os = "OSX" - elif os.startswith("dragonfly"): - canonical_os = canonical_kernel = "DragonFly" - elif os.startswith("freebsd"): - canonical_os = canonical_kernel = "FreeBSD" - elif os.startswith("netbsd"): - canonical_os = canonical_kernel = "NetBSD" - elif os.startswith("openbsd"): - canonical_os = canonical_kernel = "OpenBSD" - elif os.startswith("solaris"): - canonical_os = canonical_kernel = "SunOS" + canonical_os = canonical_kernel = 'WINNT' + elif os.startswith('darwin'): + canonical_kernel = 'Darwin' + canonical_os = 'OSX' + elif os.startswith('dragonfly'): + canonical_os = canonical_kernel = 'DragonFly' + elif os.startswith('freebsd'): + canonical_os = canonical_kernel = 'FreeBSD' + elif os.startswith('netbsd'): + canonical_os = canonical_kernel = 'NetBSD' + elif os.startswith('openbsd'): + canonical_os = canonical_kernel = 'OpenBSD' + elif os.startswith('solaris'): + canonical_os = canonical_kernel = 'SunOS' else: - raise ValueError("Unknown OS: %s" % os) + raise ValueError('Unknown OS: %s' % os) # The CPU granularity is probably not enough. Moving more things from # old-configure will tell us if we need more - if cpu.endswith("86") or (cpu.startswith("i") and "86" in cpu): - canonical_cpu = "x86" - endianness = "little" - elif cpu in ("x86_64", "ia64"): + if cpu.endswith('86') or (cpu.startswith('i') and '86' in cpu): + canonical_cpu = 'x86' + endianness = 'little' + elif cpu in ('x86_64', 'ia64'): canonical_cpu = cpu - endianness = "little" - elif cpu in ("s390", "s390x"): + endianness = 'little' + elif cpu in ('s390', 's390x'): canonical_cpu = cpu - endianness = "big" - elif cpu in ("powerpc64", "ppc64", "powerpc64le", "ppc64le"): - canonical_cpu = "ppc64" - endianness = "little" if "le" in cpu else "big" - elif cpu in ("powerpc", "ppc", "rs6000") or cpu.startswith("powerpc"): - canonical_cpu = "ppc" - endianness = "big" - elif cpu in ("Alpha", "alpha", "ALPHA"): - canonical_cpu = "Alpha" - endianness = "little" - elif cpu.startswith("hppa") or cpu == "parisc": - canonical_cpu = "hppa" - endianness = "big" - elif cpu.startswith("sparc64") or cpu.startswith("sparcv9"): - canonical_cpu = "sparc64" - endianness = "big" - elif cpu.startswith("sparc") or cpu == "sun4u": - canonical_cpu = "sparc" - endianness = "big" - elif cpu.startswith("arm"): - canonical_cpu = "arm" - endianness = "big" if cpu.startswith(("armeb", "armbe")) else "little" - elif cpu in ("m68k"): - canonical_cpu = "m68k" - endianness = "big" - elif cpu in ("mips", "mipsel"): - canonical_cpu = "mips32" - endianness = "little" if "el" in cpu else "big" - elif cpu in ("mips64", "mips64el"): - canonical_cpu = "mips64" - endianness = "little" if "el" in cpu else "big" - elif cpu.startswith("aarch64"): - canonical_cpu = "aarch64" - endianness = "little" - elif cpu in ("riscv64", "riscv64gc"): - canonical_cpu = "riscv64" - endianness = "little" - elif cpu == "sh4": - canonical_cpu = "sh4" - endianness = "little" + endianness = 'big' + elif cpu in ('powerpc64', 'ppc64', 'powerpc64le', 'ppc64le'): + canonical_cpu = 'ppc64' + endianness = 'little' if 'le' in cpu else 'big' + elif cpu in ('powerpc', 'ppc', 'rs6000') or cpu.startswith('powerpc'): + canonical_cpu = 'ppc' + endianness = 'big' + elif cpu in ('Alpha', 'alpha', 'ALPHA'): + canonical_cpu = 'Alpha' + endianness = 'little' + elif cpu.startswith('hppa') or cpu == 'parisc': + canonical_cpu = 'hppa' + endianness = 'big' + elif cpu.startswith('sparc64') or cpu.startswith('sparcv9'): + canonical_cpu = 'sparc64' + endianness = 'big' + elif cpu.startswith('sparc') or cpu == 'sun4u': + canonical_cpu = 'sparc' + endianness = 'big' + elif cpu.startswith('arm'): + canonical_cpu = 'arm' + endianness = 'big' if cpu.startswith(('armeb', 'armbe')) else 'little' + elif cpu in ('m68k'): + canonical_cpu = 'm68k' + endianness = 'big' + elif cpu in ('mips', 'mipsel'): + canonical_cpu = 'mips32' + endianness = 'little' if 'el' in cpu else 'big' + elif cpu in ('mips64', 'mips64el'): + canonical_cpu = 'mips64' + endianness = 'little' if 'el' in cpu else 'big' + elif cpu.startswith('aarch64'): + canonical_cpu = 'aarch64' + endianness = 'little' + elif cpu in ('riscv64', 'riscv64gc'): + canonical_cpu = 'riscv64' + endianness = 'little' + elif cpu == 'sh4': + canonical_cpu = 'sh4' + endianness = 'little' else: - raise ValueError("Unknown CPU type: %s" % cpu) + raise ValueError('Unknown CPU type: %s' % cpu) # Toolchains, most notably for cross compilation may use cpu-os # prefixes. We need to be more specific about the LLVM target on Mac # so cross-language LTO will work correctly. - if os.startswith("darwin"): - toolchain = "%s-apple-%s" % (cpu, os) - elif canonical_cpu == "aarch64" and canonical_os == "WINNT": - toolchain = "aarch64-windows-msvc" + if os.startswith('darwin'): + toolchain = '%s-apple-%s' % (cpu, os) + elif canonical_cpu == 'aarch64' and canonical_os == 'WINNT': + toolchain = 'aarch64-windows-msvc' else: - toolchain = "%s-%s" % (cpu, os) + toolchain = '%s-%s' % (cpu, os) return namespace( alias=triplet, @@ -812,53 +777,52 @@ def split_triplet(triplet, allow_msvc=False): # This defines a fake target/host namespace for when running with --help # If either --host or --target is passed on the command line, then fall # back to the real deal. -@depends("--help", "--host", "--target") +@depends('--help', '--host', '--target') def help_host_target(help, host, target): if help and not host and not target: return namespace( - alias="unknown-unknown-unknown", - cpu="unknown", - bitness="unknown", - kernel="unknown", - os="unknown", - endianness="unknown", - raw_cpu="unknown", - raw_os="unknown", - toolchain="unknown-unknown", + alias='unknown-unknown-unknown', + cpu='unknown', + bitness='unknown', + kernel='unknown', + os='unknown', + endianness='unknown', + raw_cpu='unknown', + raw_os='unknown', + toolchain='unknown-unknown', ) def config_sub(shell, triplet): - config_sub = os.path.join(os.path.dirname(__file__), "..", "autoconf", "config.sub") + config_sub = os.path.join(os.path.dirname(__file__), '..', + 'autoconf', 'config.sub') return check_cmd_output(shell, config_sub, triplet).strip() -@depends("--host", shell) -@checking("for host system type", lambda h: h.alias) -@imports("os") -@imports("sys") -@imports(_from="__builtin__", _import="ValueError") +@depends('--host', shell) +@checking('for host system type', lambda h: h.alias) +@imports('os') +@imports('sys') +@imports(_from='__builtin__', _import='ValueError') def real_host(value, shell): - if not value and sys.platform == "win32": - arch = os.environ.get("PROCESSOR_ARCHITEW6432") or os.environ.get( - "PROCESSOR_ARCHITECTURE" - ) - if arch == "AMD64": - return split_triplet("x86_64-pc-mingw32") - elif arch == "x86": - return split_triplet("i686-pc-mingw32") + if not value and sys.platform == 'win32': + arch = (os.environ.get('PROCESSOR_ARCHITEW6432') or + os.environ.get('PROCESSOR_ARCHITECTURE')) + if arch == 'AMD64': + return split_triplet('x86_64-pc-mingw32') + elif arch == 'x86': + return split_triplet('i686-pc-mingw32') if not value: - config_guess = os.path.join( - os.path.dirname(__file__), "..", "autoconf", "config.guess" - ) + config_guess = os.path.join(os.path.dirname(__file__), '..', + 'autoconf', 'config.guess') # Ensure that config.guess is determining the host triplet, not the target # triplet env = os.environ.copy() - env.pop("CC_FOR_BUILD", None) - env.pop("HOST_CC", None) - env.pop("CC", None) + env.pop('CC_FOR_BUILD', None) + env.pop('HOST_CC', None) + env.pop('CC', None) host = check_cmd_output(shell, config_guess, env=env).strip() try: @@ -879,9 +843,9 @@ def real_host(value, shell): host = help_host_target | real_host -@depends("--target", real_host, shell, "--enable-project", "--enable-application") -@checking("for target system type", lambda t: t.alias) -@imports(_from="__builtin__", _import="ValueError") +@depends('--target', real_host, shell, '--enable-project', '--enable-application') +@checking('for target system type', lambda t: t.alias) +@imports(_from='__builtin__', _import='ValueError') def real_target(value, host, shell, project, application): # Because --enable-project is implied by --enable-application, and # implied options are not currently handled during --help, which is @@ -894,27 +858,26 @@ def real_target(value, host, shell, project, application): elif project: project = project[0] if not value: - if project == "mobile/android": - if host.raw_os == "mingw32": + if project == 'mobile/android': + if host.raw_os == 'mingw32': log.warning( - "Building Firefox for Android on Windows is not fully " - "supported. See https://bugzilla.mozilla.org/show_bug.cgi?" - "id=1169873 for details." - ) - return split_triplet("arm-unknown-linux-androideabi") + 'Building Firefox for Android on Windows is not fully ' + 'supported. See https://bugzilla.mozilla.org/show_bug.cgi?' + 'id=1169873 for details.') + return split_triplet('arm-unknown-linux-androideabi') return host # If --target was only given a cpu arch, expand it with the # non-cpu part of the host. For mobile/android, expand it with # unknown-linux-android. target = value[0] - if "-" not in target: - if project == "mobile/android": - rest = "unknown-linux-android" - if target.startswith("arm"): - rest += "eabi" + if '-' not in target: + if project == 'mobile/android': + rest = 'unknown-linux-android' + if target.startswith('arm'): + rest += 'eabi' else: - cpu, rest = host.alias.split("-", 1) - target = "-".join((target, rest)) + cpu, rest = host.alias.split('-', 1) + target = '-'.join((target, rest)) try: return split_triplet(target) except ValueError: @@ -930,14 +893,14 @@ target = help_host_target | real_target @depends(host, target) -@checking("whether cross compiling") +@checking('whether cross compiling') def cross_compiling(host, target): return host != target -set_config("CROSS_COMPILE", cross_compiling) -set_define("CROSS_COMPILE", cross_compiling) -add_old_configure_assignment("CROSS_COMPILE", cross_compiling) +set_config('CROSS_COMPILE', cross_compiling) +set_define('CROSS_COMPILE', cross_compiling) +add_old_configure_assignment('CROSS_COMPILE', cross_compiling) @depends(target) @@ -946,42 +909,43 @@ def have_64_bit(target): return True -set_config("HAVE_64BIT_BUILD", have_64_bit) -set_define("HAVE_64BIT_BUILD", have_64_bit) -add_old_configure_assignment("HAVE_64BIT_BUILD", have_64_bit) +set_config('HAVE_64BIT_BUILD', have_64_bit) +set_define('HAVE_64BIT_BUILD', have_64_bit) +add_old_configure_assignment('HAVE_64BIT_BUILD', have_64_bit) @depends(host) def host_os_kernel_major_version(host): - versions = host.raw_os.split(".") - version = "".join(x for x in versions[0] if x.isdigit()) + versions = host.raw_os.split('.') + version = ''.join(x for x in versions[0] if x.isdigit()) return version -set_config("HOST_MAJOR_VERSION", host_os_kernel_major_version) +set_config('HOST_MAJOR_VERSION', host_os_kernel_major_version) # Autoconf needs these set @depends(host) def host_for_sub_configure(host): - return "--host=%s" % host.alias + return '--host=%s' % host.alias @depends(target) def target_for_sub_configure(target): target_alias = target.alias - return "--target=%s" % target_alias + return '--target=%s' % target_alias # These variables are for compatibility with the current moz.builds and # old-configure. Eventually, we'll want to canonicalize better. @depends(target) def target_variables(target): - if target.kernel == "kFreeBSD": - os_target = "GNU/kFreeBSD" - os_arch = "GNU_kFreeBSD" - elif target.kernel == "Darwin" or (target.kernel == "Linux" and target.os == "GNU"): + if target.kernel == 'kFreeBSD': + os_target = 'GNU/kFreeBSD' + os_arch = 'GNU_kFreeBSD' + elif target.kernel == 'Darwin' or (target.kernel == 'Linux' and + target.os == 'GNU'): os_target = target.kernel os_arch = target.kernel else: @@ -991,26 +955,28 @@ def target_variables(target): return namespace( OS_TARGET=os_target, OS_ARCH=os_arch, - INTEL_ARCHITECTURE=target.cpu in ("x86", "x86_64") or None, + INTEL_ARCHITECTURE=target.cpu in ('x86', 'x86_64') or None, ) -set_config("OS_TARGET", target_variables.OS_TARGET) -add_old_configure_assignment("OS_TARGET", target_variables.OS_TARGET) -set_config("OS_ARCH", target_variables.OS_ARCH) -add_old_configure_assignment("OS_ARCH", target_variables.OS_ARCH) -set_config("CPU_ARCH", target.cpu) -add_old_configure_assignment("CPU_ARCH", target.cpu) -set_config("INTEL_ARCHITECTURE", target_variables.INTEL_ARCHITECTURE) -set_config("TARGET_CPU", target.raw_cpu) -set_config("TARGET_OS", target.raw_os) -set_config("TARGET_ENDIANNESS", target.endianness) +set_config('OS_TARGET', target_variables.OS_TARGET) +add_old_configure_assignment('OS_TARGET', + target_variables.OS_TARGET) +set_config('OS_ARCH', target_variables.OS_ARCH) +add_old_configure_assignment('OS_ARCH', + target_variables.OS_ARCH) +set_config('CPU_ARCH', target.cpu) +add_old_configure_assignment('CPU_ARCH', target.cpu) +set_config('INTEL_ARCHITECTURE', target_variables.INTEL_ARCHITECTURE) +set_config('TARGET_CPU', target.raw_cpu) +set_config('TARGET_OS', target.raw_os) +set_config('TARGET_ENDIANNESS', target.endianness) @depends(host) def host_variables(host): - if host.kernel == "kFreeBSD": - os_arch = "GNU_kFreeBSD" + if host.kernel == 'kFreeBSD': + os_arch = 'GNU_kFreeBSD' else: os_arch = host.kernel return namespace( @@ -1018,200 +984,193 @@ def host_variables(host): ) -set_config("HOST_CPU_ARCH", host.cpu) -set_config("HOST_OS_ARCH", host_variables.HOST_OS_ARCH) -add_old_configure_assignment("HOST_OS_ARCH", host_variables.HOST_OS_ARCH) +set_config('HOST_CPU_ARCH', host.cpu) +set_config('HOST_OS_ARCH', host_variables.HOST_OS_ARCH) +add_old_configure_assignment('HOST_OS_ARCH', + host_variables.HOST_OS_ARCH) @depends(target) def target_is_windows(target): - if target.kernel == "WINNT": + if target.kernel == 'WINNT': return True -set_define("_WINDOWS", target_is_windows) -set_define("WIN32", target_is_windows) -set_define("XP_WIN", target_is_windows) +set_define('_WINDOWS', target_is_windows) +set_define('WIN32', target_is_windows) +set_define('XP_WIN', target_is_windows) @depends(target) def target_is_unix(target): - if target.kernel != "WINNT": + if target.kernel != 'WINNT': return True -set_define("XP_UNIX", target_is_unix) +set_define('XP_UNIX', target_is_unix) @depends(target) def target_is_darwin(target): - if target.kernel == "Darwin": + if target.kernel == 'Darwin': return True -set_define("XP_DARWIN", target_is_darwin) +set_define('XP_DARWIN', target_is_darwin) @depends(target) def target_is_osx(target): - if target.kernel == "Darwin" and target.os == "OSX": + if target.kernel == 'Darwin' and target.os == 'OSX': return True -set_define("XP_MACOSX", target_is_osx) +set_define('XP_MACOSX', target_is_osx) @depends(target) def target_is_linux(target): - if target.kernel == "Linux": + if target.kernel == 'Linux': return True -set_define("XP_LINUX", target_is_linux) +set_define('XP_LINUX', target_is_linux) @depends(target) def target_is_android(target): - if target.os == "Android": + if target.os == 'Android': return True -set_define("ANDROID", target_is_android) +set_define('ANDROID', target_is_android) @depends(target) def target_is_openbsd(target): - if target.kernel == "OpenBSD": + if target.kernel == 'OpenBSD': return True -set_define("XP_OPENBSD", target_is_openbsd) - +set_define('XP_OPENBSD', target_is_openbsd) @depends(target) def target_is_netbsd(target): - if target.kernel == "NetBSD": + if target.kernel == 'NetBSD': return True -set_define("XP_NETBSD", target_is_netbsd) - +set_define('XP_NETBSD', target_is_netbsd) @depends(target) def target_is_freebsd(target): - if target.kernel == "FreeBSD": + if target.kernel == 'FreeBSD': return True -set_define("XP_FREEBSD", target_is_freebsd) - +set_define('XP_FREEBSD', target_is_freebsd) @depends(target) def target_is_solaris(target): - if target.kernel == "SunOS": + if target.kernel == 'SunOS': return True -set_define("XP_SOLARIS", target_is_solaris) +set_define('XP_SOLARIS', target_is_solaris) @depends(target) def target_is_sparc(target): - if target.cpu == "sparc64": + if target.cpu == 'sparc64': return True - -set_define("SPARC64", target_is_sparc) +set_define('SPARC64', target_is_sparc) -@depends("--enable-project", check_build_environment, "--help") -@imports(_from="os.path", _import="exists") +@depends('--enable-project', check_build_environment, '--help') +@imports(_from='os.path', _import='exists') def include_project_configure(project, build_env, help): if not project: - die("--enable-project is required.") + die('--enable-project is required.') base_dir = build_env.topsrcdir - path = os.path.join(base_dir, project[0], "moz.configure") + path = os.path.join(base_dir, project[0], 'moz.configure') if not exists(path): - die("Cannot find project %s", project[0]) + die('Cannot find project %s', project[0]) return path @depends(include_project_configure, check_build_environment) def build_project(include_project_configure, build_env): - ret = os.path.dirname( - os.path.relpath(include_project_configure, build_env.topsrcdir) - ) + ret = os.path.dirname(os.path.relpath(include_project_configure, + build_env.topsrcdir)) return ret -set_config("MOZ_BUILD_APP", build_project) -set_define("MOZ_BUILD_APP", build_project) -add_old_configure_assignment("MOZ_BUILD_APP", build_project) +set_config('MOZ_BUILD_APP', build_project) +set_define('MOZ_BUILD_APP', build_project) +add_old_configure_assignment('MOZ_BUILD_APP', build_project) -option(env="MOZILLA_OFFICIAL", help="Build an official release") +option(env='MOZILLA_OFFICIAL', + help='Build an official release') -@depends("MOZILLA_OFFICIAL") +@depends('MOZILLA_OFFICIAL') def mozilla_official(official): if official: return True -set_config("MOZILLA_OFFICIAL", mozilla_official) -set_define("MOZILLA_OFFICIAL", mozilla_official) -add_old_configure_assignment("MOZILLA_OFFICIAL", mozilla_official) +set_config('MOZILLA_OFFICIAL', mozilla_official) +set_define('MOZILLA_OFFICIAL', mozilla_official) +add_old_configure_assignment('MOZILLA_OFFICIAL', mozilla_official) # Allow specifying custom paths to the version files used by the milestone() function below. -option( - "--with-version-file-path", - nargs=1, - help="Specify a custom path to app version files instead of auto-detecting", - default=None, -) - +option('--with-version-file-path', + nargs=1, + help='Specify a custom path to app version files instead of auto-detecting', + default=None) -@depends("--with-version-file-path") +@depends('--with-version-file-path') def version_path(path): return path - # set RELEASE_OR_BETA and NIGHTLY_BUILD variables depending on the cycle we're in # The logic works like this: # - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD) # - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora # - otherwise, we're building Release/Beta (define RELEASE_OR_BETA) -@depends(check_build_environment, build_project, version_path, "--help") -@imports(_from="__builtin__", _import="open") -@imports("os") -@imports("re") +@depends(check_build_environment, build_project, version_path, '--help') +@imports(_from='__builtin__', _import='open') +@imports('os') +@imports('re') def milestone(build_env, build_project, version_path, _): versions = [] - paths = ["config/milestone.txt"] - if build_project == "js": + paths = ['config/milestone.txt'] + if build_project == 'js': paths = paths * 3 else: paths += [ - "browser/config/version.txt", - "browser/config/version_display.txt", + 'browser/config/version.txt', + 'browser/config/version_display.txt', ] if version_path: version_path = version_path[0] else: - version_path = os.path.join(build_project, "config") - for f in ("version.txt", "version_display.txt"): + version_path = os.path.join(build_project, 'config') + for f in ('version.txt', 'version_display.txt'): f = os.path.join(version_path, f) if not os.path.exists(os.path.join(build_env.topsrcdir, f)): break paths.append(f) for p in paths: - with open(os.path.join(build_env.topsrcdir, p), "r") as fh: + with open(os.path.join(build_env.topsrcdir, p), 'r') as fh: content = fh.read().splitlines() if not content: - die("Could not find a version number in {}".format(p)) + die('Could not find a version number in {}'.format(p)) versions.append(content[-1]) milestone, firefox_version, firefox_version_display = versions[:3] @@ -1226,28 +1185,26 @@ def milestone(build_env, build_project, version_path, _): is_nightly = is_release_or_beta = is_early_beta_or_earlier = None - if "a1" in milestone: + if 'a1' in milestone: is_nightly = True - elif "a" not in milestone: + elif 'a' not in milestone: is_release_or_beta = True - major_version = milestone.split(".")[0] + major_version = milestone.split('.')[0] m = re.search(r"([ab]\d+)", milestone) - ab_patch = m.group(1) if m else "" + ab_patch = m.group(1) if m else '' - defines = os.path.join(build_env.topsrcdir, "build", "defines.sh") - with open(defines, "r") as fh: + defines = os.path.join(build_env.topsrcdir, 'build', 'defines.sh') + with open(defines, 'r') as fh: for line in fh.read().splitlines(): line = line.strip() - if not line or line.startswith("#"): + if not line or line.startswith('#'): continue - name, _, value = line.partition("=") + name, _, value = line.partition('=') name = name.strip() value = value.strip() - if name != "EARLY_BETA_OR_EARLIER": - die( - "Only the EARLY_BETA_OR_EARLIER variable can be set in build/defines.sh" - ) + if name != 'EARLY_BETA_OR_EARLIER': + die('Only the EARLY_BETA_OR_EARLIER variable can be set in build/defines.sh') if value: is_early_beta_or_earlier = True @@ -1256,41 +1213,39 @@ def milestone(build_env, build_project, version_path, _): # # Only expose major milestone and alpha version in the symbolversion # string; as the name suggests, we use it for symbol versioning on Linux. - return namespace( - version=milestone, - uaversion="%s.0" % major_version, - symbolversion="%s%s" % (major_version, ab_patch), - is_nightly=is_nightly, - is_release_or_beta=is_release_or_beta, - is_early_beta_or_earlier=is_early_beta_or_earlier, - app_version=app_version, - app_version_display=app_version_display, - ) - - -set_config("GRE_MILESTONE", milestone.version) -set_config("NIGHTLY_BUILD", milestone.is_nightly) -set_define("NIGHTLY_BUILD", milestone.is_nightly) -set_config("RELEASE_OR_BETA", milestone.is_release_or_beta) -set_define("RELEASE_OR_BETA", milestone.is_release_or_beta) -add_old_configure_assignment("RELEASE_OR_BETA", milestone.is_release_or_beta) -set_config("EARLY_BETA_OR_EARLIER", milestone.is_early_beta_or_earlier) -set_define("EARLY_BETA_OR_EARLIER", milestone.is_early_beta_or_earlier) -add_old_configure_assignment( - "EARLY_BETA_OR_EARLIER", milestone.is_early_beta_or_earlier -) -set_define("MOZILLA_VERSION", depends(milestone)(lambda m: '"%s"' % m.version)) -set_config("MOZILLA_VERSION", milestone.version) -set_define("MOZILLA_VERSION_U", milestone.version) -set_define("MOZILLA_UAVERSION", depends(milestone)(lambda m: '"%s"' % m.uaversion)) -set_config("MOZILLA_SYMBOLVERSION", milestone.symbolversion) + return namespace(version=milestone, + uaversion='%s.0' % major_version, + symbolversion='%s%s' % (major_version, ab_patch), + is_nightly=is_nightly, + is_release_or_beta=is_release_or_beta, + is_early_beta_or_earlier=is_early_beta_or_earlier, + app_version=app_version, + app_version_display=app_version_display) + + +set_config('GRE_MILESTONE', milestone.version) +set_config('NIGHTLY_BUILD', milestone.is_nightly) +set_define('NIGHTLY_BUILD', milestone.is_nightly) +set_config('RELEASE_OR_BETA', milestone.is_release_or_beta) +set_define('RELEASE_OR_BETA', milestone.is_release_or_beta) +add_old_configure_assignment('RELEASE_OR_BETA', + milestone.is_release_or_beta) +set_config('EARLY_BETA_OR_EARLIER', milestone.is_early_beta_or_earlier) +set_define('EARLY_BETA_OR_EARLIER', milestone.is_early_beta_or_earlier) +add_old_configure_assignment('EARLY_BETA_OR_EARLIER', + milestone.is_early_beta_or_earlier) +set_define('MOZILLA_VERSION', depends(milestone)(lambda m: '"%s"' % m.version)) +set_config('MOZILLA_VERSION', milestone.version) +set_define('MOZILLA_VERSION_U', milestone.version) +set_define('MOZILLA_UAVERSION', depends(milestone)(lambda m: '"%s"' % m.uaversion)) +set_config('MOZILLA_SYMBOLVERSION', milestone.symbolversion) # JS configure still wants to look at these. -add_old_configure_assignment("MOZILLA_VERSION", milestone.version) -add_old_configure_assignment("MOZILLA_SYMBOLVERSION", milestone.symbolversion) +add_old_configure_assignment('MOZILLA_VERSION', milestone.version) +add_old_configure_assignment('MOZILLA_SYMBOLVERSION', milestone.symbolversion) -set_config("MOZ_APP_VERSION", milestone.app_version) -set_config("MOZ_APP_VERSION_DISPLAY", milestone.app_version_display) -add_old_configure_assignment("MOZ_APP_VERSION", milestone.app_version) +set_config('MOZ_APP_VERSION', milestone.app_version) +set_config('MOZ_APP_VERSION_DISPLAY', milestone.app_version_display) +add_old_configure_assignment('MOZ_APP_VERSION', milestone.app_version) # Dummy function for availability in toolkit/moz.configure. Overridden in @@ -1303,40 +1258,35 @@ def fennec_nightly(is_nightly): # The app update channel is 'default' when not supplied. The value is used in # the application's confvars.sh (and is made available to a project specific # moz.configure). -option( - "--enable-update-channel", - nargs=1, - help="Select application update channel", - default="default", -) +option('--enable-update-channel', + nargs=1, + help='Select application update channel', + default='default') -@depends("--enable-update-channel") +@depends('--enable-update-channel') def update_channel(channel): - if not channel or channel[0] == "": - return "default" + if not channel or channel[0] == '': + return 'default' return channel[0].lower() -set_config("MOZ_UPDATE_CHANNEL", update_channel) -set_define("MOZ_UPDATE_CHANNEL", update_channel) -add_old_configure_assignment("MOZ_UPDATE_CHANNEL", update_channel) +set_config('MOZ_UPDATE_CHANNEL', update_channel) +set_define('MOZ_UPDATE_CHANNEL', update_channel) +add_old_configure_assignment('MOZ_UPDATE_CHANNEL', update_channel) -option( - env="MOZBUILD_STATE_PATH", - nargs=1, - help="Path to a persistent state directory for the build system " - "and related tools", -) +option(env='MOZBUILD_STATE_PATH', nargs=1, + help='Path to a persistent state directory for the build system ' + 'and related tools') -@depends("MOZBUILD_STATE_PATH", "--help") -@imports("os") +@depends('MOZBUILD_STATE_PATH', '--help') +@imports('os') def mozbuild_state_path(path, _): if path: return path[0] - return os.path.expanduser(os.path.join("~", ".mozbuild")) + return os.path.expanduser(os.path.join('~', '.mozbuild')) # A template providing a shorthand for setting a variable. The created @@ -1348,12 +1298,14 @@ def mozbuild_state_path(path, _): # add_old_configure_assignment. util.configure would be an appropriate place for # this, but it uses add_old_configure_assignment, which is defined in this file. @template -def project_flag(env=None, set_for_old_configure=False, set_as_define=False, **kwargs): +def project_flag(env=None, set_for_old_configure=False, + set_as_define=False, **kwargs): if not env: - configure_error("A project_flag must be passed a variable name to set.") + configure_error( + "A project_flag must be passed a variable name to set.") - opt = option(env=env, possible_origins=("implied",), **kwargs) + opt = option(env=env, possible_origins=('implied',), **kwargs) @depends(opt.option) def option_implementation(value): @@ -1368,41 +1320,29 @@ def project_flag(env=None, set_for_old_configure=False, set_as_define=False, **k if set_for_old_configure: add_old_configure_assignment(env, option_implementation) - # milestone.is_nightly corresponds to cases NIGHTLY_BUILD is set. - @depends(milestone) def enabled_in_nightly(milestone): return milestone.is_nightly - # Branding # ============================================================== -option( - "--with-app-basename", - env="MOZ_APP_BASENAME", - nargs=1, - help="Typically stays consistent for multiple branded versions of a " - 'given application (e.g. Aurora and Firefox both use "Firefox"), but ' - "may vary for full rebrandings (e.g. Iceweasel). Used for " - 'application.ini\'s "Name" field, which controls profile location in ' - 'the absence of a "Profile" field (see below), and various system ' - "integration hooks (Unix remoting, Windows MessageWindow name, etc.", -) - - -@depends("--with-app-basename", target_is_android) +option('--with-app-basename', env='MOZ_APP_BASENAME', nargs=1, + help='Typically stays consistent for multiple branded versions of a ' + 'given application (e.g. Aurora and Firefox both use "Firefox"), but ' + 'may vary for full rebrandings (e.g. Iceweasel). Used for ' + 'application.ini\'s "Name" field, which controls profile location in ' + 'the absence of a "Profile" field (see below), and various system ' + 'integration hooks (Unix remoting, Windows MessageWindow name, etc.') + +@depends('--with-app-basename', target_is_android) def moz_app_basename(value, target_is_android): if value: return value[0] if target_is_android: - return "Fennec" - return "Firefox" - + return 'Fennec' + return 'Firefox' -set_config( - "MOZ_APP_BASENAME", - moz_app_basename, - when=depends(build_project)(lambda p: p != "js"), -) +set_config('MOZ_APP_BASENAME', moz_app_basename, + when=depends(build_project)(lambda p: p != 'js')) diff --git a/build/moz.configure/java.configure b/build/moz.configure/java.configure index f45f3b77fb4aed34065b2afd4e9304da8dcaf934..b58e9817b3aa173e5470d74d9ce320250ccc4e53 100644 --- a/build/moz.configure/java.configure +++ b/build/moz.configure/java.configure @@ -7,37 +7,28 @@ # Java detection # ======================================================== -option( - "--with-java-bin-path", - nargs=1, - help="Location of Java binaries (java, jarsigner, keytool)", -) +option('--with-java-bin-path', nargs=1, + help='Location of Java binaries (java, jarsigner, keytool)') -@depends(host, "--with-java-bin-path") -@imports(_from="os", _import="environ") +@depends(host, '--with-java-bin-path') +@imports(_from='os', _import='environ') def java_search_paths(host, path): if path: # Look for javac and jar in the specified path. return path # With no path specified, look for javac and jar in $JAVA_HOME (if set), # JDK registery on Windows, and $PATH. - if "JAVA_HOME" in environ: - return [os.path.join(environ["JAVA_HOME"], "bin")] - if host.os == "WINNT": - for x in get_registry_values( - r"HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8\JavaHome", - get_32_and_64_bit=True, - ): - return [os.path.join(x[0], "bin")] - if host.os == "OSX": - home = check_cmd_output( - "/usr/libexec/java_home", "-v", "1.8", onerror=lambda: "" - ).rstrip() + if 'JAVA_HOME' in environ: + return [os.path.join(environ['JAVA_HOME'], 'bin')] + if host.os == 'WINNT': + for x in get_registry_values(r'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8\JavaHome', get_32_and_64_bit=True): + return [os.path.join(x[0], 'bin')] + if host.os == 'OSX': + home = check_cmd_output('/usr/libexec/java_home', '-v', '1.8', onerror=lambda: '').rstrip() if home: - return [os.path.join(home, "bin")] - return [environ.get("PATH")] - + return [os.path.join(home, 'bin')] + return [environ.get('PATH')] # Finds the given java tool, failing with a custom error message if we can't # find it. @@ -45,35 +36,27 @@ def java_search_paths(host, path): @template def check_java_tool(tool): - check = check_prog( - tool.upper(), (tool,), paths=java_search_paths, allow_missing=True - ) + check = check_prog(tool.upper(), (tool,), paths=java_search_paths, + allow_missing=True) @depends(check) def require_tool(result): if result is None: - die( - "The program %s was not found. Set $JAVA_HOME to your Java " - "SDK directory or use '--with-java-bin-path={java-bin-dir}'" % tool - ) + die("The program %s was not found. Set $JAVA_HOME to your Java " + "SDK directory or use '--with-java-bin-path={java-bin-dir}'" + % tool) return result return require_tool -check_java_tool("java") -check_java_tool("jarsigner") -check_java_tool("keytool") +check_java_tool('java') +check_java_tool('jarsigner') +check_java_tool('keytool') # Java Code Coverage # ======================================================== -option( - "--enable-java-coverage", - env="MOZ_JAVA_CODE_COVERAGE", - help="Enable Java code coverage", -) +option('--enable-java-coverage', env='MOZ_JAVA_CODE_COVERAGE', help='Enable Java code coverage') -set_config( - "MOZ_JAVA_CODE_COVERAGE", depends("--enable-java-coverage")(lambda v: bool(v)) -) +set_config('MOZ_JAVA_CODE_COVERAGE', depends('--enable-java-coverage')(lambda v: bool(v))) diff --git a/build/moz.configure/keyfiles.configure b/build/moz.configure/keyfiles.configure index 242a773aac214453ce8e2f6c2cbbde5b9260c869..5d51cccea2809614a5bf0bcc64b70131d29f8b97 100644 --- a/build/moz.configure/keyfiles.configure +++ b/build/moz.configure/keyfiles.configure @@ -7,18 +7,17 @@ @template def keyfile(desc, default=None, help=None, callback=lambda x: x): - help = help or ( - "Use the secret key contained in the given keyfile " "for %s requests" % desc - ) - name = desc.lower().replace(" ", "-") - no_key = callback("no-%s-key" % name) + help = help or ('Use the secret key contained in the given keyfile ' + 'for %s requests' % desc) + name = desc.lower().replace(' ', '-') + no_key = callback('no-%s-key' % name) - option("--with-%s-keyfile" % name, nargs=1, default=default, help=help) + option('--with-%s-keyfile' % name, nargs=1, default=default, help=help) - @depends("--with-%s-keyfile" % name) - @checking("for the %s key" % desc, lambda x: x and x is not no_key) - @imports(_from="__builtin__", _import="open") - @imports(_from="__builtin__", _import="IOError") + @depends('--with-%s-keyfile' % name) + @checking('for the %s key' % desc, lambda x: x and x is not no_key) + @imports(_from='__builtin__', _import='open') + @imports(_from='__builtin__', _import='IOError') def keyfile(value): if value: try: @@ -37,32 +36,29 @@ def keyfile(desc, default=None, help=None, callback=lambda x: x): @template def simple_keyfile(desc, default=None): value = keyfile(desc, default=default) - set_config("MOZ_%s_KEY" % desc.upper().replace(" ", "_"), value) + set_config('MOZ_%s_KEY' % desc.upper().replace(' ', '_'), value) @template def id_and_secret_keyfile(desc, default=None): def id_and_secret(value): - if value.startswith("no-") and value.endswith("-key"): - id = value[:-3] + "clientid" + if value.startswith('no-') and value.endswith('-key'): + id = value[:-3] + 'clientid' secret = value - elif " " in value: - id, secret = value.split(" ", 1) + elif ' ' in value: + id, secret = value.split(' ', 1) else: - raise FatalCheckError("%s key file has an invalid format." % desc) + raise FatalCheckError('%s key file has an invalid format.' % desc) return namespace( id=id, secret=secret, ) - content = keyfile( - desc, - help="Use the client id and secret key contained " - "in the given keyfile for %s requests" % desc, - default=default, - callback=id_and_secret, - ) + content = keyfile(desc, help='Use the client id and secret key contained ' + 'in the given keyfile for %s requests' % desc, + default=default, + callback=id_and_secret) - name = desc.upper().replace(" ", "_") - set_config("MOZ_%s_CLIENTID" % name, content.id) - set_config("MOZ_%s_KEY" % name, content.secret) + name = desc.upper().replace(' ', '_') + set_config('MOZ_%s_CLIENTID' % name, content.id) + set_config('MOZ_%s_KEY' % name, content.secret) diff --git a/build/moz.configure/lto-pgo.configure b/build/moz.configure/lto-pgo.configure index 2f32b1158807fd611a3465b5545d588cac37b7ca..c4436d24db3612880b50992f975428fb914ba230 100644 --- a/build/moz.configure/lto-pgo.configure +++ b/build/moz.configure/lto-pgo.configure @@ -6,134 +6,121 @@ # PGO # ============================================================== -llvm_profdata = check_prog( - "LLVM_PROFDATA", ["llvm-profdata"], allow_missing=True, paths=toolchain_search_path -) - -option( - "--enable-profile-generate", - env="MOZ_PROFILE_GENERATE", - nargs="?", - choices=("cross",), - help="Build a PGO instrumented binary", -) - -imply_option("MOZ_PGO", depends_if("--enable-profile-generate")(lambda _: True)) - -set_config( - "MOZ_PROFILE_GENERATE", depends_if("--enable-profile-generate")(lambda _: True) -) - -set_define( - "MOZ_PROFILE_GENERATE", depends_if("--enable-profile-generate")(lambda _: True) -) - -add_old_configure_assignment( - "MOZ_PROFILE_GENERATE", 1, when="--enable-profile-generate" -) - -option( - "--enable-profile-use", - env="MOZ_PROFILE_USE", - nargs="?", - choices=("cross",), - help="Use a generated profile during the build", -) - -option( - "--with-pgo-profile-path", - help="Path to the directory with unmerged profile data to use during the build", - nargs=1, -) - -imply_option("MOZ_PGO", depends_if("--enable-profile-use")(lambda _: True)) - -set_config("MOZ_PROFILE_USE", depends_if("--enable-profile-use")(lambda _: True)) - - -@depends( - "--with-pgo-profile-path", - "--enable-profile-use", - llvm_profdata, - check_build_environment, -) -@imports("os") +llvm_profdata = check_prog('LLVM_PROFDATA', ['llvm-profdata'], + allow_missing=True, + paths=toolchain_search_path) + +option('--enable-profile-generate', + env='MOZ_PROFILE_GENERATE', + nargs='?', + choices=('cross',), + help='Build a PGO instrumented binary') + +imply_option('MOZ_PGO', + depends_if('--enable-profile-generate')(lambda _: True)) + +set_config('MOZ_PROFILE_GENERATE', + depends_if('--enable-profile-generate')(lambda _: True)) + +set_define('MOZ_PROFILE_GENERATE', + depends_if('--enable-profile-generate')(lambda _: True)) + +add_old_configure_assignment('MOZ_PROFILE_GENERATE', 1, + when='--enable-profile-generate') + +option('--enable-profile-use', + env='MOZ_PROFILE_USE', + nargs='?', + choices=('cross',), + help='Use a generated profile during the build') + +option('--with-pgo-profile-path', + help='Path to the directory with unmerged profile data to use during the build', + nargs=1) + +imply_option('MOZ_PGO', + depends_if('--enable-profile-use')(lambda _: True)) + +set_config('MOZ_PROFILE_USE', + depends_if('--enable-profile-use')(lambda _: True)) + + +@depends('--with-pgo-profile-path', '--enable-profile-use', llvm_profdata, check_build_environment) +@imports('os') def pgo_profile_path(path, pgo_use, profdata, build_env): topobjdir = build_env.topobjdir - if topobjdir.endswith("/js/src"): + if topobjdir.endswith('/js/src'): topobjdir = topobjdir[:-7] if not path: - return os.path.join(topobjdir, "instrumented", "merged.profdata") + return os.path.join(topobjdir, 'instrumented', 'merged.profdata') if path and not pgo_use: - die("Pass --enable-profile-use to use --with-pgo-profile-path.") + die('Pass --enable-profile-use to use --with-pgo-profile-path.') if path and not profdata: - die("LLVM_PROFDATA must be set to process the pgo profile.") + die('LLVM_PROFDATA must be set to process the pgo profile.') if not os.path.isfile(path[0]): - die("Argument to --with-pgo-profile-path must be a file.") + die('Argument to --with-pgo-profile-path must be a file.') if not os.path.isabs(path[0]): - die("Argument to --with-pgo-profile-path must be an absolute path.") + die('Argument to --with-pgo-profile-path must be an absolute path.') return path[0] -set_config("PGO_PROFILE_PATH", pgo_profile_path) - +set_config('PGO_PROFILE_PATH', pgo_profile_path) @depends(c_compiler, pgo_profile_path, target_is_windows) -@imports("multiprocessing") -@imports(_from="__builtin__", _import="min") +@imports('multiprocessing') +@imports(_from='__builtin__', _import='min') def pgo_flags(compiler, profdata, target_is_windows): - if compiler.type == "gcc": + if compiler.type == 'gcc': return namespace( - gen_cflags=["-fprofile-generate"], - gen_ldflags=["-fprofile-generate"], - use_cflags=["-fprofile-use", "-fprofile-correction", "-Wcoverage-mismatch"], - use_ldflags=["-fprofile-use"], + gen_cflags=['-fprofile-generate'], + gen_ldflags=['-fprofile-generate'], + use_cflags=['-fprofile-use', '-fprofile-correction', + '-Wcoverage-mismatch'], + use_ldflags=['-fprofile-use'], ) - if compiler.type in ("clang-cl", "clang"): - prefix = "" - if compiler.type == "clang-cl": - prefix = "/clang:" + if compiler.type in ('clang-cl', 'clang'): + prefix = '' + if compiler.type == 'clang-cl': + prefix = '/clang:' gen_ldflags = None else: - gen_ldflags = ["-fprofile-generate"] + gen_ldflags = ['-fprofile-generate'] - gen_cflags = [prefix + "-fprofile-generate"] + gen_cflags = [prefix + '-fprofile-generate'] if target_is_windows: # native llvm-profdata.exe on Windows can't read profile data # if name compression is enabled (which cross-compiling enables # by default) - gen_cflags += ["-mllvm", "-enable-name-compression=false"] + gen_cflags += ['-mllvm', '-enable-name-compression=false'] return namespace( gen_cflags=gen_cflags, gen_ldflags=gen_ldflags, - use_cflags=[ - prefix + "-fprofile-use=%s" % profdata, - # Some error messages about mismatched profile data - # come in via -Wbackend-plugin, so disable those too. - "-Wno-error=backend-plugin", - ], + use_cflags=[prefix + '-fprofile-use=%s' % profdata, + # Some error messages about mismatched profile data + # come in via -Wbackend-plugin, so disable those too. + '-Wno-error=backend-plugin'], use_ldflags=[], ) -set_config("PROFILE_GEN_CFLAGS", pgo_flags.gen_cflags) -set_config("PROFILE_GEN_LDFLAGS", pgo_flags.gen_ldflags) -set_config("PROFILE_USE_CFLAGS", pgo_flags.use_cflags) -set_config("PROFILE_USE_LDFLAGS", pgo_flags.use_ldflags) +set_config('PROFILE_GEN_CFLAGS', pgo_flags.gen_cflags) +set_config('PROFILE_GEN_LDFLAGS', pgo_flags.gen_ldflags) +set_config('PROFILE_USE_CFLAGS', pgo_flags.use_cflags) +set_config('PROFILE_USE_LDFLAGS', pgo_flags.use_ldflags) -option( - "--with-pgo-jarlog", - help="Use the provided jarlog file when packaging during a profile-use " "build", - nargs=1, -) +option('--with-pgo-jarlog', + help='Use the provided jarlog file when packaging during a profile-use ' + 'build', + nargs=1) -set_config("PGO_JARLOG_PATH", depends_if("--with-pgo-jarlog")(lambda p: p)) +set_config('PGO_JARLOG_PATH', depends_if('--with-pgo-jarlog')(lambda p: p)) -@depends("MOZ_PGO", "--enable-profile-use", "--enable-profile-generate", c_compiler) +@depends('MOZ_PGO', '--enable-profile-use', '--enable-profile-generate', + c_compiler) def moz_pgo_rust(pgo, profile_use, profile_generate, c_compiler): if not pgo: return @@ -143,51 +130,38 @@ def moz_pgo_rust(pgo, profile_use, profile_generate, c_compiler): return if profile_use and profile_generate: - die("Cannot build with --enable-profile-use and --enable-profile-generate.") + die('Cannot build with --enable-profile-use and --enable-profile-generate.') - want_cross = (len(profile_use) and profile_use[0] == "cross") or ( - len(profile_generate) and profile_generate[0] == "cross" - ) + want_cross = (len(profile_use) and profile_use[0] == 'cross') \ + or (len(profile_generate) and profile_generate[0] == 'cross') if not want_cross: return - if c_compiler.type == "gcc": - die("Cannot use cross-language PGO with GCC.") + if c_compiler.type == 'gcc': + die('Cannot use cross-language PGO with GCC.') return True - -set_config("MOZ_PGO_RUST", moz_pgo_rust) +set_config('MOZ_PGO_RUST', moz_pgo_rust) # LTO # ============================================================== -option( - "--enable-lto", - env="MOZ_LTO", - nargs="?", - choices=("full", "thin", "cross"), - help="Enable LTO", -) - -option( - env="MOZ_LD64_KNOWN_GOOD", - nargs=1, - help="Indicate that ld64 is free of symbol aliasing bugs.", -) - -imply_option("MOZ_LD64_KNOWN_GOOD", depends_if("MOZ_AUTOMATION")(lambda _: True)) - - -@depends( - "--enable-lto", - c_compiler, - "MOZ_LD64_KNOWN_GOOD", - target, - "--enable-profile-generate", -) -@imports("multiprocessing") +option('--enable-lto', + env='MOZ_LTO', + nargs='?', + choices=('full', 'thin', 'cross'), + help='Enable LTO') + +option(env='MOZ_LD64_KNOWN_GOOD', + nargs=1, + help='Indicate that ld64 is free of symbol aliasing bugs.') + +imply_option('MOZ_LD64_KNOWN_GOOD', depends_if('MOZ_AUTOMATION')(lambda _: True)) + +@depends('--enable-lto', c_compiler, 'MOZ_LD64_KNOWN_GOOD', target, '--enable-profile-generate') +@imports('multiprocessing') def lto(value, c_compiler, ld64_known_good, target, instrumented_build): cflags = [] ldflags = [] @@ -196,48 +170,41 @@ def lto(value, c_compiler, ld64_known_good, target, instrumented_build): if value: if instrumented_build: - log.warning("Disabling LTO because --enable-profile-generate is specified") + log.warning('Disabling LTO because --enable-profile-generate is specified') return enabled = True # `cross` implies `thin`, but with Rust code participating in LTO # as well. Make that a little more explicit. - if len(value) and value[0].lower() == "cross": - if c_compiler.type == "gcc": - die("Cross-language LTO is not supported with GCC.") + if len(value) and value[0].lower() == 'cross': + if c_compiler.type == 'gcc': + die('Cross-language LTO is not supported with GCC.') rust_lto = True - value = ["thin"] - - if ( - target.kernel == "Darwin" - and target.os == "OSX" - and len(value) - and value[0].lower() == "cross" - and not ld64_known_good - ): - die( - "The Mac linker is known to have a bug that affects cross-language " - "LTO. If you know that your linker is free from this bug, please " - "set the environment variable `MOZ_LD64_KNOWN_GOOD=1` and re-run " - "configure." - ) - - if c_compiler.type == "clang": - if len(value) and value[0].lower() == "full": + value = ['thin'] + + if target.kernel == 'Darwin' and target.os == 'OSX' \ + and len(value) and value[0].lower() == 'cross' and not ld64_known_good: + die('The Mac linker is known to have a bug that affects cross-language ' + 'LTO. If you know that your linker is free from this bug, please ' + 'set the environment variable `MOZ_LD64_KNOWN_GOOD=1` and re-run ' + 'configure.') + + if c_compiler.type == 'clang': + if len(value) and value[0].lower() == 'full': cflags.append("-flto") ldflags.append("-flto") else: cflags.append("-flto=thin") ldflags.append("-flto=thin") - elif c_compiler.type == "clang-cl": - if len(value) and value[0].lower() == "full": + elif c_compiler.type == 'clang-cl': + if len(value) and value[0].lower() == 'full': cflags.append("-flto") else: cflags.append("-flto=thin") # With clang-cl, -flto can only be used with -c or -fuse-ld=lld. # AC_TRY_LINKs during configure don't have -c, so pass -fuse-ld=lld. - cflags.append("-fuse-ld=lld") + cflags.append("-fuse-ld=lld"); # Explicitly set the CPU to optimize for so the linker doesn't # choose a poor default. Rust compilation by default uses the @@ -253,19 +220,19 @@ def lto(value, c_compiler, ld64_known_good, target, instrumented_build): # specifically schedule code for the pentium4's deep pipeline, so # that probably contributes to it being an OK default for our # purposes. - if target.cpu == "x86": - ldflags.append("-mllvm:-mcpu=pentium4") + if target.cpu == 'x86': + ldflags.append('-mllvm:-mcpu=pentium4') # This is also the CPU that Rust uses. The LLVM source code # recommends this as the "generic 64-bit specific x86 processor model": # # https://github.com/llvm/llvm-project/blob/e7694f34ab6a12b8bb480cbfcb396d0a64fe965f/llvm/lib/Target/X86/X86.td#L1165-L1187 - if target.cpu == "x86_64": - ldflags.append("-mllvm:-mcpu=x86-64") + if target.cpu == 'x86_64': + ldflags.append('-mllvm:-mcpu=x86-64') # We do not need special flags for arm64. Hooray for fixed-length # instruction sets. else: num_cores = multiprocessing.cpu_count() - if len(value) and value[0].lower() == "full": + if len(value) and value[0].lower() == 'full': cflags.append("-flto") else: cflags.append("-flto=thin") @@ -277,12 +244,12 @@ def lto(value, c_compiler, ld64_known_good, target, instrumented_build): # Tell LTO not to inline functions above a certain size, to mitigate # binary size growth while still getting good performance. # (For hot functions, PGO will put a multiplier on this limit.) - if target.os == "WINNT": - ldflags.append("-mllvm:-import-instr-limit=10") - elif target.os == "OSX": - ldflags.append("-Wl,-mllvm,-import-instr-limit=10") - elif c_compiler.type == "clang": - ldflags.append("-Wl,-plugin-opt=-import-instr-limit=10") + if target.os == 'WINNT': + ldflags.append('-mllvm:-import-instr-limit=10'); + elif target.os == 'OSX': + ldflags.append('-Wl,-mllvm,-import-instr-limit=10'); + elif c_compiler.type == 'clang': + ldflags.append('-Wl,-plugin-opt=-import-instr-limit=10'); return namespace( enabled=enabled, @@ -292,11 +259,11 @@ def lto(value, c_compiler, ld64_known_good, target, instrumented_build): ) -add_old_configure_assignment("MOZ_LTO", lto.enabled) -set_config("MOZ_LTO", lto.enabled) -set_define("MOZ_LTO", lto.enabled) -set_config("MOZ_LTO_CFLAGS", lto.cflags) -set_config("MOZ_LTO_LDFLAGS", lto.ldflags) -set_config("MOZ_LTO_RUST_CROSS", lto.rust_lto) -add_old_configure_assignment("MOZ_LTO_CFLAGS", lto.cflags) -add_old_configure_assignment("MOZ_LTO_LDFLAGS", lto.ldflags) +add_old_configure_assignment('MOZ_LTO', lto.enabled) +set_config('MOZ_LTO', lto.enabled) +set_define('MOZ_LTO', lto.enabled) +set_config('MOZ_LTO_CFLAGS', lto.cflags) +set_config('MOZ_LTO_LDFLAGS', lto.ldflags) +set_config('MOZ_LTO_RUST_CROSS', lto.rust_lto) +add_old_configure_assignment('MOZ_LTO_CFLAGS', lto.cflags) +add_old_configure_assignment('MOZ_LTO_LDFLAGS', lto.ldflags) diff --git a/build/moz.configure/memory.configure b/build/moz.configure/memory.configure index 855706b457daca6eb54777abfb4621147eacaef8..b0f8548fb78b8641ecf8cb0dee90cc77c990a590 100644 --- a/build/moz.configure/memory.configure +++ b/build/moz.configure/memory.configure @@ -7,68 +7,55 @@ @depends(target) def jemalloc_default(target): - return target.kernel in ("Darwin", "Linux", "WINNT") + return target.kernel in ('Darwin', 'Linux', 'WINNT') -option( - "--enable-jemalloc", - env="MOZ_MEMORY", - default=jemalloc_default, - help="{Replace|Do not replace} memory allocator with jemalloc", -) +option('--enable-jemalloc', env='MOZ_MEMORY', default=jemalloc_default, + help='{Replace|Do not replace} memory allocator with jemalloc') -set_config("MOZ_MEMORY", True, when="--enable-jemalloc") -set_define("MOZ_MEMORY", True, when="--enable-jemalloc") -add_old_configure_assignment("MOZ_MEMORY", True, when="--enable-jemalloc") +set_config('MOZ_MEMORY', True, when='--enable-jemalloc') +set_define('MOZ_MEMORY', True, when='--enable-jemalloc') +add_old_configure_assignment('MOZ_MEMORY', True, when='--enable-jemalloc') @depends(milestone, build_project) def replace_malloc_default(milestone, build_project): - if build_project == "memory": + if build_project == 'memory': return True - if milestone.is_early_beta_or_earlier and build_project != "js": + if milestone.is_early_beta_or_earlier and build_project != 'js': return True -option( - "--enable-replace-malloc", - default=replace_malloc_default, - when="--enable-jemalloc", - help="{Enable|Disable} ability to dynamically replace the malloc implementation", -) +option('--enable-replace-malloc', default=replace_malloc_default, + when='--enable-jemalloc', + help='{Enable|Disable} ability to dynamically replace the malloc implementation') -set_config("MOZ_REPLACE_MALLOC", True, when="--enable-replace-malloc") -set_define("MOZ_REPLACE_MALLOC", True, when="--enable-replace-malloc") +set_config('MOZ_REPLACE_MALLOC', True, when='--enable-replace-malloc') +set_define('MOZ_REPLACE_MALLOC', True, when='--enable-replace-malloc') -@depends(build_project, when="--enable-replace-malloc") +@depends(build_project, when='--enable-replace-malloc') def replace_malloc_static(build_project): # Default to statically linking replace-malloc libraries that can be # statically linked, except when building with --enable-project=memory. - if build_project != "memory": + if build_project != 'memory': return True -set_config("MOZ_REPLACE_MALLOC_STATIC", replace_malloc_static) +set_config('MOZ_REPLACE_MALLOC_STATIC', replace_malloc_static) # PHC (Probabilistic Heap Checker) # ============================================================== # In general, it only makes sense for PHC to run on the platforms that have a # crash reporter. -@depends( - milestone, - target, - replace_malloc_default, - "--enable-replace-malloc", - when="--enable-jemalloc", -) +@depends(milestone, target, replace_malloc_default, '--enable-replace-malloc', + when='--enable-jemalloc') def phc_default(milestone, target, replace_malloc_default, replace_malloc): - if not replace_malloc_default or ( - replace_malloc.origin != "default" and not replace_malloc - ): + if not replace_malloc_default or \ + (replace_malloc.origin != 'default' and not replace_malloc): return False # Nightly or early beta only because PHC has a non-negligible performance cost. if not milestone.is_early_beta_or_earlier: @@ -78,21 +65,18 @@ def phc_default(milestone, target, replace_malloc_default, replace_malloc): # # XXX: PHC is implemented but not yet enabled on Mac. Bug 1576515 is about # enabling it on Mac, but it is blocked by bug 1035892. - return ( - target.os == "GNU" and target.kernel == "Linux" and target.bitness == 64 - ) or (target.kernel == "WINNT" and target.bitness == 64) + return (target.os == 'GNU' and target.kernel == 'Linux' and + target.bitness == 64) or \ + (target.kernel == 'WINNT' and target.bitness == 64) -option( - "--enable-phc", - env="MOZ_PHC", - default=phc_default, - when="--enable-jemalloc", - help="{Enable|Disable} PHC (Probabilistic Memory Checker). " - "Also enables replace-malloc and frame pointers", -) -imply_option("--enable-replace-malloc", True, when="--enable-phc") -imply_option("--enable-frame-pointers", True, when="--enable-phc") +option('--enable-phc', env='MOZ_PHC', default=phc_default, + when='--enable-jemalloc', + help='{Enable|Disable} PHC (Probabilistic Memory Checker). ' + 'Also enables replace-malloc and frame pointers') +imply_option('--enable-replace-malloc', True, when='--enable-phc') +imply_option('--enable-frame-pointers', True, when='--enable-phc') -set_config("MOZ_PHC", True, when="--enable-phc") +set_config('MOZ_PHC', True, when='--enable-phc') + diff --git a/build/moz.configure/node.configure b/build/moz.configure/node.configure index 1c8d55fa070f9e342d7748dcff83f838a5b9eb47..7e87a24424d38e3b69c87387c5bda9d97b42544c 100644 --- a/build/moz.configure/node.configure +++ b/build/moz.configure/node.configure @@ -4,49 +4,45 @@ # 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/. -option("--disable-nodejs", help="Require Node.js to build") -option(env="NODEJS", nargs=1, help="Path to nodejs") +option('--disable-nodejs', + help='Require Node.js to build') +option(env='NODEJS', nargs=1, help='Path to nodejs') -@depends("--enable-nodejs", "NODEJS") -@checking( - "for nodejs", callback=lambda x: "%s (%s)" % (x.path, x.str_version) if x else "no" -) -@imports(_from="mozbuild.nodeutil", _import="find_node_executable") -@imports(_from="mozbuild.nodeutil", _import="NODE_MIN_VERSION") +@depends('--enable-nodejs', 'NODEJS') +@checking('for nodejs', + callback=lambda x: '%s (%s)' % (x.path, x.str_version) if x else 'no') +@imports(_from='mozbuild.nodeutil', _import='find_node_executable') +@imports(_from='mozbuild.nodeutil', _import='NODE_MIN_VERSION') def nodejs(require, env_node): node_exe = env_node[0] if env_node else None nodejs, version = find_node_executable(node_exe) - MAYBE_FILE_A_BUG = """ + MAYBE_FILE_A_BUG = ''' Executing `mach bootstrap --no-system-changes` should install a compatible version in ~/.mozbuild on most platforms. If you believe this is a bug, is a good way to file. More details: - """ + ''' if not nodejs: - msg = ( - "could not find Node.js executable later than %s; ensure " - "`node` or `nodejs` is in PATH or set NODEJS in environment " - "to point to an executable.%s" % (NODE_MIN_VERSION, MAYBE_FILE_A_BUG) - ) + msg = ('could not find Node.js executable later than %s; ensure ' + '`node` or `nodejs` is in PATH or set NODEJS in environment ' + 'to point to an executable.%s' % (NODE_MIN_VERSION, MAYBE_FILE_A_BUG) + ) if require: raise FatalCheckError(msg) else: log.warning(msg) - log.warning("(This will become an error in the near future.)") + log.warning('(This will become an error in the near future.)') return if not version: - msg = "NODEJS must point to node %s or newer; found node location: %s. %s" % ( - NODE_MIN_VERSION, - nodejs, - MAYBE_FILE_A_BUG, - ) + msg = 'NODEJS must point to node %s or newer; found node location: %s. %s' % ( + NODE_MIN_VERSION, nodejs, MAYBE_FILE_A_BUG) if require: raise FatalCheckError(msg) @@ -57,8 +53,8 @@ def nodejs(require, env_node): return namespace( path=nodejs, version=version, - str_version=".".join(str(v) for v in version), + str_version='.'.join(str(v) for v in version), ) -set_config("NODEJS", depends_if(nodejs)(lambda p: p.path)) +set_config('NODEJS', depends_if(nodejs)(lambda p: p.path)) diff --git a/build/moz.configure/nspr.configure b/build/moz.configure/nspr.configure index 2b21a66f03b269275aa1619cc8864ba148d9cce1..0d6f73fff89d400916886bfb583f1eb3d233238e 100644 --- a/build/moz.configure/nspr.configure +++ b/build/moz.configure/nspr.configure @@ -6,66 +6,54 @@ # Top-level configure defaults to building NSPR from source. Standalone JS # doesn't. -option( - "--enable-nspr-build", - when=js_standalone, - help="{Build|Do not build} NSPR from source tree", -) +option('--enable-nspr-build', when=js_standalone, + help='{Build|Do not build} NSPR from source tree') - -@depends("--enable-nspr-build", when=js_standalone) +@depends('--enable-nspr-build', when=js_standalone) def enable_nspr_build(enable): if enable: return enable +option('--with-system-nspr', help='Use system NSPR') -option("--with-system-nspr", help="Use system NSPR") - - -@depends(enable_nspr_build, "--with-system-nspr", js_standalone) +@depends(enable_nspr_build, '--with-system-nspr', js_standalone) def build_nspr(nspr_build, system_nspr, js_standalone): - if nspr_build is not None and nspr_build.origin != "default": + if nspr_build is not None and nspr_build.origin != 'default': if nspr_build and system_nspr: - die("Cannot use both --enable-nspr-build and --with-system-nspr") + die('Cannot use both --enable-nspr-build and --with-system-nspr') if js_standalone: return nspr_build return not system_nspr +set_config('MOZ_BUILD_NSPR', True, when=build_nspr) +set_config('MOZ_SYSTEM_NSPR', True, when='--with-system-nspr') -set_config("MOZ_BUILD_NSPR", True, when=build_nspr) -set_config("MOZ_SYSTEM_NSPR", True, when="--with-system-nspr") - - -@depends(build_nspr, "--with-system-nspr", js_standalone) +@depends(build_nspr, '--with-system-nspr', js_standalone) def js_without_nspr(build_nspr, system_nspr, js_standalone): if js_standalone: return not build_nspr and not system_nspr - -set_config("JS_WITHOUT_NSPR", True, when=js_without_nspr) -set_define("JS_WITHOUT_NSPR", True, when=js_without_nspr) - +set_config('JS_WITHOUT_NSPR', True, when=js_without_nspr) +set_define('JS_WITHOUT_NSPR', True, when=js_without_nspr) @depends(js_standalone) def nspr_minver(js_standalone): if js_standalone: - return "nspr >= 4.10" - return "nspr >= 4.26" - - -nspr_pkg = pkg_check_modules("NSPR", nspr_minver, when="--with-system-nspr") + return 'nspr >= 4.10' + return 'nspr >= 4.26' +nspr_pkg = pkg_check_modules('NSPR', nspr_minver, when='--with-system-nspr') @depends_if(nspr_pkg) def nspr_pkg(nspr_pkg): def extract(prefix, list): for item in list: if item.startswith(prefix): - return item[len(prefix) :] - return "" + return item[len(prefix):] + return '' - include_dir = extract("-I", nspr_pkg.cflags) - lib_dir = extract("-L", nspr_pkg.libs) + include_dir = extract('-I', nspr_pkg.cflags) + lib_dir = extract('-L', nspr_pkg.libs) return namespace( cflags=nspr_pkg.cflags, include_dir=include_dir, @@ -73,45 +61,42 @@ def nspr_pkg(nspr_pkg): lib_dir=lib_dir, ) - -@depends("--with-system-nspr", nspr_minver) +@depends('--with-system-nspr', nspr_minver) def pkgconf_requires_private(system_nspr, nspr_minver): if not system_nspr: - return "" - return "Requires.private: %s" % nspr_minver - + return '' + return 'Requires.private: %s' % nspr_minver -set_config("PKGCONF_REQUIRES_PRIVATE", pkgconf_requires_private) +set_config('PKGCONF_REQUIRES_PRIVATE', pkgconf_requires_private) # pkg_check_modules takes care of NSPR_CFLAGS and NSPR_LIBS when using --with-system-nspr. @depends(check_build_environment, c_compiler, fold_libs, when=build_nspr) def nspr_config(build_env, c_compiler, fold_libs): - libs = ["nspr4", "plc4", "plds4"] - if c_compiler.type == "clang-cl": - lib_dir = os.path.join(build_env.dist, "lib") - libs = [os.path.join(lib_dir, "%s.lib" % lib) for lib in libs] + libs = ['nspr4', 'plc4', 'plds4'] + if c_compiler.type == 'clang-cl': + lib_dir = os.path.join(build_env.dist, 'lib') + libs = [os.path.join(lib_dir, '%s.lib' % lib) for lib in libs] else: - lib_dir = os.path.join(build_env.dist, "lib" if fold_libs else "bin") - libs = ["-L%s" % lib_dir] + ["-l%s" % lib for lib in libs] + lib_dir = os.path.join(build_env.dist, 'lib' if fold_libs else 'bin') + libs = ['-L%s' % lib_dir] + ['-l%s' % lib for lib in libs] - include_dir = os.path.join(build_env.dist, "include", "nspr") + include_dir = os.path.join(build_env.dist, 'include', 'nspr') return namespace( - cflags=["-I%s" % include_dir], + cflags=['-I%s' % include_dir], include_dir=include_dir, libs=libs, lib_dir=lib_dir, ) +set_config('NSPR_CFLAGS', nspr_config.cflags, when=nspr_config) +set_config('NSPR_LIBS', nspr_config.libs, when=nspr_config) -set_config("NSPR_CFLAGS", nspr_config.cflags, when=nspr_config) -set_config("NSPR_LIBS", nspr_config.libs, when=nspr_config) - -set_config("NSPR_INCLUDE_DIR", nspr_config.include_dir, when=nspr_config) -set_config("NSPR_LIB_DIR", nspr_config.lib_dir, when=nspr_config) -set_config("NSPR_INCLUDE_DIR", nspr_pkg.include_dir, when=nspr_pkg) -set_config("NSPR_LIB_DIR", nspr_pkg.lib_dir, when=nspr_pkg) +set_config('NSPR_INCLUDE_DIR', nspr_config.include_dir, when=nspr_config) +set_config('NSPR_LIB_DIR', nspr_config.lib_dir, when=nspr_config) +set_config('NSPR_INCLUDE_DIR', nspr_pkg.include_dir, when=nspr_pkg) +set_config('NSPR_LIB_DIR', nspr_pkg.lib_dir, when=nspr_pkg) -add_old_configure_assignment("NSPR_CFLAGS", nspr_config.cflags, when=nspr_config) -add_old_configure_assignment("NSPR_LIBS", nspr_config.libs, when=nspr_config) -add_old_configure_assignment("NSPR_CFLAGS", nspr_pkg.cflags, when=nspr_pkg) -add_old_configure_assignment("NSPR_LIBS", nspr_pkg.libs, when=nspr_pkg) +add_old_configure_assignment('NSPR_CFLAGS', nspr_config.cflags, when=nspr_config) +add_old_configure_assignment('NSPR_LIBS', nspr_config.libs, when=nspr_config) +add_old_configure_assignment('NSPR_CFLAGS', nspr_pkg.cflags, when=nspr_pkg) +add_old_configure_assignment('NSPR_LIBS', nspr_pkg.libs, when=nspr_pkg) diff --git a/build/moz.configure/nss.configure b/build/moz.configure/nss.configure index f3ac215885d4322b74cc35176107a55d0fc5e96f..b239f0532d3e1a6b0d220e7ec45c3379386dc956 100644 --- a/build/moz.configure/nss.configure +++ b/build/moz.configure/nss.configure @@ -4,20 +4,18 @@ # 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/. -option("--with-system-nss", help="Use system NSS") +option('--with-system-nss', help='Use system NSS') -imply_option("--with-system-nspr", True, when="--with-system-nss") +imply_option('--with-system-nspr', True, when='--with-system-nss') -nss_pkg = pkg_check_modules( - "NSS", "nss >= 3.59", when="--with-system-nss", config=False -) +nss_pkg = pkg_check_modules('NSS', 'nss >= 3.59', when='--with-system-nss', config=False) -set_config("MOZ_SYSTEM_NSS", True, when="--with-system-nss") +set_config('MOZ_SYSTEM_NSS', True, when='--with-system-nss') @depends(nss_pkg, check_build_environment) def nss_config(nss_pkg, build_env): - cflags = ["-I%s" % os.path.join(build_env.dist, "include", "nss")] + cflags = ['-I%s' % os.path.join(build_env.dist, 'include', 'nss')] libs = None if nss_pkg: cflags = list(nss_pkg.cflags) + cflags @@ -25,6 +23,6 @@ def nss_config(nss_pkg, build_env): return namespace(cflags=cflags, libs=libs) -set_config("NSS_CFLAGS", nss_config.cflags) -set_config("NSS_LIBS", nss_config.libs) -add_old_configure_assignment("NSS_CFLAGS", nss_config.cflags) +set_config('NSS_CFLAGS', nss_config.cflags) +set_config('NSS_LIBS', nss_config.libs) +add_old_configure_assignment('NSS_CFLAGS', nss_config.cflags) diff --git a/build/moz.configure/old.configure b/build/moz.configure/old.configure index 4c4987e1d4e9ffecb519dbe745171d76929e5784..8c807c0794fab7edb8896671669d867bc3e62df3 100644 --- a/build/moz.configure/old.configure +++ b/build/moz.configure/old.configure @@ -5,115 +5,113 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. -m4 = check_prog("M4", ("m4",)) +m4 = check_prog('M4', ('m4',)) @depends(mozconfig) def prepare_mozconfig(mozconfig): - if mozconfig["path"]: + if mozconfig['path']: items = {} - for key, value in mozconfig["vars"]["added"].items(): - items[key] = (value, "added") - for key, (old, value) in mozconfig["vars"]["modified"].items(): - items[key] = (value, "modified") - for t in ("env", "vars"): - for key in mozconfig[t]["removed"].keys(): - items[key] = (None, "removed " + t) + for key, value in mozconfig['vars']['added'].items(): + items[key] = (value, 'added') + for key, (old, value) in mozconfig['vars']['modified'].items(): + items[key] = (value, 'modified') + for t in ('env', 'vars'): + for key in mozconfig[t]['removed'].keys(): + items[key] = (None, 'removed ' + t) return items -@depends("OLD_CONFIGURE", build_project) +@depends('OLD_CONFIGURE', build_project) def old_configure(old_configure, build_project): # os.path.abspath in the sandbox will ensure forward slashes on Windows, # which is actually necessary because this path actually ends up literally # as $0, and backslashes there breaks autoconf's detection of the source # directory. old_configure = os.path.abspath(old_configure[0]) - if build_project == "js": + if build_project == 'js': old_configure_dir = os.path.dirname(old_configure) - if not old_configure_dir.endswith("/js/src"): - old_configure = os.path.join( - old_configure_dir, "js", "src", os.path.basename(old_configure) - ) + if not old_configure_dir.endswith('/js/src'): + old_configure = os.path.join(old_configure_dir, 'js', 'src', + os.path.basename(old_configure)) return old_configure @depends(prepare_mozconfig, old_configure_assignments) -@imports(_from="__builtin__", _import="open") -@imports(_from="__builtin__", _import="print") -@imports(_from="__builtin__", _import="sorted") -@imports(_from="mozbuild.shellutil", _import="quote") +@imports(_from='__builtin__', _import='open') +@imports(_from='__builtin__', _import='print') +@imports(_from='__builtin__', _import='sorted') +@imports(_from='mozbuild.shellutil', _import='quote') def prepare_configure(mozconfig, old_configure_assignments): - with open("old-configure.vars", "w") as out: - log.debug("Injecting the following to old-configure:") + with open('old-configure.vars', 'w') as out: + log.debug('Injecting the following to old-configure:') def inject(command): - print(command, file=out) # noqa Python 2vs3 - log.debug("| %s", command) + print(command, file=out) # noqa Python 2vs3 + log.debug('| %s', command) if mozconfig: - inject("# start of mozconfig values") + inject('# start of mozconfig values') for key, (value, action) in sorted(mozconfig.items()): - if action.startswith("removed "): - inject("unset %s # from %s" % (key, action[len("removed ") :])) + if action.startswith('removed '): + inject("unset %s # from %s" % ( + key, action[len('removed '):])) else: inject("%s=%s # %s" % (key, quote(value), action)) - inject("# end of mozconfig values") + inject('# end of mozconfig values') for k, v in old_configure_assignments: - inject("%s=%s" % (k, quote(v))) + inject('%s=%s' % (k, quote(v))) @template def old_configure_options(*options): for opt in options: - option(opt, nargs="*", help="Help missing for old configure options") + option(opt, nargs='*', help='Help missing for old configure options') @dependable def all_options(): return list(options) - return depends( - host_for_sub_configure, target_for_sub_configure, all_options, *options - ) + return depends(host_for_sub_configure, target_for_sub_configure, all_options, *options) @old_configure_options( - "--cache-file", - "--datadir", - "--enable-crashreporter", - "--enable-dbus", - "--enable-debug-js-modules", - "--enable-dump-painting", - "--enable-extensions", - "--enable-libproxy", - "--enable-logrefcnt", - "--enable-necko-wifi", - "--enable-negotiateauth", - "--enable-official-branding", - "--enable-parental-controls", - "--enable-sandbox", - "--enable-system-cairo", - "--enable-system-extension-dirs", - "--enable-system-pixman", - "--enable-universalchardet", - "--enable-updater", - "--enable-xul", - "--enable-zipwriter", - "--includedir", - "--libdir", - "--prefix", - "--with-android-max-sdk", - "--with-android-min-sdk", - "--with-branding", - "--with-distribution-id", - "--with-macbundlename-prefix", - "--with-system-libevent", - "--with-system-png", - "--with-user-appdir", - "--x-includes", - "--x-libraries", + '--cache-file', + '--datadir', + '--enable-crashreporter', + '--enable-dbus', + '--enable-debug-js-modules', + '--enable-dump-painting', + '--enable-extensions', + '--enable-libproxy', + '--enable-logrefcnt', + '--enable-necko-wifi', + '--enable-negotiateauth', + '--enable-official-branding', + '--enable-parental-controls', + '--enable-sandbox', + '--enable-system-cairo', + '--enable-system-extension-dirs', + '--enable-system-pixman', + '--enable-universalchardet', + '--enable-updater', + '--enable-xul', + '--enable-zipwriter', + '--includedir', + '--libdir', + '--prefix', + '--with-android-max-sdk', + '--with-android-min-sdk', + '--with-branding', + '--with-distribution-id', + '--with-macbundlename-prefix', + '--with-system-libevent', + '--with-system-png', + '--with-user-appdir', + '--x-includes', + '--x-libraries', ) def prepare_configure_options(host, target, all_options, *options): # old-configure only supports the options listed in @old_configure_options @@ -122,7 +120,7 @@ def prepare_configure_options(host, target, all_options, *options): options = [ value.format(name) for name, value in zip(all_options, options) - if value.origin != "default" + if value.origin != 'default' ] + [host, target] return namespace(options=options, all_options=all_options) @@ -133,57 +131,36 @@ def old_configure_for(old_configure_path, extra_env=None): if extra_env is None: extra_env = dependable(None) - @depends( - prepare_configure, - prepare_configure_options, - altered_path, - extra_env, - check_build_environment, - old_configure_path, - "MOZILLABUILD", - awk, - m4, - shell, - ) - @imports(_from="__builtin__", _import="compile") - @imports(_from="__builtin__", _import="open") - @imports(_from="__builtin__", _import="OSError") - @imports("glob") - @imports("itertools") - @imports("logging") - @imports("os") - @imports("subprocess") - @imports("sys") - @imports(_from="mozbuild.shellutil", _import="quote") - @imports(_from="mozbuild.shellutil", _import="split") - @imports(_from="tempfile", _import="NamedTemporaryFile") - @imports(_from="subprocess", _import="CalledProcessError") - @imports(_from="six", _import="exec_") - @imports(_from="six", _import="iteritems") - @imports(_from="six", _import="string_types") - def old_configure( - prepare_configure, - prepare_configure_options, - altered_path, - extra_env, - build_env, - old_configure, - mozillabuild, - awk, - m4, - shell, - ): + @depends(prepare_configure, prepare_configure_options, altered_path, extra_env, + check_build_environment, old_configure_path, 'MOZILLABUILD', awk, m4, shell) + @imports(_from='__builtin__', _import='compile') + @imports(_from='__builtin__', _import='open') + @imports(_from='__builtin__', _import='OSError') + @imports('glob') + @imports('itertools') + @imports('logging') + @imports('os') + @imports('subprocess') + @imports('sys') + @imports(_from='mozbuild.shellutil', _import='quote') + @imports(_from='mozbuild.shellutil', _import='split') + @imports(_from='tempfile', _import='NamedTemporaryFile') + @imports(_from='subprocess', _import='CalledProcessError') + @imports(_from='six', _import='exec_') + @imports(_from='six', _import='iteritems') + @imports(_from='six', _import='string_types') + def old_configure(prepare_configure, prepare_configure_options, altered_path, extra_env, + build_env, old_configure, mozillabuild, awk, m4, shell): # Use prepare_configure to make lint happy prepare_configure refresh = True if os.path.exists(old_configure): mtime = os.path.getmtime(old_configure) - aclocal = os.path.join(build_env.topsrcdir, "build", "autoconf", "*.m4") + aclocal = os.path.join(build_env.topsrcdir, 'build', 'autoconf', + '*.m4') for input in itertools.chain( - ( - old_configure + ".in", - os.path.join(os.path.dirname(old_configure), "aclocal.m4"), - ), + (old_configure + '.in', + os.path.join(os.path.dirname(old_configure), 'aclocal.m4')), glob.iglob(aclocal), ): if os.path.getmtime(input) > mtime: @@ -192,54 +169,40 @@ def old_configure_for(old_configure_path, extra_env=None): refresh = False if refresh: - autoconf = os.path.join( - build_env.topsrcdir, "build", "autoconf", "autoconf.sh" - ) - log.info("Refreshing %s with %s", old_configure, autoconf) + autoconf = os.path.join(build_env.topsrcdir, 'build', 'autoconf', 'autoconf.sh') + log.info('Refreshing %s with %s', old_configure, autoconf) env = dict(os.environ) - env["M4"] = m4 - env["AWK"] = awk - env["AC_MACRODIR"] = os.path.join(build_env.topsrcdir, "build", "autoconf") + env['M4'] = m4 + env['AWK'] = awk + env['AC_MACRODIR'] = os.path.join(build_env.topsrcdir, 'build', 'autoconf') try: - script = subprocess.check_output( - [ - shell, - autoconf, - "--localdir=%s" % os.path.dirname(old_configure), - old_configure + ".in", - ], - env=env, - ) + script = subprocess.check_output([ + shell, autoconf, + '--localdir=%s' % os.path.dirname(old_configure), + old_configure + '.in'], env=env) except CalledProcessError as exc: # Autoconf on win32 may break due to a bad $PATH. Let the user know # their $PATH is suspect. if mozillabuild: mozillabuild_path = normsep(mozillabuild[0]) - sh_path = normsep(find_program("sh")) + sh_path = normsep(find_program('sh')) if mozillabuild_path not in sh_path: - log.warning( - "The '{}msys/bin' directory is not first in $PATH. " - "This may cause autoconf to fail. ($PATH is currently " - "set to: {})".format(mozillabuild_path, os.environ["PATH"]) - ) - die("autoconf exited with return code {}".format(exc.returncode)) + log.warning("The '{}msys/bin' directory is not first in $PATH. " + "This may cause autoconf to fail. ($PATH is currently " + "set to: {})".format(mozillabuild_path, os.environ[ + 'PATH'])) + die('autoconf exited with return code {}'.format(exc.returncode)) if not script: - die( - "Generated old-configure is empty! Check that your autoconf 2.13 program works!" - ) + die('Generated old-configure is empty! Check that your autoconf 2.13 program works!') # Make old-configure append to config.log, where we put our own log. # This could be done with a m4 macro, but it's way easier this way - script = script.replace(b">./config.log", b">>${CONFIG_LOG=./config.log}") - - with NamedTemporaryFile( - mode="wb", - prefix=os.path.basename(old_configure), - dir=os.path.dirname(old_configure), - delete=False, - ) as fh: + script = script.replace(b'>./config.log', b'>>${CONFIG_LOG=./config.log}') + + with NamedTemporaryFile(mode='wb', prefix=os.path.basename(old_configure), + dir=os.path.dirname(old_configure), delete=False) as fh: fh.write(script) try: @@ -250,40 +213,37 @@ def old_configure_for(old_configure_path, extra_env=None): os.remove(old_configure) os.rename(fh.name, old_configure) except OSError as e: - die("Failed re-creating old-configure: %s" % e.message) + die('Failed re-creating old-configure: %s' % e.message) cmd = [shell, old_configure] + prepare_configure_options.options env = dict(os.environ) # For debugging purpose, in case it's not what we'd expect. - log.debug("Running %s", quote(*cmd)) + log.debug('Running %s', quote(*cmd)) # Our logging goes to config.log, the same file old.configure uses. # We can't share the handle on the file, so close it. - logger = logging.getLogger("moz.configure") + logger = logging.getLogger('moz.configure') config_log = None for handler in logger.handlers: if isinstance(handler, logging.FileHandler): config_log = handler config_log.close() logger.removeHandler(config_log) - env["CONFIG_LOG"] = config_log.baseFilename + env['CONFIG_LOG'] = config_log.baseFilename log_size = os.path.getsize(config_log.baseFilename) break if altered_path: - env["PATH"] = altered_path + env['PATH'] = altered_path if extra_env: env.update(extra_env) - env["OLD_CONFIGURE_VARS"] = os.path.join( - build_env.topobjdir, "old-configure.vars" - ) - proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env - ) + env['OLD_CONFIGURE_VARS'] = os.path.join(build_env.topobjdir, 'old-configure.vars') + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + env=env) while True: line = proc.stdout.readline() if not line: @@ -294,58 +254,53 @@ def old_configure_for(old_configure_path, extra_env=None): if ret: with log.queue_debug(): if config_log: - with open(config_log.baseFilename, "r") as fh: + with open(config_log.baseFilename, 'r') as fh: fh.seek(log_size) for line in fh: log.debug(line.rstrip()) - log.error("old-configure failed") + log.error('old-configure failed') sys.exit(ret) if config_log: # Create a new handler in append mode - handler = logging.FileHandler(config_log.baseFilename, mode="a", delay=True) + handler = logging.FileHandler(config_log.baseFilename, mode='a', delay=True) handler.setFormatter(config_log.formatter) logger.addHandler(handler) raw_config = { - "split": split, - "unique_list": unique_list, + 'split': split, + 'unique_list': unique_list, } - with open("config.data", "r") as fh: - code = compile(fh.read(), "config.data", "exec") + with open('config.data', 'r') as fh: + code = compile(fh.read(), 'config.data', 'exec') exec_(code, raw_config) # Ensure all the flags known to old-configure appear in the # @old_configure_options above. all_options = set(prepare_configure_options.all_options) - for flag in raw_config["flags"]: + for flag in raw_config['flags']: if flag not in all_options: - die( - "Missing option in `@old_configure_options` in %s: %s", - __file__, - flag, - ) + die('Missing option in `@old_configure_options` in %s: %s', + __file__, flag) # If the code execution above fails, we want to keep the file around for # debugging. - os.remove("config.data") - - return namespace( - **{ - c: [ - (k[1:-1], v[1:-1] if isinstance(v, string_types) else v) - for k, v in raw_config[c] - ] - for c in ("substs", "defines") - } - ) + os.remove('config.data') + + return namespace(**{ + c: [ + (k[1:-1], v[1:-1] if isinstance(v, string_types) else v) + for k, v in raw_config[c] + ] + for c in ('substs', 'defines') + }) return old_configure old_configure = old_configure_for(old_configure) -set_config("OLD_CONFIGURE_SUBSTS", old_configure.substs) -set_config("OLD_CONFIGURE_DEFINES", old_configure.defines) +set_config('OLD_CONFIGURE_SUBSTS', old_configure.substs) +set_config('OLD_CONFIGURE_DEFINES', old_configure.defines) # Assuming no other option is declared after this function, handle the @@ -354,18 +309,17 @@ set_config("OLD_CONFIGURE_DEFINES", old_configure.defines) # them. We only do so for options that haven't been declared so far, # which should be a proxy for the options that old-configure handles # and that we don't know anything about. -@depends("--help") -@imports("__sandbox__") -@imports(_from="mozbuild.configure.options", _import="Option") +@depends('--help') +@imports('__sandbox__') +@imports(_from='mozbuild.configure.options', _import='Option') def remaining_mozconfig_options(_): helper = __sandbox__._helper for arg in list(helper): - if helper._origins[arg] != "mozconfig": + if helper._origins[arg] != 'mozconfig': continue - name = arg.split("=", 1)[0] + name = arg.split('=', 1)[0] if name.isupper() and name not in __sandbox__._options: - option = Option(env=name, nargs="*", help=name) + option = Option(env=name, nargs='*', help=name) helper.handle(option) - # Please do not add anything after remaining_mozconfig_options() diff --git a/build/moz.configure/pkg.configure b/build/moz.configure/pkg.configure index 20d90f17fdd7262222ea63a829b6352423dbb7c1..cbc34409a629dd6124921c3ab7cacc0b59f28e74 100644 --- a/build/moz.configure/pkg.configure +++ b/build/moz.configure/pkg.configure @@ -7,17 +7,17 @@ @depends(toolchain_prefix, when=compile_environment) def pkg_config(prefixes): - return tuple("{}pkg-config".format(p) for p in (prefixes or ()) + ("",)) + return tuple('{}pkg-config'.format(p) + for p in (prefixes or ()) + ('',)) -pkg_config = check_prog("PKG_CONFIG", pkg_config, allow_missing=True) +pkg_config = check_prog('PKG_CONFIG', pkg_config, allow_missing=True) @depends_if(pkg_config) -@checking("for pkg-config version") +@checking('for pkg-config version') def pkg_config_version(pkg_config): - return Version(check_cmd_output(pkg_config, "--version").rstrip()) - + return Version(check_cmd_output(pkg_config, '--version').rstrip()) # Locates the given module using pkg-config. # - `var` determines the name of variables to set when the package is found. @@ -34,41 +34,38 @@ def pkg_config_version(pkg_config): @template -def pkg_check_modules(var, package_desc, when=always, allow_missing=False, config=True): +def pkg_check_modules(var, package_desc, when=always, + allow_missing=False, config=True): if isinstance(package_desc, (tuple, list)): - package_desc = " ".join(package_desc) + package_desc = ' '.join(package_desc) package_desc = dependable(package_desc) allow_missing = dependable(allow_missing) - @depends(when, "--enable-compile-environment") + @depends(when, '--enable-compile-environment') def when_and_compile_environment(when, compile_environment): return when and compile_environment - @depends(pkg_config, pkg_config_version, when=when_and_compile_environment) + @depends(pkg_config, pkg_config_version, + when=when_and_compile_environment) def check_pkg_config(pkg_config, version): - min_version = "0.9.0" + min_version = '0.9.0' if pkg_config is None: - die( - "*** The pkg-config script could not be found. Make sure it is\n" + die("*** The pkg-config script could not be found. Make sure it is\n" "*** in your path, or set the PKG_CONFIG environment variable\n" - "*** to the full path to pkg-config." - ) + "*** to the full path to pkg-config.") if version < min_version: - die( - "*** Your version of pkg-config is too old. You need version %s or newer.", - min_version, - ) + die("*** Your version of pkg-config is too old. You need version %s or newer.", + min_version) @depends(pkg_config, package_desc, allow_missing, when=when_and_compile_environment) - @imports("sys") - @imports(_from="mozbuild.configure.util", _import="LineIO") + @imports('sys') + @imports(_from='mozbuild.configure.util', _import='LineIO') def package(pkg_config, package_desc, allow_missing): # package_desc may start as a depends function, so we can't use # @checking here. log.info("checking for %s... " % package_desc) retcode, stdout, stderr = get_cmd_output( - pkg_config, "--errors-to-stdout", "--print-errors", package_desc - ) + pkg_config, '--errors-to-stdout', '--print-errors', package_desc) if retcode == 0: log.info("yes") return True @@ -80,24 +77,24 @@ def pkg_check_modules(var, package_desc, when=always, allow_missing=False, confi sys.exit(1) @depends(pkg_config, package_desc, when=package) - @checking("%s_CFLAGS" % var, callback=lambda t: " ".join(t)) + @checking('%s_CFLAGS' % var, callback=lambda t: ' '.join(t)) def pkg_cflags(pkg_config, package_desc): - flags = check_cmd_output(pkg_config, "--cflags", package_desc) + flags = check_cmd_output(pkg_config, '--cflags', package_desc) return tuple(flags.split()) @depends(pkg_config, package_desc, when=package) - @checking("%s_LIBS" % var, callback=lambda t: " ".join(t)) + @checking('%s_LIBS' % var, callback=lambda t: ' '.join(t)) def pkg_libs(pkg_config, package_desc): - libs = check_cmd_output(pkg_config, "--libs", package_desc) + libs = check_cmd_output(pkg_config, '--libs', package_desc) # Remove evil flags like -Wl,--export-dynamic - return tuple(libs.replace("-Wl,--export-dynamic", "").split()) + return tuple(libs.replace('-Wl,--export-dynamic', '').split()) @depends(pkg_cflags, pkg_libs, when=package) def pkg_info(cflags, libs): return namespace(cflags=cflags, libs=libs) if config: - set_config("%s_CFLAGS" % var, pkg_cflags) - set_config("%s_LIBS" % var, pkg_libs) + set_config('%s_CFLAGS' % var, pkg_cflags) + set_config('%s_LIBS' % var, pkg_libs) return pkg_info diff --git a/build/moz.configure/rust.configure b/build/moz.configure/rust.configure index f4fcdd60e9325e54460b82792f0f3f3e27a68e01..0d6d2faf9377ba4f8fe529dfa0e1401a0e5e84d4 100644 --- a/build/moz.configure/rust.configure +++ b/build/moz.configure/rust.configure @@ -7,25 +7,15 @@ # Rust is required by `rust_compiler` below. We allow_missing here # to propagate failures to the better error message there. -option(env="RUSTC", nargs=1, help="Path to the rust compiler") -option(env="CARGO", nargs=1, help="Path to the Cargo package manager") - -rustc = check_prog( - "_RUSTC", - ["rustc"], - what="rustc", - paths=toolchain_search_path, - input="RUSTC", - allow_missing=True, -) -cargo = check_prog( - "_CARGO", - ["cargo"], - what="cargo", - paths=toolchain_search_path, - input="CARGO", - allow_missing=True, -) +option(env='RUSTC', nargs=1, help='Path to the rust compiler') +option(env='CARGO', nargs=1, help='Path to the Cargo package manager') + +rustc = check_prog('_RUSTC', ['rustc'], what='rustc', + paths=toolchain_search_path, input='RUSTC', + allow_missing=True) +cargo = check_prog('_CARGO', ['cargo'], what='cargo', + paths=toolchain_search_path, input='CARGO', + allow_missing=True) @template @@ -51,28 +41,29 @@ def unwrap_rustup(prog, name): # "+stable" file. We'll examine the error output to try and distinguish # between failing rustup and failing rustc. @depends(prog, dependable(name)) - @imports(_from="__builtin__", _import="open") - @imports("os") + @imports(_from='__builtin__', _import='open') + @imports('os') def unwrap(prog, name): if not prog: return def from_rustup_which(): - out = check_cmd_output("rustup", "which", name, executable=prog).rstrip() + out = check_cmd_output('rustup', 'which', name, + executable=prog).rstrip() # If for some reason the above failed to return something, keep the # PROG we found originally. if out: - log.info("Actually using '%s'", out) + log.info('Actually using \'%s\'', out) return out - log.info("No `rustup which` output, using '%s'", prog) + log.info('No `rustup which` output, using \'%s\'', prog) return prog - (retcode, stdout, stderr) = get_cmd_output(prog, "+stable") + (retcode, stdout, stderr) = get_cmd_output(prog, '+stable') - if name == "cargo" and retcode != 101: + if name == 'cargo' and retcode != 101: prog = from_rustup_which() - elif name == "rustc": + elif name == 'rustc': if retcode == 0: prog = from_rustup_which() elif "+stable" in stderr: @@ -90,56 +81,51 @@ def unwrap_rustup(prog, name): return unwrap - -rustc = unwrap_rustup(rustc, "rustc") -cargo = unwrap_rustup(cargo, "cargo") +rustc = unwrap_rustup(rustc, 'rustc') +cargo = unwrap_rustup(cargo, 'cargo') -set_config("CARGO", cargo) -set_config("RUSTC", rustc) +set_config('CARGO', cargo) +set_config('RUSTC', rustc) @depends_if(rustc) -@checking("rustc version", lambda info: info.version) +@checking('rustc version', lambda info: info.version) def rustc_info(rustc): if not rustc: return - out = check_cmd_output(rustc, "--version", "--verbose").splitlines() - info = dict((s.strip() for s in line.split(":", 1)) for line in out[1:]) + out = check_cmd_output(rustc, '--version', '--verbose').splitlines() + info = dict((s.strip() for s in line.split(':', 1)) for line in out[1:]) return namespace( - version=Version(info.get("release", "0")), - commit=info.get("commit-hash", "unknown"), - host=info["host"], - llvm_version=Version(info.get("LLVM version", "0")), + version=Version(info.get('release', '0')), + commit=info.get('commit-hash', 'unknown'), + host=info['host'], + llvm_version=Version(info.get('LLVM version', '0')), ) - -set_config( - "RUSTC_VERSION", - depends(rustc_info)(lambda info: str(info.version) if info else None), -) - +set_config('RUSTC_VERSION', depends(rustc_info)( + lambda info: str(info.version) if info else None)) @depends_if(cargo) -@checking("cargo version", lambda info: info.version) -@imports("re") +@checking('cargo version', lambda info: info.version) +@imports('re') def cargo_info(cargo): if not cargo: return - out = check_cmd_output(cargo, "--version", "--verbose").splitlines() - info = dict((s.strip() for s in line.split(":", 1)) for line in out[1:]) - version = info.get("release") + out = check_cmd_output(cargo, '--version', '--verbose').splitlines() + info = dict((s.strip() for s in line.split(':', 1)) for line in out[1:]) + version = info.get('release') # Older versions of cargo didn't support --verbose, in which case, they # only output a not-really-pleasant-to-parse output. Fortunately, they # don't error out, so we can just try some regexp matching on the output # we already got. if version is None: - VERSION_FORMAT = r"^cargo (\d\.\d+\.\d+).*" + VERSION_FORMAT = r'^cargo (\d\.\d+\.\d+).*' m = re.search(VERSION_FORMAT, out[0]) # Fail fast if cargo changes its output on us. if not m: - die("Could not determine cargo version from output: %s", out) + die('Could not determine cargo version from output: %s', out) version = m.group(1) return namespace( @@ -148,42 +134,35 @@ def cargo_info(cargo): @depends(rustc_info, cargo_info, build_project, c_compiler, target) -@imports(_from="mozboot.util", _import="MINIMUM_RUST_VERSION") -@imports(_from="textwrap", _import="dedent") +@imports(_from='mozboot.util', _import='MINIMUM_RUST_VERSION') +@imports(_from='textwrap', _import='dedent') def rust_compiler(rustc_info, cargo_info, build_project, c_compiler, target): if not rustc_info: - die( - dedent( - """\ + die(dedent('''\ Rust compiler not found. To compile rust language sources, you must have 'rustc' in your path. See https://www.rust-lang.org/ for more information. You can install rust by running './mach bootstrap' or by directly running the installer from https://rustup.rs/ - """ - ) - ) - if build_project == "tools/crashreporter": - rustc_min_version = Version("1.38.0") - elif target.os == "WINNT" and c_compiler.type != "clang-cl": - rustc_min_version = Version("1.44.0") + ''')) + if build_project == 'tools/crashreporter': + rustc_min_version = Version('1.38.0') + elif target.os == 'WINNT' and c_compiler.type != 'clang-cl': + rustc_min_version = Version('1.44.0') else: rustc_min_version = Version(MINIMUM_RUST_VERSION) cargo_min_version = rustc_min_version version = rustc_info.version - is_nightly = "nightly" in version.version + is_nightly = 'nightly' in version.version is_version_number_match = ( - version.major == rustc_min_version.major - and version.minor == rustc_min_version.minor - and version.patch == rustc_min_version.patch - ) + version.major == rustc_min_version.major and + version.minor == rustc_min_version.minor and + version.patch == rustc_min_version.patch) if version < rustc_min_version or (is_version_number_match and is_nightly): - die( - dedent( - """\ + die(dedent('''\ Rust compiler {} is too old. To compile Rust language sources please install at least @@ -196,60 +175,48 @@ def rust_compiler(rustc_info, cargo_info, build_project, c_compiler, target): If you have the 'rustup' tool installed you can upgrade to the latest release by typing 'rustup update'. The installer is available from https://rustup.rs/ - """.format( - version, rustc_min_version, rustc_min_version - ) - ) - ) + '''.format(version, rustc_min_version, rustc_min_version))) if not cargo_info: - die( - dedent( - """\ + die(dedent('''\ Cargo package manager not found. To compile Rust language sources, you must have 'cargo' in your path. See https://www.rust-lang.org/ for more information. You can install cargo by running './mach bootstrap' or by directly running the installer from https://rustup.rs/ - """ - ) - ) + ''')) version = cargo_info.version if version < cargo_min_version: - die( - dedent( - """\ + die(dedent('''\ Cargo package manager {} is too old. To compile Rust language sources please install at least version {} of 'cargo' and make sure it is first in your path. You can verify this by typing 'cargo --version'. - """ - ).format(version, cargo_min_version) - ) + ''').format(version, cargo_min_version)) return True @depends(rustc, when=rust_compiler) -@imports(_from="__builtin__", _import="ValueError") +@imports(_from='__builtin__', _import='ValueError') def rust_supported_targets(rustc): - out = check_cmd_output(rustc, "--print", "target-list").splitlines() + out = check_cmd_output(rustc, '--print', 'target-list').splitlines() data = {} for t in out: try: info = split_triplet(t) except ValueError: - if t.startswith("thumb"): - cpu, rest = t.split("-", 1) - retry = "-".join(("arm", rest)) - elif t.endswith("-windows-msvc"): - retry = t[: -len("windows-msvc")] + "mingw32" - elif t.endswith("-windows-gnu"): - retry = t[: -len("windows-gnu")] + "mingw32" + if t.startswith('thumb'): + cpu, rest = t.split('-', 1) + retry = '-'.join(('arm', rest)) + elif t.endswith('-windows-msvc'): + retry = t[:-len('windows-msvc')] + 'mingw32' + elif t.endswith('-windows-gnu'): + retry = t[:-len('windows-gnu')] + 'mingw32' else: continue try: @@ -261,9 +228,7 @@ def rust_supported_targets(rustc): return data -def detect_rustc_target( - host_or_target, compiler_info, arm_target, rust_supported_targets -): +def detect_rustc_target(host_or_target, compiler_info, arm_target, rust_supported_targets): # Rust's --target options are similar to, but not exactly the same # as, the autoconf-derived targets we use. An example would be that # Rust uses distinct target triples for targetting the GNU C++ ABI @@ -274,8 +239,7 @@ def detect_rustc_target( # We correlate the autoconf-derived targets with the list of targets # rustc gives us with --print target-list. candidates = rust_supported_targets.get( - (host_or_target.cpu, host_or_target.endianness, host_or_target.os), [] - ) + (host_or_target.cpu, host_or_target.endianness, host_or_target.os), []) def find_candidate(candidates): if len(candidates) == 1: @@ -286,25 +250,20 @@ def detect_rustc_target( # We have multiple candidates. There are two cases where we can try to # narrow further down using extra information from the build system. # - For windows targets, correlate with the C compiler type - if host_or_target.kernel == "WINNT": - if compiler_info.type in ("gcc", "clang"): - suffix = "windows-gnu" + if host_or_target.kernel == 'WINNT': + if compiler_info.type in ('gcc', 'clang'): + suffix = 'windows-gnu' else: - suffix = "windows-msvc" - narrowed = [ - c for c in candidates if c.rust_target.endswith("-{}".format(suffix)) - ] + suffix = 'windows-msvc' + narrowed = [c for c in candidates if c.rust_target.endswith('-{}'.format(suffix))] if len(narrowed) == 1: return narrowed[0].rust_target elif narrowed: candidates = narrowed - vendor_aliases = {"pc": ("w64", "windows")} - narrowed = [ - c - for c in candidates - if host_or_target.vendor in vendor_aliases.get(c.target.vendor, ()) - ] + vendor_aliases = {'pc': ('w64', 'windows')} + narrowed = [c for c in candidates + if host_or_target.vendor in vendor_aliases.get(c.target.vendor, ())] if len(narrowed) == 1: return narrowed[0].rust_target @@ -315,40 +274,39 @@ def detect_rustc_target( # Also, sadly, the only interface to check the rust target cpu features # is --print target-spec-json, and it's unstable, so we have to rely on # our own knowledge of what each arm target means. - if host_or_target.cpu == "arm" and host_or_target.endianness == "little": + if host_or_target.cpu == 'arm' and host_or_target.endianness == 'little': prefixes = [] if arm_target.arm_arch >= 7: - if arm_target.thumb2 and arm_target.fpu == "neon": - prefixes.append("thumbv7neon") + if arm_target.thumb2 and arm_target.fpu == 'neon': + prefixes.append('thumbv7neon') if arm_target.thumb2: - prefixes.append("thumbv7a") - prefixes.append("armv7") + prefixes.append('thumbv7a') + prefixes.append('armv7') if arm_target.arm_arch >= 6: - prefixes.append("armv6") - if host_or_target.os != "Android": + prefixes.append('armv6') + if host_or_target.os != 'Android': # arm-* rust targets are armv6... except arm-linux-androideabi - prefixes.append("arm") + prefixes.append('arm') if arm_target.arm_arch >= 5: - prefixes.append("armv5te") - if host_or_target.os == "Android": + prefixes.append('armv5te') + if host_or_target.os == 'Android': # arm-* rust targets are armv6... except arm-linux-androideabi - prefixes.append("arm") + prefixes.append('arm') if arm_target.arm_arch >= 4: - prefixes.append("armv4t") + prefixes.append('armv4t') # rust freebsd targets are the only ones that don't have a 'hf' suffix # for hard-float. Technically, that means if the float abi ever is not # hard-float, this will pick a wrong target, but since rust only # supports hard-float, let's assume that means freebsd only support # hard-float. - if arm_target.float_abi == "hard" and host_or_target.os != "FreeBSD": - suffix = "hf" + if arm_target.float_abi == 'hard' and host_or_target.os != 'FreeBSD': + suffix = 'hf' else: - suffix = "" + suffix = '' for p in prefixes: for c in candidates: - if c.rust_target.startswith( - "{}-".format(p) - ) and c.rust_target.endswith(suffix): + if c.rust_target.startswith('{}-'.format(p)) and \ + c.rust_target.endswith(suffix): return c.rust_target # See if we can narrow down on the exact alias @@ -367,16 +325,18 @@ def detect_rustc_target( # See if we can narrow down with the raw OS and raw CPU narrowed = [ - c - for c in candidates - if c.target.raw_os == host_or_target.raw_os - and c.target.raw_cpu == host_or_target.raw_cpu + c for c in candidates + if c.target.raw_os == host_or_target.raw_os and + c.target.raw_cpu == host_or_target.raw_cpu ] if len(narrowed) == 1: return narrowed[0].rust_target # Finally, see if the vendor can be used to disambiguate. - narrowed = [c for c in candidates if c.target.vendor == host_or_target.vendor] + narrowed = [ + c for c in candidates + if c.target.vendor == host_or_target.vendor + ] if len(narrowed) == 1: return narrowed[0].rust_target @@ -385,27 +345,28 @@ def detect_rustc_target( rustc_target = find_candidate(candidates) if rustc_target is None: - die("Don't know how to translate {} for rustc".format(host_or_target.alias)) + die("Don't know how to translate {} for rustc".format( + host_or_target.alias)) return rustc_target -@imports("os") -@imports(_from="six", _import="ensure_binary") -@imports(_from="tempfile", _import="mkstemp") -@imports(_from="textwrap", _import="dedent") -@imports(_from="mozbuild.configure.util", _import="LineIO") +@imports('os') +@imports(_from='six', _import='ensure_binary') +@imports(_from='tempfile', _import='mkstemp') +@imports(_from='textwrap', _import='dedent') +@imports(_from='mozbuild.configure.util', _import='LineIO') def assert_rust_compile(host_or_target, rustc_target, rustc): # Check to see whether our rustc has a reasonably functional stdlib # for our chosen target. - target_arg = "--target=" + rustc_target - in_fd, in_path = mkstemp(prefix="conftest", suffix=".rs", text=True) - out_fd, out_path = mkstemp(prefix="conftest", suffix=".rlib") + target_arg = '--target=' + rustc_target + in_fd, in_path = mkstemp(prefix='conftest', suffix='.rs', text=True) + out_fd, out_path = mkstemp(prefix='conftest', suffix='.rlib') os.close(out_fd) try: source = 'pub extern fn hello() { println!("Hello world"); }' - log.debug("Creating `%s` with content:", in_path) - with LineIO(lambda l: log.debug("| %s", l)) as out: + log.debug('Creating `%s` with content:', in_path) + with LineIO(lambda l: log.debug('| %s', l)) as out: out.write(source) os.write(in_fd, ensure_binary(source)) @@ -413,29 +374,20 @@ def assert_rust_compile(host_or_target, rustc_target, rustc): cmd = [ rustc, - "--crate-type", - "staticlib", + '--crate-type', 'staticlib', target_arg, - "-o", - out_path, + '-o', out_path, in_path, ] def failed(): - die( - dedent( - """\ + die(dedent('''\ Cannot compile for {} with {} The target may be unsupported, or you may not have a rust std library for that target installed. Try: rustup target add {} - """.format( - host_or_target.alias, rustc, rustc_target - ) - ) - ) - + '''.format(host_or_target.alias, rustc, rustc_target))) check_cmd_output(*cmd, onerror=failed) if not os.path.exists(out_path) or os.path.getsize(out_path) == 0: failed() @@ -444,31 +396,20 @@ def assert_rust_compile(host_or_target, rustc_target, rustc): os.remove(out_path) -@depends( - rustc, - host, - host_c_compiler, - rustc_info.host, - rust_supported_targets, - arm_target, - when=rust_compiler, -) -@checking("for rust host triplet") -@imports(_from="textwrap", _import="dedent") -def rust_host_triple( - rustc, host, compiler_info, rustc_host, rust_supported_targets, arm_target -): - rustc_target = detect_rustc_target( - host, compiler_info, arm_target, rust_supported_targets - ) +@depends(rustc, host, host_c_compiler, rustc_info.host, rust_supported_targets, + arm_target, when=rust_compiler) +@checking('for rust host triplet') +@imports(_from='textwrap', _import='dedent') +def rust_host_triple(rustc, host, compiler_info, rustc_host, rust_supported_targets, + arm_target): + rustc_target = detect_rustc_target(host, compiler_info, arm_target, + rust_supported_targets) if rustc_target != rustc_host: if host.alias == rustc_target: configure_host = host.alias else: - configure_host = "{}/{}".format(host.alias, rustc_target) - die( - dedent( - """\ + configure_host = '{}/{}'.format(host.alias, rustc_target) + die(dedent('''\ The rust compiler host ({rustc}) is not suitable for the configure host ({configure}). You can solve this by: @@ -476,79 +417,59 @@ def rust_host_triple( mozconfig and adding "ac_add_options --host={rustc}". * Or, install the rust toolchain for {configure}, if supported, by running "rustup default stable-{rustc_target}" - """.format( - rustc=rustc_host, - configure=configure_host, - rustc_target=rustc_target, - ) - ) - ) + '''.format(rustc=rustc_host, configure=configure_host, rustc_target=rustc_target))) assert_rust_compile(host, rustc_target, rustc) return rustc_target - -@depends( - rustc, target, c_compiler, rust_supported_targets, arm_target, when=rust_compiler -) -@checking("for rust target triplet") -def rust_target_triple( - rustc, target, compiler_info, rust_supported_targets, arm_target -): - rustc_target = detect_rustc_target( - target, compiler_info, arm_target, rust_supported_targets - ) +@depends(rustc, target, c_compiler, rust_supported_targets, arm_target, when=rust_compiler) +@checking('for rust target triplet') +def rust_target_triple(rustc, target, compiler_info, rust_supported_targets, arm_target): + rustc_target = detect_rustc_target(target, compiler_info, arm_target, rust_supported_targets) assert_rust_compile(target, rustc_target, rustc) return rustc_target -set_config("RUST_TARGET", rust_target_triple) -set_config("RUST_HOST_TARGET", rust_host_triple) +set_config('RUST_TARGET', rust_target_triple) +set_config('RUST_HOST_TARGET', rust_host_triple) # This is used for putting source info into symbol files. -set_config("RUSTC_COMMIT", depends(rustc_info)(lambda i: i.commit)) +set_config('RUSTC_COMMIT', depends(rustc_info)(lambda i: i.commit)) # Rustdoc is required by Rust tests below. -option(env="RUSTDOC", nargs=1, help="Path to the rustdoc program") +option(env='RUSTDOC', nargs=1, help='Path to the rustdoc program') -rustdoc = check_prog( - "RUSTDOC", - ["rustdoc"], - paths=toolchain_search_path, - input="RUSTDOC", - allow_missing=True, -) +rustdoc = check_prog('RUSTDOC', ['rustdoc'], paths=toolchain_search_path, + input='RUSTDOC', allow_missing=True) # This option is separate from --enable-tests because Rust tests are particularly # expensive in terms of compile time (especially for code in libxul). -option( - "--enable-rust-tests", - help="Enable building and running of Rust tests during `make check`", -) +option('--enable-rust-tests', + help='Enable building and running of Rust tests during `make check`') -@depends("--enable-rust-tests", rustdoc) +@depends('--enable-rust-tests', rustdoc) def rust_tests(enable_rust_tests, rustdoc): if enable_rust_tests and not rustdoc: - die("--enable-rust-tests requires rustdoc") + die('--enable-rust-tests requires rustdoc') return bool(enable_rust_tests) -set_config("MOZ_RUST_TESTS", rust_tests) +set_config('MOZ_RUST_TESTS', rust_tests) @depends(target, c_compiler, rustc) -@imports("os") +@imports('os') def rustc_natvis_ldflags(target, compiler_info, rustc): - if target.kernel == "WINNT" and compiler_info.type == "clang-cl": - sysroot = check_cmd_output(rustc, "--print", "sysroot").strip() - etc = os.path.join(sysroot, "lib/rustlib/etc") + if target.kernel == 'WINNT' and compiler_info.type == 'clang-cl': + sysroot = check_cmd_output(rustc, '--print', 'sysroot').strip() + etc = os.path.join(sysroot, 'lib/rustlib/etc') ldflags = [] if os.path.isdir(etc): for f in os.listdir(etc): - if f.endswith(".natvis"): - ldflags.append("-NATVIS:" + normsep(os.path.join(etc, f))) + if f.endswith('.natvis'): + ldflags.append('-NATVIS:' + normsep(os.path.join(etc, f))) return ldflags -set_config("RUSTC_NATVIS_LDFLAGS", rustc_natvis_ldflags) +set_config('RUSTC_NATVIS_LDFLAGS', rustc_natvis_ldflags) diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index a73b2a351e9cbba44595f3c3ec1bda47ad0e5d74..e458fe47ea34fa7fb82f62d703671032bca5dae3 100755 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -4,41 +4,41 @@ # 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/. -imply_option("--enable-release", mozilla_official) -imply_option("--enable-release", depends_if("MOZ_AUTOMATION")(lambda x: True)) +imply_option('--enable-release', mozilla_official) +imply_option('--enable-release', depends_if('MOZ_AUTOMATION')(lambda x: True)) -option( - "--enable-release", - default=milestone.is_release_or_beta, - help="{Build|Do not build} with more conservative, release " - "engineering-oriented options.{ This may slow down builds.|}", -) +option('--enable-release', + default=milestone.is_release_or_beta, + help='{Build|Do not build} with more conservative, release ' + 'engineering-oriented options.{ This may slow down builds.|}') -@depends("--enable-release") +@depends('--enable-release') def developer_options(value): if not value: return True -add_old_configure_assignment("DEVELOPER_OPTIONS", developer_options) -set_config("DEVELOPER_OPTIONS", developer_options) +add_old_configure_assignment('DEVELOPER_OPTIONS', developer_options) +set_config('DEVELOPER_OPTIONS', developer_options) # Code optimization # ============================================================== -option("--disable-optimize", nargs="?", help="Disable optimizations via compiler flags") +option('--disable-optimize', + nargs='?', + help='Disable optimizations via compiler flags') -@depends("--enable-optimize", "--help") +@depends('--enable-optimize', '--help') def moz_optimize(option, _): flags = None if len(option): - val = "2" + val = '2' flags = option[0] elif option: - val = "1" + val = '1' else: val = None @@ -48,25 +48,22 @@ def moz_optimize(option, _): ) -set_config("MOZ_OPTIMIZE", moz_optimize.optimize) -add_old_configure_assignment("MOZ_OPTIMIZE", moz_optimize.optimize) -add_old_configure_assignment("MOZ_CONFIGURE_OPTIMIZE_FLAGS", moz_optimize.flags) +set_config('MOZ_OPTIMIZE', moz_optimize.optimize) +add_old_configure_assignment('MOZ_OPTIMIZE', moz_optimize.optimize) +add_old_configure_assignment('MOZ_CONFIGURE_OPTIMIZE_FLAGS', moz_optimize.flags) # yasm detection # ============================================================== -yasm = check_prog("YASM", ["yasm"], allow_missing=True) +yasm = check_prog('YASM', ['yasm'], allow_missing=True) @depends_if(yasm) -@checking("yasm version") +@checking('yasm version') def yasm_version(yasm): - version = ( - check_cmd_output( - yasm, "--version", onerror=lambda: die("Failed to get yasm version.") - ) - .splitlines()[0] - .split()[1] - ) + version = check_cmd_output( + yasm, '--version', + onerror=lambda: die('Failed to get yasm version.') + ).splitlines()[0].split()[1] return Version(version) @@ -74,199 +71,170 @@ def yasm_version(yasm): def yasm_asflags(yasm, target): if yasm: asflags = { - ("OSX", "x86"): ["-f", "macho32"], - ("OSX", "x86_64"): ["-f", "macho64"], - ("WINNT", "x86"): ["-f", "win32"], - ("WINNT", "x86_64"): ["-f", "x64"], + ('OSX', 'x86'): ['-f', 'macho32'], + ('OSX', 'x86_64'): ['-f', 'macho64'], + ('WINNT', 'x86'): ['-f', 'win32'], + ('WINNT', 'x86_64'): ['-f', 'x64'], }.get((target.os, target.cpu), None) if asflags is None: # We're assuming every x86 platform we support that's # not Windows or Mac is ELF. - if target.cpu == "x86": - asflags = ["-f", "elf32"] - elif target.cpu == "x86_64": - asflags = ["-f", "elf64"] + if target.cpu == 'x86': + asflags = ['-f', 'elf32'] + elif target.cpu == 'x86_64': + asflags = ['-f', 'elf64'] if asflags: - asflags += ["-rnasm", "-pnasm"] + asflags += ['-rnasm', '-pnasm'] return asflags -set_config("YASM_ASFLAGS", yasm_asflags) +set_config('YASM_ASFLAGS', yasm_asflags) # Android NDK # ============================================================== -@depends("--disable-compile-environment", target) +@depends('--disable-compile-environment', target) def compiling_android(compile_env, target): - return compile_env and target.os == "Android" + return compile_env and target.os == 'Android' -include("android-ndk.configure", when=compiling_android) +include('android-ndk.configure', when=compiling_android) with only_when(target_is_osx): # MacOS deployment target version # ============================================================== # This needs to happen before any compilation test is done. - option( - "--enable-macos-target", - env="MACOSX_DEPLOYMENT_TARGET", - nargs=1, - default="10.9", - help="Set the minimum MacOS version needed at runtime", - ) + option('--enable-macos-target', env='MACOSX_DEPLOYMENT_TARGET', nargs=1, + default='10.9', help='Set the minimum MacOS version needed at runtime') + - @depends("--enable-macos-target") - @imports(_from="os", _import="environ") + @depends('--enable-macos-target') + @imports(_from='os', _import='environ') def macos_target(value): if value: # Ensure every compiler process we spawn uses this value. - environ["MACOSX_DEPLOYMENT_TARGET"] = value[0] + environ['MACOSX_DEPLOYMENT_TARGET'] = value[0] return value[0] - set_config("MACOSX_DEPLOYMENT_TARGET", macos_target) - add_old_configure_assignment("MACOSX_DEPLOYMENT_TARGET", macos_target) + + set_config('MACOSX_DEPLOYMENT_TARGET', macos_target) + add_old_configure_assignment('MACOSX_DEPLOYMENT_TARGET', macos_target) @depends(host) def host_is_osx(host): - if host.os == "OSX": + if host.os == 'OSX': return True with only_when(host_is_osx | target_is_osx): # MacOS SDK # ========= - option( - "--with-macos-sdk", - env="MACOS_SDK_DIR", - nargs=1, - help="Location of platform SDK to use", - ) + option('--with-macos-sdk', env='MACOS_SDK_DIR', nargs=1, + help='Location of platform SDK to use') - @depends("--with-macos-sdk", host) - @imports(_from="os.path", _import="isdir") - @imports(_from="biplist", _import="readPlist") + @depends('--with-macos-sdk', host) + @imports(_from='os.path', _import='isdir') + @imports(_from='biplist', _import='readPlist') def macos_sdk(sdk, host): - sdk_min_version = Version("10.11") - sdk_max_version = Version("11.0") + sdk_min_version = Version('10.11') + sdk_max_version = Version('11.0') if sdk: sdk = sdk[0] - elif host.os == "OSX": - sdk = check_cmd_output( - "xcrun", "--show-sdk-path", onerror=lambda: "" - ).rstrip() + elif host.os == 'OSX': + sdk = check_cmd_output('xcrun', '--show-sdk-path', onerror=lambda: '').rstrip() if not sdk: - die( - "Could not find the macOS SDK. Please use --with-macos-sdk to give " - "the path to a macOS SDK." - ) + die('Could not find the macOS SDK. Please use --with-macos-sdk to give ' + 'the path to a macOS SDK.') else: - die( - "Need a macOS SDK when targeting macOS. Please use --with-macos-sdk " - "to give the path to a macOS SDK." - ) + die('Need a macOS SDK when targeting macOS. Please use --with-macos-sdk ' + 'to give the path to a macOS SDK.') if not isdir(sdk): - die( - "SDK not found in %s. When using --with-macos-sdk, you must specify a " - "valid SDK. SDKs are installed when the optional cross-development " - "tools are selected during the Xcode/Developer Tools installation." - % sdk - ) - obj = readPlist(os.path.join(sdk, "SDKSettings.plist")) + die('SDK not found in %s. When using --with-macos-sdk, you must specify a ' + 'valid SDK. SDKs are installed when the optional cross-development ' + 'tools are selected during the Xcode/Developer Tools installation.' + % sdk) + obj = readPlist(os.path.join(sdk, 'SDKSettings.plist')) if not obj: - die("Error parsing SDKSettings.plist in the SDK directory: %s" % sdk) - if "Version" not in obj: - die( - "Error finding Version information in SDKSettings.plist from the SDK: %s" - % sdk - ) - version = Version(obj["Version"]) + die('Error parsing SDKSettings.plist in the SDK directory: %s' % sdk) + if 'Version' not in obj: + die('Error finding Version information in SDKSettings.plist from the SDK: %s' % sdk) + version = Version(obj['Version']) if version < sdk_min_version: - die( - 'SDK version "%s" is too old. Please upgrade to at least %s. ' - "You may need to point to it using --with-macos-sdk= in your " - "mozconfig." % (version, sdk_min_version) - ) + die('SDK version "%s" is too old. Please upgrade to at least %s. ' + 'You may need to point to it using --with-macos-sdk= in your ' + 'mozconfig.' % (version, sdk_min_version)) if version > sdk_max_version: - die( - 'SDK version "%s" is unsupported. Please downgrade to version ' - "%s. You may need to point to it using --with-macos-sdk= in " - "your mozconfig." % (version, sdk_max_version) - ) + die('SDK version "%s" is unsupported. Please downgrade to version ' + '%s. You may need to point to it using --with-macos-sdk= in ' + 'your mozconfig.' % (version, sdk_max_version)) return sdk - set_config("MACOS_SDK_DIR", macos_sdk) + set_config('MACOS_SDK_DIR', macos_sdk) with only_when(target_is_osx): with only_when(cross_compiling): - option( - "--with-macos-private-frameworks", - env="MACOS_PRIVATE_FRAMEWORKS_DIR", - nargs=1, - help="Location of private frameworks to use", - ) + option('--with-macos-private-frameworks', + env="MACOS_PRIVATE_FRAMEWORKS_DIR", nargs=1, + help='Location of private frameworks to use') - @depends_if("--with-macos-private-frameworks") - @imports(_from="os.path", _import="isdir") + @depends_if('--with-macos-private-frameworks') + @imports(_from='os.path', _import='isdir') def macos_private_frameworks(value): if value and not isdir(value[0]): - die( - "PrivateFrameworks not found not found in %s. When using " - "--with-macos-private-frameworks, you must specify a valid " - "directory", - value[0], - ) + die('PrivateFrameworks not found not found in %s. When using ' + '--with-macos-private-frameworks, you must specify a valid ' + 'directory', value[0]) return value[0] @depends(macos_private_frameworks) def macos_private_frameworks(value): if value: return value - return "/System/Library/PrivateFrameworks" + return '/System/Library/PrivateFrameworks' - set_config("MACOS_PRIVATE_FRAMEWORKS_DIR", macos_private_frameworks) + set_config('MACOS_PRIVATE_FRAMEWORKS_DIR', macos_private_frameworks) # Compiler wrappers # ============================================================== -option( - "--with-compiler-wrapper", - env="COMPILER_WRAPPER", - nargs=1, - help="Enable compiling with wrappers such as distcc and ccache", -) +option('--with-compiler-wrapper', env='COMPILER_WRAPPER', nargs=1, + help='Enable compiling with wrappers such as distcc and ccache') -option("--with-ccache", env="CCACHE", nargs="?", help="Enable compiling with ccache") +option('--with-ccache', env='CCACHE', nargs='?', + help='Enable compiling with ccache') -@depends_if("--with-ccache") +@depends_if('--with-ccache') def ccache(value): if len(value): return value # If --with-ccache was given without an explicit value, we default to # 'ccache'. - return "ccache" + return 'ccache' -ccache = check_prog("CCACHE", progs=(), input=ccache) +ccache = check_prog('CCACHE', progs=(), input=ccache) -option(env="CCACHE_PREFIX", nargs=1, help="Compiler prefix to use when using ccache") +option(env='CCACHE_PREFIX', + nargs=1, + help='Compiler prefix to use when using ccache') -ccache_prefix = depends_if("CCACHE_PREFIX")(lambda prefix: prefix[0]) -set_config("CCACHE_PREFIX", ccache_prefix) +ccache_prefix = depends_if('CCACHE_PREFIX')(lambda prefix: prefix[0]) +set_config('CCACHE_PREFIX', ccache_prefix) # Distinguish ccache from sccache. @depends_if(ccache) def ccache_is_sccache(ccache): - return check_cmd_output(ccache, "--version").startswith("sccache") + return check_cmd_output(ccache, '--version').startswith('sccache') @depends(ccache, ccache_is_sccache) @@ -278,70 +246,59 @@ def using_ccache(ccache, ccache_is_sccache): def using_sccache(ccache, ccache_is_sccache): return ccache and ccache_is_sccache +option(env='RUSTC_WRAPPER', nargs=1, + help='Wrap rust compilation with given tool') -option(env="RUSTC_WRAPPER", nargs=1, help="Wrap rust compilation with given tool") - - -@depends(ccache, ccache_is_sccache, "RUSTC_WRAPPER") -@imports(_from="textwrap", _import="dedent") -@imports("os") +@depends(ccache, ccache_is_sccache, 'RUSTC_WRAPPER') +@imports(_from='textwrap', _import='dedent') +@imports('os') def check_sccache_version(ccache, ccache_is_sccache, rustc_wrapper): - sccache_min_version = Version("0.2.13") + sccache_min_version = Version('0.2.13') def check_version(path): - out = check_cmd_output(path, "--version") + out = check_cmd_output(path, '--version') version = Version(out.rstrip().split()[-1]) if version < sccache_min_version: - die( - dedent( - """\ + die(dedent('''\ sccache %s or later is required. sccache in use at %s has version %s. Please upgrade or acquire a new version with |./mach bootstrap|. - """ - ), - sccache_min_version, - path, - version, - ) + '''), sccache_min_version, path, version) if ccache and ccache_is_sccache: check_version(ccache) - if rustc_wrapper and ( - os.path.splitext(os.path.basename(rustc_wrapper[0]))[0].lower() == "sccache" - ): + if (rustc_wrapper and + (os.path.splitext(os.path.basename(rustc_wrapper[0]))[0].lower() == + 'sccache')): check_version(rustc_wrapper[0]) +set_config('MOZ_USING_CCACHE', using_ccache) +set_config('MOZ_USING_SCCACHE', using_sccache) -set_config("MOZ_USING_CCACHE", using_ccache) -set_config("MOZ_USING_SCCACHE", using_sccache) +option(env='SCCACHE_VERBOSE_STATS', + help='Print verbose sccache stats after build') -option(env="SCCACHE_VERBOSE_STATS", help="Print verbose sccache stats after build") - -@depends(using_sccache, "SCCACHE_VERBOSE_STATS") +@depends(using_sccache, 'SCCACHE_VERBOSE_STATS') def sccache_verbose_stats(using_sccache, verbose_stats): return using_sccache and bool(verbose_stats) -set_config("SCCACHE_VERBOSE_STATS", sccache_verbose_stats) +set_config('SCCACHE_VERBOSE_STATS', sccache_verbose_stats) -@depends("--with-compiler-wrapper", ccache) -@imports(_from="mozbuild.shellutil", _import="split", _as="shell_split") +@depends('--with-compiler-wrapper', ccache) +@imports(_from='mozbuild.shellutil', _import='split', _as='shell_split') def compiler_wrapper(wrapper, ccache): if wrapper: raw_wrapper = wrapper[0] wrapper = shell_split(raw_wrapper) wrapper_program = find_program(wrapper[0]) if not wrapper_program: - die( - "Cannot find `%s` from the given compiler wrapper `%s`", - wrapper[0], - raw_wrapper, - ) + die('Cannot find `%s` from the given compiler wrapper `%s`', + wrapper[0], raw_wrapper) wrapper[0] = wrapper_program if ccache: @@ -358,39 +315,35 @@ def using_compiler_wrapper(compiler_wrapper): return True -set_config("MOZ_USING_COMPILER_WRAPPER", using_compiler_wrapper) +set_config('MOZ_USING_COMPILER_WRAPPER', using_compiler_wrapper) # GC rooting and hazard analysis. # ============================================================== -option(env="MOZ_HAZARD", help="Build for the GC rooting hazard analysis") +option(env='MOZ_HAZARD', help='Build for the GC rooting hazard analysis') -@depends("MOZ_HAZARD") +@depends('MOZ_HAZARD') def hazard_analysis(value): if value: return True -set_config("MOZ_HAZARD", hazard_analysis) +set_config('MOZ_HAZARD', hazard_analysis) # Cross-compilation related things. # ============================================================== -option( - "--with-toolchain-prefix", - env="TOOLCHAIN_PREFIX", - nargs=1, - help="Prefix for the target toolchain", -) +option('--with-toolchain-prefix', env='TOOLCHAIN_PREFIX', nargs=1, + help='Prefix for the target toolchain') -@depends("--with-toolchain-prefix", target, cross_compiling) +@depends('--with-toolchain-prefix', target, cross_compiling) def toolchain_prefix(value, target, cross_compiling): if value: return tuple(value) if cross_compiling: - return ("%s-" % target.toolchain, "%s-" % target.alias) + return ('%s-' % target.toolchain, '%s-' % target.alias) @depends(toolchain_prefix, target) @@ -398,34 +351,35 @@ def first_toolchain_prefix(toolchain_prefix, target): # Pass TOOLCHAIN_PREFIX down to the build system if it was given from the # command line/environment (in which case there's only one value in the tuple), # or when cross-compiling for Android or OSX. - if toolchain_prefix and ( - target.os in ("Android", "OSX") or len(toolchain_prefix) == 1 - ): + if toolchain_prefix and (target.os in ('Android', 'OSX') or len(toolchain_prefix) == 1): return toolchain_prefix[0] -set_config("TOOLCHAIN_PREFIX", first_toolchain_prefix) -add_old_configure_assignment("TOOLCHAIN_PREFIX", first_toolchain_prefix) +set_config('TOOLCHAIN_PREFIX', first_toolchain_prefix) +add_old_configure_assignment('TOOLCHAIN_PREFIX', first_toolchain_prefix) # Compilers # ============================================================== -include("compilers-util.configure") +include('compilers-util.configure') def try_preprocess(compiler, language, source, onerror=None): - return try_invoke_compiler(compiler, language, source, ["-E"], onerror) - - -@imports(_from="mozbuild.configure.constants", _import="CompilerType") -@imports(_from="mozbuild.configure.constants", _import="CPU_preprocessor_checks") -@imports(_from="mozbuild.configure.constants", _import="kernel_preprocessor_checks") -@imports(_from="mozbuild.configure.constants", _import="OS_preprocessor_checks") -@imports(_from="six", _import="iteritems") -@imports(_from="textwrap", _import="dedent") -@imports(_from="__builtin__", _import="Exception") + return try_invoke_compiler(compiler, language, source, ['-E'], onerror) + + +@imports(_from='mozbuild.configure.constants', _import='CompilerType') +@imports(_from='mozbuild.configure.constants', + _import='CPU_preprocessor_checks') +@imports(_from='mozbuild.configure.constants', + _import='kernel_preprocessor_checks') +@imports(_from='mozbuild.configure.constants', + _import='OS_preprocessor_checks') +@imports(_from='six', _import='iteritems') +@imports(_from='textwrap', _import='dedent') +@imports(_from='__builtin__', _import='Exception') def get_compiler_info(compiler, language): - """Returns information about the given `compiler` (command line in the + '''Returns information about the given `compiler` (command line in the form of a list or tuple), in the given `language`. The returned information includes: @@ -433,7 +387,7 @@ def get_compiler_info(compiler, language): - the compiler version - the compiler supported language - the compiler supported language version - """ + ''' # Note: We'd normally do a version check for clang, but versions of clang # in Xcode have a completely different versioning scheme despite exposing # the version with the same defines. @@ -442,8 +396,7 @@ def get_compiler_info(compiler, language): # We then only include the version information when the compiler matches # the feature check, so that an unsupported version of clang would have # no version number. - check = dedent( - """\ + check = dedent('''\ #if defined(_MSC_VER) && defined(__clang__) && defined(_MT) %COMPILER "clang-cl" %VERSION __clang_major__.__clang_minor__.__clang_patchlevel__ @@ -462,94 +415,91 @@ def get_compiler_info(compiler, language): #elif __STDC_VERSION__ %STDC_VERSION __STDC_VERSION__ #endif - """ - ) + ''') # While we're doing some preprocessing, we might as well do some more # preprocessor-based tests at the same time, to check the toolchain # matches what we want. for name, preprocessor_checks in ( - ("CPU", CPU_preprocessor_checks), - ("KERNEL", kernel_preprocessor_checks), - ("OS", OS_preprocessor_checks), + ('CPU', CPU_preprocessor_checks), + ('KERNEL', kernel_preprocessor_checks), + ('OS', OS_preprocessor_checks), ): for n, (value, condition) in enumerate(iteritems(preprocessor_checks)): - check += dedent( - """\ + check += dedent('''\ #%(if)s %(condition)s %%%(name)s "%(value)s" - """ - % { - "if": "elif" if n else "if", - "condition": condition, - "name": name, - "value": value, - } - ) - check += "#endif\n" + ''' % { + 'if': 'elif' if n else 'if', + 'condition': condition, + 'name': name, + 'value': value, + }) + check += '#endif\n' # Also check for endianness. The advantage of living in modern times is # that all the modern compilers we support now have __BYTE_ORDER__ defined # by the preprocessor. - check += dedent( - """\ + check += dedent('''\ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ %ENDIANNESS "little" #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ %ENDIANNESS "big" #endif - """ - ) + ''') result = try_preprocess(compiler, language, check) if not result: - raise FatalCheckError("Unknown compiler or compiler not supported.") + raise FatalCheckError( + 'Unknown compiler or compiler not supported.') # Metadata emitted by preprocessors such as GCC with LANG=ja_JP.utf-8 may # have non-ASCII characters. Treat the output as bytearray. data = {} for line in result.splitlines(): - if line.startswith("%"): - k, _, v = line.partition(" ") - k = k.lstrip("%") - data[k] = v.replace(" ", "").lstrip('"').rstrip('"') - log.debug("%s = %s", k, data[k]) + if line.startswith('%'): + k, _, v = line.partition(' ') + k = k.lstrip('%') + data[k] = v.replace(' ', '').lstrip('"').rstrip('"') + log.debug('%s = %s', k, data[k]) try: - type = CompilerType(data["COMPILER"]) + type = CompilerType(data['COMPILER']) except Exception: - raise FatalCheckError("Unknown compiler or compiler not supported.") + raise FatalCheckError( + 'Unknown compiler or compiler not supported.') - cplusplus = int(data.get("cplusplus", "0L").rstrip("L")) - stdc_version = int(data.get("STDC_VERSION", "0L").rstrip("L")) + cplusplus = int(data.get('cplusplus', '0L').rstrip('L')) + stdc_version = int(data.get('STDC_VERSION', '0L').rstrip('L')) - version = data.get("VERSION") + version = data.get('VERSION') if version: version = Version(version) return namespace( type=type, version=version, - cpu=data.get("CPU"), - kernel=data.get("KERNEL"), - endianness=data.get("ENDIANNESS"), - os=data.get("OS"), - language="C++" if cplusplus else "C", + cpu=data.get('CPU'), + kernel=data.get('KERNEL'), + endianness=data.get('ENDIANNESS'), + os=data.get('OS'), + language='C++' if cplusplus else 'C', language_version=cplusplus if cplusplus else stdc_version, ) def same_arch_different_bits(): return ( - ("x86", "x86_64"), - ("ppc", "ppc64"), - ("sparc", "sparc64"), + ('x86', 'x86_64'), + ('ppc', 'ppc64'), + ('sparc', 'sparc64'), ) -@imports(_from="mozbuild.shellutil", _import="quote") -@imports(_from="mozbuild.configure.constants", _import="OS_preprocessor_checks") +@imports(_from='mozbuild.shellutil', _import='quote') +@imports(_from='mozbuild.configure.constants', + _import='OS_preprocessor_checks') def check_compiler(compiler, language, target): info = get_compiler_info(compiler, language) @@ -559,72 +509,66 @@ def check_compiler(compiler, language, target): # -------------------------------------------------------------------- if language != info.language: raise FatalCheckError( - "`%s` is not a %s compiler." % (quote(*compiler), language) - ) + '`%s` is not a %s compiler.' % (quote(*compiler), language)) # Note: We do a strict version check because there sometimes are backwards # incompatible changes in the standard, and not all code that compiles as # C99 compiles as e.g. C11 (as of writing, this is true of libnestegg, for # example) - if info.language == "C" and info.language_version != 199901: - if info.type == "clang-cl": - flags.append("-Xclang") - flags.append("-std=gnu99") + if info.language == 'C' and info.language_version != 199901: + if info.type == 'clang-cl': + flags.append('-Xclang') + flags.append('-std=gnu99') cxx17_version = 201703 - if info.language == "C++": + if info.language == 'C++': if info.language_version != cxx17_version: # MSVC headers include C++17 features, but don't guard them # with appropriate checks. - if info.type == "clang-cl": - flags.append("-Xclang") - flags.append("-std=c++17") + if info.type == 'clang-cl': + flags.append('-Xclang') + flags.append('-std=c++17') else: - flags.append("-std=gnu++17") + flags.append('-std=gnu++17') # Check compiler target # -------------------------------------------------------------------- has_target = False - if info.type == "clang": + if info.type == 'clang': # Add the target explicitly when the target is aarch64 macosx, because # the clang target is named differently, and we need to work around # https://github.com/rust-lang/rust-bindgen/issues/1871 and # https://github.com/alexcrichton/cc-rs/issues/542 so we always want # the target on the command line, even if the compiler would default to # that. - if target.os == "OSX" and target.cpu == "aarch64": - if "--target=arm64-apple-darwin" not in compiler: - flags.append("--target=arm64-apple-darwin") + if target.os == 'OSX' and target.cpu == 'aarch64': + if '--target=arm64-apple-darwin' not in compiler: + flags.append('--target=arm64-apple-darwin') has_target = True - elif ( - not info.kernel - or info.kernel != target.kernel - or not info.endianness - or info.endianness != target.endianness - ): - flags.append("--target=%s" % target.toolchain) + elif not info.kernel or info.kernel != target.kernel or \ + not info.endianness or info.endianness != target.endianness: + flags.append('--target=%s' % target.toolchain) has_target = True # Add target flag when there is an OS mismatch (e.g. building for Android on # Linux). However, only do this if the target OS is in our whitelist, to # keep things the same on other platforms. elif target.os in OS_preprocessor_checks and ( - not info.os or info.os != target.os - ): - flags.append("--target=%s" % target.toolchain) + not info.os or info.os != target.os): + flags.append('--target=%s' % target.toolchain) has_target = True if not has_target and (not info.cpu or info.cpu != target.cpu): same_arch = same_arch_different_bits() if (target.cpu, info.cpu) in same_arch: - flags.append("-m32") + flags.append('-m32') elif (info.cpu, target.cpu) in same_arch: - flags.append("-m64") - elif info.type == "clang-cl" and target.cpu == "aarch64": - flags.append("--target=%s" % target.toolchain) - elif info.type == "clang": - flags.append("--target=%s" % target.toolchain) + flags.append('-m64') + elif info.type == 'clang-cl' and target.cpu == 'aarch64': + flags.append('--target=%s' % target.toolchain) + elif info.type == 'clang': + flags.append('--target=%s' % target.toolchain) return namespace( type=info.type, @@ -637,133 +581,102 @@ def check_compiler(compiler, language, target): ) -@imports(_from="__builtin__", _import="open") -@imports("json") -@imports("os") +@imports(_from='__builtin__', _import='open') +@imports('json') +@imports('os') def get_vc_paths(topsrcdir): def vswhere(args): - program_files = os.environ.get("PROGRAMFILES(X86)") or os.environ.get( - "PROGRAMFILES" - ) + program_files = (os.environ.get('PROGRAMFILES(X86)') or + os.environ.get('PROGRAMFILES')) if not program_files: return [] - vswhere = os.path.join( - program_files, "Microsoft Visual Studio", "Installer", "vswhere.exe" - ) + vswhere = os.path.join(program_files, 'Microsoft Visual Studio', + 'Installer', 'vswhere.exe') if not os.path.exists(vswhere): return [] - return json.loads(check_cmd_output(vswhere, "-format", "json", *args)) - - for install in vswhere( - [ - "-products", - "*", - "-requires", - "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", - ] - ): - path = install["installationPath"] - tools_version = ( - open( - os.path.join( - path, r"VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt" - ), - "r", - ) - .read() - .strip() - ) - tools_path = os.path.join(path, r"VC\Tools\MSVC", tools_version) - yield (Version(install["installationVersion"]), tools_path) + return json.loads(check_cmd_output(vswhere, '-format', 'json', *args)) + + for install in vswhere(['-products', '*', '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64']): + path = install['installationPath'] + tools_version = open(os.path.join( + path, r'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt'), 'r').read().strip() + tools_path = os.path.join( + path, r'VC\Tools\MSVC', tools_version) + yield (Version(install['installationVersion']), tools_path) @depends(host) def host_is_windows(host): - if host.kernel == "WINNT": + if host.kernel == 'WINNT': return True -option( - "--with-visual-studio-version", - nargs=1, - choices=("2017",), - when=host_is_windows, - help="Select a specific Visual Studio version to use", -) +option('--with-visual-studio-version', nargs=1, + choices=('2017',), when=host_is_windows, + help='Select a specific Visual Studio version to use') -@depends("--with-visual-studio-version", when=host_is_windows) +@depends('--with-visual-studio-version', when=host_is_windows) def vs_major_version(value): if value: - return {"2017": 15}[value[0]] - - -option( - env="VC_PATH", - nargs=1, - when=host_is_windows, - help="Path to the Microsoft Visual C/C++ compiler", -) - - -@depends( - host, - vs_major_version, - check_build_environment, - "VC_PATH", - "--with-visual-studio-version", - when=host_is_windows, -) -@imports(_from="__builtin__", _import="sorted") -@imports(_from="operator", _import="itemgetter") -def vc_compiler_paths_for_version( - host, vs_major_version, env, vc_path, vs_release_name -): + return {'2017': 15}[value[0]] + + +option(env='VC_PATH', nargs=1, when=host_is_windows, + help='Path to the Microsoft Visual C/C++ compiler') + + +@depends(host, vs_major_version, check_build_environment, 'VC_PATH', + '--with-visual-studio-version', when=host_is_windows) +@imports(_from='__builtin__', _import='sorted') +@imports(_from='operator', _import='itemgetter') +def vc_compiler_paths_for_version(host, vs_major_version, env, vc_path, vs_release_name): if vc_path and vs_release_name: - die("VC_PATH and --with-visual-studio-version cannot be used together.") + die('VC_PATH and --with-visual-studio-version cannot be used together.') if vc_path: # Use an arbitrary version, it doesn't matter. - all_versions = [(Version("15"), vc_path[0])] + all_versions = [(Version('15'), vc_path[0])] else: all_versions = sorted(get_vc_paths(env.topsrcdir), key=itemgetter(0)) if not all_versions: return if vs_major_version: - versions = [d for (v, d) in all_versions if v.major == vs_major_version] + versions = [d for (v, d) in all_versions if v.major == + vs_major_version] if not versions: - die("Visual Studio %s could not be found!" % vs_release_name) + die('Visual Studio %s could not be found!' % vs_release_name) path = versions[0] else: # Choose the newest version. path = all_versions[-1][1] host_dir = { - "x86_64": "HostX64", - "x86": "HostX86", + 'x86_64': 'HostX64', + 'x86': 'HostX86', }.get(host.cpu) if host_dir: - path = os.path.join(path, "bin", host_dir) + path = os.path.join(path, 'bin', host_dir) return { - "x64": [os.path.join(path, "x64")], + 'x64': [os.path.join(path, 'x64')], # The cross toolchains require DLLs from the native x64 toolchain. - "x86": [os.path.join(path, "x86"), os.path.join(path, "x64")], - "arm64": [os.path.join(path, "arm64"), os.path.join(path, "x64")], + 'x86': [os.path.join(path, 'x86'), os.path.join(path, 'x64')], + 'arm64': [os.path.join(path, 'arm64'), os.path.join(path, 'x64')], } @template def vc_compiler_path_for(host_or_target): - @depends(host_or_target, vc_compiler_paths_for_version, when=host_is_windows) + @depends(host_or_target, vc_compiler_paths_for_version, + when=host_is_windows) def vc_compiler_path(target, paths): vc_target = { - "x86": "x86", - "x86_64": "x64", - "arm": "arm", - "aarch64": "arm64", + 'x86': 'x86', + 'x86_64': 'x64', + 'arm': 'arm', + 'aarch64': 'arm64' }.get(target.cpu) if not paths: return return paths.get(vc_target) - return vc_compiler_path @@ -772,42 +685,32 @@ host_vc_compiler_path = vc_compiler_path_for(host) @dependable -@imports("os") -@imports(_from="os", _import="environ") +@imports('os') +@imports(_from='os', _import='environ') def original_path(): - return environ["PATH"].split(os.pathsep) + return environ['PATH'].split(os.pathsep) @template def toolchain_search_path_for(host_or_target): arch_alias, vc_path = { - host: ("host", host_vc_compiler_path), - target: ("target", vc_compiler_path), + host: ('host', host_vc_compiler_path), + target: ('target', vc_compiler_path), }[host_or_target] - @depends( - dependable(arch_alias), - vc_path, - original_path, - developer_options, - mozbuild_state_path, - ) - @imports("os") - @imports(_from="os", _import="environ") - def toolchain_search_path( - arch_alias, - vc_compiler_path, - original_path, - developer_options, - mozbuild_state_path, - ): + @depends(dependable(arch_alias), vc_path, original_path, developer_options, + mozbuild_state_path) + @imports('os') + @imports(_from='os', _import='environ') + def toolchain_search_path(arch_alias, vc_compiler_path, original_path, + developer_options, mozbuild_state_path): result = list(original_path) if vc_compiler_path: # The second item, if there is one, is necessary to have in $PATH for # Windows to load the required DLLs from there. if len(vc_compiler_path) > 1: - environ["PATH"] = os.pathsep.join(result + vc_compiler_path[1:]) + environ['PATH'] = os.pathsep.join(result + vc_compiler_path[1:]) # The first item is where the programs are going to be result.append(vc_compiler_path[0]) @@ -815,42 +718,35 @@ def toolchain_search_path_for(host_or_target): # Also add in the location to which `mach bootstrap` or # `mach artifact toolchain` installs clang, cbindgen, etc. bootstrapped = [ - os.path.join(mozbuild_state_path, *rest) - for rest in ( - ["clang", "bin"], - ["cbindgen"], - ["dump_syms"], - ["nasm"], - ["lucetc"], - ) - ] + os.path.join(mozbuild_state_path, *rest) for rest in ( + ['clang', 'bin'], + ['cbindgen'], + ['dump_syms'], + ['nasm'], + ['lucetc'], + )] # Also add the rustup install directory for cargo/rustc. - cargo_home = environ.get("CARGO_HOME", "") + cargo_home = environ.get('CARGO_HOME', '') if cargo_home: cargo_home = os.path.abspath(cargo_home) else: - cargo_home = os.path.expanduser(os.path.join("~", ".cargo")) - rustup_path = os.path.join(cargo_home, "bin") + cargo_home = os.path.expanduser(os.path.join('~', '.cargo')) + rustup_path = os.path.join(cargo_home, 'bin') result.append(rustup_path) if developer_options: - log.debug( - "Prioritizing mozbuild state dir in {} toolchain path because " - "you are not building in release mode.".format(arch_alias) - ) + log.debug('Prioritizing mozbuild state dir in {} toolchain path because ' + 'you are not building in release mode.'.format(arch_alias)) search_path = bootstrapped + result else: - log.debug( - "Prioritizing system over mozbuild state dir in {} " - "toolchain path because you are building in " - "release mode.".format(arch_alias) - ) + log.debug('Prioritizing system over mozbuild state dir in {} ' + 'toolchain path because you are building in ' + 'release mode.'.format(arch_alias)) search_path = result + bootstrapped - log.debug("Search path for {} toolchain: {}".format(arch_alias, search_path)) + log.debug('Search path for {} toolchain: {}'.format(arch_alias, search_path)) return search_path - return toolchain_search_path @@ -861,10 +757,10 @@ host_toolchain_search_path = toolchain_search_path_for(host) # As a workaround until bug 1516228 and bug 1516253 are fixed, set the PATH # variable for the build to contain the toolchain search path. @depends(toolchain_search_path, host_toolchain_search_path) -@imports("os") -@imports(_from="os", _import="environ") +@imports('os') +@imports(_from='os', _import='environ') def altered_path(toolchain_search_path, host_toolchain_search_path): - path = environ["PATH"].split(os.pathsep) + path = environ['PATH'].split(os.pathsep) altered_path = list(toolchain_search_path) for p in host_toolchain_search_path: if p not in altered_path: @@ -875,45 +771,42 @@ def altered_path(toolchain_search_path, host_toolchain_search_path): return os.pathsep.join(altered_path) -set_config("PATH", altered_path) +set_config('PATH', altered_path) @template def default_c_compilers(host_or_target, other_c_compiler=None): - """Template defining the set of default C compilers for the host and + '''Template defining the set of default C compilers for the host and target platforms. `host_or_target` is either `host` or `target` (the @depends functions from init.configure. `other_c_compiler` is the `target` C compiler when `host_or_target` is `host`. - """ + ''' assert host_or_target in {host, target} other_c_compiler = () if other_c_compiler is None else (other_c_compiler,) @depends(host_or_target, target, toolchain_prefix, *other_c_compiler) - def default_c_compilers( - host_or_target, target, toolchain_prefix, *other_c_compiler - ): - if host_or_target.kernel == "WINNT": - supported = types = ("clang-cl", "clang") - elif host_or_target.kernel == "Darwin": - types = ("clang",) - supported = ("clang", "gcc") + def default_c_compilers(host_or_target, target, toolchain_prefix, + *other_c_compiler): + if host_or_target.kernel == 'WINNT': + supported = types = ('clang-cl', 'clang') + elif host_or_target.kernel == 'Darwin': + types = ('clang',) + supported = ('clang', 'gcc') else: - supported = types = ("clang", "gcc") + supported = types = ('clang', 'gcc') info = other_c_compiler[0] if other_c_compiler else None if info and info.type in supported: # When getting default C compilers for the host, we prioritize the # same compiler as the target C compiler. prioritized = info.compiler - if info.type == "gcc": + if info.type == 'gcc': same_arch = same_arch_different_bits() - if ( - target.cpu != host_or_target.cpu - and (target.cpu, host_or_target.cpu) not in same_arch - and (host_or_target.cpu, target.cpu) not in same_arch - ): + if (target.cpu != host_or_target.cpu and + (target.cpu, host_or_target.cpu) not in same_arch and + (host_or_target.cpu, target.cpu) not in same_arch): # If the target C compiler is GCC, and it can't be used with # -m32/-m64 for the host, it's probably toolchain-prefixed, # so we prioritize a raw 'gcc' instead. @@ -921,13 +814,13 @@ def default_c_compilers(host_or_target, other_c_compiler=None): types = [prioritized] + [t for t in types if t != info.type] - gcc = ("gcc",) + gcc = ('gcc',) if toolchain_prefix and host_or_target is target: - gcc = tuple("%sgcc" % p for p in toolchain_prefix) + gcc + gcc = tuple('%sgcc' % p for p in toolchain_prefix) + gcc result = [] for type in types: - if type == "gcc": + if type == 'gcc': result.extend(gcc) else: result.append(type) @@ -939,7 +832,7 @@ def default_c_compilers(host_or_target, other_c_compiler=None): @template def default_cxx_compilers(c_compiler, other_c_compiler=None, other_cxx_compiler=None): - """Template defining the set of default C++ compilers for the host and + '''Template defining the set of default C++ compilers for the host and target platforms. `c_compiler` is the @depends function returning a Compiler instance for the desired platform. @@ -951,7 +844,7 @@ def default_cxx_compilers(c_compiler, other_c_compiler=None, other_cxx_compiler= We also factor in the target C++ compiler when getting the default host C++ compiler, using the target C++ compiler if the host and target C compilers are the same. - """ + ''' assert (other_c_compiler is None) == (other_cxx_compiler is None) if other_c_compiler is not None: @@ -969,11 +862,11 @@ def default_cxx_compilers(c_compiler, other_c_compiler=None, other_cxx_compiler= dir = os.path.dirname(c_compiler.compiler) file = os.path.basename(c_compiler.compiler) - if c_compiler.type == "gcc": - return (os.path.join(dir, file.replace("gcc", "g++")),) + if c_compiler.type == 'gcc': + return (os.path.join(dir, file.replace('gcc', 'g++')),) - if c_compiler.type == "clang": - return (os.path.join(dir, file.replace("clang", "clang++")),) + if c_compiler.type == 'clang': + return (os.path.join(dir, file.replace('clang', 'clang++')),) return (c_compiler.compiler,) @@ -982,13 +875,13 @@ def default_cxx_compilers(c_compiler, other_c_compiler=None, other_cxx_compiler= @template def provided_program(env_var, when=None): - """Template handling cases where a program can be specified either as a + '''Template handling cases where a program can be specified either as a path or as a path with applicable arguments. - """ + ''' @depends_if(env_var, when=when) - @imports(_from="itertools", _import="takewhile") - @imports(_from="mozbuild.shellutil", _import="split", _as="shell_split") + @imports(_from='itertools', _import='takewhile') + @imports(_from='mozbuild.shellutil', _import='split', _as='shell_split') def provided(cmd): # Assume the first dash-prefixed item (and any subsequent items) are # command-line options, the item before the dash-prefixed item is @@ -996,36 +889,31 @@ def provided_program(env_var, when=None): # of some kind (e.g. sccache). cmd = shell_split(cmd[0]) - without_flags = list(takewhile(lambda x: not x.startswith("-"), cmd)) + without_flags = list(takewhile(lambda x: not x.startswith('-'), cmd)) return namespace( wrapper=without_flags[:-1], program=without_flags[-1], - flags=cmd[len(without_flags) :], + flags=cmd[len(without_flags):], ) return provided def prepare_flags(host_or_target, macos_sdk): - if macos_sdk and host_or_target.os == "OSX": - return ["-isysroot", macos_sdk] + if macos_sdk and host_or_target.os == 'OSX': + return ['-isysroot', macos_sdk] return [] def minimum_gcc_version(): - return Version("7.1.0") + return Version('7.1.0') @template -def compiler( - language, - host_or_target, - c_compiler=None, - other_compiler=None, - other_c_compiler=None, -): - """Template handling the generic base checks for the compiler for the +def compiler(language, host_or_target, c_compiler=None, other_compiler=None, + other_c_compiler=None): + '''Template handling the generic base checks for the compiler for the given `language` on the given platform (`host_or_target`). `host_or_target` is either `host` or `target` (the @depends functions from init.configure. @@ -1036,35 +924,34 @@ def compiler( When `host_or_target` is `host` and the language is 'C++', `other_c_compiler` is the result of the `compiler` template for the language 'C' for `target`. - """ + ''' assert host_or_target in {host, target} - assert language in ("C", "C++") - assert language == "C" or c_compiler is not None + assert language in ('C', 'C++') + assert language == 'C' or c_compiler is not None assert host_or_target is target or other_compiler is not None - assert language == "C" or host_or_target is target or other_c_compiler is not None + assert language == 'C' or host_or_target is target or \ + other_c_compiler is not None host_or_target_str = { - host: "host", - target: "target", + host: 'host', + target: 'target', }[host_or_target] var = { - ("C", target): "CC", - ("C++", target): "CXX", - ("C", host): "HOST_CC", - ("C++", host): "HOST_CXX", + ('C', target): 'CC', + ('C++', target): 'CXX', + ('C', host): 'HOST_CC', + ('C++', host): 'HOST_CXX', }[language, host_or_target] default_compilers = { - "C": lambda: default_c_compilers(host_or_target, other_compiler), - "C++": lambda: default_cxx_compilers( - c_compiler, other_c_compiler, other_compiler - ), + 'C': lambda: default_c_compilers(host_or_target, other_compiler), + 'C++': lambda: default_cxx_compilers(c_compiler, other_c_compiler, other_compiler), }[language]() - what = "the %s %s compiler" % (host_or_target_str, language) + what = 'the %s %s compiler' % (host_or_target_str, language) - option(env=var, nargs=1, help="Path to %s" % what) + option(env=var, nargs=1, help='Path to %s' % what) # Handle the compiler given by the user through one of the CC/CXX/HOST_CC/ # HOST_CXX variables. @@ -1079,20 +966,15 @@ def compiler( # old-configure complicates things, and for now, we a) can't take the plain # result from check_prog as CC/CXX/HOST_CC/HOST_CXX and b) have to let # old-configure AC_SUBST it (because it's autoconf doing it, not us) - compiler = check_prog( - "_%s" % var, - what=what, - progs=default_compilers, - input=provided_compiler.program, - paths=search_path, - ) + compiler = check_prog('_%s' % var, what=what, progs=default_compilers, + input=provided_compiler.program, + paths=search_path) @depends(compiler, provided_compiler, compiler_wrapper, host_or_target, macos_sdk) - @checking("whether %s can be used" % what, lambda x: bool(x)) - @imports(_from="mozbuild.shellutil", _import="quote") - def valid_compiler( - compiler, provided_compiler, compiler_wrapper, host_or_target, macos_sdk - ): + @checking('whether %s can be used' % what, lambda x: bool(x)) + @imports(_from='mozbuild.shellutil', _import='quote') + def valid_compiler(compiler, provided_compiler, compiler_wrapper, + host_or_target, macos_sdk): wrapper = list(compiler_wrapper or ()) flags = prepare_flags(host_or_target, macos_sdk) if provided_compiler: @@ -1100,12 +982,13 @@ def compiler( # When doing a subconfigure, the compiler is set by old-configure # and it contains the wrappers from --with-compiler-wrapper and # --with-ccache. - if provided_wrapper[: len(wrapper)] == wrapper: - provided_wrapper = provided_wrapper[len(wrapper) :] + if provided_wrapper[:len(wrapper)] == wrapper: + provided_wrapper = provided_wrapper[len(wrapper):] wrapper.extend(provided_wrapper) flags.extend(provided_compiler.flags) - info = check_compiler(wrapper + [compiler] + flags, language, host_or_target) + info = check_compiler(wrapper + [compiler] + flags, language, + host_or_target) # Check that the additional flags we got are enough to not require any # more flags. If we get an exception, just ignore it; it's liable to be @@ -1115,83 +998,65 @@ def compiler( try: if info.flags: flags += info.flags - info = check_compiler( - wrapper + [compiler] + flags, language, host_or_target - ) + info = check_compiler(wrapper + [compiler] + flags, language, + host_or_target) except FatalCheckError: pass if not info.target_cpu or info.target_cpu != host_or_target.cpu: raise FatalCheckError( - "%s %s compiler target CPU (%s) does not match --%s CPU (%s)" - % ( - host_or_target_str.capitalize(), - language, - info.target_cpu or "unknown", - host_or_target_str, - host_or_target.raw_cpu, - ) - ) + '%s %s compiler target CPU (%s) does not match --%s CPU (%s)' + % (host_or_target_str.capitalize(), language, + info.target_cpu or 'unknown', host_or_target_str, + host_or_target.raw_cpu)) - if not info.target_kernel or (info.target_kernel != host_or_target.kernel): + if not info.target_kernel or (info.target_kernel != + host_or_target.kernel): raise FatalCheckError( - "%s %s compiler target kernel (%s) does not match --%s kernel (%s)" - % ( - host_or_target_str.capitalize(), - language, - info.target_kernel or "unknown", - host_or_target_str, - host_or_target.kernel, - ) - ) + '%s %s compiler target kernel (%s) does not match --%s kernel (%s)' + % (host_or_target_str.capitalize(), language, + info.target_kernel or 'unknown', host_or_target_str, + host_or_target.kernel)) - if not info.target_endianness or ( - info.target_endianness != host_or_target.endianness - ): + if not info.target_endianness or (info.target_endianness != + host_or_target.endianness): raise FatalCheckError( - "%s %s compiler target endianness (%s) does not match --%s " - "endianness (%s)" - % ( - host_or_target_str.capitalize(), - language, - info.target_endianness or "unknown", - host_or_target_str, - host_or_target.endianness, - ) - ) + '%s %s compiler target endianness (%s) does not match --%s ' + 'endianness (%s)' + % (host_or_target_str.capitalize(), language, + info.target_endianness or 'unknown', host_or_target_str, + host_or_target.endianness)) # Compiler version checks # =================================================== # Check the compiler version here instead of in `compiler_version` so # that the `checking` message doesn't pretend the compiler can be used # to then bail out one line later. - if info.type == "gcc": - if host_or_target.os == "Android": - raise FatalCheckError( - "GCC is not supported on Android.\n" - "Please use clang from the Android NDK instead." - ) + if info.type == 'gcc': + if host_or_target.os == 'Android': + raise FatalCheckError('GCC is not supported on Android.\n' + 'Please use clang from the Android NDK instead.') gcc_version = minimum_gcc_version() if info.version < gcc_version: raise FatalCheckError( - "Only GCC %d.%d or newer is supported (found version %s)." - % (gcc_version.major, gcc_version.minor, info.version) - ) + 'Only GCC %d.%d or newer is supported (found version %s).' + % (gcc_version.major, gcc_version.minor, info.version)) - if info.type == "clang-cl": - if info.version < "8.0.0": + if info.type == 'clang-cl': + if info.version < '8.0.0': raise FatalCheckError( - "Only clang-cl 8.0 or newer is supported (found version %s)" - % info.version - ) + 'Only clang-cl 8.0 or newer is supported (found version %s)' + % info.version) # If you want to bump the version check here search for # diagnose_if above, and see the associated comment. - if info.type == "clang" and not info.version: - raise FatalCheckError("Only clang/llvm 5.0 or newer is supported.") + if info.type == 'clang' and not info.version: + raise FatalCheckError( + 'Only clang/llvm 5.0 or newer is supported.') if info.flags: - raise FatalCheckError("Unknown compiler or compiler not supported.") + raise FatalCheckError( + 'Unknown compiler or compiler not supported.') return namespace( wrapper=wrapper, @@ -1203,87 +1068,69 @@ def compiler( ) @depends(valid_compiler) - @checking("%s version" % what) + @checking('%s version' % what) def compiler_version(compiler): return compiler.version - if language == "C++": - + if language == 'C++': @depends(valid_compiler, c_compiler) def valid_compiler(compiler, c_compiler): if compiler.type != c_compiler.type: - die( - "The %s C compiler is %s, while the %s C++ compiler is " - "%s. Need to use the same compiler suite.", - host_or_target_str, - c_compiler.type, - host_or_target_str, - compiler.type, - ) + die('The %s C compiler is %s, while the %s C++ compiler is ' + '%s. Need to use the same compiler suite.', + host_or_target_str, c_compiler.type, + host_or_target_str, compiler.type) if compiler.version != c_compiler.version: - die( - "The %s C compiler is version %s, while the %s C++ " - "compiler is version %s. Need to use the same compiler " - "version.", - host_or_target_str, - c_compiler.version, - host_or_target_str, - compiler.version, - ) + die('The %s C compiler is version %s, while the %s C++ ' + 'compiler is version %s. Need to use the same compiler ' + 'version.', + host_or_target_str, c_compiler.version, + host_or_target_str, compiler.version) return compiler # Set CC/CXX/HOST_CC/HOST_CXX for old-configure, which needs the wrapper # and the flags that were part of the user input for those variables to # be provided. - add_old_configure_assignment( - var, - depends_if(valid_compiler)( - lambda x: list(x.wrapper) + [x.compiler] + list(x.flags) - ), - ) + add_old_configure_assignment(var, depends_if(valid_compiler)( + lambda x: list(x.wrapper) + [x.compiler] + list(x.flags))) if host_or_target is target: - add_old_configure_assignment( - "ac_cv_prog_%s" % var, - depends_if(valid_compiler)( - lambda x: list(x.wrapper) + [x.compiler] + list(x.flags) - ), - ) + add_old_configure_assignment('ac_cv_prog_%s' % var, depends_if(valid_compiler)( + lambda x: list(x.wrapper) + [x.compiler] + list(x.flags))) # We check that it works in python configure already. - add_old_configure_assignment("ac_cv_prog_%s_works" % var.lower(), "yes") + add_old_configure_assignment('ac_cv_prog_%s_works' % var.lower(), 'yes') add_old_configure_assignment( - "ac_cv_prog_%s_cross" % var.lower(), - depends(cross_compiling)(lambda x: "yes" if x else "no"), - ) - gcc_like = depends(valid_compiler.type)( - lambda x: "yes" if x in ("gcc", "clang") else "no" - ) - add_old_configure_assignment("ac_cv_prog_%s_g" % var.lower(), gcc_like) - if language == "C": - add_old_configure_assignment("ac_cv_prog_gcc", gcc_like) - if language == "C++": - add_old_configure_assignment("ac_cv_prog_gxx", gcc_like) + 'ac_cv_prog_%s_cross' % var.lower(), + depends(cross_compiling)(lambda x: 'yes' if x else 'no')) + gcc_like = depends(valid_compiler.type)(lambda x: 'yes' if x in ('gcc', 'clang') else 'no') + add_old_configure_assignment('ac_cv_prog_%s_g' % var.lower(), gcc_like) + if language == 'C': + add_old_configure_assignment('ac_cv_prog_gcc', gcc_like) + if language == 'C++': + add_old_configure_assignment('ac_cv_prog_gxx', gcc_like) + # Set CC_TYPE/CC_VERSION/HOST_CC_TYPE/HOST_CC_VERSION to allow # old-configure to do some of its still existing checks. - if language == "C": - set_config("%s_TYPE" % var, valid_compiler.type) - add_old_configure_assignment("%s_TYPE" % var, valid_compiler.type) + if language == 'C': set_config( - "%s_VERSION" % var, depends(valid_compiler.version)(lambda v: str(v)) - ) + '%s_TYPE' % var, valid_compiler.type) + add_old_configure_assignment( + '%s_TYPE' % var, valid_compiler.type) + set_config( + '%s_VERSION' % var, depends(valid_compiler.version)(lambda v: str(v))) valid_compiler = compiler_class(valid_compiler, host_or_target) def compiler_error(): - raise FatalCheckError( - "Failed compiling a simple %s source with %s" % (language, what) - ) + raise FatalCheckError('Failed compiling a simple %s source with %s' + % (language, what)) - valid_compiler.try_compile(check_msg="%s works" % what, onerror=compiler_error) + valid_compiler.try_compile(check_msg='%s works' % what, + onerror=compiler_error) - set_config("%s_BASE_FLAGS" % var, valid_compiler.flags) + set_config('%s_BASE_FLAGS' % var, valid_compiler.flags) # Set CPP/CXXCPP for both the build system and old-configure. We don't # need to check this works for preprocessing, because we already relied @@ -1291,21 +1138,20 @@ def compiler( # in the first place. if host_or_target is target: pp_var = { - "C": "CPP", - "C++": "CXXCPP", + 'C': 'CPP', + 'C++': 'CXXCPP', }[language] preprocessor = depends_if(valid_compiler)( - lambda x: list(x.wrapper) + [x.compiler, "-E"] + list(x.flags) - ) + lambda x: list(x.wrapper) + [x.compiler, '-E'] + list(x.flags)) set_config(pp_var, preprocessor) add_old_configure_assignment(pp_var, preprocessor) - if language == "C": + if language == 'C': linker_var = { - target: "LD", - host: "HOST_LD", + target: 'LD', + host: 'HOST_LD', }[host_or_target] @deprecated_option(env=linker_var, nargs=1) @@ -1316,171 +1162,147 @@ def compiler( @depends(linker) def unused_linker(linker): if linker: - log.warning( - "The value of %s is not used by this build system." % linker_var - ) + log.warning('The value of %s is not used by this build system.' + % linker_var) return valid_compiler -c_compiler = compiler("C", target) -cxx_compiler = compiler("C++", target, c_compiler=c_compiler) -host_c_compiler = compiler("C", host, other_compiler=c_compiler) -host_cxx_compiler = compiler( - "C++", - host, - c_compiler=host_c_compiler, - other_compiler=cxx_compiler, - other_c_compiler=c_compiler, -) +c_compiler = compiler('C', target) +cxx_compiler = compiler('C++', target, c_compiler=c_compiler) +host_c_compiler = compiler('C', host, other_compiler=c_compiler) +host_cxx_compiler = compiler('C++', host, c_compiler=host_c_compiler, + other_compiler=cxx_compiler, + other_c_compiler=c_compiler) # Generic compiler-based conditions. -building_with_gcc = depends(c_compiler)(lambda info: info.type == "gcc") +building_with_gcc = depends(c_compiler)(lambda info: info.type == 'gcc') @depends(cxx_compiler, ccache_prefix) -@imports("os") +@imports('os') def cxx_is_icecream(info, ccache_prefix): - if ( - os.path.islink(info.compiler) - and os.path.basename(os.readlink(info.compiler)) == "icecc" - ): + if (os.path.islink(info.compiler) and os.path.basename( + os.readlink(info.compiler)) == 'icecc'): return True - if ccache_prefix and os.path.basename(ccache_prefix) == "icecc": + if ccache_prefix and os.path.basename(ccache_prefix) == 'icecc': return True - -set_config("CXX_IS_ICECREAM", cxx_is_icecream) +set_config('CXX_IS_ICECREAM', cxx_is_icecream) @depends(c_compiler) def msvs_version(info): # clang-cl emulates the same version scheme as cl. And MSVS_VERSION needs to # be set for GYP on Windows. - if info.type == "clang-cl": - return "2017" + if info.type == 'clang-cl': + return '2017' - return "" + return '' -set_config("MSVS_VERSION", msvs_version) +set_config('MSVS_VERSION', msvs_version) -include("compile-checks.configure") -include("arm.configure", when=depends(target.cpu)(lambda cpu: cpu == "arm")) +include('compile-checks.configure') +include('arm.configure', when=depends(target.cpu)(lambda cpu: cpu == 'arm')) @depends(host, host_os_kernel_major_version, target) def needs_macos_sdk_headers_check(host, version, target): # Only an issue on Mac OS X 10.14 (and probably above). - if host.kernel != "Darwin" or target.kernel != "Darwin" or version < "18": + if host.kernel != 'Darwin' or target.kernel !='Darwin' or version < '18': return return True -@depends( - cxx_compiler.try_run( - header="#include_next ", - check_msg="for macOS SDK headers", - when=needs_macos_sdk_headers_check, - ), - when=needs_macos_sdk_headers_check, -) +@depends(cxx_compiler.try_run(header='#include_next ', + check_msg='for macOS SDK headers', + when=needs_macos_sdk_headers_check), + when=needs_macos_sdk_headers_check) def check_have_mac_10_14_sdk(value): if value: return - die( - "System inttypes.h not found. Please try running " - "`open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg` " - "and following the instructions to install the necessary headers" - ) + die('System inttypes.h not found. Please try running ' + '`open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg` ' + 'and following the instructions to install the necessary headers') -@depends( - have_64_bit, - try_compile( - body='static_assert(sizeof(void *) == 8, "")', check_msg="for 64-bit OS" - ), -) +@depends(have_64_bit, + try_compile(body='static_assert(sizeof(void *) == 8, "")', + check_msg='for 64-bit OS')) def check_have_64_bit(have_64_bit, compiler_have_64_bit): if have_64_bit != compiler_have_64_bit: - configure_error( - "The target compiler does not agree with configure " - "about the target bitness." - ) + configure_error('The target compiler does not agree with configure ' + 'about the target bitness.') @depends(cxx_compiler, target) def needs_libstdcxx_newness_check(cxx_compiler, target): # We only have to care about this on Linux and MinGW. - if cxx_compiler.type == "clang-cl": + if cxx_compiler.type == 'clang-cl': return - if target.kernel not in ("Linux", "WINNT"): + if target.kernel not in ('Linux', 'WINNT'): return - if target.os == "Android": + if target.os == 'Android': return return True def die_on_old_libstdcxx(): - die( - "The libstdc++ in use is not new enough. Please run " - "./mach bootstrap to update your compiler, or update your system " - "libstdc++ installation." - ) - - -try_compile( - includes=["cstddef"], - body="\n".join( - [ - # _GLIBCXX_RELEASE showed up in libstdc++ 7. - "#if defined(__GLIBCXX__) && !defined(_GLIBCXX_RELEASE)", - "# error libstdc++ not new enough", - "#endif", - "#if defined(_GLIBCXX_RELEASE)", - "# if _GLIBCXX_RELEASE < %d" % minimum_gcc_version().major, - "# error libstdc++ not new enough", - "# else", - " (void) 0", - "# endif", - "#endif", - ] - ), - check_msg="for new enough STL headers from libstdc++", - when=needs_libstdcxx_newness_check, - onerror=die_on_old_libstdcxx, -) + die('The libstdc++ in use is not new enough. Please run ' + './mach bootstrap to update your compiler, or update your system ' + 'libstdc++ installation.') + +try_compile(includes=['cstddef'], + body='\n'.join([ + # _GLIBCXX_RELEASE showed up in libstdc++ 7. + '#if defined(__GLIBCXX__) && !defined(_GLIBCXX_RELEASE)', + '# error libstdc++ not new enough', + '#endif', + '#if defined(_GLIBCXX_RELEASE)', + '# if _GLIBCXX_RELEASE < %d' % minimum_gcc_version().major, + '# error libstdc++ not new enough', + '# else', + ' (void) 0', + '# endif', + '#endif', + ]), + check_msg='for new enough STL headers from libstdc++', + when=needs_libstdcxx_newness_check, + onerror=die_on_old_libstdcxx) @depends(c_compiler, target) def default_debug_flags(compiler_info, target): # Debug info is ON by default. - if compiler_info.type == "clang-cl": - return "-Z7" - elif target.kernel == "WINNT" and compiler_info.type == "clang": - return "-g -gcodeview" - return "-g" + if compiler_info.type == 'clang-cl': + return '-Z7' + elif target.kernel == 'WINNT' and compiler_info.type == 'clang': + return '-g -gcodeview' + return '-g' -option(env="MOZ_DEBUG_FLAGS", nargs=1, help="Debug compiler flags") +option(env='MOZ_DEBUG_FLAGS', + nargs=1, + help='Debug compiler flags') -imply_option("--enable-debug-symbols", depends_if("--enable-debug")(lambda v: v)) +imply_option('--enable-debug-symbols', + depends_if('--enable-debug')(lambda v: v)) -option( - "--disable-debug-symbols", - nargs="?", - help="Disable debug symbols using the given compiler flags", -) +option('--disable-debug-symbols', + nargs='?', + help='Disable debug symbols using the given compiler flags') -set_config("MOZ_DEBUG_SYMBOLS", depends_if("--enable-debug-symbols")(lambda _: True)) +set_config('MOZ_DEBUG_SYMBOLS', + depends_if('--enable-debug-symbols')(lambda _: True)) -@depends("MOZ_DEBUG_FLAGS", "--enable-debug-symbols", default_debug_flags) +@depends('MOZ_DEBUG_FLAGS', '--enable-debug-symbols', default_debug_flags) def debug_flags(env_debug_flags, enable_debug_flags, default_debug_flags): # If MOZ_DEBUG_FLAGS is set, and --enable-debug-symbols is set to a value, # --enable-debug-symbols takes precedence. Note, the value of @@ -1492,8 +1314,8 @@ def debug_flags(env_debug_flags, enable_debug_flags, default_debug_flags): return default_debug_flags -set_config("MOZ_DEBUG_FLAGS", debug_flags) -add_old_configure_assignment("MOZ_DEBUG_FLAGS", debug_flags) +set_config('MOZ_DEBUG_FLAGS', debug_flags) +add_old_configure_assignment('MOZ_DEBUG_FLAGS', debug_flags) @depends(c_compiler) @@ -1508,15 +1330,15 @@ def color_cflags(info): # value changes to e.g. "=always", exact string match may fail and # multiple color flags could be added. So examine downstream consumers # before adding flags to return values. - if info.type == "gcc": - return "-fdiagnostics-color" - elif info.type == "clang": - return "-fcolor-diagnostics" + if info.type == 'gcc': + return '-fdiagnostics-color' + elif info.type == 'clang': + return '-fcolor-diagnostics' else: - return "" + return '' -set_config("COLOR_CFLAGS", color_cflags) +set_config('COLOR_CFLAGS', color_cflags) # Some standard library headers (notably bionic on Android) declare standard # functions (e.g. getchar()) and also #define macros for those standard @@ -1568,54 +1390,48 @@ set_config("COLOR_CFLAGS", color_cflags) @depends(c_compiler, target) def libcxx_override_visibility(c_compiler, target): - if c_compiler.type == "clang" and target.os == "Android": + if c_compiler.type == 'clang' and target.os == 'Android': return namespace( - empty="", - hide_from_abi="__attribute__((__exclude_from_explicit_instantiation__))", + empty='', + hide_from_abi='__attribute__((__exclude_from_explicit_instantiation__))', ) -set_define("_LIBCPP_INLINE_VISIBILITY", libcxx_override_visibility.empty) -set_define("_LIBCPP_ALWAYS_INLINE", libcxx_override_visibility.empty) - -set_define("_LIBCPP_HIDE_FROM_ABI", libcxx_override_visibility.hide_from_abi) +set_define('_LIBCPP_INLINE_VISIBILITY', libcxx_override_visibility.empty) +set_define('_LIBCPP_ALWAYS_INLINE', libcxx_override_visibility.empty) +set_define('_LIBCPP_HIDE_FROM_ABI', libcxx_override_visibility.hide_from_abi) @depends(target, check_build_environment) def visibility_flags(target, env): - if target.os != "WINNT": - if target.kernel == "Darwin": - return ("-fvisibility=hidden", "-fvisibility-inlines-hidden") - return ( - "-I%s/system_wrappers" % os.path.join(env.dist), - "-include", - "%s/config/gcc_hidden.h" % env.topsrcdir, - ) + if target.os != 'WINNT': + if target.kernel == 'Darwin': + return ('-fvisibility=hidden', '-fvisibility-inlines-hidden') + return ('-I%s/system_wrappers' % os.path.join(env.dist), + '-include', + '%s/config/gcc_hidden.h' % env.topsrcdir) @depends(target, visibility_flags) def wrap_system_includes(target, visibility_flags): - if visibility_flags and target.kernel != "Darwin": + if visibility_flags and target.kernel != 'Darwin': return True -set_define( - "HAVE_VISIBILITY_HIDDEN_ATTRIBUTE", - depends(visibility_flags)(lambda v: bool(v) or None), -) -set_define( - "HAVE_VISIBILITY_ATTRIBUTE", depends(visibility_flags)(lambda v: bool(v) or None) -) -set_config("WRAP_SYSTEM_INCLUDES", wrap_system_includes) -set_config("VISIBILITY_FLAGS", visibility_flags) +set_define('HAVE_VISIBILITY_HIDDEN_ATTRIBUTE', + depends(visibility_flags)(lambda v: bool(v) or None)) +set_define('HAVE_VISIBILITY_ATTRIBUTE', + depends(visibility_flags)(lambda v: bool(v) or None)) +set_config('WRAP_SYSTEM_INCLUDES', wrap_system_includes) +set_config('VISIBILITY_FLAGS', visibility_flags) @template def depend_cflags(host_or_target_c_compiler): @depends(host_or_target_c_compiler) def depend_cflags(host_or_target_c_compiler): - if host_or_target_c_compiler.type != "clang-cl": - return ["-MD", "-MP", "-MF $(MDDEPDIR)/$(@F).pp"] + if host_or_target_c_compiler.type != 'clang-cl': + return ['-MD', '-MP', '-MF $(MDDEPDIR)/$(@F).pp'] else: # clang-cl doesn't accept the normal -MD -MP -MF options that clang # does, but the underlying cc1 binary understands how to generate @@ -1623,35 +1439,30 @@ def depend_cflags(host_or_target_c_compiler): # normal clang driver sends to cc1 when given the "correct" # dependency options. return [ - "-Xclang", - "-MP", - "-Xclang", - "-dependency-file", - "-Xclang", - "$(MDDEPDIR)/$(@F).pp", - "-Xclang", - "-MT", - "-Xclang", - "$@", + '-Xclang', '-MP', + '-Xclang', '-dependency-file', + '-Xclang', '$(MDDEPDIR)/$(@F).pp', + '-Xclang', '-MT', + '-Xclang', '$@' ] return depend_cflags -set_config("_DEPEND_CFLAGS", depend_cflags(c_compiler)) -set_config("_HOST_DEPEND_CFLAGS", depend_cflags(host_c_compiler)) +set_config('_DEPEND_CFLAGS', depend_cflags(c_compiler)) +set_config('_HOST_DEPEND_CFLAGS', depend_cflags(host_c_compiler)) @depends(c_compiler) def preprocess_option(compiler): # The uses of PREPROCESS_OPTION depend on the spacing for -o/-Fi. - if compiler.type in ("gcc", "clang"): - return "-E -o " + if compiler.type in ('gcc', 'clang'): + return '-E -o ' else: - return "-P -Fi" + return '-P -Fi' -set_config("PREPROCESS_OPTION", preprocess_option) +set_config('PREPROCESS_OPTION', preprocess_option) # We only want to include windows.configure when we are compiling on @@ -1660,135 +1471,120 @@ set_config("PREPROCESS_OPTION", preprocess_option) @depends(target, host) def is_windows(target, host): - return host.kernel == "WINNT" or target.kernel == "WINNT" + return host.kernel == 'WINNT' or target.kernel == 'WINNT' -include("windows.configure", when=is_windows) +include('windows.configure', when=is_windows) # On Power ISA, determine compiler flags for VMX, VSX and VSX-3. -set_config( - "PPC_VMX_FLAGS", - ["-maltivec"], - when=depends(target.cpu)(lambda cpu: cpu.startswith("ppc")), -) +set_config('PPC_VMX_FLAGS', + ['-maltivec'], + when=depends(target.cpu)(lambda cpu: cpu.startswith('ppc'))) -set_config( - "PPC_VSX_FLAGS", - ["-mvsx"], - when=depends(target.cpu)(lambda cpu: cpu.startswith("ppc")), -) +set_config('PPC_VSX_FLAGS', + ['-mvsx'], + when=depends(target.cpu)(lambda cpu: cpu.startswith('ppc'))) -set_config( - "PPC_VSX3_FLAGS", - ["-mvsx", "-mcpu=power9"], - when=depends(target.cpu)(lambda cpu: cpu.startswith("ppc")), -) +set_config('PPC_VSX3_FLAGS', + ['-mvsx','-mcpu=power9'], + when=depends(target.cpu)(lambda cpu: cpu.startswith('ppc'))) # ASAN # ============================================================== -option("--enable-address-sanitizer", help="Enable Address Sanitizer") +option('--enable-address-sanitizer', help='Enable Address Sanitizer') -@depends(when="--enable-address-sanitizer") +@depends(when='--enable-address-sanitizer') def asan(): return True -add_old_configure_assignment("MOZ_ASAN", asan) +add_old_configure_assignment('MOZ_ASAN', asan) # MSAN # ============================================================== -option("--enable-memory-sanitizer", help="Enable Memory Sanitizer") +option('--enable-memory-sanitizer', help='Enable Memory Sanitizer') -@depends(when="--enable-memory-sanitizer") +@depends(when='--enable-memory-sanitizer') def msan(): return True -add_old_configure_assignment("MOZ_MSAN", msan) +add_old_configure_assignment('MOZ_MSAN', msan) # TSAN # ============================================================== -option("--enable-thread-sanitizer", help="Enable Thread Sanitizer") +option('--enable-thread-sanitizer', help='Enable Thread Sanitizer') -@depends(when="--enable-thread-sanitizer") +@depends(when='--enable-thread-sanitizer') def tsan(): return True -add_old_configure_assignment("MOZ_TSAN", tsan) +add_old_configure_assignment('MOZ_TSAN', tsan) # UBSAN # ============================================================== -option( - "--enable-undefined-sanitizer", nargs="*", help="Enable UndefinedBehavior Sanitizer" -) - +option('--enable-undefined-sanitizer', + nargs='*', + help='Enable UndefinedBehavior Sanitizer') -@depends_if("--enable-undefined-sanitizer") +@depends_if('--enable-undefined-sanitizer') def ubsan(options): default_checks = [ - "bool", - "bounds", - "enum", - "integer-divide-by-zero", - "object-size", - "pointer-overflow", - "return", - "vla-bound", + 'bool', + 'bounds', + 'enum', + 'integer-divide-by-zero', + 'object-size', + 'pointer-overflow', + 'return', + 'vla-bound', ] checks = options if len(options) else default_checks - return ",".join(checks) - + return ','.join(checks) -add_old_configure_assignment("MOZ_UBSAN_CHECKS", ubsan) +add_old_configure_assignment('MOZ_UBSAN_CHECKS', ubsan) -option( - "--enable-signed-overflow-sanitizer", - help="Enable UndefinedBehavior Sanitizer (Signed Integer Overflow Parts)", -) +option('--enable-signed-overflow-sanitizer', + help='Enable UndefinedBehavior Sanitizer (Signed Integer Overflow Parts)') -@depends(when="--enable-signed-overflow-sanitizer") +@depends(when='--enable-signed-overflow-sanitizer') def ub_signed_overflow_san(): return True -add_old_configure_assignment("MOZ_SIGNED_OVERFLOW_SANITIZE", ub_signed_overflow_san) +add_old_configure_assignment('MOZ_SIGNED_OVERFLOW_SANITIZE', ub_signed_overflow_san) -option( - "--enable-unsigned-overflow-sanitizer", - help="Enable UndefinedBehavior Sanitizer (Unsigned Integer Overflow Parts)", -) +option('--enable-unsigned-overflow-sanitizer', + help='Enable UndefinedBehavior Sanitizer (Unsigned Integer Overflow Parts)') -@depends(when="--enable-unsigned-overflow-sanitizer") +@depends(when='--enable-unsigned-overflow-sanitizer') def ub_unsigned_overflow_san(): return True -add_old_configure_assignment("MOZ_UNSIGNED_OVERFLOW_SANITIZE", ub_unsigned_overflow_san) +add_old_configure_assignment('MOZ_UNSIGNED_OVERFLOW_SANITIZE', ub_unsigned_overflow_san) # Security Hardening # ============================================================== -option( - "--enable-hardening", - env="MOZ_SECURITY_HARDENING", - help="Enables security hardening compiler options", -) +option('--enable-hardening', env='MOZ_SECURITY_HARDENING', + help='Enables security hardening compiler options') # This function is a bit confusing. It adds or removes hardening flags in @@ -1800,19 +1596,12 @@ option( # flag. --disable-hardening will omit the security flags. (However, not all # possible security flags will be omitted by --disable-hardening, as many are # compiler-default options we do not explicitly enable.) -@depends( - "--enable-hardening", - "--enable-address-sanitizer", - "--enable-debug", - "--enable-optimize", - c_compiler, - target, -) -def security_hardening_cflags( - hardening_flag, asan, debug, optimize, c_compiler, target -): - compiler_is_gccish = c_compiler.type in ("gcc", "clang") - mingw_clang = c_compiler.type == "clang" and target.os == "WINNT" +@depends('--enable-hardening', '--enable-address-sanitizer', + '--enable-debug', '--enable-optimize', c_compiler, target) +def security_hardening_cflags(hardening_flag, asan, debug, optimize, c_compiler, + target): + compiler_is_gccish = c_compiler.type in ('gcc', 'clang') + mingw_clang = c_compiler.type == 'clang' and target.os == 'WINNT' flags = [] ldflags = [] @@ -1827,15 +1616,15 @@ def security_hardening_cflags( # Also, undefine it before defining it just in case a distro adds it, see Bug 1418398 if compiler_is_gccish and optimize and not asan: # Don't enable FORTIFY_SOURCE on Android on the top-level, but do enable in js/ - if target.os != "Android": + if target.os != 'Android': flags.append("-U_FORTIFY_SOURCE") flags.append("-D_FORTIFY_SOURCE=2") js_flags.append("-U_FORTIFY_SOURCE") js_flags.append("-D_FORTIFY_SOURCE=2") if mingw_clang: # mingw-clang needs to link in ssp which is not done by default - ldflags.append("-lssp") - js_ldflags.append("-lssp") + ldflags.append('-lssp') + js_ldflags.append('-lssp') # fstack-protector ------------------------------------ # Enable only if hardening is not disabled and ASAN is @@ -1849,18 +1638,14 @@ def security_hardening_cflags( # ftrivial-auto-var-init ------------------------------ # Initialize local variables with a 0xAA pattern in clang debug builds. # Linux32 fails some xpcshell tests with -ftrivial-auto-var-init - linux32 = target.kernel == "Linux" and target.cpu == "x86" - if ( - (c_compiler.type == "clang" or c_compiler.type == "clang-cl") - and c_compiler.version >= "8" - and debug - and not linux32 - ): - if c_compiler.type == "clang-cl": - flags.append("-Xclang") - js_flags.append("-Xclang") - flags.append("-ftrivial-auto-var-init=pattern") - js_flags.append("-ftrivial-auto-var-init=pattern") + linux32 = target.kernel == 'Linux' and target.cpu == 'x86' + if (c_compiler.type == 'clang' or c_compiler.type == 'clang-cl') and \ + c_compiler.version >= '8' and debug and not linux32: + if c_compiler.type == 'clang-cl': + flags.append('-Xclang') + js_flags.append('-Xclang') + flags.append('-ftrivial-auto-var-init=pattern') + js_flags.append('-ftrivial-auto-var-init=pattern') # ASLR ------------------------------------------------ # ASLR (dynamicbase) is enabled by default in clang-cl; but the @@ -1870,12 +1655,9 @@ def security_hardening_cflags( js_ldflags.append("-Wl,--dynamicbase") # Control Flow Guard (CFG) ---------------------------- - if ( - c_compiler.type == "clang-cl" - and c_compiler.version >= "8" - and (target.cpu != "aarch64" or c_compiler.version >= "8.0.1") - ): - if target.cpu == "aarch64" and c_compiler.version >= "10.0.0": + if c_compiler.type == 'clang-cl' and c_compiler.version >= '8' and \ + (target.cpu != 'aarch64' or c_compiler.version >= '8.0.1'): + if target.cpu == 'aarch64' and c_compiler.version >= '10.0.0': # The added checks in clang 10 make arm64 builds crash. (Bug 1639318) flags.append("-guard:cf,nochecks") js_flags.append("-guard:cf,nochecks") @@ -1897,7 +1679,7 @@ def security_hardening_cflags( # Do not merge variables for ASAN; can detect some subtle bugs if asan: # clang-cl does not recognize the flag, it must be passed down to clang - if c_compiler.type == "clang-cl": + if c_compiler.type == 'clang-cl': flags.append("-Xclang") flags.append("-fno-common") @@ -1909,72 +1691,58 @@ def security_hardening_cflags( ) -set_config("MOZ_HARDENING_CFLAGS", security_hardening_cflags.flags) -set_config("MOZ_HARDENING_LDFLAGS", security_hardening_cflags.ldflags) -set_config("MOZ_HARDENING_CFLAGS_JS", security_hardening_cflags.js_flags) -set_config("MOZ_HARDENING_LDFLAGS_JS", security_hardening_cflags.js_ldflags) +set_config('MOZ_HARDENING_CFLAGS', security_hardening_cflags.flags) +set_config('MOZ_HARDENING_LDFLAGS', security_hardening_cflags.ldflags) +set_config('MOZ_HARDENING_CFLAGS_JS', security_hardening_cflags.js_flags) +set_config('MOZ_HARDENING_LDFLAGS_JS', security_hardening_cflags.js_ldflags) # Frame pointers # ============================================================== @depends(c_compiler) def frame_pointer_flags(compiler): - if compiler.type == "clang-cl": + if compiler.type == 'clang-cl': return namespace( - enable=["-Oy-"], - disable=["-Oy"], + enable=['-Oy-'], + disable=['-Oy'], ) return namespace( - enable=["-fno-omit-frame-pointer", "-funwind-tables"], - disable=["-fomit-frame-pointer", "-funwind-tables"], + enable=['-fno-omit-frame-pointer', '-funwind-tables'], + disable=['-fomit-frame-pointer', '-funwind-tables'], ) -@depends( - moz_optimize.optimize, - moz_debug, - target, - "--enable-memory-sanitizer", - "--enable-address-sanitizer", - "--enable-undefined-sanitizer", -) +@depends(moz_optimize.optimize, moz_debug, target, + '--enable-memory-sanitizer', '--enable-address-sanitizer', + '--enable-undefined-sanitizer') def frame_pointer_default(optimize, debug, target, msan, asan, ubsan): - return bool( - not optimize - or debug - or msan - or asan - or ubsan - or (target.os == "WINNT" and target.cpu in ("x86", "aarch64")) - ) + return bool(not optimize or debug or msan or asan or ubsan or \ + (target.os == 'WINNT' and target.cpu in ('x86', 'aarch64'))) -option( - "--enable-frame-pointers", - default=frame_pointer_default, - help="{Enable|Disable} frame pointers", -) +option('--enable-frame-pointers', default=frame_pointer_default, + help='{Enable|Disable} frame pointers') -@depends("--enable-frame-pointers", frame_pointer_flags) +@depends('--enable-frame-pointers', frame_pointer_flags) def frame_pointer_flags(enable, flags): if enable: return flags.enable return flags.disable -set_config("MOZ_FRAMEPTR_FLAGS", frame_pointer_flags) +set_config('MOZ_FRAMEPTR_FLAGS', frame_pointer_flags) # nasm detection # ============================================================== -nasm = check_prog("NASM", ["nasm"], allow_missing=True, paths=toolchain_search_path) +nasm = check_prog('NASM', ['nasm'], allow_missing=True, paths=toolchain_search_path) @depends_if(nasm) -@checking("nasm version") +@checking('nasm version') def nasm_version(nasm): - (retcode, stdout, _) = get_cmd_output(nasm, "-v") + (retcode, stdout, _) = get_cmd_output(nasm, '-v') if retcode: # mac stub binary return None @@ -1993,31 +1761,30 @@ def nasm_minor_version(nasm_version): return str(nasm_version.minor) -set_config("NASM_MAJOR_VERSION", nasm_major_version) -set_config("NASM_MINOR_VERSION", nasm_minor_version) +set_config('NASM_MAJOR_VERSION', nasm_major_version) +set_config('NASM_MINOR_VERSION', nasm_minor_version) @depends(nasm, target) def nasm_asflags(nasm, target): if nasm: asflags = { - ("OSX", "x86"): ["-f", "macho32"], - ("OSX", "x86_64"): ["-f", "macho64"], - ("WINNT", "x86"): ["-f", "win32"], - ("WINNT", "x86_64"): ["-f", "win64"], + ('OSX', 'x86'): ['-f', 'macho32'], + ('OSX', 'x86_64'): ['-f', 'macho64'], + ('WINNT', 'x86'): ['-f', 'win32'], + ('WINNT', 'x86_64'): ['-f', 'win64'], }.get((target.os, target.cpu), None) if asflags is None: # We're assuming every x86 platform we support that's # not Windows or Mac is ELF. - if target.cpu == "x86": - asflags = ["-f", "elf32"] - elif target.cpu == "x86_64": - asflags = ["-f", "elf64"] + if target.cpu == 'x86': + asflags = ['-f', 'elf32'] + elif target.cpu == 'x86_64': + asflags = ['-f', 'elf64'] return asflags -set_config("NASM_ASFLAGS", nasm_asflags) - +set_config('NASM_ASFLAGS', nasm_asflags) @depends(nasm_asflags) def have_nasm(value): @@ -2030,45 +1797,43 @@ def have_yasm(yasm_asflags): if yasm_asflags: return True +set_config('HAVE_NASM', have_nasm) -set_config("HAVE_NASM", have_nasm) - -set_config("HAVE_YASM", have_yasm) +set_config('HAVE_YASM', have_yasm) # Until the YASM variable is not necessary in old-configure. -add_old_configure_assignment("YASM", have_yasm) +add_old_configure_assignment('YASM', have_yasm) # Code Coverage # ============================================================== -option("--enable-coverage", env="MOZ_CODE_COVERAGE", help="Enable code coverage") +option('--enable-coverage', env='MOZ_CODE_COVERAGE', + help='Enable code coverage') -@depends("--enable-coverage") +@depends('--enable-coverage') def code_coverage(value): if value: return True -set_config("MOZ_CODE_COVERAGE", code_coverage) -set_define("MOZ_CODE_COVERAGE", code_coverage) - +set_config('MOZ_CODE_COVERAGE', code_coverage) +set_define('MOZ_CODE_COVERAGE', code_coverage) @depends(target, c_compiler, vc_path, check_build_environment, when=code_coverage) -@imports("os") -@imports("re") -@imports(_from="__builtin__", _import="open") +@imports('os') +@imports('re') +@imports(_from='__builtin__', _import='open') def coverage_cflags(target, c_compiler, vc_path, build_env): - cflags = ["--coverage"] + cflags = ['--coverage'] # clang 11 no longer accepts this flag (its behavior became the default) - if c_compiler.type in ("clang", "clang-cl") and c_compiler.version < "11.0.0": + if c_compiler.type in ('clang', 'clang-cl') and c_compiler.version < '11.0.0': cflags += [ - "-Xclang", - "-coverage-no-function-names-in-data", + '-Xclang', '-coverage-no-function-names-in-data', ] - if target.os == "WINNT" and c_compiler.type == "clang-cl": + if target.os == 'WINNT' and c_compiler.type == 'clang-cl': # The Visual Studio directory is the parent of the Visual C++ directory. vs_path = os.path.dirname(vc_path) @@ -2077,49 +1842,46 @@ def coverage_cflags(target, c_compiler, vc_path, build_env): vs_path = os.path.realpath(vs_path) cflags += [ - "-fprofile-exclude-files=^{}.*$".format(re.escape(vs_path)), + '-fprofile-exclude-files=^{}.*$'.format(re.escape(vs_path)), ] - response_file_path = os.path.join(build_env.topobjdir, "code_coverage_cflags") + response_file_path = os.path.join(build_env.topobjdir, 'code_coverage_cflags') - with open(response_file_path, "w") as f: - f.write(" ".join(cflags)) + with open(response_file_path, 'w') as f: + f.write(' '.join(cflags)) - return ["@{}".format(response_file_path)] + return ['@{}'.format(response_file_path)] - -set_config("COVERAGE_CFLAGS", coverage_cflags) +set_config('COVERAGE_CFLAGS', coverage_cflags) # ============================================================== -option(env="RUSTFLAGS", nargs=1, help="Rust compiler flags") -set_config("RUSTFLAGS", depends("RUSTFLAGS")(lambda flags: flags)) +option(env='RUSTFLAGS', + nargs=1, + help='Rust compiler flags') +set_config('RUSTFLAGS', depends('RUSTFLAGS')(lambda flags: flags)) # Rust compiler flags # ============================================================== -option( - env="RUSTC_OPT_LEVEL", - nargs=1, - help="Rust compiler optimization level (-C opt-level=%s)", -) +option(env='RUSTC_OPT_LEVEL', + nargs=1, + help='Rust compiler optimization level (-C opt-level=%s)') # --enable-release kicks in full optimizations. -imply_option("RUSTC_OPT_LEVEL", "2", when="--enable-release") +imply_option('RUSTC_OPT_LEVEL', '2', when='--enable-release') -@depends("RUSTC_OPT_LEVEL", moz_optimize) +@depends('RUSTC_OPT_LEVEL', moz_optimize) def rustc_opt_level(opt_level_option, moz_optimize): if opt_level_option: return opt_level_option[0] else: - return "1" if moz_optimize.optimize else "0" + return '1' if moz_optimize.optimize else '0' -@depends( - rustc_opt_level, debug_rust, "--enable-debug-symbols", "--enable-frame-pointers" -) +@depends(rustc_opt_level, debug_rust, '--enable-debug-symbols', '--enable-frame-pointers') def rust_compile_flags(opt_level, debug_rust, debug_symbols, frame_pointers): # Cargo currently supports only two interesting profiles for building: # development and release. Those map (roughly) to --enable-debug and @@ -2138,26 +1900,27 @@ def rust_compile_flags(opt_level, debug_rust, debug_symbols, frame_pointers): # opt-level=0 implies -C debug-assertions, which may not be desired # unless Rust debugging is enabled. - if opt_level == "0" and not debug_rust: + if opt_level == '0' and not debug_rust: debug_assertions = False if debug_symbols: - debug_info = "2" + debug_info = '2' opts = [] if opt_level is not None: - opts.append("opt-level=%s" % opt_level) + opts.append('opt-level=%s' % opt_level) if debug_assertions is not None: - opts.append("debug-assertions=%s" % ("yes" if debug_assertions else "no")) + opts.append('debug-assertions=%s' % + ('yes' if debug_assertions else 'no')) if debug_info is not None: - opts.append("debuginfo=%s" % debug_info) + opts.append('debuginfo=%s' % debug_info) if frame_pointers: - opts.append("force-frame-pointers=yes") + opts.append('force-frame-pointers=yes') flags = [] for opt in opts: - flags.extend(["-C", opt]) + flags.extend(['-C', opt]) return flags @@ -2166,52 +1929,38 @@ def rust_compile_flags(opt_level, debug_rust, debug_symbols, frame_pointers): # ============================================================== -option("--disable-cargo-incremental", help="Disable incremental rust compilation.") - - -@depends( - rustc_opt_level, - debug_rust, - "MOZ_AUTOMATION", - code_coverage, - "--disable-cargo-incremental", - using_sccache, - "RUSTC_WRAPPER", -) -@imports("os") -def cargo_incremental( - opt_level, - debug_rust, - automation, - code_coverage, - enabled, - using_sccache, - rustc_wrapper, -): +option('--disable-cargo-incremental', + help='Disable incremental rust compilation.') + +@depends(rustc_opt_level, debug_rust, 'MOZ_AUTOMATION', code_coverage, + '--disable-cargo-incremental', using_sccache, 'RUSTC_WRAPPER') +@imports('os') +def cargo_incremental(opt_level, debug_rust, automation, code_coverage, + enabled, using_sccache, rustc_wrapper): """Return a value for the CARGO_INCREMENTAL environment variable.""" if not enabled: - return "0" + return '0' # We never want to use incremental compilation in automation. sccache # handles our automation use case much better than incremental compilation # would. if automation: - return "0" + return '0' # Coverage instrumentation doesn't play well with incremental compilation # https://github.com/rust-lang/rust/issues/50203. if code_coverage: - return "0" + return '0' # Incremental compilation doesn't work as well as it should, and if we're # using sccache, it's better to use sccache than incremental compilation. if not using_sccache and rustc_wrapper: rustc_wrapper = os.path.basename(rustc_wrapper[0]) - if os.path.splitext(rustc_wrapper)[0].lower() == "sccache": + if os.path.splitext(rustc_wrapper)[0].lower() == 'sccache': using_sccache = True if using_sccache: - return "0" + return '0' # Incremental compilation is automatically turned on for debug builds, so # we don't need to do anything special here. @@ -2223,14 +1972,14 @@ def cargo_incremental( # Let's assume that if Rust code is using -O2 or higher, we shouldn't # be using incremental compilation, because we'd be imposing a # significant runtime cost. - if opt_level not in ("0", "1"): + if opt_level not in ('0', '1'): return # We're clear to use incremental compilation! - return "1" + return '1' -set_config("CARGO_INCREMENTAL", cargo_incremental) +set_config('CARGO_INCREMENTAL', cargo_incremental) # Linker detection # ============================================================== @@ -2252,60 +2001,46 @@ set_config("CARGO_INCREMENTAL", cargo_incremental) # https://bugzilla.mozilla.org/show_bug.cgi?id=1563654#c2. @depends(target) def is_linker_option_enabled(target): - if target.kernel not in ("WINNT", "SunOS"): + if target.kernel not in ('WINNT', 'SunOS'): return True -option( - "--enable-gold", - env="MOZ_FORCE_GOLD", - help="Enable GNU Gold Linker when it is not already the default", - when=is_linker_option_enabled, -) - -imply_option("--enable-linker", "gold", when="--enable-gold") +option('--enable-gold', + env='MOZ_FORCE_GOLD', + help='Enable GNU Gold Linker when it is not already the default', + when=is_linker_option_enabled) +imply_option('--enable-linker', 'gold', when='--enable-gold') @depends(target, developer_options) def enable_linker_default(target, developer_options): # x86-64 gold has bugs in how it lays out .note.* sections. See bug 1573820. # x86-32 gold has a bug when assembly files are built. See bug 1651699. # lld is faster, so prefer that for developer builds. - if target.os == "Android" and target.cpu in ("x86", "x86_64"): - return "lld" if developer_options else "bfd" + if target.os == 'Android' and target.cpu in ('x86', 'x86_64'): + return 'lld' if developer_options else 'bfd' -option( - "--enable-linker", - nargs=1, - help="Select the linker {bfd, gold, ld64, lld, lld-*}{|}", - default=enable_linker_default, - when=is_linker_option_enabled, -) +option('--enable-linker', nargs=1, + help='Select the linker {bfd, gold, ld64, lld, lld-*}{|}', + default=enable_linker_default, + when=is_linker_option_enabled) # No-op to enable depending on --enable-linker from default_elfhack in # toolkit/moz.configure. -@depends("--enable-linker", when=is_linker_option_enabled) +@depends('--enable-linker', when=is_linker_option_enabled) def enable_linker(linker): return linker -@depends( - "--enable-linker", - c_compiler, - developer_options, - "--enable-gold", - extra_toolchain_flags, - target, - when=is_linker_option_enabled, -) -@checking("for linker", lambda x: x.KIND) -@imports("os") -@imports("shutil") -def select_linker( - linker, c_compiler, developer_options, enable_gold, toolchain_flags, target -): +@depends('--enable-linker', c_compiler, developer_options, '--enable-gold', + extra_toolchain_flags, target, when=is_linker_option_enabled) +@checking('for linker', lambda x: x.KIND) +@imports('os') +@imports('shutil') +def select_linker(linker, c_compiler, developer_options, enable_gold, + toolchain_flags, target): if linker: linker = linker[0] @@ -2313,28 +2048,28 @@ def select_linker( linker = None def is_valid_linker(linker): - if target.kernel == "Darwin": - valid_linkers = ("ld64", "lld") + if target.kernel == 'Darwin': + valid_linkers = ('ld64', 'lld') else: - valid_linkers = ("bfd", "gold", "lld") + valid_linkers = ('bfd', 'gold', 'lld') if linker in valid_linkers: return True - if "lld" in valid_linkers and linker.startswith("lld-"): + if 'lld' in valid_linkers and linker.startswith('lld-'): return True return False if linker and not is_valid_linker(linker): # Check that we are trying to use a supported linker - die("Unsupported linker " + linker) + die('Unsupported linker ' + linker) # Check the kind of linker - version_check = ["-Wl,--version"] + version_check = ['-Wl,--version'] cmd_base = c_compiler.wrapper + [c_compiler.compiler] + c_compiler.flags def try_linker(linker): # Generate the compiler flag - if linker == "ld64": - linker_flag = ["-fuse-ld=ld"] + if linker == 'ld64': + linker_flag = ['-fuse-ld=ld'] elif linker: linker_flag = ["-fuse-ld=" + linker] else: @@ -2350,29 +2085,29 @@ def select_linker( # Instead, abuse its LD_PRINT_OPTIONS feature to detect a message # specific to it on stderr when it fails to process --version. env = dict(os.environ) - env["LD_PRINT_OPTIONS"] = "1" + env['LD_PRINT_OPTIONS'] = '1' # Some locales might not print out the strings we are looking for, so # ensure consistent output. - env["LC_ALL"] = "C" + env['LC_ALL'] = 'C' retcode, stdout, stderr = get_cmd_output(*cmd, env=env) - if retcode == 1 and "Logging ld64 options" in stderr: - kind = "ld64" + if retcode == 1 and 'Logging ld64 options' in stderr: + kind = 'ld64' elif retcode != 0: return None - elif "GNU ld" in stdout: + elif 'GNU ld' in stdout: # We are using the normal linker - kind = "bfd" + kind = 'bfd' - elif "GNU gold" in stdout: - kind = "gold" + elif 'GNU gold' in stdout: + kind = 'gold' - elif "LLD" in stdout: - kind = "lld" + elif 'LLD' in stdout: + kind = 'lld' else: - kind = "unknown" + kind = 'unknown' return namespace( KIND=kind, @@ -2385,17 +2120,13 @@ def select_linker( die("Could not use {} as linker".format(linker)) die("Failed to find a linker") - if ( - linker is None - and enable_gold.origin == "default" - and developer_options - and result.KIND in ("bfd", "gold") - ): + if (linker is None and enable_gold.origin == 'default' and + developer_options and result.KIND in ('bfd', 'gold')): # try and use lld if available. - tried = try_linker("lld") - if result.KIND != "gold" and (tried is None or tried.KIND != "lld"): - tried = try_linker("gold") - if tried is None or tried.KIND != "gold": + tried = try_linker('lld') + if result.KIND != 'gold' and (tried is None or tried.KIND != 'lld'): + tried = try_linker('gold') + if tried is None or tried.KIND != 'gold': tried = None if tried: result = tried @@ -2407,22 +2138,22 @@ def select_linker( return result -set_config("LINKER_KIND", select_linker.KIND) +set_config('LINKER_KIND', select_linker.KIND) @depends_if(select_linker, macos_sdk) def linker_ldflags(linker, macos_sdk): flags = list((linker and linker.LINKER_FLAG) or []) if macos_sdk: - if linker and linker.KIND == "ld64": - flags.append("-Wl,-syslibroot,%s" % macos_sdk) + if linker and linker.KIND == 'ld64': + flags.append('-Wl,-syslibroot,%s' % macos_sdk) else: - flags.append("-Wl,--sysroot=%s" % macos_sdk) + flags.append('-Wl,--sysroot=%s' % macos_sdk) return flags -add_old_configure_assignment("LINKER_LDFLAGS", linker_ldflags) +add_old_configure_assignment('LINKER_LDFLAGS', linker_ldflags) # There's a wrinkle with MinGW: linker configuration is not enabled, so @@ -2430,34 +2161,38 @@ add_old_configure_assignment("LINKER_LDFLAGS", linker_ldflags) @depends(select_linker, target, c_compiler) def gcc_use_gnu_ld(select_linker, target, c_compiler): if select_linker is not None: - return select_linker.KIND in ("bfd", "gold", "lld") - if target.kernel == "WINNT" and c_compiler.type == "clang": + return select_linker.KIND in ('bfd', 'gold', 'lld') + if target.kernel == 'WINNT' and c_compiler.type == 'clang': return True return None # GCC_USE_GNU_LD=1 means the linker is command line compatible with GNU ld. -set_config("GCC_USE_GNU_LD", gcc_use_gnu_ld) -add_old_configure_assignment("GCC_USE_GNU_LD", gcc_use_gnu_ld) +set_config('GCC_USE_GNU_LD', gcc_use_gnu_ld) +add_old_configure_assignment('GCC_USE_GNU_LD', gcc_use_gnu_ld) # Assembler detection # ============================================================== -option(env="AS", nargs=1, help="Path to the assembler") - +option(env='AS', nargs=1, help='Path to the assembler') @depends(target, c_compiler) def as_info(target, c_compiler): - if c_compiler.type == "clang-cl": + if c_compiler.type == 'clang-cl': ml = { - "x86": "ml.exe", - "x86_64": "ml64.exe", - "aarch64": "armasm64.exe", + 'x86': 'ml.exe', + 'x86_64': 'ml64.exe', + 'aarch64': 'armasm64.exe', }.get(target.cpu) - return namespace(type="masm", names=(ml,)) + return namespace( + type='masm', + names=(ml, ) + ) # When building with anything but clang-cl, we just use the C compiler as the assembler. - return namespace(type="gcc", names=(c_compiler.compiler,)) - + return namespace( + type='gcc', + names=(c_compiler.compiler, ) + ) # One would expect the assembler to be specified merely as a program. But in # cases where the assembler is passed down into js/, it can be specified in @@ -2465,176 +2200,152 @@ def as_info(target, c_compiler): # permit the same behavior in general, even though it seems somewhat unusual. # So we have to do the same sort of dance as we did above with # `provided_compiler`. -provided_assembler = provided_program("AS") -assembler = check_prog( - "_AS", - input=provided_assembler.program, - what="the assembler", - progs=as_info.names, - paths=toolchain_search_path, -) - +provided_assembler = provided_program('AS') +assembler = check_prog('_AS', input=provided_assembler.program, + what='the assembler', progs=as_info.names, + paths=toolchain_search_path) @depends(as_info, assembler, provided_assembler, c_compiler) def as_with_flags(as_info, assembler, provided_assembler, c_compiler): if provided_assembler: - return provided_assembler.wrapper + [assembler] + provided_assembler.flags + return provided_assembler.wrapper + \ + [assembler] + \ + provided_assembler.flags - if as_info.type == "masm": + if as_info.type == 'masm': return assembler - assert as_info.type == "gcc" + assert as_info.type == 'gcc' # Need to add compiler wrappers and flags as appropriate. return c_compiler.wrapper + [assembler] + c_compiler.flags -add_old_configure_assignment("AS", as_with_flags) -add_old_configure_assignment("ac_cv_prog_AS", as_with_flags) +add_old_configure_assignment('AS', as_with_flags) +add_old_configure_assignment('ac_cv_prog_AS', as_with_flags) @depends(assembler, c_compiler, extra_toolchain_flags) -@imports("subprocess") -@imports(_from="os", _import="devnull") +@imports('subprocess') +@imports(_from='os', _import='devnull') def gnu_as(assembler, c_compiler, toolchain_flags): # clang uses a compatible GNU assembler. - if c_compiler.type == "clang": + if c_compiler.type == 'clang': return True - if c_compiler.type == "gcc": + if c_compiler.type == 'gcc': cmd = [assembler] + c_compiler.flags if toolchain_flags: cmd += toolchain_flags - cmd += ["-Wa,--version", "-c", "-o", devnull, "-x", "assembler", "-"] + cmd += ['-Wa,--version', '-c', '-o', devnull, '-x', 'assembler', '-'] # We don't actually have to provide any input on stdin, `Popen.communicate` will # close the stdin pipe. # clang will error if it uses its integrated assembler for this target, # so handle failures gracefully. - if "GNU" in check_cmd_output(*cmd, stdin=subprocess.PIPE, onerror=lambda: ""): + if 'GNU' in check_cmd_output(*cmd, stdin=subprocess.PIPE, onerror=lambda: ''): return True -set_config("GNU_AS", gnu_as) -add_old_configure_assignment("GNU_AS", gnu_as) +set_config('GNU_AS', gnu_as) +add_old_configure_assignment('GNU_AS', gnu_as) @depends(as_info, target) def as_dash_c_flag(as_info, target): # armasm64 doesn't understand -c. - if as_info.type == "masm" and target.cpu == "aarch64": - return "" + if as_info.type == 'masm' and target.cpu == 'aarch64': + return '' else: - return "-c" + return '-c' -set_config("AS_DASH_C_FLAG", as_dash_c_flag) +set_config('AS_DASH_C_FLAG', as_dash_c_flag) @depends(as_info, target) def as_outoption(as_info, target): # The uses of ASOUTOPTION depend on the spacing for -o/-Fo. - if as_info.type == "masm" and target.cpu != "aarch64": - return "-Fo" + if as_info.type == 'masm' and target.cpu != 'aarch64': + return '-Fo' - return "-o " + return '-o ' -set_config("ASOUTOPTION", as_outoption) +set_config('ASOUTOPTION', as_outoption) # clang plugin handling # ============================================================== -option( - "--enable-clang-plugin", - env="ENABLE_CLANG_PLUGIN", - help="Enable building with the Clang plugin (gecko specific static analyzers)", -) +option('--enable-clang-plugin', env='ENABLE_CLANG_PLUGIN', + help="Enable building with the Clang plugin (gecko specific static analyzers)") -add_old_configure_assignment( - "ENABLE_CLANG_PLUGIN", depends_if("--enable-clang-plugin")(lambda _: True) -) +add_old_configure_assignment('ENABLE_CLANG_PLUGIN', + depends_if('--enable-clang-plugin')(lambda _: True)) - -@depends(host_c_compiler, c_compiler, when="--enable-clang-plugin") +@depends(host_c_compiler, c_compiler, when='--enable-clang-plugin') def llvm_config(host_c_compiler, c_compiler): clang = None for compiler in (host_c_compiler, c_compiler): - if compiler and compiler.type == "clang": + if compiler and compiler.type == 'clang': clang = compiler.compiler break - elif compiler and compiler.type == "clang-cl": - clang = os.path.join(os.path.dirname(compiler.compiler), "clang") + elif compiler and compiler.type == 'clang-cl': + clang = os.path.join(os.path.dirname(compiler.compiler), 'clang') break if not clang: - die("Cannot --enable-clang-plugin when not building with clang") - llvm_config = "llvm-config" - out = check_cmd_output(clang, "--print-prog-name=llvm-config", onerror=lambda: None) + die('Cannot --enable-clang-plugin when not building with clang') + llvm_config = 'llvm-config' + out = check_cmd_output(clang, '--print-prog-name=llvm-config', + onerror=lambda: None) if out: llvm_config = out.rstrip() return (llvm_config,) -llvm_config = check_prog( - "LLVM_CONFIG", - llvm_config, - what="llvm-config", - when="--enable-clang-plugin", - paths=toolchain_search_path, -) - -add_old_configure_assignment("LLVM_CONFIG", llvm_config) +llvm_config = check_prog('LLVM_CONFIG', llvm_config, what='llvm-config', + when='--enable-clang-plugin', + paths=toolchain_search_path) +add_old_configure_assignment('LLVM_CONFIG', llvm_config) -option( - "--enable-clang-plugin-alpha", - env="ENABLE_CLANG_PLUGIN_ALPHA", - help="Enable static analysis with clang-plugin alpha checks.", -) +option('--enable-clang-plugin-alpha', env='ENABLE_CLANG_PLUGIN_ALPHA', + help='Enable static analysis with clang-plugin alpha checks.') -@depends("--enable-clang-plugin", "--enable-clang-plugin-alpha") +@depends('--enable-clang-plugin', '--enable-clang-plugin-alpha') def check_clang_plugin_alpha(enable_clang_plugin, enable_clang_plugin_alpha): if enable_clang_plugin_alpha: if enable_clang_plugin: return True die("Cannot enable clang-plugin alpha checkers without --enable-clang-plugin.") +add_old_configure_assignment('ENABLE_CLANG_PLUGIN_ALPHA', check_clang_plugin_alpha) +set_define('MOZ_CLANG_PLUGIN_ALPHA', check_clang_plugin_alpha) -add_old_configure_assignment("ENABLE_CLANG_PLUGIN_ALPHA", check_clang_plugin_alpha) -set_define("MOZ_CLANG_PLUGIN_ALPHA", check_clang_plugin_alpha) +option('--enable-mozsearch-plugin', env='ENABLE_MOZSEARCH_PLUGIN', + help="Enable building with the mozsearch indexer plugin") -option( - "--enable-mozsearch-plugin", - env="ENABLE_MOZSEARCH_PLUGIN", - help="Enable building with the mozsearch indexer plugin", -) - -add_old_configure_assignment( - "ENABLE_MOZSEARCH_PLUGIN", depends_if("--enable-mozsearch-plugin")(lambda _: True) -) +add_old_configure_assignment('ENABLE_MOZSEARCH_PLUGIN', + depends_if('--enable-mozsearch-plugin')(lambda _: True)) # Libstdc++ compatibility hacks # ============================================================== # -option( - "--enable-stdcxx-compat", - env="MOZ_STDCXX_COMPAT", - help="Enable compatibility with older libstdc++", -) +option('--enable-stdcxx-compat', env='MOZ_STDCXX_COMPAT', + help='Enable compatibility with older libstdc++') @template def libstdcxx_version(var, compiler): - @depends(compiler, when="--enable-stdcxx-compat") + @depends(compiler, when='--enable-stdcxx-compat') @checking(var, lambda v: v and "GLIBCXX_%s" % v.dotted) - @imports(_from="mozbuild.configure.libstdcxx", _import="find_version") - @imports(_from="__builtin__", _import="Exception") + @imports(_from='mozbuild.configure.libstdcxx', _import='find_version') + @imports(_from='__builtin__', _import='Exception') def version(compiler): try: result = find_version( - compiler.wrapper + [compiler.compiler] + compiler.flags - ) + compiler.wrapper + [compiler.compiler] + compiler.flags) except Exception: die("Couldn't determine libstdc++ version") if result: @@ -2648,70 +2359,61 @@ def libstdcxx_version(var, compiler): add_gcc_flag( - "-D_GLIBCXX_USE_CXX11_ABI=0", - cxx_compiler, - when=libstdcxx_version("MOZ_LIBSTDCXX_TARGET_VERSION", cxx_compiler), -) + '-D_GLIBCXX_USE_CXX11_ABI=0', cxx_compiler, + when=libstdcxx_version( + 'MOZ_LIBSTDCXX_TARGET_VERSION', cxx_compiler)) add_gcc_flag( - "-D_GLIBCXX_USE_CXX11_ABI=0", - host_cxx_compiler, - when=libstdcxx_version("MOZ_LIBSTDCXX_HOST_VERSION", host_cxx_compiler), -) + '-D_GLIBCXX_USE_CXX11_ABI=0', host_cxx_compiler, + when=libstdcxx_version( + 'MOZ_LIBSTDCXX_HOST_VERSION', host_cxx_compiler)) # Support various fuzzing options # ============================================================== -option("--enable-fuzzing", help="Enable fuzzing support") - +option('--enable-fuzzing', help='Enable fuzzing support') -@depends("--enable-fuzzing") +@depends('--enable-fuzzing') def enable_fuzzing(value): if value: return True - -@depends( - try_compile( - body="__AFL_COMPILER;", check_msg="for AFL compiler", when="--enable-fuzzing" - ) -) +@depends(try_compile(body='__AFL_COMPILER;', + check_msg='for AFL compiler', + when='--enable-fuzzing')) def enable_aflfuzzer(afl): if afl: return True - -@depends(enable_fuzzing, enable_aflfuzzer, c_compiler, target) +@depends(enable_fuzzing, + enable_aflfuzzer, + c_compiler, + target) def enable_libfuzzer(fuzzing, afl, c_compiler, target): - if fuzzing and not afl and c_compiler.type == "clang" and target.os != "Android": + if fuzzing and not afl and c_compiler.type == 'clang' and target.os != 'Android': return True - -@depends(enable_fuzzing, enable_aflfuzzer, enable_libfuzzer) +@depends(enable_fuzzing, + enable_aflfuzzer, + enable_libfuzzer) def enable_fuzzing_interfaces(fuzzing, afl, libfuzzer): if fuzzing and (afl or libfuzzer): return True +set_config('FUZZING', enable_fuzzing) +set_define('FUZZING', enable_fuzzing) -set_config("FUZZING", enable_fuzzing) -set_define("FUZZING", enable_fuzzing) - -set_config("LIBFUZZER", enable_libfuzzer) -set_define("LIBFUZZER", enable_libfuzzer) -add_old_configure_assignment("LIBFUZZER", enable_libfuzzer) +set_config('LIBFUZZER', enable_libfuzzer) +set_define('LIBFUZZER', enable_libfuzzer) +add_old_configure_assignment('LIBFUZZER', enable_libfuzzer) -set_config("FUZZING_INTERFACES", enable_fuzzing_interfaces) -set_define("FUZZING_INTERFACES", enable_fuzzing_interfaces) -add_old_configure_assignment("FUZZING_INTERFACES", enable_fuzzing_interfaces) +set_config('FUZZING_INTERFACES', enable_fuzzing_interfaces) +set_define('FUZZING_INTERFACES', enable_fuzzing_interfaces) +add_old_configure_assignment('FUZZING_INTERFACES', enable_fuzzing_interfaces) -@depends( - c_compiler.try_compile( - flags=["-fsanitize=fuzzer-no-link"], - when=enable_fuzzing, - check_msg="whether the C compiler supports -fsanitize=fuzzer-no-link", - ), - tsan, -) +@depends(c_compiler.try_compile(flags=['-fsanitize=fuzzer-no-link'], + when=enable_fuzzing, + check_msg='whether the C compiler supports -fsanitize=fuzzer-no-link'), tsan) def libfuzzer_flags(value, tsan): if tsan: # With ThreadSanitizer, we should not use any libFuzzer instrumentation because @@ -2725,20 +2427,19 @@ def libfuzzer_flags(value, tsan): if value: no_link_flag_supported = True # recommended for (and only supported by) clang >= 6 - use_flags = ["-fsanitize=fuzzer-no-link"] + use_flags = ['-fsanitize=fuzzer-no-link'] else: no_link_flag_supported = False - use_flags = ["-fsanitize-coverage=trace-pc-guard,trace-cmp"] + use_flags = ['-fsanitize-coverage=trace-pc-guard,trace-cmp'] return namespace( no_link_flag_supported=no_link_flag_supported, use_flags=use_flags, ) - -set_config("HAVE_LIBFUZZER_FLAG_FUZZER_NO_LINK", libfuzzer_flags.no_link_flag_supported) -set_config("LIBFUZZER_FLAGS", libfuzzer_flags.use_flags) -add_old_configure_assignment("LIBFUZZER_FLAGS", libfuzzer_flags.use_flags) +set_config('HAVE_LIBFUZZER_FLAG_FUZZER_NO_LINK', libfuzzer_flags.no_link_flag_supported) +set_config('LIBFUZZER_FLAGS', libfuzzer_flags.use_flags) +add_old_configure_assignment('LIBFUZZER_FLAGS', libfuzzer_flags.use_flags) # Shared library building # ============================================================== @@ -2746,56 +2447,43 @@ add_old_configure_assignment("LIBFUZZER_FLAGS", libfuzzer_flags.use_flags) # XXX: The use of makefile constructs in these variables is awful. @depends(target, c_compiler) def make_shared_library(target, compiler): - if target.os == "WINNT": - if compiler.type == "gcc": + if target.os == 'WINNT': + if compiler.type == 'gcc': return namespace( - mkshlib=["$(CXX)", "$(DSO_LDOPTS)", "-o", "$@"], - mkcshlib=["$(CC)", "$(DSO_LDOPTS)", "-o", "$@"], + mkshlib=['$(CXX)', '$(DSO_LDOPTS)', '-o', '$@'], + mkcshlib=['$(CC)', '$(DSO_LDOPTS)', '-o', '$@'], ) - elif compiler.type == "clang": + elif compiler.type == 'clang': return namespace( - mkshlib=[ - "$(CXX)", - "$(DSO_LDOPTS)", - "-Wl,-pdb,$(LINK_PDBFILE)", - "-o", - "$@", - ], - mkcshlib=[ - "$(CC)", - "$(DSO_LDOPTS)", - "-Wl,-pdb,$(LINK_PDBFILE)", - "-o", - "$@", - ], + mkshlib=['$(CXX)', '$(DSO_LDOPTS)', '-Wl,-pdb,$(LINK_PDBFILE)', '-o', '$@'], + mkcshlib=['$(CC)', '$(DSO_LDOPTS)', '-Wl,-pdb,$(LINK_PDBFILE)', '-o', '$@'], ) else: linker = [ - "$(LINKER)", - "-NOLOGO", - "-DLL", - "-OUT:$@", - "-PDB:$(LINK_PDBFILE)", - "$(DSO_LDOPTS)", + '$(LINKER)', + '-NOLOGO', '-DLL', + '-OUT:$@', + '-PDB:$(LINK_PDBFILE)', + '$(DSO_LDOPTS)' ] return namespace( mkshlib=linker, mkcshlib=linker, ) - cc = ["$(CC)", "$(COMPUTED_C_LDFLAGS)"] - cxx = ["$(CXX)", "$(COMPUTED_CXX_LDFLAGS)"] - flags = ["$(PGO_CFLAGS)", "$(DSO_PIC_CFLAGS)", "$(DSO_LDOPTS)"] - output = ["-o", "$@"] + cc = ['$(CC)', '$(COMPUTED_C_LDFLAGS)'] + cxx = ['$(CXX)', '$(COMPUTED_CXX_LDFLAGS)'] + flags = ['$(PGO_CFLAGS)', '$(DSO_PIC_CFLAGS)', '$(DSO_LDOPTS)'] + output = ['-o', '$@'] - if target.kernel == "Darwin": + if target.kernel == 'Darwin': soname = [] - elif target.os == "NetBSD": - soname = ["-Wl,-soname,$(DSO_SONAME)"] + elif target.os == 'NetBSD': + soname = ['-Wl,-soname,$(DSO_SONAME)'] else: - assert compiler.type in ("gcc", "clang") + assert compiler.type in ('gcc', 'clang') - soname = ["-Wl,-h,$(DSO_SONAME)"] + soname = ['-Wl,-h,$(DSO_SONAME)'] return namespace( mkshlib=cxx + flags + soname + output, @@ -2803,47 +2491,49 @@ def make_shared_library(target, compiler): ) -set_config("MKSHLIB", make_shared_library.mkshlib) -set_config("MKCSHLIB", make_shared_library.mkcshlib) +set_config('MKSHLIB', make_shared_library.mkshlib) +set_config('MKCSHLIB', make_shared_library.mkcshlib) @depends(c_compiler, toolchain_prefix, when=target_is_windows) def rc_names(c_compiler, toolchain_prefix): - if c_compiler.type in ("gcc", "clang"): - return tuple("%s%s" % (p, "windres") for p in ("",) + (toolchain_prefix or ())) - return ("llvm-rc",) + if c_compiler.type in ('gcc', 'clang'): + return tuple('%s%s' % (p, 'windres') + for p in ('',) + (toolchain_prefix or ())) + return ('llvm-rc',) -check_prog("RC", rc_names, paths=toolchain_search_path, when=target_is_windows) +check_prog('RC', rc_names, paths=toolchain_search_path, when=target_is_windows) @depends(link, toolchain_prefix, c_compiler) def ar_config(link, toolchain_prefix, c_compiler): - if c_compiler.type == "clang-cl" and link: + if c_compiler.type == 'clang-cl' and link: # if LINKER is set, it's either for lld-link or link - if "lld-link" in link: + if 'lld-link' in link: return namespace( - names=("llvm-lib",), - flags=("-llvmlibthin", "-out:$@"), + names=('llvm-lib',), + flags=('-llvmlibthin', '-out:$@'), ) else: return namespace( - names=("lib",), - flags=("-NOLOGO", "-OUT:$@"), + names=('lib',), + flags=('-NOLOGO', '-OUT:$@'), ) return namespace( - names=tuple("%s%s" % (p, "ar") for p in (toolchain_prefix or ()) + ("",)), - flags=("crs", "$@"), + names=tuple('%s%s' % (p, 'ar') + for p in (toolchain_prefix or ()) + ('',)), + flags=('crs', '$@'), ) -ar = check_prog("AR", ar_config.names, paths=toolchain_search_path) +ar = check_prog('AR', ar_config.names, paths=toolchain_search_path) -add_old_configure_assignment("AR", ar) +add_old_configure_assignment('AR', ar) -set_config("AR_FLAGS", ar_config.flags) +set_config('AR_FLAGS', ar_config.flags) -option("--enable-cpp-rtti", help="Enable C++ RTTI") +option('--enable-cpp-rtti', help='Enable C++ RTTI') -add_old_configure_assignment("_MOZ_USE_RTTI", "1", when="--enable-cpp-rtti") +add_old_configure_assignment('_MOZ_USE_RTTI', '1', when='--enable-cpp-rtti') diff --git a/build/moz.configure/update-programs.configure b/build/moz.configure/update-programs.configure index d5a75b9ac8eb6536dbc1172633cfe88ec21665c9..e3bb7b4642953c0008d5577e2d857b46227e78be 100644 --- a/build/moz.configure/update-programs.configure +++ b/build/moz.configure/update-programs.configure @@ -7,55 +7,43 @@ # Verify MAR signatures # ============================================================== -option("--disable-verify-mar", help="Disable verifying MAR signatures") +option('--disable-verify-mar', help='Disable verifying MAR signatures') -set_define( - "MOZ_VERIFY_MAR_SIGNATURE", depends_if("--enable-verify-mar")(lambda _: True) -) -set_config( - "MOZ_VERIFY_MAR_SIGNATURE", depends_if("--enable-verify-mar")(lambda _: True) -) +set_define('MOZ_VERIFY_MAR_SIGNATURE', + depends_if('--enable-verify-mar')(lambda _: True)) +set_config('MOZ_VERIFY_MAR_SIGNATURE', + depends_if('--enable-verify-mar')(lambda _: True)) # Maintenance service (Windows only) # ============================================================== -option( - "--enable-maintenance-service", - when=target_is_windows, - default=target_is_windows, - help="{Enable|Disable} building of maintenance service", -) - -set_define( - "MOZ_MAINTENANCE_SERVICE", - depends_if("--enable-maintenance-service", when=target_is_windows)(lambda _: True), -) -set_config( - "MOZ_MAINTENANCE_SERVICE", - depends_if("--enable-maintenance-service", when=target_is_windows)(lambda _: True), -) +option('--enable-maintenance-service', + when=target_is_windows, default=target_is_windows, + help='{Enable|Disable} building of maintenance service') + +set_define('MOZ_MAINTENANCE_SERVICE', + depends_if('--enable-maintenance-service', + when=target_is_windows)(lambda _: True)) +set_config('MOZ_MAINTENANCE_SERVICE', + depends_if('--enable-maintenance-service', + when=target_is_windows)(lambda _: True)) # Update agent (currently Windows only) # This is an independent task that runs on a schedule to # check for, download, and install updates. # ============================================================== -option( - "--enable-update-agent", - when=target_is_windows, - default=False, - help="{Enable|Disable} building update agent", -) +option('--enable-update-agent', + when=target_is_windows, default=False, + help='{Enable|Disable} building update agent') -set_define( - "MOZ_UPDATE_AGENT", - depends_if("--enable-update-agent", when=target_is_windows)(lambda _: True), -) +set_define('MOZ_UPDATE_AGENT', + depends_if('--enable-update-agent', + when=target_is_windows)(lambda _: True)) -set_config( - "MOZ_UPDATE_AGENT", - depends_if("--enable-update-agent", when=target_is_windows)(lambda _: True), -) +set_config('MOZ_UPDATE_AGENT', + depends_if('--enable-update-agent', + when=target_is_windows)(lambda _: True)) # Enable or disable the default browser agent, which monitors the user's default # browser setting on Windows. @@ -64,20 +52,17 @@ set_config( @depends(target) def default_browser_agent_default(target): - return target.os == "WINNT" + return target.os == 'WINNT' -option( - "--enable-default-browser-agent", - default=default_browser_agent_default, - help="{Enable|Disable} building the default browser agent", -) +option('--enable-default-browser-agent', default=default_browser_agent_default, + help='{Enable|Disable} building the default browser agent') -@depends("--enable-default-browser-agent", when=target_is_windows) +@depends('--enable-default-browser-agent', when=target_is_windows) def default_agent_flag(enabled): if enabled: return True -set_config("MOZ_DEFAULT_BROWSER_AGENT", default_agent_flag) +set_config('MOZ_DEFAULT_BROWSER_AGENT', default_agent_flag) diff --git a/build/moz.configure/util.configure b/build/moz.configure/util.configure index fe82698c620bca595cb3065cd9c81a9279094437..7ee1a498ad8ccf2f6cec2ae840cd66872da04125 100644 --- a/build/moz.configure/util.configure +++ b/build/moz.configure/util.configure @@ -5,51 +5,45 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. -@imports("sys") +@imports('sys') def die(*args): - "Print an error and terminate configure." + 'Print an error and terminate configure.' log.error(*args) sys.exit(1) -@imports(_from="mozbuild.configure", _import="ConfigureError") +@imports(_from='mozbuild.configure', _import='ConfigureError') def configure_error(message): - """Raise a programming error and terminate configure. + '''Raise a programming error and terminate configure. Primarily for use in moz.configure templates to sanity check - their inputs from moz.configure usage.""" + their inputs from moz.configure usage.''' raise ConfigureError(message) # A wrapper to obtain a process' output and return code. # Returns a tuple (retcode, stdout, stderr). -@imports("os") -@imports("six") -@imports("subprocess") -@imports(_from="mozbuild.shellutil", _import="quote") -@imports(_from="mozbuild.util", _import="system_encoding") +@imports('os') +@imports('six') +@imports('subprocess') +@imports(_from='mozbuild.shellutil', _import='quote') +@imports(_from='mozbuild.util', _import='system_encoding') def get_cmd_output(*args, **kwargs): - log.debug("Executing: `%s`", quote(*args)) + log.debug('Executing: `%s`', quote(*args)) proc = subprocess.Popen( - args, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, # On Python 2 on Windows, close_fds prevents the process from inheriting # stdout/stderr. Elsewhere, it simply prevents it from inheriting extra # file descriptors, which is what we want. - close_fds=os.name != "nt", - **kwargs - ) + close_fds=os.name != 'nt', **kwargs) stdout, stderr = proc.communicate() # Normally we would set the `encoding` and `errors` arguments in the # constructor to subprocess.Popen, but those arguments were added in 3.6 # and we need to support back to 3.5, so instead we need to do this # nonsense. - stdout = six.ensure_text( - stdout, encoding=system_encoding, errors="replace" - ).replace("\r\n", "\n") - stderr = six.ensure_text( - stderr, encoding=system_encoding, errors="replace" - ).replace("\r\n", "\n") + stdout = six.ensure_text(stdout, encoding=system_encoding, + errors='replace').replace('\r\n', '\n') + stderr = six.ensure_text(stderr, encoding=system_encoding, + errors='replace').replace('\r\n', '\n') return proc.wait(), stdout, stderr @@ -57,83 +51,87 @@ def get_cmd_output(*args, **kwargs): # by running the given command if it exits normally, and streams that # output to log.debug and calls die or the given error callback if it # does not. -@imports(_from="mozbuild.configure.util", _import="LineIO") -@imports(_from="mozbuild.shellutil", _import="quote") +@imports(_from='mozbuild.configure.util', _import='LineIO') +@imports(_from='mozbuild.shellutil', _import='quote') def check_cmd_output(*args, **kwargs): - onerror = kwargs.pop("onerror", None) + onerror = kwargs.pop('onerror', None) with log.queue_debug(): retcode, stdout, stderr = get_cmd_output(*args, **kwargs) if retcode == 0: return stdout - log.debug("The command returned non-zero exit status %d.", retcode) - for out, desc in ((stdout, "output"), (stderr, "error output")): + log.debug('The command returned non-zero exit status %d.', + retcode) + for out, desc in ((stdout, 'output'), (stderr, 'error output')): if out: - log.debug("Its %s was:", desc) - with LineIO(lambda l: log.debug("| %s", l)) as o: + log.debug('Its %s was:', desc) + with LineIO(lambda l: log.debug('| %s', l)) as o: o.write(out) if onerror: return onerror() - die("Command `%s` failed with exit status %d." % (quote(*args), retcode)) + die('Command `%s` failed with exit status %d.' % + (quote(*args), retcode)) -@imports("os") +@imports('os') def is_absolute_or_relative(path): if os.altsep and os.altsep in path: return True return os.sep in path -@imports(_import="mozpack.path", _as="mozpath") +@imports(_import='mozpack.path', _as='mozpath') def normsep(path): return mozpath.normsep(path) -@imports("ctypes") -@imports(_from="ctypes", _import="wintypes") -@imports(_from="mozbuild.configure.constants", _import="WindowsBinaryType") +@imports('ctypes') +@imports(_from='ctypes', _import='wintypes') +@imports(_from='mozbuild.configure.constants', _import='WindowsBinaryType') def windows_binary_type(path): """Obtain the type of a binary on Windows. Returns WindowsBinaryType constant. """ GetBinaryTypeW = ctypes.windll.kernel32.GetBinaryTypeW - GetBinaryTypeW.argtypes = [wintypes.LPWSTR, ctypes.POINTER(wintypes.DWORD)] + GetBinaryTypeW.argtypes = [wintypes.LPWSTR, + ctypes.POINTER(wintypes.DWORD)] GetBinaryTypeW.restype = wintypes.BOOL bin_type = wintypes.DWORD() res = GetBinaryTypeW(path, ctypes.byref(bin_type)) if not res: - die("could not obtain binary type of %s" % path) + die('could not obtain binary type of %s' % path) if bin_type.value == 0: - return WindowsBinaryType("win32") + return WindowsBinaryType('win32') elif bin_type.value == 6: - return WindowsBinaryType("win64") + return WindowsBinaryType('win64') # If we see another binary type, something is likely horribly wrong. else: - die("unsupported binary type on %s: %s" % (path, bin_type)) + die('unsupported binary type on %s: %s' % (path, bin_type)) -@imports("ctypes") -@imports(_from="ctypes", _import="wintypes") +@imports('ctypes') +@imports(_from='ctypes', _import='wintypes') def get_GetShortPathNameW(): GetShortPathNameW = ctypes.windll.kernel32.GetShortPathNameW - GetShortPathNameW.argtypes = [wintypes.LPCWSTR, wintypes.LPWSTR, wintypes.DWORD] + GetShortPathNameW.argtypes = [wintypes.LPCWSTR, wintypes.LPWSTR, + wintypes.DWORD] GetShortPathNameW.restype = wintypes.DWORD return GetShortPathNameW @template -@imports("ctypes") -@imports("platform") -@imports(_from="mozbuild.shellutil", _import="quote") +@imports('ctypes') +@imports('platform') +@imports(_from='mozbuild.shellutil', _import='quote') def normalize_path(): # Until the build system can properly handle programs that need quoting, # transform those paths into their short version on Windows (e.g. # c:\PROGRA~1...). - if platform.system() == "Windows": + if platform.system() == 'Windows': GetShortPathNameW = get_GetShortPathNameW() def normalize_path(path): @@ -145,20 +143,17 @@ def normalize_path(): out = ctypes.create_unicode_buffer(size) needed = GetShortPathNameW(path, out, size) if size >= needed: - if " " in out.value: - die( - "GetShortPathName returned a long path name: `%s`. " + if ' ' in out.value: + die("GetShortPathName returned a long path name: `%s`. " "Use `fsutil file setshortname' " "to create a short name " "for any components of this path " "that have spaces.", - out.value, - ) + out.value) return normsep(out.value) size = needed else: - def normalize_path(path): return normsep(path) @@ -172,10 +167,10 @@ normalize_path = normalize_path() # exists. # The `paths` parameter may be passed to search the given paths instead of # $PATH. -@imports("sys") -@imports(_from="os", _import="pathsep") -@imports(_from="os", _import="environ") -@imports(_from="mozfile", _import="which") +@imports('sys') +@imports(_from='os', _import='pathsep') +@imports(_from='os', _import='environ') +@imports(_from='mozfile', _import='which') def find_program(file, paths=None): # The following snippet comes from `which` itself, with a slight # modification to use lowercase extensions, because it's confusing rustup @@ -183,11 +178,12 @@ def find_program(file, paths=None): # Windows has the concept of a list of extensions (PATHEXT env var). if sys.platform.startswith("win"): - exts = [e.lower() for e in environ.get("PATHEXT", "").split(pathsep)] + exts = [e.lower() + for e in environ.get("PATHEXT", "").split(pathsep)] # If '.exe' is not in exts then obviously this is Win9x and # or a bogus PATHEXT, then use a reasonable default. - if ".exe" not in exts: - exts = [".com", ".exe", ".bat"] + if '.exe' not in exts: + exts = ['.com', '.exe', '.bat'] else: exts = None @@ -197,43 +193,42 @@ def find_program(file, paths=None): if paths: if not isinstance(paths, (list, tuple)): - die( - "Paths provided to find_program must be a list of strings, " "not %r", - paths, - ) + die("Paths provided to find_program must be a list of strings, " + "not %r", paths) paths = pathsep.join(paths) path = which(file, path=paths, exts=exts) return normalize_path(path) if path else None -@imports("os") -@imports(_from="mozbuild.configure.util", _import="LineIO") -@imports(_from="six", _import="ensure_binary") -@imports(_from="tempfile", _import="mkstemp") +@imports('os') +@imports(_from='mozbuild.configure.util', _import='LineIO') +@imports(_from='six', _import='ensure_binary') +@imports(_from='tempfile', _import='mkstemp') def try_invoke_compiler(compiler, language, source, flags=None, onerror=None): flags = flags or [] if not isinstance(flags, (list, tuple)): - die("Flags provided to try_compile must be a list of strings, " "not %r", flags) + die("Flags provided to try_compile must be a list of strings, " + "not %r", flags) suffix = { - "C": ".c", - "C++": ".cpp", + 'C': '.c', + 'C++': '.cpp', }[language] - fd, path = mkstemp(prefix="conftest.", suffix=suffix, text=True) + fd, path = mkstemp(prefix='conftest.', suffix=suffix, text=True) try: - source = source.encode("ascii", "replace") + source = source.encode('ascii', 'replace') - log.debug("Creating `%s` with content:", path) - with LineIO(lambda l: log.debug("| %s", l)) as out: + log.debug('Creating `%s` with content:', path) + with LineIO(lambda l: log.debug('| %s', l)) as out: out.write(source) os.write(fd, ensure_binary(source)) os.close(fd) cmd = compiler + [path] + list(flags) - kwargs = {"onerror": onerror} + kwargs = {'onerror': onerror} return check_cmd_output(*cmd, **kwargs) finally: os.remove(path) @@ -293,9 +288,9 @@ def unique_list(l): # ('19.0', 'arm', r'C:\...\amd64_arm\cl.exe') # ('19.0', 'x64', r'C:\...\amd64\cl.exe') # ('19.0', 'x86', r'C:\...\amd64_x86\cl.exe') -@imports(_import="winreg") -@imports(_from="__builtin__", _import="WindowsError") -@imports(_from="fnmatch", _import="fnmatch") +@imports(_import='winreg') +@imports(_from='__builtin__', _import='WindowsError') +@imports(_from='fnmatch', _import='fnmatch') def get_registry_values(pattern, get_32_and_64_bit=False): def enum_helper(func, key): i = 0 @@ -308,7 +303,7 @@ def get_registry_values(pattern, get_32_and_64_bit=False): def get_keys(key, pattern, access_mask): try: - s = winreg.OpenKey(key, "\\".join(pattern[:-1]), 0, access_mask) + s = winreg.OpenKey(key, '\\'.join(pattern[:-1]), 0, access_mask) except WindowsError: return for k in enum_helper(winreg.EnumKey, s): @@ -320,7 +315,7 @@ def get_registry_values(pattern, get_32_and_64_bit=False): def get_values(key, pattern, access_mask): try: - s = winreg.OpenKey(key, "\\".join(pattern[:-1]), 0, access_mask) + s = winreg.OpenKey(key, '\\'.join(pattern[:-1]), 0, access_mask) except WindowsError: return for k, v, t in enum_helper(winreg.EnumValue, s): @@ -331,7 +326,7 @@ def get_registry_values(pattern, get_32_and_64_bit=False): subpattern = [] for p in pattern: subpattern.append(p) - if "*" in p: + if '*' in p: yield subpattern subpattern = [] if subpattern: @@ -344,7 +339,7 @@ def get_registry_values(pattern, get_32_and_64_bit=False): matches = base_key[:-1] base_key = base_key[-1] if i == len(pattern) - 1: - want_name = "*" in p[-1] + want_name = '*' in p[-1] for name, value in get_values(base_key, p, access_mask): yield matches + ((name, value) if want_name else (value,)) else: @@ -352,30 +347,25 @@ def get_registry_values(pattern, get_32_and_64_bit=False): next_keys.append(matches + (name, k)) keys = next_keys - pattern = pattern.split("\\") - assert pattern[0].startswith("HKEY_") + pattern = pattern.split('\\') + assert pattern[0].startswith('HKEY_') keys = [(getattr(winreg, pattern[0]),)] pattern = list(split_pattern(pattern[1:])) if get_32_and_64_bit: - for match in get_all_values( - keys, pattern, winreg.KEY_READ | winreg.KEY_WOW64_32KEY - ): + for match in get_all_values(keys, pattern, winreg.KEY_READ | winreg.KEY_WOW64_32KEY): yield match - for match in get_all_values( - keys, pattern, winreg.KEY_READ | winreg.KEY_WOW64_64KEY - ): + for match in get_all_values(keys, pattern, winreg.KEY_READ | winreg.KEY_WOW64_64KEY): yield match else: for match in get_all_values(keys, pattern, winreg.KEY_READ): yield match -@imports(_from="mozbuild.configure.util", _import="Version", _as="_Version") +@imports(_from='mozbuild.configure.util', _import='Version', _as='_Version') def Version(v): - "A version number that can be compared usefully." + 'A version number that can be compared usefully.' return _Version(v) - # Denotes a deprecated option. Combines option() and @depends: # @deprecated_option('--option') # def option(value): @@ -388,23 +378,22 @@ def Version(v): @template def deprecated_option(*args, **kwargs): - assert "help" not in kwargs - kwargs["help"] = "Deprecated" + assert 'help' not in kwargs + kwargs['help'] = 'Deprecated' opt = option(*args, **kwargs) def decorator(func): @depends(opt.option) def deprecated(value): - if value.origin != "default": + if value.origin != 'default': return func(value) - return deprecated return decorator # from mozbuild.util import ReadOnlyNamespace as namespace -@imports(_from="mozbuild.util", _import="ReadOnlyNamespace") +@imports(_from='mozbuild.util', _import='ReadOnlyNamespace') def namespace(**kwargs): return ReadOnlyNamespace(**kwargs) @@ -413,8 +402,8 @@ def namespace(**kwargs): # The given object can be a literal value, a function that takes no argument, # or, for convenience, a @depends function. @template -@imports(_from="inspect", _import="isfunction") -@imports(_from="mozbuild.configure", _import="SandboxDependsFunction") +@imports(_from='inspect', _import='isfunction') +@imports(_from='mozbuild.configure', _import='SandboxDependsFunction') def dependable(obj): if isinstance(obj, SandboxDependsFunction): return obj @@ -422,7 +411,7 @@ def dependable(obj): return depends(when=True)(obj) # Depend on --help to make lint happy if the dependable is used as an input # to an option(). - return depends("--help", when=True)(lambda _: obj) + return depends('--help', when=True)(lambda _: obj) always = dependable(True) @@ -436,7 +425,7 @@ never = dependable(False) def depends_tmpl(eval_args_fn, *args, **kwargs): if kwargs: assert len(kwargs) == 1 - when = kwargs["when"] + when = kwargs['when'] else: when = None @@ -445,9 +434,7 @@ def depends_tmpl(eval_args_fn, *args, **kwargs): def wrapper(*args): if eval_args_fn(args): return func(*args) - return wrapper - return decorator @@ -468,7 +455,6 @@ def depends_all(*args, **kwargs): # Hacks related to old-configure # ============================== - @dependable def old_configure_assignments(): return [] @@ -480,14 +466,14 @@ def add_old_configure_assignment(var, value, when=None): value = dependable(value) @depends(old_configure_assignments, var, value, when=when) - @imports(_from="mozbuild.shellutil", _import="quote") + @imports(_from='mozbuild.shellutil', _import='quote') def add_assignment(assignments, var, value): if var is None or value is None: return if value is True: - assignments.append((var, "1")) + assignments.append((var, '1')) elif value is False: - assignments.append((var, "")) + assignments.append((var, '')) else: if isinstance(value, (list, tuple)): value = quote(*value) diff --git a/build/moz.configure/warnings.configure b/build/moz.configure/warnings.configure index b549bd57f722b581b959acd8a5eb330753c61042..1efd7155960e61e74dce87a96e653c3233ab6c0c 100755 --- a/build/moz.configure/warnings.configure +++ b/build/moz.configure/warnings.configure @@ -4,44 +4,39 @@ # 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/. -option( - "--enable-warnings-as-errors", - env="MOZ_ENABLE_WARNINGS_AS_ERRORS", - default=depends("MOZ_AUTOMATION")(lambda x: bool(x)), - help="{Enable|Disable} treating warnings as errors", -) +option('--enable-warnings-as-errors', env='MOZ_ENABLE_WARNINGS_AS_ERRORS', + default=depends('MOZ_AUTOMATION')(lambda x: bool(x)), + help='{Enable|Disable} treating warnings as errors') -@depends("--enable-warnings-as-errors") +@depends('--enable-warnings-as-errors') def rust_warning_flags(warnings_as_errors): flags = [] # Note that cargo passes --cap-lints warn to rustc for third-party code, so # we don't need a very complicated setup. if warnings_as_errors: - flags.append("-Dwarnings") + flags.append('-Dwarnings') else: - flags.extend(("--cap-lints", "warn")) + flags.extend(('--cap-lints', 'warn')) return flags +c_warning_flag = dependable('-Werror') -c_warning_flag = dependable("-Werror") - -@depends("--enable-warnings-as-errors", c_warning_flag) +@depends('--enable-warnings-as-errors', c_warning_flag) def warnings_as_errors(warnings_as_errors, c_warning_flag): if not warnings_as_errors: - return "" + return '' return c_warning_flag - -set_config("WARNINGS_AS_ERRORS", warnings_as_errors) +set_config('WARNINGS_AS_ERRORS', warnings_as_errors) # We have a peculiar setup in old-configure.in where some compilation tests # depend on enabling warnings-as-errors even if it's disabled for Firefox # compilation. We therefore need this assignment. -add_old_configure_assignment("WARNINGS_AS_ERRORS", c_warning_flag) +add_old_configure_assignment('WARNINGS_AS_ERRORS', c_warning_flag) # GCC/Clang warnings: @@ -49,70 +44,70 @@ add_old_configure_assignment("WARNINGS_AS_ERRORS", c_warning_flag) # https://clang.llvm.org/docs/DiagnosticsReference.html # lots of useful warnings -add_gcc_warning("-Wall") +add_gcc_warning('-Wall') # catch implicit truncation of enum values assigned to smaller bit fields -check_and_add_gcc_warning("-Wbitfield-enum-conversion") +check_and_add_gcc_warning('-Wbitfield-enum-conversion') # catches bugs, e.g. "if (c); foo();", few false positives -add_gcc_warning("-Wempty-body") +add_gcc_warning('-Wempty-body') # catches return types with qualifiers like const -add_gcc_warning("-Wignored-qualifiers") +add_gcc_warning('-Wignored-qualifiers') # function declaration hides virtual function from base class -add_gcc_warning("-Woverloaded-virtual", cxx_compiler) +add_gcc_warning('-Woverloaded-virtual', cxx_compiler) # catches pointer arithmetic using NULL or sizeof(void) -add_gcc_warning("-Wpointer-arith") +add_gcc_warning('-Wpointer-arith') # catch modifying constructor parameter that shadows member variable -check_and_add_gcc_warning("-Wshadow-field-in-constructor-modified") +check_and_add_gcc_warning('-Wshadow-field-in-constructor-modified') # catches comparing signed/unsigned ints -add_gcc_warning("-Wsign-compare") +add_gcc_warning('-Wsign-compare') # catches overflow bugs, few false positives -add_gcc_warning("-Wtype-limits") +add_gcc_warning('-Wtype-limits') # catches some dead code -add_gcc_warning("-Wunreachable-code") -check_and_add_gcc_warning("-Wunreachable-code-return") +add_gcc_warning('-Wunreachable-code') +check_and_add_gcc_warning('-Wunreachable-code-return') # catches treating string literals as non-const -add_gcc_warning("-Wwrite-strings", cxx_compiler) +add_gcc_warning('-Wwrite-strings', cxx_compiler) # turned on by -Wall, but we use offsetof on non-POD types frequently -add_gcc_warning("-Wno-invalid-offsetof", cxx_compiler) +add_gcc_warning('-Wno-invalid-offsetof', cxx_compiler) # catches objects passed by value to variadic functions. -check_and_add_gcc_warning("-Wclass-varargs") +check_and_add_gcc_warning('-Wclass-varargs') # catches empty if/switch/for initialization statements that have no effect -check_and_add_gcc_warning("-Wempty-init-stmt", cxx_compiler) +check_and_add_gcc_warning('-Wempty-init-stmt', cxx_compiler) # catches some implicit conversion of floats to ints -check_and_add_gcc_warning("-Wfloat-overflow-conversion") -check_and_add_gcc_warning("-Wfloat-zero-conversion") +check_and_add_gcc_warning('-Wfloat-overflow-conversion') +check_and_add_gcc_warning('-Wfloat-zero-conversion') # catches issues around loops -check_and_add_gcc_warning("-Wloop-analysis") +check_and_add_gcc_warning('-Wloop-analysis') # catches C++ version forward-compat issues -check_and_add_gcc_warning("-Wc++2a-compat", cxx_compiler) +check_and_add_gcc_warning('-Wc++2a-compat', cxx_compiler) # catches possible misuse of the comma operator -check_and_add_gcc_warning("-Wcomma", cxx_compiler) +check_and_add_gcc_warning('-Wcomma', cxx_compiler) # catches duplicated conditions in if-else-if chains -check_and_add_gcc_warning("-Wduplicated-cond") +check_and_add_gcc_warning('-Wduplicated-cond') # catches unintentional switch case fallthroughs -check_and_add_gcc_warning("-Wimplicit-fallthrough", cxx_compiler) +check_and_add_gcc_warning('-Wimplicit-fallthrough', cxx_compiler) # catches unused variable/function declarations -check_and_add_gcc_warning("-Wunused-function", cxx_compiler) -check_and_add_gcc_warning("-Wunused-variable", cxx_compiler) +check_and_add_gcc_warning('-Wunused-function', cxx_compiler) +check_and_add_gcc_warning('-Wunused-variable', cxx_compiler) # catches expressions used as a null pointer constant # XXX: at the time of writing, the version of clang used on the OS X test @@ -122,117 +117,115 @@ check_and_add_gcc_warning("-Wunused-variable", cxx_compiler) # -Werror=non-literal-null-conversion, but we only do that when # --enable-warnings-as-errors is specified so that no unexpected fatal # warnings are produced. -check_and_add_gcc_warning( - "-Werror=non-literal-null-conversion", when="--enable-warnings-as-errors" -) +check_and_add_gcc_warning('-Werror=non-literal-null-conversion', + when='--enable-warnings-as-errors') # catches string literals used in boolean expressions -check_and_add_gcc_warning("-Wstring-conversion") +check_and_add_gcc_warning('-Wstring-conversion') # catches comparisons that are always true or false -check_and_add_gcc_warning("-Wtautological-overlap-compare") -check_and_add_gcc_warning("-Wtautological-unsigned-enum-zero-compare") -check_and_add_gcc_warning("-Wtautological-unsigned-zero-compare") +check_and_add_gcc_warning('-Wtautological-overlap-compare') +check_and_add_gcc_warning('-Wtautological-unsigned-enum-zero-compare') +check_and_add_gcc_warning('-Wtautological-unsigned-zero-compare') # This can be triggered by certain patterns used deliberately in portable code -check_and_add_gcc_warning("-Wno-error=tautological-type-limit-compare") +check_and_add_gcc_warning('-Wno-error=tautological-type-limit-compare') # we inline 'new' and 'delete' in mozalloc -check_and_add_gcc_warning("-Wno-inline-new-delete", cxx_compiler) +check_and_add_gcc_warning('-Wno-inline-new-delete', cxx_compiler) # Prevent the following GCC warnings from being treated as errors: # too many false positives -check_and_add_gcc_warning("-Wno-error=maybe-uninitialized") +check_and_add_gcc_warning('-Wno-error=maybe-uninitialized') # we don't want our builds held hostage when a platform-specific API # becomes deprecated. -check_and_add_gcc_warning("-Wno-error=deprecated-declarations") +check_and_add_gcc_warning('-Wno-error=deprecated-declarations') # false positives depending on optimization -check_and_add_gcc_warning("-Wno-error=array-bounds") +check_and_add_gcc_warning('-Wno-error=array-bounds') # can't get rid of those PGO warnings -check_and_add_gcc_warning("-Wno-error=coverage-mismatch") +check_and_add_gcc_warning('-Wno-error=coverage-mismatch') # -Wbackend-plugin warnings from Android PGO profile-use builds: # error: /builds/worker/workspace/build/src/mozglue/misc/AutoProfilerLabel.cpp: # Function control flow change detected (hash mismatch) # _ZN7mozilla17AutoProfilerLabelD2Ev [-Werror,-Wbackend-plugin] -check_and_add_gcc_warning("-Wno-error=backend-plugin") +check_and_add_gcc_warning('-Wno-error=backend-plugin') # false positives depending on optimizations -check_and_add_gcc_warning("-Wno-error=free-nonheap-object") +check_and_add_gcc_warning('-Wno-error=free-nonheap-object') # Would be a pain to fix all occurrences, for very little gain -check_and_add_gcc_warning("-Wno-multistatement-macros") +check_and_add_gcc_warning('-Wno-multistatement-macros') # Disable the -Werror for return-std-move because of a false positive # on nsTAutoStringN: https://bugs.llvm.org/show_bug.cgi?id=37249 -check_and_add_gcc_warning("-Wno-error=return-std-move") +check_and_add_gcc_warning('-Wno-error=return-std-move') # Disable the -Werror for -Wclass-memaccess as we have a long # tail of issues to fix -check_and_add_gcc_warning("-Wno-error=class-memaccess") +check_and_add_gcc_warning('-Wno-error=class-memaccess') # -Watomic-alignment is a new warning in clang 7 that seems way too broad. # https://bugs.llvm.org/show_bug.cgi?id=38593 -check_and_add_gcc_warning("-Wno-error=atomic-alignment") +check_and_add_gcc_warning('-Wno-error=atomic-alignment') # New warning with gcc 9. Not useful # https://bugzilla.mozilla.org/show_bug.cgi?id=1515356 -check_and_add_gcc_warning("-Wno-error=deprecated-copy") +check_and_add_gcc_warning('-Wno-error=deprecated-copy') # catches format/argument mismatches with printf c_format_warning, cxx_format_warning = check_and_add_gcc_warning( - "-Wformat", when=depends(target)(lambda t: t.kernel != "WINNT") -) + '-Wformat', when=depends(target)(lambda t: t.kernel != 'WINNT')) # Add compile-time warnings for unprotected functions and format functions # that represent possible security problems. Enable this only when -Wformat # is enabled, otherwise it is an error -check_and_add_gcc_warning( - "-Wformat-security", when=c_format_warning & cxx_format_warning -) -check_and_add_gcc_warning( - "-Wformat-overflow=2", when=c_format_warning & cxx_format_warning -) +check_and_add_gcc_warning('-Wformat-security', + when=c_format_warning & cxx_format_warning) +check_and_add_gcc_warning('-Wformat-overflow=2', + when=c_format_warning & cxx_format_warning) # Other MinGW specific things -with only_when(depends(target)(lambda t: t.kernel == "WINNT")): +with only_when(depends(target)(lambda t: t.kernel == 'WINNT')): # When compiling for Windows with gcc, we encounter lots of "#pragma warning"'s # which is an MSVC-only pragma that GCC does not recognize. - check_and_add_gcc_warning("-Wno-unknown-pragmas") + check_and_add_gcc_warning('-Wno-unknown-pragmas') # When compiling for Windows with gcc, gcc throws false positives and true # positives where the callsite is ifdef-ed out - check_and_add_gcc_warning("-Wno-unused-function") + check_and_add_gcc_warning('-Wno-unused-function') # When compiling for Windows with gcc, gcc cannot produce this warning # correctly: it mistakes DWORD_PTR and ULONG_PTR as types you cannot # give NULL to. (You can in fact do that.) - check_and_add_gcc_warning("-Wno-conversion-null") + check_and_add_gcc_warning('-Wno-conversion-null') # Throughout the codebase we regularly have switch statements off of enums # without covering every value in the enum. We don't care about these warnings. - check_and_add_gcc_warning("-Wno-switch") + check_and_add_gcc_warning('-Wno-switch') # Another code pattern we have is using start and end constants in enums of # different types. We do this for safety, but then when comparing it throws # an error, which we would like to ignore. This seems to only affect the MinGW # build, but we're not sure why. - check_and_add_gcc_warning("-Wno-enum-compare") + check_and_add_gcc_warning('-Wno-enum-compare') # We hit this all over the place with the gtest INSTANTIATE_TEST_CASE_P macro -check_and_add_gcc_warning("-Wno-gnu-zero-variadic-macro-arguments") +check_and_add_gcc_warning('-Wno-gnu-zero-variadic-macro-arguments') # Make it an error to be missing function declarations. -check_and_add_gcc_warning("-Werror=implicit-function-declaration") +check_and_add_gcc_warning('-Werror=implicit-function-declaration') # New in clang 11. We can't really do anything about this warning. -check_and_add_gcc_warning("-Wno-psabi") +check_and_add_gcc_warning('-Wno-psabi') # Please keep these last in this file -add_old_configure_assignment("_WARNINGS_CFLAGS", warnings_flags.cflags) -add_old_configure_assignment("_WARNINGS_CXXFLAGS", warnings_flags.cxxflags) -add_old_configure_assignment("_WARNINGS_HOST_CFLAGS", warnings_flags.host_cflags) -add_old_configure_assignment("_WARNINGS_HOST_CXXFLAGS", warnings_flags.host_cxxflags) +add_old_configure_assignment('_WARNINGS_CFLAGS', warnings_flags.cflags) +add_old_configure_assignment('_WARNINGS_CXXFLAGS', warnings_flags.cxxflags) +add_old_configure_assignment( + '_WARNINGS_HOST_CFLAGS', warnings_flags.host_cflags) +add_old_configure_assignment( + '_WARNINGS_HOST_CXXFLAGS', warnings_flags.host_cxxflags) diff --git a/build/moz.configure/windows.configure b/build/moz.configure/windows.configure index 2cc6a60411b9966d159cbe0392b73ec571914054..466d6fed7467302679e76d66240f8741149e4b7a 100644 --- a/build/moz.configure/windows.configure +++ b/build/moz.configure/windows.configure @@ -4,20 +4,16 @@ # 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/. -option( - "--with-windows-version", - nargs=1, - default="603", - help="Windows SDK version to target. Win 8.1 (603) is currently" - "the minimum supported version.", -) +option('--with-windows-version', nargs=1, default='603', + help='Windows SDK version to target. Win 8.1 (603) is currently' + 'the minimum supported version.') -@depends("--with-windows-version") -@imports(_from="__builtin__", _import="ValueError") +@depends('--with-windows-version') +@imports(_from='__builtin__', _import='ValueError') def valid_windows_version(value): if not value: - die("Cannot build with --without-windows-version") + die('Cannot build with --without-windows-version') try: version = int(value[0], 16) if version in (0x603,): @@ -25,30 +21,25 @@ def valid_windows_version(value): except ValueError: pass - die("Invalid value for --with-windows-version (%s)", value[0]) + die('Invalid value for --with-windows-version (%s)', value[0]) -option(env="WINDOWSSDKDIR", nargs=1, help="Directory containing the Windows SDK") +option(env='WINDOWSSDKDIR', nargs=1, + help='Directory containing the Windows SDK') -@depends("WINDOWSSDKDIR", host, c_compiler) +@depends('WINDOWSSDKDIR', host, c_compiler) def windows_sdk_dir(value, host, compiler): if value: return value # Ideally, we'd actually check for host/target ABI being MSVC, but # that's waiting for bug 1617793. - if host.kernel != "WINNT" or compiler.type != "clang-cl": + if host.kernel != 'WINNT' or compiler.type != 'clang-cl': return () - return set( - x[1] - for x in get_registry_values( - r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots" - r"\KitsRoot*", - get_32_and_64_bit=True, - ) - ) - + return set(x[1] for x in get_registry_values( + r'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots' + r'\KitsRoot*', get_32_and_64_bit=True)) # The Windows SDK 8.1 and 10 have different layouts. The former has # $SDK/include/$subdir, while the latter has $SDK/include/$version/$subdir. @@ -59,17 +50,16 @@ def windows_sdk_dir(value, host, compiler): # 8.1. -@imports("os") -@imports("re") -@imports(_from="__builtin__", _import="sorted") -@imports(_from="__builtin__", _import="Exception") +@imports('os') +@imports('re') +@imports(_from='__builtin__', _import='sorted') +@imports(_from='__builtin__', _import='Exception') def get_sdk_dirs(sdk, subdir): def get_dirs_containing(sdk, stem, subdir): base = os.path.join(sdk, stem) try: - subdirs = [ - d for d in os.listdir(base) if os.path.isdir(os.path.join(base, d)) - ] + subdirs = [d for d in os.listdir(base) + if os.path.isdir(os.path.join(base, d))] except Exception: subdirs = [] if not subdirs: @@ -78,21 +68,18 @@ def get_sdk_dirs(sdk, subdir): return (base,) # At this point, either we have an incomplete or invalid SDK directory, # or we exclusively have version numbers in subdirs. - return tuple( - os.path.join(base, s) - for s in subdirs - if os.path.isdir(os.path.join(base, s, subdir)) - ) + return tuple(os.path.join(base, s) for s in subdirs + if os.path.isdir(os.path.join(base, s, subdir))) def categorize(dirs): return {os.path.basename(d): d for d in dirs} - include_dirs = categorize(get_dirs_containing(sdk, "include", subdir)) - lib_dirs = categorize(get_dirs_containing(sdk, "lib", subdir)) + include_dirs = categorize(get_dirs_containing(sdk, 'include', subdir)) + lib_dirs = categorize(get_dirs_containing(sdk, 'lib', subdir)) - if "include" in include_dirs: - include_dirs["winv6.3"] = include_dirs["include"] - del include_dirs["include"] + if 'include' in include_dirs: + include_dirs['winv6.3'] = include_dirs['include'] + del include_dirs['include'] valid_versions = sorted(set(include_dirs) & set(lib_dirs), reverse=True) if valid_versions: @@ -103,47 +90,39 @@ def get_sdk_dirs(sdk, subdir): ) -@imports(_from="mozbuild.shellutil", _import="quote") +@imports(_from='mozbuild.shellutil', _import='quote') def valid_windows_sdk_dir_result(value): if value: - return "0x%04x in %s" % (value.version, quote(value.path)) + return '0x%04x in %s' % (value.version, quote(value.path)) -@depends(c_compiler, windows_sdk_dir, valid_windows_version, "WINDOWSSDKDIR") -@checking("for Windows SDK", valid_windows_sdk_dir_result) -@imports(_from="__builtin__", _import="sorted") -@imports(_from="__builtin__", _import="Exception") -@imports(_from="textwrap", _import="dedent") -def valid_windows_sdk_dir( - compiler, windows_sdk_dir, target_version, windows_sdk_dir_env -): +@depends(c_compiler, windows_sdk_dir, valid_windows_version, 'WINDOWSSDKDIR') +@checking('for Windows SDK', valid_windows_sdk_dir_result) +@imports(_from='__builtin__', _import='sorted') +@imports(_from='__builtin__', _import='Exception') +@imports(_from='textwrap', _import='dedent') +def valid_windows_sdk_dir(compiler, windows_sdk_dir, target_version, + windows_sdk_dir_env): # Ideally, we'd actually check for host/target ABI being MSVC, but # that's waiting for bug 1617793. - if compiler.type != "clang-cl": + if compiler.type != 'clang-cl': return None if windows_sdk_dir_env: windows_sdk_dir_env = windows_sdk_dir_env[0] sdks = {} for d in windows_sdk_dir: - sdk = get_sdk_dirs(d, "um") + sdk = get_sdk_dirs(d, 'um') if sdk: - check = dedent( - """\ + check = dedent('''\ #include WINVER_MAXVER - """ - ) - um_dir = os.path.join(sdk.include, "um") - shared_dir = os.path.join(sdk.include, "shared") - result = try_preprocess( - compiler.wrapper - + [compiler.compiler] - + compiler.flags - + ["-X", "-I", um_dir, "-I", shared_dir], - "C", - check, - onerror=lambda: "", - ) + ''') + um_dir = os.path.join(sdk.include, 'um') + shared_dir = os.path.join(sdk.include, 'shared') + result = try_preprocess(compiler.wrapper + [compiler.compiler] + + compiler.flags + + ['-X', '-I', um_dir, '-I', shared_dir], 'C', + check, onerror=lambda: '') if result: maxver = result.splitlines()[-1] try: @@ -155,10 +134,9 @@ def valid_windows_sdk_dir( continue if d == windows_sdk_dir_env: raise FatalCheckError( - "Error while checking the version of the SDK in " - "WINDOWSSDKDIR (%s). Please verify it contains a valid and " - "complete SDK installation." % windows_sdk_dir_env - ) + 'Error while checking the version of the SDK in ' + 'WINDOWSSDKDIR (%s). Please verify it contains a valid and ' + 'complete SDK installation.' % windows_sdk_dir_env) valid_sdks = sorted(sdks, key=lambda x: sdks[x][0], reverse=True) if valid_sdks: @@ -166,18 +144,16 @@ def valid_windows_sdk_dir( if not valid_sdks or biggest_version < target_version: if windows_sdk_dir_env: raise FatalCheckError( - "You are targeting Windows version 0x%04x, but your SDK only " - "supports up to version 0x%04x. Install and use an updated SDK, " - "or target a lower version using --with-windows-version. " - "Alternatively, try running the Windows SDK Configuration Tool " - "and selecting a newer SDK. See " - "https://developer.mozilla.org/En/Windows_SDK_versions for " - "details on fixing this." % (target_version, biggest_version) - ) + 'You are targeting Windows version 0x%04x, but your SDK only ' + 'supports up to version 0x%04x. Install and use an updated SDK, ' + 'or target a lower version using --with-windows-version. ' + 'Alternatively, try running the Windows SDK Configuration Tool ' + 'and selecting a newer SDK. See ' + 'https://developer.mozilla.org/En/Windows_SDK_versions for ' + 'details on fixing this.' % (target_version, biggest_version)) raise FatalCheckError( - "Cannot find a Windows SDK for version >= 0x%04x." % target_version - ) + 'Cannot find a Windows SDK for version >= 0x%04x.' % target_version) return namespace( path=sdk.path, @@ -187,27 +163,27 @@ def valid_windows_sdk_dir( ) -@imports(_from="mozbuild.shellutil", _import="quote") +@imports(_from='mozbuild.shellutil', _import='quote') def valid_ucrt_sdk_dir_result(value): if value: - return "%s in %s" % (value.version, quote(value.path)) + return '%s in %s' % (value.version, quote(value.path)) -@depends(windows_sdk_dir, "WINDOWSSDKDIR", c_compiler) -@checking("for Universal CRT SDK", valid_ucrt_sdk_dir_result) -@imports("os") -@imports(_from="__builtin__", _import="sorted") -@imports(_import="mozpack.path", _as="mozpath") +@depends(windows_sdk_dir, 'WINDOWSSDKDIR', c_compiler) +@checking('for Universal CRT SDK', valid_ucrt_sdk_dir_result) +@imports('os') +@imports(_from='__builtin__', _import='sorted') +@imports(_import='mozpack.path', _as='mozpath') def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env, compiler): # Ideally, we'd actually check for host/target ABI being MSVC, but # that's waiting for bug 1617793. - if compiler.type != "clang-cl": + if compiler.type != 'clang-cl': return None if windows_sdk_dir_env: windows_sdk_dir_env = windows_sdk_dir_env[0] sdks = {} for d in windows_sdk_dir: - sdk = get_sdk_dirs(d, "ucrt") + sdk = get_sdk_dirs(d, 'ucrt') if sdk: version = os.path.basename(sdk.include) # We're supposed to always find a version in the directory, because @@ -215,7 +191,7 @@ def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env, compiler): # contain the Universal CRT SDK. When the main SDK is 8.1, there # is, however, supposed to be a reduced install of the SDK 10 # with the UCRT. - if version != "include": + if version != 'include': sdks[d] = Version(version), sdk continue if d == windows_sdk_dir_env: @@ -223,14 +199,12 @@ def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env, compiler): # Universal CRT SDK, chances are this is a start-shell-msvc*.bat # setup, where INCLUDE and LIB already contain the UCRT paths. ucrt_includes = [ - p - for p in os.environ.get("INCLUDE", "").split(";") - if os.path.basename(p).lower() == "ucrt" + p for p in os.environ.get('INCLUDE', '').split(';') + if os.path.basename(p).lower() == 'ucrt' ] ucrt_libs = [ - p - for p in os.environ.get("LIB", "").split(";") - if os.path.basename(os.path.dirname(p)).lower() == "ucrt" + p for p in os.environ.get('LIB', '').split(';') + if os.path.basename(os.path.dirname(p)).lower() == 'ucrt' ] if ucrt_includes and ucrt_libs: # Pick the first of each, since they are the ones that the @@ -239,36 +213,30 @@ def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env, compiler): lib = os.path.dirname(os.path.dirname(ucrt_libs[0])) path = os.path.dirname(os.path.dirname(include)) version = os.path.basename(include) - if version != "include" and mozpath.basedir(lib, [path]): - sdks[d] = ( - Version(version), - namespace( - path=path, - include=include, - lib=lib, - ), + if version != 'include' and mozpath.basedir(lib, [path]): + sdks[d] = Version(version), namespace( + path=path, + include=include, + lib=lib, ) continue raise FatalCheckError( - "The SDK in WINDOWSSDKDIR (%s) does not contain the Universal " - "CRT." % windows_sdk_dir_env - ) + 'The SDK in WINDOWSSDKDIR (%s) does not contain the Universal ' + 'CRT.' % windows_sdk_dir_env) valid_sdks = sorted(sdks, key=lambda x: sdks[x][0], reverse=True) if not valid_sdks: - raise FatalCheckError( - "Cannot find the Universal CRT SDK. " "Please install it." - ) + raise FatalCheckError('Cannot find the Universal CRT SDK. ' + 'Please install it.') version, sdk = sdks[valid_sdks[0]] - minimum_ucrt_version = Version("10.0.17134.0") + minimum_ucrt_version = Version('10.0.17134.0') if version < minimum_ucrt_version: - raise FatalCheckError( - "Latest Universal CRT SDK version found %s" - " and minimum required is %s. This or a later" - " version can be installed using the Visual" - " Studio installer." % (version, minimum_ucrt_version) - ) + raise FatalCheckError('Latest Universal CRT SDK version found %s' + ' and minimum required is %s. This or a later' + ' version can be installed using the Visual' + ' Studio installer.' + % (version, minimum_ucrt_version)) return namespace( path=sdk.path, @@ -279,36 +247,35 @@ def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env, compiler): @depends(c_compiler, host_c_compiler, toolchain_search_path) -@imports("os") +@imports('os') def vc_path(c_compiler, host_c_compiler, toolchain_search_path): - if c_compiler.type != "clang-cl" and host_c_compiler.type != "clang-cl": + if c_compiler.type != 'clang-cl' and host_c_compiler.type != 'clang-cl': return # In clang-cl builds, we need the headers and libraries from an MSVC installation. - vc_program = find_program("cl.exe", paths=toolchain_search_path) + vc_program = find_program('cl.exe', paths=toolchain_search_path) if not vc_program: - die("Cannot find a Visual C++ install for e.g. ATL headers.") + die('Cannot find a Visual C++ install for e.g. ATL headers.') result = os.path.dirname(vc_program) while True: next, p = os.path.split(result) if next == result: - die( - "Cannot determine the Visual C++ directory the compiler (%s) " - "is in" % vc_program - ) + die('Cannot determine the Visual C++ directory the compiler (%s) ' + 'is in' % vc_program) result = next - if p.lower() == "bin": + if p.lower() == 'bin': break return os.path.normpath(result) -option(env="DIA_SDK_PATH", nargs=1, help="Path to the Debug Interface Access SDK") +option(env='DIA_SDK_PATH', nargs=1, + help='Path to the Debug Interface Access SDK') -@depends(vc_path, "DIA_SDK_PATH") -@checking("for the Debug Interface Access SDK", lambda x: x or "not found") -@imports("os") +@depends(vc_path, 'DIA_SDK_PATH') +@checking('for the Debug Interface Access SDK', lambda x: x or 'not found') +@imports('os') def dia_sdk_dir(vc_path, dia_sdk_path): if dia_sdk_path: path = os.path.normpath(dia_sdk_path[0]) @@ -316,58 +283,51 @@ def dia_sdk_dir(vc_path, dia_sdk_path): elif vc_path: # This would be easier if we had the installationPath that # get_vc_paths works with, since 'DIA SDK' is relative to that. - path = os.path.normpath( - os.path.join(vc_path, "..", "..", "..", "..", "DIA SDK") - ) + path = os.path.normpath(os.path.join( + vc_path, '..', '..', '..', '..', 'DIA SDK')) else: return - if os.path.exists(os.path.join(path, "include", "dia2.h")): + if os.path.exists(os.path.join(path, 'include', 'dia2.h')): return path @depends(vc_path, valid_windows_sdk_dir, valid_ucrt_sdk_dir, dia_sdk_dir) -@imports("os") +@imports('os') def include_path(vc_path, windows_sdk_dir, ucrt_sdk_dir, dia_sdk_dir): if not vc_path: return - atlmfc_dir = os.path.join(vc_path, "atlmfc", "include") + atlmfc_dir = os.path.join(vc_path, 'atlmfc', 'include') if not os.path.isdir(atlmfc_dir): - die( - "Cannot find the ATL/MFC headers in the Visual C++ directory (%s). " - "Please install them." % vc_path - ) + die('Cannot find the ATL/MFC headers in the Visual C++ directory (%s). ' + 'Please install them.' % vc_path) - winrt_dir = os.path.join(windows_sdk_dir.include, "winrt") + winrt_dir = os.path.join(windows_sdk_dir.include, 'winrt') if not os.path.isdir(winrt_dir): - die( - "Cannot find the WinRT headers in the Windows SDK directory (%s). " - "Please install them." % windows_sdk_dir.path - ) + die('Cannot find the WinRT headers in the Windows SDK directory (%s). ' + 'Please install them.' % windows_sdk_dir.path) includes = [] - include_env = os.environ.get("INCLUDE") + include_env = os.environ.get('INCLUDE') if include_env: includes.append(include_env) - includes.extend( - ( - os.path.join(vc_path, "include"), - atlmfc_dir, - os.path.join(windows_sdk_dir.include, "shared"), - os.path.join(windows_sdk_dir.include, "um"), - winrt_dir, - os.path.join(ucrt_sdk_dir.include, "ucrt"), - ) - ) + includes.extend(( + os.path.join(vc_path, 'include'), + atlmfc_dir, + os.path.join(windows_sdk_dir.include, 'shared'), + os.path.join(windows_sdk_dir.include, 'um'), + winrt_dir, + os.path.join(ucrt_sdk_dir.include, 'ucrt'), + )) if dia_sdk_dir: - includes.append(os.path.join(dia_sdk_dir, "include")) + includes.append(os.path.join(dia_sdk_dir, 'include')) # Set in the environment for old-configure - includes = ";".join(includes) - os.environ["INCLUDE"] = includes + includes = ';'.join(includes) + os.environ['INCLUDE'] = includes return includes -set_config("INCLUDE", include_path) +set_config('INCLUDE', include_path) @template @@ -379,10 +339,10 @@ def dia_sdk_subdir(host_or_target, subdir): # For some reason the DIA SDK still uses the old-style targets # even in a newer MSVC. old_target = { - "x86": "", - "x86_64": "amd64", - "arm": "arm", - "aarch64": "arm64", + 'x86': '', + 'x86_64': 'amd64', + 'arm': 'arm', + 'aarch64': 'arm64' }.get(target.cpu) if old_target is None: return @@ -396,52 +356,40 @@ def dia_sdk_subdir(host_or_target, subdir): return dia_sdk_subdir -set_config("WIN_DIA_SDK_BIN_DIR", dia_sdk_subdir(host, "bin")) +set_config('WIN_DIA_SDK_BIN_DIR', dia_sdk_subdir(host, 'bin')) @template def lib_path_for(host_or_target): - @depends( - host_or_target, - dependable(host_or_target is host), - vc_path, - valid_windows_sdk_dir, - valid_ucrt_sdk_dir, - dia_sdk_subdir(host_or_target, "lib"), - ) - @imports("os") - def lib_path( - target, is_host, vc_path, windows_sdk_dir, ucrt_sdk_dir, dia_sdk_lib_dir - ): + @depends(host_or_target, dependable(host_or_target is host), vc_path, + valid_windows_sdk_dir, valid_ucrt_sdk_dir, dia_sdk_subdir(host_or_target, 'lib')) + @imports('os') + def lib_path(target, is_host, vc_path, windows_sdk_dir, ucrt_sdk_dir, dia_sdk_lib_dir): if not vc_path: return sdk_target = { - "x86": "x86", - "x86_64": "x64", - "arm": "arm", - "aarch64": "arm64", + 'x86': 'x86', + 'x86_64': 'x64', + 'arm': 'arm', + 'aarch64': 'arm64', }.get(target.cpu) # MSVC2017 switched to use the same target naming as the sdk. - atlmfc_dir = os.path.join(vc_path, "atlmfc", "lib", sdk_target) + atlmfc_dir = os.path.join(vc_path, 'atlmfc', 'lib', sdk_target) if not os.path.isdir(atlmfc_dir): - die( - "Cannot find the ATL/MFC libraries in the Visual C++ directory " - "(%s). Please install them." % vc_path - ) + die('Cannot find the ATL/MFC libraries in the Visual C++ directory ' + '(%s). Please install them.' % vc_path) libs = [] - lib_env = os.environ.get("LIB") + lib_env = os.environ.get('LIB') if lib_env and not is_host: - libs.extend(lib_env.split(";")) - libs.extend( - ( - os.path.join(vc_path, "lib", sdk_target), - atlmfc_dir, - os.path.join(windows_sdk_dir.lib, "um", sdk_target), - os.path.join(ucrt_sdk_dir.lib, "ucrt", sdk_target), - ) - ) + libs.extend(lib_env.split(';')) + libs.extend(( + os.path.join(vc_path, 'lib', sdk_target), + atlmfc_dir, + os.path.join(windows_sdk_dir.lib, 'um', sdk_target), + os.path.join(ucrt_sdk_dir.lib, 'ucrt', sdk_target), + )) if dia_sdk_lib_dir: libs.append(dia_sdk_lib_dir) return libs @@ -450,28 +398,27 @@ def lib_path_for(host_or_target): @depends_if(lib_path_for(target)) -@imports("os") +@imports('os') def lib_path(libs): # Set in the environment for old-configure - libs = ";".join(libs) - os.environ["LIB"] = libs + libs = ';'.join(libs) + os.environ['LIB'] = libs return libs -set_config("LIB", lib_path) +set_config('LIB', lib_path) lib_path_for_host = lib_path_for(host) - @depends_if(lib_path_for_host) -@imports(_from="mozbuild.shellutil", _import="quote") +@imports(_from='mozbuild.shellutil', _import='quote') def host_linker_libpaths(libs): - return ["-LIBPATH:%s" % quote(l) for l in libs] + return ['-LIBPATH:%s' % quote(l) for l in libs] @depends_if(lib_path_for_host) -@imports(_from="mozbuild.shellutil", _import="quote") +@imports(_from='mozbuild.shellutil', _import='quote') def host_linker_libpaths_bat(libs): # .bat files need a different style of quoting. Batch quoting is actually # not defined, and up to applications to handle, so it's not really clear @@ -482,54 +429,42 @@ def host_linker_libpaths_bat(libs): return ['"-LIBPATH:%s"' % l for l in libs] -set_config("HOST_LINKER_LIBPATHS", host_linker_libpaths) -set_config("HOST_LINKER_LIBPATHS_BAT", host_linker_libpaths_bat) +set_config('HOST_LINKER_LIBPATHS', host_linker_libpaths) +set_config('HOST_LINKER_LIBPATHS_BAT', host_linker_libpaths_bat) @depends(valid_windows_sdk_dir, valid_ucrt_sdk_dir, host) -@imports(_from="os", _import="environ") +@imports(_from='os', _import='environ') def sdk_bin_path(valid_windows_sdk_dir, valid_ucrt_sdk_dir, host): if not valid_windows_sdk_dir: return vc_host = { - "x86": "x86", - "x86_64": "x64", + 'x86': 'x86', + 'x86_64': 'x64', }.get(host.cpu) # From version 10.0.15063.0 onwards the bin path contains the version number. - versioned_bin = ( - "bin" - if valid_ucrt_sdk_dir.version < "10.0.15063.0" - else os.path.join("bin", str(valid_ucrt_sdk_dir.version)) - ) + versioned_bin = ('bin' if valid_ucrt_sdk_dir.version < '10.0.15063.0' + else os.path.join('bin', str(valid_ucrt_sdk_dir.version))) result = [ - environ["PATH"], - os.path.join(valid_windows_sdk_dir.path, versioned_bin, vc_host), + environ['PATH'], + os.path.join(valid_windows_sdk_dir.path, versioned_bin, vc_host) ] - if vc_host == "x64": - result.append(os.path.join(valid_windows_sdk_dir.path, versioned_bin, "x86")) + if vc_host == 'x64': + result.append( + os.path.join(valid_windows_sdk_dir.path, versioned_bin, 'x86')) return result -option(env="LINKER", nargs=1, when=target_is_windows, help="Path to the linker") +option(env='LINKER', nargs=1, when=target_is_windows, help='Path to the linker') -link = check_prog( - "LINKER", - ("lld-link",), - input="LINKER", - when=target_is_windows, - paths=toolchain_search_path, -) +link = check_prog('LINKER', ('lld-link',), input='LINKER', + when=target_is_windows, paths=toolchain_search_path) -option(env="HOST_LINKER", nargs=1, when=host_is_windows, help="Path to the host linker") +option(env='HOST_LINKER', nargs=1, when=host_is_windows, help='Path to the host linker') -host_link = check_prog( - "HOST_LINKER", - ("lld-link",), - input="HOST_LINKER", - when=host_is_windows, - paths=host_toolchain_search_path, -) +host_link = check_prog('HOST_LINKER', ('lld-link',), input='HOST_LINKER', + when=host_is_windows, paths=host_toolchain_search_path) -add_old_configure_assignment("LINKER", link) +add_old_configure_assignment('LINKER', link) diff --git a/build/pgo/profileserver.py b/build/pgo/profileserver.py index 7f3de106ab423f854ca50d75b3cdb41f255e3e80..cbb45e08a293ceef91cceb9eb4f79eb081d424d2 100755 --- a/build/pgo/profileserver.py +++ b/build/pgo/profileserver.py @@ -22,31 +22,27 @@ from six import string_types PORT = 8888 PATH_MAPPINGS = { - "/webkit/PerformanceTests": "third_party/webkit/PerformanceTests", + '/webkit/PerformanceTests': 'third_party/webkit/PerformanceTests', # It is tempting to map to `testing/talos/talos/tests` instead, to avoid # writing `tests/` in every path, but we can't do that because some files # refer to scripts located in `../..`. - "/talos": "testing/talos/talos", + '/talos': 'testing/talos/talos', } def get_crashreports(directory, name=None): rc = 0 - upload_path = os.environ.get("UPLOAD_PATH") + upload_path = os.environ.get('UPLOAD_PATH') if upload_path: # For automation, log the minidumps with stackwalk and get them moved to # the artifacts directory. - fetches_dir = os.environ.get("MOZ_FETCHES_DIR") + fetches_dir = os.environ.get('MOZ_FETCHES_DIR') if not fetches_dir: - raise Exception( - "Unable to process minidump in automation because " - "$MOZ_FETCHES_DIR is not set in the environment" - ) - stackwalk_binary = os.path.join( - fetches_dir, "minidump_stackwalk", "minidump_stackwalk" - ) - if sys.platform == "win32": - stackwalk_binary += ".exe" + raise Exception("Unable to process minidump in automation because " + "$MOZ_FETCHES_DIR is not set in the environment") + stackwalk_binary = os.path.join(fetches_dir, 'minidump_stackwalk', 'minidump_stackwalk') + if sys.platform == 'win32': + stackwalk_binary += '.exe' minidump_path = os.path.join(directory, "minidumps") rc = mozcrash.check_for_crashes( minidump_path, @@ -58,49 +54,48 @@ def get_crashreports(directory, name=None): return rc -if __name__ == "__main__": +if __name__ == '__main__': cli = CLI() debug_args, interactive = cli.debugger_arguments() runner_args = cli.runner_args() build = MozbuildObject.from_environment() - binary = runner_args.get("binary") + binary = runner_args.get('binary') if not binary: try: binary = build.get_binary_path(where="staged-package") except BinaryNotFoundException as e: - print("{}\n\n{}\n".format(e, e.help())) + print('{}\n\n{}\n'.format(e, e.help())) sys.exit(1) binary = os.path.normpath(os.path.abspath(binary)) path_mappings = { - k: os.path.join(build.topsrcdir, v) for k, v in PATH_MAPPINGS.items() + k: os.path.join(build.topsrcdir, v) + for k, v in PATH_MAPPINGS.items() } - httpd = MozHttpd( - port=PORT, - docroot=os.path.join(build.topsrcdir, "build", "pgo"), - path_mappings=path_mappings, - ) + httpd = MozHttpd(port=PORT, + docroot=os.path.join(build.topsrcdir, "build", "pgo"), + path_mappings=path_mappings) httpd.start(block=False) locations = ServerLocations() - locations.add_host(host="127.0.0.1", port=PORT, options="primary,privileged") + locations.add_host(host='127.0.0.1', + port=PORT, + options='primary,privileged') - old_profraw_files = glob.glob("*.profraw") + old_profraw_files = glob.glob('*.profraw') for f in old_profraw_files: os.remove(f) with TemporaryDirectory() as profilePath: # TODO: refactor this into mozprofile - profile_data_dir = os.path.join(build.topsrcdir, "testing", "profiles") - with open(os.path.join(profile_data_dir, "profiles.json"), "r") as fh: - base_profiles = json.load(fh)["profileserver"] + profile_data_dir = os.path.join(build.topsrcdir, 'testing', 'profiles') + with open(os.path.join(profile_data_dir, 'profiles.json'), 'r') as fh: + base_profiles = json.load(fh)['profileserver'] - prefpaths = [ - os.path.join(profile_data_dir, profile, "user.js") - for profile in base_profiles - ] + prefpaths = [os.path.join(profile_data_dir, profile, 'user.js') + for profile in base_profiles] prefs = {} for path in prefpaths: @@ -118,16 +113,12 @@ if __name__ == "__main__": # and this is a bool pref. prefs["browser.tabs.remote.autostart"] = True - profile = FirefoxProfile( - profile=profilePath, - preferences=prefs, - addons=[ - os.path.join( - build.topsrcdir, "tools", "quitter", "quitter@mozilla.org.xpi" - ) - ], - locations=locations, - ) + profile = FirefoxProfile(profile=profilePath, + preferences=prefs, + addons=[os.path.join( + build.topsrcdir, 'tools', 'quitter', + 'quitter@mozilla.org.xpi')], + locations=locations) env = os.environ.copy() env["MOZ_CRASHREPORTER_NO_REPORT"] = "1" @@ -146,31 +137,28 @@ if __name__ == "__main__": env["LLVM_PROFILE_FILE"] = "default_%p_random_%m.profraw" # Write to an output file if we're running in automation - process_args = {"universal_newlines": True} - if "UPLOAD_PATH" in env: - process_args["logfile"] = os.path.join( - env["UPLOAD_PATH"], "profile-run-1.log" - ) + process_args = {'universal_newlines': True} + if 'UPLOAD_PATH' in env: + process_args['logfile'] = os.path.join(env['UPLOAD_PATH'], 'profile-run-1.log') # Run Firefox a first time to initialize its profile - runner = FirefoxRunner( - profile=profile, - binary=binary, - cmdargs=["data:text/html,"], - env=env, - process_args=process_args, - ) + runner = FirefoxRunner(profile=profile, + binary=binary, + cmdargs=['data:text/html,'], + env=env, + process_args=process_args) runner.start() ret = runner.wait() if ret: - print("Firefox exited with code %d during profile initialization" % ret) - logfile = process_args.get("logfile") + print("Firefox exited with code %d during profile initialization" + % ret) + logfile = process_args.get('logfile') if logfile: print("Firefox output (%s):" % logfile) with open(logfile) as f: print(f.read()) httpd.stop() - get_crashreports(profilePath, name="Profile initialization") + get_crashreports(profilePath, name='Profile initialization') sys.exit(ret) jarlog = os.getenv("JARLOG_FILE") @@ -180,55 +168,48 @@ if __name__ == "__main__": if os.path.exists(jarlog): os.remove(jarlog) - if "UPLOAD_PATH" in env: - process_args["logfile"] = os.path.join( - env["UPLOAD_PATH"], "profile-run-2.log" - ) + if 'UPLOAD_PATH' in env: + process_args['logfile'] = os.path.join(env['UPLOAD_PATH'], 'profile-run-2.log') cmdargs = ["http://localhost:%d/index.html" % PORT] - runner = FirefoxRunner( - profile=profile, - binary=binary, - cmdargs=cmdargs, - env=env, - process_args=process_args, - ) + runner = FirefoxRunner(profile=profile, + binary=binary, + cmdargs=cmdargs, + env=env, + process_args=process_args) runner.start(debug_args=debug_args, interactive=interactive) ret = runner.wait() httpd.stop() if ret: print("Firefox exited with code %d during profiling" % ret) - logfile = process_args.get("logfile") + logfile = process_args.get('logfile') if logfile: print("Firefox output (%s):" % logfile) with open(logfile) as f: print(f.read()) - get_crashreports(profilePath, name="Profiling run") + get_crashreports(profilePath, name='Profiling run') sys.exit(ret) # Try to move the crash reports to the artifacts even if Firefox appears # to exit successfully, in case there's a crash that doesn't set the # return code to non-zero for some reason. - if get_crashreports(profilePath, name="Firefox exited successfully?") != 0: + if get_crashreports(profilePath, name='Firefox exited successfully?') != 0: print("Firefox exited successfully, but produced a crashreport") sys.exit(1) - llvm_profdata = env.get("LLVM_PROFDATA") + llvm_profdata = env.get('LLVM_PROFDATA') if llvm_profdata: - profraw_files = glob.glob("*.profraw") + profraw_files = glob.glob('*.profraw') if not profraw_files: - print( - "Could not find profraw files in the current directory: %s" - % os.getcwd() - ) + print('Could not find profraw files in the current directory: %s' % os.getcwd()) sys.exit(1) merge_cmd = [ llvm_profdata, - "merge", - "-o", - "merged.profdata", + 'merge', + '-o', + 'merged.profdata', ] + profraw_files rc = subprocess.call(merge_cmd) if rc != 0: - print("INFRA-ERROR: Failed to merge profile data. Corrupt profile?") + print('INFRA-ERROR: Failed to merge profile data. Corrupt profile?') # exit with TBPL_RETRY sys.exit(4) diff --git a/build/submit_telemetry_data.py b/build/submit_telemetry_data.py index 0748fbfeadd2479f8bd04b6905118b1816fb2cc8..700f7550f1641578cf857733e9772a8e2af70be6 100644 --- a/build/submit_telemetry_data.py +++ b/build/submit_telemetry_data.py @@ -19,15 +19,15 @@ from mozbuild.telemetry import ( verify_statedir, ) -BUILD_TELEMETRY_URL = "https://incoming.telemetry.mozilla.org/{endpoint}" -SUBMIT_ENDPOINT = "submit/eng-workflow/build/1/{ping_uuid}" -STATUS_ENDPOINT = "status" +BUILD_TELEMETRY_URL = 'https://incoming.telemetry.mozilla.org/{endpoint}' +SUBMIT_ENDPOINT = 'submit/eng-workflow/build/1/{ping_uuid}' +STATUS_ENDPOINT = 'status' def delete_expired_files(directory, days=30): - """Discards files in a directory older than a specified number + '''Discards files in a directory older than a specified number of days - """ + ''' now = datetime.datetime.now() for filename in os.listdir(directory): filepath = os.path.join(directory, filename) @@ -42,9 +42,9 @@ def delete_expired_files(directory, days=30): def check_edge_server_status(session): - """Returns True if the Telemetry Edge Server + '''Returns True if the Telemetry Edge Server is ready to accept data - """ + ''' status_url = BUILD_TELEMETRY_URL.format(endpoint=STATUS_ENDPOINT) response = session.get(status_url) if response.status_code != 200: @@ -53,9 +53,9 @@ def check_edge_server_status(session): def send_telemetry_ping(session, data, ping_uuid): - """Sends a single build telemetry ping to the + '''Sends a single build telemetry ping to the edge server, returning the response object - """ + ''' resource_url = SUBMIT_ENDPOINT.format(ping_uuid=str(ping_uuid)) url = BUILD_TELEMETRY_URL.format(endpoint=resource_url) response = session.post(url, json=data) @@ -64,9 +64,9 @@ def send_telemetry_ping(session, data, ping_uuid): def submit_telemetry_data(outgoing, submitted): - """Sends information about `./mach build` invocations to + '''Sends information about `./mach build` invocations to the Telemetry pipeline - """ + ''' with requests.Session() as session: # Confirm the server is OK if not check_edge_server_status(session): @@ -76,14 +76,14 @@ def submit_telemetry_data(outgoing, submitted): for filename in os.listdir(outgoing): path = os.path.join(outgoing, filename) - if os.path.isdir(path) or not path.endswith(".json"): - logging.info("skipping item {}".format(path)) + if os.path.isdir(path) or not path.endswith('.json'): + logging.info('skipping item {}'.format(path)) continue ping_uuid = os.path.splitext(filename)[0] # strip ".json" to get ping UUID try: - with open(path, "r") as f: + with open(path, 'r') as f: data = json.load(f) # Verify the data matches the schema @@ -93,7 +93,7 @@ def submit_telemetry_data(outgoing, submitted): response = send_telemetry_ping(session, data, ping_uuid) if response.status_code != 200: - msg = "response code {code} sending {uuid} to telemetry: {body}".format( + msg = 'response code {code} sending {uuid} to telemetry: {body}'.format( body=response.content, code=response.status_code, uuid=ping_uuid, @@ -102,25 +102,27 @@ def submit_telemetry_data(outgoing, submitted): continue # Move from "outgoing" to "submitted" - os.rename( - os.path.join(outgoing, filename), os.path.join(submitted, filename) - ) + os.rename(os.path.join(outgoing, filename), + os.path.join(submitted, filename)) - logging.info("successfully posted {} to telemetry".format(ping_uuid)) + logging.info('successfully posted {} to telemetry'.format(ping_uuid)) except ValueError as ve: # ValueError is thrown if JSON cannot be decoded - logging.exception("exception parsing JSON at %s: %s" % (path, str(ve))) + logging.exception('exception parsing JSON at %s: %s' + % (path, str(ve))) os.remove(path) except voluptuous.Error as e: # Invalid is thrown if some data does not fit # the correct Schema - logging.exception("invalid data found at %s: %s" % (path, e.message)) + logging.exception('invalid data found at %s: %s' + % (path, e.message)) os.remove(path) except Exception as e: - logging.error("exception posting to telemetry " "server: %s" % str(e)) + logging.error('exception posting to telemetry ' + 'server: %s' % str(e)) break delete_expired_files(submitted) @@ -128,9 +130,9 @@ def submit_telemetry_data(outgoing, submitted): return 0 -if __name__ == "__main__": +if __name__ == '__main__': if len(sys.argv) != 2: - print("usage: python submit_telemetry_data.py ") + print('usage: python submit_telemetry_data.py ') sys.exit(1) statedir = sys.argv[1] @@ -139,11 +141,9 @@ if __name__ == "__main__": outgoing, submitted, telemetry_log = verify_statedir(statedir) # Configure logging - logging.basicConfig( - filename=telemetry_log, - format="%(asctime)s %(message)s", - level=logging.DEBUG, - ) + logging.basicConfig(filename=telemetry_log, + format='%(asctime)s %(message)s', + level=logging.DEBUG) sys.exit(submit_telemetry_data(outgoing, submitted)) diff --git a/build/unix/elfhack/inject/copy_source.py b/build/unix/elfhack/inject/copy_source.py index 02b4f6237e27723d9975af6d66e2c2c6c49a37f9..757253e3975eba1c1b6fc666ecfc35e27696ac16 100644 --- a/build/unix/elfhack/inject/copy_source.py +++ b/build/unix/elfhack/inject/copy_source.py @@ -6,5 +6,5 @@ def copy(out_file, in_path): - with open(in_path, "r") as fh: + with open(in_path, 'r') as fh: out_file.write(fh.read()) diff --git a/build/unix/elfhack/inject/moz.build b/build/unix/elfhack/inject/moz.build index 5b717a49cfeb9d9fc833f53ba88ca73f786ddfec..516104c06aaa6104bfee6c4c7f0b128f5e277bfc 100644 --- a/build/unix/elfhack/inject/moz.build +++ b/build/unix/elfhack/inject/moz.build @@ -6,35 +6,35 @@ # dummy library name to avoid skipping building the source here, which # we only need the object for. -Library("elfhack_inject") +Library('elfhack_inject') DIST_INSTALL = False -cpu = CONFIG["CPU_ARCH"] +cpu = CONFIG['CPU_ARCH'] -gen_src = "%s.c" % cpu -GeneratedFile( - gen_src, script="copy_source.py", entry_point="copy", inputs=["../inject.c"] -) +gen_src = '%s.c' % cpu +GeneratedFile(gen_src, script='copy_source.py', entry_point='copy', + inputs = ['../inject.c']) SOURCES += [ - "!%s" % gen_src, + '!%s' % gen_src, ] NO_PGO = True -for v in ("OS_CPPFLAGS", "OS_CFLAGS", "DEBUG", "CLANG_PLUGIN", "OPTIMIZE", "FRAMEPTR"): +for v in ('OS_CPPFLAGS', 'OS_CFLAGS', 'DEBUG', 'CLANG_PLUGIN', 'OPTIMIZE', + 'FRAMEPTR'): flags = [] idx = 0 for flag in COMPILE_FLAGS[v]: - if flag == "-isystem": - flags.append("".join(COMPILE_FLAGS[v][idx : idx + 2])) - elif flag.startswith(("-m", "-I", "-isystem")): + if flag == '-isystem': + flags.append(''.join(COMPILE_FLAGS[v][idx:idx + 2])) + elif flag.startswith(('-m', '-I', '-isystem')): flags.append(flag) idx += 1 COMPILE_FLAGS[v] = flags -COMPILE_FLAGS["OS_CFLAGS"] += ["-O2", "-fno-stack-protector", "-fno-lto"] +COMPILE_FLAGS['OS_CFLAGS'] += ['-O2', '-fno-stack-protector', '-fno-lto'] AllowCompilerWarnings() NoVisibilityFlags() diff --git a/build/unix/elfhack/moz.build b/build/unix/elfhack/moz.build index bb68b3aa4e009f869fd728cbae225b4b74407949..4c12e7e62ee40fb14ae4da1b1ff79a6f4eac94ab 100644 --- a/build/unix/elfhack/moz.build +++ b/build/unix/elfhack/moz.build @@ -5,28 +5,29 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DIST_INSTALL = False -DIRS += ["inject"] +DIRS += ['inject'] -if not CONFIG["CROSS_COMPILE"]: +if not CONFIG['CROSS_COMPILE']: SOURCES += [ - "dummy.c", - "test-array.c", - "test-ctors.c", + 'dummy.c', + 'test-array.c', + 'test-ctors.c', ] - SOURCES["dummy.c"].flags += ["-fno-lto"] - SOURCES["test-array.c"].flags += ["-fno-lto"] - SOURCES["test-ctors.c"].flags += ["-fno-lto"] + SOURCES['dummy.c'].flags += ['-fno-lto'] + SOURCES['test-array.c'].flags += ['-fno-lto'] + SOURCES['test-ctors.c'].flags += ['-fno-lto'] HOST_SOURCES += [ - "elf.cpp", - "elfhack.cpp", + 'elf.cpp', + 'elfhack.cpp', ] -HostProgram("elfhack") +HostProgram('elfhack') NO_PGO = True -COMPILE_FLAGS["OS_CXXFLAGS"] = [ - f for f in COMPILE_FLAGS["OS_CXXFLAGS"] if f != "-fno-exceptions" -] + ["-fexceptions"] +COMPILE_FLAGS['OS_CXXFLAGS'] = [ + f for f in COMPILE_FLAGS['OS_CXXFLAGS'] if f != '-fno-exceptions' +] + ['-fexceptions'] + diff --git a/build/unix/moz.build b/build/unix/moz.build index 3e2a9047a269aad648ff615ff6ce51979823b424..95e5b92ac6c3f9f534ac2a6d424b13cc036542e8 100644 --- a/build/unix/moz.build +++ b/build/unix/moz.build @@ -4,12 +4,12 @@ # 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/. -if CONFIG["MOZ_LIBSTDCXX_TARGET_VERSION"] or CONFIG["MOZ_LIBSTDCXX_HOST_VERSION"]: - DIRS += ["stdc++compat"] +if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION'] or CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']: + DIRS += ['stdc++compat'] -if CONFIG["USE_ELF_HACK"]: - DIRS += ["elfhack"] +if CONFIG['USE_ELF_HACK']: + DIRS += ['elfhack'] FINAL_TARGET_FILES += [ - "run-mozilla.sh", + 'run-mozilla.sh', ] diff --git a/build/unix/rewrite_asan_dylib.py b/build/unix/rewrite_asan_dylib.py index 0bcf31b559ad488f869773324335747b51ae7714..ada15fa690b2dbe985c2ea691c89004c7a751cce 100644 --- a/build/unix/rewrite_asan_dylib.py +++ b/build/unix/rewrite_asan_dylib.py @@ -11,20 +11,19 @@ import subprocess import shutil from buildconfig import substs -""" +''' Scans the given directories for binaries referencing the AddressSanitizer runtime library, copies it to the main directory and rewrites binaries to not reference it with absolute paths but with @executable_path instead. -""" +''' # This is the dylib we're looking for -DYLIB_NAME = "libclang_rt.asan_osx_dynamic.dylib" +DYLIB_NAME = 'libclang_rt.asan_osx_dynamic.dylib' def resolve_rpath(filename): - otoolOut = subprocess.check_output( - [substs["OTOOL"], "-l", filename], universal_newlines=True - ) + otoolOut = subprocess.check_output([substs['OTOOL'], '-l', filename], + universal_newlines=True) currentCmd = None # The lines we need to find look like this: @@ -37,19 +36,19 @@ def resolve_rpath(filename): # ... # Other load command types have a varying number of fields. for line in otoolOut.splitlines(): - cmdMatch = re.match(r"^\s+cmd ([A-Z_]+)", line) + cmdMatch = re.match(r'^\s+cmd ([A-Z_]+)', line) if cmdMatch is not None: currentCmd = cmdMatch.group(1) continue - if currentCmd == "LC_RPATH": - pathMatch = re.match(r"^\s+path (.*) \(offset \d+\)", line) + if currentCmd == 'LC_RPATH': + pathMatch = re.match(r'^\s+path (.*) \(offset \d+\)', line) if pathMatch is not None: path = pathMatch.group(1) if os.path.isdir(path): return path - sys.stderr.write("@rpath could not be resolved from %s\n" % filename) + sys.stderr.write('@rpath could not be resolved from %s\n' % filename) sys.exit(1) @@ -61,13 +60,12 @@ def scan_directory(path): filename = os.path.join(root, filename) # Skip all files that aren't either dylibs or executable - if not (filename.endswith(".dylib") or os.access(filename, os.X_OK)): + if not (filename.endswith('.dylib') or os.access(filename, os.X_OK)): continue try: otoolOut = subprocess.check_output( - [substs["OTOOL"], "-L", filename], universal_newlines=True - ) + [substs['OTOOL'], '-L', filename], universal_newlines=True) except Exception: # Errors are expected on non-mach executables, ignore them and continue continue @@ -77,13 +75,14 @@ def scan_directory(path): absDylibPath = line.split()[0] # Don't try to rewrite binaries twice - if absDylibPath.startswith("@executable_path/"): + if absDylibPath.startswith('@executable_path/'): continue if not dylibCopied: - if absDylibPath.startswith("@rpath/"): + if absDylibPath.startswith('@rpath/'): rpath = resolve_rpath(filename) - copyDylibPath = absDylibPath.replace("@rpath", rpath) + copyDylibPath = absDylibPath.replace( + '@rpath', rpath) else: copyDylibPath = absDylibPath @@ -94,38 +93,28 @@ def scan_directory(path): # Now rewrite the library itself subprocess.check_call( - [ - substs["INSTALL_NAME_TOOL"], - "-id", - "@executable_path/" + DYLIB_NAME, - os.path.join(path, DYLIB_NAME), - ] - ) + [substs['INSTALL_NAME_TOOL'], '-id', + '@executable_path/' + DYLIB_NAME, + os.path.join(path, DYLIB_NAME)]) dylibCopied = True else: - sys.stderr.write( - "dylib path in %s was not found at: %s\n" - % (filename, copyDylibPath) - ) + sys.stderr.write('dylib path in %s was not found at: %s\n' % ( + filename, copyDylibPath)) # Now use install_name_tool to rewrite the path in our binary - relpath = "" if path == root else os.path.relpath(path, root) + "/" - subprocess.check_call( - [ - substs["INSTALL_NAME_TOOL"], - "-change", - absDylibPath, - "@executable_path/" + relpath + DYLIB_NAME, - filename, - ] - ) + relpath = '' if path == root else os.path.relpath( + path, root) + '/' + subprocess.check_call([substs['INSTALL_NAME_TOOL'], '-change', + absDylibPath, + '@executable_path/' + relpath + DYLIB_NAME, + filename]) break if not dylibCopied: - sys.stderr.write("%s could not be found\n" % DYLIB_NAME) + sys.stderr.write('%s could not be found\n' % DYLIB_NAME) sys.exit(1) -if __name__ == "__main__": +if __name__ == '__main__': for d in sys.argv[1:]: scan_directory(d) diff --git a/build/unix/stdc++compat/moz.build b/build/unix/stdc++compat/moz.build index aac8f2b0f591b10bf2ce6425593b5e523f3982d8..4444d0c4f29724341c67a3a9dafb0cd80bd0d78c 100644 --- a/build/unix/stdc++compat/moz.build +++ b/build/unix/stdc++compat/moz.build @@ -4,14 +4,14 @@ # 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/. -if CONFIG["MOZ_LIBSTDCXX_TARGET_VERSION"]: - Library("stdc++compat") - SOURCES += ["stdc++compat.cpp"] +if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION']: + Library('stdc++compat') + SOURCES += ['stdc++compat.cpp'] -if CONFIG["MOZ_LIBSTDCXX_HOST_VERSION"]: - HostLibrary("host_stdc++compat") +if CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']: + HostLibrary('host_stdc++compat') HOST_SOURCES += [ - "stdc++compat.cpp", + 'stdc++compat.cpp', ] FORCE_STATIC_LIB = True @@ -19,9 +19,9 @@ FORCE_STATIC_LIB = True NO_PGO = True DisableStlWrapping() -COMPILE_FLAGS["CLANG_PLUGIN"] = [] +COMPILE_FLAGS['CLANG_PLUGIN'] = [] -DEFINES["MOZ_LIBSTDCXX_VERSION"] = CONFIG["MOZ_LIBSTDCXX_TARGET_VERSION"] -HOST_DEFINES["MOZ_LIBSTDCXX_VERSION"] = CONFIG["MOZ_LIBSTDCXX_HOST_VERSION"] +DEFINES['MOZ_LIBSTDCXX_VERSION'] = CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION'] +HOST_DEFINES['MOZ_LIBSTDCXX_VERSION'] = CONFIG['MOZ_LIBSTDCXX_HOST_VERSION'] -OS_LIBS += ["-Wl,--version-script,%s/hide_std.ld" % SRCDIR] +OS_LIBS += ['-Wl,--version-script,%s/hide_std.ld' % SRCDIR] diff --git a/build/upload.py b/build/upload.py index 4742b284583a4eef6b0d7aed1d4d906f0d1bea10..89de5e6a7aec5c9e7314dd1ad1aeafc9ced82a42 100644 --- a/build/upload.py +++ b/build/upload.py @@ -34,14 +34,14 @@ def FixupMsysPath(path): and commandline arguments into Windows native paths. This sucks if you're trying to pass an absolute path on a remote server. This function attempts to un-mangle such paths.""" - if "OSTYPE" in os.environ and os.environ["OSTYPE"] == "msys": + if 'OSTYPE' in os.environ and os.environ['OSTYPE'] == 'msys': # sort of awful, find out where our shell is (should be in msys/bin) # and strip the first part of that path out of the other path - if "SHELL" in os.environ: - sh = os.environ["SHELL"] - msys = sh[: sh.find("/bin")] + if 'SHELL' in os.environ: + sh = os.environ['SHELL'] + msys = sh[:sh.find('/bin')] if path.startswith(msys): - path = path[len(msys) :] + path = path[len(msys):] return path @@ -55,7 +55,7 @@ def GetBaseRelativePath(path, local_file, base_path): dir = os.path.dirname(local_file) # strip base_path + extra slash and make it unixy - dir = dir[len(base_path) + 1 :].replace("\\", "/") + dir = dir[len(base_path) + 1:].replace('\\', '/') return path + dir @@ -79,28 +79,26 @@ def CopyFilesLocally(path, files, verbose=False, base_path=None): shutil.copy(file, target_path) -if __name__ == "__main__": - path = OptionalEnvironmentVariable("UPLOAD_PATH") +if __name__ == '__main__': + path = OptionalEnvironmentVariable('UPLOAD_PATH') - if sys.platform == "win32": + if sys.platform == 'win32': if path is not None: path = FixupMsysPath(path) parser = OptionParser(usage="usage: %prog [options] ") - parser.add_option( - "-b", - "--base-path", - action="store", - help="Preserve file paths relative to this path when uploading. " - "If unset, all files will be uploaded directly to UPLOAD_PATH.", - ) + parser.add_option("-b", "--base-path", + action="store", + help="Preserve file paths relative to this path when uploading. " + "If unset, all files will be uploaded directly to UPLOAD_PATH.") (options, args) = parser.parse_args() if len(args) < 1: print("You must specify at least one file to upload") sys.exit(1) try: - CopyFilesLocally(path, args, base_path=options.base_path, verbose=True) + CopyFilesLocally(path, args, base_path=options.base_path, + verbose=True) except IOError as strerror: print(strerror) sys.exit(1) diff --git a/build/upload_generated_sources.py b/build/upload_generated_sources.py index 4a528b106eb5f037a396c3a3e191b81c9e0c47f8..0b5768cdf8d9c50a94b627c9b8cc1983118c9060 100644 --- a/build/upload_generated_sources.py +++ b/build/upload_generated_sources.py @@ -26,30 +26,29 @@ import time # Arbitrary, should probably measure this. NUM_WORKER_THREADS = 10 -log = logging.getLogger("upload-generated-sources") +log = logging.getLogger('upload-generated-sources') log.setLevel(logging.INFO) @contextmanager def timed(): - """ + ''' Yield a function that provides the elapsed time in seconds since this function was called. - """ + ''' start = time.time() def elapsed(): return time.time() - start - yield elapsed def gzip_compress(data): - """ + ''' Apply gzip compression to `data` and return the result as a `BytesIO`. - """ + ''' b = io.BytesIO() - with gzip.GzipFile(fileobj=b, mode="w") as f: + with gzip.GzipFile(fileobj=b, mode='w') as f: f.write(data) b.flush() b.seek(0) @@ -57,17 +56,16 @@ def gzip_compress(data): def upload_worker(queue, event, bucket, session_args): - """ + ''' Get `(name, contents)` entries from `queue` and upload `contents` to S3 with gzip compression using `name` as the key, prefixed with the SHA-512 digest of `contents` as a hex string. If an exception occurs, set `event`. - """ + ''' try: import boto3 - session = boto3.session.Session(**session_args) - s3 = session.client("s3") + s3 = session.client('s3') while True: if event.is_set(): # Some other thread hit an exception. @@ -76,68 +74,63 @@ def upload_worker(queue, event, bucket, session_args): pathname = get_filename_with_digest(name, contents) compressed = gzip_compress(contents) extra_args = { - "ContentEncoding": "gzip", - "ContentType": "text/plain", + 'ContentEncoding': 'gzip', + 'ContentType': 'text/plain', } - log.info( - 'Uploading "{}" ({} bytes)'.format(pathname, len(compressed.getvalue())) - ) + log.info('Uploading "{}" ({} bytes)'.format( + pathname, len(compressed.getvalue()))) with timed() as elapsed: - s3.upload_fileobj(compressed, bucket, pathname, ExtraArgs=extra_args) - log.info( - 'Finished uploading "{}" in {:0.3f}s'.format(pathname, elapsed()) - ) + s3.upload_fileobj(compressed, bucket, + pathname, ExtraArgs=extra_args) + log.info('Finished uploading "{}" in {:0.3f}s'.format( + pathname, elapsed())) queue.task_done() except Exception: - log.exception("Thread encountered exception:") + log.exception('Thread encountered exception:') event.set() def do_work(artifact, region, bucket): - session_args = {"region_name": region} + session_args = {'region_name': region} session = requests.Session() - retry = Retry(total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504]) + retry = Retry(total=5, backoff_factor=0.1, + status_forcelist=[500, 502, 503, 504]) http_adapter = requests.adapters.HTTPAdapter(max_retries=retry) - session.mount("https://", http_adapter) - session.mount("http://", http_adapter) + session.mount('https://', http_adapter) + session.mount('http://', http_adapter) - if "TASK_ID" in os.environ: - level = os.environ.get("MOZ_SCM_LEVEL", "1") - secrets_url = "http://taskcluster/secrets/v1/secret/project/releng/gecko/build/level-{}/gecko-generated-sources-upload".format( # noqa - level - ) + if 'TASK_ID' in os.environ: + level = os.environ.get('MOZ_SCM_LEVEL', '1') + secrets_url = 'http://taskcluster/secrets/v1/secret/project/releng/gecko/build/level-{}/gecko-generated-sources-upload'.format( # noqa + level) log.info( - 'Using AWS credentials from the secrets service: "{}"'.format(secrets_url) - ) + 'Using AWS credentials from the secrets service: "{}"'.format(secrets_url)) res = session.get(secrets_url) res.raise_for_status() secret = res.json() session_args.update( - aws_access_key_id=secret["secret"]["AWS_ACCESS_KEY_ID"], - aws_secret_access_key=secret["secret"]["AWS_SECRET_ACCESS_KEY"], + aws_access_key_id=secret['secret']['AWS_ACCESS_KEY_ID'], + aws_secret_access_key=secret['secret']['AWS_SECRET_ACCESS_KEY'], ) else: - log.info("Trying to use your AWS credentials..") + log.info('Trying to use your AWS credentials..') # First, fetch the artifact containing the sources. log.info('Fetching generated sources artifact: "{}"'.format(artifact)) with timed() as elapsed: res = session.get(artifact) - log.info( - "Fetch HTTP status: {}, {} bytes downloaded in {:0.3f}s".format( - res.status_code, len(res.content), elapsed() - ) - ) + log.info('Fetch HTTP status: {}, {} bytes downloaded in {:0.3f}s'.format( + res.status_code, len(res.content), elapsed())) res.raise_for_status() # Create a queue and worker threads for uploading. q = Queue() event = Event() - log.info("Creating {} worker threads".format(NUM_WORKER_THREADS)) + log.info('Creating {} worker threads'.format(NUM_WORKER_THREADS)) for i in range(NUM_WORKER_THREADS): t = Thread(target=upload_worker, args=(q, event, bucket, session_args)) t.daemon = True t.start() - with tarfile.open(fileobj=io.BytesIO(res.content), mode="r|gz") as tar: + with tarfile.open(fileobj=io.BytesIO(res.content), mode='r|gz') as tar: # Next, process each file. for entry in tar: if event.is_set(): @@ -148,28 +141,28 @@ def do_work(artifact, region, bucket): # We don't use q.join() here because we want to also monitor event. while q.unfinished_tasks: if event.wait(0.1): - log.error("Worker thread encountered exception, exiting...") + log.error('Worker thread encountered exception, exiting...') break def main(argv): - logging.basicConfig(format="%(levelname)s - %(threadName)s - %(message)s") + logging.basicConfig(format='%(levelname)s - %(threadName)s - %(message)s') parser = argparse.ArgumentParser( - description="Upload generated source files in ARTIFACT to BUCKET in S3." - ) - parser.add_argument("artifact", help="generated-sources artifact from build task") + description='Upload generated source files in ARTIFACT to BUCKET in S3.') + parser.add_argument('artifact', + help='generated-sources artifact from build task') args = parser.parse_args(argv) region, bucket = get_s3_region_and_bucket() config = MozbuildObject.from_environment() config.activate_virtualenv() - config.virtualenv_manager.install_pip_package("boto3==1.4.4") + config.virtualenv_manager.install_pip_package('boto3==1.4.4') with timed() as elapsed: do_work(region=region, bucket=bucket, artifact=args.artifact) - log.info("Finished in {:.03f}s".format(elapsed())) + log.info('Finished in {:.03f}s'.format(elapsed())) return 0 -if __name__ == "__main__": +if __name__ == '__main__': sys.exit(main(sys.argv[1:])) diff --git a/build/valgrind/mach_commands.py b/build/valgrind/mach_commands.py index 408c0be28c14fabc7f6948353d563fe63971cfa4..26801bc41c53c239f3fb5b450cbf318d3dc9d3d0 100644 --- a/build/valgrind/mach_commands.py +++ b/build/valgrind/mach_commands.py @@ -22,32 +22,24 @@ from mozbuild.base import ( def is_valgrind_build(cls): - """Must be a build with --enable-valgrind and --disable-jemalloc.""" + '''Must be a build with --enable-valgrind and --disable-jemalloc.''' defines = cls.config_environment.defines - return "MOZ_VALGRIND" in defines and "MOZ_MEMORY" not in defines + return 'MOZ_VALGRIND' in defines and 'MOZ_MEMORY' not in defines @CommandProvider class MachCommands(MachCommandBase): - """ + ''' Run Valgrind tests. - """ - - @Command( - "valgrind-test", - category="testing", - conditions=[conditions.is_firefox_or_thunderbird, is_valgrind_build], - description="Run the Valgrind test job (memory-related errors).", - ) - @CommandArgument( - "--suppressions", - default=[], - action="append", - metavar="FILENAME", - help="Specify a suppression file for Valgrind to use. Use " - "--suppression multiple times to specify multiple suppression " - "files.", - ) + ''' + @Command('valgrind-test', category='testing', + conditions=[conditions.is_firefox_or_thunderbird, is_valgrind_build], + description='Run the Valgrind test job (memory-related errors).') + @CommandArgument('--suppressions', default=[], action='append', + metavar='FILENAME', + help='Specify a suppression file for Valgrind to use. Use ' + '--suppression multiple times to specify multiple suppression ' + 'files.') def valgrind_test(self, suppressions): from mozfile import TemporaryDirectory @@ -59,29 +51,28 @@ class MachCommands(MachCommandBase): from six import string_types from valgrind.output_handler import OutputHandler - build_dir = os.path.join(self.topsrcdir, "build") + build_dir = os.path.join(self.topsrcdir, 'build') # XXX: currently we just use the PGO inputs for Valgrind runs. This may # change in the future. - httpd = MozHttpd(docroot=os.path.join(build_dir, "pgo")) + httpd = MozHttpd(docroot=os.path.join(build_dir, 'pgo')) httpd.start(block=False) with TemporaryDirectory() as profilePath: # TODO: refactor this into mozprofile - profile_data_dir = os.path.join(self.topsrcdir, "testing", "profiles") - with open(os.path.join(profile_data_dir, "profiles.json"), "r") as fh: - base_profiles = json.load(fh)["valgrind"] + profile_data_dir = os.path.join( + self.topsrcdir, 'testing', 'profiles') + with open(os.path.join(profile_data_dir, 'profiles.json'), 'r') as fh: + base_profiles = json.load(fh)['valgrind'] - prefpaths = [ - os.path.join(profile_data_dir, profile, "user.js") - for profile in base_profiles - ] + prefpaths = [os.path.join(profile_data_dir, profile, 'user.js') + for profile in base_profiles] prefs = {} for path in prefpaths: prefs.update(Preferences.read_prefs(path)) interpolation = { - "server": "%s:%d" % httpd.httpd.server_address, + 'server': '%s:%d' % httpd.httpd.server_address, } for k, v in prefs.items(): if isinstance(v, string_types): @@ -89,93 +80,88 @@ class MachCommands(MachCommandBase): prefs[k] = Preferences.cast(v) quitter = os.path.join( - self.topsrcdir, "tools", "quitter", "quitter@mozilla.org.xpi" - ) + self.topsrcdir, 'tools', 'quitter', 'quitter@mozilla.org.xpi') locations = ServerLocations() - locations.add_host( - host="127.0.0.1", port=httpd.httpd.server_port, options="primary" - ) + locations.add_host(host='127.0.0.1', + port=httpd.httpd.server_port, + options='primary') - profile = FirefoxProfile( - profile=profilePath, - preferences=prefs, - addons=[quitter], - locations=locations, - ) + profile = FirefoxProfile(profile=profilePath, + preferences=prefs, + addons=[quitter], + locations=locations) firefox_args = [httpd.get_url()] env = os.environ.copy() - env["G_SLICE"] = "always-malloc" - env["MOZ_CC_RUN_DURING_SHUTDOWN"] = "1" - env["MOZ_CRASHREPORTER_NO_REPORT"] = "1" - env["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "1" - env["XPCOM_DEBUG_BREAK"] = "warn" + env['G_SLICE'] = 'always-malloc' + env['MOZ_CC_RUN_DURING_SHUTDOWN'] = '1' + env['MOZ_CRASHREPORTER_NO_REPORT'] = '1' + env['MOZ_DISABLE_NONLOCAL_CONNECTIONS'] = '1' + env['XPCOM_DEBUG_BREAK'] = 'warn' outputHandler = OutputHandler(self.log) kp_kwargs = { - "processOutputLine": [outputHandler], - "universal_newlines": True, + 'processOutputLine': [outputHandler], + 'universal_newlines': True, } - valgrind = "valgrind" + valgrind = 'valgrind' if not os.path.exists(valgrind): valgrind = findInPath(valgrind) valgrind_args = [ valgrind, - "--sym-offsets=yes", - "--smc-check=all-non-file", - "--vex-iropt-register-updates=allregs-at-mem-access", - "--gen-suppressions=all", - "--num-callers=36", - "--leak-check=full", - "--show-possibly-lost=no", - "--track-origins=yes", - "--trace-children=yes", - "-v", # Enable verbosity to get the list of used suppressions + '--sym-offsets=yes', + '--smc-check=all-non-file', + '--vex-iropt-register-updates=allregs-at-mem-access', + '--gen-suppressions=all', + '--num-callers=36', + '--leak-check=full', + '--show-possibly-lost=no', + '--track-origins=yes', + '--trace-children=yes', + '-v', # Enable verbosity to get the list of used suppressions # Avoid excessive delays in the presence of spinlocks. # See bug 1309851. - "--fair-sched=yes", + '--fair-sched=yes', # Keep debuginfo after library unmap. See bug 1382280. - "--keep-debuginfo=yes", + '--keep-debuginfo=yes', # Reduce noise level on rustc and/or LLVM compiled code. # See bug 1365915 - "--expensive-definedness-checks=yes", + '--expensive-definedness-checks=yes', # Compensate for the compiler inlining `new` but not `delete` # or vice versa. - "--show-mismatched-frees=no", + '--show-mismatched-frees=no', ] for s in suppressions: - valgrind_args.append("--suppressions=" + s) + valgrind_args.append('--suppressions=' + s) - supps_dir = os.path.join(build_dir, "valgrind") - supps_file1 = os.path.join(supps_dir, "cross-architecture.sup") - valgrind_args.append("--suppressions=" + supps_file1) + supps_dir = os.path.join(build_dir, 'valgrind') + supps_file1 = os.path.join(supps_dir, 'cross-architecture.sup') + valgrind_args.append('--suppressions=' + supps_file1) - if mozinfo.os == "linux": + if mozinfo.os == 'linux': machtype = { - "x86_64": "x86_64-pc-linux-gnu", - "x86": "i386-pc-linux-gnu", + 'x86_64': 'x86_64-pc-linux-gnu', + 'x86': 'i386-pc-linux-gnu', }.get(mozinfo.processor) if machtype: - supps_file2 = os.path.join(supps_dir, machtype + ".sup") + supps_file2 = os.path.join(supps_dir, machtype + '.sup') if os.path.isfile(supps_file2): - valgrind_args.append("--suppressions=" + supps_file2) + valgrind_args.append('--suppressions=' + supps_file2) exitcode = None timeout = 1800 binary_not_found_exception = None try: - runner = FirefoxRunner( - profile=profile, - binary=self.get_binary_path(), - cmdargs=firefox_args, - env=env, - process_args=kp_kwargs, - ) + runner = FirefoxRunner(profile=profile, + binary=self.get_binary_path(), + cmdargs=firefox_args, + env=env, + process_args=kp_kwargs) runner.start(debug_args=valgrind_args) exitcode = runner.wait(timeout=timeout) except BinaryNotFoundException as e: @@ -185,58 +171,39 @@ class MachCommands(MachCommandBase): supps = outputHandler.suppression_count if errs != supps: status = 1 # turns the TBPL job orange - self.log( - logging.ERROR, - "valgrind-fail-parsing", - {"errs": errs, "supps": supps}, - "TEST-UNEXPECTED-FAIL | valgrind-test | error parsing: {errs} errors " - "seen, but {supps} generated suppressions seen", - ) + self.log(logging.ERROR, 'valgrind-fail-parsing', + {'errs': errs, 'supps': supps}, + 'TEST-UNEXPECTED-FAIL | valgrind-test | error parsing: {errs} errors ' + 'seen, but {supps} generated suppressions seen') elif errs == 0: status = 0 - self.log( - logging.INFO, - "valgrind-pass", - {}, - "TEST-PASS | valgrind-test | valgrind found no errors", - ) + self.log(logging.INFO, 'valgrind-pass', {}, + 'TEST-PASS | valgrind-test | valgrind found no errors') else: status = 1 # turns the TBPL job orange # We've already printed details of the errors. if binary_not_found_exception: status = 2 # turns the TBPL job red - self.log( - logging.ERROR, - "valgrind-fail-errors", - {"error": str(binary_not_found_exception)}, - "TEST-UNEXPECTED-FAIL | valgrind-test | {error}", - ) - self.log( - logging.INFO, - "valgrind-fail-errors", - {"help": binary_not_found_exception.help()}, - "{help}", - ) + self.log(logging.ERROR, 'valgrind-fail-errors', + {'error': str(binary_not_found_exception)}, + 'TEST-UNEXPECTED-FAIL | valgrind-test | {error}') + self.log(logging.INFO, 'valgrind-fail-errors', + {'help': binary_not_found_exception.help()}, + '{help}') elif exitcode is None: status = 2 # turns the TBPL job red - self.log( - logging.ERROR, - "valgrind-fail-timeout", - {"timeout": timeout}, - "TEST-UNEXPECTED-FAIL | valgrind-test | Valgrind timed out " - "(reached {timeout} second limit)", - ) + self.log(logging.ERROR, 'valgrind-fail-timeout', + {'timeout': timeout}, + 'TEST-UNEXPECTED-FAIL | valgrind-test | Valgrind timed out ' + '(reached {timeout} second limit)') elif exitcode != 0: status = 2 # turns the TBPL job red - self.log( - logging.ERROR, - "valgrind-fail-errors", - {"exitcode": exitcode}, - "TEST-UNEXPECTED-FAIL | valgrind-test | non-zero exit code " - "from Valgrind: {exitcode}", - ) + self.log(logging.ERROR, 'valgrind-fail-errors', + {'exitcode': exitcode}, + 'TEST-UNEXPECTED-FAIL | valgrind-test | non-zero exit code ' + 'from Valgrind: {exitcode}') httpd.stop() diff --git a/build/valgrind/output_handler.py b/build/valgrind/output_handler.py index d3a84d3444341853b9c57b701dc1cab5406d98be..9557bb534391c1d5fb1f259d807f4ba64ed8bf2c 100644 --- a/build/valgrind/output_handler.py +++ b/build/valgrind/output_handler.py @@ -9,7 +9,7 @@ import re class OutputHandler(object): - """ + ''' A class for handling Valgrind output. Valgrind errors look like this: @@ -38,32 +38,31 @@ class OutputHandler(object): the count of these lines doesn't match the error count found during parsing, then the parsing has missed one or more errors and we can fail appropriately. - """ # NOQA: E501 + ''' # NOQA: E501 def __init__(self, logger): # The regexps in this list match all of Valgrind's errors. Note that # Valgrind is English-only, so we don't have to worry about # localization. self.logger = logger - self.re_error = ( - r"==\d+== (" - + r"(Use of uninitialised value of size \d+)|" - + r"(Conditional jump or move depends on uninitialised value\(s\))|" - + r"(Syscall param .* contains uninitialised byte\(s\))|" - + r"(Syscall param .* points to (unaddressable|uninitialised) byte\(s\))|" - + r"((Unaddressable|Uninitialised) byte\(s\) found during client check request)|" - + r"(Invalid free\(\) / delete / delete\[\] / realloc\(\))|" - + r"(Mismatched free\(\) / delete / delete \[\])|" - + r"(Invalid (read|write) of size \d+)|" - + r"(Jump to the invalid address stated on the next line)|" - + r"(Source and destination overlap in .*)|" - + r"(.* bytes in .* blocks are .* lost)" - + r")" - ) + self.re_error = \ + r'==\d+== (' + \ + r'(Use of uninitialised value of size \d+)|' + \ + r'(Conditional jump or move depends on uninitialised value\(s\))|' + \ + r'(Syscall param .* contains uninitialised byte\(s\))|' + \ + r'(Syscall param .* points to (unaddressable|uninitialised) byte\(s\))|' + \ + r'((Unaddressable|Uninitialised) byte\(s\) found during client check request)|' + \ + r'(Invalid free\(\) / delete / delete\[\] / realloc\(\))|' + \ + r'(Mismatched free\(\) / delete / delete \[\])|' + \ + r'(Invalid (read|write) of size \d+)|' + \ + r'(Jump to the invalid address stated on the next line)|' + \ + r'(Source and destination overlap in .*)|' + \ + r'(.* bytes in .* blocks are .* lost)' + \ + r')' # Match identifer chars, plus ':' for namespaces, and '\?' in order to # match "???" which Valgrind sometimes produces. - self.re_stack_entry = r"^==\d+==.*0x[A-Z0-9]+: ([A-Za-z0-9_:\?]+)" - self.re_suppression = r" *" + self.re_stack_entry = r'^==\d+==.*0x[A-Z0-9]+: ([A-Za-z0-9_:\?]+)' + self.re_suppression = r' *' self.error_count = 0 self.suppression_count = 0 self.number_of_stack_entries_to_get = 0 @@ -72,7 +71,7 @@ class OutputHandler(object): self.buffered_lines = None def log(self, line): - self.logger(logging.INFO, "valgrind-output", {"line": line}, "{line}") + self.logger(logging.INFO, 'valgrind-output', {'line': line}, '{line}') def __call__(self, line): if self.number_of_stack_entries_to_get == 0: @@ -95,20 +94,18 @@ class OutputHandler(object): if m: self.curr_location += m.group(1) else: - self.curr_location += "?!?" + self.curr_location += '?!?' self.number_of_stack_entries_to_get -= 1 if self.number_of_stack_entries_to_get != 0: - self.curr_location += " / " + self.curr_location += ' / ' else: # We've finished getting the first few stack entries. Print the # failure message and the buffered lines, and then reset state. - self.logger( - logging.ERROR, - "valgrind-error-msg", - {"error": self.curr_error, "location": self.curr_location}, - "TEST-UNEXPECTED-FAIL | valgrind-test | {error} at {location}", - ) + self.logger(logging.ERROR, 'valgrind-error-msg', + {'error': self.curr_error, + 'location': self.curr_location}, + 'TEST-UNEXPECTED-FAIL | valgrind-test | {error} at {location}') for b in self.buffered_lines: self.log(b) self.curr_error = None diff --git a/build/variables.py b/build/variables.py index ef2d6e6800f3c5a09585f52990c827c91c28e652..01ae2f0d8bc28606d47252b8b4673682af1b0a2f 100644 --- a/build/variables.py +++ b/build/variables.py @@ -9,36 +9,35 @@ import subprocess import sys from datetime import datetime -SOURCESTAMP_FILENAME = "sourcestamp.txt" +SOURCESTAMP_FILENAME = 'sourcestamp.txt' def buildid_header(output): - buildid = os.environ.get("MOZ_BUILD_DATE") + buildid = os.environ.get('MOZ_BUILD_DATE') if buildid and len(buildid) != 14: - print("Ignoring invalid MOZ_BUILD_DATE: %s" % buildid, file=sys.stderr) + print('Ignoring invalid MOZ_BUILD_DATE: %s' % buildid, file=sys.stderr) buildid = None if not buildid: - buildid = datetime.now().strftime("%Y%m%d%H%M%S") + buildid = datetime.now().strftime('%Y%m%d%H%M%S') output.write("#define MOZ_BUILDID %s\n" % buildid) def get_program_output(*command): try: with open(os.devnull) as stderr: - return subprocess.check_output( - command, stderr=stderr, universal_newlines=True - ) + return subprocess.check_output(command, stderr=stderr, + universal_newlines=True) except Exception: - return "" + return '' def get_hg_info(workdir): - repo = get_program_output("hg", "-R", workdir, "path", "default") + repo = get_program_output('hg', '-R', workdir, 'path', 'default') if repo: repo = repo.strip() - if repo.startswith("ssh://"): - repo = "https://" + repo[6:] - repo = repo.rstrip("/") + if repo.startswith('ssh://'): + repo = 'https://' + repo[6:] + repo = repo.rstrip('/') changeset = get_hg_changeset(workdir) @@ -46,7 +45,7 @@ def get_hg_info(workdir): def get_hg_changeset(path): - return get_program_output("hg", "-R", path, "parent", "--template={node}") + return get_program_output('hg', '-R', path, 'parent', '--template={node}') def get_info_from_sourcestamp(sourcestamp_path): @@ -63,51 +62,50 @@ def get_info_from_sourcestamp(sourcestamp_path): # Parse the repo and the changeset. The sourcestamp file is supposed to # contain two lines: the first is the build id and the second is the source # URL. - if len(lines) != 2 or not lines[1].startswith("http"): + if len(lines) != 2 or not lines[1].startswith('http'): # Just return if the file doesn't contain what we expect. return None, None # Return the repo and the changeset. - return lines[1].split("/rev/") + return lines[1].split('/rev/') def source_repo_header(output): # We allow the source repo and changeset to be specified via the # environment (see configure) import buildconfig - - repo = buildconfig.substs.get("MOZ_SOURCE_REPO") - changeset = buildconfig.substs.get("MOZ_SOURCE_CHANGESET") - source = "" + repo = buildconfig.substs.get('MOZ_SOURCE_REPO') + changeset = buildconfig.substs.get('MOZ_SOURCE_CHANGESET') + source = '' if not repo: - sourcestamp_path = os.path.join(buildconfig.topsrcdir, SOURCESTAMP_FILENAME) - if os.path.exists(os.path.join(buildconfig.topsrcdir, ".hg")): + sourcestamp_path = os.path.join( + buildconfig.topsrcdir, SOURCESTAMP_FILENAME) + if os.path.exists(os.path.join(buildconfig.topsrcdir, '.hg')): repo, changeset = get_hg_info(buildconfig.topsrcdir) elif os.path.exists(sourcestamp_path): repo, changeset = get_info_from_sourcestamp(sourcestamp_path) elif not changeset: changeset = get_hg_changeset(buildconfig.topsrcdir) if not changeset: - raise Exception( - "could not resolve changeset; " "try setting MOZ_SOURCE_CHANGESET" - ) + raise Exception('could not resolve changeset; ' + 'try setting MOZ_SOURCE_CHANGESET') if changeset: - output.write("#define MOZ_SOURCE_STAMP %s\n" % changeset) + output.write('#define MOZ_SOURCE_STAMP %s\n' % changeset) - if repo and buildconfig.substs.get("MOZ_INCLUDE_SOURCE_INFO"): - source = "%s/rev/%s" % (repo, changeset) - output.write("#define MOZ_SOURCE_REPO %s\n" % repo) - output.write("#define MOZ_SOURCE_URL %s\n" % source) + if repo and buildconfig.substs.get('MOZ_INCLUDE_SOURCE_INFO'): + source = '%s/rev/%s' % (repo, changeset) + output.write('#define MOZ_SOURCE_REPO %s\n' % repo) + output.write('#define MOZ_SOURCE_URL %s\n' % source) def main(args): - if len(args): + if (len(args)): func = globals().get(args[0]) if func: return func(sys.stdout, *args[1:]) -if __name__ == "__main__": +if __name__ == '__main__': sys.exit(main(sys.argv[1:])) diff --git a/build/win32/autowinchecksec.py b/build/win32/autowinchecksec.py index 1a394977dc140a69a27e3d18611031b6eb4e420c..80ed2e218d9b1401b7f08bc0c5cc297e483009b3 100644 --- a/build/win32/autowinchecksec.py +++ b/build/win32/autowinchecksec.py @@ -22,63 +22,56 @@ binary_path = sys.argv[1] # execute winchecksec against the binary, using the WINCHECKSEC environment # variable as the path to winchecksec.exe try: - winchecksec_path = buildconfig.substs["WINCHECKSEC"] + winchecksec_path = buildconfig.substs['WINCHECKSEC'] except KeyError: - print( - "TEST-UNEXPECTED-FAIL | autowinchecksec.py | WINCHECKSEC environment variable is " - "not set, can't check DEP/ASLR etc. status." - ) + print("TEST-UNEXPECTED-FAIL | autowinchecksec.py | WINCHECKSEC environment variable is " + "not set, can't check DEP/ASLR etc. status.") sys.exit(1) -wine = buildconfig.substs.get("WINE") -if wine and winchecksec_path.lower().endswith(".exe"): +wine = buildconfig.substs.get('WINE') +if wine and winchecksec_path.lower().endswith('.exe'): cmd = [wine, winchecksec_path] else: cmd = [winchecksec_path] try: - result = subprocess.check_output(cmd + ["-j", binary_path], universal_newlines=True) + result = subprocess.check_output(cmd + ['-j', binary_path], + universal_newlines=True) except subprocess.CalledProcessError as e: - print( - "TEST-UNEXPECTED-FAIL | autowinchecksec.py | Winchecksec returned error code %d:\n%s" - % (e.returncode, e.output) - ) + print("TEST-UNEXPECTED-FAIL | autowinchecksec.py | Winchecksec returned error code %d:\n%s" % ( + e.returncode, e.output)) sys.exit(1) result = json.loads(result) checks = [ - "aslr", - "cfg", - "dynamicBase", - "gs", - "isolation", - "nx", - "seh", + 'aslr', + 'cfg', + 'dynamicBase', + 'gs', + 'isolation', + 'nx', + 'seh', ] -if buildconfig.substs["CPU_ARCH"] == "x86": +if buildconfig.substs['CPU_ARCH'] == 'x86': checks += [ - "safeSEH", + 'safeSEH', ] else: checks += [ - "highEntropyVA", + 'highEntropyVA', ] failed = [c for c in checks if result.get(c) is False] if failed: - print( - "TEST-UNEXPECTED-FAIL | autowinchecksec.py | Winchecksec reported %d error(s) for %s" - % (len(failed), binary_path) - ) - print( - "TEST-UNEXPECTED-FAIL | autowinchecksec.py | The following check(s) failed: %s" - % (", ".join(failed)) - ) + print("TEST-UNEXPECTED-FAIL | autowinchecksec.py | Winchecksec reported %d error(s) for %s" % + (len(failed), binary_path)) + print("TEST-UNEXPECTED-FAIL | autowinchecksec.py | The following check(s) failed: %s" % + (', '.join(failed))) sys.exit(1) else: print("TEST-PASS | autowinchecksec.py | %s succeeded" % binary_path) diff --git a/build/win32/crashinjectdll/moz.build b/build/win32/crashinjectdll/moz.build index ff113f61e6c104f633a8943e1095587313972680..270b88ec07f602c521b52221b03c36cdb97415ca 100644 --- a/build/win32/crashinjectdll/moz.build +++ b/build/win32/crashinjectdll/moz.build @@ -5,12 +5,12 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. SOURCES += [ - "crashinjectdll.cpp", + 'crashinjectdll.cpp', ] -SharedLibrary("crashinjectdll") +SharedLibrary('crashinjectdll') -DEFFILE = "crashinjectdll.def" +DEFFILE = 'crashinjectdll.def' USE_STATIC_LIBS = True NO_PGO = True diff --git a/build/win32/moz.build b/build/win32/moz.build index 7f4e378573a5a4aa1c41316a1d0cfc2de869fe57..853d6f03c082234c51712ee8dba82638bfd50bf3 100644 --- a/build/win32/moz.build +++ b/build/win32/moz.build @@ -4,35 +4,41 @@ # 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/. -TEST_DIRS += ["crashinjectdll"] +TEST_DIRS += ['crashinjectdll'] -if CONFIG["ENABLE_TESTS"]: - Program("crashinject") +if CONFIG['ENABLE_TESTS']: + Program('crashinject') SOURCES += [ - "crashinject.cpp", + 'crashinject.cpp', ] USE_STATIC_LIBS = True NO_PGO = True -if CONFIG["WIN32_REDIST_DIR"] and CONFIG["COMPILE_ENVIRONMENT"]: - for f in ["MSVC_C_RUNTIME_DLL", "MSVC_CXX_RUNTIME_DLL"]: - FINAL_TARGET_FILES += ["%%%s/%s" % (CONFIG["WIN32_REDIST_DIR"], CONFIG[f])] +if CONFIG['WIN32_REDIST_DIR'] and CONFIG['COMPILE_ENVIRONMENT']: + for f in ['MSVC_C_RUNTIME_DLL', 'MSVC_CXX_RUNTIME_DLL']: + FINAL_TARGET_FILES += [ + '%%%s/%s' % (CONFIG['WIN32_REDIST_DIR'], CONFIG[f]) + ] -if CONFIG["WIN_UCRT_REDIST_DIR"] and CONFIG["COMPILE_ENVIRONMENT"]: +if CONFIG['WIN_UCRT_REDIST_DIR'] and CONFIG['COMPILE_ENVIRONMENT']: win7_ucrt_redists = [ - "api-ms-win-core-file-l1-2-0.dll", - "api-ms-win-core-file-l2-1-0.dll", - "api-ms-win-core-localization-l1-2-0.dll", - "api-ms-win-core-processthreads-l1-1-1.dll", - "api-ms-win-core-synch-l1-2-0.dll", - "api-ms-win-core-timezone-l1-1-0.dll", - "api-ms-win-crt-*.dll", - "ucrtbase.dll", + 'api-ms-win-core-file-l1-2-0.dll', + 'api-ms-win-core-file-l2-1-0.dll', + 'api-ms-win-core-localization-l1-2-0.dll', + 'api-ms-win-core-processthreads-l1-1-1.dll', + 'api-ms-win-core-synch-l1-2-0.dll', + 'api-ms-win-core-timezone-l1-1-0.dll', + 'api-ms-win-crt-*.dll', + 'ucrtbase.dll', ] for f in win7_ucrt_redists: - FINAL_TARGET_FILES += ["%%%s/%s" % (CONFIG["WIN_UCRT_REDIST_DIR"], f)] + FINAL_TARGET_FILES += [ + '%%%s/%s' % (CONFIG['WIN_UCRT_REDIST_DIR'], f) + ] -if CONFIG["LLVM_SYMBOLIZER"] and CONFIG["WIN_DIA_SDK_BIN_DIR"]: +if CONFIG['LLVM_SYMBOLIZER'] and CONFIG['WIN_DIA_SDK_BIN_DIR']: # On Windows, llvm-symbolizer depends on the MS DIA library. - FINAL_TARGET_FILES += ["%%%s/msdia140.dll" % CONFIG["WIN_DIA_SDK_BIN_DIR"]] + FINAL_TARGET_FILES += [ + '%%%s/msdia140.dll' % CONFIG['WIN_DIA_SDK_BIN_DIR'] + ] diff --git a/build/windows_toolchain.py b/build/windows_toolchain.py index dab661042d2ba4beb548e7fa118d8c4b311bb9f9..98a2b9fc2543b84d88f6b1daf472b62bbc444a76 100644 --- a/build/windows_toolchain.py +++ b/build/windows_toolchain.py @@ -16,126 +16,134 @@ import hashlib import os import sys -from mozpack.files import FileFinder -from mozpack.mozjar import JarWriter +from mozpack.files import ( + FileFinder, +) +from mozpack.mozjar import ( + JarWriter, +) import mozpack.path as mozpath -SDK_RELEASE = "10.0.17134.0" +SDK_RELEASE = '10.0.17134.0' PATTERNS = [ { - "srcdir": "%(vs_path)s/DIA SDK", - "dstdir": "DIA SDK", - "files": [ + 'srcdir': '%(vs_path)s/DIA SDK', + 'dstdir': 'DIA SDK', + 'files': [ { - "pattern": "bin/**", - "ignore": ("bin/arm/**",), + 'pattern': 'bin/**', + 'ignore': ( + 'bin/arm/**', + ), }, { - "pattern": "idl/**", + 'pattern': 'idl/**', }, { - "pattern": "include/**", + 'pattern': 'include/**', }, { - "pattern": "lib/**", - "ignore": ("lib/arm/**",), + 'pattern': 'lib/**', + 'ignore': ( + 'lib/arm/**', + ), }, ], }, { - "srcdir": "%(vs_path)s/VC/Tools/MSVC/14.16.27023", - "dstdir": "VC", - "files": [ + 'srcdir': '%(vs_path)s/VC/Tools/MSVC/14.16.27023', + 'dstdir': 'VC', + 'files': [ # ATL is needed by Breakpad. { - "pattern": "atlmfc/include/**", + 'pattern': 'atlmfc/include/**', }, { - "pattern": "atlmfc/lib/arm64/atls.*", + 'pattern': 'atlmfc/lib/arm64/atls.*', }, { - "pattern": "atlmfc/lib/x64/atls.*", + 'pattern': 'atlmfc/lib/x64/atls.*', }, { - "pattern": "atlmfc/lib/x86/atls.*", + 'pattern': 'atlmfc/lib/x86/atls.*', }, # ARM64 PGO-instrumented builds require ARM64 pgort140.dll. { - "pattern": "bin/arm64/pgort140.dll", + 'pattern': 'bin/arm64/pgort140.dll', }, { - "pattern": "bin/Hostx64/**", + 'pattern': 'bin/Hostx64/**', }, # 32-bit PGO-instrumented builds require 32-bit pgort140.dll. { - "pattern": "bin/Hostx86/x86/pgort140.dll", + 'pattern': 'bin/Hostx86/x86/pgort140.dll', }, { - "pattern": "include/**", + 'pattern': 'include/**', }, { - "pattern": "lib/**", - "ignore": ( - "lib/arm64/store/**", - "lib/onecore/**", - "lib/x64/store/**", - "lib/x86/store/**", + 'pattern': 'lib/**', + 'ignore': ( + 'lib/arm64/store/**', + 'lib/onecore/**', + 'lib/x64/store/**', + 'lib/x86/store/**', ), }, ], }, { - "srcdir": "%(vs_path)s/VC/Redist/MSVC/14.16.27012", - "dstdir": "VC/redist", - "files": [ + 'srcdir': '%(vs_path)s/VC/Redist/MSVC/14.16.27012', + 'dstdir': 'VC/redist', + 'files': [ { - "pattern": "arm64/Microsoft.VC141.CRT/**", + 'pattern': 'arm64/Microsoft.VC141.CRT/**', }, { - "pattern": "x64/Microsoft.VC141.CRT/**", + 'pattern': 'x64/Microsoft.VC141.CRT/**', }, { - "pattern": "x86/Microsoft.VC141.CRT/**", + 'pattern': 'x86/Microsoft.VC141.CRT/**', }, ], }, { - "srcdir": "%(sdk_path)s", - "dstdir": "SDK", - "files": [ + 'srcdir': '%(sdk_path)s', + 'dstdir': 'SDK', + 'files': [ { - "pattern": "bin/%s/x64/**" % SDK_RELEASE, + 'pattern': 'bin/%s/x64/**' % SDK_RELEASE, }, { - "pattern": "Include/%s/**" % SDK_RELEASE, + 'pattern': 'Include/%s/**' % SDK_RELEASE, }, { - "pattern": "Lib/%s/ucrt/arm64/**" % SDK_RELEASE, + 'pattern': 'Lib/%s/ucrt/arm64/**' % SDK_RELEASE, }, { - "pattern": "Lib/%s/ucrt/x64/**" % SDK_RELEASE, + 'pattern': 'Lib/%s/ucrt/x64/**' % SDK_RELEASE, }, { - "pattern": "Lib/%s/ucrt/x86/**" % SDK_RELEASE, + 'pattern': 'Lib/%s/ucrt/x86/**' % SDK_RELEASE, }, { - "pattern": "Lib/%s/um/arm64/**" % SDK_RELEASE, + 'pattern': 'Lib/%s/um/arm64/**' % SDK_RELEASE, }, { - "pattern": "Lib/%s/um/x64/**" % SDK_RELEASE, + 'pattern': 'Lib/%s/um/x64/**' % SDK_RELEASE, }, { - "pattern": "Lib/%s/um/x86/**" % SDK_RELEASE, + 'pattern': 'Lib/%s/um/x86/**' % SDK_RELEASE, }, { - "pattern": "Redist/D3D/**", + 'pattern': 'Redist/D3D/**', }, { - "pattern": "Redist/ucrt/DLLs/x64/**", + 'pattern': 'Redist/ucrt/DLLs/x64/**', }, { - "pattern": "Redist/ucrt/DLLs/x86/**", + 'pattern': 'Redist/ucrt/DLLs/x86/**', }, ], }, @@ -147,28 +155,25 @@ def find_vs_paths(): Returns a 2-tuple of (Visual Studio Path, SDK Path). """ - pf = os.environ.get("ProgramFiles(x86)") + pf = os.environ.get('ProgramFiles(x86)') if not pf: - raise Exception( - 'No "ProgramFiles(x86)" environment variable. ' - "Not running on 64-bit Windows?" - ) + raise Exception('No "ProgramFiles(x86)" environment variable. ' + 'Not running on 64-bit Windows?') - vs_path = os.path.join(pf, "Microsoft Visual Studio", "2017", "Community") + vs_path = os.path.join(pf, 'Microsoft Visual Studio', '2017', 'Community') if not os.path.exists(vs_path): - raise Exception( - "%s does not exist; Visual Studio 2017 not installed?" % vs_path - ) + raise Exception('%s does not exist; Visual Studio 2017 not installed?' % + vs_path) - sdk_path = os.path.join(pf, "Windows Kits", "10") + sdk_path = os.path.join(pf, 'Windows Kits', '10') if not os.path.exists(sdk_path): - raise Exception("%s does not exist; Windows 10 SDK not installed?" % sdk_path) + raise Exception('%s does not exist; Windows 10 SDK not installed?' % + sdk_path) - sdk_fullver_path = os.path.join(sdk_path, "Include", SDK_RELEASE) + sdk_fullver_path = os.path.join(sdk_path, 'Include', SDK_RELEASE) if not os.path.exists(sdk_fullver_path): - raise Exception( - "%s does not exist; Wrong SDK version installed?" % sdk_fullver_path - ) + raise Exception('%s does not exist; Wrong SDK version installed?' % + sdk_fullver_path) return vs_path, sdk_path @@ -182,15 +187,15 @@ def resolve_files(): vs_path, sdk_path = find_vs_paths() for entry in PATTERNS: - fullpath = entry["srcdir"] % { - "vs_path": vs_path, - "sdk_path": sdk_path, + fullpath = entry['srcdir'] % { + 'vs_path': vs_path, + 'sdk_path': sdk_path, } - for pattern in entry["files"]: - finder = FileFinder(fullpath, ignore=pattern.get("ignore", [])) - for p, f in finder.find(pattern["pattern"]): - dstpath = "%s/%s" % (entry["dstdir"], p) - yield dstpath.encode("utf-8"), f + for pattern in entry['files']: + finder = FileFinder(fullpath, ignore=pattern.get('ignore', [])) + for p, f in finder.find(pattern['pattern']): + dstpath = '%s/%s' % (entry['dstdir'], p) + yield dstpath.encode('utf-8'), f def resolve_files_and_hash(manifest): @@ -217,18 +222,18 @@ def format_manifest(manifest): """Return formatted SHA-256 manifests as a byte strings.""" sha256_lines = [] for path, (length, sha256) in sorted(manifest.items()): - sha256_lines.append(b"%s\t%d\t%s" % (sha256, length, path)) + sha256_lines.append(b'%s\t%d\t%s' % (sha256, length, path)) # Trailing newline. - sha256_lines.append(b"") + sha256_lines.append(b'') - return b"\n".join(sha256_lines) + return b'\n'.join(sha256_lines) def write_zip(zip_path, prefix=None): """Write toolchain data to a zip file.""" - if isinstance(prefix, unicode): # noqa Special case for Python 2 - prefix = prefix.encode("utf-8") + if isinstance(prefix, unicode): # noqa Special case for Python 2 + prefix = prefix.encode('utf-8') with JarWriter(file=zip_path, compress_level=5) as zip: manifest = {} @@ -241,37 +246,37 @@ def write_zip(zip_path, prefix=None): sha256_manifest = format_manifest(manifest) - sdk_path = b"SDK_VERSION" - sha256_path = b"MANIFEST.SHA256" + sdk_path = b'SDK_VERSION' + sha256_path = b'MANIFEST.SHA256' if prefix: sdk_path = mozpath.join(prefix, sdk_path) sha256_path = mozpath.join(prefix, sha256_path) - zip.add(sdk_path, SDK_RELEASE.encode("utf-8")) + zip.add(sdk_path, SDK_RELEASE.encode('utf-8')) zip.add(sha256_path, sha256_manifest) -if __name__ == "__main__": +if __name__ == '__main__': if len(sys.argv) != 3: - print("usage: %s create-zip " % sys.argv[0]) + print('usage: %s create-zip ' % sys.argv[0]) sys.exit(1) - assert sys.argv[1] == "create-zip" + assert sys.argv[1] == 'create-zip' prefix = os.path.basename(sys.argv[2]) - destzip = "%s.zip" % sys.argv[2] + destzip = '%s.zip' % sys.argv[2] write_zip(destzip, prefix=prefix) sha1 = hashlib.sha1() sha256 = hashlib.sha256() sha512 = hashlib.sha512() - with open(destzip, "rb") as fh: + with open(destzip, 'rb') as fh: data = fh.read() sha1.update(data) sha256.update(data) sha512.update(data) - print("Hashes of %s (size=%d)" % (destzip, len(data))) - print("SHA-1: %s" % sha1.hexdigest()) - print("SHA-256: %s" % sha256.hexdigest()) - print("SHA-512: %s" % sha512.hexdigest()) + print('Hashes of %s (size=%d)' % (destzip, len(data))) + print('SHA-1: %s' % sha1.hexdigest()) + print('SHA-256: %s' % sha256.hexdigest()) + print('SHA-512: %s' % sha512.hexdigest()) diff --git a/caps/moz.build b/caps/moz.build index e35debe6dac6d2fb65c4ee5bc0e61781f33a827a..a971c5252e0005df50d587b3533fb0c37c6cb906 100644 --- a/caps/moz.build +++ b/caps/moz.build @@ -4,78 +4,79 @@ # 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/. -MOCHITEST_MANIFESTS += ["tests/mochitest/mochitest.ini"] -MOCHITEST_CHROME_MANIFESTS += ["tests/mochitest/chrome.ini"] -BROWSER_CHROME_MANIFESTS += ["tests/mochitest/browser.ini"] -XPCSHELL_TESTS_MANIFESTS += ["tests/unit/xpcshell.ini"] +MOCHITEST_MANIFESTS += ['tests/mochitest/mochitest.ini'] +MOCHITEST_CHROME_MANIFESTS += ['tests/mochitest/chrome.ini'] +BROWSER_CHROME_MANIFESTS += ['tests/mochitest/browser.ini'] +XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini'] # Hack to make this file available as a resource:// URI. TESTING_JS_MODULES += [ - "tests/mochitest/resource_test_file.html", + 'tests/mochitest/resource_test_file.html', ] XPIDL_SOURCES += [ - "nsIAddonPolicyService.idl", - "nsIDomainPolicy.idl", - "nsIPrincipal.idl", - "nsIScriptSecurityManager.idl", + 'nsIAddonPolicyService.idl', + 'nsIDomainPolicy.idl', + 'nsIPrincipal.idl', + 'nsIScriptSecurityManager.idl', ] -XPIDL_MODULE = "caps" +XPIDL_MODULE = 'caps' EXPORTS += [ - "nsJSPrincipals.h", - "nsScriptSecurityManager.h", + 'nsJSPrincipals.h', + 'nsScriptSecurityManager.h', ] EXPORTS.mozilla = [ - "BasePrincipal.h", - "ContentPrincipal.h", - "ExpandedPrincipal.h", - "NullPrincipal.h", - "NullPrincipalURI.h", - "OriginAttributes.h", - "PrincipalHashKey.h", - "SystemPrincipal.h", + 'BasePrincipal.h', + 'ContentPrincipal.h', + 'ExpandedPrincipal.h', + 'NullPrincipal.h', + 'NullPrincipalURI.h', + 'OriginAttributes.h', + 'PrincipalHashKey.h', + 'SystemPrincipal.h', ] SOURCES += [ # Compile this separately since nsExceptionHandler.h conflicts # with something from NullPrincipal.cpp. - "BasePrincipal.cpp", + 'BasePrincipal.cpp', ] UNIFIED_SOURCES += [ - "ContentPrincipal.cpp", - "DomainPolicy.cpp", - "ExpandedPrincipal.cpp", - "nsJSPrincipals.cpp", - "nsScriptSecurityManager.cpp", - "NullPrincipal.cpp", - "NullPrincipalURI.cpp", - "OriginAttributes.cpp", - "SystemPrincipal.cpp", + 'ContentPrincipal.cpp', + 'DomainPolicy.cpp', + 'ExpandedPrincipal.cpp', + 'nsJSPrincipals.cpp', + 'nsScriptSecurityManager.cpp', + 'NullPrincipal.cpp', + 'NullPrincipalURI.cpp', + 'OriginAttributes.cpp', + 'SystemPrincipal.cpp', ] USE_LIBS += [ - "jsoncpp", + 'jsoncpp', ] LOCAL_INCLUDES += [ - "/docshell/base", - "/dom/base", - "/js/xpconnect/src", - "/netwerk/base", - "/netwerk/cookie", - "/toolkit/components/jsoncpp/include", + '/docshell/base', + '/dom/base', + '/js/xpconnect/src', + '/netwerk/base', + '/netwerk/cookie', + '/toolkit/components/jsoncpp/include', ] -if CONFIG["ENABLE_TESTS"]: - DIRS += ["tests/gtest"] +if CONFIG['ENABLE_TESTS']: + DIRS += ['tests/gtest'] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' with Files("**"): BUG_COMPONENT = ("Core", "Security: CAPS") + diff --git a/caps/tests/gtest/moz.build b/caps/tests/gtest/moz.build index 1ce86631197a906d3dfb94e188a447d7b8e0b1a1..bcc102c939c128146bdd39df97bb1b27f71d5d34 100644 --- a/caps/tests/gtest/moz.build +++ b/caps/tests/gtest/moz.build @@ -5,11 +5,11 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. UNIFIED_SOURCES += [ - "TestOriginAttributes.cpp", - "TestPrincipalAttributes.cpp", - "TestPrincipalSerialization.cpp", + 'TestOriginAttributes.cpp', + 'TestPrincipalAttributes.cpp', + 'TestPrincipalSerialization.cpp' ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul-gtest" +FINAL_LIBRARY = 'xul-gtest' diff --git a/chrome/moz.build b/chrome/moz.build index b5d767b65ceeb70b5040f5c89fa2625488e789bf..55e720f3349f2c9fb873931b901c91e088d93f18 100644 --- a/chrome/moz.build +++ b/chrome/moz.build @@ -4,44 +4,44 @@ # 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/. -TEST_DIRS += ["test"] +TEST_DIRS += ['test'] XPIDL_SOURCES += [ - "nsIChromeRegistry.idl", - "nsIToolkitChromeRegistry.idl", + 'nsIChromeRegistry.idl', + 'nsIToolkitChromeRegistry.idl', ] -XPIDL_MODULE = "chrome" +XPIDL_MODULE = 'chrome' EXPORTS += [ - "nsChromeProtocolHandler.h", + 'nsChromeProtocolHandler.h', ] EXPORTS.mozilla.chrome += [ - "RegistryMessageUtils.h", + 'RegistryMessageUtils.h', ] UNIFIED_SOURCES += [ - "nsChromeProtocolHandler.cpp", - "nsChromeRegistry.cpp", - "nsChromeRegistryChrome.cpp", - "nsChromeRegistryContent.cpp", + 'nsChromeProtocolHandler.cpp', + 'nsChromeRegistry.cpp', + 'nsChromeRegistryChrome.cpp', + 'nsChromeRegistryContent.cpp', ] -include("/ipc/chromium/chromium-config.mozbuild") +include('/ipc/chromium/chromium-config.mozbuild') -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' LOCAL_INCLUDES += [ - "!/xpcom", - "/dom/base", - "/netwerk/base", - "/netwerk/protocol/res", - "/xpcom/components", + '!/xpcom', + '/dom/base', + '/netwerk/base', + '/netwerk/protocol/res', + '/xpcom/components' ] -if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": - CXXFLAGS += CONFIG["TK_CFLAGS"] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk': + CXXFLAGS += CONFIG['TK_CFLAGS'] with Files("**"): BUG_COMPONENT = ("Toolkit", "Startup and Profile System") diff --git a/chrome/test/moz.build b/chrome/test/moz.build index 148e5d5ad9704200166d15e13e4127d5ffd14d66..ed3bd5bbe741206ab042b76540e6e50dcf960a01 100644 --- a/chrome/test/moz.build +++ b/chrome/test/moz.build @@ -5,6 +5,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. XPCSHELL_TESTS_MANIFESTS += [ - "unit/xpcshell.ini", - "unit_ipc/xpcshell.ini", + 'unit/xpcshell.ini', + 'unit_ipc/xpcshell.ini', ] diff --git a/client.py b/client.py index 76b325b7f503d60e107def9da876a94a03eaaf9e..ad6c1ab7fa7f230ddcf2beb0b7c96b82fbb0027f 100755 --- a/client.py +++ b/client.py @@ -5,10 +5,10 @@ from __future__ import absolute_import, print_function -LIBFFI_DIRS = (("js/ctypes/libffi", "libffi"),) -HG_EXCLUSIONS = [".hg", ".hgignore", ".hgtags"] +LIBFFI_DIRS = (('js/ctypes/libffi', 'libffi'),) +HG_EXCLUSIONS = ['.hg', '.hgignore', '.hgtags'] -CVSROOT_LIBFFI = ":pserver:anoncvs@sources.redhat.com:/cvs/libffi" +CVSROOT_LIBFFI = ':pserver:anoncvs@sources.redhat.com:/cvs/libffi' import os import sys @@ -19,8 +19,8 @@ from optparse import OptionParser from subprocess import check_call topsrcdir = os.path.dirname(__file__) -if topsrcdir == "": - topsrcdir = "." +if topsrcdir == '': + topsrcdir = '.' def check_call_noisy(cmd, *args, **kwargs): @@ -32,28 +32,27 @@ def do_hg_pull(dir, repository, hg): fulldir = os.path.join(topsrcdir, dir) # clone if the dir doesn't exist, pull if it does if not os.path.exists(fulldir): - check_call_noisy([hg, "clone", repository, fulldir]) + check_call_noisy([hg, 'clone', repository, fulldir]) else: - cmd = [hg, "pull", "-u", "-R", fulldir] + cmd = [hg, 'pull', '-u', '-R', fulldir] if repository is not None: cmd.append(repository) check_call_noisy(cmd) - check_call( - [hg, "parent", "-R", fulldir, "--template=Updated to revision {node}.\n"] - ) + check_call([hg, 'parent', '-R', fulldir, + '--template=Updated to revision {node}.\n']) def do_hg_replace(dir, repository, tag, exclusions, hg): """ - Replace the contents of dir with the contents of repository, except for - files matching exclusions. + Replace the contents of dir with the contents of repository, except for + files matching exclusions. """ fulldir = os.path.join(topsrcdir, dir) if os.path.exists(fulldir): shutil.rmtree(fulldir) assert not os.path.exists(fulldir) - check_call_noisy([hg, "clone", "-u", tag, repository, fulldir]) + check_call_noisy([hg, 'clone', '-u', tag, repository, fulldir]) for thing in exclusions: for excluded in glob.iglob(os.path.join(fulldir, thing)): @@ -77,18 +76,11 @@ def do_cvs_export(modules, tag, cvsroot, cvs): shutil.rmtree(fullpath) (parent, leaf) = os.path.split(module) - print( - "CVS export begin: " - + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC") - ) - check_call_noisy( - [cvs, "-d", cvsroot, "export", "-r", tag, "-d", leaf, cvs_module], - cwd=os.path.join(topsrcdir, parent), - ) - print( - "CVS export end: " - + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC") - ) + print("CVS export begin: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")) + check_call_noisy([cvs, '-d', cvsroot, + 'export', '-r', tag, '-d', leaf, cvs_module], + cwd=os.path.join(topsrcdir, parent)) + print("CVS export end: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")) def toggle_trailing_blank_line(depname): @@ -104,7 +96,7 @@ def toggle_trailing_blank_line(depname): open(depname, "wb").writelines(lines[:-1]) else: # adding blank line - open(depname, "ab").write(b"\n") + open(depname, "ab").write(b'\n') def get_trailing_blank_line_state(depname): @@ -119,9 +111,9 @@ def get_trailing_blank_line_state(depname): def update_nspr_or_nss(tag, depfile, destination, hgpath): - destination = destination.rstrip("/") - permanent_patch_dir = destination + "/patches" - temporary_patch_dir = destination + ".patches" + destination = destination.rstrip('/') + permanent_patch_dir = destination + '/patches' + temporary_patch_dir = destination + '.patches' if os.path.exists(temporary_patch_dir): print("please clean up leftover directory " + temporary_patch_dir) sys.exit(2) @@ -131,7 +123,7 @@ def update_nspr_or_nss(tag, depfile, destination, hgpath): shutil.move(permanent_patch_dir, temporary_patch_dir) # now update the destination print("reverting to HG version of %s to get its blank line state" % depfile) - check_call_noisy([options.hg, "revert", depfile]) + check_call_noisy([options.hg, 'revert', depfile]) old_state = get_trailing_blank_line_state(depfile) print("old state of %s is: %s" % (depfile, old_state)) do_hg_replace(destination, hgpath, tag, HG_EXCLUSIONS, options.hg) @@ -141,7 +133,7 @@ def update_nspr_or_nss(tag, depfile, destination, hgpath): print("toggling blank line in: ", depfile) toggle_trailing_blank_line(depfile) tag_file = destination + "/TAG-INFO" - with open(tag_file, "w") as f: + with open(tag_file, 'w') as f: f.write(tag) # move patch directory back to a subdirectory if os.path.exists(temporary_patch_dir): @@ -163,36 +155,19 @@ def warn_if_patch_exists(path): o = OptionParser( - usage="client.py [options] update_nspr tagname | update_nss tagname | update_libffi tagname" -) -o.add_option( - "--skip-mozilla", - dest="skip_mozilla", - action="store_true", - default=False, - help="Obsolete", -) - -o.add_option( - "--cvs", - dest="cvs", - default=os.environ.get("CVS", "cvs"), - help="The location of the cvs binary", -) -o.add_option( - "--cvsroot", - dest="cvsroot", - help="The CVSROOT for libffi (default : %s)" % CVSROOT_LIBFFI, -) -o.add_option( - "--hg", - dest="hg", - default=os.environ.get("HG", "hg"), - help="The location of the hg binary", -) -o.add_option( - "--repo", dest="repo", help="the repo to update from (default: upstream repo)" -) + usage="client.py [options] update_nspr tagname | update_nss tagname | update_libffi tagname") +o.add_option("--skip-mozilla", dest="skip_mozilla", + action="store_true", default=False, + help="Obsolete") + +o.add_option("--cvs", dest="cvs", default=os.environ.get('CVS', 'cvs'), + help="The location of the cvs binary") +o.add_option("--cvsroot", dest="cvsroot", + help="The CVSROOT for libffi (default : %s)" % CVSROOT_LIBFFI) +o.add_option("--hg", dest="hg", default=os.environ.get('HG', 'hg'), + help="The location of the hg binary") +o.add_option("--repo", dest="repo", + help="the repo to update from (default: upstream repo)") try: options, args = o.parse_args() @@ -201,23 +176,23 @@ except IndexError: o.print_help() sys.exit(2) -if action in ("checkout", "co"): +if action in ('checkout', 'co'): print("Warning: client.py checkout is obsolete.", file=sys.stderr) pass -elif action in ("update_nspr"): - (tag,) = args[1:] +elif action in ('update_nspr'): + tag, = args[1:] depfile = "nsprpub/config/prdepend.h" if not options.repo: - options.repo = "https://hg.mozilla.org/projects/nspr" - update_nspr_or_nss(tag, depfile, "nsprpub", options.repo) -elif action in ("update_nss"): - (tag,) = args[1:] + options.repo = 'https://hg.mozilla.org/projects/nspr' + update_nspr_or_nss(tag, depfile, 'nsprpub', options.repo) +elif action in ('update_nss'): + tag, = args[1:] depfile = "security/nss/coreconf/coreconf.dep" if not options.repo: - options.repo = "https://hg.mozilla.org/projects/nss" - update_nspr_or_nss(tag, depfile, "security/nss", options.repo) -elif action in ("update_libffi"): - (tag,) = args[1:] + options.repo = 'https://hg.mozilla.org/projects/nss' + update_nspr_or_nss(tag, depfile, 'security/nss', options.repo) +elif action in ('update_libffi'): + tag, = args[1:] if not options.cvsroot: options.cvsroot = CVSROOT_LIBFFI do_cvs_export(LIBFFI_DIRS, tag, options.cvsroot, options.cvs) diff --git a/config/MozZipFile.py b/config/MozZipFile.py index c5f08aef03cabbb93a781750507020e9c4d21b43..400da02dbce8ac76c4be89a1b65d1b9762daabda 100644 --- a/config/MozZipFile.py +++ b/config/MozZipFile.py @@ -12,24 +12,25 @@ from mozbuild.util import lock_file class ZipFile(zipfile.ZipFile): - """Class with methods to open, read, write, close, list zip files. + """ Class with methods to open, read, write, close, list zip files. Subclassing zipfile.ZipFile to allow for overwriting of existing entries, though only for writestr, not for write. """ - def __init__(self, file, mode="r", compression=zipfile.ZIP_STORED, lock=False): + def __init__(self, file, mode="r", compression=zipfile.ZIP_STORED, + lock=False): if lock: assert isinstance(file, six.text_type) - self.lockfile = lock_file(file + ".lck") + self.lockfile = lock_file(file + '.lck') else: self.lockfile = None - if mode == "a" and lock: + if mode == 'a' and lock: # appending to a file which doesn't exist fails, but we can't check # existence util we hold the lock if (not os.path.isfile(file)) or os.path.getsize(file) == 0: - mode = "w" + mode = 'w' zipfile.ZipFile.__init__(self, file, mode, compression) self._remove = [] @@ -44,12 +45,11 @@ class ZipFile(zipfile.ZipFile): This method is overloaded to allow overwriting existing entries. """ if not isinstance(zinfo_or_arcname, zipfile.ZipInfo): - zinfo = zipfile.ZipInfo( - filename=zinfo_or_arcname, date_time=time.localtime(time.time()) - ) + zinfo = zipfile.ZipInfo(filename=zinfo_or_arcname, + date_time=time.localtime(time.time())) zinfo.compress_type = self.compression # Add some standard UNIX file access permissions (-rw-r--r--). - zinfo.external_attr = (0x81A4 & 0xFFFF) << 16 + zinfo.external_attr = (0x81a4 & 0xFFFF) << 16 else: zinfo = zinfo_or_arcname @@ -70,10 +70,9 @@ class ZipFile(zipfile.ZipFile): if self.filelist[i].filename == zinfo.filename: break zi = self.filelist[i] - if ( - zinfo.compress_type == zipfile.ZIP_STORED - and zi.compress_size == len(bytes) - ) or (i + 1) == len(self.filelist): + if ((zinfo.compress_type == zipfile.ZIP_STORED + and zi.compress_size == len(bytes)) + or (i + 1) == len(self.filelist)): # make sure we're allowed to write, otherwise done by writestr below self._writecheck(zi) # overwrite existing entry @@ -109,21 +108,18 @@ class ZipFile(zipfile.ZipFile): self.lockfile = None return r - if self.fp.mode != "r+b": + if self.fp.mode != 'r+b': # adjust file mode if we originally just wrote, now we rewrite self.fp.close() - self.fp = open(self.filename, "r+b") - all = map(lambda zi: (zi, True), self.filelist) + map( - lambda zi: (zi, False), self._remove - ) + self.fp = open(self.filename, 'r+b') + all = map(lambda zi: (zi, True), self.filelist) + \ + map(lambda zi: (zi, False), self._remove) all.sort(key=lambda l: l[0].header_offset) # empty _remove for multiple closes self._remove = [] - lengths = [ - all[i + 1][0].header_offset - all[i][0].header_offset - for i in xrange(len(all) - 1) - ] + lengths = [all[i+1][0].header_offset - all[i][0].header_offset + for i in xrange(len(all)-1)] lengths.append(self.end - all[-1][0].header_offset) to_pos = 0 for (zi, keep), length in zip(all, lengths): @@ -131,7 +127,7 @@ class ZipFile(zipfile.ZipFile): continue oldoff = zi.header_offset # python <= 2.4 has file_offset - if hasattr(zi, "file_offset"): + if hasattr(zi, 'file_offset'): zi.file_offset = zi.file_offset + to_pos - oldoff zi.header_offset = to_pos self.fp.seek(oldoff) diff --git a/config/check_js_msg_encoding.py b/config/check_js_msg_encoding.py index 69d2a368dcc54cdffe337f3ae50269055bd572ba..197a51e1fb7f7c2b78959a1ee36fdc28fbc7be0f 100644 --- a/config/check_js_msg_encoding.py +++ b/config/check_js_msg_encoding.py @@ -18,32 +18,33 @@ from mozversioncontrol import get_repository_from_env scriptname = os.path.basename(__file__) -expected_encoding = "ascii" +expected_encoding = 'ascii' # The following files don't define JSErrorFormatString. ignore_files = [ - "dom/base/domerr.msg", - "js/xpconnect/src/xpc.msg", + 'dom/base/domerr.msg', + 'js/xpconnect/src/xpc.msg', ] def log_pass(filename, text): - print("TEST-PASS | {} | {} | {}".format(scriptname, filename, text)) + print('TEST-PASS | {} | {} | {}'.format(scriptname, filename, text)) def log_fail(filename, text): - print("TEST-UNEXPECTED-FAIL | {} | {} | {}".format(scriptname, filename, text)) + print('TEST-UNEXPECTED-FAIL | {} | {} | {}'.format(scriptname, filename, + text)) def check_single_file(filename): - with open(filename, "rb") as f: + with open(filename, 'rb') as f: data = f.read() try: data.decode(expected_encoding) except Exception: - log_fail(filename, "not in {} encoding".format(expected_encoding)) + log_fail(filename, 'not in {} encoding'.format(expected_encoding)) - log_pass(filename, "ok") + log_pass(filename, 'ok') return True @@ -53,7 +54,7 @@ def check_files(): with get_repository_from_env() as repo: root = repo.path - for filename, _ in repo.get_tracked_files_finder().find("**/*.msg"): + for filename, _ in repo.get_tracked_files_finder().find('**/*.msg'): if filename not in ignore_files: if not check_single_file(os.path.join(root, filename)): result = False @@ -68,5 +69,5 @@ def main(): sys.exit(0) -if __name__ == "__main__": +if __name__ == '__main__': main() diff --git a/config/check_js_opcode.py b/config/check_js_opcode.py index c42ea5ee63fa9fea74615fcf7dd32b8d1ee52374..dfa9921a0b0eab12443d3f423320075cf6a6587d 100644 --- a/config/check_js_opcode.py +++ b/config/check_js_opcode.py @@ -18,15 +18,15 @@ topsrcdir = os.path.dirname(os.path.dirname(__file__)) def log_pass(text): - print("TEST-PASS | {} | {}".format(scriptname, text)) + print('TEST-PASS | {} | {}'.format(scriptname, text)) def log_fail(text): - print("TEST-UNEXPECTED-FAIL | {} | {}".format(scriptname, text)) + print('TEST-UNEXPECTED-FAIL | {} | {}'.format(scriptname, text)) def check_opcode(): - sys.path.insert(0, os.path.join(topsrcdir, "js", "src", "vm")) + sys.path.insert(0, os.path.join(topsrcdir, 'js', 'src', 'vm')) import jsopcode try: @@ -35,7 +35,7 @@ def check_opcode(): log_fail(e.args[0]) return False - log_pass("ok") + log_pass('ok') return True @@ -46,5 +46,5 @@ def main(): sys.exit(0) -if __name__ == "__main__": +if __name__ == '__main__': main() diff --git a/config/check_source_count.py b/config/check_source_count.py index 33f26acd393fe41482d75044d191dd2d21ba79bf..df87c0689f610c67bb0509f786edf6ed9912b429 100755 --- a/config/check_source_count.py +++ b/config/check_source_count.py @@ -32,32 +32,23 @@ for f in files: details[f] = num if count == expected_count: - print( - "TEST-PASS | check_source_count.py {0} | {1}".format( - search_string, expected_count - ) - ) + print("TEST-PASS | check_source_count.py {0} | {1}" + .format(search_string, expected_count)) else: - print( - "TEST-UNEXPECTED-FAIL | check_source_count.py {0} | ".format(search_string), - end="", - ) + print("TEST-UNEXPECTED-FAIL | check_source_count.py {0} | " + .format(search_string), + end='') if count < expected_count: - print( - "There are fewer occurrences of /{0}/ than expected. " - "This may mean that you have removed some, but forgotten to " - "account for it {1}.".format(search_string, error_location) - ) + print("There are fewer occurrences of /{0}/ than expected. " + "This may mean that you have removed some, but forgotten to " + "account for it {1}.".format(search_string, error_location)) else: - print( - "There are more occurrences of /{0}/ than expected. We're trying " - "to prevent an increase in the number of {1}'s, using {2} if " - "possible. If it is unavoidable, you should update the expected " - "count {3}.".format( - search_string, search_string, replacement, error_location - ) - ) + print("There are more occurrences of /{0}/ than expected. We're trying " + "to prevent an increase in the number of {1}'s, using {2} if " + "possible. If it is unavoidable, you should update the expected " + "count {3}.".format(search_string, search_string, replacement, + error_location)) print("Expected: {0}; found: {1}".format(expected_count, count)) for k in sorted(details): diff --git a/config/check_spidermonkey_style.py b/config/check_spidermonkey_style.py index 41d0866cd387a07f129aa357070de3ed89614120..262026f5a115d696186e9a6a8229df7f7ba9e07e 100644 --- a/config/check_spidermonkey_style.py +++ b/config/check_spidermonkey_style.py @@ -45,103 +45,99 @@ import sys # We don't bother checking files in these directories, because they're (a) auxiliary or (b) # imported code that doesn't follow our coding style. ignored_js_src_dirs = [ - "js/src/config/", # auxiliary stuff - "js/src/ctypes/libffi/", # imported code - "js/src/devtools/", # auxiliary stuff - "js/src/editline/", # imported code - "js/src/gdb/", # auxiliary stuff - "js/src/vtune/", # imported code - "js/src/zydis/", # imported code + 'js/src/config/', # auxiliary stuff + 'js/src/ctypes/libffi/', # imported code + 'js/src/devtools/', # auxiliary stuff + 'js/src/editline/', # imported code + 'js/src/gdb/', # auxiliary stuff + 'js/src/vtune/', # imported code + 'js/src/zydis/', # imported code ] # We ignore #includes of these files, because they don't follow the usual rules. -included_inclnames_to_ignore = set( - [ - "ffi.h", # generated in ctypes/libffi/ - "devtools/Instruments.h", # we ignore devtools/ in general - "double-conversion/double-conversion.h", # strange MFBT case - "javascript-trace.h", # generated in $OBJDIR if HAVE_DTRACE is defined - "frontend/ReservedWordsGenerated.h", # generated in $OBJDIR - "frontend/smoosh_generated.h", # generated in $OBJDIR - "gc/StatsPhasesGenerated.h", # generated in $OBJDIR - "gc/StatsPhasesGenerated.inc", # generated in $OBJDIR - "jit/CacheIROpsGenerated.h", # generated in $OBJDIR - "jit/LOpcodesGenerated.h", # generated in $OBJDIR - "jit/MOpcodesGenerated.h", # generated in $OBJDIR - "js/ProfilingCategoryList.h", # comes from mozglue/baseprofiler - "jscustomallocator.h", # provided by embedders; allowed to be missing - "js-config.h", # generated in $OBJDIR - "fdlibm.h", # fdlibm - "FuzzerDefs.h", # included without a path - "FuzzingInterface.h", # included without a path - "mozmemory.h", # included without a path - "pratom.h", # NSPR - "prcvar.h", # NSPR - "prerror.h", # NSPR - "prinit.h", # NSPR - "prio.h", # NSPR - "private/pprio.h", # NSPR - "prlink.h", # NSPR - "prlock.h", # NSPR - "prprf.h", # NSPR - "prthread.h", # NSPR - "prtypes.h", # NSPR - "selfhosted.out.h", # generated in $OBJDIR - "shellmoduleloader.out.h", # generated in $OBJDIR - "unicode/basictz.h", # ICU - "unicode/locid.h", # ICU - "unicode/plurrule.h", # ICU - "unicode/putil.h", # ICU - "unicode/timezone.h", # ICU - "unicode/ucal.h", # ICU - "unicode/uchar.h", # ICU - "unicode/uclean.h", # ICU - "unicode/ucol.h", # ICU - "unicode/ucurr.h", # ICU - "unicode/udat.h", # ICU - "unicode/udata.h", # ICU - "unicode/udateintervalformat.h", # ICU - "unicode/udatpg.h", # ICU - "unicode/udisplaycontext.h", # ICU - "unicode/uenum.h", # ICU - "unicode/ufieldpositer.h", # ICU - "unicode/uformattedvalue.h", # ICU - "unicode/ulistformatter.h", # ICU - "unicode/uldnames.h", # ICU - "unicode/uloc.h", # ICU - "unicode/umachine.h", # ICU - "unicode/uniset.h", # ICU - "unicode/unistr.h", # ICU - "unicode/unorm2.h", # ICU - "unicode/unum.h", # ICU - "unicode/unumberformatter.h", # ICU - "unicode/unumsys.h", # ICU - "unicode/upluralrules.h", # ICU - "unicode/ureldatefmt.h", # ICU - "unicode/ures.h", # ICU - "unicode/ustring.h", # ICU - "unicode/utypes.h", # ICU - "unicode/uversion.h", # ICU - "vtune/VTuneWrapper.h", # VTune - "zydis/ZydisAPI.h", # Zydis - ] -) +included_inclnames_to_ignore = set([ + 'ffi.h', # generated in ctypes/libffi/ + 'devtools/Instruments.h', # we ignore devtools/ in general + 'double-conversion/double-conversion.h', # strange MFBT case + 'javascript-trace.h', # generated in $OBJDIR if HAVE_DTRACE is defined + 'frontend/ReservedWordsGenerated.h', # generated in $OBJDIR + 'frontend/smoosh_generated.h', # generated in $OBJDIR + 'gc/StatsPhasesGenerated.h', # generated in $OBJDIR + 'gc/StatsPhasesGenerated.inc', # generated in $OBJDIR + 'jit/CacheIROpsGenerated.h', # generated in $OBJDIR + 'jit/LOpcodesGenerated.h', # generated in $OBJDIR + 'jit/MOpcodesGenerated.h', # generated in $OBJDIR + 'js/ProfilingCategoryList.h', # comes from mozglue/baseprofiler + 'jscustomallocator.h', # provided by embedders; allowed to be missing + 'js-config.h', # generated in $OBJDIR + 'fdlibm.h', # fdlibm + 'FuzzerDefs.h', # included without a path + 'FuzzingInterface.h', # included without a path + 'mozmemory.h', # included without a path + 'pratom.h', # NSPR + 'prcvar.h', # NSPR + 'prerror.h', # NSPR + 'prinit.h', # NSPR + 'prio.h', # NSPR + 'private/pprio.h', # NSPR + 'prlink.h', # NSPR + 'prlock.h', # NSPR + 'prprf.h', # NSPR + 'prthread.h', # NSPR + 'prtypes.h', # NSPR + 'selfhosted.out.h', # generated in $OBJDIR + 'shellmoduleloader.out.h', # generated in $OBJDIR + 'unicode/basictz.h', # ICU + 'unicode/locid.h', # ICU + 'unicode/plurrule.h', # ICU + 'unicode/putil.h', # ICU + 'unicode/timezone.h', # ICU + 'unicode/ucal.h', # ICU + 'unicode/uchar.h', # ICU + 'unicode/uclean.h', # ICU + 'unicode/ucol.h', # ICU + 'unicode/ucurr.h', # ICU + 'unicode/udat.h', # ICU + 'unicode/udata.h', # ICU + 'unicode/udateintervalformat.h', # ICU + 'unicode/udatpg.h', # ICU + 'unicode/udisplaycontext.h', # ICU + 'unicode/uenum.h', # ICU + 'unicode/ufieldpositer.h', # ICU + 'unicode/uformattedvalue.h', # ICU + 'unicode/ulistformatter.h', # ICU + 'unicode/uldnames.h', # ICU + 'unicode/uloc.h', # ICU + 'unicode/umachine.h', # ICU + 'unicode/uniset.h', # ICU + 'unicode/unistr.h', # ICU + 'unicode/unorm2.h', # ICU + 'unicode/unum.h', # ICU + 'unicode/unumberformatter.h', # ICU + 'unicode/unumsys.h', # ICU + 'unicode/upluralrules.h', # ICU + 'unicode/ureldatefmt.h', # ICU + 'unicode/ures.h', # ICU + 'unicode/ustring.h', # ICU + 'unicode/utypes.h', # ICU + 'unicode/uversion.h', # ICU + 'vtune/VTuneWrapper.h', # VTune + 'zydis/ZydisAPI.h', # Zydis +]) # These files have additional constraints on where they are #included, so we # ignore #includes of them when checking #include ordering. -oddly_ordered_inclnames = set( - [ - "ctypes/typedefs.h", # Included multiple times in the body of ctypes/CTypes.h - # Included in the body of frontend/TokenStream.h - "frontend/ReservedWordsGenerated.h", - "gc/StatsPhasesGenerated.h", # Included in the body of gc/Statistics.h - "gc/StatsPhasesGenerated.inc", # Included in the body of gc/Statistics.cpp - "psapi.h", # Must be included after "util/Windows.h" on Windows - "machine/endian.h", # Must be included after on BSD - "winbase.h", # Must precede other system headers(?) - "windef.h", # Must precede other system headers(?) - ] -) +oddly_ordered_inclnames = set([ + 'ctypes/typedefs.h', # Included multiple times in the body of ctypes/CTypes.h + # Included in the body of frontend/TokenStream.h + 'frontend/ReservedWordsGenerated.h', + 'gc/StatsPhasesGenerated.h', # Included in the body of gc/Statistics.h + 'gc/StatsPhasesGenerated.inc', # Included in the body of gc/Statistics.cpp + 'psapi.h', # Must be included after "util/Windows.h" on Windows + 'machine/endian.h', # Must be included after on BSD + 'winbase.h', # Must precede other system headers(?) + 'windef.h' # Must precede other system headers(?) +]) # The files in tests/style/ contain code that fails this checking in various # ways. Here is the output we expect. If the actual output differs from @@ -151,7 +147,7 @@ oddly_ordered_inclnames = set( # accordingly. # - This script has been broken somehow. # -expected_output = """\ +expected_output = '''\ js/src/tests/style/BadIncludes.h:3: error: the file includes itself @@ -208,26 +204,24 @@ js/src/tests/style/BadIncludesOrder-inl.h:28:29: error: -> tests/style/HeaderCycleB1-inl.h -> tests/style/HeaderCycleB4-inl.h -""".splitlines( - True -) +'''.splitlines(True) actual_output = [] def out(*lines): for line in lines: - actual_output.append(line + "\n") + actual_output.append(line + '\n') def error(filename, linenum, *lines): location = filename if linenum is not None: - location += ":" + str(linenum) - out(location + ": error:") - for line in lines: - out(" " + line) - out("") + location += ':' + str(linenum) + out(location + ': error:') + for line in (lines): + out(' ' + line) + out('') class FileKind(object): @@ -240,25 +234,25 @@ class FileKind(object): @staticmethod def get(filename): - if filename.endswith(".c"): + if filename.endswith('.c'): return FileKind.C - if filename.endswith(".cpp"): + if filename.endswith('.cpp'): return FileKind.CPP - if filename.endswith(("inlines.h", "-inl.h")): + if filename.endswith(('inlines.h', '-inl.h')): return FileKind.INL_H - if filename.endswith(".h"): + if filename.endswith('.h'): return FileKind.H - if filename.endswith(".tbl"): + if filename.endswith('.tbl'): return FileKind.TBL - if filename.endswith(".msg"): + if filename.endswith('.msg'): return FileKind.MSG - error(filename, None, "unknown file kind") + error(filename, None, 'unknown file kind') def check_style(enable_fixup): @@ -273,51 +267,52 @@ def check_style(enable_fixup): # - "js/public/Vector.h" -> "js/Vector.h" # - "js/src/vm/String.h" -> "vm/String.h" - non_js_dirnames = ("mfbt/", "memory/mozalloc/", "mozglue/") # type: tuple(str) - non_js_inclnames = set() # type: set(inclname) - js_names = dict() # type: dict(filename, inclname) + non_js_dirnames = ('mfbt/', + 'memory/mozalloc/', + 'mozglue/') # type: tuple(str) + non_js_inclnames = set() # type: set(inclname) + js_names = dict() # type: dict(filename, inclname) # Process files in js/src. - js_src_root = os.path.join("js", "src") + js_src_root = os.path.join('js', 'src') for dirpath, dirnames, filenames in os.walk(js_src_root): if dirpath == js_src_root: # Skip any subdirectories that contain a config.status file # (likely objdirs). builddirs = [] for dirname in dirnames: - path = os.path.join(dirpath, dirname, "config.status") + path = os.path.join(dirpath, dirname, 'config.status') if os.path.isfile(path): builddirs.append(dirname) for dirname in builddirs: dirnames.remove(dirname) for filename in filenames: - filepath = os.path.join(dirpath, filename).replace("\\", "/") - if not filepath.startswith( - tuple(ignored_js_src_dirs) - ) and filepath.endswith((".c", ".cpp", ".h", ".tbl", ".msg")): - inclname = filepath[len("js/src/") :] + filepath = os.path.join(dirpath, filename).replace('\\', '/') + if not filepath.startswith(tuple(ignored_js_src_dirs)) and \ + filepath.endswith(('.c', '.cpp', '.h', '.tbl', '.msg')): + inclname = filepath[len('js/src/'):] js_names[filepath] = inclname # Look for header files in directories in non_js_dirnames. for non_js_dir in non_js_dirnames: for dirpath, dirnames, filenames in os.walk(non_js_dir): for filename in filenames: - if filename.endswith(".h"): - inclname = "mozilla/" + filename + if filename.endswith('.h'): + inclname = 'mozilla/' + filename non_js_inclnames.add(inclname) # Look for header files in js/public. - js_public_root = os.path.join("js", "public") + js_public_root = os.path.join('js', 'public') for dirpath, dirnames, filenames in os.walk(js_public_root): for filename in filenames: - if filename.endswith((".h", ".msg")): - filepath = os.path.join(dirpath, filename).replace("\\", "/") - inclname = "js/" + filepath[len("js/public/") :] + if filename.endswith(('.h', '.msg')): + filepath = os.path.join(dirpath, filename).replace('\\', '/') + inclname = 'js/' + filepath[len('js/public/'):] js_names[filepath] = inclname all_inclnames = non_js_inclnames | set(js_names.values()) - edges = dict() # type: dict(inclname, set(inclname)) + edges = dict() # type: dict(inclname, set(inclname)) # We don't care what's inside the MFBT and MOZALLOC files, but because they # are #included from JS files we have to add them to the inclusion graph. @@ -328,59 +323,46 @@ def check_style(enable_fixup): for filename in sorted(js_names.keys()): inclname = js_names[filename] file_kind = FileKind.get(filename) - if ( - file_kind == FileKind.C - or file_kind == FileKind.CPP - or file_kind == FileKind.H - or file_kind == FileKind.INL_H - ): - included_h_inclnames = set() # type: set(inclname) - - with open(filename, encoding="utf-8") as f: + if file_kind == FileKind.C or file_kind == FileKind.CPP or \ + file_kind == FileKind.H or file_kind == FileKind.INL_H: + included_h_inclnames = set() # type: set(inclname) + + with open(filename, encoding='utf-8') as f: code = read_file(f) if enable_fixup: code = code.sorted(inclname) - with open(filename, "w") as f: + with open(filename, 'w') as f: f.write(code.to_source()) - check_file( - filename, inclname, file_kind, code, all_inclnames, included_h_inclnames - ) + check_file(filename, inclname, file_kind, code, + all_inclnames, included_h_inclnames) edges[inclname] = included_h_inclnames find_cycles(all_inclnames, edges) # Compare expected and actual output. - difflines = difflib.unified_diff( - expected_output, - actual_output, - fromfile="check_spidermonkey_style.py expected output", - tofile="check_spidermonkey_style.py actual output", - ) + difflines = difflib.unified_diff(expected_output, actual_output, + fromfile='check_spidermonkey_style.py expected output', + tofile='check_spidermonkey_style.py actual output') ok = True for diffline in difflines: ok = False - print(diffline, end="") + print(diffline, end='') return ok def module_name(name): - """Strip the trailing .cpp, .h, inlines.h or -inl.h from a filename.""" + '''Strip the trailing .cpp, .h, inlines.h or -inl.h from a filename.''' - return ( - name.replace("inlines.h", "") - .replace("-inl.h", "") - .replace(".h", "") - .replace(".cpp", "") - ) # NOQA: E501 + return name.replace('inlines.h', '').replace('-inl.h', '').replace('.h', '').replace('.cpp', '') # NOQA: E501 def is_module_header(enclosing_inclname, header_inclname): - """Determine if an included name is the "module header", i.e. should be - first in the file.""" + '''Determine if an included name is the "module header", i.e. should be + first in the file.''' module = module_name(enclosing_inclname) @@ -398,15 +380,15 @@ def is_module_header(enclosing_inclname, header_inclname): # # module == "vm/SourceHook", # header_inclname == "js/experimental/SourceHook.h" - m = re.match(r"js\/.*?([^\/]+)\.h", header_inclname) - if m is not None and module.endswith("/" + m.group(1)): + m = re.match(r'js\/.*?([^\/]+)\.h', header_inclname) + if m is not None and module.endswith('/' + m.group(1)): return True return False class Include(object): - """Important information for a single #include statement.""" + '''Important information for a single #include statement.''' def __init__(self, include_prefix, inclname, line_suffix, linenum, is_system): self.include_prefix = include_prefix @@ -421,7 +403,7 @@ class Include(object): return True def section(self, enclosing_inclname): - """Identify which section inclname belongs to. + '''Identify which section inclname belongs to. The section numbers are as follows. 0. Module header (e.g. jsfoo.h or jsfooinlines.h within jsfoo.cpp) @@ -432,12 +414,12 @@ class Include(object): 5. jsfooinlines.h 6. foo/Bar-inl.h 7. non-.h, e.g. *.tbl, *.msg (these can be scattered throughout files) - """ + ''' if self.is_system: return 2 - if not self.inclname.endswith(".h"): + if not self.inclname.endswith('.h'): return 7 # A couple of modules have the .h file in js/ and the .cpp file elsewhere and so need @@ -445,23 +427,23 @@ class Include(object): if is_module_header(enclosing_inclname, self.inclname): return 0 - if "/" in self.inclname: - if self.inclname.startswith("mozilla/"): + if '/' in self.inclname: + if self.inclname.startswith('mozilla/'): return 1 - if self.inclname.endswith("-inl.h"): + if self.inclname.endswith('-inl.h'): return 6 return 4 - if self.inclname.endswith("inlines.h"): + if self.inclname.endswith('inlines.h'): return 5 return 3 def quote(self): if self.is_system: - return "<" + self.inclname + ">" + return '<' + self.inclname + '>' else: return '"' + self.inclname + '"' @@ -469,22 +451,22 @@ class Include(object): return (self.section(enclosing_inclname), self.inclname.lower()) def to_source(self): - return self.include_prefix + self.quote() + self.line_suffix + "\n" + return self.include_prefix + self.quote() + self.line_suffix + '\n' class CppBlock(object): - """C preprocessor block: a whole file or a single #if/#elif/#else block. + '''C preprocessor block: a whole file or a single #if/#elif/#else block. A #if/#endif block is the contents of a #if/#endif (or similar) section. The top-level block, which is not within a #if/#endif pair, is also considered a block. Each kid is either an Include (representing a #include), OrdinaryCode, or - a nested CppBlock.""" + a nested CppBlock.''' def __init__(self, start_line=""): self.start = start_line - self.end = "" + self.end = '' self.kids = [] def is_style_relevant(self): @@ -506,8 +488,8 @@ class CppBlock(object): """ def pretty_sorted_includes(includes): - """Return a new list containing the given includes, in order, - with blank lines separating sections.""" + """ Return a new list containing the given includes, in order, + with blank lines separating sections. """ keys = [inc.sort_key(enclosing_inclname) for inc in includes] if sorted(keys) == keys: return includes # if nothing is out of order, don't touch anything @@ -522,13 +504,11 @@ class CppBlock(object): return output def should_try_to_sort(includes): - if "tests/style/BadIncludes" in enclosing_inclname: + if 'tests/style/BadIncludes' in enclosing_inclname: return False # don't straighten the counterexample if any(inc.inclname in oddly_ordered_inclnames for inc in includes): return False # don't sort batches containing odd includes - if includes == sorted( - includes, key=lambda inc: inc.sort_key(enclosing_inclname) - ): + if includes == sorted(includes, key=lambda inc: inc.sort_key(enclosing_inclname)): return False # it's already sorted, avoid whitespace-only fixups return True @@ -542,11 +522,9 @@ class CppBlock(object): def flush_batch(): """Sort the contents of `batch` and move it to `output`.""" - assert all( - isinstance(item, Include) - or (isinstance(item, OrdinaryCode) and "".join(item.lines).isspace()) - for item in batch - ) + assert all(isinstance(item, Include) + or (isinstance(item, OrdinaryCode) and "".join(item.lines).isspace()) + for item in batch) # Here we throw away the blank lines. # `pretty_sorted_includes` puts them back. @@ -559,7 +537,8 @@ class CppBlock(object): cutoff = last_include_index + 1 if should_try_to_sort(includes): - output.extend(pretty_sorted_includes(includes) + batch[cutoff:]) + output.extend(pretty_sorted_includes( + includes) + batch[cutoff:]) else: output.extend(batch) del batch[:] @@ -586,11 +565,11 @@ class CppBlock(object): return result def to_source(self): - return self.start + "".join(kid.to_source() for kid in self.kids) + self.end + return self.start + ''.join(kid.to_source() for kid in self.kids) + self.end class OrdinaryCode(object): - """ A list of lines of code that aren't #include/#if/#else/#endif lines. """ + ''' A list of lines of code that aren't #include/#if/#else/#endif lines. ''' def __init__(self, lines=None): self.lines = lines if lines is not None else [] @@ -599,7 +578,7 @@ class OrdinaryCode(object): return False def to_source(self): - return "".join(self.lines) + return ''.join(self.lines) # A "snippet" is one of: @@ -608,33 +587,30 @@ class OrdinaryCode(object): # * CppBlock - a whole file or #if/#elif/#else block; contains a list of snippets # * OrdinaryCode - representing lines of non-#include-relevant code - def read_file(f): block_stack = [CppBlock()] # Extract the #include statements as a tree of snippets. for linenum, line in enumerate(f, start=1): - if line.lstrip().startswith("#"): + if line.lstrip().startswith('#'): # Look for a |#include "..."| line. m = re.match(r'(\s*#\s*include\s+)"([^"]*)"(.*)', line) if m is not None: prefix, inclname, suffix = m.groups() - block_stack[-1].kids.append( - Include(prefix, inclname, suffix, linenum, is_system=False) - ) + block_stack[-1].kids.append(Include(prefix, + inclname, suffix, linenum, is_system=False)) continue # Look for a |#include <...>| line. - m = re.match(r"(\s*#\s*include\s+)<([^>]*)>(.*)", line) + m = re.match(r'(\s*#\s*include\s+)<([^>]*)>(.*)', line) if m is not None: prefix, inclname, suffix = m.groups() - block_stack[-1].kids.append( - Include(prefix, inclname, suffix, linenum, is_system=True) - ) + block_stack[-1].kids.append(Include(prefix, + inclname, suffix, linenum, is_system=True)) continue # Look for a |#{if,ifdef,ifndef}| line. - m = re.match(r"\s*#\s*(if|ifdef|ifndef)\b", line) + m = re.match(r'\s*#\s*(if|ifdef|ifndef)\b', line) if m is not None: # Open a new block. new_block = CppBlock(line) @@ -643,7 +619,7 @@ def read_file(f): continue # Look for a |#{elif,else}| line. - m = re.match(r"\s*#\s*(elif|else)\b", line) + m = re.match(r'\s*#\s*(elif|else)\b', line) if m is not None: # Close the current block, and open an adjacent one. block_stack.pop() @@ -653,12 +629,13 @@ def read_file(f): continue # Look for a |#endif| line. - m = re.match(r"\s*#\s*endif\b", line) + m = re.match(r'\s*#\s*endif\b', line) if m is not None: # Close the current block. block_stack.pop().end = line if len(block_stack) == 0: - raise ValueError("#endif without #if at line " + str(linenum)) + raise ValueError( + "#endif without #if at line " + str(linenum)) continue # Otherwise, we have an ordinary line. @@ -669,24 +646,18 @@ def read_file(f): return block_stack[-1] -def check_file( - filename, inclname, file_kind, code, all_inclnames, included_h_inclnames -): +def check_file(filename, inclname, file_kind, code, all_inclnames, included_h_inclnames): + def check_include_statement(include): - """Check the style of a single #include statement.""" + '''Check the style of a single #include statement.''' if include.is_system: # Check it is not a known local file (in which case it's probably a system header). - if ( - include.inclname in included_inclnames_to_ignore - or include.inclname in all_inclnames - ): - error( - filename, - include.linenum, - include.quote() + " should be included using", - 'the #include "..." form', - ) + if include.inclname in included_inclnames_to_ignore or \ + include.inclname in all_inclnames: + error(filename, include.linenum, + include.quote() + ' should be included using', + 'the #include "..." form') else: if include.inclname not in included_inclnames_to_ignore: @@ -694,12 +665,9 @@ def check_file( # Check the #include path has the correct form. if include.inclname not in all_inclnames: - error( - filename, - include.linenum, - include.quote() + " is included using the wrong path;", - "did you forget a prefix, or is the file not yet committed?", - ) + error(filename, include.linenum, + include.quote() + ' is included using the wrong path;', + 'did you forget a prefix, or is the file not yet committed?') # Record inclusions of .h files for cycle detection later. # (Exclude .tbl and .msg files.) @@ -708,38 +676,28 @@ def check_file( # Check a H file doesn't #include an INL_H file. if file_kind == FileKind.H and included_kind == FileKind.INL_H: - error( - filename, - include.linenum, - "vanilla header includes an inline-header file " - + include.quote(), - ) + error(filename, include.linenum, + 'vanilla header includes an inline-header file ' + include.quote()) # Check a file doesn't #include itself. (We do this here because the cycle # detection below doesn't detect this case.) if inclname == include.inclname: - error(filename, include.linenum, "the file includes itself") + error(filename, include.linenum, + 'the file includes itself') def check_includes_order(include1, include2): - """Check the ordering of two #include statements.""" + '''Check the ordering of two #include statements.''' - if ( - include1.inclname in oddly_ordered_inclnames - or include2.inclname in oddly_ordered_inclnames - ): + if include1.inclname in oddly_ordered_inclnames or \ + include2.inclname in oddly_ordered_inclnames: return section1 = include1.section(inclname) section2 = include2.section(inclname) - if (section1 > section2) or ( - (section1 == section2) - and (include1.inclname.lower() > include2.inclname.lower()) - ): - error( - filename, - str(include1.linenum) + ":" + str(include2.linenum), - include1.quote() + " should be included after " + include2.quote(), - ) + if (section1 > section2) or \ + ((section1 == section2) and (include1.inclname.lower() > include2.inclname.lower())): + error(filename, str(include1.linenum) + ':' + str(include2.linenum), + include1.quote() + ' should be included after ' + include2.quote()) # Check the extracted #include statements, both individually, and the ordering of # adjacent pairs that live in the same block. @@ -757,7 +715,7 @@ def check_file( def find_cycles(all_inclnames, edges): - """Find and draw any cycles.""" + '''Find and draw any cycles.''' SCCs = tarjan(all_inclnames, edges) @@ -768,22 +726,22 @@ def find_cycles(all_inclnames, edges): drawn = set() def draw(v, indent): - out(" " * indent + ("-> " if indent else " ") + v) + out(' ' * indent + ('-> ' if indent else ' ') + v) if v in drawn: return drawn.add(v) for succ in sorted(edges[v]): if succ in cset: draw(succ, indent + 1) - draw(sorted(c)[0], 0) - out("") + out('') have_drawn_an_SCC = False for scc in sorted(SCCs): if len(scc) != 1: if not have_drawn_an_SCC: - error("(multiple files)", None, "header files form one or more cycles") + error('(multiple files)', None, + 'header files form one or more cycles') have_drawn_an_SCC = True draw_SCC(scc) @@ -841,31 +799,25 @@ def main(): elif sys.argv[1:] == []: fixup = False else: - print( - "TEST-UNEXPECTED-FAIL | check_spidermonkey_style.py | unexpected command " - "line options: " + repr(sys.argv[1:]) - ) + print("TEST-UNEXPECTED-FAIL | check_spidermonkey_style.py | unexpected command " + "line options: " + repr(sys.argv[1:])) sys.exit(1) ok = check_style(fixup) if ok: - print("TEST-PASS | check_spidermonkey_style.py | ok") + print('TEST-PASS | check_spidermonkey_style.py | ok') else: - print( - "TEST-UNEXPECTED-FAIL | check_spidermonkey_style.py | " - + "actual output does not match expected output; diff is above." - ) - print( - "TEST-UNEXPECTED-FAIL | check_spidermonkey_style.py | " - + "Hint: If the problem is that you renamed a header, and many #includes " - + "are no longer in alphabetical order, commit your work and then try " - + "`check_spidermonkey_style.py --fixup`. " - + "You need to commit first because --fixup modifies your files in place." - ) + print('TEST-UNEXPECTED-FAIL | check_spidermonkey_style.py | ' + + 'actual output does not match expected output; diff is above.') + print('TEST-UNEXPECTED-FAIL | check_spidermonkey_style.py | ' + + 'Hint: If the problem is that you renamed a header, and many #includes ' + + 'are no longer in alphabetical order, commit your work and then try ' + + '`check_spidermonkey_style.py --fixup`. ' + + 'You need to commit first because --fixup modifies your files in place.') sys.exit(0 if ok else 1) -if __name__ == "__main__": +if __name__ == '__main__': main() diff --git a/config/check_vanilla_allocations.py b/config/check_vanilla_allocations.py index 10578d8b6568750f017724d9ecea5373b2b9ee89..64e1c611b73cfbd27ca1cc540d772edb5983c0b1 100644 --- a/config/check_vanilla_allocations.py +++ b/config/check_vanilla_allocations.py @@ -62,40 +62,39 @@ has_failed = False def fail(msg): - print("TEST-UNEXPECTED-FAIL | check_vanilla_allocations.py |", msg) + print('TEST-UNEXPECTED-FAIL | check_vanilla_allocations.py |', msg) global has_failed has_failed = True def main(): parser = argparse.ArgumentParser() - parser.add_argument( - "--aggressive", - action="store_true", - help="also check for malloc, calloc, realloc and free", - ) - parser.add_argument("file", type=str, help="name of the file to check") + parser.add_argument('--aggressive', action='store_true', + help='also check for malloc, calloc, realloc and free') + parser.add_argument('file', type=str, + help='name of the file to check') args = parser.parse_args() # Run |nm|. Options: # -u: show only undefined symbols # -C: demangle symbol names # -A: show an object filename for each undefined symbol - nm = buildconfig.substs.get("NM") or "nm" - cmd = [nm, "-u", "-C", "-A", args.file] - lines = subprocess.check_output( - cmd, universal_newlines=True, stderr=subprocess.PIPE - ).split("\n") + nm = buildconfig.substs.get('NM') or 'nm' + cmd = [nm, '-u', '-C', '-A', args.file] + lines = subprocess.check_output(cmd, universal_newlines=True, + stderr=subprocess.PIPE).split('\n') # alloc_fns contains all the vanilla allocation/free functions that we look # for. Regexp chars are escaped appropriately. alloc_fns = [ # Matches |operator new(unsigned T)|, where |T| is |int| or |long|. - r"operator new\(unsigned", + r'operator new\(unsigned', + # Matches |operator new[](unsigned T)|, where |T| is |int| or |long|. - r"operator new\[\]\(unsigned", - r"memalign", + r'operator new\[\]\(unsigned', + + r'memalign', # These three aren't available on all Linux configurations. # r'posix_memalign', # r'aligned_alloc', @@ -103,17 +102,23 @@ def main(): ] if args.aggressive: - alloc_fns += [r"malloc", r"calloc", r"realloc", r"free", r"strdup"] + alloc_fns += [ + r'malloc', + r'calloc', + r'realloc', + r'free', + r'strdup' + ] # This is like alloc_fns, but regexp chars are not escaped. - alloc_fns_unescaped = [fn.replace("\\", "") for fn in alloc_fns] + alloc_fns_unescaped = [fn.replace('\\', '') for fn in alloc_fns] # This regexp matches the relevant lines in the output of |nm|, which look # like the following. # # js/src/libjs_static.a:Utility.o: U malloc # - alloc_fns_re = r"([^:/ ]+):\s+U (" + r"|".join(alloc_fns) + r")" + alloc_fns_re = r'([^:/ ]+):\s+U (' + r'|'.join(alloc_fns) + r')' # This tracks which allocation/free functions have been seen in # util/Utility.cpp. @@ -131,7 +136,7 @@ def main(): # The stdc++compat library has an implicit call to operator new in # thread::_M_start_thread. - if "stdc++compat" in filename: + if 'stdc++compat' in filename: continue # The memory allocator code contains calls to memalign. These are ok, so @@ -153,15 +158,15 @@ def main(): # From intl/icu/source/common/umutex.h: # On Linux, the default constructor of std::condition_variable_any # produces an in-line reference to global operator new(), [...]. - if filename == "umutex.o": + if filename == 'umutex.o': continue # Ignore allocations from decimal conversion functions inside mozglue. - if filename == "Decimal.o": + if filename == 'Decimal.o': continue fn = m.group(2) - if filename == "Utility.o": + if filename == 'Utility.o': util_Utility_cpp.add(fn) else: # An allocation is present in a non-special file. Fail! @@ -179,51 +184,45 @@ def main(): # This should never happen, but check just in case. if util_Utility_cpp: - fail( - "unexpected allocation fns used in util/Utility.cpp: " - + ", ".join(util_Utility_cpp) - ) + fail('unexpected allocation fns used in util/Utility.cpp: ' + + ', '.join(util_Utility_cpp)) # If we found any improper references to allocation functions, try to use # DWARF debug info to get more accurate line number information about the # bad calls. This is a lot slower than 'nm -A', and it is not always # precise when building with --enable-optimized. if emit_line_info: - print("check_vanilla_allocations.py: Source lines with allocation calls:") - print( - "check_vanilla_allocations.py: Accurate in unoptimized builds; " - "util/Utility.cpp expected." - ) + print('check_vanilla_allocations.py: Source lines with allocation calls:') + print('check_vanilla_allocations.py: Accurate in unoptimized builds; ' + 'util/Utility.cpp expected.') # Run |nm|. Options: # -u: show only undefined symbols # -C: demangle symbol names # -l: show line number information for each undefined symbol - cmd = ["nm", "-u", "-C", "-l", args.file] - lines = subprocess.check_output( - cmd, universal_newlines=True, stderr=subprocess.PIPE - ).split("\n") + cmd = ['nm', '-u', '-C', '-l', args.file] + lines = subprocess.check_output(cmd, universal_newlines=True, + stderr=subprocess.PIPE).split('\n') # This regexp matches the relevant lines in the output of |nm -l|, # which look like the following. # # U malloc util/Utility.cpp:117 # - alloc_lines_re = r"U ((" + r"|".join(alloc_fns) + r").*)\s+(\S+:\d+)$" + alloc_lines_re = r'U ((' + r'|'.join(alloc_fns) + r').*)\s+(\S+:\d+)$' for line in lines: m = re.search(alloc_lines_re, line) if m: - print( - "check_vanilla_allocations.py:", m.group(1), "called at", m.group(3) - ) + print('check_vanilla_allocations.py:', + m.group(1), 'called at', m.group(3)) if has_failed: sys.exit(1) - print("TEST-PASS | check_vanilla_allocations.py | ok") + print('TEST-PASS | check_vanilla_allocations.py | ok') sys.exit(0) -if __name__ == "__main__": +if __name__ == '__main__': main() diff --git a/config/create_rc.py b/config/create_rc.py index 973bb5b44e776250f9e45ba3439e26b411200c75..f3c366e2386ae632f608cbda985a3da5d4bc55c8 100644 --- a/config/create_rc.py +++ b/config/create_rc.py @@ -11,7 +11,7 @@ from mozbuild.preprocessor import Preprocessor import buildconfig -TEMPLATE = """ +TEMPLATE = ''' // 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/. @@ -65,15 +65,15 @@ BEGIN END END -""" +''' def preprocess(path, defines): - pp = Preprocessor(defines=defines, marker="%") + pp = Preprocessor(defines=defines, marker='%') pp.context.update(defines) pp.out = io.StringIO() - pp.do_filter("substitution") - pp.do_include(io.open(path, "r", encoding="latin1")) + pp.do_filter('substitution') + pp.do_include(io.open(path, 'r', encoding='latin1')) pp.out.seek(0) return pp.out @@ -81,23 +81,23 @@ def preprocess(path, defines): def parse_module_ver(path, defines): result = {} for line in preprocess(path, defines): - content, *comment = line.split("#", 1) + content, *comment = line.split('#', 1) if not content.strip(): continue - entry, value = content.split("=", 1) + entry, value = content.split('=', 1) result[entry.strip()] = value.strip() return result def get_buildid(): - path = os.path.join(buildconfig.topobjdir, "buildid.h") - define, MOZ_BUILDID, buildid = io.open(path, "r", encoding="utf-8").read().split() + path = os.path.join(buildconfig.topobjdir, 'buildid.h') + define, MOZ_BUILDID, buildid = io.open(path, 'r', encoding='utf-8').read().split() return buildid def days_from_2000_to_buildid(buildid): start = datetime(2000, 1, 1, 0, 0, 0) - buildid_time = datetime.strptime(buildid, "%Y%m%d%H%M%S") + buildid_time = datetime.strptime(buildid, '%Y%m%d%H%M%S') return (buildid_time - start).days @@ -105,11 +105,11 @@ def digits_only(s): for l in range(len(s), 0, -1): if s[:l].isdigit(): return s[:l] - return "0" + return '0' def split_and_normalize_version(version, len): - return ([digits_only(x) for x in version.split(".")] + ["0"] * len)[:len] + return ([digits_only(x) for x in version.split('.')] + ['0'] * len)[:len] def has_manifest(module_rc, manifest_id): @@ -118,43 +118,41 @@ def has_manifest(module_rc, manifest_id): if len(line) < 2: continue id, what, *rest = line - if id == manifest_id and what in ("24", "RT_MANIFEST"): + if id == manifest_id and what in ('24', 'RT_MANIFEST'): return True return False -def generate_module_rc(binary="", rcinclude=None): +def generate_module_rc(binary='', rcinclude=None): deps = set() buildid = get_buildid() - milestone = buildconfig.substs["GRE_MILESTONE"] - app_version = buildconfig.substs.get("MOZ_APP_VERSION") or milestone - app_winversion = ",".join(split_and_normalize_version(app_version, 4)) - milestone_winversion = ",".join( - split_and_normalize_version(milestone, 3) - + [str(days_from_2000_to_buildid(buildid))] - ) - display_name = buildconfig.substs.get("MOZ_APP_DISPLAYNAME", "Mozilla") + milestone = buildconfig.substs['GRE_MILESTONE'] + app_version = buildconfig.substs.get('MOZ_APP_VERSION') or milestone + app_winversion = ','.join(split_and_normalize_version(app_version, 4)) + milestone_winversion = ','.join(split_and_normalize_version(milestone, 3) + + [str(days_from_2000_to_buildid(buildid))]) + display_name = buildconfig.substs.get('MOZ_APP_DISPLAYNAME', 'Mozilla') milestone_string = milestone - flags = ["0"] - if buildconfig.substs.get("MOZ_DEBUG"): - flags.append("VS_FF_DEBUG") - milestone_string += " Debug" - if not buildconfig.substs.get("MOZILLA_OFFICIAL"): - flags.append("VS_FF_PRIVATEBUILD") - if buildconfig.substs.get("NIGHTLY_BUILD"): - flags.append("VS_FF_PRERELEASE") + flags = ['0'] + if buildconfig.substs.get('MOZ_DEBUG'): + flags.append('VS_FF_DEBUG') + milestone_string += ' Debug' + if not buildconfig.substs.get('MOZILLA_OFFICIAL'): + flags.append('VS_FF_PRIVATEBUILD') + if buildconfig.substs.get('NIGHTLY_BUILD'): + flags.append('VS_FF_PRERELEASE') defines = { - "MOZ_APP_DISPLAYNAME": display_name, - "MOZ_APP_VERSION": app_version, - "MOZ_APP_WINVERSION": app_winversion, + 'MOZ_APP_DISPLAYNAME': display_name, + 'MOZ_APP_VERSION': app_version, + 'MOZ_APP_WINVERSION': app_winversion, } - relobjdir = os.path.relpath(".", buildconfig.topobjdir) + relobjdir = os.path.relpath('.', buildconfig.topobjdir) srcdir = os.path.join(buildconfig.topsrcdir, relobjdir) - module_ver = os.path.join(srcdir, "module.ver") + module_ver = os.path.join(srcdir, 'module.ver') if os.path.exists(module_ver): deps.add(module_ver) overrides = parse_module_ver(module_ver, defines) @@ -162,42 +160,39 @@ def generate_module_rc(binary="", rcinclude=None): overrides = {} if rcinclude: - include = "// From included resource {}\n{}".format( - rcinclude, preprocess(rcinclude, defines).read() - ) + include = '// From included resource {}\n{}'.format( + rcinclude, preprocess(rcinclude, defines).read()) else: - include = "" + include = '' data = TEMPLATE.format( include=include, - fileversion=overrides.get("WIN32_MODULE_FILEVERSION", milestone_winversion), - productversion=overrides.get( - "WIN32_MODULE_PRODUCTVERSION", milestone_winversion - ), - fileflags=" | ".join(flags), - comment=overrides.get("WIN32_MODULE_COMMENT", ""), - copyright=overrides.get("WIN32_MODULE_COPYRIGHT", "License: MPL 2"), - company=overrides.get("WIN32_MODULE_COMPANYNAME", "Mozilla Foundation"), - description=overrides.get("WIN32_MODULE_DESCRIPTION", ""), - mfversion=overrides.get("WIN32_MODULE_FILEVERSION_STRING", milestone_string), - mpversion=overrides.get("WIN32_MODULE_PRODUCTVERSION_STRING", milestone_string), - module=overrides.get("WIN32_MODULE_NAME", ""), - trademarks=overrides.get("WIN32_MODULE_TRADEMARKS", "Mozilla"), - binary=overrides.get("WIN32_MODULE_ORIGINAL_FILENAME", binary), - productname=overrides.get("WIN32_MODULE_PRODUCTNAME", display_name), + fileversion=overrides.get('WIN32_MODULE_FILEVERSION', milestone_winversion), + productversion=overrides.get('WIN32_MODULE_PRODUCTVERSION', milestone_winversion), + fileflags=' | '.join(flags), + comment=overrides.get('WIN32_MODULE_COMMENT', ''), + copyright=overrides.get('WIN32_MODULE_COPYRIGHT', 'License: MPL 2'), + company=overrides.get('WIN32_MODULE_COMPANYNAME', 'Mozilla Foundation'), + description=overrides.get('WIN32_MODULE_DESCRIPTION', ''), + mfversion=overrides.get('WIN32_MODULE_FILEVERSION_STRING', milestone_string), + mpversion=overrides.get('WIN32_MODULE_PRODUCTVERSION_STRING', milestone_string), + module=overrides.get('WIN32_MODULE_NAME', ''), + trademarks=overrides.get('WIN32_MODULE_TRADEMARKS', 'Mozilla'), + binary=overrides.get('WIN32_MODULE_ORIGINAL_FILENAME', binary), + productname=overrides.get('WIN32_MODULE_PRODUCTNAME', display_name), buildid=buildid, ) - manifest_id = "2" if binary.lower().endswith(".dll") else "1" + manifest_id = '2' if binary.lower().endswith('.dll') else '1' if binary and not has_manifest(data, manifest_id): - manifest_path = os.path.join(srcdir, binary + ".manifest") + manifest_path = os.path.join(srcdir, binary + '.manifest') if os.path.exists(manifest_path): - manifest_path = manifest_path.replace("\\", "\\\\") + manifest_path = manifest_path.replace('\\', '\\\\') data += '\n{} RT_MANIFEST "{}"\n'.format(manifest_id, manifest_path) - with io.open("{}.rc".format(binary or "module"), "w", encoding="latin1") as fh: + with io.open('{}.rc'.format(binary or 'module'), 'w', encoding='latin1') as fh: fh.write(data) -if __name__ == "__main__": +if __name__ == '__main__': generate_module_rc(*sys.argv[1:]) diff --git a/config/create_res.py b/config/create_res.py index 5588fa0a4900dc73d38ba860460aef16fc81df54..bfa69aafbcf650b3fc684dece71c8a50963eb97f 100644 --- a/config/create_res.py +++ b/config/create_res.py @@ -18,31 +18,27 @@ class CPPFlag(Action): all_flags = [] def __call__(self, parser, namespace, values, option_string=None): - if "windres" in buildconfig.substs["RC"].lower(): - if option_string == "-U": + if 'windres' in buildconfig.substs['RC'].lower(): + if option_string == '-U': return - if option_string == "-I": - option_string = "--include-dir" + if option_string == '-I': + option_string = '--include-dir' self.all_flags.extend((option_string, values)) def generate_res(): parser = ArgumentParser() - parser.add_argument( - "-D", action=CPPFlag, metavar="VAR[=VAL]", help="Define a variable" - ) - parser.add_argument("-U", action=CPPFlag, metavar="VAR", help="Undefine a variable") - parser.add_argument( - "-I", action=CPPFlag, metavar="DIR", help="Search path for includes" - ) - parser.add_argument("-o", dest="output", metavar="OUTPUT", help="Output file") - parser.add_argument("input", help="Input file") + parser.add_argument('-D', action=CPPFlag, metavar='VAR[=VAL]', help='Define a variable') + parser.add_argument('-U', action=CPPFlag, metavar='VAR', help='Undefine a variable') + parser.add_argument('-I', action=CPPFlag, metavar='DIR', help='Search path for includes') + parser.add_argument('-o', dest='output', metavar='OUTPUT', help='Output file') + parser.add_argument('input', help='Input file') args = parser.parse_args() - is_windres = "windres" in buildconfig.substs["RC"].lower() + is_windres = 'windres' in buildconfig.substs['RC'].lower() - verbose = os.environ.get("BUILD_VERBOSE_LOG") + verbose = os.environ.get('BUILD_VERBOSE_LOG') # llvm-rc doesn't preprocess on its own, so preprocess manually # Theoretically, not windres could be rc.exe, but configure won't use it @@ -50,12 +46,12 @@ def generate_res(): # output. try: if not is_windres: - fd, path = tempfile.mkstemp(suffix=".rc") - command = buildconfig.substs["CXXCPP"] + CPPFlag.all_flags - command.extend(("-DRC_INVOKED", args.input)) + fd, path = tempfile.mkstemp(suffix='.rc') + command = buildconfig.substs['CXXCPP'] + CPPFlag.all_flags + command.extend(('-DRC_INVOKED', args.input)) if verbose: - print("Executing:", " ".join(command)) - with os.fdopen(fd, "wb") as fh: + print('Executing:', ' '.join(command)) + with os.fdopen(fd, 'wb') as fh: retcode = subprocess.run(command, stdout=fh).returncode if retcode: # Rely on the subprocess printing out any relevant error @@ -63,9 +59,9 @@ def generate_res(): else: path = args.input - command = [buildconfig.substs["RC"]] + command = [buildconfig.substs['RC']] if is_windres: - command.extend(("-O", "coff")) + command.extend(('-O', 'coff')) # Even though llvm-rc doesn't preprocess, we still need to pass at least # the -I flags. @@ -73,15 +69,15 @@ def generate_res(): if args.output: if is_windres: - command.extend(("-o", args.output)) + command.extend(('-o', args.output)) else: # Use win1252 code page for the input. - command.extend(("-c", "1252", "-Fo" + args.output)) + command.extend(('-c', '1252', '-Fo' + args.output)) command.append(path) if verbose: - print("Executing:", " ".join(command)) + print('Executing:', ' '.join(command)) retcode = subprocess.run(command).returncode if retcode: # Rely on the subprocess printing out any relevant error @@ -93,5 +89,5 @@ def generate_res(): return 0 -if __name__ == "__main__": +if __name__ == '__main__': sys.exit(generate_res()) diff --git a/config/createprecomplete.py b/config/createprecomplete.py index dda4efcdf8e194c8fdd656837fa5f1e67a1c8101..fadd796aa21f404b6c5f8fe4495842a806ef7821 100644 --- a/config/createprecomplete.py +++ b/config/createprecomplete.py @@ -14,27 +14,25 @@ import io def get_build_entries(root_path): - """Iterates through the root_path, creating a list for each file and - directory. Excludes any file paths ending with channel-prefs.js. + """ Iterates through the root_path, creating a list for each file and + directory. Excludes any file paths ending with channel-prefs.js. """ rel_file_path_set = set() rel_dir_path_set = set() for root, dirs, files in os.walk(root_path): for file_name in files: - parent_dir_rel_path = root[len(root_path) + 1 :] + parent_dir_rel_path = root[len(root_path)+1:] rel_path_file = os.path.join(parent_dir_rel_path, file_name) rel_path_file = rel_path_file.replace("\\", "/") - if not ( - rel_path_file.endswith("channel-prefs.js") - or rel_path_file.endswith("update-settings.ini") - or rel_path_file.find("distribution/") != -1 - ): + if not (rel_path_file.endswith("channel-prefs.js") or + rel_path_file.endswith("update-settings.ini") or + rel_path_file.find("distribution/") != -1): rel_file_path_set.add(rel_path_file) for dir_name in dirs: - parent_dir_rel_path = root[len(root_path) + 1 :] + parent_dir_rel_path = root[len(root_path)+1:] rel_path_dir = os.path.join(parent_dir_rel_path, dir_name) - rel_path_dir = rel_path_dir.replace("\\", "/") + "/" + rel_path_dir = rel_path_dir.replace("\\", "/")+"/" if rel_path_dir.find("distribution/") == -1: rel_dir_path_set.add(rel_path_dir) @@ -47,26 +45,26 @@ def get_build_entries(root_path): def generate_precomplete(root_path): - """Creates the precomplete file containing the remove and rmdir - application update instructions. The given directory is used - for the location to enumerate and to create the precomplete file. + """ Creates the precomplete file containing the remove and rmdir + application update instructions. The given directory is used + for the location to enumerate and to create the precomplete file. """ rel_path_precomplete = "precomplete" # If inside a Mac bundle use the root of the bundle for the path. if os.path.basename(root_path) == "Resources": - root_path = os.path.abspath(os.path.join(root_path, "../../")) + root_path = os.path.abspath(os.path.join(root_path, '../../')) rel_path_precomplete = "Contents/Resources/precomplete" precomplete_file_path = os.path.join(root_path, rel_path_precomplete) # Open the file so it exists before building the list of files and open it # in binary mode to prevent OS specific line endings. - precomplete_file = io.open(precomplete_file_path, mode="wt", newline="\n") + precomplete_file = io.open(precomplete_file_path, mode="wt", newline='\n') rel_file_path_list, rel_dir_path_list = get_build_entries(root_path) for rel_file_path in rel_file_path_list: - precomplete_file.write('remove "' + rel_file_path + '"\n') + precomplete_file.write("remove \""+rel_file_path+"\"\n") for rel_dir_path in rel_dir_path_list: - precomplete_file.write('rmdir "' + rel_dir_path + '"\n') + precomplete_file.write("rmdir \""+rel_dir_path+"\"\n") precomplete_file.close() diff --git a/config/external/fdlibm/moz.build b/config/external/fdlibm/moz.build index 343645f0ce8f91d90fa95fa729cf8420708d20c0..51caca5328d73ac218310ea4e06451cd3fb1a8f4 100644 --- a/config/external/fdlibm/moz.build +++ b/config/external/fdlibm/moz.build @@ -4,9 +4,9 @@ # 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/. -with Files("**"): - BUG_COMPONENT = ("Core", "JavaScript Engine") +with Files('**'): + BUG_COMPONENT = ('Core', 'JavaScript Engine') DIRS += [ - "../../../modules/fdlibm", + '../../../modules/fdlibm', ] diff --git a/config/external/ffi/moz.build b/config/external/ffi/moz.build index 682dc9933de26c6bae663a2d3569396b5ece2848..6d3ab38e802536c11e5c79ed3bbe85ee466d7812 100644 --- a/config/external/ffi/moz.build +++ b/config/external/ffi/moz.build @@ -4,148 +4,133 @@ # 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/. -FINAL_LIBRARY = "js" +FINAL_LIBRARY = 'js' -if CONFIG["MOZ_SYSTEM_FFI"]: - OS_LIBS += CONFIG["MOZ_FFI_LIBS"] +if CONFIG['MOZ_SYSTEM_FFI']: + OS_LIBS += CONFIG['MOZ_FFI_LIBS'] else: AllowCompilerWarnings() NoVisibilityFlags() CONFIGURE_DEFINE_FILES += [ - "/js/src/ctypes/libffi/fficonfig.h", + '/js/src/ctypes/libffi/fficonfig.h', ] LOCAL_INCLUDES += [ - "!/js/src/ctypes/libffi", - "!/js/src/ctypes/libffi/include", - "/js/src/ctypes/libffi/include", - "/js/src/ctypes/libffi/src/%s" % CONFIG["FFI_TARGET_DIR"], + '!/js/src/ctypes/libffi', + '!/js/src/ctypes/libffi/include', + '/js/src/ctypes/libffi/include', + '/js/src/ctypes/libffi/src/%s' % CONFIG['FFI_TARGET_DIR'], ] - DEFINES["TARGET"] = CONFIG["FFI_TARGET"] - DEFINES[CONFIG["FFI_TARGET"]] = True - DEFINES["FFI_NO_RAW_API"] = True - DEFINES["FFI_BUILDING"] = True - DEFINES["HAVE_AS_ASCII_PSEUDO_OP"] = True - DEFINES["HAVE_AS_STRING_PSEUDO_OP"] = True - - if CONFIG["MOZ_DEBUG"]: - DEFINES["FFI_DEBUG"] = True - if not CONFIG["MOZ_NO_DEBUG_RTL"]: - DEFINES["USE_DEBUG_RTL"] = True + DEFINES['TARGET'] = CONFIG['FFI_TARGET'] + DEFINES[CONFIG['FFI_TARGET']] = True + DEFINES['FFI_NO_RAW_API'] = True + DEFINES['FFI_BUILDING'] = True + DEFINES['HAVE_AS_ASCII_PSEUDO_OP'] = True + DEFINES['HAVE_AS_STRING_PSEUDO_OP'] = True + + if CONFIG['MOZ_DEBUG']: + DEFINES['FFI_DEBUG'] = True + if not CONFIG['MOZ_NO_DEBUG_RTL']: + DEFINES['USE_DEBUG_RTL'] = True SOURCES += [ - "/js/src/ctypes/libffi/src/debug.c", + '/js/src/ctypes/libffi/src/debug.c', ] - if CONFIG["OS_TARGET"] != "WINNT": - DEFINES["HAVE_HIDDEN_VISIBILITY_ATTRIBUTE"] = True + if CONFIG['OS_TARGET'] != 'WINNT': + DEFINES['HAVE_HIDDEN_VISIBILITY_ATTRIBUTE'] = True - if CONFIG["INTEL_ARCHITECTURE"]: - DEFINES["HAVE_AS_X86_PCREL"] = True + if CONFIG['INTEL_ARCHITECTURE']: + DEFINES['HAVE_AS_X86_PCREL'] = True # Don't bother setting EH_FRAME_FLAGS on Windows. # Quoted defines confuse msvcc.sh, and the value isn't used there. - if CONFIG["OS_TARGET"] != "WINNT": - if CONFIG["FFI_TARGET"] == "ARM": - DEFINES["EH_FRAME_FLAGS"] = '"aw"' + if CONFIG['OS_TARGET'] != 'WINNT': + if CONFIG['FFI_TARGET'] == 'ARM': + DEFINES['EH_FRAME_FLAGS'] = '"aw"' else: - DEFINES["EH_FRAME_FLAGS"] = '"a"' + DEFINES['EH_FRAME_FLAGS'] = '"a"' # Common source files. SOURCES += [ - "/js/src/ctypes/libffi/src/closures.c", - "/js/src/ctypes/libffi/src/java_raw_api.c", - "/js/src/ctypes/libffi/src/prep_cif.c", - "/js/src/ctypes/libffi/src/raw_api.c", - "/js/src/ctypes/libffi/src/types.c", + '/js/src/ctypes/libffi/src/closures.c', + '/js/src/ctypes/libffi/src/java_raw_api.c', + '/js/src/ctypes/libffi/src/prep_cif.c', + '/js/src/ctypes/libffi/src/raw_api.c', + '/js/src/ctypes/libffi/src/types.c', ] # Per-platform sources and flags. ffi_srcs = () ffi_h_defines = [] - if CONFIG["FFI_TARGET"] == "X86_WIN64": - if CONFIG["CC_TYPE"] == "clang-cl": - ffi_srcs = ("ffiw64.c",) + if CONFIG['FFI_TARGET'] == 'X86_WIN64': + if CONFIG['CC_TYPE'] == 'clang-cl': + ffi_srcs = ('ffiw64.c',) # libffi asm needs to be preprocessed for MSVC's assembler - GeneratedFile( - "win64_intel.asm", - inputs=[ - "/js/src/ctypes/libffi/src/x86/win64_intel.S", - "!/js/src/ctypes/libffi/fficonfig.h", - "!/js/src/ctypes/libffi/include/ffi.h", - ], - script="preprocess_libffi_asm.py", - flags=["$(DEFINES)", "$(LOCAL_INCLUDES)"], - ) - SOURCES += ["!win64_intel.asm"] + GeneratedFile('win64_intel.asm', inputs=[ + '/js/src/ctypes/libffi/src/x86/win64_intel.S', + '!/js/src/ctypes/libffi/fficonfig.h', + '!/js/src/ctypes/libffi/include/ffi.h', + ], script='preprocess_libffi_asm.py', + flags=['$(DEFINES)', '$(LOCAL_INCLUDES)']) + SOURCES += ['!win64_intel.asm'] else: - ffi_srcs = ("ffiw64.c", "win64.S") + ffi_srcs = ('ffiw64.c', 'win64.S') - elif CONFIG["FFI_TARGET"] == "X86_64": - DEFINES["HAVE_AS_X86_64_UNWIND_SECTION_TYPE"] = True - ffi_srcs = ("ffi64.c", "unix64.S", "ffiw64.c", "win64.S") + elif CONFIG['FFI_TARGET'] == 'X86_64': + DEFINES['HAVE_AS_X86_64_UNWIND_SECTION_TYPE'] = True + ffi_srcs = ('ffi64.c', 'unix64.S', 'ffiw64.c', 'win64.S') - elif CONFIG["FFI_TARGET"] == "X86_WIN32" and CONFIG["CC_TYPE"] == "clang-cl": - ffi_srcs = ("ffi.c",) + elif CONFIG['FFI_TARGET'] == 'X86_WIN32' and CONFIG['CC_TYPE'] == 'clang-cl': + ffi_srcs = ('ffi.c',) # libffi asm needs to be preprocessed for MSVC's assembler - GeneratedFile( - "sysv_intel.asm", - inputs=[ - "/js/src/ctypes/libffi/src/x86/sysv_intel.S", - "!/js/src/ctypes/libffi/fficonfig.h", - "!/js/src/ctypes/libffi/include/ffi.h", - ], - script="preprocess_libffi_asm.py", - flags=["$(DEFINES)", "$(LOCAL_INCLUDES)"], - ) - SOURCES += ["!sysv_intel.asm"] - ASFLAGS += ["-safeseh"] - - elif CONFIG["FFI_TARGET"] == "ARM_WIN64": - ffi_srcs = ("ffi.c",) + GeneratedFile('sysv_intel.asm', inputs=[ + '/js/src/ctypes/libffi/src/x86/sysv_intel.S', + '!/js/src/ctypes/libffi/fficonfig.h', + '!/js/src/ctypes/libffi/include/ffi.h', + ], script='preprocess_libffi_asm.py', + flags=['$(DEFINES)', '$(LOCAL_INCLUDES)']) + SOURCES += ['!sysv_intel.asm'] + ASFLAGS += ['-safeseh'] + + elif CONFIG['FFI_TARGET'] == 'ARM_WIN64': + ffi_srcs = ('ffi.c',) # libffi asm needs to be preprocessed for MSVC's assembler GeneratedFile( - "win64_armasm.asm", + 'win64_armasm.asm', inputs=[ - "/js/src/ctypes/libffi/src/aarch64/win64_armasm.S", - "!/js/src/ctypes/libffi/fficonfig.h", - "!/js/src/ctypes/libffi/include/ffi.h", + '/js/src/ctypes/libffi/src/aarch64/win64_armasm.S', + '!/js/src/ctypes/libffi/fficonfig.h', + '!/js/src/ctypes/libffi/include/ffi.h', ], - script="preprocess_libffi_asm.py", - flags=["$(DEFINES)", "$(LOCAL_INCLUDES)"], - ) - SOURCES += ["!win64_armasm.asm"] + script='preprocess_libffi_asm.py', + flags=['$(DEFINES)', '$(LOCAL_INCLUDES)']) + SOURCES += ['!win64_armasm.asm'] else: - ffi_srcs = ("ffi.c", "sysv.S") - if CONFIG["FFI_TARGET"] == "ARM" and CONFIG["CC_TYPE"] == "clang": - ASFLAGS += ["-no-integrated-as"] - - if CONFIG["FFI_TARGET"] in ("X86_WIN32", "X86_DARWIN") and CONFIG["CC_TYPE"] in ( - "gcc", - "clang", - ): - DEFINES["SYMBOL_UNDERSCORE"] = True - - if CONFIG["OS_ARCH"] == "Darwin" and CONFIG["CPU_ARCH"] in ("arm", "aarch64"): - DEFINES["FFI_EXEC_TRAMPOLINE_TABLE"] = True - ffi_h_defines.append("FFI_EXEC_TRAMPOLINE_TABLE") - - elif ( - CONFIG["OS_ARCH"] in ("Darwin", "FreeBSD", "GNU_kFreeBSD", "OpenBSD", "SunOS") - or CONFIG["OS_TARGET"] == "Android" - ): - DEFINES["FFI_MMAP_EXEC_WRIT"] = True + ffi_srcs = ('ffi.c', 'sysv.S') + if CONFIG['FFI_TARGET'] == 'ARM' and CONFIG['CC_TYPE'] == 'clang': + ASFLAGS += ['-no-integrated-as'] + + if CONFIG['FFI_TARGET'] in ('X86_WIN32', 'X86_DARWIN') and \ + CONFIG['CC_TYPE'] in ('gcc', 'clang'): + DEFINES['SYMBOL_UNDERSCORE'] = True + + if CONFIG['OS_ARCH'] == 'Darwin' and CONFIG['CPU_ARCH'] in ('arm', 'aarch64'): + DEFINES['FFI_EXEC_TRAMPOLINE_TABLE'] = True + ffi_h_defines.append('FFI_EXEC_TRAMPOLINE_TABLE') + + elif CONFIG['OS_ARCH'] in ('Darwin', 'FreeBSD', 'GNU_kFreeBSD', 'OpenBSD', 'SunOS') or \ + CONFIG['OS_TARGET'] == 'Android': + DEFINES['FFI_MMAP_EXEC_WRIT'] = True SOURCES += [ - "/js/src/ctypes/libffi/src/%s/%s" % (CONFIG["FFI_TARGET_DIR"], s) + '/js/src/ctypes/libffi/src/%s/%s' % (CONFIG['FFI_TARGET_DIR'], s) for s in sorted(ffi_srcs) ] - GeneratedFile( - "/js/src/ctypes/libffi/include/ffi.h", - script="subst_header.py", - inputs=["/js/src/ctypes/libffi/include/ffi.h.in"], - flags=ffi_h_defines, - ) + GeneratedFile('/js/src/ctypes/libffi/include/ffi.h', + script='subst_header.py', + inputs=['/js/src/ctypes/libffi/include/ffi.h.in'], + flags=ffi_h_defines) diff --git a/config/external/ffi/preprocess_libffi_asm.py b/config/external/ffi/preprocess_libffi_asm.py index 69e65be5ea89e9f243c7d8baa6128f531be9502a..81ce51d6fa2fa95208046f49c18ee26ffc759be0 100644 --- a/config/external/ffi/preprocess_libffi_asm.py +++ b/config/external/ffi/preprocess_libffi_asm.py @@ -18,9 +18,9 @@ def main(output, input_asm, ffi_h, ffi_config_h, defines, includes): includes = shlex.split(includes) # CPP uses -E which generates #line directives. -EP suppresses them. # -TC forces the compiler to treat the input as C. - cpp = buildconfig.substs["CPP"] + ["-EP"] + ["-TC"] + cpp = buildconfig.substs['CPP'] + ['-EP'] + ['-TC'] input_asm = mozpath.relpath(input_asm, os.getcwd()) args = cpp + defines + includes + [input_asm] - print(" ".join(args)) + print(' '.join(args)) preprocessed = subprocess.check_output(args) output.write(preprocessed) diff --git a/config/external/ffi/subst_header.py b/config/external/ffi/subst_header.py index 7614cfd92fd5f53e863b5922532bc847c527a089..da48e2fca25545a7a63b778f68912cc206c83de5 100644 --- a/config/external/ffi/subst_header.py +++ b/config/external/ffi/subst_header.py @@ -12,21 +12,19 @@ from mozbuild.preprocessor import Preprocessor def main(output, input_file, *defines): pp = Preprocessor() - pp.context.update( - { - "FFI_EXEC_TRAMPOLINE_TABLE": "0", - "HAVE_LONG_DOUBLE": "0", - "TARGET": buildconfig.substs["FFI_TARGET"], - "VERSION": "", - } - ) + pp.context.update({ + 'FFI_EXEC_TRAMPOLINE_TABLE': '0', + 'HAVE_LONG_DOUBLE': '0', + 'TARGET': buildconfig.substs['FFI_TARGET'], + 'VERSION': '', + }) for d in defines: - pp.context.update({d: "1"}) - pp.do_filter("substitution") + pp.context.update({d: '1'}) + pp.do_filter('substitution') pp.setMarker(None) pp.out = output pp.do_include(input_file) -if __name__ == "__main__": +if __name__ == '__main__': main(*sys.agv[1:]) diff --git a/config/external/freetype2/moz.build b/config/external/freetype2/moz.build index 3d025e1ee4c645b43cb2f13e613e33f58c952d16..1c13f39fbf113f4af82f4602e402af0bab7f1d51 100644 --- a/config/external/freetype2/moz.build +++ b/config/external/freetype2/moz.build @@ -4,11 +4,11 @@ # 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/. -Library("freetype") +Library('freetype') -if CONFIG["MOZ_TREE_FREETYPE"]: +if CONFIG['MOZ_TREE_FREETYPE']: DIRS += [ - "/modules/freetype2", + '/modules/freetype2', ] else: - OS_LIBS += CONFIG["FT2_LIBS"] + OS_LIBS += CONFIG['FT2_LIBS'] diff --git a/config/external/icu/common/moz.build b/config/external/icu/common/moz.build index ce1b0d05748b42e4f6a601e25ec1f39a4f01c54c..6b1e02c20336ce4c6f903d5390323d79802f8a2e 100644 --- a/config/external/icu/common/moz.build +++ b/config/external/icu/common/moz.build @@ -4,30 +4,30 @@ # 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/. -Library("icuuc") -FINAL_LIBRARY = "icu" +Library('icuuc') +FINAL_LIBRARY = 'icu' -DEFINES["U_COMMON_IMPLEMENTATION"] = True +DEFINES['U_COMMON_IMPLEMENTATION'] = True -LOCAL_INCLUDES += ["/intl/icu/source/i18n"] +LOCAL_INCLUDES += ['/intl/icu/source/i18n'] -if CONFIG["CC_TYPE"] in ("clang", "gcc"): +if CONFIG['CC_TYPE'] in ('clang', 'gcc'): CXXFLAGS += [ - "-Wno-deprecated-declarations", - "-Wno-type-limits", - "-Wno-unused-but-set-variable", - "-Wno-unused-function", - "-Wno-sign-compare", - "-Wno-maybe-uninitialized", + '-Wno-deprecated-declarations', + '-Wno-type-limits', + '-Wno-unused-but-set-variable', + '-Wno-unused-function', + '-Wno-sign-compare', + '-Wno-maybe-uninitialized', ] -include("../defs.mozbuild") -include("sources.mozbuild") +include('../defs.mozbuild') +include('sources.mozbuild') SOURCES += sources -if CONFIG["TARGET_ENDIANNESS"] == "big": - HostLibrary("host_icuuc") - HOST_DEFINES["U_COMMON_IMPLEMENTATION"] = True +if CONFIG['TARGET_ENDIANNESS'] == 'big': + HostLibrary('host_icuuc') + HOST_DEFINES['U_COMMON_IMPLEMENTATION'] = True HOST_SOURCES += sources HOST_SOURCES += other_sources diff --git a/config/external/icu/data/convert_icudata.py b/config/external/icu/data/convert_icudata.py index c8c18f9e0196b2a38e5fe8834353dfa78651907e..c6cb2bdfc565ca811bbb2c9ad08200016eb46545 100644 --- a/config/external/icu/data/convert_icudata.py +++ b/config/external/icu/data/convert_icudata.py @@ -10,11 +10,9 @@ import buildconfig def main(output, data_file): output.close() - subprocess.run( - [ - os.path.join(buildconfig.topobjdir, "dist", "host", "bin", "icupkg"), - "-tb", - data_file, - output.name, - ] - ) + subprocess.run([ + os.path.join(buildconfig.topobjdir, 'dist', 'host', 'bin', 'icupkg'), + '-tb', + data_file, + output.name, + ]) diff --git a/config/external/icu/data/moz.build b/config/external/icu/data/moz.build index a2b7cbe8bbcaf8655f6003bc8ceb075d62dfb804..9033631336a35573cb68662ce1a025db8ef42c8f 100644 --- a/config/external/icu/data/moz.build +++ b/config/external/icu/data/moz.build @@ -6,35 +6,33 @@ # Build a library containing the ICU data for use in the JS shell, so that # JSAPI consumers don't have to deal with setting ICU's data path. -Library("icudata") +Library('icudata') -LOCAL_INCLUDES += ["."] +LOCAL_INCLUDES += ['.'] -prefix = "" -if (CONFIG["OS_ARCH"] == "WINNT" and CONFIG["CPU_ARCH"] == "x86") or CONFIG[ - "OS_ARCH" -] == "Darwin": - prefix = "_" +prefix = '' +if (CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CPU_ARCH'] == 'x86') or CONFIG['OS_ARCH'] == 'Darwin': + prefix = '_' data_file = { - "little": "icudt%sl.dat" % CONFIG["MOZ_ICU_VERSION"], - "big": "icudt%sb.dat" % CONFIG["MOZ_ICU_VERSION"], + 'little': 'icudt%sl.dat' % CONFIG['MOZ_ICU_VERSION'], + 'big': 'icudt%sb.dat' % CONFIG['MOZ_ICU_VERSION'], } data_dir = { - "little": SRCDIR, - "big": OBJDIR, + 'little': SRCDIR, + 'big': OBJDIR, } -endianness = CONFIG.get("TARGET_ENDIANNESS", "little") -DEFINES["ICU_DATA_FILE"] = '"%s/%s"' % (data_dir[endianness], data_file[endianness]) -DEFINES["ICU_DATA_SYMBOL"] = "%sicudt%s_dat" % (prefix, CONFIG["MOZ_ICU_VERSION"]) +endianness = CONFIG.get('TARGET_ENDIANNESS', 'little') +DEFINES['ICU_DATA_FILE'] = '"%s/%s"' % (data_dir[endianness], data_file[endianness]) +DEFINES['ICU_DATA_SYMBOL'] = '%sicudt%s_dat' % (prefix, CONFIG['MOZ_ICU_VERSION']) SOURCES += [ - "icu_data.S", + 'icu_data.S', ] -if CONFIG["OS_ARCH"] == "WINNT" and CONFIG["CC_TYPE"] == "clang-cl": +if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CC_TYPE'] == 'clang-cl': USE_INTEGRATED_CLANGCL_AS = True -if CONFIG["TARGET_ENDIANNESS"] == "big": - GeneratedFile( - data_file["big"], script="convert_icudata.py", inputs=[data_file["little"]] - ) +if CONFIG['TARGET_ENDIANNESS'] == 'big': + GeneratedFile(data_file['big'], + script='convert_icudata.py', + inputs=[data_file['little']]) diff --git a/config/external/icu/i18n/moz.build b/config/external/icu/i18n/moz.build index 07adbcc7a118a28ee9af3ed11e892f22e09801b4..b530e2399b7289c67af87a9fb515760828e48973 100644 --- a/config/external/icu/i18n/moz.build +++ b/config/external/icu/i18n/moz.build @@ -4,20 +4,20 @@ # 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/. -Library("icui18n") -FINAL_LIBRARY = "icu" +Library('icui18n') +FINAL_LIBRARY = 'icu' -DEFINES["U_I18N_IMPLEMENTATION"] = True +DEFINES['U_I18N_IMPLEMENTATION'] = True -LOCAL_INCLUDES += ["/intl/icu/source/common"] +LOCAL_INCLUDES += ['/intl/icu/source/common'] -include("../defs.mozbuild") -include("sources.mozbuild") +include('../defs.mozbuild') +include('sources.mozbuild') SOURCES += sources -if CONFIG["TARGET_ENDIANNESS"] == "big": - HostLibrary("host_icui18n") - HOST_DEFINES["U_I18N_IMPLEMENTATION"] = True +if CONFIG['TARGET_ENDIANNESS'] == 'big': + HostLibrary('host_icui18n') + HOST_DEFINES['U_I18N_IMPLEMENTATION'] = True HOST_SOURCES += sources HOST_SOURCES += other_sources diff --git a/config/external/icu/icupkg/moz.build b/config/external/icu/icupkg/moz.build index 39314fbda791162d997c09b1b815782e0af6b8bb..72cf9c33d910506a57d1a994f6f870d0c5d82244 100644 --- a/config/external/icu/icupkg/moz.build +++ b/config/external/icu/icupkg/moz.build @@ -4,24 +4,24 @@ # 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/. -HostProgram("icupkg") +HostProgram('icupkg') LOCAL_INCLUDES += [ - "/intl/icu/source/common", - "/intl/icu/source/i18n", - "/intl/icu/source/tools/toolutil", + '/intl/icu/source/common', + '/intl/icu/source/i18n', + '/intl/icu/source/tools/toolutil', ] -include("../defs.mozbuild") -include("sources.mozbuild") +include('../defs.mozbuild') +include('sources.mozbuild') HOST_SOURCES += sources HOST_SOURCES += [ - "/intl/icu/source/stubdata/stubdata.cpp", + '/intl/icu/source/stubdata/stubdata.cpp', ] HOST_USE_LIBS += [ - "host_icui18n", - "host_icutoolutil", - "host_icuuc", + 'host_icui18n', + 'host_icutoolutil', + 'host_icuuc', ] diff --git a/config/external/icu/moz.build b/config/external/icu/moz.build index 296d60d521f775b1e5debf31c6b902acb5e85b7e..ee203e8cdb434b2b8ee91b630c9ad36e725d9964 100644 --- a/config/external/icu/moz.build +++ b/config/external/icu/moz.build @@ -4,19 +4,19 @@ # 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/. -Library("icu") +Library('icu') -if CONFIG["MOZ_SYSTEM_ICU"]: - OS_LIBS += CONFIG["MOZ_ICU_LIBS"] +if CONFIG['MOZ_SYSTEM_ICU']: + OS_LIBS += CONFIG['MOZ_ICU_LIBS'] else: DIRS += [ - "common", - "data", - "i18n", + 'common', + 'data', + 'i18n', ] - if CONFIG["TARGET_ENDIANNESS"] == "big": + if CONFIG['TARGET_ENDIANNESS'] == 'big': DIRS += [ - "toolutil", - "icupkg", + 'toolutil', + 'icupkg', ] - USE_LIBS += ["icudata"] + USE_LIBS += ['icudata'] diff --git a/config/external/icu/toolutil/moz.build b/config/external/icu/toolutil/moz.build index e8dc827c2bbeec218f00206ca05ddabf5e50c68e..7de97db9e100e015a77b756fc29af1738ce6cfb9 100644 --- a/config/external/icu/toolutil/moz.build +++ b/config/external/icu/toolutil/moz.build @@ -4,17 +4,17 @@ # 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/. -HostLibrary("host_icutoolutil") -FINAL_LIBRARY = "icu" +HostLibrary('host_icutoolutil') +FINAL_LIBRARY = 'icu' -DEFINES["U_TOOLUTIL_IMPLEMENTATION"] = True +DEFINES['U_TOOLUTIL_IMPLEMENTATION'] = True LOCAL_INCLUDES += [ - "/intl/icu/source/common", - "/intl/icu/source/i18n", + '/intl/icu/source/common', + '/intl/icu/source/i18n', ] -include("../defs.mozbuild") -include("sources.mozbuild") +include('../defs.mozbuild') +include('sources.mozbuild') HOST_SOURCES += sources diff --git a/config/external/lgpllibs/moz.build b/config/external/lgpllibs/moz.build index d7c38ac630e95c55021d684d2a9701a5625ce9b5..a6d616c7bbfde3438105692965a27cfc416ab303 100644 --- a/config/external/lgpllibs/moz.build +++ b/config/external/lgpllibs/moz.build @@ -10,5 +10,5 @@ # # Any library added here should also be reflected in the about:license page. -GeckoSharedLibrary("lgpllibs", linkage=None) -SHARED_LIBRARY_NAME = "lgpllibs" +GeckoSharedLibrary('lgpllibs', linkage=None) +SHARED_LIBRARY_NAME = 'lgpllibs' diff --git a/config/external/moz.build b/config/external/moz.build index 4e9888f36503e560ba882428dffcb3f979952686..70aa33930812c2e796bdbd39f2ca498236db9841 100644 --- a/config/external/moz.build +++ b/config/external/moz.build @@ -7,65 +7,65 @@ external_dirs = [] DIRS += [ - "lgpllibs", - "rlbox", - "rlbox_lucet_sandbox", - "sqlite", + 'lgpllibs', + 'rlbox', + 'rlbox_lucet_sandbox', + 'sqlite', ] -if not CONFIG["MOZ_SYSTEM_JPEG"]: - external_dirs += ["media/libjpeg"] +if not CONFIG['MOZ_SYSTEM_JPEG']: + external_dirs += ['media/libjpeg'] DIRS += [ - "/third_party/prio", - "/third_party/msgpack", - "/third_party/sipcc", + '/third_party/prio', + '/third_party/msgpack', + '/third_party/sipcc', ] # There's no "native" brotli or woff2 yet, but probably in the future... -external_dirs += ["modules/brotli"] -external_dirs += ["modules/woff2"] +external_dirs += ['modules/brotli'] +external_dirs += ['modules/woff2'] -external_dirs += ["modules/xz-embedded"] +external_dirs += ['modules/xz-embedded'] -if CONFIG["MOZ_VORBIS"]: - external_dirs += ["media/libvorbis"] +if CONFIG['MOZ_VORBIS']: + external_dirs += ['media/libvorbis'] -if CONFIG["MOZ_TREMOR"]: - external_dirs += ["media/libtremor"] +if CONFIG['MOZ_TREMOR']: + external_dirs += ['media/libtremor'] -if CONFIG["MOZ_WEBM_ENCODER"]: - external_dirs += ["media/libmkv"] +if CONFIG['MOZ_WEBM_ENCODER']: + external_dirs += ['media/libmkv'] -if not CONFIG["MOZ_SYSTEM_LIBVPX"]: - external_dirs += ["media/libvpx"] +if not CONFIG['MOZ_SYSTEM_LIBVPX']: + external_dirs += ['media/libvpx'] -if CONFIG["MOZ_AV1"]: - external_dirs += ["media/libaom"] - external_dirs += ["media/libdav1d"] +if CONFIG['MOZ_AV1']: + external_dirs += ['media/libaom'] + external_dirs += ['media/libdav1d'] -if not CONFIG["MOZ_SYSTEM_PNG"]: - external_dirs += ["media/libpng"] +if not CONFIG['MOZ_SYSTEM_PNG']: + external_dirs += ['media/libpng'] -if not CONFIG["MOZ_SYSTEM_WEBP"]: - external_dirs += ["media/libwebp"] +if not CONFIG['MOZ_SYSTEM_WEBP']: + external_dirs += ['media/libwebp'] -if CONFIG["CPU_ARCH"] == "arm": - external_dirs += ["media/openmax_dl/dl"] +if CONFIG['CPU_ARCH'] == 'arm': + external_dirs += ['media/openmax_dl/dl'] -if CONFIG["MOZ_FFVPX"]: - external_dirs += ["media/ffvpx"] +if CONFIG['MOZ_FFVPX']: + external_dirs += ['media/ffvpx'] external_dirs += [ - "media/kiss_fft", - "media/libcubeb", - "media/libnestegg", - "media/libogg", - "media/libopus", - "media/libtheora", - "media/libspeex_resampler", - "media/libsoundtouch", - "media/mp4parse-rust", - "media/psshparser", + 'media/kiss_fft', + 'media/libcubeb', + 'media/libnestegg', + 'media/libogg', + 'media/libopus', + 'media/libtheora', + 'media/libspeex_resampler', + 'media/libsoundtouch', + 'media/mp4parse-rust', + 'media/psshparser' ] -DIRS += ["../../" + i for i in external_dirs] +DIRS += ['../../' + i for i in external_dirs] diff --git a/config/external/nspr/ds/moz.build b/config/external/nspr/ds/moz.build index d2676e20937a7f259b8baedf78e0c1b409dcb661..d0e5c3fa37469e8943e035e139e872e5fbcad822 100644 --- a/config/external/nspr/ds/moz.build +++ b/config/external/nspr/ds/moz.build @@ -4,31 +4,31 @@ # 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/. -if CONFIG["MOZ_FOLD_LIBS"]: - Library("plds4") +if CONFIG['MOZ_FOLD_LIBS']: + Library('plds4') else: - SharedLibrary("plds4") - SOURCES += ["/nsprpub/lib/ds/plvrsion.c"] - USE_LIBS += ["nspr4"] + SharedLibrary('plds4') + SOURCES += ['/nsprpub/lib/ds/plvrsion.c'] + USE_LIBS += ['nspr4'] # We allow warnings for third-party code that can be updated from upstream. # TODO: fix NSPR warnings and remove this AllowCompilerWarnings() -DEFINES["_NSPR_BUILD_"] = True +DEFINES['_NSPR_BUILD_'] = True LOCAL_INCLUDES += [ - "/config/external/nspr", - "/nsprpub/pr/include", + '/config/external/nspr', + '/nsprpub/pr/include', ] EXPORTS.nspr += [ - "/nsprpub/lib/ds/plarena.h", - "/nsprpub/lib/ds/plarenas.h", - "/nsprpub/lib/ds/plhash.h", + '/nsprpub/lib/ds/plarena.h', + '/nsprpub/lib/ds/plarenas.h', + '/nsprpub/lib/ds/plhash.h', ] SOURCES += [ - "/nsprpub/lib/ds/plarena.c", - "/nsprpub/lib/ds/plhash.c", + '/nsprpub/lib/ds/plarena.c', + '/nsprpub/lib/ds/plhash.c', ] diff --git a/config/external/nspr/libc/moz.build b/config/external/nspr/libc/moz.build index 62bb8814f6579f543e8efdb6bd7cbcc72c197863..c735ba7de2faf096bd755f8de27e02cd67c6e0e8 100644 --- a/config/external/nspr/libc/moz.build +++ b/config/external/nspr/libc/moz.build @@ -4,42 +4,42 @@ # 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/. -if CONFIG["MOZ_FOLD_LIBS"]: - Library("plc4") +if CONFIG['MOZ_FOLD_LIBS']: + Library('plc4') else: - SharedLibrary("plc4") - SOURCES += ["/nsprpub/lib/libc/src/plvrsion.c"] - USE_LIBS += ["nspr4"] + SharedLibrary('plc4') + SOURCES += ['/nsprpub/lib/libc/src/plvrsion.c'] + USE_LIBS += ['nspr4'] # We allow warnings for third-party code that can be updated from upstream. # TODO: fix NSPR warnings and remove this AllowCompilerWarnings() -DEFINES["_NSPR_BUILD_"] = True +DEFINES['_NSPR_BUILD_'] = True LOCAL_INCLUDES += [ - "/config/external/nspr", + '/config/external/nspr', ] EXPORTS.nspr += [ - "/nsprpub/lib/libc/include/plbase64.h", - "/nsprpub/lib/libc/include/plerror.h", - "/nsprpub/lib/libc/include/plgetopt.h", - "/nsprpub/lib/libc/include/plstr.h", + '/nsprpub/lib/libc/include/plbase64.h', + '/nsprpub/lib/libc/include/plerror.h', + '/nsprpub/lib/libc/include/plgetopt.h', + '/nsprpub/lib/libc/include/plstr.h', ] SOURCES += [ - "/nsprpub/lib/libc/src/base64.c", - "/nsprpub/lib/libc/src/plerror.c", - "/nsprpub/lib/libc/src/plgetopt.c", - "/nsprpub/lib/libc/src/strcase.c", - "/nsprpub/lib/libc/src/strcat.c", - "/nsprpub/lib/libc/src/strchr.c", - "/nsprpub/lib/libc/src/strcmp.c", - "/nsprpub/lib/libc/src/strcpy.c", - "/nsprpub/lib/libc/src/strdup.c", - "/nsprpub/lib/libc/src/strlen.c", - "/nsprpub/lib/libc/src/strpbrk.c", - "/nsprpub/lib/libc/src/strstr.c", - "/nsprpub/lib/libc/src/strtok.c", + '/nsprpub/lib/libc/src/base64.c', + '/nsprpub/lib/libc/src/plerror.c', + '/nsprpub/lib/libc/src/plgetopt.c', + '/nsprpub/lib/libc/src/strcase.c', + '/nsprpub/lib/libc/src/strcat.c', + '/nsprpub/lib/libc/src/strchr.c', + '/nsprpub/lib/libc/src/strcmp.c', + '/nsprpub/lib/libc/src/strcpy.c', + '/nsprpub/lib/libc/src/strdup.c', + '/nsprpub/lib/libc/src/strlen.c', + '/nsprpub/lib/libc/src/strpbrk.c', + '/nsprpub/lib/libc/src/strstr.c', + '/nsprpub/lib/libc/src/strtok.c', ] diff --git a/config/external/nspr/moz.build b/config/external/nspr/moz.build index f2b3d4e8c1d5c783100848502552480052b24cf3..0629702034769ae433ae95fbc53a0ac29e7139a7 100644 --- a/config/external/nspr/moz.build +++ b/config/external/nspr/moz.build @@ -4,25 +4,25 @@ # 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/. -Library("nspr") +Library('nspr') -if CONFIG["MOZ_BUILD_NSPR"]: +if CONFIG['MOZ_BUILD_NSPR']: DIRS += [ - "pr", - "ds", - "libc", + 'pr', + 'ds', + 'libc', ] - if CONFIG["MOZ_FOLD_LIBS"]: + if CONFIG['MOZ_FOLD_LIBS']: # When folding libraries, nspr is actually in the nss library. USE_LIBS += [ - "nss", + 'nss', ] else: USE_LIBS += [ - "nspr4", - "plc4", - "plds4", + 'nspr4', + 'plc4', + 'plds4', ] - EXPORTS.nspr += ["prcpucfg.h"] + EXPORTS.nspr += ['prcpucfg.h'] else: - OS_LIBS += CONFIG["NSPR_LIBS"] + OS_LIBS += CONFIG['NSPR_LIBS'] diff --git a/config/external/nspr/pr/moz.build b/config/external/nspr/pr/moz.build index 4e06a37323a41c8c80f3729028a0c5f3962cc4a8..9b323af89ad2e06074806bea8a37c7078708a984 100644 --- a/config/external/nspr/pr/moz.build +++ b/config/external/nspr/pr/moz.build @@ -4,253 +4,250 @@ # 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/. -if CONFIG["MOZ_FOLD_LIBS"]: - Library("nspr4") +if CONFIG['MOZ_FOLD_LIBS']: + Library('nspr4') else: - SharedLibrary("nspr4") + SharedLibrary('nspr4') # We allow warnings for third-party code that can be updated from upstream. # TODO: fix NSPR warnings and remove this AllowCompilerWarnings() -DEFINES["_NSPR_BUILD_"] = True -if CONFIG["OS_ARCH"] == "Linux": - OS_LIBS += CONFIG["REALTIME_LIBS"] - DEFINES["LINUX"] = True - DEFINES["HAVE_FCNTL_FILE_LOCKING"] = True - DEFINES["HAVE_POINTER_LOCALTIME_R"] = True - DEFINES["_GNU_SOURCE"] = True - SOURCES += ["/nsprpub/pr/src/md/unix/linux.c"] - if CONFIG["CPU_ARCH"] == "x86_64": - SOURCES += ["/nsprpub/pr/src/md/unix/os_Linux_x86_64.s"] - elif CONFIG["CPU_ARCH"] == "x86": - DEFINES["i386"] = True - SOURCES += ["/nsprpub/pr/src/md/unix/os_Linux_x86.s"] - elif CONFIG["CPU_ARCH"] == "ppc": - SOURCES += ["/nsprpub/pr/src/md/unix/os_Linux_ppc.s"] -elif CONFIG["OS_TARGET"] in ("FreeBSD", "OpenBSD", "NetBSD"): - DEFINES["HAVE_BSD_FLOCK"] = True - DEFINES["HAVE_SOCKLEN_T"] = True - DEFINES["HAVE_POINTER_LOCALTIME_R"] = True - DEFINES[CONFIG["OS_TARGET"].upper()] = True - SOURCES += ["/nsprpub/pr/src/md/unix/%s.c" % CONFIG["OS_TARGET"].lower()] -elif CONFIG["OS_TARGET"] == "Darwin": - OS_LIBS += ["-framework CoreServices"] +DEFINES['_NSPR_BUILD_'] = True +if CONFIG['OS_ARCH'] == 'Linux': + OS_LIBS += CONFIG['REALTIME_LIBS'] + DEFINES['LINUX'] = True + DEFINES['HAVE_FCNTL_FILE_LOCKING'] = True + DEFINES['HAVE_POINTER_LOCALTIME_R'] = True + DEFINES['_GNU_SOURCE'] = True + SOURCES += ['/nsprpub/pr/src/md/unix/linux.c'] + if CONFIG['CPU_ARCH'] == 'x86_64': + SOURCES += ['/nsprpub/pr/src/md/unix/os_Linux_x86_64.s'] + elif CONFIG['CPU_ARCH'] == 'x86': + DEFINES['i386'] = True + SOURCES += ['/nsprpub/pr/src/md/unix/os_Linux_x86.s'] + elif CONFIG['CPU_ARCH'] == 'ppc': + SOURCES += ['/nsprpub/pr/src/md/unix/os_Linux_ppc.s'] +elif CONFIG['OS_TARGET'] in ('FreeBSD', 'OpenBSD', 'NetBSD'): + DEFINES['HAVE_BSD_FLOCK'] = True + DEFINES['HAVE_SOCKLEN_T'] = True + DEFINES['HAVE_POINTER_LOCALTIME_R'] = True + DEFINES[CONFIG['OS_TARGET'].upper()] = True + SOURCES += ['/nsprpub/pr/src/md/unix/%s.c' % CONFIG['OS_TARGET'].lower()] +elif CONFIG['OS_TARGET'] == 'Darwin': + OS_LIBS += ['-framework CoreServices'] # See also IncreaseDescriptorLimits in toolkit/xre/nsAppRunner.cpp - DEFINES["FD_SETSIZE"] = 4096 - DEFINES["_DARWIN_UNLIMITED_SELECT"] = True - if not CONFIG["HOST_MAJOR_VERSION"]: - DEFINES["HAS_CONNECTX"] = True - elif CONFIG["HOST_MAJOR_VERSION"] >= "15": - DEFINES["HAS_CONNECTX"] = True - DEFINES["DARWIN"] = True - DEFINES["HAVE_BSD_FLOCK"] = True - DEFINES["HAVE_SOCKLEN_T"] = True - DEFINES["HAVE_POINTER_LOCALTIME_R"] = True + DEFINES['FD_SETSIZE'] = 4096 + DEFINES['_DARWIN_UNLIMITED_SELECT'] = True + if not CONFIG['HOST_MAJOR_VERSION']: + DEFINES['HAS_CONNECTX'] = True + elif CONFIG['HOST_MAJOR_VERSION'] >= '15': + DEFINES['HAS_CONNECTX'] = True + DEFINES['DARWIN'] = True + DEFINES['HAVE_BSD_FLOCK'] = True + DEFINES['HAVE_SOCKLEN_T'] = True + DEFINES['HAVE_POINTER_LOCALTIME_R'] = True SOURCES += [ - "/nsprpub/pr/src/md/unix/darwin.c", - "/nsprpub/pr/src/md/unix/os_Darwin.s", + '/nsprpub/pr/src/md/unix/darwin.c', + '/nsprpub/pr/src/md/unix/os_Darwin.s', ] - DEFINES["HAVE_CRT_EXTERNS_H"] = True -elif CONFIG["OS_TARGET"] == "SunOS": - DEFINES["HAVE_FCNTL_FILE_LOCKING"] = True - DEFINES["HAVE_SOCKLEN_T"] = True - DEFINES["_PR_HAVE_OFF64_T"] = True - DEFINES["_PR_INET6"] = True - DEFINES["SOLARIS"] = True - SOURCES += ["/nsprpub/pr/src/md/unix/solaris.c"] - if CONFIG["CPU_ARCH"] == "x86_64": - SOURCES += ["/nsprpub/pr/src/md/unix/os_SunOS_x86_64.s"] - elif CONFIG["CPU_ARCH"] == "x86": - SOURCES += ["/nsprpub/pr/src/md/unix/os_SunOS_x86.s"] - elif CONFIG["CPU_ARCH"] == "sparc64": - ASFLAGS += ["-x", "assembler-with-cpp", "-D_ASM"] - SOURCES += ["/nsprpub/pr/src/md/unix/os_SunOS_sparcv9.s"] -elif CONFIG["OS_TARGET"] == "WINNT": + DEFINES['HAVE_CRT_EXTERNS_H'] = True +elif CONFIG['OS_TARGET'] == 'SunOS': + DEFINES['HAVE_FCNTL_FILE_LOCKING'] = True + DEFINES['HAVE_SOCKLEN_T'] = True + DEFINES['_PR_HAVE_OFF64_T'] = True + DEFINES['_PR_INET6'] = True + DEFINES['SOLARIS'] = True + SOURCES += ['/nsprpub/pr/src/md/unix/solaris.c'] + if CONFIG['CPU_ARCH'] == 'x86_64': + SOURCES += ['/nsprpub/pr/src/md/unix/os_SunOS_x86_64.s'] + elif CONFIG['CPU_ARCH'] == 'x86': + SOURCES += ['/nsprpub/pr/src/md/unix/os_SunOS_x86.s'] + elif CONFIG['CPU_ARCH'] == 'sparc64': + ASFLAGS += ['-x', 'assembler-with-cpp', '-D_ASM'] + SOURCES += ['/nsprpub/pr/src/md/unix/os_SunOS_sparcv9.s'] +elif CONFIG['OS_TARGET'] == 'WINNT': OS_LIBS += [ - "advapi32", - "ws2_32", - "mswsock", - "winmm", + 'advapi32', + 'ws2_32', + 'mswsock', + 'winmm', ] - DEFINES["XP_PC"] = True - DEFINES["WIN32"] = True + DEFINES['XP_PC'] = True + DEFINES['WIN32'] = True # For historical reasons we use the WIN95 NSPR target instead of # WINNT. - DEFINES["WIN95"] = True - DEFINES["WINNT"] = False - DEFINES["_PR_GLOBAL_THREADS_ONLY"] = True - if not CONFIG["DEBUG"]: - DEFINES["DO_NOT_WAIT_FOR_CONNECT_OVERLAPPED_OPERATIONS"] = True - if CONFIG["CPU_ARCH"] == "x86_64": - DEFINES["_AMD64_"] = True - elif CONFIG["CPU_ARCH"] == "x86": - DEFINES["_X86_"] = True - elif CONFIG["CPU_ARCH"] == "aarch64": - DEFINES["_ARM64_"] = True + DEFINES['WIN95'] = True + DEFINES['WINNT'] = False + DEFINES['_PR_GLOBAL_THREADS_ONLY'] = True + if not CONFIG['DEBUG']: + DEFINES['DO_NOT_WAIT_FOR_CONNECT_OVERLAPPED_OPERATIONS'] = True + if CONFIG['CPU_ARCH'] == 'x86_64': + DEFINES['_AMD64_'] = True + elif CONFIG['CPU_ARCH'] == 'x86': + DEFINES['_X86_'] = True + elif CONFIG['CPU_ARCH'] == 'aarch64': + DEFINES['_ARM64_'] = True else: - error("Unsupported CPU_ARCH value: %s" % CONFIG["CPU_ARCH"]) + error('Unsupported CPU_ARCH value: %s' % CONFIG['CPU_ARCH']) else: - error( - 'Not a supported OS_TARGET for NSPR in moz.build: "%s". Use --with-system-nspr' - % CONFIG["OS_TARGET"] - ) + error('Not a supported OS_TARGET for NSPR in moz.build: "%s". Use --with-system-nspr' % CONFIG['OS_TARGET']) LOCAL_INCLUDES += [ - "/config/external/nspr", - "/nsprpub/pr/include", - "/nsprpub/pr/include/private", + '/config/external/nspr', + '/nsprpub/pr/include', + '/nsprpub/pr/include/private', ] SOURCES += [ - "/nsprpub/pr/src/io/prpolevt.c", # conflicting definition of PRFilePrivate - "/nsprpub/pr/src/misc/praton.c", # duplicate definition of index_hex -] + '/nsprpub/pr/src/io/prpolevt.c', # conflicting definition of PRFilePrivate + '/nsprpub/pr/src/misc/praton.c', # duplicate definition of index_hex + ] UNIFIED_SOURCES += [ - "/nsprpub/pr/src/io/prfdcach.c", - "/nsprpub/pr/src/io/priometh.c", - "/nsprpub/pr/src/io/pripv6.c", - "/nsprpub/pr/src/io/prlayer.c", - "/nsprpub/pr/src/io/prlog.c", - "/nsprpub/pr/src/io/prmapopt.c", - "/nsprpub/pr/src/io/prmmap.c", - "/nsprpub/pr/src/io/prmwait.c", - "/nsprpub/pr/src/io/prprf.c", - "/nsprpub/pr/src/io/prscanf.c", - "/nsprpub/pr/src/io/prstdio.c", - "/nsprpub/pr/src/linking/prlink.c", - "/nsprpub/pr/src/malloc/prmalloc.c", - "/nsprpub/pr/src/malloc/prmem.c", - "/nsprpub/pr/src/md/prosdep.c", - "/nsprpub/pr/src/memory/prseg.c", - "/nsprpub/pr/src/memory/prshma.c", - "/nsprpub/pr/src/misc/pratom.c", - "/nsprpub/pr/src/misc/prdtoa.c", - "/nsprpub/pr/src/misc/prenv.c", - "/nsprpub/pr/src/misc/prerr.c", - "/nsprpub/pr/src/misc/prerror.c", - "/nsprpub/pr/src/misc/prerrortable.c", - "/nsprpub/pr/src/misc/prinit.c", - "/nsprpub/pr/src/misc/prinrval.c", - "/nsprpub/pr/src/misc/pripc.c", - "/nsprpub/pr/src/misc/prlog2.c", - "/nsprpub/pr/src/misc/prnetdb.c", - "/nsprpub/pr/src/misc/prrng.c", - "/nsprpub/pr/src/misc/prsystem.c", - "/nsprpub/pr/src/misc/prtime.c", - "/nsprpub/pr/src/misc/prtpool.c", - "/nsprpub/pr/src/threads/prcmon.c", - "/nsprpub/pr/src/threads/prrwlock.c", - "/nsprpub/pr/src/threads/prtpd.c", + '/nsprpub/pr/src/io/prfdcach.c', + '/nsprpub/pr/src/io/priometh.c', + '/nsprpub/pr/src/io/pripv6.c', + '/nsprpub/pr/src/io/prlayer.c', + '/nsprpub/pr/src/io/prlog.c', + '/nsprpub/pr/src/io/prmapopt.c', + '/nsprpub/pr/src/io/prmmap.c', + '/nsprpub/pr/src/io/prmwait.c', + '/nsprpub/pr/src/io/prprf.c', + '/nsprpub/pr/src/io/prscanf.c', + '/nsprpub/pr/src/io/prstdio.c', + '/nsprpub/pr/src/linking/prlink.c', + '/nsprpub/pr/src/malloc/prmalloc.c', + '/nsprpub/pr/src/malloc/prmem.c', + '/nsprpub/pr/src/md/prosdep.c', + '/nsprpub/pr/src/memory/prseg.c', + '/nsprpub/pr/src/memory/prshma.c', + '/nsprpub/pr/src/misc/pratom.c', + '/nsprpub/pr/src/misc/prdtoa.c', + '/nsprpub/pr/src/misc/prenv.c', + '/nsprpub/pr/src/misc/prerr.c', + '/nsprpub/pr/src/misc/prerror.c', + '/nsprpub/pr/src/misc/prerrortable.c', + '/nsprpub/pr/src/misc/prinit.c', + '/nsprpub/pr/src/misc/prinrval.c', + '/nsprpub/pr/src/misc/pripc.c', + '/nsprpub/pr/src/misc/prlog2.c', + '/nsprpub/pr/src/misc/prnetdb.c', + '/nsprpub/pr/src/misc/prrng.c', + '/nsprpub/pr/src/misc/prsystem.c', + '/nsprpub/pr/src/misc/prtime.c', + '/nsprpub/pr/src/misc/prtpool.c', + '/nsprpub/pr/src/threads/prcmon.c', + '/nsprpub/pr/src/threads/prrwlock.c', + '/nsprpub/pr/src/threads/prtpd.c', ] -if CONFIG["OS_TARGET"] != "WINNT": - DEFINES["_PR_PTHREADS"] = True +if CONFIG['OS_TARGET'] != 'WINNT': + DEFINES['_PR_PTHREADS'] = True UNIFIED_SOURCES += [ - "/nsprpub/pr/src/md/unix/unix.c", - "/nsprpub/pr/src/md/unix/unix_errors.c", - "/nsprpub/pr/src/md/unix/uxproces.c", - "/nsprpub/pr/src/md/unix/uxrng.c", - "/nsprpub/pr/src/md/unix/uxshm.c", - "/nsprpub/pr/src/pthreads/ptio.c", - "/nsprpub/pr/src/pthreads/ptmisc.c", - "/nsprpub/pr/src/pthreads/ptsynch.c", - "/nsprpub/pr/src/pthreads/ptthread.c", + '/nsprpub/pr/src/md/unix/unix.c', + '/nsprpub/pr/src/md/unix/unix_errors.c', + '/nsprpub/pr/src/md/unix/uxproces.c', + '/nsprpub/pr/src/md/unix/uxrng.c', + '/nsprpub/pr/src/md/unix/uxshm.c', + '/nsprpub/pr/src/pthreads/ptio.c', + '/nsprpub/pr/src/pthreads/ptmisc.c', + '/nsprpub/pr/src/pthreads/ptsynch.c', + '/nsprpub/pr/src/pthreads/ptthread.c', ] else: SOURCES += [ # ntinrval.c needs windows.h without WIN32_LEAN_AND_MEAN, so it can't be # unified after any file that pulled in windows.h in lean-and-mean mode. - "/nsprpub/pr/src/md/windows/ntinrval.c", + '/nsprpub/pr/src/md/windows/ntinrval.c', # w32poll.c needs a custom value of FD_SETSIZE for winsock.h. - "/nsprpub/pr/src/md/windows/w32poll.c", + '/nsprpub/pr/src/md/windows/w32poll.c', # w95sock.c needs winsock2.h which conflicts with winsock.h. - "/nsprpub/pr/src/md/windows/w95sock.c", + '/nsprpub/pr/src/md/windows/w95sock.c', ] UNIFIED_SOURCES += [ - "/nsprpub/pr/src/io/prdir.c", - "/nsprpub/pr/src/io/prfile.c", - "/nsprpub/pr/src/io/prio.c", - "/nsprpub/pr/src/io/prsocket.c", - "/nsprpub/pr/src/md/windows/ntgc.c", - "/nsprpub/pr/src/md/windows/ntmisc.c", - "/nsprpub/pr/src/md/windows/ntsec.c", - "/nsprpub/pr/src/md/windows/ntsem.c", - "/nsprpub/pr/src/md/windows/w32ipcsem.c", - "/nsprpub/pr/src/md/windows/w32rng.c", - "/nsprpub/pr/src/md/windows/w32shm.c", - "/nsprpub/pr/src/md/windows/w95cv.c", - "/nsprpub/pr/src/md/windows/w95dllmain.c", - "/nsprpub/pr/src/md/windows/w95io.c", - "/nsprpub/pr/src/md/windows/w95thred.c", - "/nsprpub/pr/src/md/windows/win32_errors.c", - "/nsprpub/pr/src/misc/pripcsem.c", - "/nsprpub/pr/src/threads/combined/prucpu.c", - "/nsprpub/pr/src/threads/combined/prucv.c", - "/nsprpub/pr/src/threads/combined/prulock.c", - "/nsprpub/pr/src/threads/combined/prustack.c", - "/nsprpub/pr/src/threads/combined/pruthr.c", - "/nsprpub/pr/src/threads/prcthr.c", - "/nsprpub/pr/src/threads/prdump.c", - "/nsprpub/pr/src/threads/prmon.c", - "/nsprpub/pr/src/threads/prsem.c", + '/nsprpub/pr/src/io/prdir.c', + '/nsprpub/pr/src/io/prfile.c', + '/nsprpub/pr/src/io/prio.c', + '/nsprpub/pr/src/io/prsocket.c', + '/nsprpub/pr/src/md/windows/ntgc.c', + '/nsprpub/pr/src/md/windows/ntmisc.c', + '/nsprpub/pr/src/md/windows/ntsec.c', + '/nsprpub/pr/src/md/windows/ntsem.c', + '/nsprpub/pr/src/md/windows/w32ipcsem.c', + '/nsprpub/pr/src/md/windows/w32rng.c', + '/nsprpub/pr/src/md/windows/w32shm.c', + '/nsprpub/pr/src/md/windows/w95cv.c', + '/nsprpub/pr/src/md/windows/w95dllmain.c', + '/nsprpub/pr/src/md/windows/w95io.c', + '/nsprpub/pr/src/md/windows/w95thred.c', + '/nsprpub/pr/src/md/windows/win32_errors.c', + '/nsprpub/pr/src/misc/pripcsem.c', + '/nsprpub/pr/src/threads/combined/prucpu.c', + '/nsprpub/pr/src/threads/combined/prucv.c', + '/nsprpub/pr/src/threads/combined/prulock.c', + '/nsprpub/pr/src/threads/combined/prustack.c', + '/nsprpub/pr/src/threads/combined/pruthr.c', + '/nsprpub/pr/src/threads/prcthr.c', + '/nsprpub/pr/src/threads/prdump.c', + '/nsprpub/pr/src/threads/prmon.c', + '/nsprpub/pr/src/threads/prsem.c', ] EXPORTS.nspr += [ - "/nsprpub/pr/include/nspr.h", - "/nsprpub/pr/include/pratom.h", - "/nsprpub/pr/include/prbit.h", - "/nsprpub/pr/include/prclist.h", - "/nsprpub/pr/include/prcmon.h", - "/nsprpub/pr/include/prcvar.h", - "/nsprpub/pr/include/prdtoa.h", - "/nsprpub/pr/include/prenv.h", - "/nsprpub/pr/include/prerr.h", - "/nsprpub/pr/include/prerror.h", - "/nsprpub/pr/include/prinet.h", - "/nsprpub/pr/include/prinit.h", - "/nsprpub/pr/include/prinrval.h", - "/nsprpub/pr/include/prio.h", - "/nsprpub/pr/include/pripcsem.h", - "/nsprpub/pr/include/prlink.h", - "/nsprpub/pr/include/prlock.h", - "/nsprpub/pr/include/prlog.h", - "/nsprpub/pr/include/prlong.h", - "/nsprpub/pr/include/prmem.h", - "/nsprpub/pr/include/prmon.h", - "/nsprpub/pr/include/prmwait.h", - "/nsprpub/pr/include/prnetdb.h", - "/nsprpub/pr/include/prpdce.h", - "/nsprpub/pr/include/prprf.h", - "/nsprpub/pr/include/prproces.h", - "/nsprpub/pr/include/prrng.h", - "/nsprpub/pr/include/prrwlock.h", - "/nsprpub/pr/include/prshm.h", - "/nsprpub/pr/include/prshma.h", - "/nsprpub/pr/include/prsystem.h", - "/nsprpub/pr/include/prthread.h", - "/nsprpub/pr/include/prtime.h", - "/nsprpub/pr/include/prtpool.h", - "/nsprpub/pr/include/prtrace.h", - "/nsprpub/pr/include/prtypes.h", - "/nsprpub/pr/include/prvrsion.h", - "/nsprpub/pr/include/prwin16.h", + '/nsprpub/pr/include/nspr.h', + '/nsprpub/pr/include/pratom.h', + '/nsprpub/pr/include/prbit.h', + '/nsprpub/pr/include/prclist.h', + '/nsprpub/pr/include/prcmon.h', + '/nsprpub/pr/include/prcvar.h', + '/nsprpub/pr/include/prdtoa.h', + '/nsprpub/pr/include/prenv.h', + '/nsprpub/pr/include/prerr.h', + '/nsprpub/pr/include/prerror.h', + '/nsprpub/pr/include/prinet.h', + '/nsprpub/pr/include/prinit.h', + '/nsprpub/pr/include/prinrval.h', + '/nsprpub/pr/include/prio.h', + '/nsprpub/pr/include/pripcsem.h', + '/nsprpub/pr/include/prlink.h', + '/nsprpub/pr/include/prlock.h', + '/nsprpub/pr/include/prlog.h', + '/nsprpub/pr/include/prlong.h', + '/nsprpub/pr/include/prmem.h', + '/nsprpub/pr/include/prmon.h', + '/nsprpub/pr/include/prmwait.h', + '/nsprpub/pr/include/prnetdb.h', + '/nsprpub/pr/include/prpdce.h', + '/nsprpub/pr/include/prprf.h', + '/nsprpub/pr/include/prproces.h', + '/nsprpub/pr/include/prrng.h', + '/nsprpub/pr/include/prrwlock.h', + '/nsprpub/pr/include/prshm.h', + '/nsprpub/pr/include/prshma.h', + '/nsprpub/pr/include/prsystem.h', + '/nsprpub/pr/include/prthread.h', + '/nsprpub/pr/include/prtime.h', + '/nsprpub/pr/include/prtpool.h', + '/nsprpub/pr/include/prtrace.h', + '/nsprpub/pr/include/prtypes.h', + '/nsprpub/pr/include/prvrsion.h', + '/nsprpub/pr/include/prwin16.h', ] EXPORTS.nspr.md += [ - "/nsprpub/pr/include/md/_darwin.cfg", - "/nsprpub/pr/include/md/_freebsd.cfg", - "/nsprpub/pr/include/md/_linux.cfg", - "/nsprpub/pr/include/md/_netbsd.cfg", - "/nsprpub/pr/include/md/_openbsd.cfg", - "/nsprpub/pr/include/md/_solaris.cfg", - "/nsprpub/pr/include/md/_win95.cfg", + '/nsprpub/pr/include/md/_darwin.cfg', + '/nsprpub/pr/include/md/_freebsd.cfg', + '/nsprpub/pr/include/md/_linux.cfg', + '/nsprpub/pr/include/md/_netbsd.cfg', + '/nsprpub/pr/include/md/_openbsd.cfg', + '/nsprpub/pr/include/md/_solaris.cfg', + '/nsprpub/pr/include/md/_win95.cfg', ] EXPORTS.nspr.private += [ - "/nsprpub/pr/include/private/pprio.h", - "/nsprpub/pr/include/private/pprthred.h", - "/nsprpub/pr/include/private/prpriv.h", + '/nsprpub/pr/include/private/pprio.h', + '/nsprpub/pr/include/private/pprthred.h', + '/nsprpub/pr/include/private/prpriv.h', ] diff --git a/config/external/rlbox/moz.build b/config/external/rlbox/moz.build index d222f530a90ae06634951ff145f7153a933f5fd7..d216e62cad861e275991a3dfeb31642357691fb1 100644 --- a/config/external/rlbox/moz.build +++ b/config/external/rlbox/moz.build @@ -5,23 +5,25 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXPORTS.mozilla.rlbox += [ - "/third_party/rlbox/include/rlbox.hpp", - "/third_party/rlbox/include/rlbox_conversion.hpp", - "/third_party/rlbox/include/rlbox_helpers.hpp", - "/third_party/rlbox/include/rlbox_noop_sandbox.hpp", - "/third_party/rlbox/include/rlbox_policy_types.hpp", - "/third_party/rlbox/include/rlbox_range.hpp", - "/third_party/rlbox/include/rlbox_sandbox.hpp", - "/third_party/rlbox/include/rlbox_stdlib.hpp", - "/third_party/rlbox/include/rlbox_stdlib_polyfill.hpp", - "/third_party/rlbox/include/rlbox_struct_support.hpp", - "/third_party/rlbox/include/rlbox_type_traits.hpp", - "/third_party/rlbox/include/rlbox_types.hpp", - "/third_party/rlbox/include/rlbox_unwrap.hpp", - "/third_party/rlbox/include/rlbox_wrapper_traits.hpp", - "rlbox_config.h", + '/third_party/rlbox/include/rlbox.hpp', + '/third_party/rlbox/include/rlbox_conversion.hpp', + '/third_party/rlbox/include/rlbox_helpers.hpp', + '/third_party/rlbox/include/rlbox_noop_sandbox.hpp', + '/third_party/rlbox/include/rlbox_policy_types.hpp', + '/third_party/rlbox/include/rlbox_range.hpp', + '/third_party/rlbox/include/rlbox_sandbox.hpp', + '/third_party/rlbox/include/rlbox_stdlib.hpp', + '/third_party/rlbox/include/rlbox_stdlib_polyfill.hpp', + '/third_party/rlbox/include/rlbox_struct_support.hpp', + '/third_party/rlbox/include/rlbox_type_traits.hpp', + '/third_party/rlbox/include/rlbox_types.hpp', + '/third_party/rlbox/include/rlbox_unwrap.hpp', + '/third_party/rlbox/include/rlbox_wrapper_traits.hpp', + 'rlbox_config.h', ] -SOURCES += ["rlbox_thread_locals.cpp"] +SOURCES += [ + 'rlbox_thread_locals.cpp' +] -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' \ No newline at end of file diff --git a/config/external/rlbox_lucet_sandbox/moz.build b/config/external/rlbox_lucet_sandbox/moz.build index 42825246362c96fd5d68eece6823b182b86a59a4..0eb93084bb3a686952f6dc0603d85cd8cdcf969b 100644 --- a/config/external/rlbox_lucet_sandbox/moz.build +++ b/config/external/rlbox_lucet_sandbox/moz.build @@ -5,10 +5,12 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXPORTS.mozilla.rlbox += [ - "/third_party/rust/rlbox_lucet_sandbox/include/lucet_sandbox.h", - "/third_party/rust/rlbox_lucet_sandbox/include/rlbox_lucet_sandbox.hpp", + '/third_party/rust/rlbox_lucet_sandbox/include/lucet_sandbox.h', + '/third_party/rust/rlbox_lucet_sandbox/include/rlbox_lucet_sandbox.hpp', ] -SOURCES += ["rlbox_lucet_thread_locals.cpp"] +SOURCES += [ + 'rlbox_lucet_thread_locals.cpp' +] -FINAL_LIBRARY = "xul" +FINAL_LIBRARY = 'xul' \ No newline at end of file diff --git a/config/external/sqlite/moz.build b/config/external/sqlite/moz.build index 6294924c564ae8c2ebc0033895be91069179fcd2..dc575ec0426d922cc758a62ae6d7f33af0040ce4 100644 --- a/config/external/sqlite/moz.build +++ b/config/external/sqlite/moz.build @@ -4,15 +4,15 @@ # 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/. -DIRS += ["../../../third_party/sqlite3/src"] -if CONFIG["MOZ_FOLD_LIBS"]: - Library("sqlite") +DIRS += ['../../../third_party/sqlite3/src'] +if CONFIG['MOZ_FOLD_LIBS']: + Library('sqlite') # When folding libraries, sqlite is actually in the nss library. USE_LIBS += [ - "nss", + 'nss', ] else: - SharedLibrary("sqlite") - SHARED_LIBRARY_NAME = "mozsqlite3" + SharedLibrary('sqlite') + SHARED_LIBRARY_NAME = 'mozsqlite3' - SYMBOLS_FILE = "/third_party/sqlite3/src/sqlite.symbols" + SYMBOLS_FILE = '/third_party/sqlite3/src/sqlite.symbols' diff --git a/config/external/zlib/moz.build b/config/external/zlib/moz.build index 755400fa7f86cbe11b3d91ea5b1c13a922677087..c6b7cfe7d8035da9c0215d05d061978e7d990c58 100644 --- a/config/external/zlib/moz.build +++ b/config/external/zlib/moz.build @@ -4,12 +4,12 @@ # 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/. -Library("zlib") +Library('zlib') -if CONFIG["MOZ_SYSTEM_ZLIB"]: - OS_LIBS += CONFIG["MOZ_ZLIB_LIBS"] +if CONFIG['MOZ_SYSTEM_ZLIB']: + OS_LIBS += CONFIG['MOZ_ZLIB_LIBS'] else: - if CONFIG["ZLIB_IN_MOZGLUE"]: + if CONFIG['ZLIB_IN_MOZGLUE']: # Can't do this until mozglue is handled by moz.build instead of # config/rules.mk. # USE_LIBS += [ @@ -17,5 +17,5 @@ else: # ] pass DIRS += [ - "../../../modules/zlib", + '../../../modules/zlib', ] diff --git a/config/make-stl-wrappers.py b/config/make-stl-wrappers.py index 5102e1984ee888c8b44ce493c432913bed93562b..9ab022a5b803531674e9f0d4d16fbefff54ef324 100644 --- a/config/make-stl-wrappers.py +++ b/config/make-stl-wrappers.py @@ -13,7 +13,7 @@ from mozbuild.util import FileAvoidWrite def gen_wrappers(unused, outdir, compiler, template_file, *header_list): - template = open(template_file, "r").read() + template = open(template_file, 'r').read() for header in header_list: with FileAvoidWrite(os.path.join(outdir, header)) as f: diff --git a/config/make-system-wrappers.py b/config/make-system-wrappers.py index d46ec5cc0f5abd4a4accbba1c396ba932fde4e1c..8636e244e8d1758a1ce3c8ff5694d00cd723007f 100644 --- a/config/make-system-wrappers.py +++ b/config/make-system-wrappers.py @@ -6,13 +6,13 @@ from __future__ import print_function import os from mozbuild.util import FileAvoidWrite -header_template = """#pragma GCC system_header +header_template = '''#pragma GCC system_header #pragma GCC visibility push(default) {includes} #pragma GCC visibility pop -""" +''' -include_next_template = "#include_next <{header}>" +include_next_template = '#include_next <{header}>' # The 'unused' arg is the output file from the file_generate action. We actually @@ -21,13 +21,13 @@ def gen_wrappers(unused, outdir, *header_list): for header in header_list: with FileAvoidWrite(os.path.join(outdir, header)) as f: includes = include_next_template.format(header=header) - if header == "wayland-util.h": + if header == 'wayland-util.h': # wayland-util.h in Wayland < 1.12 includes math.h inside an # extern "C" block, which breaks including the header from C++. # This was fixed in Wayland 1.12, but for versions earlier than # that, we work around that by force-including math.h first. - includes = "#include \n" + includes - elif header == "wayland-client.h": + includes = '#include \n' + includes + elif header == 'wayland-client.h': # The system wayland-client.h uses quote includes for # wayland-util.h, which means wayland-util.h is picked from the # directory containing wayland-client.h first, and there's no diff --git a/config/make-windows-h-wrapper.py b/config/make-windows-h-wrapper.py index b77c7a879d08d2b2558946fe6ff7a0370a40aa3c..6219d84e5b7471c22cccafba097bfb2ad6ea6ca8 100644 --- a/config/make-windows-h-wrapper.py +++ b/config/make-windows-h-wrapper.py @@ -7,24 +7,21 @@ import re import textwrap import string -comment_re = re.compile(r"//[^\n]*\n|/\*.*\*/", re.S) -decl_re = re.compile( - r"""^(.+)\s+ # type +comment_re = re.compile(r'//[^\n]*\n|/\*.*\*/', re.S) +decl_re = re.compile(r'''^(.+)\s+ # type (\w+)\s* # name (?:\((.*)\))?$ # optional param tys - """, - re.X | re.S, -) + ''', re.X | re.S) def read_decls(filename): """Parse & yield C-style decls from an input file""" - with open(filename, "r") as fd: + with open(filename, 'r') as fd: # Strip comments from the source text. - text = comment_re.sub("", fd.read()) + text = comment_re.sub('', fd.read()) # Parse individual declarations. - raw_decls = [d.strip() for d in text.split(";") if d.strip()] + raw_decls = [d.strip() for d in text.split(';') if d.strip()] for raw in raw_decls: match = decl_re.match(raw) if match is None: @@ -32,16 +29,16 @@ def read_decls(filename): ty, name, params = match.groups() if params is not None: - params = [a.strip() for a in params.split(",") if a.strip()] + params = [a.strip() for a in params.split(',') if a.strip()] yield ty, name, params def generate(fd, consts_path, unicodes_path, template_path, compiler): # Parse the template - with open(template_path, "r") as template_fd: + with open(template_path, 'r') as template_fd: template = string.Template(template_fd.read()) - decls = "" + decls = '' # Each constant should be saved to a temporary, and then re-assigned to a # constant with the correct name, allowing the value to be determined by @@ -49,17 +46,13 @@ def generate(fd, consts_path, unicodes_path, template_path, compiler): for ty, name, args in read_decls(consts_path): assert args is None, "parameters in const decl!" - decls += textwrap.dedent( - """ + decls += textwrap.dedent(""" #ifdef {name} constexpr {ty} _tmp_{name} = {name}; #undef {name} constexpr {ty} {name} = _tmp_{name}; #endif - """.format( - ty=ty, name=name - ) - ) + """.format(ty=ty, name=name)) # Each unicode declaration defines a static inline function with the # correct types which calls the 'A' or 'W'-suffixed versions of the @@ -69,11 +62,10 @@ def generate(fd, consts_path, unicodes_path, template_path, compiler): assert args is not None, "argument list required for unicode decl" # Parameter & argument string list - params = ", ".join("%s a%d" % (ty, i) for i, ty in enumerate(args)) - args = ", ".join("a%d" % i for i in range(len(args))) + params = ', '.join('%s a%d' % (ty, i) for i, ty in enumerate(args)) + args = ', '.join('a%d' % i for i in range(len(args))) - decls += textwrap.dedent( - """ + decls += textwrap.dedent(""" #ifdef {name} #undef {name} static inline {ty} WINAPI @@ -86,10 +78,7 @@ def generate(fd, consts_path, unicodes_path, template_path, compiler): #endif }} #endif - """.format( - ty=ty, name=name, params=params, args=args - ) - ) + """.format(ty=ty, name=name, params=params, args=args)) # Write out the resulting file fd.write(template.substitute(decls=decls)) diff --git a/config/moz.build b/config/moz.build index 7651bcd111ea6943dce0d3377dc8a81d9d01ea65..2a14de6418b89f3e86902a22894533be8fe7fb1a 100644 --- a/config/moz.build +++ b/config/moz.build @@ -4,11 +4,11 @@ # 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/. -with Files("**"): - BUG_COMPONENT = ("Firefox Build System", "General") +with Files('**'): + BUG_COMPONENT = ('Firefox Build System', 'General') -with Files("mozunit/**"): - BUG_COMPONENT = ("Testing", "Python Test") +with Files('mozunit/**'): + BUG_COMPONENT = ('Testing', 'Python Test') DIST_INSTALL = False # For sanity's sake, we compile nsinstall without the wrapped system @@ -16,89 +16,73 @@ DIST_INSTALL = False NoVisibilityFlags() CONFIGURE_SUBST_FILES += [ - "tests/src-simple/Makefile", + 'tests/src-simple/Makefile', ] -if CONFIG["HOST_OS_ARCH"] != "WINNT": +if CONFIG['HOST_OS_ARCH'] != 'WINNT': HOST_SOURCES += [ - "nsinstall.c", - "pathsub.c", + 'nsinstall.c', + 'pathsub.c', ] - HostProgram("nsinstall_real") + HostProgram('nsinstall_real') PYTHON_UNITTEST_MANIFESTS += [ - "tests/python.ini", + 'tests/python.ini', ] -if CONFIG["CC_TYPE"] in ("clang", "gcc") and CONFIG["MOZ_OPTIMIZE"]: - CFLAGS += ["-O3"] +if CONFIG['CC_TYPE'] in ('clang', 'gcc') and CONFIG['MOZ_OPTIMIZE']: + CFLAGS += ['-O3'] -HOST_DEFINES["UNICODE"] = True -HOST_DEFINES["_UNICODE"] = True +HOST_DEFINES['UNICODE'] = True +HOST_DEFINES['_UNICODE'] = True -include("stl-headers.mozbuild") -if CONFIG["WRAP_STL_INCLUDES"]: +include('stl-headers.mozbuild') +if CONFIG['WRAP_STL_INCLUDES']: stl_compiler = None - if CONFIG["OS_TARGET"] == "WINNT": - stl_compiler = "msvc" + if CONFIG['OS_TARGET'] == 'WINNT': + stl_compiler = 'msvc' else: - stl_compiler = "gcc" + stl_compiler = 'gcc' if stl_compiler: # Note that the 'stl_wrappers' folder is known to the build system as # containing generated files; if this is changed here then the code in # GeneratedFile.__init__ in python/mozbuild/mozbuild/frontend/data.py # might need to be updated accordingly as well. - template_file = SRCDIR + "/%s-stl-wrapper.template.h" % stl_compiler - output_dir = "/dist/stl_wrappers" + template_file = SRCDIR + '/%s-stl-wrapper.template.h' % stl_compiler + output_dir = '/dist/stl_wrappers' # We have to use a sentinel file as the first file because the # file_generate action will create it for us, but we want to create all # the files in gen_wrappers() - outputs = tuple( - ["stl.sentinel"] + ["%s/%s" % (output_dir, h) for h in stl_headers] - ) + outputs = tuple(['stl.sentinel'] + ['%s/%s' % (output_dir, h) for h in stl_headers]) GeneratedFile( - *outputs, - script="make-stl-wrappers.py", - entry_point="gen_wrappers", - flags=[TOPOBJDIR + output_dir, stl_compiler, template_file] + stl_headers - ) + *outputs, script='make-stl-wrappers.py', entry_point='gen_wrappers', + flags=[TOPOBJDIR + output_dir, stl_compiler, template_file] + stl_headers) # Wrap to make it easier to use correctly # NOTE: If we aren't wrapping STL includes, we're building part of the browser # which won't need this wrapper, such as L10N. Just don't try to generate the # wrapper in that case. - if CONFIG["OS_TARGET"] == "WINNT": - GeneratedFile( - "/dist/stl_wrappers/windows.h", - script="make-windows-h-wrapper.py", - entry_point="generate", - inputs=[ - "windows-h-constant.decls.h", - "windows-h-unicode.decls.h", - "windows-h-wrapper.template.h", - ], - flags=[stl_compiler], - ) + if CONFIG['OS_TARGET'] == 'WINNT': + GeneratedFile('/dist/stl_wrappers/windows.h', + script='make-windows-h-wrapper.py', + entry_point='generate', + inputs = ['windows-h-constant.decls.h', + 'windows-h-unicode.decls.h', + 'windows-h-wrapper.template.h'], + flags=[stl_compiler]) -if CONFIG["WRAP_SYSTEM_INCLUDES"]: - include("system-headers.mozbuild") - output_dir = "/dist/system_wrappers" - outputs = tuple( - ["system-header.sentinel"] - + ["%s/%s" % (output_dir, h) for h in stl_headers + system_headers] - ) - GeneratedFile( - *outputs, - script="make-system-wrappers.py", - entry_point="gen_wrappers", - flags=[TOPOBJDIR + output_dir] + stl_headers + system_headers - ) +if CONFIG['WRAP_SYSTEM_INCLUDES']: + include('system-headers.mozbuild') + output_dir = '/dist/system_wrappers' + outputs = tuple(['system-header.sentinel'] + ['%s/%s' % (output_dir, h) for h in stl_headers + system_headers]) + GeneratedFile(*outputs, script='make-system-wrappers.py', + entry_point='gen_wrappers', + flags = [TOPOBJDIR + output_dir] + stl_headers + system_headers) -if CONFIG["COMPILE_ENVIRONMENT"] and CONFIG["CBINDGEN"]: +if CONFIG['COMPILE_ENVIRONMENT'] and CONFIG['CBINDGEN']: GeneratedFile( - "cbindgen-metadata.json", - script="/build/RunCbindgen.py", - entry_point="generate_metadata", - inputs=["!/.cargo/config"], - ) + 'cbindgen-metadata.json', + script='/build/RunCbindgen.py', + entry_point='generate_metadata', + inputs=['!/.cargo/config']) diff --git a/config/mozunit/mozunit/mozunit.py b/config/mozunit/mozunit/mozunit.py index bc327e47bb489f337a77ecda64edfe90c9c69309..260bbe9f3f8836788b6bde663773f1cc1de59627 100644 --- a/config/mozunit/mozunit/mozunit.py +++ b/config/mozunit/mozunit/mozunit.py @@ -23,15 +23,13 @@ try: # buildconfig doesn't yet support Python 3, so we can use pathlib to # resolve the topsrcdir relative to our current location. from pathlib import Path - topsrcdir = Path(here).parents[2] except ImportError: from mozbuild.base import MozbuildObject - build = MozbuildObject.from_environment(cwd=here) topsrcdir = build.topsrcdir -"""Helper to make python unit tests report the way that the Mozilla +'''Helper to make python unit tests report the way that the Mozilla unit test infrastructure expects tests to report. Usage: @@ -40,7 +38,7 @@ import mozunit if __name__ == '__main__': mozunit.main() -""" +''' class _MozTestResult(_TestResult): @@ -55,32 +53,32 @@ class _MozTestResult(_TestResult): else: return str(test) - def printStatus(self, status, test, message=""): + def printStatus(self, status, test, message=''): line = "{status} | {file} | {klass}.{test}{sep}{message}".format( status=status, file=inspect.getfile(test.__class__), klass=test.__class__.__name__, test=test._testMethodName, - sep=", " if message else "", + sep=', ' if message else '', message=message, ) self.stream.writeln(line) def addSuccess(self, test): _TestResult.addSuccess(self, test) - self.printStatus("TEST-PASS", test) + self.printStatus('TEST-PASS', test) def addSkip(self, test, reason): _TestResult.addSkip(self, test, reason) - self.printStatus("TEST-SKIP", test) + self.printStatus('TEST-SKIP', test) def addExpectedFailure(self, test, err): _TestResult.addExpectedFailure(self, test, err) - self.printStatus("TEST-KNOWN-FAIL", test) + self.printStatus('TEST-KNOWN-FAIL', test) def addUnexpectedSuccess(self, test): _TestResult.addUnexpectedSuccess(self, test) - self.printStatus("TEST-UNEXPECTED-PASS", test) + self.printStatus('TEST-UNEXPECTED-PASS', test) def addError(self, test, err): _TestResult.addError(self, test, err) @@ -96,15 +94,15 @@ class _MozTestResult(_TestResult): def printFail(self, test, err): exctype, value, tb = err - message = value or "NO MESSAGE" - if hasattr(value, "message"): + message = value or 'NO MESSAGE' + if hasattr(value, 'message'): message = value.message.splitlines()[0] # Skip test runner traceback levels while tb and self._is_relevant_tb_level(tb): tb = tb.tb_next if tb: _, ln, _ = inspect.getframeinfo(tb)[:3] - message = "line {0}: {1}".format(ln, message) + message = 'line {0}: {1}'.format(ln, message) self.printStatus("TEST-UNEXPECTED-FAIL", test, message) @@ -119,8 +117,8 @@ class MozTestRunner(_TestRunner): def _mocked_file(cls): - """Create a mocked file class that inherits from the given class.""" - + '''Create a mocked file class that inherits from the given class. + ''' class MockedFile(cls): def __init__(self, context, filename, content): self.context = context @@ -145,74 +143,73 @@ MockedBytesFile = _mocked_file(BytesIO) def normcase(path): - """ + ''' Normalize the case of `path`. Don't use `os.path.normcase` because that also normalizes forward slashes to backslashes on Windows. - """ - if sys.platform.startswith("win"): + ''' + if sys.platform.startswith('win'): return path.lower() return path class _MockBaseOpen(object): - """Callable that acts like the open() function; see MockedOpen for more + '''Callable that acts like the open() function; see MockedOpen for more info. - """ - + ''' def __init__(self, open, files): self.open = open self.files = files - def __call__(self, name, mode="r", buffering=None, encoding=None, newline=None): + def __call__(self, name, mode='r', buffering=None, encoding=None, newline=None): # open() can be called with an integer "name" (i.e. a file descriptor). # We don't generally do this in our codebase, but internal Python # libraries sometimes do and we want to handle that cleanly. if isinstance(name, int): - return self.open( - name, mode=mode, buffering=buffering, encoding=encoding, newline=newline - ) + return self.open(name, mode=mode, buffering=buffering, + encoding=encoding, newline=newline) # buffering is ignored. absname = normcase(os.path.abspath(name)) - if "w" in mode: + if 'w' in mode: file = self._mocked_file(absname, mode) elif absname in self.files: content = self.files[absname] if content is None: - raise IOError(2, "No such file or directory") + raise IOError(2, 'No such file or directory') file = self._mocked_file(absname, mode, content) - elif "a" in mode: - read_mode = "rb" if "b" in mode else "r" - file = self._mocked_file(absname, mode, self.open(name, read_mode).read()) + elif 'a' in mode: + read_mode = 'rb' if 'b' in mode else 'r' + file = self._mocked_file( + absname, mode, self.open(name, read_mode).read()) else: file = self.open(name, mode) - if "a" in mode: + if 'a' in mode: file.seek(0, os.SEEK_END) return file def _mocked_file(self, name, mode, content=None): - raise NotImplementedError("subclass must implement") + raise NotImplementedError('subclass must implement') class _MockPy2Open(_MockBaseOpen): def _mocked_file(self, name, mode, content=None): - content = six.ensure_binary(content or b"") + content = six.ensure_binary(content or b'') return MockedBytesFile(self, name, content) class _MockOpen(_MockBaseOpen): def _mocked_file(self, name, mode, content=None): - if "b" in mode: - content = six.ensure_binary(content or b"") + if 'b' in mode: + content = six.ensure_binary(content or b'') return MockedBytesFile(self, name, content) else: - content = six.ensure_text(content or u"") + content = six.ensure_text(content or u'') return MockedStringFile(self, name, content) class MockedOpen(object): - """ + ''' Context manager diverting the open builtin such that opening files can open "virtual" file instances given when creating a MockedOpen. @@ -232,7 +229,7 @@ class MockedOpen(object): f = open('foo', 'w') f.write('foo') self.assertRaises(Exception,f.open('foo', 'r')) - """ + ''' def __init__(self, files={}): self.files = {} @@ -241,7 +238,6 @@ class MockedOpen(object): def __enter__(self): import six.moves.builtins - self.open = six.moves.builtins.open self.io_open = io.open self._orig_path_exists = os.path.exists @@ -256,7 +252,6 @@ class MockedOpen(object): def __exit__(self, type, value, traceback): import six.moves.builtins - six.moves.builtins.open = self.open io.open = self.io_open os.path.exists = self._orig_path_exists @@ -264,7 +259,8 @@ class MockedOpen(object): os.path.isfile = self._orig_path_isfile def _wrapped_exists(self, p): - return self._wrapped_isfile(p) or self._wrapped_isdir(p) + return (self._wrapped_isfile(p) or + self._wrapped_isdir(p)) def _wrapped_isfile(self, p): p = normcase(p) @@ -279,7 +275,7 @@ class MockedOpen(object): def _wrapped_isdir(self, p): p = normcase(p) - p = p if p.endswith(("/", "\\")) else p + os.sep + p = p if p.endswith(('/', '\\')) else p + os.sep if any(f.startswith(p) for f in self.f