bug 1399870 - Make DEFFILE a Path instead of a string. r?gps draft
authorTed Mielczarek <ted@mielczarek.org>
Thu, 14 Sep 2017 06:24:43 -0400
changeset 668585 e741faa38717e1f754ce2b03386809f6bfd521f9
parent 668584 bad8da300ca3c63680dc2b763db5b8ea2c90e36a
child 668586 e55f5733b30b15527f7a40df4ae56fb15062f9cd
push id81087
push userbmo:ted@mielczarek.org
push dateThu, 21 Sep 2017 20:59:05 +0000
reviewersgps
bugs1399870
milestone57.0a1
bug 1399870 - Make DEFFILE a Path instead of a string. r?gps DEFFILE is currently just used as a passthrough variable. All but one of the current uses of it 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. MozReview-Commit-ID: IRokABaZW2c
accessible/interfaces/ia2/moz.build
accessible/interfaces/msaa/moz.build
accessible/ipc/win/handler/moz.build
build/win32/crashinjectdll/moz.build
config/external/lgpllibs/moz.build
config/rules.mk
dom/plugins/test/testplugin/testplugin.mozbuild
gfx/angle/src/libEGL/moz.build
gfx/angle/src/libGLESv2/moz.build
modules/pdfium/moz.build
mozglue/build/moz.build
python/mozbuild/mozbuild/frontend/context.py
python/mozbuild/mozbuild/frontend/emitter.py
--- a/accessible/interfaces/ia2/moz.build
+++ b/accessible/interfaces/ia2/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 GeckoSharedLibrary('IA2Marshal', linkage=None)
 
 DEFINES['REGISTER_PROXY_DLL'] = True
 
-DEFFILE = SRCDIR + '/IA2Marshal.def'
+DEFFILE = 'IA2Marshal.def'
 
 OS_LIBS += [
     'uuid',
     'kernel32',
     'rpcrt4',
     'ole32',
     'oleaut32',
 ]
--- a/accessible/interfaces/msaa/moz.build
+++ b/accessible/interfaces/msaa/moz.build
@@ -13,17 +13,17 @@ SOURCES += [
     'AccessibleMarshalThunk.c',
 ]
 
 DEFINES['REGISTER_PROXY_DLL'] = True
 # The following line is required to preserve compatibility with older versions
 # of AccessibleMarshal.dll.
 DEFINES['PROXY_CLSID'] = 'IID_ISimpleDOMNode'
 
-DEFFILE = SRCDIR + '/AccessibleMarshal.def'
+DEFFILE = 'AccessibleMarshal.def'
 
 OS_LIBS += [
     'kernel32',
     'rpcrt4',
     'oleaut32',
 ]
 
 GENERATED_FILES += [
--- a/accessible/ipc/win/handler/moz.build
+++ b/accessible/ipc/win/handler/moz.build
@@ -27,17 +27,17 @@ GENERATED_FILES += [
     'dlldata.c',
     'HandlerData.h',
     'HandlerData.tlb',
     'HandlerData_c.c',
     'HandlerData_i.c',
     'HandlerData_p.c',
 ]
 
-DEFFILE = SRCDIR + '/AccessibleHandler.def'
+DEFFILE = 'AccessibleHandler.def'
 
 USE_LIBS += [
     'mscom_oop',
 ]
 
 OS_LIBS += [
     'rpcrt4',
 ]
--- 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',
 ]
 
 SharedLibrary('crashinjectdll')
 
-DEFFILE = SRCDIR + '/crashinjectdll.def'
+DEFFILE = 'crashinjectdll.def'
 
 USE_STATIC_LIBS = True
 NO_PGO = True
--- a/config/external/lgpllibs/moz.build
+++ b/config/external/lgpllibs/moz.build
@@ -10,9 +10,9 @@
 #
 # Any library added here should also be reflected in the about:license page.
 
 GeckoSharedLibrary('lgpllibs', linkage=None)
 SHARED_LIBRARY_NAME = 'lgpllibs'
 
 if CONFIG['MOZ_LIBAV_FFT']:
     DIRS += ['/media/libav']
-    DEFFILE = SRCDIR + '/lgpllibs.def'
+    DEFFILE = 'lgpllibs.def'
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -169,24 +169,24 @@ COMPILE_CFLAGS += $(COMPILE_PDB_FLAG)
 COMPILE_CXXFLAGS += $(COMPILE_PDB_FLAG)
 
 LINK_PDBFILE ?= $(basename $(@F)).pdb
 ifdef MOZ_DEBUG
 CODFILE=$(basename $(@F)).cod
 endif
 
 ifdef DEFFILE
-OS_LDFLAGS += -DEF:$(call normalizepath,$(DEFFILE))
+OS_LDFLAGS += -DEF:$(DEFFILE)
 EXTRA_DEPS += $(DEFFILE)
 endif
 
 else #!GNU_CC
 
 ifdef DEFFILE
