Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
mantielero committed Dec 20, 2023
1 parent bffbc8b commit c78372a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 51 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-zig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
fileName: "FMUChecker-2.0.4-win64.zip"
extract: true

# chmod +x /home/runner/work/fmu.nim/fmu.nim/FMUChecker-2.0.4-win64/fmuCheck.win64
- name: Make FMUChecker executable in Linux
run: chmod +x /home/runner/work/fmu.nim/fmu.nim/FMUChecker-2.0.4-linux64/fmuCheck.linux64
if: runner.os == 'Linux'
Expand Down
67 changes: 17 additions & 50 deletions src/lib/fmu/fmubuilder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -34,58 +34,25 @@ template exportFmu*( fmu:Fmu;
doAssert execCmdEx( cmdline ).exitCode == QuitSuccess

else: # -d:zig
if defined(linux):
var libFolder = joinPath(tmpFolder, "binaries/linux64", fmu.id & ".so")

var cmdline = "nim c --app:lib "
var zig = """ --os:linux --cc:clang --cpu:amd64 --os:linux --clang.exe="zigcc" --clang.linkerexe="zigcc" """
zig &= """ --passC:"-target x86_64-linux-gnu -fno-sanitize=undefined" """
zig &= """ --passL:"-target x86_64-linux-gnu -fno-sanitize=undefined" """
cmdline &= zig
cmdline &= "-o:" & libFolder & " --mm:orc -f -d:release " & fmu.nimFile

consoleLogger.log(lvlInfo, "fmuBuilder > exportFmu: exporting library using command line:\n" & " " & cmdline)

doAssert execCmdEx( cmdline ).exitCode == QuitSuccess


libFolder = joinPath(tmpFolder, "binaries/win64", fmu.id & ".dll")
cmdline = "nim c --app:lib "
zig = """ --os:windows --cc:clang --cpu:amd64 --os:windows --clang.exe="zigcc" --clang.linkerexe="zigcc" """
zig &= """ --passC:"-target x86_64-windows -fno-sanitize=undefined" """
zig &= """ --passL:"-target x86_64-windows -fno-sanitize=undefined" """
cmdline &= zig
cmdline &= "-o:" & libFolder & " --mm:orc -f -d:release " & fmu.nimFile

consoleLogger.log(lvlInfo, "fmuBuilder > exportFmu: exporting library using command line:\n" & " " & cmdline)
doAssert execCmdEx( cmdline ).exitCode == QuitSuccess

var cmdline = "nim c --app:lib "

elif defined(windows):
var libFolder = joinPath(tmpFolder, "binaries/linux64", fmu.id & ".so")

var cmdline = "nim c --app:lib "
var zig = """ --cc:clang --clang.exe="zigcc.cmd" --clang.linkerexe="zigcc.cmd" """
zig &= """ --passC:"-target x86_64-linux-gnu" """
zig &= """ --passL:"-target x86_64-linux-gnu" """
cmdline &= zig
cmdline &= "--os:linux -o:" & libFolder & " --mm:orc -f -d:release " & fmu.nimFile

consoleLogger.log(lvlInfo, "fmuBuilder > exportFmu: exporting library using command line:\n" & " " & cmdline)

doAssert execCmdEx( cmdline ).exitCode == QuitSuccess


libFolder = joinPath(tmpFolder, "binaries/win64", fmu.id & ".dll")
cmdline = "nim c --app:lib "
zig = """ --cc:clang --clang.exe="zigcc.cmd" --clang.linkerexe="zigcc.cmd" """
zig &= """ --passC:"-target x86_64-windows" """
zig &= """ --passL:"-target x86_64-windows" """
cmdline &= zig
cmdline &= "--os:windows -o:" & libFolder & " --mm:orc -f -d:release " & fmu.nimFile

consoleLogger.log(lvlInfo, "fmuBuilder > exportFmu: exporting library using command line:\n" & " " & cmdline)
doAssert execCmdEx( cmdline ).exitCode == QuitSuccess
var zigPath = "zigcc"
if defined(windows):
zigPath &= ".cmd"
#var osvalue, relpath, ext, target: string
for (osvalue, relpath, ext, target) in @[("linux", "binaries/linux64", ".so", "x86_64-linux-gnu"), ("windows", "binaries/win64", ".dll", "x86_64-windows")]:
var execLine = cmdline
execLine &= " --os:" & osvalue & " --cc:clang --cpu:amd64 --os:" & osvalue
execLine &= " --clang.exe=\"" & zigPath & "\" --clang.linkerexe=\"" & zigPath & "\" "
execLine &= " --passC:\"-target " & target & " -fno-sanitize=undefined\" "
execLine &= " --passL:\"-target " & target & " -fno-sanitize=undefined\" "
var libFolder = joinPath(tmpFolder, relpath, fmu.id & ext)
execLine &= "-o:" & libFolder & " --mm:orc -f -d:release " & fmu.nimFile

consoleLogger.log(lvlInfo, "fmuBuilder > exportFmu: exporting library using command line:\n" & " " & execLine)

doAssert execCmdEx( execLine ).exitCode == QuitSuccess


#zig &= """ --passC:"-target x86_64-linux-musl -fno-sanitize=undefined" """
Expand Down

0 comments on commit c78372a

Please sign in to comment.