Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak scripts for cross-compilation on macOS. #42

Merged
merged 1 commit into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 23 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,29 @@ use std::process::Command;
use std::{env, fs};

fn main() {
let src = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let build_folder = dst.join("mesa");
let _ = fs::create_dir(&build_folder);
let cargo_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
let src = cargo_dir.join("mesa-src");
let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("mesa");
let _ = fs::create_dir(&dst);

if !build_folder.join("build.ninja").exists() {
run(Command::new("meson")
.current_dir(&build_folder)
.arg(&src.join("mesa-src"))
if !dst.join("build.ninja").exists() {
let mut cmd = Command::new("meson");
match env::var_os("CARGO_CFG_TARGET_VENDOR")
.unwrap()
.into_string()
.unwrap()
.as_str()
{
"apple" => {
cmd
.arg("--cross-file")
.arg(cargo_dir.join("crossfiles").join("darwin.meson"));
}
_ => {}
}
run(cmd
.current_dir(&dst)
.arg(&src)
.arg("-Dplatforms=")
.arg("-Ddri3=disabled")
.arg("-Dglx-direct=false")
Expand All @@ -26,7 +40,7 @@ fn main() {
.arg("-Dglx=disabled"));
}

run(Command::new("ninja").current_dir(&build_folder));
run(Command::new("ninja").current_dir(&dst));
}

fn run(cmd: &mut Command) {
Expand Down
5 changes: 5 additions & 0 deletions crossfiles/darwin.meson
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[host_machine]
system = 'darwin'
cpu_family = 'x86_64'
cpu = 'i686'
endian = 'little'
2 changes: 1 addition & 1 deletion mesa-src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ elif with_dri_i965 and with_shader_cache
endif

# Determine whether or not the rt library is needed for time functions
if host_machine.system() == 'windows' or cc.has_function('clock_gettime')
if host_machine.system() == 'windows' or host_machine.system() == 'darwin' or cc.has_function('clock_gettime')
dep_clock = null_dep
else
dep_clock = cc.find_library('rt')
Expand Down
13 changes: 13 additions & 0 deletions patches/5.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/mesa-src/meson.build b/mesa-src/meson.build
index 2c3397d6..9990d3ef 100644
--- a/mesa-src/meson.build
+++ b/mesa-src/meson.build
@@ -1304,7 +1304,7 @@ elif with_dri_i965 and with_shader_cache
endif

# Determine whether or not the rt library is needed for time functions
-if host_machine.system() == 'windows' or cc.has_function('clock_gettime')
+if host_machine.system() == 'windows' or host_machine.system() == 'darwin' or cc.has_function('clock_gettime')
dep_clock = null_dep
else
dep_clock = cc.find_library('rt')
3 changes: 2 additions & 1 deletion tools/update-mesa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ tar -xvf mesa-tmp/build/meson-dist/mesa-${VERSION}.tar.xz
mv mesa-${VERSION} mesa-src
rm -rf mesa-tmp

# apply local patches necessary for Servo
# apply local patches necessary for Servo or wrench cross-compilation
patch -i patches/1.diff -p1
patch -i patches/2-mesa-issue-2034.diff -p1
patch -i patches/3-mesa-issue-2035.diff -p1
patch -i patches/4-mesa-issue-1020.diff -p1
patch -i patches/5.diff -p1