This repository has been archived by the owner on Mar 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.rs
51 lines (46 loc) · 1.78 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::fs;
use std::path::Path;
use std::process::Command;
fn main() {
if cfg!(all(not(feature = "force-glutin"), target_os = "macos")) {
build_mmtabbarview();
build_nibs();
}
}
fn build_mmtabbarview() {
if !Path::new("./src/platform/cocoa/MMTabBarView/.git").exists() {
let _ = Command::new("git")
.args(&["submodule", "update", "--init"])
.status();
}
let status = Command::new("xcodebuild")
.args(&["-project",
"./src/platform/cocoa/MMTabBarView/MMTabBarView/MMTabBarView.xcodeproj"])
.args(&["-configuration", "Release"])
.args(&["SYMROOT=../../../../../target/MMTabBarView/"])
.status()
.expect("failed to execute xcodebuild");
assert!(status.success(), "xcodebuild failed");
println!("cargo:rustc-link-search=framework=target/MMTabBarView/Release/");
}
fn build_nibs() {
fn ibtool(src: &str, out_dir: &Path) {
let out = out_dir.to_str().unwrap();
let filename = Path::new(src).file_name().unwrap();
let out_file = filename.to_str().unwrap().replace("xib", "nib");
let status = Command::new("ibtool")
.arg(src)
.arg("--compile")
.arg(&format!("{}/{}", out, out_file))
.status()
.expect("failed to execute ibtool");
assert!(status.success(), "ibtool failed");
}
let nibs_dir = Path::new("target/nibs");
fs::create_dir_all(&nibs_dir).unwrap();
ibtool("src/platform/cocoa/xib/App.xib", nibs_dir);
ibtool("src/platform/cocoa/xib/Window.xib", nibs_dir);
}