Skip to content

Commit

Permalink
build: hopefully fix windows
Browse files Browse the repository at this point in the history
and a few more stuff
  • Loading branch information
ObserverOfTime committed Mar 15, 2024
1 parent 3f07987 commit 9c06be4
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ on:
- "bindings/**"
- "binding.gyp"

concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true

jobs:
test:
name: Test parsers
Expand Down
2 changes: 1 addition & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"-std=c11",
"-Wno-unused-value",
]
},
}
]
}
3 changes: 3 additions & 0 deletions bindings/go/binding.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package tree_sitter_xml

//go:generate make -C../../xml libtree-sitter-xml.a
//go:generate make -C../../dtd libtree-sitter-dtd.a

// #cgo CFLAGS: -std=c11 -fPIC
// #cgo LDFLAGS: -L../../xml -l:libtree-sitter-xml.a
// #cgo LDFLAGS: -L../../dtd -l:libtree-sitter-dtd.a
Expand Down
3 changes: 2 additions & 1 deletion bindings/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ fn main() {
let mut config = cc::Build::new();
config.include(&xml_dir);
config
.flag_if_supported("-std=c11")
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-value");

Expand All @@ -22,5 +23,5 @@ fn main() {

println!("cargo:rerun-if-changed={}", common_dir.join("scanner.h").to_str().unwrap());

config.compile("parser-scanner");
config.compile("tree-sitter-xml");
}
2 changes: 1 addition & 1 deletion common/scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static inline void advance(TSLexer *lexer) { lexer->advance(lexer, false); }
/// Check if the character is valid in a name
/// TODO: explicitly follow https://www.w3.org/TR/xml11/#NT-Name
static inline bool is_valid_name_char(wchar_t chr) {
return iswalnum(chr) || chr == '_' || chr == ':' || chr == '.' || chr == '-' || chr == L'·';
return iswalnum(chr) || chr == '_' || chr == ':' || chr == '.' || chr == '-' || chr == 0xB7;
}

/// Check if the character is valid to start a name
Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ def get_tag(self):
"dtd/src/parser.c",
"dtd/src/scanner.c",
],
extra_compile_args=(
["-std=c11", "-Wno-unused-value"] if system() != "Windows" else []
),
extra_compile_args=[
"-std=c11",
"-Wno-unused-parameter",
"-Wno-unused-value",
] if system() != "Windows" else [],
define_macros=[
("Py_LIMITED_API", "0x03080000"),
("PY_SSIZE_T_CLEAN", None)
Expand Down
2 changes: 2 additions & 0 deletions xml/src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ typedef Array(String) Vector;
/// Create a new String instance
#define String() { ts_calloc(STRING_CAP + 1, sizeof(char)), 0, STRING_CAP }

#ifndef _WIN32
static inline uint32_t max(uint32_t a, uint32_t b) {
return a > b ? a : b;
}
#endif

static inline bool string_equals(String *a, String b) {
return strcmp(a->contents, b.contents) == 0;
Expand Down

0 comments on commit 9c06be4

Please sign in to comment.