mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 00:44:27 +00:00
CI: find clang-c/Index.h and libclang where Ubuntu and Homebrew keep them; the language server on Windows paths
CI has failed since the embed merge (2026-10-25): - Linux: bootstrap/build.sh asks llvm-config for the folder with clang-c/Index.h - macOS: FINCH_LIBCLANG's -L folders also go to the compiler's own link "clang" - Windows: the language server turns file:///C:/x into C:/x and back (diagnostics went to /C:/x); the -g tests compare without \r; shared.sh (dlopen, -rdynamic) is not run there Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GzNP6r8dg6WDxUVZy8wjL
This commit is contained in:
parent
bb9702aeba
commit
72e96a3f71
4 changed files with 33 additions and 7 deletions
|
|
@ -27,8 +27,20 @@ case $seed in windows-*) EXE=.exe ;; esac
|
||||||
CLANG=${FINCH_CLANG:-clang}
|
CLANG=${FINCH_CLANG:-clang}
|
||||||
LIBS=${FINCH_LIBCLANG:--lclang}
|
LIBS=${FINCH_LIBCLANG:--lclang}
|
||||||
INC=
|
INC=
|
||||||
[ -z "${FINCH_LLVM_INCLUDE:-}" ] || INC="-I $FINCH_LLVM_INCLUDE" # where clang-c/Index.h is, if clang does not find it itself
|
# where clang-c/Index.h is, if clang does not find it itself (Debian and Ubuntu keep it in /usr/lib/llvm-N/include)
|
||||||
|
if [ -z "${FINCH_LLVM_INCLUDE:-}" ] && command -v llvm-config > /dev/null 2>&1 \
|
||||||
|
&& [ -f "$(llvm-config --includedir)/clang-c/Index.h" ]; then
|
||||||
|
FINCH_LLVM_INCLUDE=$(llvm-config --includedir)
|
||||||
|
fi
|
||||||
|
[ -z "${FINCH_LLVM_INCLUDE:-}" ] || INC="-I $FINCH_LLVM_INCLUDE"
|
||||||
export FINCH_RT=$PWD/runtime/finch_rt.c
|
export FINCH_RT=$PWD/runtime/finch_rt.c
|
||||||
|
# the -L folders of FINCH_LIBCLANG are where the compiler's own link "clang" is found too
|
||||||
|
if [ -z "${FINCH_LDFLAGS:-}" ]; then
|
||||||
|
for w in $LIBS; do
|
||||||
|
case $w in -L*) FINCH_LDFLAGS="${FINCH_LDFLAGS:-} $w" ;; esac
|
||||||
|
done
|
||||||
|
[ -z "${FINCH_LDFLAGS:-}" ] || export FINCH_LDFLAGS
|
||||||
|
fi
|
||||||
# Windows: libclang.dll has to sit next to the programs that use it (FINCH_LIBCLANG is then the path of that dll)
|
# Windows: libclang.dll has to sit next to the programs that use it (FINCH_LIBCLANG is then the path of that dll)
|
||||||
if [ -n "$EXE" ]; then cp "$LIBS" build/; fi
|
if [ -n "$EXE" ]; then cp "$LIBS" build/; fi
|
||||||
|
|
||||||
|
|
|
||||||
13
src/lsp.fch
13
src/lsp.fch
|
|
@ -126,13 +126,22 @@ fn uriToPath(str uri) -> str {
|
||||||
i += 1
|
i += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return str(out)
|
p := str(out)
|
||||||
|
if p.len > 2 && p[0] == '/' && p[2] == ':' {
|
||||||
|
p = p.sub(1, p.len) // Windows: file:///C:/x -> C:/x
|
||||||
|
}
|
||||||
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pathToUri(str path) -> str {
|
fn pathToUri(str path) -> str {
|
||||||
digits := "0123456789ABCDEF"
|
digits := "0123456789ABCDEF"
|
||||||
[]str parts = ["file://"]
|
[]str parts = ["file://"]
|
||||||
for c in path {
|
p := path.replace("\\", "/")
|
||||||
|
if p.len > 1 && p[1] == ':' {
|
||||||
|
parts.push("/" + p.sub(0, 2)) // Windows: C:/x -> file:///C:/x
|
||||||
|
p = p.sub(2, p.len)
|
||||||
|
}
|
||||||
|
for c in p {
|
||||||
n := int(c)
|
n := int(c)
|
||||||
if (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || "/-_.~".contains(str(c)) {
|
if (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || "/-_.~".contains(str(c)) {
|
||||||
parts.push(str(c))
|
parts.push(str(c))
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@ init = c.request("initialize", {"processId": None, "rootUri": None, "capabilitie
|
||||||
check("initialize", init["capabilities"]["hoverProvider"] is True)
|
check("initialize", init["capabilities"]["hoverProvider"] is True)
|
||||||
c.notify("initialized", {})
|
c.notify("initialized", {})
|
||||||
c.notify("textDocument/didOpen", {"textDocument": {"uri": uri, "languageId": "finch", "version": 1, "text": src}})
|
c.notify("textDocument/didOpen", {"textDocument": {"uri": uri, "languageId": "finch", "version": 1, "text": src}})
|
||||||
check("no errors in a good file", c.diagnostics(uri) == [])
|
first = c.diagnostics(uri)
|
||||||
|
check("no errors in a good file", first == [], first)
|
||||||
|
|
||||||
h = c.request("textDocument/hover", {"textDocument": td, "position": pos(12, "total")})
|
h = c.request("textDocument/hover", {"textDocument": td, "position": pos(12, "total")})
|
||||||
check("hover: variable type", h and "int total" in h["contents"]["value"], h)
|
check("hover: variable type", h and "int total" in h["contents"]["value"], h)
|
||||||
|
|
|
||||||
10
tests/run.sh
10
tests/run.sh
|
|
@ -79,7 +79,7 @@ for f in new/enums.fch new/generics.fch new/std_json.fch run/basics.fch run/meth
|
||||||
run/defer.fch run/c_structs.fch run/memory.fch; do
|
run/defer.fch run/c_structs.fch run/memory.fch; do
|
||||||
input="${f%.fch}.in"
|
input="${f%.fch}.in"
|
||||||
[ -f "$input" ] || input=/dev/null
|
[ -f "$input" ] || input=/dev/null
|
||||||
if "$FINCH" build "$f" -g -O0 -o "$tmp/progg" > "$tmp/err" 2>&1 && [ "$("$tmp/progg" < "$input" 2>&1)" == "$(cat "${f%.fch}.out")" ]; then
|
if "$FINCH" build "$f" -g -O0 -o "$tmp/progg" > "$tmp/err" 2>&1 && [ "$("$tmp/progg" < "$input" 2>&1 | tr -d '\r')" == "$(tr -d '\r' < "${f%.fch}.out")" ]; then
|
||||||
pass=$((pass + 1))
|
pass=$((pass + 1))
|
||||||
else
|
else
|
||||||
failed=$((failed + 1))
|
failed=$((failed + 1))
|
||||||
|
|
@ -88,8 +88,12 @@ for f in new/enums.fch new/generics.fch new/std_json.fch run/basics.fch run/meth
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# a library a C program loads (finch build --shared)
|
# a library a C program loads (finch build --shared); the test's host uses dlopen and -rdynamic, so not on Windows
|
||||||
if FINCH="$FINCH" ./shared.sh > "$tmp/shared.out" 2>&1; then
|
# (there a DLL can't call functions of the program that loads it without an import library)
|
||||||
|
case "$(uname -s)" in MINGW*|MSYS*|CYGWIN*) skip_shared=1 ;; *) skip_shared=0 ;; esac
|
||||||
|
if [ $skip_shared = 1 ]; then
|
||||||
|
:
|
||||||
|
elif FINCH="$FINCH" ./shared.sh > "$tmp/shared.out" 2>&1; then
|
||||||
pass=$((pass + 1))
|
pass=$((pass + 1))
|
||||||
else
|
else
|
||||||
failed=$((failed + 1))
|
failed=$((failed + 1))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue