mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-21 16:31:39 +00:00
adds nimbasePattern compiler option (#22144)
adds optonal --nimbasepattern
This commit is contained in:
@@ -935,7 +935,9 @@ proc cgsymValue(m: BModule, name: string): Rope =
|
||||
result.addActualSuffixForHCR(m.module, sym)
|
||||
|
||||
proc generateHeaders(m: BModule) =
|
||||
m.s[cfsHeaders].add("\L#include \"nimbase.h\"\L")
|
||||
var nimbase = m.config.nimbasePattern
|
||||
if nimbase == "": nimbase = "nimbase.h"
|
||||
m.s[cfsHeaders].addf("\L#include \"$1\"\L", [nimbase])
|
||||
|
||||
for it in m.headerFiles:
|
||||
if it[0] == '#':
|
||||
|
||||
@@ -829,6 +829,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||
of "header":
|
||||
if conf != nil: conf.headerFile = arg
|
||||
incl(conf.globalOptions, optGenIndex)
|
||||
of "nimbasepattern":
|
||||
if conf != nil: conf.nimbasePattern = arg
|
||||
of "index":
|
||||
case arg.normalize
|
||||
of "", "on": conf.globalOptions.incl {optGenIndex}
|
||||
|
||||
@@ -333,6 +333,7 @@ type
|
||||
|
||||
cppDefines*: HashSet[string] # (*)
|
||||
headerFile*: string
|
||||
nimbasePattern*: string # pattern to find nimbase.h
|
||||
features*: set[Feature]
|
||||
legacyFeatures*: set[LegacyFeature]
|
||||
arguments*: string ## the arguments to be passed to the program that
|
||||
|
||||
26
tests/options/tnimbasepattern.nim
Normal file
26
tests/options/tnimbasepattern.nim
Normal file
@@ -0,0 +1,26 @@
|
||||
discard """
|
||||
cmd: "nim cpp --nimbasepattern:test.h --cincludes:./tests/options $file "
|
||||
output:'''
|
||||
(a: 1)
|
||||
'''
|
||||
"""
|
||||
const header = """
|
||||
#pragma once
|
||||
#include "nimbase.h"
|
||||
struct Foo {
|
||||
int a;
|
||||
};
|
||||
"""
|
||||
|
||||
import os
|
||||
static:
|
||||
const dir = "./tests/options/"
|
||||
createDir(dir)
|
||||
writeFile(dir / "test.h", header)
|
||||
|
||||
type
|
||||
Foo {.importc.} = object
|
||||
a: int32 = 1
|
||||
|
||||
|
||||
echo $Foo()
|
||||
Reference in New Issue
Block a user