From de99592416385a202f9293eb66aeb9411d490570 Mon Sep 17 00:00:00 2001 From: Ted Mielczarek Date: Tue, 18 Sep 2018 15:50:19 -0400 Subject: [PATCH] Bug 1399870 - make DEFFILE a Path instead of a string; r=gps All but one of the current uses of DEFFILE use `SRCDIR + '/file.def'` to get a srcdir-relative path anyway, and the other one wants an objdir-relative path, so using Path makes everything clearer. This makes it more straightforward to translate the paths for the WSL build. --- accessible/interfaces/ia2/moz.build | 2 +- accessible/interfaces/msaa/moz.build | 2 +- accessible/ipc/win/handler/moz.build | 2 +- build/win32/crashinjectdll/moz.build | 2 +- config/rules.mk | 3 --- .../test/testplugin/testplugin.mozbuild | 2 +- gfx/angle/targets/libEGL/moz.build | 2 +- gfx/angle/targets/libGLESv2/moz.build | 2 +- gfx/angle/update-angle.py | 2 +- modules/pdfium/moz.build | 2 +- mozglue/build/moz.build | 2 +- python/mozbuild/mozbuild/frontend/context.py | 2 +- python/mozbuild/mozbuild/frontend/emitter.py | 24 +++++++++++++++---- .../backend/data/variable_passthru/baz.def | 0 .../test/backend/test_recursivemake.py | 6 +++-- .../frontend/data/variable-passthru/baz.def | 0 .../mozbuild/test/frontend/test_emitter.py | 4 +++- 17 files changed, 37 insertions(+), 22 deletions(-) mode change 100644 => 100755 gfx/angle/update-angle.py create mode 100644 python/mozbuild/mozbuild/test/backend/data/variable_passthru/baz.def create mode 100644 python/mozbuild/mozbuild/test/frontend/data/variable-passthru/baz.def diff --git a/accessible/interfaces/ia2/moz.build b/accessible/interfaces/ia2/moz.build index da3d1d39b058..e12747769c5f 100644 --- a/accessible/interfaces/ia2/moz.build +++ b/accessible/interfaces/ia2/moz.build @@ -8,7 +8,7 @@ GeckoSharedLibrary('IA2Marshal', linkage=None) DEFINES['REGISTER_PROXY_DLL'] = True -DEFFILE = SRCDIR + '/IA2Marshal.def' +DEFFILE = 'IA2Marshal.def' OS_LIBS += [ 'uuid', diff --git a/accessible/interfaces/msaa/moz.build b/accessible/interfaces/msaa/moz.build index 14aabb852e2f..f8ae7ca4344d 100644 --- a/accessible/interfaces/msaa/moz.build +++ b/accessible/interfaces/msaa/moz.build @@ -18,7 +18,7 @@ DEFINES['REGISTER_PROXY_DLL'] = True # of AccessibleMarshal.dll. DEFINES['PROXY_CLSID'] = 'IID_ISimpleDOMNode' -DEFFILE = SRCDIR + '/AccessibleMarshal.def' +DEFFILE = 'AccessibleMarshal.def' OS_LIBS += [ 'kernel32', diff --git a/accessible/ipc/win/handler/moz.build b/accessible/ipc/win/handler/moz.build index fae401fef0b5..f3c7cc8af472 100644 --- a/accessible/ipc/win/handler/moz.build +++ b/accessible/ipc/win/handler/moz.build @@ -37,7 +37,7 @@ GENERATED_FILES += [ 'HandlerData_p.c', ] -DEFFILE = SRCDIR + '/AccessibleHandler.def' +DEFFILE = 'AccessibleHandler.def' USE_LIBS += [ 'mscom_oop', diff --git a/build/win32/crashinjectdll/moz.build b/build/win32/crashinjectdll/moz.build index d062589e775a..270b88ec07f6 100644 --- a/build/win32/crashinjectdll/moz.build +++ b/build/win32/crashinjectdll/moz.build @@ -10,7 +10,7 @@ SOURCES += [ SharedLibrary('crashinjectdll') -DEFFILE = SRCDIR + '/crashinjectdll.def' +DEFFILE = 'crashinjectdll.def' USE_STATIC_LIBS = True NO_PGO = True diff --git a/config/rules.mk b/config/rules.mk index 5ba50272a4f6..7e6a6806bf51 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -153,9 +153,6 @@ CODFILE=$(basename $(@F)).cod endif endif # !GNU_CC - -EXTRA_DEPS += $(DEFFILE) - endif # WINNT ifeq (arm-Darwin,$(CPU_ARCH)-$(OS_TARGET)) diff --git a/dom/plugins/test/testplugin/testplugin.mozbuild b/dom/plugins/test/testplugin/testplugin.mozbuild index ef87fb6eb34a..2207005fa854 100644 --- a/dom/plugins/test/testplugin/testplugin.mozbuild +++ b/dom/plugins/test/testplugin/testplugin.mozbuild @@ -42,7 +42,7 @@ NO_PGO = True if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': RCFILE = 'nptest.rc' RESFILE = 'nptest.res' - DEFFILE = SRCDIR + '/nptest.def' + DEFFILE = 'nptest.def' if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa' and '64' in CONFIG['OS_TEST']: OS_LIBS += ['-framework Carbon'] diff --git a/gfx/angle/targets/libEGL/moz.build b/gfx/angle/targets/libEGL/moz.build index 4cfbea1ab601..7dc47d165b6f 100644 --- a/gfx/angle/targets/libEGL/moz.build +++ b/gfx/angle/targets/libEGL/moz.build @@ -153,6 +153,6 @@ OS_LIBS += [ # '/WX', #] -DEFFILE = SRCDIR + '/../../checkout/src/libEGL/libEGL.def' +DEFFILE = '../../checkout/src/libEGL/libEGL.def' RCFILE = '../../checkout/src/libEGL/libEGL.rc' GeckoSharedLibrary('libEGL', linkage=None) diff --git a/gfx/angle/targets/libGLESv2/moz.build b/gfx/angle/targets/libGLESv2/moz.build index 9e25a6cdf20c..bc4fded68124 100644 --- a/gfx/angle/targets/libGLESv2/moz.build +++ b/gfx/angle/targets/libGLESv2/moz.build @@ -171,6 +171,6 @@ OS_LIBS += [ # '/WX', #] -DEFFILE = SRCDIR + '/../../checkout/src/libGLESv2/libGLESv2_autogen.def' +DEFFILE = '../../checkout/src/libGLESv2/libGLESv2_autogen.def' RCFILE = '../../checkout/src/libGLESv2/libGLESv2.rc' GeckoSharedLibrary('libGLESv2', linkage=None) diff --git a/gfx/angle/update-angle.py b/gfx/angle/update-angle.py old mode 100644 new mode 100755 index a5e21375ffe6..68eb5320062d --- a/gfx/angle/update-angle.py +++ b/gfx/angle/update-angle.py @@ -509,7 +509,7 @@ def export_target(root): total_used_files.add(def_path) def_rel_path = list(fixup_paths([def_path]))[0] - extras['DEFFILE'] = "SRCDIR + '/{}'".format(def_rel_path) + extras['DEFFILE'] = "'{}'".format(def_rel_path) os_libs = list(map( lambda x: x[:-len('.lib')], set(accum_desc.get('libs', [])) )) diff --git a/modules/pdfium/moz.build b/modules/pdfium/moz.build index 48547e2f2ac7..9ede8dfbe8bc 100644 --- a/modules/pdfium/moz.build +++ b/modules/pdfium/moz.build @@ -562,4 +562,4 @@ AllowCompilerWarnings() GeckoSharedLibrary('pdfium', linkage=None) if CONFIG['OS_TARGET'] == 'WINNT': - DEFFILE = SRCDIR + '/pdfium.def' + DEFFILE = 'pdfium.def' diff --git a/mozglue/build/moz.build b/mozglue/build/moz.build index 4945d1663f5c..dacfa1a2e226 100644 --- a/mozglue/build/moz.build +++ b/mozglue/build/moz.build @@ -30,7 +30,7 @@ if CONFIG['MOZ_UBSAN']: ] if CONFIG['OS_TARGET'] == 'WINNT': - DEFFILE = 'mozglue.def' + DEFFILE = '!mozglue.def' # We'll break the DLL blocklist if we immediately load user32.dll DELAYLOAD_DLLS += [ 'user32.dll', diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index b72094eac1e6..76109447c89a 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -1614,7 +1614,7 @@ VARIABLES = { This variable can only be used on Windows. """), - 'DEFFILE': (unicode, unicode, + 'DEFFILE': (Path, unicode, """The program .def (module definition) file. This variable can only be used on Windows. diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index ab22d59dd732..6d4211520537 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -1036,7 +1036,6 @@ class TreeMetadataEmitter(LoggingMixin): 'RCFILE', 'RESFILE', 'RCINCLUDE', - 'DEFFILE', 'WIN32_EXE_LDFLAGS', 'USE_EXTENSION_MANIFEST', 'NO_JS_MANIFEST', @@ -1067,13 +1066,28 @@ class TreeMetadataEmitter(LoggingMixin): if 'LDFLAGS' in context and context['LDFLAGS']: computed_link_flags.resolve_flags('MOZBUILD', context['LDFLAGS']) - deffile = context['DEFFILE'] - if deffile and context.config.substs.get('OS_ARCH') == 'WINNT': + deffile = context.get('DEFFILE') + if deffile and context.config.substs.get('OS_TARGET') == 'WINNT': + if isinstance(deffile, SourcePath): + if not os.path.exists(deffile.full_path): + raise SandboxValidationError( + 'Path specified in DEFFILE does not exist: %s ' + '(resolved to %s)' % (deffile, + deffile.full_path), context) + path = mozpath.relpath(deffile.full_path, context.objdir) + else: + path = deffile.target_basename + + # We don't have any better way to indicate that the def file + # is a dependency to whatever we're building beyond stuffing + # it into EXTRA_DEPS. + passthru.variables['EXTRA_DEPS'] = [path] + if context.config.substs.get('GNU_CC'): - computed_link_flags.resolve_flags('DEFFILE', [deffile]) + computed_link_flags.resolve_flags('DEFFILE', [path]) else: computed_link_flags.resolve_flags('DEFFILE', - ['-DEF:' + deffile]) + ['-DEF:' + path]) dist_install = context['DIST_INSTALL'] if dist_install is True: diff --git a/python/mozbuild/mozbuild/test/backend/data/variable_passthru/baz.def b/python/mozbuild/mozbuild/test/backend/data/variable_passthru/baz.def new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py index 33b794953652..ad250d13d559 100644 --- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py +++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py @@ -325,8 +325,10 @@ class TestRecursiveMakeBackend(BackendTester): 'RCINCLUDE': [ 'RCINCLUDE := bar.rc', ], - 'DEFFILE': [ - 'DEFFILE := baz.def', + 'EXTRA_DEPS': [ + 'EXTRA_DEPS += %s' % mozpath.join(mozpath.relpath(env.topsrcdir, + env.topobjdir), + 'baz.def'), ], 'WIN32_EXE_LDFLAGS': [ 'WIN32_EXE_LDFLAGS += -subsystem:console', diff --git a/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/baz.def b/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/baz.def new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/mozbuild/mozbuild/test/frontend/test_emitter.py b/python/mozbuild/mozbuild/test/frontend/test_emitter.py index 784464ea0321..d4c7ee84e4ab 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py +++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py @@ -190,7 +190,9 @@ class TestEmitterBasic(unittest.TestCase): 'RCFILE': 'foo.rc', 'RESFILE': 'bar.res', 'RCINCLUDE': 'bar.rc', - 'DEFFILE': 'baz.def', + 'EXTRA_DEPS': [mozpath.join(mozpath.relpath(reader.config.topsrcdir, + reader.config.topobjdir), + 'baz.def')], 'WIN32_EXE_LDFLAGS': ['-subsystem:console'], }