Skip to content

Commit

Permalink
fix appType staticLib vs staticlib
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Dec 1, 2023
1 parent 6c5479b commit 2e492c2
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions constantine/zoo_exports.nim
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@ var prefix_sha256* {.compileTime.} = "ctt_sha256_"

import std/macros

# macro libPrefix*(prefix: static string, procAst: untyped): untyped =
# if prefix == "":
# return procAst
# else:
# var pragmas = procAst.pragma
# if pragmas.kind == nnkEmpty:
# pragmas = nnkPragma.newTree()

# pragmas.add ident"noconv"
# pragmas.add nnkExprColonExpr.newTree(
# ident"exportc",
# newLit(prefix & "$1"))
# pragmas.add nnkExprColonExpr.newTree(
# ident"raises",
# nnkBracket.newTree())

# if appType == "lib":
# pragmas.add ident"dynlib"

# result = procAst
# result.pragma = pragmas

macro libPrefix*(prefix: static string, procAst: untyped): untyped =
var pragmas = procAst.pragma
if pragmas.kind == nnkEmpty:
Expand All @@ -41,7 +63,7 @@ macro libPrefix*(prefix: static string, procAst: untyped): untyped =
ident"raises",
nnkBracket.newTree())

if appType != "lib" and appType != "staticLib":
if appType != "lib" and appType != "staticlib":
# extern only does name-mangling but allows for dead-code elimination.
pragmas.add nnkExprColonExpr.newTree(
ident"extern",
Expand All @@ -58,4 +80,4 @@ macro libPrefix*(prefix: static string, procAst: untyped): untyped =
pragmas.add ident"dynlib"

result = procAst
result.pragma = pragmas
result.pragma = pragmas

0 comments on commit 2e492c2

Please sign in to comment.