Bundle extools and auxtools in all builds, not just releases

This commit is contained in:
Tad Hardesty 2024-08-08 20:27:25 -07:00
parent d423f00f78
commit 6cae59f0ef
11 changed files with 249 additions and 70 deletions

204
Cargo.lock generated
View file

@ -100,6 +100,17 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "async-trait"
version = "0.1.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.68",
]
[[package]]
name = "attribute-derive"
version = "0.6.1"
@ -134,6 +145,12 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "base64"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "bincode"
version = "1.3.3"
@ -155,6 +172,15 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]]
name = "builtins-proc-macro"
version = "0.0.0"
@ -190,6 +216,12 @@ dependencies = [
"syn 2.0.68",
]
[[package]]
name = "bytes"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
[[package]]
name = "cc"
version = "1.0.100"
@ -291,6 +323,15 @@ version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
[[package]]
name = "cpufeatures"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504"
dependencies = [
"libc",
]
[[package]]
name = "crc32fast"
version = "1.4.2"
@ -325,6 +366,16 @@ version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
[[package]]
name = "crypto-common"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "dap-types"
version = "0.0.0"
@ -357,6 +408,16 @@ dependencies = [
"syn 2.0.68",
]
[[package]]
name = "digest"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
]
[[package]]
name = "dm-langserver"
version = "1.9.0"
@ -377,6 +438,8 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"sha256",
"ureq",
"url",
]
@ -603,6 +666,16 @@ dependencies = [
"slab",
]
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "get-size"
version = "0.1.4"
@ -695,6 +768,12 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "iana-time-zone"
version = "0.1.60"
@ -1243,6 +1322,53 @@ dependencies = [
"bytemuck",
]
[[package]]
name = "ring"
version = "0.17.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
dependencies = [
"cc",
"cfg-if",
"getrandom",
"libc",
"spin",
"untrusted",
"windows-sys",
]
[[package]]
name = "rustls"
version = "0.23.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044"
dependencies = [
"log",
"once_cell",
"ring",
"rustls-pki-types",
"rustls-webpki",
"subtle",
"zeroize",
]
[[package]]
name = "rustls-pki-types"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0"
[[package]]
name = "rustls-webpki"
version = "0.102.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e"
dependencies = [
"ring",
"rustls-pki-types",
"untrusted",
]
[[package]]
name = "ryu"
version = "1.0.18"
@ -1300,6 +1426,29 @@ dependencies = [
"syn 2.0.68",
]
[[package]]
name = "sha2"
version = "0.10.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "sha256"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18278f6a914fa3070aa316493f7d2ddfb9ac86ebc06fa3b83bffda487e9065b0"
dependencies = [
"async-trait",
"bytes",
"hex",
"sha2",
]
[[package]]
name = "simd-adler32"
version = "0.3.7"
@ -1327,12 +1476,24 @@ version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "subtle"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "syn"
version = "1.0.109"
@ -1388,6 +1549,12 @@ dependencies = [
"serde",
]
[[package]]
name = "typenum"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "unicase"
version = "2.7.0"
@ -1424,6 +1591,28 @@ version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d"
[[package]]
name = "untrusted"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "ureq"
version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a"
dependencies = [
"base64",
"flate2",
"log",
"once_cell",
"rustls",
"rustls-pki-types",
"url",
"webpki-roots",
]
[[package]]
name = "url"
version = "2.5.2"
@ -1524,6 +1713,15 @@ version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
[[package]]
name = "webpki-roots"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd"
dependencies = [
"rustls-pki-types",
]
[[package]]
name = "weezl"
version = "0.1.8"
@ -1640,3 +1838,9 @@ dependencies = [
"quote",
"syn 2.0.68",
]
[[package]]
name = "zeroize"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"

View file

