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 9f42807 commit adfa6b4
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 7 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ A tree-sitter parser for XML & DTD files.
[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix
[npm]: https://img.shields.io/npm/v/%40tree-sitter-grammars%2Ftree-sitter-xml?logo=npm
[crates]: https://img.shields.io/crates/v/tree-sitter-xml?logo=rust
[pypi]: https://img.shields.io/pypi/v/tree-sitter-pymanifest?logo=pypi&logoColor=ffd242
[pypi]: https://img.shields.io/pypi/v/tree-sitter-xml?logo=pypi&logoColor=ffd242
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

1 comment on commit adfa6b4

@Robert4S
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting the following error message on nvim boot:

nvim-treesitter[xml]: Error during compilation
src/scanner.c: In function 'string_push':
src/scanner.c:28:24: warning: implicit declaration of function 'max' [-Wimplicit-function-declaration]
   28 |         uint32_t cap = max(STRING_CAP, string->size << 1);
      |                        ^~~

collect2.exe: error: ld returned 1 exit status

so it seems like this max function is not being declared

Please sign in to comment.