Skip to content

Commit

Permalink
Merge pull request #4 from rerun-io/andreas/fix-windows-build
Browse files Browse the repository at this point in the history
Published crate windows fixes
  • Loading branch information
Wumpf authored Oct 15, 2024
2 parents 8097727 + 09eeb83 commit df538e4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 42 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# re_rav1d changelog
Tracks differences since [rav1d 1.0.0](https://crates.io/crates/rav1d/1.0.0)

## re_rav1d 0.1.3
* Remove *.c files from the release again
* Move build.rs parts that are only relevant for the cli to the cli project

## re_rav1d 0.1.2
* Linux/x64: re-enable assembly routines and prevent illegal relocations [#3](https://github.com/rerun-io/re_rav1d/pull/3)


## re_rav1d 0.1.1
* Include `tools/compat/getopt.c` in the release


## re_rav1d 0.1.0
* Add `dav1d-rs` as a Rust API ([upstream PR](https://github.com/memorysafety/rav1d/pull/1364))
* Fix crash on erroneous videos ([upstream PR](https://github.com/memorysafety/rav1d/pull/1362))
Expand Down
12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ default-members = [".", "tools"]
[package]
name = "re_rav1d"
authors = ["Rav1d Developers", "Prossimo"]
version = "0.1.2"
version = "0.1.3-alpha.1"
edition = "2021"
rust-version = "1.79"
description = "Rust port of the dav1d AV1 decoder"
license = "BSD-2-Clause"
repository = "https://github.com/memorysafety/rav1d"
exclude = ["*.in", "meson*", "tests/", "doc/", "package/"]
exclude = ["*.c", "*.in", "meson*", "tests/", "doc/", "package/"]

[lib]
path = "lib.rs"
Expand All @@ -37,7 +37,13 @@ cc = "1.0.79"
nasm-rs = { version = "0.3", features = ["parallel"] }

[features]
default = ["asm", "asm_arm64_dotprod", "asm_arm64_i8mm", "bitdepth_8", "bitdepth_16"]
default = [
"asm",
"asm_arm64_dotprod",
"asm_arm64_i8mm",
"bitdepth_8",
"bitdepth_16",
]
asm = []
asm_arm64_dotprod = ["asm"]
asm_arm64_i8mm = ["asm"]
Expand Down
37 changes: 0 additions & 37 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,41 +331,4 @@ fn main() {
{
asm::main();
}

// NOTE: we rely on libraries that are only distributed for Windows so
// targeting Windows/MSVC is not supported when cross compiling.
#[cfg(all(target_os = "windows", target_env = "msvc"))]
{
use cc::windows_registry;
use std::env;

let os = env::var("CARGO_CFG_TARGET_OS").expect("missing CARGO_CFG_TARGET_OS");
let target = env::var("TARGET").expect("missing TARGET");
if os == "windows" {
// for sprintf, snprintf, etc.
println!("cargo:rustc-link-lib=static=oldnames");
let tool = windows_registry::find_tool(&target, "cl.exe")
.expect("couldn't find cl.exe; are the Visual Studio C++ tools installed?");
let lib_paths = &tool
.env()
.iter()
.find(|(key, _val)| key == "LIB")
.expect("LIB path not found")
.1;
for path in lib_paths.to_str().unwrap().split(';') {
if path != "" {
println!("cargo:rustc-link-search={path}");
}
}

let getopt = "getopt";
cc::Build::new()
.files([&"tools/compat/getopt.c"])
.include("include/compat")
.debug(cfg!(debug_assertions))
.compile(&getopt);
// cc automatically outputs the following line
// println!("cargo:rustc-link-lib=static={getopt}");
}
}
}
38 changes: 38 additions & 0 deletions tools/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
fn main() {
// NOTE: we rely on libraries that are only distributed for Windows so
// targeting Windows/MSVC is not supported when cross compiling.
#[cfg(all(target_os = "windows", target_env = "msvc"))]
{
use cc::windows_registry;
use std::env;

let os = env::var("CARGO_CFG_TARGET_OS").expect("missing CARGO_CFG_TARGET_OS");
let target = env::var("TARGET").expect("missing TARGET");
if os == "windows" {
// for sprintf, snprintf, etc.
println!("cargo:rustc-link-lib=static=oldnames");
let tool = windows_registry::find_tool(&target, "cl.exe")
.expect("couldn't find cl.exe; are the Visual Studio C++ tools installed?");
let lib_paths = &tool
.env()
.iter()
.find(|(key, _val)| key == "LIB")
.expect("LIB path not found")
.1;
for path in lib_paths.to_str().unwrap().split(';') {
if path != "" {
println!("cargo:rustc-link-search={path}");
}
}

let getopt = "getopt";
cc::Build::new()
.files([&"tools/compat/getopt.c"])
.include("include/compat")
.debug(cfg!(debug_assertions))
.compile(&getopt);
// cc automatically outputs the following line
// println!("cargo:rustc-link-lib=static={getopt}");
}
}
}

0 comments on commit df538e4

Please sign in to comment.