@@ -33,26 +33,53 @@ if (!libclangPath) {
3333
3434let libclang : ReturnType < typeof Deno . dlopen < typeof IMPORTS > > ;
3535
36- if ( libclangPath . includes ( ".so" ) || libclangPath . endsWith ( ".dll" ) ) {
37- // Explicit path, try without catching
38- libclang = Deno . dlopen ( libclangPath , IMPORTS ) ;
39- } else if ( Deno . build . os === "windows" ) {
36+ if ( Deno . build . os === "windows" ) {
37+ if ( libclangPath . includes ( ".dll" ) ) {
38+ try {
39+ libclang = Deno . dlopen ( libclangPath , IMPORTS ) ;
40+ } catch {
41+ // Ignore
42+ }
43+ }
4044 libclang = Deno . dlopen (
4145 join ( libclangPath , "libclang.dll" ) ,
4246 IMPORTS ,
4347 ) ;
48+ } else if ( Deno . build . os === "darwin" ) {
49+ if ( libclangPath . includes ( ".dylib" ) ) {
50+ try {
51+ libclang = Deno . dlopen ( libclangPath , IMPORTS ) ;
52+ } catch {
53+ // Ignore
54+ }
55+ }
56+ libclang = Deno . dlopen (
57+ join ( libclangPath , "libclang.dylib" ) ,
58+ IMPORTS ,
59+ ) ;
4460} else {
45- // Try 14.0.6 first, then 14, then 13
61+ if ( libclangPath . includes ( ".so" ) ) {
62+ try {
63+ libclang = Deno . dlopen ( libclangPath , IMPORTS ) ;
64+ } catch {
65+ // Ignore
66+ }
67+ }
68+ // Try plain libclang first, then 14.0.6, then 14, and finally try 13.
4669 try {
47- libclang = Deno . dlopen (
48- join ( libclangPath , "libclang.so.14.0.6" ) ,
49- IMPORTS ,
50- ) ;
70+ libclang = Deno . dlopen ( join ( libclangPath , "libclang.so" ) , IMPORTS ) ;
5171 } catch {
5272 try {
53- libclang = Deno . dlopen ( join ( libclangPath , "libclang.so.14" ) , IMPORTS ) ;
73+ libclang = Deno . dlopen (
74+ join ( libclangPath , "libclang.so.14.0.6" ) ,
75+ IMPORTS ,
76+ ) ;
5477 } catch {
55- libclang = Deno . dlopen ( join ( libclangPath , "libclang.so.13" ) , IMPORTS ) ;
78+ try {
79+ libclang = Deno . dlopen ( join ( libclangPath , "libclang.so.14" ) , IMPORTS ) ;
80+ } catch {
81+ libclang = Deno . dlopen ( join ( libclangPath , "libclang.so.13" ) , IMPORTS ) ;
82+ }
5683 }
5784 }
5885}
0 commit comments