diff options
Diffstat (limited to 'compiler/cgen.nim')
-rw-r--r-- | compiler/cgen.nim | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index afb36e787..5c60a3cf3 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1280,18 +1280,15 @@ proc addNimDefines(result: var Rope; conf: ConfigRef) {.inline.} = if conf.isDefined("nimEmulateOverflowChecks"): 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 = - if optCompileOnly in conf.globalOptions: - result = ("/* Generated by Nim Compiler v$1 */$N" & - "/* The generated code is subject to the original license. */$N") % - [rope(VersionAsString)] - else: - 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), + result = headerTop() + if optCompileOnly notin conf.globalOptions: + result.add ("/* Compiled for: $1, $2, $3 */$N" & + "/* Command for C compiler:$n $4 */$N") % + [rope(platform.OS[conf.target.targetOS].name), rope(platform.CPU[conf.target.targetCPU].name), rope(extccomp.CC[conf.cCompiler].name), rope(getCompileCFileCmd(conf, cfile))] @@ -1858,11 +1855,7 @@ proc myOpen(graph: ModuleGraph; module: PSym): PPassContext {.nosinks.} = incl g.generatedHeader.flags, isHeaderFile proc writeHeader(m: BModule) = - # could factor with 2 other instances - var result = ("/* Generated by Nim Compiler v$1 */$N" & - "/* The generated code is subject to the original license. */$N") % - [rope(VersionAsString)] - + var result = headerTop() var guard = "__$1__" % [m.filename.splitFile.name.rope] result.addf("#ifndef $1$n#define $1$n", [guard]) addNimDefines(result, m.config) |