Compare commits
6 commits
wip/buildi
...
master
Author | SHA1 | Date | |
---|---|---|---|
2c9ce46dd2 | |||
cec1cd8714 | |||
611f6038db | |||
2da2056cac | |||
fa9ffd9002 | |||
bba4790ff7 |
146 changed files with 470 additions and 260 deletions
|
@ -1,108 +0,0 @@
|
||||||
FROM rust:slim-bullseye
|
|
||||||
|
|
||||||
RUN set -eux; \
|
|
||||||
apt-get update; \
|
|
||||||
apt-get install --no-install-recommends -y \
|
|
||||||
build-essential \
|
|
||||||
curl \
|
|
||||||
gpg \
|
|
||||||
jq \
|
|
||||||
libatk1.0-dev \
|
|
||||||
libclang-13-dev \
|
|
||||||
libglib2.0-dev \
|
|
||||||
libgtk-3-dev \
|
|
||||||
libpango1.0-dev \
|
|
||||||
libssl-dev \
|
|
||||||
libzstd-dev \
|
|
||||||
pkg-config; \
|
|
||||||
apt-get remove -y --auto-remove; \
|
|
||||||
rm -rf /var/lib/apt/lists/*; \
|
|
||||||
rustup default nightly
|
|
||||||
|
|
||||||
# https://jake-shadle.github.io/xwin/
|
|
||||||
|
|
||||||
ENV KEYRINGS /usr/local/share/keyrings
|
|
||||||
ARG XWIN_VERSION=0.2.11
|
|
||||||
ARG XWIN_PREFIX="xwin-$XWIN_VERSION-x86_64-unknown-linux-musl"
|
|
||||||
ARG LLVM_VERSION=16
|
|
||||||
|
|
||||||
ADD https://apt.llvm.org/llvm-snapshot.gpg.key /root/llvm-snapshot.gpg.key
|
|
||||||
ADD https://dl.winehq.org/wine-builds/winehq.key /root/winehq.key
|
|
||||||
ADD https://github.com/Jake-Shadle/xwin/releases/download/$XWIN_VERSION/$XWIN_PREFIX.tar.gz /root/$XWIN_PREFIX.tar.gz
|
|
||||||
|
|
||||||
RUN set -eux; \
|
|
||||||
mkdir -p $KEYRINGS; \
|
|
||||||
# clang/lld/llvm
|
|
||||||
gpg --dearmor > $KEYRINGS/llvm.gpg < /root/llvm-snapshot.gpg.key; \
|
|
||||||
# wine
|
|
||||||
gpg --dearmor > $KEYRINGS/winehq.gpg < /root/winehq.key; \
|
|
||||||
echo "deb [signed-by=$KEYRINGS/llvm.gpg] http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-${LLVM_VERSION} main" > /etc/apt/sources.list.d/llvm.list; \
|
|
||||||
echo "deb [signed-by=$KEYRINGS/winehq.gpg] https://dl.winehq.org/wine-builds/debian/ bullseye main" > /etc/apt/sources.list.d/winehq.list; \
|
|
||||||
dpkg --add-architecture i386; \
|
|
||||||
apt-get update; \
|
|
||||||
apt-get install --no-install-recommends -y \
|
|
||||||
libclang-${LLVM_VERSION}-dev \
|
|
||||||
gcc-mingw-w64-x86-64 \
|
|
||||||
clang-${LLVM_VERSION} \
|
|
||||||
llvm-${LLVM_VERSION} \
|
|
||||||
lld-${LLVM_VERSION} \
|
|
||||||
winehq-staging \
|
|
||||||
tar; \
|
|
||||||
# ensure that clang/clang++ are callable directly
|
|
||||||
ln -s clang-${LLVM_VERSION} /usr/bin/clang && ln -s clang /usr/bin/clang++ && ln -s lld-${LLVM_VERSION} /usr/bin/ld.lld; \
|
|
||||||
# We also need to setup symlinks ourselves for the MSVC shims because they aren't in the debian packages
|
|
||||||
ln -s clang-${LLVM_VERSION} /usr/bin/clang-cl && ln -s llvm-ar-${LLVM_VERSION} /usr/bin/llvm-lib && ln -s lld-link-${LLVM_VERSION} /usr/bin/lld-link; \
|
|
||||||
# Verify the symlinks are correct
|
|
||||||
clang++ -v; \
|
|
||||||
ld.lld -v; \
|
|
||||||
# Doesn't have an actual -v/--version flag, but it still exits with 0
|
|
||||||
llvm-lib -v; \
|
|
||||||
clang-cl -v; \
|
|
||||||
lld-link --version; \
|
|
||||||
# Use clang instead of gcc when compiling and linking binaries targeting the host (eg proc macros, build files)
|
|
||||||
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100; \
|
|
||||||
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100; \
|
|
||||||
update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld 100; \
|
|
||||||
rustup target add x86_64-pc-windows-msvc; \
|
|
||||||
rustup component add rust-src; \
|
|
||||||
# Install xwin to cargo/bin via github release. Note you could also just use `cargo install xwin`.
|
|
||||||
tar -xzv -f /root/$XWIN_PREFIX.tar.gz -C /usr/local/cargo/bin --strip-components=1 $XWIN_PREFIX/xwin; \
|
|
||||||
# Splat the CRT and SDK files to /xwin/crt and /xwin/sdk respectively
|
|
||||||
xwin --accept-license splat --include-debug-libs --output /xwin; \
|
|
||||||
# Remove unneeded files to reduce image size
|
|
||||||
apt-get remove -y --auto-remove; \
|
|
||||||
rm -rf \
|
|
||||||
.xwin-cache \
|
|
||||||
/usr/local/cargo/bin/xwin \
|
|
||||||
/root/$XWIN_PREFIX.tar.gz \
|
|
||||||
/var/lib/apt/lists/* \
|
|
||||||
/root/*.key;
|
|
||||||
|
|
||||||
# Note that we're using the full target triple for each variable instead of the
|
|
||||||
# simple CC/CXX/AR shorthands to avoid issues when compiling any C/C++ code for
|
|
||||||
# build dependencies that need to compile and execute in the host environment
|
|
||||||
ENV CC_x86_64_pc_windows_msvc="clang-cl" \
|
|
||||||
CXX_x86_64_pc_windows_msvc="clang-cl" \
|
|
||||||
AR_x86_64_pc_windows_msvc="llvm-lib" \
|
|
||||||
# wine can be quite spammy with log messages and they're generally uninteresting
|
|
||||||
WINEDEBUG="-all" \
|
|
||||||
# Use wine to run test executables
|
|
||||||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUNNER="wine" \
|
|
||||||
# Note that we only disable unused-command-line-argument here since clang-cl
|
|
||||||
# doesn't implement all of the options supported by cl, but the ones it doesn't
|
|
||||||
# are _generally_ not interesting.
|
|
||||||
CL_FLAGS="-Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/xwin/crt/include /imsvc/xwin/sdk/include/ucrt /imsvc/xwin/sdk/include/um /imsvc/xwin/sdk/include/shared" \
|
|
||||||
# Let cargo know what linker to invoke if you haven't already specified it
|
|
||||||
# in a .cargo/config.toml file
|
|
||||||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER="lld-link" \
|
|
||||||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS="-Lnative=/xwin/crt/lib/x86_64 -Lnative=/xwin/sdk/lib/um/x86_64 -Lnative=/xwin/sdk/lib/ucrt/x86_64"
|
|
||||||
|
|
||||||
# These are separate since docker/podman won't transform environment variables defined in the same ENV block
|
|
||||||
ENV CFLAGS_x86_64_pc_windows_msvc="$CL_FLAGS" \
|
|
||||||
CXXFLAGS_x86_64_pc_windows_msvc="$CL_FLAGS"
|
|
||||||
|
|
||||||
# Run wineboot just to setup the default WINEPREFIX so we don't do it every
|
|
||||||
# container run
|
|
||||||
RUN wine wineboot --init
|
|
||||||
|
|
||||||
WORKDIR /src/dt_p2p
|
|
4
.fdignore
Normal file
4
.fdignore
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/msvc
|
||||||
|
/target
|
||||||
|
/.xwin-cache
|
||||||
|
/.wineprefix
|
13
.gitignore
vendored
13
.gitignore
vendored
|
@ -1,9 +1,6 @@
|
||||||
|
.envrc
|
||||||
/target
|
/target
|
||||||
|
/msvc
|
||||||
|
/tools/xwin
|
||||||
# Added by cargo
|
/.xwin-cache
|
||||||
#
|
/.wineprefix
|
||||||
# already existing elements were commented out
|
|
||||||
|
|
||||||
#/target
|
|
||||||
/Cargo.lock
|
|
||||||
|
|
254
Cargo.lock
generated
Normal file
254
Cargo.lock
generated
Normal file
|
@ -0,0 +1,254 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bindgen"
|
||||||
|
version = "0.65.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cexpr",
|
||||||
|
"clang-sys",
|
||||||
|
"lazy_static",
|
||||||
|
"lazycell",
|
||||||
|
"log",
|
||||||
|
"peeking_take_while",
|
||||||
|
"prettyplease",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"regex",
|
||||||
|
"rustc-hash",
|
||||||
|
"shlex",
|
||||||
|
"syn",
|
||||||
|
"which",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cexpr"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
||||||
|
dependencies = [
|
||||||
|
"nom",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clang-sys"
|
||||||
|
version = "1.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
|
||||||
|
dependencies = [
|
||||||
|
"glob",
|
||||||
|
"libc",
|
||||||
|
"libloading",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dt_p2p"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bindgen",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "either"
|
||||||
|
version = "1.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glob"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazycell"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.144"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libloading"
|
||||||
|
version = "0.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "minimal-lexical"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nom"
|
||||||
|
version = "7.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"minimal-lexical",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.17.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "peeking_take_while"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "prettyplease"
|
||||||
|
version = "0.2.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3b69d39aab54d069e7f2fe8cb970493e7834601ca2d8c65fd7bbd183578080d1"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.58"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.27"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex"
|
||||||
|
version = "1.8.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390"
|
||||||
|
dependencies = [
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-hash"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shlex"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "which"
|
||||||
|
version = "4.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
"libc",
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
21
Cargo.toml
21
Cargo.toml
|
@ -1,9 +1,18 @@
|
||||||
[workspace]
|
[package]
|
||||||
resolver = "2"
|
name = "dt_p2p"
|
||||||
members = [
|
version = "0.1.0"
|
||||||
"lib/dt_p2p",
|
edition = "2021"
|
||||||
"lib/nat_traversal"
|
|
||||||
]
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
libc = "0.2.144"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
bindgen = "0.65.1"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
# [profile.dev.package.backtrace]
|
# [profile.dev.package.backtrace]
|
||||||
# opt-level = 3
|
# opt-level = 3
|
||||||
|
|
35
Dockerfile
35
Dockerfile
|
@ -1,35 +0,0 @@
|
||||||
FROM dtmt-ci-base-msvc
|
|
||||||
|
|
||||||
# Create dummy crates and copy their Cargo.toml, so that dependencies can be cached
|
|
||||||
RUN set -e; \
|
|
||||||
cargo new --bin crates/dtmt; \
|
|
||||||
cargo new --bin crates/dtmm; \
|
|
||||||
cargo new --lib lib/dtmt-shared; \
|
|
||||||
cargo new --lib lib/nexusmods; \
|
|
||||||
cargo new --lib lib/sdk; \
|
|
||||||
cargo new --lib lib/serde_sjson; \
|
|
||||||
cargo new --lib lib/steamlocate-rs
|
|
||||||
|
|
||||||
COPY Cargo.toml Cargo.lock /src/dtmt/
|
|
||||||
COPY crates/dtmt/Cargo.toml /src/dtmt/crates/dtmt/
|
|
||||||
COPY crates/dtmm/Cargo.toml /src/dtmt/crates/dtmm/
|
|
||||||
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/
|
|
||||||
|
|
||||||
# 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
|
|
||||||
COPY lib/oodle /src/dtmt/lib/oodle
|
|
||||||
# color-eyre needs to be copied, too, then, as it's used by `oodle`
|
|
||||||
COPY lib/color-eyre /src/dtmt/lib/color-eyre
|
|
||||||
COPY --from=dtmt-ci-base-msvc /src/*.lib /src/dtmt/lib/oodle/
|
|
||||||
|
|
||||||
RUN cargo build --release --target x86_64-pc-windows-msvc --locked -Zbuild-std
|
|
||||||
RUN rm -r crates lib
|
|
||||||
|
|
||||||
COPY . /src/dtmt
|
|
||||||
COPY --from=dtmt-ci-base-msvc /src/*.lib /src/dtmt/lib/oodle/
|
|
||||||
|
|
||||||
RUN cargo build --release --target x86_64-pc-windows-msvc --frozen -Zbuild-std
|
|
58
Justfile
58
Justfile
|
@ -1,12 +1,52 @@
|
||||||
image_name := 'dt_p2p-ci-base'
|
xwin_version := '0.2.12'
|
||||||
|
xwin_prefix := 'xwin-' + xwin_version + '-x86_64-unknown-linux-musl'
|
||||||
|
|
||||||
ci-build:
|
export WINEPREFIX := justfile_directory() + "/.wineprefix"
|
||||||
docker run --rm -ti --user $(id -u) -v ./:/src/dt_p2p {{ image_name }} cargo --color always build --target x86_64-pc-windows --locked -Zbuild-std
|
export WINEDEBUG := '-all'
|
||||||
|
|
||||||
build-image:
|
# Note that we only disable unused-command-line-argument here since clang-cl
|
||||||
docker build -f .ci/Dockerfile .
|
# doesn't implement all of the options supported by cl, but the ones it doesn't
|
||||||
|
# are _generally_ not interesting.
|
||||||
|
CL_FLAGS := "-Wno-unused-command-line-argument -fuse-ld=lld-link ./msvc/crt/include ./msvc/sdk/include/ucrt ./msvc/sdk/include/um ./msvc/sdk/include/shared"
|
||||||
|
|
||||||
ci-image:
|
export CC_x86_64_pc_windows_msvc := "clang-cl"
|
||||||
docker build -t {{ image_name }} .ci/image
|
export CXX_x86_64_pc_windows_msvc := "clang-cl"
|
||||||
docker tag {{ image_name }} registry.sclu1034.dev/{{ image_name }}
|
export AR_x86_64_pc_windows_msvc := "llvm-lib"
|
||||||
docker push registry.sclu1034.dev/{{ image_name }}
|
# Use wine to run test executables
|
||||||
|
export CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUNNER := "wine"
|
||||||
|
# Let cargo know what linker to invoke if you haven't already specified it
|
||||||
|
# in a .cargo/config.toml file
|
||||||
|
export CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER := "lld-link"
|
||||||
|
export CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS := "-Lnative=./msvc/crt/lib/x86_64 -Lnative=./msvc/sdk/lib/um/x86_64 -Lnative=./msvc/sdk/lib/ucrt/x86_64"
|
||||||
|
export CFLAGS_x86_64_pc_windows_msvc := CL_FLAGS
|
||||||
|
export CXXFLAGS_x86_64_pc_windows_msvc := CL_FLAGS
|
||||||
|
|
||||||
|
default: build
|
||||||
|
|
||||||
|
build: start-wineserver
|
||||||
|
cargo build -Zbuild-std --target x86_64-pc-windows-msvc
|
||||||
|
[ -d "$game_dir" ] && cp ./target/x86_64-pc-windows-msvc/debug/dt_p2p.dll "$game_dir/binaries/plugins/dt_p2p_debug_pluginw64_release.dll"
|
||||||
|
|
||||||
|
[no-exit-message]
|
||||||
|
wine *ARGS:
|
||||||
|
@wine {{ ARGS }}
|
||||||
|
|
||||||
|
start-wineserver:
|
||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
bold=$(tput bold)
|
||||||
|
normal=$(tput sgr0)
|
||||||
|
|
||||||
|
mkdir -p "$WINEPREFIX"
|
||||||
|
if ! pgrep wineserver >/dev/null; then
|
||||||
|
echo "${bold}wineserver -p${normal}"
|
||||||
|
wineserver -p
|
||||||
|
echo "${bold}wine wineboot --init --update${normal}"
|
||||||
|
wine wineboot --init --update
|
||||||
|
fi
|
||||||
|
|
||||||
|
setup-msvc:
|
||||||
|
mkdir -p ./tools
|
||||||
|
curl --fail -L https://github.com/Jake-Shadle/xwin/releases/download/{{ xwin_version }}/{{ xwin_prefix }}.tar.gz | tar -xzv -C ./tools --strip-components=1 {{ xwin_prefix }}/xwin
|
||||||
|
./tools/xwin --accept-license splat --include-debug-libs --output ./msvc
|
||||||
|
|
26
README.adoc
26
README.adoc
|
@ -11,3 +11,29 @@
|
||||||
:warning-caption: :warning:
|
:warning-caption: :warning:
|
||||||
|
|
||||||
An engine plugin for Warhammer 40,000 Darktide that implements peer-to-peer networking.
|
An engine plugin for Warhammer 40,000 Darktide that implements peer-to-peer networking.
|
||||||
|
|
||||||
|
== Building
|
||||||
|
|
||||||
|
> This assumes cross-compiling on a Linux build machine.
|
||||||
|
> If you're on Windows, you're on your own. Shouldn't be too difficult, you're on native build anyways.
|
||||||
|
|
||||||
|
=== Prerequisites
|
||||||
|
|
||||||
|
* A reasonably recent version of LLVM, lld & Clang
|
||||||
|
** A symlink `clang-cl` -> `clang` in `PATH`
|
||||||
|
* cURL
|
||||||
|
* Wine
|
||||||
|
* Rust nightly toolchain, MSVC target and `rust-src`:
|
||||||
|
** `rustup toolchain install nightly`
|
||||||
|
** `rustup target add x86_64-pc-windows-msvc`
|
||||||
|
** `rustup component add rust-src`
|
||||||
|
|
||||||
|
=== Build
|
||||||
|
|
||||||
|
You'll need to download the MSVC libraries once (their license forbids redistribution, even in something like a Docker image).
|
||||||
|
|
||||||
|
With https://github.com/casey/just[just], simply run `just setup-msvc`, otherwise run the corresponding commands from `Justfile` manually. This will download the current Visual Studio Build Tools and corresponding libraries and headers into `./msvc`.
|
||||||
|
|
||||||
|
Then run `just build`, which runs `cargo build` with the necessary toolchain variables set (see top of `Justfile`).
|
||||||
|
|
||||||
|
The `.dll` in `target/x86_64-pc-windows-msvc/debug` can then be copied to the game's `binaries/plugins` folder. Remember to rename it so it has the required `_pluginw64_release.dll` suffix.
|
||||||
|
|
2
lib/dt_p2p/.gitignore
vendored
2
lib/dt_p2p/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
/target
|
|
||||||
/Cargo.lock
|
|
|
@ -1,15 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "dt_p2p"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
libc = "0.2.144"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib", "lib"]
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
bindgen = "0.65.1"
|
|
|
@ -1,53 +0,0 @@
|
||||||
mod stingray_sdk;
|
|
||||||
|
|
||||||
use std::ffi::c_char;
|
|
||||||
use std::ffi::CString;
|
|
||||||
|
|
||||||
use stingray_sdk::GetApiFunction;
|
|
||||||
use stingray_sdk::PluginApi;
|
|
||||||
use stingray_sdk::PluginApiID;
|
|
||||||
|
|
||||||
use crate::stingray_sdk::LoggingApi;
|
|
||||||
|
|
||||||
const PLUGIN_NAME: &str = "dt_p2p";
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn get_name() -> *const c_char {
|
|
||||||
let s = CString::new(PLUGIN_NAME).expect("Failed to create CString from plugin name");
|
|
||||||
s.as_ptr()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn setup_game(get_engine_api: GetApiFunction) {
|
|
||||||
println!("setup_game");
|
|
||||||
|
|
||||||
let log = LoggingApi::get(get_engine_api);
|
|
||||||
|
|
||||||
log.info(
|
|
||||||
PLUGIN_NAME,
|
|
||||||
format!("Hello, world! This is {}!", PLUGIN_NAME),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn shutdown_game() {
|
|
||||||
println!("shutdown_game");
|
|
||||||
|
|
||||||
// log.info(PLUGIN_NAME, format!("Goodbye, world!", PLUGIN_NAME));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn get_plugin_api(id: PluginApiID) -> *mut PluginApi {
|
|
||||||
if id == PluginApiID::PLUGIN_API_ID {
|
|
||||||
let api = PluginApi {
|
|
||||||
get_name: Some(get_name),
|
|
||||||
setup_game: Some(setup_game),
|
|
||||||
shutdown_game: Some(shutdown_game),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
Box::into_raw(Box::new(api))
|
|
||||||
} else {
|
|
||||||
std::ptr::null_mut()
|
|
||||||
}
|
|
||||||
}
|
|
2
lib/nat_traversal/.gitignore
vendored
2
lib/nat_traversal/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
/target
|
|
||||||
/Cargo.lock
|
|
|
@ -1,8 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "nat_traversal"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
|
@ -1,14 +0,0 @@
|
||||||
pub fn add(left: usize, right: usize) -> usize {
|
|
||||||
left + right
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn it_works() {
|
|
||||||
let result = add(2, 2);
|
|
||||||
assert_eq!(result, 4);
|
|
||||||
}
|
|
||||||
}
|
|
4
rust-toolchain.toml
Normal file
4
rust-toolchain.toml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
[toolchain]
|
||||||
|
channel = "nightly"
|
||||||
|
components = ["rust-src"]
|
||||||
|
targets = ["x86_64-pc-windows-msvc"]
|
20
rustfmt.toml
Normal file
20
rustfmt.toml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Copyright (C) 2022 Lucas Schwiderski
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
unstable_features = true
|
||||||
|
hard_tabs = false
|
||||||
|
max_width = 100
|
||||||
|
edition = "2021"
|
||||||
|
use_field_init_shorthand = true
|
60
src/lib.rs
Normal file
60
src/lib.rs
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
use std::ffi::{c_char, CString};
|
||||||
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
|
mod plugin;
|
||||||
|
mod stingray_sdk;
|
||||||
|
|
||||||
|
use plugin::Plugin;
|
||||||
|
use stingray_sdk::{GetApiFunction, PluginApi, PluginApiID};
|
||||||
|
|
||||||
|
pub const PLUGIN_NAME: &str = "dt_p2p";
|
||||||
|
|
||||||
|
static PLUGIN: OnceLock<Plugin> = OnceLock::new();
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn get_name() -> *const c_char {
|
||||||
|
let s = CString::new(PLUGIN_NAME).expect("Failed to create CString from plugin name");
|
||||||
|
s.as_ptr()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn setup_game(get_engine_api: GetApiFunction) {
|
||||||
|
let plugin = Plugin::new(get_engine_api);
|
||||||
|
plugin.setup_game();
|
||||||
|
PLUGIN
|
||||||
|
.set(plugin)
|
||||||
|
.expect("Failed to initalize global plugin object.");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn shutdown_game() {
|
||||||
|
// Safety: The engine ensures that `setup_game` was called before this, where `PLUGIN` was
|
||||||
|
// initialized.
|
||||||
|
let plugin = unsafe { PLUGIN.get().unwrap_unchecked() };
|
||||||
|
plugin.shutdown_game();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn update_game(dt: f32) {
|
||||||
|
// Safety: The engine ensures that `setup_game` was called before this, where `PLUGIN` was
|
||||||
|
// initialized.
|
||||||
|
let plugin = unsafe { PLUGIN.get().unwrap_unchecked() };
|
||||||
|
plugin.update_game(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn get_plugin_api(id: PluginApiID) -> *mut PluginApi {
|
||||||
|
if id == PluginApiID::PLUGIN_API_ID {
|
||||||
|
let api = PluginApi {
|
||||||
|
get_name: Some(get_name),
|
||||||
|
setup_game: Some(setup_game),
|
||||||
|
update_game: Some(update_game),
|
||||||
|
shutdown_game: Some(shutdown_game),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
Box::into_raw(Box::new(api))
|
||||||
|
} else {
|
||||||
|
std::ptr::null_mut()
|
||||||
|
}
|
||||||
|
}
|
33
src/plugin.rs
Normal file
33
src/plugin.rs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
use crate::stingray_sdk::{GetApiFunction, LoggingApi};
|
||||||
|
use crate::PLUGIN_NAME;
|
||||||
|
|
||||||
|
pub(crate) struct Plugin {
|
||||||
|
log: LoggingApi,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Plugin {
|
||||||
|
pub fn new(get_engine_api: GetApiFunction) -> Self {
|
||||||
|
let log = LoggingApi::get(get_engine_api);
|
||||||
|
Self { log }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn setup_game(&self) {
|
||||||
|
self.log.info(
|
||||||
|
PLUGIN_NAME,
|
||||||
|
format!("[setup_game] Hello, world! This is {}!", PLUGIN_NAME),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn shutdown_game(&self) {
|
||||||
|
self.log
|
||||||
|
.info(PLUGIN_NAME, format!("[shutdown_game] Goodbye, world!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update_game(&self, dt: f32) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Plugin {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.write_str("PluginApi")
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue