make cgen header consistent with jsgen header (#15682)
This commit is contained in:
parent
01a62320f0
commit
275354709d
1 changed files with 9 additions and 16 deletions
|
|
@ -1280,18 +1280,15 @@ proc addNimDefines(result: var Rope; conf: ConfigRef) {.inline.} =
|
||||||
if conf.isDefined("nimEmulateOverflowChecks"):
|
if conf.isDefined("nimEmulateOverflowChecks"):
|
||||||
result.add("#define NIM_EmulateOverflowChecks\L")
|
result.add("#define NIM_EmulateOverflowChecks\L")
|
||||||
|
|
||||||
|
proc headerTop(): Rope =
|
||||||
|
result = "/* Generated by Nim Compiler v$1 */$N" % [rope(VersionAsString)]
|
||||||
|
|
||||||
proc getCopyright(conf: ConfigRef; cfile: Cfile): Rope =
|
proc getCopyright(conf: ConfigRef; cfile: Cfile): Rope =
|
||||||
if optCompileOnly in conf.globalOptions:
|
result = headerTop()
|
||||||
result = ("/* Generated by Nim Compiler v$1 */$N" &
|
if optCompileOnly notin conf.globalOptions:
|
||||||
"/* The generated code is subject to the original license. */$N") %
|
result.add ("/* Compiled for: $1, $2, $3 */$N" &
|
||||||
[rope(VersionAsString)]
|
"/* Command for C compiler:$n $4 */$N") %
|
||||||
else:
|
[rope(platform.OS[conf.target.targetOS].name),
|
||||||
result = ("/* Generated by Nim Compiler v$1 */$N" &
|
|
||||||
"/* The generated code is subject to the original license. */$N" &
|
|
||||||
"/* Compiled for: $2, $3, $4 */$N" &
|
|
||||||
"/* Command for C compiler:$n $5 */$N") %
|
|
||||||
[rope(VersionAsString),
|
|
||||||
rope(platform.OS[conf.target.targetOS].name),
|
|
||||||
rope(platform.CPU[conf.target.targetCPU].name),
|
rope(platform.CPU[conf.target.targetCPU].name),
|
||||||
rope(extccomp.CC[conf.cCompiler].name),
|
rope(extccomp.CC[conf.cCompiler].name),
|
||||||
rope(getCompileCFileCmd(conf, cfile))]
|
rope(getCompileCFileCmd(conf, cfile))]
|
||||||
|
|
@ -1858,11 +1855,7 @@ proc myOpen(graph: ModuleGraph; module: PSym): PPassContext {.nosinks.} =
|
||||||
incl g.generatedHeader.flags, isHeaderFile
|
incl g.generatedHeader.flags, isHeaderFile
|
||||||
|
|
||||||
proc writeHeader(m: BModule) =
|
proc writeHeader(m: BModule) =
|
||||||
# could factor with 2 other instances
|
var result = headerTop()
|
||||||
var result = ("/* Generated by Nim Compiler v$1 */$N" &
|
|
||||||
"/* The generated code is subject to the original license. */$N") %
|
|
||||||
[rope(VersionAsString)]
|
|
||||||
|
|
||||||
var guard = "__$1__" % [m.filename.splitFile.name.rope]
|
var guard = "__$1__" % [m.filename.splitFile.name.rope]
|
||||||
result.addf("#ifndef $1$n#define $1$n", [guard])
|
result.addf("#ifndef $1$n#define $1$n", [guard])
|
||||||
addNimDefines(result, m.config)
|
addNimDefines(result, m.config)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue