Skip to content

Commit

Permalink
Implemented hacky way of copying wasmtime.dll to output dir on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Jul 19, 2024
1 parent 3d46fa0 commit dbd03c9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ switch("d", "treesitterFeatureWasm")
# Static linking doesn't work on windows for some reason, so dynamically link
when defined(windows):
switch("d", "nimWasmtimeStatic=false")

# todo: This doesn't work for GUI, crashes with nil access
# switch("d", "nimWasmtimeStatic=true")
# switch("passC", "-static")
# switch("passL", "-lucrt -lws2_32 -lntdll -luserenv -lole32 -lbcrypt")
else:
switch("d", "nimWasmtimeStatic=true")

Expand Down
12 changes: 11 additions & 1 deletion src/absytree.nim
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,14 @@ waitFor runApp()

when enableGui:
if backend.get == Gui:
myDisableTrueColors()
myDisableTrueColors()

when defined(windows):
import std/[os, compilesettings]
import wasmh

static:
const dllIn = wasmDir / "target/release/wasmtime.dll"
const dllOut = querySetting(SingleValueSetting.outDir) / "wasmtime.dll"
echo "[absytree.nim] run tools/copy_wasmtime_dll.nims"
echo staticExec &"nim \"-d:inDir={dllIn}\" \"-d:outDir={dllOut}\" --hints:off --skipUserCfg --skipProjCfg --skipParentCfg ../tools/copy_wasmtime_dll.nims"
5 changes: 5 additions & 0 deletions tools/copy_wasmtime_dll.nims
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const inDir {.strdefine.} = ""
const outDir {.strdefine.} = ""

echo "[copy_wasmtime_dll.nims] Copy dll from '", inDir, "' to '", outDir, "'"
cpFile inDir, outDir

0 comments on commit dbd03c9

Please sign in to comment.