|
1 | | -import options, pathutils, platform, condsyms |
| 1 | +import options, pathutils, platform, condsyms, extccomp |
2 | 2 | import std/[assertions, os, sets, strtabs, times] |
3 | 3 | from std/strutils import parseEnum |
4 | 4 | import "../dist/nimony/src/lib" / [bitabs, lineinfos, nifreader, nifstreams, nifcursors] |
@@ -241,6 +241,15 @@ proc configToNif(conf: ConfigRef; dest: var TokenBuf) = |
241 | 241 | dest.toNif "externalToLink", conf.externalToLink |
242 | 242 | dest.addStrLit conf.linkOptionsCmd |
243 | 243 | dest.toNif "compileOptionsCmd", conf.compileOptionsCmd |
| 244 | + dest.addStrLit conf.compileOptions |
| 245 | + dest.addStrLit conf.cCompilerPath |
| 246 | + |
| 247 | + dest.buildTree "toCompile": |
| 248 | + for c in conf.toCompile: |
| 249 | + dest.addStrLit c.cname.string |
| 250 | + |
| 251 | + dest.addStrLit conf.cppCustomNamespace |
| 252 | + dest.addStrLit conf.nimMainPrefix |
244 | 253 |
|
245 | 254 | proc cfgCachePath(conf: ConfigRef): (AbsoluteDir, RelativeFile) = |
246 | 255 | (conf.projectPath / RelativeDir"nimcache", RelativeFile"cache.cfg.nif") |
@@ -397,6 +406,23 @@ proc loadConfigsFromNif(conf: ConfigRef; n: var Cursor) = |
397 | 406 | inc n |
398 | 407 |
|
399 | 408 | fromNif conf.compileOptionsCmd, "compileOptionsCmd", n |
| 409 | + conf.compileOptions = pool.strings[n.litId] |
| 410 | + inc n |
| 411 | + conf.cCompilerPath = pool.strings[n.litId] |
| 412 | + inc n |
| 413 | + |
| 414 | + expectTag n, "toCompile" |
| 415 | + inc n |
| 416 | + while n.kind != ParRi: |
| 417 | + let c = pool.strings[n.litId] |
| 418 | + inc n |
| 419 | + conf.addExternalFileToCompile(AbsoluteFile(c)) |
| 420 | + inc n |
| 421 | + |
| 422 | + conf.cppCustomNamespace = pool.strings[n.litId] |
| 423 | + inc n |
| 424 | + conf.nimMainPrefix = pool.strings[n.litId] |
| 425 | + inc n |
400 | 426 |
|
401 | 427 | proc sourceChanged*(conf: ConfigRef): HashSet[string] = |
402 | 428 | result = HashSet[string]() |
@@ -509,6 +535,10 @@ when isMainModule: |
509 | 535 | assertImpl externalToLink |
510 | 536 | assertImpl linkOptionsCmd |
511 | 537 | assertImpl compileOptionsCmd |
| 538 | + assertImpl compileOptions |
| 539 | + assertImpl cCompilerPath |
| 540 | + assertImpl cppCustomNamespace |
| 541 | + assertImpl nimMainPrefix |
512 | 542 |
|
513 | 543 | proc testConfig(conf1: ConfigRef) = |
514 | 544 | var dest = createTokenBuf() |
@@ -595,4 +625,8 @@ when isMainModule: |
595 | 625 | conf.externalToLink = @["foo", "bar"] |
596 | 626 | conf.linkOptionsCmd = "--foo -lbar" |
597 | 627 | conf.compileOptionsCmd = @["-O3", "-g"] |
| 628 | + conf.compileOptions = "-foo --bar" |
| 629 | + conf.cCompilerPath = "/foo/bar" |
| 630 | + conf.cppCustomNamespace = "foobar" |
| 631 | + conf.nimMainPrefix = "prefix" |
598 | 632 | testConfig conf |
0 commit comments