2019-03-24 09:45:14 +03:00
|
|
|
fn main() {
|
2020-09-11 07:18:32 +03:00
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
|
2020-04-06 22:39:35 +03:00
|
|
|
#[cfg(windows)]
|
|
|
|
{
|
2020-10-02 06:01:09 +03:00
|
|
|
use anyhow::Context as _;
|
2020-05-25 22:36:29 +03:00
|
|
|
use std::io::Write;
|
2020-10-02 21:50:50 +03:00
|
|
|
use std::path::Path;
|
2020-04-06 22:39:35 +03:00
|
|
|
let profile = std::env::var("PROFILE").unwrap();
|
2020-10-06 03:13:50 +03:00
|
|
|
let repo_dir = std::env::current_dir()
|
|
|
|
.ok()
|
|
|
|
.and_then(|cwd| cwd.parent().map(|p| p.to_path_buf()))
|
|
|
|
.unwrap();
|
|
|
|
let exe_output_dir = repo_dir.join("target").join(profile);
|
|
|
|
let windows_dir = repo_dir.join("assets").join("windows");
|
2020-04-06 22:39:35 +03:00
|
|
|
|
2020-10-18 05:08:16 +03:00
|
|
|
let conhost_dir = windows_dir.join("conhost");
|
2020-04-06 22:39:35 +03:00
|
|
|
for name in &["conpty.dll", "OpenConsole.exe"] {
|
|
|
|
let dest_name = exe_output_dir.join(name);
|
2020-05-26 01:39:04 +03:00
|
|
|
let src_name = conhost_dir.join(name);
|
2020-04-06 22:39:35 +03:00
|
|
|
|
|
|
|
if !dest_name.exists() {
|
2020-10-02 04:31:57 +03:00
|
|
|
std::fs::copy(&src_name, &dest_name)
|
|
|
|
.context(format!(
|
|
|
|
"copy {} -> {}",
|
|
|
|
src_name.display(),
|
|
|
|
dest_name.display()
|
|
|
|
))
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-18 05:08:16 +03:00
|
|
|
let angle_dir = windows_dir.join("angle");
|
|
|
|
for name in &["libEGL.dll", "libGLESv2.dll"] {
|
|
|
|
let dest_name = exe_output_dir.join(name);
|
|
|
|
let src_name = angle_dir.join(name);
|
|
|
|
|
|
|
|
if !dest_name.exists() {
|
|
|
|
std::fs::copy(&src_name, &dest_name)
|
|
|
|
.context(format!(
|
|
|
|
"copy {} -> {}",
|
|
|
|
src_name.display(),
|
|
|
|
dest_name.display()
|
|
|
|
))
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-02 04:31:57 +03:00
|
|
|
{
|
|
|
|
let dest_mesa = exe_output_dir.join("mesa");
|
|
|
|
let _ = std::fs::create_dir(&dest_mesa);
|
|
|
|
let dest_name = dest_mesa.join("opengl32.dll");
|
|
|
|
let src_name = windows_dir.join("mesa").join("opengl32.dll");
|
|
|
|
if !dest_name.exists() {
|
|
|
|
std::fs::copy(&src_name, &dest_name)
|
|
|
|
.context(format!(
|
|
|
|
"copy {} -> {}",
|
|
|
|
src_name.display(),
|
|
|
|
dest_name.display()
|
|
|
|
))
|
|
|
|
.unwrap();
|
2020-04-06 22:39:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-02 21:50:50 +03:00
|
|
|
// If a file named `.tag` is present, we'll take its contents for the
|
|
|
|
// version number that we report in wezterm -h.
|
|
|
|
let mut ci_tag = String::new();
|
|
|
|
if let Ok(tag) = std::fs::read("../.tag") {
|
|
|
|
if let Ok(s) = String::from_utf8(tag) {
|
|
|
|
ci_tag = s.trim().to_string();
|
2021-04-30 06:23:47 +03:00
|
|
|
println!("cargo:rerun-if-changed=../.tag");
|
2020-10-02 21:50:50 +03:00
|
|
|
}
|
|
|
|
}
|
2020-05-25 22:36:29 +03:00
|
|
|
let version = if ci_tag.is_empty() {
|
|
|
|
let mut cmd = std::process::Command::new("git");
|
2021-04-30 06:23:47 +03:00
|
|
|
cmd.args(&[
|
2021-12-06 05:21:06 +03:00
|
|
|
"-c",
|
|
|
|
"core.abbrev=8",
|
2021-04-30 06:23:47 +03:00
|
|
|
"show",
|
|
|
|
"-s",
|
|
|
|
"--format=%cd-%h",
|
|
|
|
"--date=format:%Y%m%d-%H%M%S",
|
|
|
|
]);
|
2020-05-25 22:36:29 +03:00
|
|
|
if let Ok(output) = cmd.output() {
|
|
|
|
if output.status.success() {
|
|
|
|
String::from_utf8_lossy(&output.stdout).trim().to_owned()
|
|
|
|
} else {
|
|
|
|
"UNKNOWN".to_owned()
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
"UNKNOWN".to_owned()
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ci_tag
|
|
|
|
};
|
|
|
|
|
|
|
|
let rcfile_name = Path::new(&std::env::var_os("OUT_DIR").unwrap()).join("resource.rc");
|
|
|
|
let mut rcfile = std::fs::File::create(&rcfile_name).unwrap();
|
2022-01-01 22:15:03 +03:00
|
|
|
println!("cargo:rerun-if-changed=../assets/windows/terminal.ico");
|
2020-05-25 22:36:29 +03:00
|
|
|
write!(
|
|
|
|
rcfile,
|
|
|
|
r#"
|
|
|
|
#include <winres.h>
|
|
|
|
// This ID is coupled with code in window/src/os/windows/window.rs
|
|
|
|
#define IDI_ICON 0x101
|
2022-03-24 17:20:26 +03:00
|
|
|
1 RT_MANIFEST "{win}\\manifest.manifest"
|
2020-05-26 02:48:49 +03:00
|
|
|
IDI_ICON ICON "{win}\\terminal.ico"
|
2020-05-25 22:36:29 +03:00
|
|
|
VS_VERSION_INFO VERSIONINFO
|
|
|
|
FILEVERSION 1,0,0,0
|
|
|
|
PRODUCTVERSION 1,0,0,0
|
|
|
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
|
|
|
FILEFLAGS 0
|
|
|
|
FILEOS VOS__WINDOWS32
|
|
|
|
FILETYPE VFT_APP
|
|
|
|
FILESUBTYPE VFT2_UNKNOWN
|
|
|
|
BEGIN
|
|
|
|
BLOCK "StringFileInfo"
|
|
|
|
BEGIN
|
|
|
|
BLOCK "040904E4"
|
|
|
|
BEGIN
|
|
|
|
VALUE "CompanyName", "Wez Furlong\0"
|
|
|
|
VALUE "FileDescription", "WezTerm - Wez's Terminal Emulator\0"
|
|
|
|
VALUE "FileVersion", "{version}\0"
|
|
|
|
VALUE "LegalCopyright", "Wez Furlong, MIT licensed\0"
|
|
|
|
VALUE "InternalName", "\0"
|
|
|
|
VALUE "OriginalFilename", "\0"
|
|
|
|
VALUE "ProductName", "WezTerm\0"
|
|
|
|
VALUE "ProductVersion", "{version}\0"
|
|
|
|
END
|
|
|
|
END
|
|
|
|
BLOCK "VarFileInfo"
|
|
|
|
BEGIN
|
|
|
|
VALUE "Translation", 0x409, 1252
|
|
|
|
END
|
|
|
|
END
|
|
|
|
"#,
|
2020-05-26 02:48:49 +03:00
|
|
|
win = windows_dir.display().to_string().replace("\\", "\\\\"),
|
2020-05-25 22:36:29 +03:00
|
|
|
version = version,
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
drop(rcfile);
|
|
|
|
|
|
|
|
// Obtain MSVC environment so that the rc compiler can find the right headers.
|
|
|
|
// https://github.com/nabijaczleweli/rust-embed-resource/issues/11#issuecomment-603655972
|
|
|
|
let target = std::env::var("TARGET").unwrap();
|
|
|
|
if let Some(tool) = cc::windows_registry::find_tool(target.as_str(), "cl.exe") {
|
|
|
|
for (key, value) in tool.env() {
|
|
|
|
std::env::set_var(key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
embed_resource::compile(rcfile_name);
|
|
|
|
}
|
2020-12-16 08:21:23 +03:00
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
{
|
|
|
|
use anyhow::Context as _;
|
|
|
|
let profile = std::env::var("PROFILE").unwrap();
|
|
|
|
let repo_dir = std::env::current_dir()
|
|
|
|
.ok()
|
|
|
|
.and_then(|cwd| cwd.parent().map(|p| p.to_path_buf()))
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
// We need to copy the plist to avoid the UNUserNotificationCenter asserting
|
|
|
|
// due to not finding the application bundle
|
|
|
|
let src_plist = repo_dir
|
|
|
|
.join("assets")
|
|
|
|
.join("macos")
|
|
|
|
.join("WezTerm.app")
|
|
|
|
.join("Contents")
|
|
|
|
.join("Info.plist");
|
|
|
|
let dest_plist = repo_dir.join("target").join(profile).join("Info.plist");
|
|
|
|
println!("cargo:rerun-if-changed=assets/macos/WezTerm.app/Contents/Info.plist");
|
|
|
|
|
|
|
|
std::fs::copy(&src_plist, &dest_plist)
|
|
|
|
.context(format!(
|
|
|
|
"copy {} -> {}",
|
|
|
|
src_plist.display(),
|
|
|
|
dest_plist.display()
|
|
|
|
))
|
|
|
|
.unwrap();
|
|
|
|
}
|
2019-03-24 09:45:14 +03:00
|
|
|
}
|