[librsvg] Visual Studio: Expand cross-compilation capabilities
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Visual Studio: Expand cross-compilation capabilities
- Date: Fri, 10 Jul 2020 04:26:30 +0000 (UTC)
commit 4ed8cb281ab746a260e4ea42b60ea83b5ea006eb
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Fri Jul 10 12:10:52 2020 +0800
Visual Studio: Expand cross-compilation capabilities
With the newly-added support in the NMake Makefiles for building for ARM64
Windows, this expands cross-compilation support for the following:
* Building for x64 Windows on a 32-bit or ARM64 Windows system
We do already support cross-compiling for 32-bit systems on x64 or ARM64
Windows systems even before we added ARM64 build support for the Rustified
librsvg.
This also fixes building on x64 systems for people that wish to build using
a x86-to-x64 Visual Studio cross-compiler.
Also add further notes on the requirements and limitations for carrying out
such cross-compilations; specifically note that building introspection files
are not currently supported for any ARM64 builds, since no official ARM64
Python binaries/installers exist, and note that building introspection files is
supported only if the host system is capable of running the target binaries.
win32/README.txt | 21 +++++++++++++++------
win32/rsvg-rust.mak | 22 ++++++++++++++++------
2 files changed, 31 insertions(+), 12 deletions(-)
---
diff --git a/win32/README.txt b/win32/README.txt
index 31d376a7..f3394d67 100644
--- a/win32/README.txt
+++ b/win32/README.txt
@@ -29,18 +29,27 @@ You will also need the following tools:
build the introspection files; if building the introspection files, the
Python installation must match the version, architecture and configuration
of the Python installation that was used to build your copy of
- GObject-Introspection).
+ GObject-Introspection). Note that introspection files cannot be built in
+ for builds that produce binaries that are not compatible with the running
+ system where the build is being carried out. This means, specifically,
+ introspection files for ARM64 builds are not currently supported also due to a
+ lack of an official native ARM64 Python build.
-For introspection builds, the pkg-config (or compatible) tool is also needed
and the introspection files and pkg-config files for the dependent libraries
(if applicable) are also needed. You will need to set PKG_CONFIG_PATH
if the pkg-config files cannot be found from the default locations that
pkg-config will look for.
-It is now possible to cross-compile librsvg for ARM64 Windows using this set of
-NMake Makefiles. You will need to ensure that the Visual Studio ARM64 cross
-compiler (either for x86 or for amd64) is installed, and you have installed the
-`aarch64-pc-windows-msvc` target (rust-std library) via `rustup`. Such builds
-can be carried out on a normal x86/x86-64 Windows 7+ or on Windows 10 ARM64.
+It is now possible to cross-compile librsvg for ARM64 Windows, as well as for
+x64 Windows on 32-bit or ARM64 Windows systems, using this set of NMake Makefiles.
+You will need to ensure that the Visual Studio ARM64 and/or x64 cross compiler
+appropriate for your system is installed, and you have installed the
+`aarch64-pc-windows-msvc` and/or 'x86_64-pc-windows-msvc' target (rust-std library)
+via `rustup` for your Rust toolchain. Similarly, you may choose to use an x86-to-x64
+Visual Studio cross compiler, even on an x64 Windows system, so this will also require
+that you have installed the 'x86_64-pc-windows-msvc' target for your currently-active
+Rust toolchain (see 'rustup default'). Such builds can be carried out on a normal
+x86/x86-64 Windows 7+ or on Windows 10 ARM64.
It is recommended that the dependent libraries are built with the same version
of Visual Studio that is being used to build librsvg, as far as possible.
diff --git a/win32/rsvg-rust.mak b/win32/rsvg-rust.mak
index 19329a35..91bd798b 100644
--- a/win32/rsvg-rust.mak
+++ b/win32/rsvg-rust.mak
@@ -13,9 +13,18 @@ CARGO = cargo
RUSTUP = rustup
!endif
+# Use Rust's cross compiling capabilities?
+!ifndef FORCE_CROSS
+FORCE_CROSS = 0
+!endif
+
!if "$(PLAT)" == "x64"
RUST_TARGET = x86_64
+!if "$(PROCESSOR_ARCHITECTURE)" == "ARM64" || "$(PROCESSOR_ARCHITECTURE)" == "x86"
+FORCE_CROSS = 1
+!endif
!elseif "$(PLAT)" == "arm64"
+FORCE_CROSS = 1
RUST_TARGET = aarch64
!else
RUST_TARGET = i686
@@ -39,13 +48,14 @@ CARGO_CMD = $(CARGO) build $(CARGO_TARGET) --release
CARGO_CMD = $(CARGO) build $(CARGO_TARGET)
!endif
-# For building the Rust bits for ARM64 Windows, we need to use a cross compiler,
+# For building the Rust bits for ARM64 Windows, or when we are building on
+# ARM64 or 32-bit Windows for x64, we need to use a cross compiler,
# and it requires us to set up a default cmd.exe environment without any of the
# MSVC envvars, except the absolutely necessary ones. So, we need to put those
# and the calls to cargo and therefore rustc in a temporary .bat file and use
# 'start /i ...' to call that .bat file
-!if "$(PLAT)" == "arm64"
-build-arm64-$(CFG).bat:
+!if $(FORCE_CROSS) > 0
+build-$(PLAT)-$(CFG).bat:
@echo @echo off>$@
@echo set CommandPromptType=>>$@
@echo set DevEnvDir=>>$@
@@ -86,14 +96,14 @@ build-arm64-$(CFG).bat:
@echo cd ..>>$@
@echo $(CARGO_CMD) --verbose>>$@
-vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\rsvg_c_api.lib:
build-arm64-$(CFG).bat
+vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\rsvg_c_api.lib:
build-$(PLAT)-$(CFG).bat
@echo Please do not manually close the command window that pops up...
@echo.
@echo If this fails due to LNK1112 or a linker executable cannot be found, run
@echo 'nmake /f Makefile CFG=$(CFG) PREFIX=$(PREFIX) $**',
@echo and then run 'start /i /wait cmd /c $**', and then continue
@echo the build with your original NMake command line.
- @start "Building the Rust bits for ARM64 Windows MSVC Build, please do not close this console
window..." /wait /i cmd /c $**
+ @start "Building the Rust bits for $(PLAT) Windows MSVC Build, please do not close this console
window..." /wait /i cmd /c $**
@del /f/q $**
!else
@@ -112,7 +122,7 @@ vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\r
cargo-clean:
@set PATH=%PATH%;%HOMEPATH%\.cargo\bin
@set CARGO_TARGET_DIR=win32\vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api
- @if exist build-arm64-$(CFG).bat del /f/q build-arm64-$(CFG).bat
+ @if exist build-$(PLAT)-$(CFG).bat del /f/q build-$(PLAT)-$(CFG).bat
@cd ..
@$(CARGO) clean
@cd win32
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]