oodle: Fix linking statically #121

Merged
lucas merged 8 commits from issue/static-linking into master 2023-11-08 11:12:26 +01:00
15 changed files with 340 additions and 398 deletions

View file

@ -8,7 +8,7 @@ RUN set -e; \
cargo new --lib lib/nexusmods; \
cargo new --lib lib/sdk; \
cargo new --lib lib/serde_sjson; \
cargo new --lib lib/steamlocate-rs
cargo new --lib lib/ansi-parser
COPY Cargo.toml Cargo.lock /src/dtmt/
COPY crates/dtmt/Cargo.toml /src/dtmt/crates/dtmt/
@ -17,7 +17,7 @@ COPY lib/dtmt-shared/Cargo.toml /src/dtmt/lib/dtmt-shared/
COPY lib/nexusmods/Cargo.toml /src/dtmt/lib/nexusmods/
COPY lib/sdk/Cargo.toml /src/dtmt/lib/sdk/
COPY lib/serde_sjson/Cargo.toml /src/dtmt/lib/serde_sjson/
COPY lib/steamlocate-rs/Cargo.toml /src/dtmt/lib/steamlocate-rs/
COPY lib/ansi-parser/Cargo.toml /src/dtmt/lib/ansi-parser/
# Crates with build scripts cannot be split that way, but they shouldn't change too often
COPY lib/luajit2-sys /src/dtmt/lib/luajit2-sys
@ -30,6 +30,6 @@ RUN cargo build --release --locked
RUN rm -r crates lib
COPY . /src/dtmt
COPY --from=dtmt-ci-base-linux /src/*.lib /src/dtmt/lib/oodle/
COPY --from=dtmt-ci-base-linux /src/*.lib /src/*.so /src/dtmt/lib/oodle/
RUN cargo build --release --locked

View file

@ -8,7 +8,7 @@ RUN set -e; \
cargo new --lib lib/nexusmods; \
cargo new --lib lib/sdk; \
cargo new --lib lib/serde_sjson; \
cargo new --lib lib/steamlocate-rs
cargo new --lib lib/ansi-parser
COPY Cargo.toml Cargo.lock /src/dtmt/
COPY crates/dtmt/Cargo.toml /src/dtmt/crates/dtmt/
@ -17,7 +17,7 @@ COPY lib/dtmt-shared/Cargo.toml /src/dtmt/lib/dtmt-shared/
COPY lib/nexusmods/Cargo.toml /src/dtmt/lib/nexusmods/
COPY lib/sdk/Cargo.toml /src/dtmt/lib/sdk/
COPY lib/serde_sjson/Cargo.toml /src/dtmt/lib/serde_sjson/
COPY lib/steamlocate-rs/Cargo.toml /src/dtmt/lib/steamlocate-rs/
COPY lib/ansi-parser/Cargo.toml /src/dtmt/lib/ansi-parser/
# Crates with build scripts cannot be split that way, but they shouldn't change too often
COPY lib/luajit2-sys /src/dtmt/lib/luajit2-sys

View file

@ -21,4 +21,4 @@ RUN set -eux; \
WORKDIR /src/dtmt
COPY liboo2corelinux64.so /src
COPY *.so *.a /src/

View file

@ -86,4 +86,4 @@ RUN wine wineboot --init
WORKDIR /src/dtmt
COPY oo2core_win32.lib oo2core_win64.lib /src
COPY *.lib /src

View file

@ -13,7 +13,7 @@ case "$TARGET" in
fi
;;
linux)
cp /src/*.so ./lib/oodle/
cp /src/*.a ./lib/oodle/
cargo build --color always --locked --profile release-lto
if [ -d "$OUTPUT" ]; then

View file

@ -47,4 +47,5 @@ if sh "$script"; then
notify 'success' "$context" "$desc"
else
notify 'failure' "$context" "$desc"
exit 1
fi

7
.gitmodules vendored
View file

@ -1,12 +1,13 @@
[submodule "lib/serde_sjson"]
path = lib/serde_sjson
url = https://git.sclu1034.dev/lucas/serde_sjson.git
[submodule "lib/steamlocate-rs"]
path = lib/steamlocate-rs
url = https://github.com/sclu1034/steamlocate-rs.git
[submodule "lib/luajit2-sys"]
path = lib/luajit2-sys
url = https://github.com/sclu1034/luajit2-sys.git
[submodule "lib/color-eyre"]
path = lib/color-eyre
url = https://github.com/sclu1034/color-eyre.git
[submodule "lib/ansi-parser"]
path = lib/ansi-parser
url = https://gitlab.com/lschwiderski/ansi-parser.git
branch = "issue/outdated-nom"

View file

@ -21,6 +21,7 @@
- all: force unix path separators for engine values
- dtmt: fix extracing files with non-flattened file names
- oodle: fix static linking
== 2023-03-01

666
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -7,11 +7,15 @@ members = [
"lib/oodle",
"lib/sdk",
"lib/serde_sjson",
"lib/steamlocate-rs",
]
exclude = [
"lib/color-eyre",
"lib/ansi-parser",
]
[patch.crates-io]
color-eyre = { path = "lib/color-eyre" }
ansi-parser = { path = "lib/ansi-parser" }
[profile.dev.package.backtrace]
opt-level = 3

1
lib/ansi-parser Submodule

@ -0,0 +1 @@
Subproject commit 27beb4bc1ffd2865a432e13f0588b5351ff419bf

View file

@ -9,7 +9,7 @@ edition = "2021"
ansi_term = "0.12.1"
color-eyre = "0.6.2"
serde = "1.0.152"
steamlocate = { path = "../../lib/steamlocate-rs", version = "*" }
steamlocate = "2.0.0-alpha.0"
time = { version = "0.3.19", features = ["formatting", "local-offset", "macros"] }
tracing = "0.1.37"
tracing-error = "0.2.0"

View file

@ -71,20 +71,15 @@ pub fn collect_game_info() -> Option<GameInfo> {
let found = dir
.app(&STEAMAPP_ID)
.and_then(|app| app.vdf.get("LastUpdated").map(|v| (app.path.clone(), v)));
.and_then(|app| app.last_updated.map(|v| (app.path.clone(), v)));
let Some((path, last_updated)) = found else {
tracing::debug!("Found Steam, but failed to find game installation");
return None;
};
let Some(last_updated) = last_updated
.as_value()
.and_then(|v| v.to::<i64>())
.and_then(|v| OffsetDateTime::from_unix_timestamp(v).ok()) else {
tracing::error!("Found Steam game, but couldn't read 'LastUpdate'.");
return None;
};
Some(GameInfo { path, last_updated })
Some(GameInfo {
path,
last_updated: last_updated.into(),
})
}

View file

@ -4,24 +4,20 @@ use std::env;
use std::path::PathBuf;
fn main() {
// Tell cargo to look for shared libraries in the specified directory
if let Ok(manifest_dir) = std::env::var("CARGO_MANIFEST_DIR") {
println!("cargo:rustc-link-search={}", manifest_dir);
dbg!(&manifest_dir);
}
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("No CARGO_MANIFEST_DIR");
println!("cargo:rustc-link-search=native={}", &manifest_dir);
let lib_name = if std::env::var("CARGO_CFG_WINDOWS").is_ok() {
if cfg!(debug_assertions) {
if std::env::var("CARGO_CFG_TARGET_FAMILY") == Ok(String::from("windows")) {
let lib_name = if cfg!(debug_assertions) {
"oo2core_win64_debug"
} else {
"oo2core_win64"
}
};
println!("cargo:rustc-link-lib=static={}", lib_name);
} else {
"oo2corelinux64"
};
println!("cargo:rustc-link-lib={}", lib_name);
dbg!(&lib_name);
println!("cargo:rustc-link-lib=static=oo2corelinux64");
println!("cargo:rustc-link-lib=stdc++");
}
println!("cargo:rerun-if-changed=oodle2.h");

@ -1 +0,0 @@
Subproject commit 4d6898f632e20ea15d47b0b071daa4f3fa6c9574