Skip to content

armgit / klad

Public Imported from GitHub
0

A drawing app built for agent/human collaboration

Rust

Windows: klad's debug build fits the 1 MB main stack, and a kept Godot folder is written with forward slashes

Indicode BV2207605bb6f2
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 48a0a95..04039fc 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -101,6 +101,14 @@ jobs:
echo "::warning title=${{ matrix.name }} tests::$line"
done
fi
+ - name: The main stack klad was linked with
+ if: always() && runner.os == 'Windows'
+ run: |
+ for exe in "${{ matrix.target }}/release/klad.exe" "${{ matrix.target }}/debug/klad.exe"; do
+ [ -f "$exe" ] || continue
+ reserve="$(python -c "import struct, sys; b = open(sys.argv[1], 'rb').read(4096); o = struct.unpack_from('<I', b, 0x3c)[0]; print(struct.unpack_from('<Q', b, o + 96)[0])" "$exe")"
+ echo "::notice title=Windows main stack::$exe is linked with $reserve bytes"
+ done
- name: Tests must pass where klad is tested
if: steps.tests.outcome == 'failure' && runner.os != 'Windows'
run: exit 1
diff --git a/Cargo.toml b/Cargo.toml
index 42463b0..9e1719a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,9 @@ publish = false
incremental = false
debug = "line-tables-only"
+[profile.dev.package.klad-cli]
+opt-level = 1
+
[profile.release]
debug = 1
diff --git a/crates/cli/src/sprites.rs b/crates/cli/src/sprites.rs
index 2781757..f20be0a 100644
--- a/crates/cli/src/sprites.rs
+++ b/crates/cli/src/sprites.rs
@@ -389,6 +389,12 @@ pub fn relative(from: &Path, to: &Path) -> PathBuf {
}
}
+pub fn kept_folder(from: &Path, to: &Path) -> String {
+ relative(from, to)
+ .to_string_lossy()
+ .replace(std::path::MAIN_SEPARATOR, "/")
+}
+
pub(crate) fn read(path: &Path) -> Option<String> {
fs::read_to_string(path).ok()
}
@@ -408,7 +414,7 @@ pub fn godot(path: &Path, dir: Option<PathBuf>, store: bool, look: &Look, packin
};
fs::create_dir_all(&target).with_context(|| format!("making {}", target.display()))?;
let target = target.canonicalize()?;
- let rel = relative(&home.canonicalize()?, &target).to_string_lossy().to_string();
+ let rel = kept_folder(&home.canonicalize()?, &target);
let keep = match (&dir, &stored) {
(Some(_), None) => true,
(Some(_), Some(s)) => store && *s != rel,
@@ -789,7 +795,7 @@ func _init():
#[test]
fn relative_folders_walk_up_and_down() {
- let rel = |a: &str, b: &str| relative(Path::new(a), Path::new(b)).to_string_lossy().to_string();
+ let rel = |a: &str, b: &str| kept_folder(Path::new(a), Path::new(b));
assert_eq!(rel("/work/art", "/work/game/sprites"), "../game/sprites");
assert_eq!(rel("/work/art", "/work/art/godot"), "godot");
assert_eq!(rel("/work/art", "/work/art"), ".");