mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
This commit is contained in:
@@ -1490,9 +1490,9 @@ proc genMainProc(m: BModule) =
|
||||
|
||||
var posixCmdLine: Rope
|
||||
if optNoMain notin m.config.globalOptions:
|
||||
posixCmdLine.add "\tN_LIB_PRIVATE int cmdCount;\L"
|
||||
posixCmdLine.add "\tN_LIB_PRIVATE char** cmdLine;\L"
|
||||
posixCmdLine.add "\tN_LIB_PRIVATE char** gEnv;\L"
|
||||
posixCmdLine.add "N_LIB_PRIVATE int cmdCount;\L"
|
||||
posixCmdLine.add "N_LIB_PRIVATE char** cmdLine;\L"
|
||||
posixCmdLine.add "N_LIB_PRIVATE char** gEnv;\L"
|
||||
|
||||
const
|
||||
# The use of a volatile function pointer to call Pre/NimMainInner
|
||||
@@ -1517,7 +1517,7 @@ proc genMainProc(m: BModule) =
|
||||
"}$N$N"
|
||||
|
||||
MainProcs =
|
||||
"\t\t$^NimMain();$N"
|
||||
"\t$^NimMain();$N"
|
||||
|
||||
MainProcsWithResult =
|
||||
MainProcs & ("\treturn $1nim_program_result;$N")
|
||||
@@ -1633,7 +1633,7 @@ proc genMainProc(m: BModule) =
|
||||
appcg(m, m.s[cfsProcs], nimMain,
|
||||
[m.g.mainModInit, initStackBottomCall, m.labels, preMainCode, m.config.nimMainPrefix, isVolatile])
|
||||
|
||||
if optNoMain notin m.config.globalOptions:
|
||||
if optNoMain notin m.config.globalOptions or optGenDynLib in m.config.globalOptions:
|
||||
if m.config.cppCustomNamespace.len > 0:
|
||||
closeNamespaceNim(m.s[cfsProcs])
|
||||
m.s[cfsProcs].add "using namespace " & m.config.cppCustomNamespace & ";\L"
|
||||
@@ -1940,8 +1940,6 @@ proc genModule(m: BModule, cfile: Cfile): Rope =
|
||||
openNamespaceNim(m.config.cppCustomNamespace, result)
|
||||
if m.s[cfsFrameDefines].len > 0:
|
||||
result.add(m.s[cfsFrameDefines])
|
||||
else:
|
||||
result.add("#define nimfr_(x, y)\n#define nimln_(x)\n\n#define nimlf_(x, y)\n")
|
||||
|
||||
for i in cfsForwardTypes..cfsProcs:
|
||||
if m.s[i].len > 0:
|
||||
|
||||
@@ -799,11 +799,13 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||
defineSymbol(conf.symbols, "consoleapp")
|
||||
of "lib":
|
||||
incl(conf.globalOptions, optGenDynLib)
|
||||
incl(conf.globalOptions, optNoMain)
|
||||
excl(conf.globalOptions, optGenGuiApp)
|
||||
defineSymbol(conf.symbols, "library")
|
||||
defineSymbol(conf.symbols, "dll")
|
||||
of "staticlib":
|
||||
incl(conf.globalOptions, optGenStaticLib)
|
||||
incl(conf.globalOptions, optNoMain)
|
||||
excl(conf.globalOptions, optGenGuiApp)
|
||||
defineSymbol(conf.symbols, "library")
|
||||
defineSymbol(conf.symbols, "staticlib")
|
||||
|
||||
@@ -300,7 +300,7 @@ Instead of depending on the generation of the individual ``.c`` files you can
|
||||
also ask the Nim compiler to generate a statically linked library:
|
||||
|
||||
```cmd
|
||||
nim c --app:staticLib --noMain fib.nim
|
||||
nim c --app:staticLib fib.nim
|
||||
gcc -o m -Inimcache -Ipath/to/nim/lib maths.c libfib.nim.a
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user