@ -24,6 +24,8 @@ ahash = "0.8.0"
[build-dependencies]
chrono = "0.4.22"
git2 = { version = "0.18.2", default-features = false }
sha256 = { version = "1.5.0", default-features = false }
ureq = "2.10.1"
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [

View file

@ -4,7 +4,7 @@ extern crate git2;
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
fn main() {
// build info
@ -18,16 +18,24 @@ fn main() {
writeln!(f, "build date: {}", chrono::Utc::now().date_naive()).unwrap();
// extools bundling
println!("cargo:rerun-if-env-changed=EXTOOLS_BUNDLE_DLL");
if env::var_os("EXTOOLS_BUNDLE_DLL").is_some() {
println!("cargo:rustc-cfg=extools_bundle");
}
println!("cargo:rustc-cfg=extools_bundle");
download_dll(
&out_dir,
"extools.dll",
"v0.0.7", // EXTOOLS_TAG
"https://github.com/tgstation/tgstation/raw/34f0cc6394a064b87cbd1d6cb225f1d3df444ba7/byond-extools.dll", // EXTOOLS_DLL_URL
"073dd08790a13580bae71758e9217917700dd85ce8d35cb030cef0cf5920fca8", // EXTOOLS_DLL_SHA256
);
// auxtools bundling
println!("cargo:rerun-if-env-changed=AUXTOOLS_BUNDLE_DLL");
if env::var_os("AUXTOOLS_BUNDLE_DLL").is_some() {
println!("cargo:rustc-cfg=auxtools_bundle");
}
println!("cargo:rustc-cfg=auxtools_bundle");
download_dll(
&out_dir,
"debug_server.dll",
"v2.3.3", // DEBUG_SERVER_TAG
"https://github.com/willox/auxtools/releases/download/v2.3.3/debug_server.dll", // DEBUG_SERVER_DLL_URL
"8c3633d8237738be39a8c8f34bbd3d819cdaa270d1f30774c5007481fc32418c", // DEBUG_SERVER_DLL_SHA256
);
}
fn read_commit() -> Result<String, git2::Error> {
@ -60,3 +68,20 @@ fn read_commit() -> Result<String, git2::Error> {
Ok(head.to_string())
}
fn download_dll(out_dir: &Path, fname: &str, tag: &str, url: &str, sha256: &str) {
let full_path = out_dir.join(fname);
println!("cargo:rustc-env=BUNDLE_PATH_{}={}", fname, full_path.display());
println!("cargo:rustc-env=BUNDLE_VERSION_{}={}", fname, tag);
if let Ok(digest) = sha256::try_digest(&full_path) {
if digest == sha256 {
return;
}
}
std::io::copy(
&mut ureq::get(url).call().expect("Error downloading DLL to bundle").into_reader(),
&mut std::fs::File::create(full_path).unwrap(),
).unwrap();
}

View file

@ -3,7 +3,7 @@ use std::fs::File;
use std::io::{Result, Write};
use std::path::{Path, PathBuf};
const BYTES: &[u8] = include_bytes!(env!("AUXTOOLS_BUNDLE_DLL"));
const BYTES: &[u8] = include_bytes!(env!("BUNDLE_PATH_debug_server.dll"));
fn write(path: &Path) -> Result<()> {
File::create(path)?.write_all(BYTES)

View file

@ -3,7 +3,7 @@ use std::fs::File;
use std::io::{Result, Write};
use std::path::{Path, PathBuf};
const BYTES: &[u8] = include_bytes!(env!("EXTOOLS_BUNDLE_DLL"));
const BYTES: &[u8] = include_bytes!(env!("BUNDLE_PATH_extools.dll"));
fn write(path: &Path) -> Result<()> {
File::create(path)?.write_all(BYTES)

View file

@ -68,10 +68,10 @@ fn main() {
}
eprint!("{}", include_str!(concat!(env!("OUT_DIR"), "/build-info.txt")));
#[cfg(extools_bundle)] {
eprintln!("extools commit: {}", env!("EXTOOLS_COMMIT_HASH"));
eprintln!("extools commit: {}", env!("BUNDLE_VERSION_extools.dll"));
}
#[cfg(auxtools_bundle)] {
eprintln!("auxtools commit: {}", env!("AUXTOOLS_COMMIT_HASH"));
eprintln!("auxtools commit: {}", env!("BUNDLE_VERSION_debug_server.dll"));
}
match std::env::current_dir() {
Ok(path) => eprintln!("directory: {}", path.display()),

View file

@ -4,11 +4,6 @@ set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
cd ..
# -----------------------------------------------------------------------------
# Prepare dependency DLLs
eval "$(scripts/download-extools.sh)"
eval "$(scripts/download-auxtools.sh)"
# -----------------------------------------------------------------------------
# Cargo build
touch crates/dm-langserver/build.rs

View file

@ -9,11 +9,6 @@ cd ..
relname=$(git describe --tags --exact)
echo "Using tag name: $relname"
# -----------------------------------------------------------------------------
# Prepare dependency DLLs
eval "$(scripts/download-extools.sh)"
eval "$(scripts/download-auxtools.sh)"
# -----------------------------------------------------------------------------
# Cargo build
touch crates/*/build.rs

View file

@ -1,21 +0,0 @@
#!/bin/bash
set -euo pipefail
# Settings
DEBUG_SERVER_TAG=v2.3.3
DEBUG_SERVER_DLL_URL=https://github.com/willox/auxtools/releases/download/v2.3.3/debug_server.dll
DEBUG_SERVER_DLL_SHA256=8c3633d8237738be39a8c8f34bbd3d819cdaa270d1f30774c5007481fc32418c
# -----------------------------------------------------------------------------
cd "$(dirname "${BASH_SOURCE[0]}")"
mkdir -p "../target/deps"
cd "../target/deps"
AUXTOOLS_BUNDLE_DLL="$PWD/debug_server.dll"
echo "export AUXTOOLS_BUNDLE_DLL=$AUXTOOLS_BUNDLE_DLL"
echo "export AUXTOOLS_COMMIT_HASH=$DEBUG_SERVER_TAG"
if ! test -f "$AUXTOOLS_BUNDLE_DLL" || ! sha256sum -c <<<"$DEBUG_SERVER_DLL_SHA256 $AUXTOOLS_BUNDLE_DLL" >/dev/null 2>/dev/null; then
wget -q -O "$AUXTOOLS_BUNDLE_DLL" "$DEBUG_SERVER_DLL_URL" >&2
sha256sum -c <<<"$DEBUG_SERVER_DLL_SHA256 $AUXTOOLS_BUNDLE_DLL" >&2
fi

View file

@ -1,21 +0,0 @@
#!/bin/bash
set -euo pipefail
# Settings
EXTOOLS_TAG=v0.0.7
EXTOOLS_DLL_URL=https://github.com/tgstation/tgstation/raw/34f0cc6394a064b87cbd1d6cb225f1d3df444ba7/byond-extools.dll
EXTOOLS_DLL_SHA256=073dd08790a13580bae71758e9217917700dd85ce8d35cb030cef0cf5920fca8
# -----------------------------------------------------------------------------
cd "$(dirname "${BASH_SOURCE[0]}")"
mkdir -p "../target/deps"
cd "../target/deps"
EXTOOLS_BUNDLE_DLL="$PWD/extools.dll"
echo "export EXTOOLS_BUNDLE_DLL=$EXTOOLS_BUNDLE_DLL"
echo "export EXTOOLS_COMMIT_HASH=$EXTOOLS_TAG"
if ! test -f "$EXTOOLS_BUNDLE_DLL" || ! sha256sum -c <<<"$EXTOOLS_DLL_SHA256 $EXTOOLS_BUNDLE_DLL" >/dev/null 2>/dev/null; then
wget -q -O "$EXTOOLS_BUNDLE_DLL" "$EXTOOLS_DLL_URL" >&2
sha256sum -c <<<"$EXTOOLS_DLL_SHA256 $EXTOOLS_BUNDLE_DLL" >&2
fi

View file

@ -12,11 +12,11 @@ DEBUG_SERVER_DLL_URL=https://github.com/willox/auxtools/releases/download/$DEBUG
DEBUG_SERVER_DLL_SHA256=$(curl -L -s "$DEBUG_SERVER_DLL_URL" | sha256sum | cut -d' ' -f1)
sed \
-e "/^DEBUG_SERVER_TAG=/c DEBUG_SERVER_TAG=$DEBUG_SERVER_TAG" \
-e "/^DEBUG_SERVER_DLL_URL=/c DEBUG_SERVER_DLL_URL=$DEBUG_SERVER_DLL_URL" \
-e "/^DEBUG_SERVER_DLL_SHA256=/c DEBUG_SERVER_DLL_SHA256=$DEBUG_SERVER_DLL_SHA256" \
-e "/DEBUG_SERVER_TAG$/c\\ \"$DEBUG_SERVER_TAG\", // DEBUG_SERVER_TAG" \
-e "/DEBUG_SERVER_DLL_URL$/c\\ \"$DEBUG_SERVER_DLL_URL\", // DEBUG_SERVER_DLL_URL" \
-e "/DEBUG_SERVER_DLL_SHA256$/c\\ \"$DEBUG_SERVER_DLL_SHA256\", // DEBUG_SERVER_DLL_SHA256" \
--in-place \
download-auxtools.sh
../crates/dm-langserver/build.rs
# Prepare the commit
git commit -m "Update to auxtools debug server $DEBUG_SERVER_TAG" -- download-auxtools.sh
git commit -m "Update to auxtools debug server $DEBUG_SERVER_TAG" -- ../crates/dm-langserver/build.rs