From 28d5272e712fb9dd543a617cdbe4ec973c9c570a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Marc=CC=A7al?= Date: Sun, 5 Jan 2025 20:40:27 -0300 Subject: [PATCH] build(swift): include all source files --- Package.swift | 10 +++++++++- lib/src/wasm/stdlib.c | 4 ++++ lib/src/wasm/wasm-stdlib.h | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 86e1ef01..572ba684 100644 --- a/Package.swift +++ b/Package.swift @@ -14,7 +14,15 @@ let package = Package( targets: [ .target(name: "TreeSitter", path: "lib", - sources: ["src/lib.c"], + exclude: [ + "src/unicode/ICU_SHA", + "src/unicode/README.md", + "src/unicode/LICENSE", + "src/wasm/stdlib-symbols.txt", + "src/lib.c", + ], + sources: ["src"], + publicHeadersPath: "include", cSettings: [ .headerSearchPath("src"), .define("_POSIX_C_SOURCE", to: "200112L"), diff --git a/lib/src/wasm/stdlib.c b/lib/src/wasm/stdlib.c index cfe2e4b3..e3e59f5d 100644 --- a/lib/src/wasm/stdlib.c +++ b/lib/src/wasm/stdlib.c @@ -3,6 +3,8 @@ // as needed, and freeing is mostly a noop. But in the special case of freeing // the last-allocated pointer, we'll reuse that pointer again. +#ifdef TREE_SITTER_FEATURE_WASM + #include #include #include @@ -107,3 +109,5 @@ void *realloc(void *ptr, size_t new_size) { memcpy(result, ®ion->data, region->size); return result; } + +#endif diff --git a/lib/src/wasm/wasm-stdlib.h b/lib/src/wasm/wasm-stdlib.h index dfc28cc6..a9d241d7 100644 --- a/lib/src/wasm/wasm-stdlib.h +++ b/lib/src/wasm/wasm-stdlib.h @@ -1,3 +1,5 @@ +#ifdef TREE_SITTER_FEATURE_WASM + unsigned char STDLIB_WASM[] = { 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x1e, 0x06, 0x60, 0x02, 0x7f, 0x7f, 0x01, 0x7f, 0x60, 0x01, 0x7f, 0x00, 0x60, 0x00, 0x00, @@ -1308,3 +1310,5 @@ unsigned char STDLIB_WASM[] = { 0x74 }; unsigned int STDLIB_WASM_LEN = 15673; + +#endif