Bug 1370007 Generate Shaders on a MinGW Cross Compile on Linux r=dvander,ted
authorTom Ritter <tom@mozilla.com>
Mon, 24 Jul 2017 14:32:08 -0500
changeset 419427 aeb9b61cd780df786b38c415fa67fe692bda68b0
parent 419426 6a43e1437ab6a76261ab3a253d955b754a0e02b9
child 419428 05dde481973c4fd927c2992195adaa5a3eb2f2f9
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander, ted
bugs1370007, 1365859
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1370007 Generate Shaders on a MinGW Cross Compile on Linux r=dvander,ted Bug 1365859 introduced a dependency on the Visual Studio binary 'fxc' to generate Shader bytecode. This was unavailable when compiling for Windows on Linux as part of a MinGW build. This commit adds a configure check for fxc, and also searches for fxc2, which was written (https://github.com/tomrittervg/fxc2) to be a tiny application that wraps D3DCompileFromFile and can produce similar (but not exactly the same) output as fxc. fxc2 is compiled using MinGW for Windows, and runs under wine, so we need to check for wine also. Finally, fxc outputs some include information fxc2 doesn't, so we will just change that assert to not take effect. MozReview-Commit-ID: 8LVxuODi6cV
build/moz.configure/toolchain.configure
gfx/layers/d3d11/genshaders.py
gfx/layers/moz.build
old mode 100644
new mode 100755
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1042,16 +1042,24 @@ set_config('VISIBILITY_FLAGS', visibilit
 # We only want to include windows.configure when we are compiling on
 # Windows, for Windows.
 @depends(target, host)
 def is_windows(target, host):
     return host.kernel == 'WINNT' and target.kernel == 'WINNT'
 
 include('windows.configure', when=is_windows)
 
+# Shader Compiler for Windows (and MinGW Cross Compile)
+# ==============================================================
+
+fxc = check_prog('FXC', ('fxc.exe', 'fxc2.exe'), when=depends(target)
+                 (lambda t: t.kernel == 'WINNT'))
+wine = check_prog('WINE', ['wine'], when=depends(target, host)
+                  (lambda t, h: t.kernel == 'WINNT' and h.kernel == 'Linux'))
+
 # Security Hardening
 # ==============================================================
 
 option('--enable-hardening', env='MOZ_SECURITY_HARDENING',
        help='Enables security hardening compiler options')
 
 @depends('--enable-hardening', c_compiler)
 def security_hardening_cflags(value, c_compiler):
old mode 100644
new mode 100755
--- a/gfx/layers/d3d11/genshaders.py
+++ b/gfx/layers/d3d11/genshaders.py
@@ -5,16 +5,17 @@ import argparse
 import codecs
 import locale
 import os
 import re
 import subprocess
 import sys
 import tempfile
 import yaml
+import buildconfig
 
 def shell_main():
   parser = argparse.ArgumentParser()
   parser.add_argument('-o', '--output', type=str, required=True,
                       help='Output file')
   parser.add_argument('manifest', type=str,
                       help='Manifest source file')
   args = parser.parse_args()
@@ -65,39 +66,43 @@ def process_manifest(output_fp, manifest
 
   output_fp.write(FOOTER)
   return deps
 
 def run_fxc(shader_model,
             shader_file,
             shader_name,
             output_fp):
+  fxc_location = buildconfig.substs['FXC']
+
   argv = [
-    'fxc',
+    fxc_location,
     '-nologo',
     '-T{0}'.format(shader_model),
     shader_file,
     '-E{0}'.format(shader_name),
     '-Vn{0}'.format(shader_name),
     '-Vi',
   ]
+  if 'Linux' in buildconfig.substs['HOST_OS_ARCH']:
+    argv.insert(0, buildconfig.substs['WINE'])
   if shader_model.startswith('vs_'):
     argv += ['-DVERTEX_SHADER']
   elif shader_model.startswith('ps_'):
     argv += ['-DPIXEL_SHADER']
 
   deps = None
   with ScopedTempFilename() as temp_filename:
     argv += ['-Fh{0}'.format(temp_filename)]
 
     sys.stdout.write('{0}\n'.format(' '.join(argv)))
     proc_stdout = subprocess.check_output(argv)
     proc_stdout = decode_console_text(sys.stdout, proc_stdout)
     deps = find_dependencies(proc_stdout)
-    assert len(deps) > 0
+    assert 'fxc2' in fxc_location or len(deps) > 0
 
     with open(temp_filename, 'r') as temp_fp:
       output_fp.write(temp_fp.read())
 
   output_fp.write("ShaderBytes s{0} = {{ {0}, sizeof({0}) }};\n".format(
     shader_name))
   return deps
 
old mode 100644
new mode 100755