Compare commits
1 commit
master
...
wip/buildi
Author | SHA1 | Date | |
---|---|---|---|
5bd6ae7df0 |
146 changed files with 260 additions and 470 deletions
108
.ci/image/Dockerfile
Normal file
108
.ci/image/Dockerfile
Normal file
|
@ -0,0 +1,108 @@
|
|||
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
|
|
@ -1,4 +0,0 @@
|
|||
/msvc
|
||||
/target
|
||||
/.xwin-cache
|
||||
/.wineprefix
|
13
.gitignore
vendored
13
.gitignore
vendored
|
@ -1,6 +1,9 @@
|
|||
.envrc
|
||||
/target
|
||||
/msvc
|
||||
/tools/xwin
|
||||
/.xwin-cache
|
||||
/.wineprefix
|
||||
|
||||
|
||||
# Added by cargo
|
||||
#
|
||||
# already existing elements were commented out
|
||||
|
||||
#/target
|
||||
/Cargo.lock
|
||||
|
|
254
Cargo.lock
generated
254
Cargo.lock
generated
|
@ -1,254 +0,0 @@
|
|||
# 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,18 +1,9 @@
|
|||
[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"
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.65.1"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"lib/dt_p2p",
|
||||
"lib/nat_traversal"
|
||||
]
|
||||
|
||||
# [profile.dev.package.backtrace]
|
||||
# opt-level = 3
|
||||
|
|
35
Dockerfile
Normal file
35
Dockerfile
Normal file
|
@ -0,0 +1,35 @@
|
|||
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,52 +1,12 @@
|
|||
xwin_version := '0.2.12'
|
||||
xwin_prefix := 'xwin-' + xwin_version + '-x86_64-unknown-linux-musl'
|
||||
image_name := 'dt_p2p-ci-base'
|
||||
|
||||
export WINEPREFIX := justfile_directory() + "/.wineprefix"
|
||||
export WINEDEBUG := '-all'
|
||||
ci-build:
|
||||
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
|
||||
|
||||
# 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 ./msvc/crt/include ./msvc/sdk/include/ucrt ./msvc/sdk/include/um ./msvc/sdk/include/shared"
|
||||
build-image:
|
||||
docker build -f .ci/Dockerfile .
|
||||
|
||||
export CC_x86_64_pc_windows_msvc := "clang-cl"
|
||||
export CXX_x86_64_pc_windows_msvc := "clang-cl"
|
||||
export AR_x86_64_pc_windows_msvc := "llvm-lib"
|
||||
# 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
|
||||
ci-image:
|
||||
docker build -t {{ image_name }} .ci/image
|
||||
docker tag {{ image_name }} registry.sclu1034.dev/{{ image_name }}
|
||||
docker push registry.sclu1034.dev/{{ image_name }}
|
||||
|
|
26
README.adoc
26
README.adoc
|
@ -11,29 +11,3 @@
|
|||
:warning-caption: :warning:
|
||||
|
||||
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
Normal file
2
lib/dt_p2p/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
/Cargo.lock
|
15
lib/dt_p2p/Cargo.toml
Normal file
15
lib/dt_p2p/Cargo.toml
Normal file
|
@ -0,0 +1,15 @@
|
|||
[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"
|
53
lib/dt_p2p/src/lib.rs
Normal file
53
lib/dt_p2p/src/lib.rs
Normal file
|
@ -0,0 +1,53 @@
|
|||
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()
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue