[vlc-commits] contrib: fxc2: Fix building fxc2 while targeting non x86 architectures

Martin Storsjö git at videolan.org
Thu May 2 23:52:26 CEST 2019


vlc | branch: master | Martin Storsjö <martin at martin.st> | Thu May  2 00:16:28 2019 +0300| [9c10728bf2f6c8a4acff8f1190a85be4a8b0747d] | committer: Martin Storsjö

contrib: fxc2: Fix building fxc2 while targeting non x86 architectures

As fxc2 relies on a precompiled binary for x86, which we need to run
at build time, we need to look for an x86 cross compiler, in case the
current target for contribs isn't x86.

Remove the patch for adding a meson build system to fxc2. fxc2 consists
of one single source file, and when building with meson, one must
create a cross file in order to specify using a different cross compiler,
just passing the name as a parameter isn't possible. Therefore, just
resort to manually compiling the single file, instead of adding a
new buildsystem that upstream doesn't contain and which makes cross
compiling with arbitrary compilers harder.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9c10728bf2f6c8a4acff8f1190a85be4a8b0747d
---

 .../fxc2/0003-Use-meson-as-a-build-system.patch    | 47 ----------------------
 contrib/src/fxc2/rules.mak                         | 23 +++++++++--
 2 files changed, 19 insertions(+), 51 deletions(-)

diff --git a/contrib/src/fxc2/0003-Use-meson-as-a-build-system.patch b/contrib/src/fxc2/0003-Use-meson-as-a-build-system.patch
deleted file mode 100644
index 272bf46da6..0000000000
--- a/contrib/src/fxc2/0003-Use-meson-as-a-build-system.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From 6289103998e7eb564e05f0866f4e5e9ba8afca45 Mon Sep 17 00:00:00 2001
-From: Pierre Lamot <pierre.lamot at yahoo.fr>
-Date: Mon, 14 Jan 2019 09:49:38 +0100
-Subject: [PATCH 3/4] Use meson as a build system
-
----
- meson.build | 28 ++++++++++++++++++++++++++++
- 1 file changed, 28 insertions(+)
- create mode 100644 meson.build
-
-diff --git a/meson.build b/meson.build
-new file mode 100644
-index 0000000..a3a8601
---- /dev/null
-+++ b/meson.build
-@@ -0,0 +1,28 @@
-+project('fxc2', 'cpp')
-+
-+if host_machine.system() != 'windows' or not host_machine.cpu_family().startswith('x86')
-+  error('only compilation for windows i686/x86_64 is supported')
-+endif
-+
-+executable(
-+  'fxc2',
-+  'fxc2.cpp',
-+  override_options : [
-+    'b_lundef=false',
-+    'b_asneeded=false'
-+  ],
-+  link_args: ['-static'],
-+  install: true
-+)
-+
-+d3dcompiler_dll = []
-+if host_machine.cpu_family() == 'x86'
-+  d3dcompiler_dll += 'dll/d3dcompiler_47_32.dll'
-+else
-+  d3dcompiler_dll += 'dll/d3dcompiler_47.dll'
-+endif
-+
-+install_data(d3dcompiler_dll,
-+  rename: ['d3dcompiler_47.dll'],
-+  install_dir : 'bin'
-+)
--- 
-2.19.1
-
diff --git a/contrib/src/fxc2/rules.mak b/contrib/src/fxc2/rules.mak
index 49ca73f80f..e1eff83cdf 100644
--- a/contrib/src/fxc2/rules.mak
+++ b/contrib/src/fxc2/rules.mak
@@ -19,12 +19,27 @@ fxc2: fxc2-$(FXC2_VERSION).tar.xz .sum-fxc2
 	tar xvf "$<" --strip-components=1 -C $@-$(FXC2_VERSION)
 	$(APPLY) $(SRC)/fxc2/0001-make-Vn-argument-as-optional-and-provide-default-var.patch
 	$(APPLY) $(SRC)/fxc2/0002-accept-windows-style-flags-and-splitted-argument-val.patch
-	$(APPLY) $(SRC)/fxc2/0003-Use-meson-as-a-build-system.patch
 	$(APPLY) $(SRC)/fxc2/0004-Revert-Fix-narrowing-conversion-from-int-to-BYTE.patch
 	$(MOVE)
 
+ifeq ($(ARCH),x86_64)
+FXC2_CXX=$(CXX)
+FXC2_DLL=dll/d3dcompiler_47.dll
+else ifeq ($(ARCH),i386)
+FXC2_CXX=$(CXX)
+FXC2_DLL=dll/d3dcompiler_47_32.dll
+else ifeq ($(shell which x86_64-w64-mingw32-g++ >/dev/null 2>&1 || echo FAIL),)
+FXC2_CXX=x86_64-w64-mingw32-g++
+FXC2_DLL=dll/d3dcompiler_47.dll
+else ifeq ($(shell which i686-w64-mingw32-g++ >/dev/null 2>&1 || echo FAIL),)
+FXC2_CXX=i686-w64-mingw32-g++
+FXC2_DLL=dll/d3dcompiler_47_32.dll
+else
+$(error No x86 (cross) compiler found for fxc2)
+endif
+
+
 .fxc2: fxc2 crossfile.meson
-	cd $< && rm -rf ./build
-	cd $< && $(HOSTVARS_MESON) $(MESON) build
-	cd $< && cd build && ninja install
+	cd $< && $(FXC2_CXX) -static fxc2.cpp -o fxc2.exe
+	cd $< && mkdir -p $(PREFIX)/bin && cp fxc2.exe $(PREFIX)/bin && cp $(FXC2_DLL) $(PREFIX)/bin/d3dcompiler_47.dll
 	touch $@



More information about the vlc-commits mailing list