mirror of
https://github.com/italicsjenga/ash-molten.git
synced 2025-01-11 05:31:30 +11:00
Upgrade to MoltenVK 1.1.0 (#25)
This commit is contained in:
parent
f8a59268e7
commit
44911f699a
11
.github/workflows/ci.yaml
vendored
11
.github/workflows/ci.yaml
vendored
|
@ -3,9 +3,9 @@ name: CI
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
name: Lint
|
name: Lint
|
||||||
runs-on: macOS-latest
|
runs-on: macos-latest
|
||||||
env:
|
env:
|
||||||
DEVELOPER_DIR: /Applications/Xcode_11.5.app
|
DEVELOPER_DIR: /Applications/Xcode_12.1.app
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
|
@ -35,9 +35,9 @@ jobs:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Test
|
name: Test
|
||||||
runs-on: macOS-latest
|
runs-on: macos-latest
|
||||||
env:
|
env:
|
||||||
DEVELOPER_DIR: /Applications/Xcode_11.5.app
|
DEVELOPER_DIR: /Applications/Xcode_12.1.app
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
|
@ -46,4 +46,5 @@ jobs:
|
||||||
override: true
|
override: true
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
command: build
|
||||||
|
|
||||||
|
|
75
build.rs
75
build.rs
|
@ -1,6 +1,9 @@
|
||||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||||
mod mac {
|
mod mac {
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::Path;
|
||||||
|
|
||||||
|
// MoltenVK git tagged release to use
|
||||||
|
pub static TAG: &str = "v1.1.0";
|
||||||
|
|
||||||
// Features are not used inside build scripts, so we have to explicitly query them from the
|
// Features are not used inside build scripts, so we have to explicitly query them from the
|
||||||
// enviroment
|
// enviroment
|
||||||
|
@ -18,7 +21,7 @@ mod mac {
|
||||||
.any(|f| f == "EXTERNAL")
|
.any(|f| f == "EXTERNAL")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn build_molten<P: AsRef<Path>>(target_dir: &P) -> &'static str {
|
pub(crate) fn build_molten<P: AsRef<Path>>(_target_dir: &P) -> &'static str {
|
||||||
use std::{
|
use std::{
|
||||||
process::Command,
|
process::Command,
|
||||||
sync::{
|
sync::{
|
||||||
|
@ -27,11 +30,8 @@ mod mac {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// MoltenVK git tagged release to use
|
|
||||||
let tag = "v.1.0.43";
|
|
||||||
|
|
||||||
let checkout_dir = Path::new(&std::env::var("OUT_DIR").expect("Couldn't find OUT_DIR"))
|
let checkout_dir = Path::new(&std::env::var("OUT_DIR").expect("Couldn't find OUT_DIR"))
|
||||||
.join(format!("MoltenVK-{}", tag));
|
.join(format!("MoltenVK-{}", TAG));
|
||||||
|
|
||||||
let exit = Arc::new(AtomicBool::new(false));
|
let exit = Arc::new(AtomicBool::new(false));
|
||||||
let wants_exit = exit.clone();
|
let wants_exit = exit.clone();
|
||||||
|
@ -62,7 +62,7 @@ mod mac {
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.arg("clone")
|
.arg("clone")
|
||||||
.arg("--branch")
|
.arg("--branch")
|
||||||
.arg(tag.to_owned())
|
.arg(TAG.to_owned())
|
||||||
.arg("--depth")
|
.arg("--depth")
|
||||||
.arg("1")
|
.arg("1")
|
||||||
.arg("https://github.com/KhronosGroup/MoltenVK.git")
|
.arg("https://github.com/KhronosGroup/MoltenVK.git")
|
||||||
|
@ -73,20 +73,10 @@ mod mac {
|
||||||
.expect("failed to clone MoltenVK")
|
.expect("failed to clone MoltenVK")
|
||||||
};
|
};
|
||||||
|
|
||||||
assert!(git_status.success(), "failed to clone MoltenVK");
|
assert!(git_status.success(), "failed to get MoltenVK");
|
||||||
|
|
||||||
let status = Command::new("sh")
|
|
||||||
.current_dir(&checkout_dir)
|
|
||||||
.arg("fetchDependencies")
|
|
||||||
.spawn()
|
|
||||||
.expect("failed to spawn fetchDependencies")
|
|
||||||
.wait()
|
|
||||||
.expect("failed to fetchDependencies");
|
|
||||||
|
|
||||||
assert!(status.success(), "failed to fetchDependencies");
|
|
||||||
|
|
||||||
// These (currently) match the identifiers used by moltenvk
|
// These (currently) match the identifiers used by moltenvk
|
||||||
let (target_name, dir) = match std::env::var("CARGO_CFG_TARGET_OS") {
|
let (target_name, _dir) = match std::env::var("CARGO_CFG_TARGET_OS") {
|
||||||
Ok(target) => match target.as_ref() {
|
Ok(target) => match target.as_ref() {
|
||||||
"macos" => ("macos", "macOS"),
|
"macos" => ("macos", "macOS"),
|
||||||
"ios" => ("ios", "iOS"),
|
"ios" => ("ios", "iOS"),
|
||||||
|
@ -95,9 +85,10 @@ mod mac {
|
||||||
Err(e) => panic!("failed to determinte target os '{}'", e),
|
Err(e) => panic!("failed to determinte target os '{}'", e),
|
||||||
};
|
};
|
||||||
|
|
||||||
let status = Command::new("make")
|
let status = Command::new("sh")
|
||||||
.current_dir(&checkout_dir)
|
.current_dir(&checkout_dir)
|
||||||
.arg(target_name)
|
.arg("fetchDependencies")
|
||||||
|
.arg(format!("--{}", target_name))
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("failed to spawn fetchDependencies")
|
.expect("failed to spawn fetchDependencies")
|
||||||
.wait()
|
.wait()
|
||||||
|
@ -105,29 +96,18 @@ mod mac {
|
||||||
|
|
||||||
assert!(status.success(), "failed to fetchDependencies");
|
assert!(status.success(), "failed to fetchDependencies");
|
||||||
|
|
||||||
let src = {
|
let mut target = target_name.to_owned();
|
||||||
let mut pb = PathBuf::new();
|
target.push_str("-debug");
|
||||||
pb.push(checkout_dir);
|
|
||||||
pb.push("Package/Release/MoltenVK");
|
|
||||||
pb.push(dir);
|
|
||||||
pb.push("static/libMoltenVK.a");
|
|
||||||
pb
|
|
||||||
};
|
|
||||||
|
|
||||||
let target = {
|
let status = Command::new("make")
|
||||||
let mut pb = PathBuf::new();
|
.current_dir(&checkout_dir)
|
||||||
pb.push(target_dir);
|
.arg(target)
|
||||||
pb.push(target_name);
|
.spawn()
|
||||||
|
.expect("failed to build MoltenVK")
|
||||||
|
.wait()
|
||||||
|
.expect("failed to build MoltenVK");
|
||||||
|
|
||||||
std::fs::create_dir_all(&pb).expect("failed to create output directory");
|
assert!(status.success(), "failed to build MoltenVK");
|
||||||
|
|
||||||
pb.push("libMoltenVK.a");
|
|
||||||
pb
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(e) = std::fs::copy(&src, &target) {
|
|
||||||
panic!("failed to copy {:?} to {:?}: {}", src, target, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
exit.store(true, Ordering::Release);
|
exit.store(true, Ordering::Release);
|
||||||
handle.join().unwrap();
|
handle.join().unwrap();
|
||||||
|
@ -142,18 +122,21 @@ fn main() {
|
||||||
|
|
||||||
// The 'external' feature was not enabled. Molten will be built automaticaly.
|
// The 'external' feature was not enabled. Molten will be built automaticaly.
|
||||||
if !is_external_enabled() {
|
if !is_external_enabled() {
|
||||||
let target_dir = Path::new(&std::env::var("OUT_DIR").unwrap()).join("MoltenVK-build");
|
let target_dir = Path::new(&std::env::var("OUT_DIR").unwrap()).join(format!(
|
||||||
let target_name = build_molten(&target_dir);
|
"MoltenVK-{}/Package/Latest/MoltenVK/MoltenVK.xcframework/{}-{}",
|
||||||
|
crate::mac::TAG,
|
||||||
|
std::env::var("CARGO_CFG_TARGET_OS").unwrap(),
|
||||||
|
std::env::var("CARGO_CFG_TARGET_ARCH").unwrap()
|
||||||
|
));
|
||||||
|
let _target_name = build_molten(&target_dir);
|
||||||
|
|
||||||
let project_dir = {
|
let project_dir = {
|
||||||
let mut pb = PathBuf::from(
|
let mut pb = PathBuf::from(
|
||||||
std::env::var("CARGO_MANIFEST_DIR").expect("unable to find env:CARGO_MANIFEST_DIR"),
|
std::env::var("CARGO_MANIFEST_DIR").expect("unable to find env:CARGO_MANIFEST_DIR"),
|
||||||
);
|
);
|
||||||
pb.push(target_dir);
|
pb.push(target_dir);
|
||||||
pb.push(target_name);
|
|
||||||
pb
|
pb
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("cargo:rustc-link-search=native={}", project_dir.display());
|
println!("cargo:rustc-link-search=native={}", project_dir.display());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue