tapp_lib_staticlib.nim 906 B

12345678910111213141516171819202122232425262728
  1. discard """
  2. joinable: false
  3. """
  4. # bug #16949
  5. when defined case1:
  6. proc foo(): int {.exportc.} = 10
  7. elif defined case2:
  8. proc foo(): int {.exportc, dynlib.} = 10
  9. elif defined caseMain:
  10. proc foo(): int {.importc.}
  11. doAssert foo() == 10
  12. else:
  13. import stdtest/specialpaths
  14. import std/[os, strformat, strutils, compilesettings]
  15. proc runCmd(cmd: string) =
  16. doAssert execShellCmd(cmd) == 0, $cmd
  17. const
  18. file = currentSourcePath
  19. nim = getCurrentCompilerExe()
  20. mode = querySetting(backend)
  21. proc test(lib, options: string) =
  22. runCmd fmt"{nim} {mode} -o:{lib} --nomain {options} -f {file}"
  23. # runCmd fmt"{nim} r -b:{mode} --passl:{lib} -d:caseMain -f {file}" # pending https://github.com/nim-lang/Nim/pull/16945
  24. test(buildDir / "libD20210205T172314.a", "--app:staticlib -d:nimLinkerWeakSymbols -d:case1")
  25. test(buildDir / DynlibFormat % "D20210205T172720", "--app:lib -d:case2")