diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..f499146 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,97 @@ +# This workflow is based on tg-rust-g/.github/workflows/rust.yml +# It has very minor modifications to be compatible with this +name: rust-g +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + build-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: "Apply Paradise Patches" + run: | + git config --global user.email "action@github.com" + git config --global user.name "CI User" + ./apply_patches.sh + shell: bash + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: i686-pc-windows-msvc + - name: Check (all features) + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: check + args: --manifest-path paradise-rust-g/Cargo.toml --target i686-pc-windows-msvc --all-features + - name: Build (release) (default features) + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: build + args: --manifest-path paradise-rust-g/Cargo.toml --target i686-pc-windows-msvc --release + - uses: actions/upload-artifact@v1 + with: + name: rust_g.dll + path: paradise-rust-g/target/i686-pc-windows-msvc/release/rust_g.dll + build-linux: + runs-on: ubuntu-latest + env: + BYOND_MAJOR: 513 + BYOND_MINOR: 1536 + PKG_CONFIG_ALLOW_CROSS: 1 + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: "Apply Paradise Patches" + run: | + git config --global user.email "action@github.com" + git config --global user.name "CI User" + ./apply_patches.sh + - run: | + sudo dpkg --add-architecture i386 + sudo apt-get update + sudo apt-get install g++-multilib zlib1g-dev:i386 libssl-dev:i386 pkg-config:i386 + ./paradise-rust-g/scripts/install_byond.sh + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: i686-unknown-linux-gnu + - name: Check (all features) + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: check + args: --manifest-path paradise-rust-g/Cargo.toml --target i686-unknown-linux-gnu --all-features + - name: Build (Debug) (all features) + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: build + args: --manifest-path paradise-rust-g/Cargo.toml --target i686-unknown-linux-gnu --all-features + - name: Run tests (all features) + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: test + args: --manifest-path paradise-rust-g/Cargo.toml --target i686-unknown-linux-gnu --all-features + env: + BYOND_BIN: /home/runner/BYOND/byond/bin + - name: Build (release) (default features) + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: build + args: --manifest-path paradise-rust-g/Cargo.toml --target i686-unknown-linux-gnu --release + - uses: actions/upload-artifact@v1 + with: + name: rust_g + path: paradise-rust-g/target/i686-unknown-linux-gnu/release/librust_g.so diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76b89d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +paradise-rust-g \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..81d2c41 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tg-rust-g"] + path = tg-rust-g + url = https://github.com/tgstation/rust-g.git diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..4441b37 --- /dev/null +++ b/README.MD @@ -0,0 +1,32 @@ +# ParadiseSS13 RUST-G + +This repository holds ParadiseSS13 modifications of [rust-g](https://github.com/tgstation/rust-g) libraries from /tg/station. + +This works by keeping an up-to-date copy of /tg/station's code, and a folder of Paradise patches to be applied. This reduces our need for major reworks to code, as we can just use patches to achieve what we need without cluttering the main tree. + +## License + +The license for RUST-G itself can be found inside the `tg-rust-g` directory. Code for the Paradise modifications falls under the same license. + +## How to (Compiling) + +1. You **must** have a copy of `Git Bash` or some other bash emulator on windows, and a git identity setup. This will not work otherwise. +2. Run the `apply_patches.sh` file to autocreate a clone of `tg-rust-g`, and apply the patches to it. +3. Paradise RUST-G requires all features to be enabled. + - To build on windows, run `cargo build --release --all-features --target=i686-pc-windows-msvc`. This will generate a 32-bit `.dll` file that is compatible with BYOND. + - To build on linux, run `cargo build --release --all-features --target=i686-unknown-linux-gnu`. This will generate a 32-bit `.so` file that is compatible with BYOND. + +If you are still stuck, check `tg-rust-g/README.md` for more detailed instructions. + +## How to (Developing) + +1. You **must** have a copy of `Git Bash` or some other bash emulator on windows, and a git identity setup. This will not work otherwise. +2. Run the `apply_patches.sh` file to autocreate a clone of `tg-rust-g`, and apply the patches to it. +3. Open the folder called `paradise-rust-g` inside an IDE of your choice. Make your edits in here. +4. Save your edits as a single commit inside `paradise-rust-g`. Do not push changes. Do not modify `tg-rust-g`. +5. Run the `rebuild_patches.sh` script to convert your commit into a patch that will be saved in the `paradise_patches` directory + +## Credits + +- /tg/station for the original RUST-G works. +- SpigotMC for the patching logic. diff --git a/apply_patches.sh b/apply_patches.sh new file mode 100755 index 0000000..7a28595 --- /dev/null +++ b/apply_patches.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +PS1="$" +basedir=`pwd` +echo "Rebuilding projects.... " + +apply_patch() { + what=$1 + target=$2 + branch=$3 + + cd "$basedir" + if [ ! -d "$target" ]; then + git clone $what $target + fi + cd "$basedir/$target" + echo "Resetting $target to $what..." + git config commit.gpgSign false + git remote rm origin >/dev/null 2>&1 + git remote add origin ../$what >/dev/null 2>&1 + git checkout master >/dev/null 2>&1 + git fetch origin >/dev/null 2>&1 + git reset --hard $branch + + echo " Applying patches to $target..." + git am --abort >/dev/null 2>&1 + git am --3way --ignore-space-change --ignore-whitespace "../${target}-patches/"*.patch + if [ "$?" != "0" ]; then + echo " Something did not apply cleanly to $target." + echo " Please review above details and finish the apply then" + echo " save the changes with rebuild_patches.sh" + exit 1 + else + echo " Patches applied cleanly to $target" + fi +} + +apply_patch tg-rust-g paradise-rust-g origin/master diff --git a/paradise-rust-g-patches/0001-Paradise-Version-Changes.patch b/paradise-rust-g-patches/0001-Paradise-Version-Changes.patch new file mode 100644 index 0000000..4ad0a37 --- /dev/null +++ b/paradise-rust-g-patches/0001-Paradise-Version-Changes.patch @@ -0,0 +1,41 @@ +From 7a73222a05051a5b839034a65f9575adf052e29d Mon Sep 17 00:00:00 2001 +From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> +Date: Wed, 13 Oct 2021 22:04:30 +0100 +Subject: [PATCH] Paradise Version Changes + + +diff --git a/Cargo.lock b/Cargo.lock +index 94f4437..9f52312 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -1502,7 +1502,7 @@ dependencies = [ + + [[package]] + name = "rust-g" +-version = "0.5.0" ++version = "0.5.0-P" + dependencies = [ + "base64 0.13.0", + "chrono", +diff --git a/Cargo.toml b/Cargo.toml +index 785f036..6fac5ec 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -1,11 +1,11 @@ + [package] + name = "rust-g" + edition = "2018" +-version = "0.5.0" ++version = "0.5.0-P" + authors = ["Bjorn Neergaard "] +-repository = "https://github.com/tgstation/rust-g" ++repository = "https://github.com/ParadiseSS13/rust-g" + license-file = "LICENSE" +-description = "Offloaded task library for the /tg/ Space Station 13 codebase" ++description = "Offloaded task library for the ParadiseSS13 Space Station 13 codebase" + + [lib] + crate-type = ["cdylib"] +-- +2.33.0.windows.2 + diff --git a/paradise-rust-g-patches/0002-Paradise-Logging-Changes.patch b/paradise-rust-g-patches/0002-Paradise-Logging-Changes.patch new file mode 100644 index 0000000..da7be8f --- /dev/null +++ b/paradise-rust-g-patches/0002-Paradise-Logging-Changes.patch @@ -0,0 +1,55 @@ +From a5fb0665885e2c297d4c4d2accf58dd34afac723 Mon Sep 17 00:00:00 2001 +From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> +Date: Wed, 13 Oct 2021 22:04:37 +0100 +Subject: [PATCH] Paradise Logging Changes + + +diff --git a/dmsrc/log.dm b/dmsrc/log.dm +index d0380a5..9faa561 100644 +--- a/dmsrc/log.dm ++++ b/dmsrc/log.dm +@@ -1,2 +1,2 @@ +-#define rustg_log_write(fname, text, format) call(RUST_G, "log_write")(fname, text, format) ++#define rustg_log_write(fname, text) call(RUST_G, "log_write")(fname, text) + /proc/rustg_log_close_all() return call(RUST_G, "log_close_all")() +diff --git a/src/log.rs b/src/log.rs +index 41e86aa..8e43147 100644 +--- a/src/log.rs ++++ b/src/log.rs +@@ -14,7 +14,7 @@ thread_local! { + static FILE_MAP: RefCell> = RefCell::new(HashMap::new()); + } + +-byond_fn! { log_write(path, data, ...rest) { ++byond_fn! { log_write(path, data) { + FILE_MAP.with(|cell| -> Result<()> { + // open file + let mut map = cell.borrow_mut(); +@@ -24,20 +24,10 @@ byond_fn! { log_write(path, data, ...rest) { + Entry::Vacant(elem) => elem.insert(open(path)?), + }; + +- if rest.first().map(|x| &**x) == Some("false") { +- // Write the data to the file with no accoutrements. +- write!(file, "{}", data)?; +- } else { +- // write first line, timestamped +- let mut iter = data.split('\n'); +- if let Some(line) = iter.next() { +- write!(file, "[{}] {}\n", Utc::now().format("%F %T%.3f"), line)?; +- } +- +- // write remaining lines +- for line in iter { +- write!(file, " - {}\n", line)?; +- } ++ // write all lines timestamped ++ let iter = data.split('\n'); ++ for line in iter { ++ write!(file, "[{}] {}\n", Utc::now().format("%FT%T"), line)?; + } + + Ok(()) +-- +2.33.0.windows.2 + diff --git a/paradise-rust-g-patches/0003-Paradise-API-Headers.patch b/paradise-rust-g-patches/0003-Paradise-API-Headers.patch new file mode 100644 index 0000000..c3d658d --- /dev/null +++ b/paradise-rust-g-patches/0003-Paradise-API-Headers.patch @@ -0,0 +1,127 @@ +From 11f3098faf5c6c388b6a24f548ef8cf2075b7321 Mon Sep 17 00:00:00 2001 +From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> +Date: Wed, 13 Oct 2021 22:11:10 +0100 +Subject: [PATCH] Paradise API Headers + + +diff --git a/dmsrc/cellularnoise.dm b/dmsrc/cellularnoise.dm +index 2f48dd9..61303f7 100644 +--- a/dmsrc/cellularnoise.dm ++++ b/dmsrc/cellularnoise.dm +@@ -1,3 +1,5 @@ ++// Cellular Noise Operations // ++ + /** + * This proc generates a cellular automata noise grid which can be used in procedural generation methods. + * +diff --git a/dmsrc/dmi.dm b/dmsrc/dmi.dm +index 6eed4e5..d3f271b 100644 +--- a/dmsrc/dmi.dm ++++ b/dmsrc/dmi.dm +@@ -1,3 +1,4 @@ ++// DMI Operations // + #define rustg_dmi_strip_metadata(fname) call(RUST_G, "dmi_strip_metadata")(fname) + #define rustg_dmi_create_png(path, width, height, data) call(RUST_G, "dmi_create_png")(path, width, height, data) + #define rustg_dmi_resize_png(path, width, height, resizetype) call(RUST_G, "dmi_resize_png")(path, width, height, resizetype) +diff --git a/dmsrc/file.dm b/dmsrc/file.dm +index e0c3033..9692a01 100644 +--- a/dmsrc/file.dm ++++ b/dmsrc/file.dm +@@ -1,3 +1,4 @@ ++// File Operations // + #define rustg_file_read(fname) call(RUST_G, "file_read")(fname) + #define rustg_file_exists(fname) call(RUST_G, "file_exists")(fname) + #define rustg_file_write(text, fname) call(RUST_G, "file_write")(text, fname) +diff --git a/dmsrc/git.dm b/dmsrc/git.dm +index 0dc5edc..b3b8a4b 100644 +--- a/dmsrc/git.dm ++++ b/dmsrc/git.dm +@@ -1,2 +1,3 @@ ++// Git Operations // + #define rustg_git_revparse(rev) call(RUST_G, "rg_git_revparse")(rev) + #define rustg_git_commit_date(rev) call(RUST_G, "rg_git_commit_date")(rev) +diff --git a/dmsrc/hash.dm b/dmsrc/hash.dm +index 867b00e..673ee4e 100644 +--- a/dmsrc/hash.dm ++++ b/dmsrc/hash.dm +@@ -1,3 +1,4 @@ ++// Hashing Operations // + #define rustg_hash_string(algorithm, text) call(RUST_G, "hash_string")(algorithm, text) + #define rustg_hash_file(algorithm, fname) call(RUST_G, "hash_file")(algorithm, fname) + #define rustg_hash_generate_totp(seed) call(RUST_G, "generate_totp")(seed) +diff --git a/dmsrc/http.dm b/dmsrc/http.dm +index 93d964b..c756919 100644 +--- a/dmsrc/http.dm ++++ b/dmsrc/http.dm +@@ -1,3 +1,4 @@ ++// HTTP Operations // + #define RUSTG_HTTP_METHOD_GET "get" + #define RUSTG_HTTP_METHOD_PUT "put" + #define RUSTG_HTTP_METHOD_DELETE "delete" +diff --git a/dmsrc/jobs.dm b/dmsrc/jobs.dm +index 499314b..c034d3c 100644 +--- a/dmsrc/jobs.dm ++++ b/dmsrc/jobs.dm +@@ -1,3 +1,4 @@ ++// Jobs Subsystem Operations // + #define RUSTG_JOB_NO_RESULTS_YET "NO RESULTS YET" + #define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB" + #define RUSTG_JOB_ERROR "JOB PANICKED" +diff --git a/dmsrc/json.dm b/dmsrc/json.dm +index 80a1853..013d2d1 100644 +--- a/dmsrc/json.dm ++++ b/dmsrc/json.dm +@@ -1 +1,2 @@ ++// JSON Operations // + #define rustg_json_is_valid(text) (call(RUST_G, "json_is_valid")(text) == "true") +diff --git a/dmsrc/log.dm b/dmsrc/log.dm +index 9faa561..8e2000a 100644 +--- a/dmsrc/log.dm ++++ b/dmsrc/log.dm +@@ -1,2 +1,3 @@ ++// Logging Operations // + #define rustg_log_write(fname, text) call(RUST_G, "log_write")(fname, text) + /proc/rustg_log_close_all() return call(RUST_G, "log_close_all")() +diff --git a/dmsrc/noise.dm b/dmsrc/noise.dm +index 6277a46..0192899 100644 +--- a/dmsrc/noise.dm ++++ b/dmsrc/noise.dm +@@ -1 +1,2 @@ ++// Noise Operations // + #define rustg_noise_get_at_coordinates(seed, x, y) call(RUST_G, "noise_get_at_coordinates")(seed, x, y) +diff --git a/dmsrc/sql.dm b/dmsrc/sql.dm +index d3bfc49..3f1d92f 100644 +--- a/dmsrc/sql.dm ++++ b/dmsrc/sql.dm +@@ -1,3 +1,4 @@ ++// SQL Opeartions // + #define rustg_sql_connect_pool(options) call(RUST_G, "sql_connect_pool")(options) + #define rustg_sql_query_async(handle, query, params) call(RUST_G, "sql_query_async")(handle, query, params) + #define rustg_sql_query_blocking(handle, query, params) call(RUST_G, "sql_query_blocking")(handle, query, params) +diff --git a/dmsrc/toml.dm b/dmsrc/toml.dm +index e403301..46010e5 100644 +--- a/dmsrc/toml.dm ++++ b/dmsrc/toml.dm +@@ -1 +1,2 @@ ++// TOML Operations // + #define rustg_read_toml_file(path) json_decode(call(RUST_G, "toml_file_to_json")(path) || "null") +diff --git a/dmsrc/unzip.dm b/dmsrc/unzip.dm +index ce945b1..970d673 100644 +--- a/dmsrc/unzip.dm ++++ b/dmsrc/unzip.dm +@@ -1,2 +1,3 @@ ++// Unzip Operations // + #define rustg_unzip_download_async(url, unzip_directory) call(RUST_G, "unzip_download_async")(url, unzip_directory) + #define rustg_unzip_check(job_id) call(RUST_G, "unzip_check")("[job_id]") +diff --git a/dmsrc/url.dm b/dmsrc/url.dm +index b56131b..5e59114 100644 +--- a/dmsrc/url.dm ++++ b/dmsrc/url.dm +@@ -1,3 +1,4 @@ ++// URL Encoder/Decoder Operations // + #define rustg_url_encode(text) call(RUST_G, "url_encode")("[text]") + #define rustg_url_decode(text) call(RUST_G, "url_decode")(text) + +-- +2.33.0.windows.2 + diff --git a/paradise-rust-g-patches/0004-Paradise-DLL-Location-Fix.patch b/paradise-rust-g-patches/0004-Paradise-DLL-Location-Fix.patch new file mode 100644 index 0000000..71874d2 --- /dev/null +++ b/paradise-rust-g-patches/0004-Paradise-DLL-Location-Fix.patch @@ -0,0 +1,22 @@ +From 9205943c2ead317cd6451ea9e4f0372685e8d2bb Mon Sep 17 00:00:00 2001 +From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> +Date: Wed, 13 Oct 2021 22:16:17 +0100 +Subject: [PATCH] Paradise DLL Location Fix + + +diff --git a/dmsrc/main.dm b/dmsrc/main.dm +index bd4497a..23afef1 100644 +--- a/dmsrc/main.dm ++++ b/dmsrc/main.dm +@@ -33,7 +33,7 @@ + // It's not in the current directory, so try others + return __rust_g = "librust_g.so" + else +- return __rust_g = "rust_g" ++ return __rust_g = "rust_g.dll" + + #define RUST_G (__rust_g || __detect_rust_g()) + #endif +-- +2.33.0.windows.2 + diff --git a/paradise-rust-g-patches/0005-Paradise-HTTP-Module-Tweaks.patch b/paradise-rust-g-patches/0005-Paradise-HTTP-Module-Tweaks.patch new file mode 100644 index 0000000..66d20bf --- /dev/null +++ b/paradise-rust-g-patches/0005-Paradise-HTTP-Module-Tweaks.patch @@ -0,0 +1,178 @@ +From ad7d7a43f2f133f182bf53cd395e1d7611e395fc Mon Sep 17 00:00:00 2001 +From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> +Date: Thu, 14 Oct 2021 15:50:14 +0100 +Subject: [PATCH] Paradise HTTP Module Tweaks + + +diff --git a/dmsrc/http.dm b/dmsrc/http.dm +index e74e6d0..55fd9df 100644 +--- a/dmsrc/http.dm ++++ b/dmsrc/http.dm +@@ -1,4 +1,4 @@ +-// HTTP Operations // ++// HTTP Operations // + #define RUSTG_HTTP_METHOD_GET "get" + #define RUSTG_HTTP_METHOD_PUT "put" + #define RUSTG_HTTP_METHOD_DELETE "delete" +@@ -8,3 +8,5 @@ + #define rustg_http_request_blocking(method, url, body, headers, options) call(RUST_G, "http_request_blocking")(method, url, body, headers, options) + #define rustg_http_request_async(method, url, body, headers, options) call(RUST_G, "http_request_async")(method, url, body, headers, options) + #define rustg_http_check_request(req_id) call(RUST_G, "http_check_request")(req_id) ++/proc/rustg_create_async_http_client() return call(RUST_G, "start_http_client")() ++/proc/rustg_close_async_http_client() return call(RUST_G, "shutdown_http_client")() +diff --git a/src/http.rs b/src/http.rs +index 28c8345..430d1d9 100644 +--- a/src/http.rs ++++ b/src/http.rs +@@ -1,8 +1,8 @@ + use crate::{error::Result, jobs}; +-use once_cell::sync::Lazy; + use serde::{Deserialize, Serialize}; + use std::collections::{BTreeMap, HashMap}; + use std::io::Write; ++use std::cell::RefCell; + + // ---------------------------------------------------------------------------- + // Interface +@@ -76,7 +76,9 @@ fn setup_http_client() -> reqwest::blocking::Client { + Client::builder().default_headers(headers).build().unwrap() + } + +-pub static HTTP_CLIENT: Lazy = Lazy::new(setup_http_client); ++thread_local! { ++ pub static HTTP_CLIENT: RefCell> = RefCell::new(Some(setup_http_client())); ++} + + // ---------------------------------------------------------------------------- + // Request construction and execution +@@ -93,38 +95,58 @@ fn construct_request( + headers: &str, + options: Option<&str>, + ) -> Result { +- let mut req = match method { +- "post" => HTTP_CLIENT.post(url), +- "put" => HTTP_CLIENT.put(url), +- "patch" => HTTP_CLIENT.patch(url), +- "delete" => HTTP_CLIENT.delete(url), +- "head" => HTTP_CLIENT.head(url), +- _ => HTTP_CLIENT.get(url), +- }; +- +- if !body.is_empty() { +- req = req.body(body.to_owned()); +- } +- +- if !headers.is_empty() { +- let headers: BTreeMap<&str, &str> = serde_json::from_str(headers)?; +- for (key, value) in headers { +- req = req.header(key, value); +- } +- } +- +- let mut output_filename = None; +- if let Some(options) = options { +- let options: RequestOptions = serde_json::from_str(options)?; +- output_filename = options.output_filename; +- if let Some(fname) = options.body_filename { +- req = req.body(std::fs::File::open(fname)?); ++ HTTP_CLIENT.with(|cell| { ++ let borrow = cell.borrow_mut(); ++ match &*borrow { ++ Some(client) => { ++ let mut req = match method { ++ "post" => client.post(url), ++ "put" => client.put(url), ++ "patch" => client.patch(url), ++ "delete" => client.delete(url), ++ "head" => client.head(url), ++ _ => client.get(url), ++ }; ++ ++ if !body.is_empty() { ++ req = req.body(body.to_owned()); ++ } ++ ++ if !headers.is_empty() { ++ let headers: BTreeMap<&str, &str> = serde_json::from_str(headers)?; ++ for (key, value) in headers { ++ req = req.header(key, value); ++ } ++ } ++ ++ let mut output_filename = None; ++ if let Some(options) = options { ++ if options != "" { ++ let options: RequestOptions = serde_json::from_str(options)?; ++ output_filename = options.output_filename; ++ if let Some(fname) = options.body_filename { ++ req = req.body(std::fs::File::open(fname)?); ++ } ++ } ++ } ++ ++ Ok(RequestPrep { ++ req, ++ output_filename, ++ }) ++ } ++ ++ // If we got here we royally fucked up ++ None => { ++ let client = setup_http_client(); ++ let req = client.get(""); ++ let output_filename = None; ++ Ok(RequestPrep { ++ req, ++ output_filename, ++ }) ++ } + } +- } +- +- Ok(RequestPrep { +- req, +- output_filename, + }) + } + +@@ -156,3 +178,17 @@ fn submit_request(prep: RequestPrep) -> Result { + + Ok(serde_json::to_string(&resp)?) + } ++ ++byond_fn! { start_http_client() { ++ HTTP_CLIENT.with(|cell| { ++ cell.replace(Some(setup_http_client())) ++ }); ++ Some("") ++} } ++ ++byond_fn! { shutdown_http_client() { ++ HTTP_CLIENT.with(|cell| { ++ cell.replace(None) ++ }); ++ Some("") ++} } +diff --git a/src/unzip.rs b/src/unzip.rs +index 8ddc746..ed708be 100644 +--- a/src/unzip.rs ++++ b/src/unzip.rs +@@ -11,9 +11,13 @@ struct UnzipPrep { + } + + fn construct_unzip(url: &str, unzip_directory: &str) -> UnzipPrep { +- let req = HTTP_CLIENT.get(url); +- let dir_copy = unzip_directory.to_string(); ++ let mut reqh = None; ++ HTTP_CLIENT.with(|client| { ++ reqh = Some(client.borrow_mut().as_ref().unwrap().get(url)); ++ }); + ++ let dir_copy = unzip_directory.to_string(); ++ let req = reqh.unwrap(); + UnzipPrep { + req, + unzip_directory: dir_copy, +-- +2.33.0.windows.2 + diff --git a/rebuild_patches.sh b/rebuild_patches.sh new file mode 100755 index 0000000..ac8bdf7 --- /dev/null +++ b/rebuild_patches.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +PS1="$" +basedir=`pwd` +clean=$1 +echo "Rebuilding patch files from current fork state..." + +cleanup_patches() { + cd "$1" + for patch in *.patch; do + gitver=$(tail -n 2 $patch | grep -ve "^$" | tail -n 1) + diffs=$(git diff --staged $patch | grep -E "^(\+|\-)" | grep -Ev "(From [a-z0-9]{32,}|\-\-\- a|\+\+\+ b|.index)") + + testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver") + if [ "x$testver" != "x" ]; then + diffs=$(echo "$diffs" | head -n -2) + fi + + + if [ "x$diffs" == "x" ] ; then + git reset HEAD $patch >/dev/null + git checkout -- $patch >/dev/null + fi + done +} + +save_patches() { + what=$1 + target=$2 + branch=$3 + cd "$basedir/$target" + git format-patch --no-stat -N -o "../${target}-patches/" $branch + cd "$basedir" + git add -A "${target}-patches" + if [ "$clean" != "clean" ]; then + cleanup_patches "${target}-patches" + fi + echo " Patches saved for $what to $target-patches/" +} +if [ "$clean" == "clean" ]; then + rm -rf *-patches +fi +save_patches tg-rust-g paradise-rust-g origin/master \ No newline at end of file diff --git a/tg-rust-g b/tg-rust-g new file mode 160000 index 0000000..995c39c --- /dev/null +++ b/tg-rust-g @@ -0,0 +1 @@ +Subproject commit 995c39ca5ea89061d0b8662f378c6561af3e6324