-OS_LDFLAGS += $(call normalizepath,$(DEFFILE))
+OS_LDFLAGS += $(DEFFILE)
 EXTRA_DEPS += $(DEFFILE)
 endif
 
 endif # !GNU_CC
 
 endif # WINNT
 
 ifeq (arm-Darwin,$(CPU_ARCH)-$(OS_TARGET))
--- a/dom/plugins/test/testplugin/testplugin.mozbuild
+++ b/dom/plugins/test/testplugin/testplugin.mozbuild
@@ -37,17 +37,17 @@ USE_STATIC_LIBS = True
 # Don't use STL wrappers; nptest isn't Gecko code
 DISABLE_STL_WRAPPING = True
 
 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']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
     CXXFLAGS += CONFIG['MOZ_GTK2_CFLAGS']
     CFLAGS += CONFIG['MOZ_GTK2_CFLAGS']
     OS_LIBS += CONFIG['MOZ_GTK2_LIBS']
--- a/gfx/angle/src/libEGL/moz.build
+++ b/gfx/angle/src/libEGL/moz.build
@@ -74,11 +74,11 @@ else:
     '\'%s/lib/%s/d3d9.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']),
     '\'%s/lib/%s/dxguid.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']),
   ]
 
 
 GeckoSharedLibrary('libEGL', linkage=None)
 
 RCFILE = SRCDIR + '/libEGL.rc'
-DEFFILE = SRCDIR + '/libEGL.def'
+DEFFILE = 'libEGL.def'
 
 USE_LIBS += ['libANGLE']
--- a/gfx/angle/src/libGLESv2/moz.build
+++ b/gfx/angle/src/libGLESv2/moz.build
@@ -79,12 +79,12 @@ else:
   EXTRA_DSO_LDOPTS += [
     '\'%s/lib/%s/d3d9.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']),
     '\'%s/lib/%s/dxguid.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']),
   ]
 
 GeckoSharedLibrary('libGLESv2', linkage=None)
 
 RCFILE = SRCDIR + '/libGLESv2.rc'
-DEFFILE = SRCDIR + '/libGLESv2.def'
+DEFFILE = 'libGLESv2.def'
 
 USE_LIBS += ['libANGLE']
 
--- a/modules/pdfium/moz.build
+++ b/modules/pdfium/moz.build
@@ -557,9 +557,9 @@ USE_LIBS += [
 ]
 
 # We allow warnings for third-party code that can be updated from upstream.
 ALLOW_COMPILER_WARNINGS = True
 
 GeckoSharedLibrary('pdfium', linkage=None)
 
 if CONFIG['OS_TARGET'] == 'WINNT':
-    DEFFILE = SRCDIR + '/pdfium.def'
+    DEFFILE = 'pdfium.def'
--- a/mozglue/build/moz.build
+++ b/mozglue/build/moz.build
@@ -17,17 +17,17 @@ if CONFIG['OS_TARGET'] == 'Android':
     ]
 
 if CONFIG['MOZ_ASAN']:
     SOURCES += [
         'AsanOptions.cpp',
     ]
 
 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',
     ]
 
 if not CONFIG['JS_STANDALONE']:
 
     if CONFIG['MOZ_MEMORY'] and FORCE_SHARED_LIB:
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -1262,17 +1262,17 @@ VARIABLES = {
         """),
 
     'RCINCLUDE': (unicode, unicode,
         """The resource script file to be included in the default .res file.
 
         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.
         """),
 
     'LD_VERSION_SCRIPT': (unicode, unicode,
         """The linker version script for shared libraries.
 
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -905,27 +905,39 @@ class TreeMetadataEmitter(LoggingMixin):
             'ANDROID_APK_NAME',
             'ANDROID_APK_PACKAGE',
             'ANDROID_GENERATED_RESFILES',
             'DISABLE_STL_WRAPPING',
             'EXTRA_DSO_LDOPTS',
             'RCFILE',
             'RESFILE',
             'RCINCLUDE',
-            'DEFFILE',
             'WIN32_EXE_LDFLAGS',
             'LD_VERSION_SCRIPT',
             'USE_EXTENSION_MANIFEST',
             'NO_JS_MANIFEST',
             'HAS_MISC_RULE',
         ]
         for v in varlist:
             if v in context and context[v]:
                 passthru.variables[v] = context[v]
 
+        deffile = context.get('DEFFILE')
+        if deffile:
+            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
+            passthru.variables['DEFFILE'] = path
+
         if context.config.substs.get('OS_TARGET') == 'WINNT' and \
                 context['DELAYLOAD_DLLS']:
             context['LDFLAGS'].extend([('-DELAYLOAD:%s' % dll)
                 for dll in context['DELAYLOAD_DLLS']])
             context['OS_LIBS'].append('delayimp')
 
         for v in ['CFLAGS', 'CXXFLAGS', 'CMFLAGS', 'CMMFLAGS', 'ASFLAGS',
                   'LDFLAGS', 'HOST_CFLAGS', 'HOST_CXXFLAGS']: