summary refs log tree commit diff stats
path: root/compiler/cgen.nim
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-10-22 23:03:09 -0700
committerGitHub <noreply@github.com>2020-10-23 08:03:09 +0200
commit275354709d2a5e38b9e06b2cee823ddef756d62d (patch)
treef089198d79916b84f3f5eb60089c59db0c0b8c2d /compiler/cgen.nim
parent01a62320f03ebd3282a7def231351c4f84c319d2 (diff)
downloadNim-275354709d2a5e38b9e06b2cee823ddef756d62d.tar.gz
make cgen header consistent with jsgen header (#15682)
Diffstat (limited to 'compiler/cgen.nim')
-rw-r--r--compiler/cgen.nim25
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)