Bug 1370007 Generate Shaders on a MinGW Cross Compile on Linux r=dvander,ted
☠☠ backed out by 173533a31006 ☠ ☠
authorTom Ritter <tom@mozilla.com>
Thu, 06 Jul 2017 15:35:49 -0500
changeset 409245 018e683b25cda1eae9430add87ae3b647c4b3a8d
parent 409244 8c55a7d1e55c02f89468d3a50df45211c2408e28
child 409246 da8c70e7f313005b615342d394bd4da581fe6a85
push id59
push userfmarier@mozilla.com
push dateTue, 11 Jul 2017 23:52:02 +0000
reviewersdvander, ted
bugs1370007, 1365859
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
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
   return deps
 def run_fxc(shader_model,
+  fxc_location = buildconfig.substs['FXC']
   argv = [
-    'fxc',
+    fxc_location,
+  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("ShaderBytes s{0} = {{ {0}, sizeof({0}) }};\n".format(
   return deps
old mode 100644
new mode 100755
--- a/moz.configure
+++ b/moz.configure
@@ -465,16 +465,19 @@ def nsis_binary_type(nsis):
 def nsis_flags(host):
     if host.kernel != 'WINNT':
         return '-nocd'
     return ''
 set_config('MAKENSISU_FLAGS', nsis_flags)
+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'))
 # Fallthrough to autoconf-based configure
 def all_paths():
     return __sandbox__._all_paths
 set_config('ALL_CONFIGURE_PATHS', all_paths())