Support building UWP with native UWP rustc target.

This commit is contained in:
Josh Matthews 2019-09-11 16:12:33 -04:00
parent 723df4abcf
commit 5367da98f8
11 changed files with 949 additions and 919 deletions

View file

@ -25,8 +25,14 @@ ar = "aarch64-linux-gnu-ar"
[target.x86_64-pc-windows-msvc] [target.x86_64-pc-windows-msvc]
linker = "lld-link.exe" linker = "lld-link.exe"
[target.x86_64-uwp-windows-msvc]
linker = "lld-link.exe"
[target.i686-pc-windows-msvc] [target.i686-pc-windows-msvc]
linker = "lld-link.exe" linker = "lld-link.exe"
[target.aarch64-pc-windows-msvc] [target.aarch64-pc-windows-msvc]
linker = "lld-link.exe" linker = "lld-link.exe"
[target.aarch64-uwp-windows-msvc]
linker = "lld-link.exe"

43
Cargo.lock generated
View file

@ -185,9 +185,9 @@ dependencies = [
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.35" version = "0.3.38"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1371048253fa3bac6704bfd6bbfc922ee9bdcee8881330d40f308b81cc5adc55" checksum = "690a62be8920ccf773ee00ef0968649b0e724cda8bd5b12286302b4ae955fdf5"
dependencies = [ dependencies = [
"backtrace-sys", "backtrace-sys",
"cfg-if", "cfg-if",
@ -502,11 +502,12 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.35" version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e5f3fee5eeb60324c2781f1e41286bdee933850fff9b3c672587fed5ec58c83" checksum = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be"
dependencies = [ dependencies = [
"rayon", "jobserver",
"num_cpus",
] ]
[[package]] [[package]]
@ -1467,6 +1468,17 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b900c08c1939860ce8b54dc6a89e26e00c04c380fd0e09796799bd7f12861e05" checksum = "b900c08c1939860ce8b54dc6a89e26e00c04c380fd0e09796799bd7f12861e05"
[[package]]
name = "getrandom"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]] [[package]]
name = "gfx" name = "gfx"
version = "0.0.1" version = "0.0.1"
@ -2358,6 +2370,17 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]]
name = "jobserver"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160"
dependencies = [
"getrandom",
"libc",
"log",
]
[[package]] [[package]]
name = "jpeg-decoder" name = "jpeg-decoder"
version = "0.1.14" version = "0.1.14"
@ -3075,7 +3098,7 @@ dependencies = [
[[package]] [[package]]
name = "mozjs" name = "mozjs"
version = "0.12.1" version = "0.12.1"
source = "git+https://github.com/servo/rust-mozjs#bc44e221420a42ccb77b54911f60ca102cba143b" source = "git+https://github.com/servo/rust-mozjs#0832eb778689143cd9f2f3967fac912f7096a466"
dependencies = [ dependencies = [
"cc", "cc",
"lazy_static", "lazy_static",
@ -3088,7 +3111,7 @@ dependencies = [
[[package]] [[package]]
name = "mozjs_sys" name = "mozjs_sys"
version = "0.67.1" version = "0.67.1"
source = "git+https://github.com/servo/mozjs?rev=dd175ee73a179ce218286c4be4ab80e1a75348be#dd175ee73a179ce218286c4be4ab80e1a75348be" source = "git+https://github.com/servo/mozjs?rev=59065889ec7726b767d70b8702b43b4e4776cbfe#59065889ec7726b767d70b8702b43b4e4776cbfe"
dependencies = [ dependencies = [
"bindgen", "bindgen",
"cc", "cc",
@ -5710,6 +5733,12 @@ dependencies = [
"urlencoding", "urlencoding",
] ]
[[package]]
name = "wasi"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d"
[[package]] [[package]]
name = "wayland-client" name = "wayland-client"
version = "0.21.13" version = "0.21.13"

View file

@ -29,4 +29,3 @@ opt-level = 3
mio = { git = "https://github.com/servo/mio.git", branch = "servo" } mio = { git = "https://github.com/servo/mio.git", branch = "servo" }
rand_os = { git = "https://github.com/servo/rand", branch = "servo-rand_os-0.1.3-uwp" } rand_os = { git = "https://github.com/servo/rand", branch = "servo-rand_os-0.1.3-uwp" }
rand_core = { git = "https://github.com/servo/rand", branch = "servo-rand_os-0.1.3-uwp" } rand_core = { git = "https://github.com/servo/rand", branch = "servo-rand_os-0.1.3-uwp" }

7
Xargo.toml Normal file
View file

@ -0,0 +1,7 @@
[target.x86_64-uwp-windows-msvc.dependencies]
std = { features = ["panic-unwind"] }
# https://github.com/rust-lang/rust/issues/65313
[target.aarch64-uwp-windows-msvc.dependencies]
std = {}

View file

@ -390,8 +390,8 @@ def windows_arm64():
windows_build_task("UWP dev build", arch="arm64", package=False) windows_build_task("UWP dev build", arch="arm64", package=False)
.with_treeherder("Windows arm64") .with_treeherder("Windows arm64")
.with_script( .with_script(
"python mach build --dev --uwp --win-arm64", "python mach build --dev --target=aarch64-uwp-windows-msvc",
"python mach package --dev --target aarch64-pc-windows-msvc --uwp=arm64", "python mach package --dev --target aarch64-uwp-windows-msvc --uwp=arm64",
) )
.with_artifacts(appx_artifact(debug=True)) .with_artifacts(appx_artifact(debug=True))
.find_or_create("build.windows_uwp_arm64_dev." + CONFIG.task_id()) .find_or_create("build.windows_uwp_arm64_dev." + CONFIG.task_id())
@ -403,8 +403,8 @@ def windows_uwp_x64():
windows_build_task("UWP dev build", package=False) windows_build_task("UWP dev build", package=False)
.with_treeherder("Windows x64") .with_treeherder("Windows x64")
.with_script( .with_script(
"mach build --dev --uwp", "python mach build --dev --target=x86_64-uwp-windows-msvc",
"mach package --dev --uwp=x64", "python mach package --dev --target=x86_64-uwp-windows-msvc --uwp=x64",
) )
.with_artifacts(appx_artifact(debug=True)) .with_artifacts(appx_artifact(debug=True))
.find_or_create("build.windows_uwp_x64_dev." + CONFIG.task_id()) .find_or_create("build.windows_uwp_x64_dev." + CONFIG.task_id())
@ -418,9 +418,9 @@ def uwp_nightly():
.with_features("taskclusterProxy") .with_features("taskclusterProxy")
.with_scopes("secrets:get:project/servo/s3-upload-credentials") .with_scopes("secrets:get:project/servo/s3-upload-credentials")
.with_script( .with_script(
"mach build --release --uwp", "python mach build --release --target=x86_64-uwp-windows-msvc",
"python mach build --release --uwp --win-arm64", "python mach build --release --target=aarch64-uwp-windows-msvc",
"mach package --release --uwp=x64 --uwp=arm64", "mach package --release --target=x86_64-uwp-windows-msvc --uwp=x64 --uwp=arm64",
"mach upload-nightly uwp --secret-from-taskcluster", "mach upload-nightly uwp --secret-from-taskcluster",
) )
.with_artifacts(appx_artifact(debug=False)) .with_artifacts(appx_artifact(debug=False))

View file

@ -164,17 +164,18 @@ class MachCommands(CommandBase):
@CommandArgument('--very-verbose', '-vv', @CommandArgument('--very-verbose', '-vv',
action='store_true', action='store_true',
help='Print very verbose output') help='Print very verbose output')
@CommandArgument('--win-arm64', action='store_true', help="Use arm64 Windows target")
@CommandArgument('params', nargs='...', @CommandArgument('params', nargs='...',
help="Command-line arguments to be passed through to Cargo") help="Command-line arguments to be passed through to Cargo")
@CommandBase.build_like_command_arguments @CommandBase.build_like_command_arguments
def build(self, release=False, dev=False, jobs=None, params=None, def build(self, release=False, dev=False, jobs=None, params=None,
no_package=False, verbose=False, very_verbose=False, no_package=False, verbose=False, very_verbose=False,
target=None, android=False, magicleap=False, libsimpleservo=False, uwp=False, target=None, android=False, magicleap=False, libsimpleservo=False,
features=None, win_arm64=False, **kwargs): features=None, **kwargs):
opts = params or [] opts = params or []
features = features or [] features = features or []
target, android = self.pick_target_triple(target, android, magicleap) target, android = self.pick_target_triple(target, android, magicleap)
uwp = target and 'uwp' in target
target_path = base_path = self.get_target_dir() target_path = base_path = self.get_target_dir()
if android: if android:
@ -220,14 +221,8 @@ class MachCommands(CommandBase):
if very_verbose: if very_verbose:
opts += ["-vv"] opts += ["-vv"]
if win_arm64:
if target:
print("Can't specify explicit --target value with --win-arm64.")
sys.exit(1)
target = "aarch64-pc-windows-msvc"
if target: if target:
if self.config["tools"]["use-rustup"]: if self.config["tools"]["use-rustup"] and not uwp:
# 'rustup target add' fails if the toolchain is not installed at all. # 'rustup target add' fails if the toolchain is not installed at all.
self.call_rustup_run(["rustc", "--version"]) self.call_rustup_run(["rustc", "--version"])
@ -265,6 +260,10 @@ class MachCommands(CommandBase):
env['PKG_CONFIG_ALLOW_CROSS'] = "1" env['PKG_CONFIG_ALLOW_CROSS'] = "1"
if uwp: if uwp:
# Ensure libstd is ready for the new UWP target.
check_call(["rustup", "component", "add", "rust-src"])
env['RUST_SYSROOT'] = path.expanduser('~\\.xargo')
# Don't try and build a desktop port. # Don't try and build a desktop port.
libsimpleservo = True libsimpleservo = True
@ -943,7 +942,7 @@ def package_msvc_dlls(servo_exe_dir, target, vcinstalldir, vs_version):
"msvcp140.dll", "msvcp140.dll",
"vcruntime140.dll", "vcruntime140.dll",
] ]
if target_arch != "aarch64" and vs_version in ("14.0", "15.0", "16.0"): if target_arch != "aarch64" and "uwp" not in target and vs_version in ("14.0", "15.0", "16.0"):
msvc_deps += ["api-ms-win-crt-runtime-l1-1-0.dll"] msvc_deps += ["api-ms-win-crt-runtime-l1-1-0.dll"]
# Check if it's Visual C++ Build Tools or Visual Studio 2015 # Check if it's Visual C++ Build Tools or Visual Studio 2015

View file

@ -634,6 +634,7 @@ install them, let us know by filing a bug!")
extra_path += [path.join(self.msvc_package_dir("llvm"), "bin")] extra_path += [path.join(self.msvc_package_dir("llvm"), "bin")]
extra_path += [path.join(self.msvc_package_dir("ninja"), "bin")] extra_path += [path.join(self.msvc_package_dir("ninja"), "bin")]
extra_path += [self.msvc_package_dir("nuget")] extra_path += [self.msvc_package_dir("nuget")]
extra_path += [path.join(self.msvc_package_dir("xargo"))]
arch = (target or host_triple()).split('-')[0] arch = (target or host_triple()).split('-')[0]
vcpkg_arch = { vcpkg_arch = {
@ -821,11 +822,6 @@ install them, let us know by filing a bug!")
action='store_true', action='store_true',
help='Build with frame pointer enabled, used by the background hang monitor.', help='Build with frame pointer enabled, used by the background hang monitor.',
), ),
CommandArgument(
'--uwp',
default=None,
action='store_true',
help='Build for HoloLens (x64)'),
CommandArgument('--with-raqote', default=None, action='store_true'), CommandArgument('--with-raqote', default=None, action='store_true'),
CommandArgument('--with-layout-2020', default=None, action='store_true'), CommandArgument('--with-layout-2020', default=None, action='store_true'),
CommandArgument('--without-wgl', default=None, action='store_true'), CommandArgument('--without-wgl', default=None, action='store_true'),
@ -912,7 +908,10 @@ install them, let us know by filing a bug!")
assert "--features" not in cargo_args assert "--features" not in cargo_args
args += ["--features", " ".join(features)] args += ["--features", " ".join(features)]
return self.call_rustup_run(["cargo", command] + args + cargo_args, env=env, verbose=verbose) if target and 'uwp' in target:
return call(["xargo", command] + args + cargo_args, env=env, verbose=verbose)
else:
return self.call_rustup_run(["cargo", command] + args + cargo_args, env=env, verbose=verbose)
def android_support_dir(self): def android_support_dir(self):
return path.join(self.context.topdir, "support", "android") return path.join(self.context.topdir, "support", "android")

View file

@ -11,4 +11,5 @@ WINDOWS_MSVC = {
"openssl": "111.3.0+1.1.1c-vs2017-2019-09-18", "openssl": "111.3.0+1.1.1c-vs2017-2019-09-18",
"gstreamer-uwp": "1.16.0.5", "gstreamer-uwp": "1.16.0.5",
"openxr-loader-uwp": "1.0", "openxr-loader-uwp": "1.0",
"xargo": "v0.3.16",
} }

View file

@ -40,4 +40,4 @@
<Capability Name="codeGeneration" /> <Capability Name="codeGeneration" />
<Capability Name="privateNetworkClientServer" /> <Capability Name="privateNetworkClientServer" />
</Capabilities> </Capabilities>
</Package> </Package>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff