Skip to content

Commit

Permalink
use getPrefixDir instead
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Jan 14, 2020
1 parent 617819d commit cff1264
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 21 deletions.
2 changes: 1 addition & 1 deletion compiler/docgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ proc writeOutput*(d: PDoc, useWarning = false) =
outfile.string)
else:
if not d.wroteCss:
let cssSource = getNimRoot(d.conf).string / "doc" / "nimdoc.css"
let cssSource = $d.conf.getPrefixDir() / "doc" / "nimdoc.css"
let cssDest = $d.conf.outDir / "nimdoc.out.css"
# renamed to make it easier to use with gitignore in user's repos
copyFile(cssSource, cssDest)
Expand Down
4 changes: 2 additions & 2 deletions compiler/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,11 @@ proc mainCommand*(graph: ModuleGraph) =
let key = lineinfos.WarningsToStr[ord(a) - ord(warnMin)]
warnings[key] = %(a in conf.notes)

let nimroot = getNimRoot(conf)
let prefixDir = conf.getPrefixDir()

var dumpdata = %[
(key: "version", val: %VersionAsString),
(key: "nimroot", val: %nimroot.string),
(key: "prefixdir", val: %prefixDir.string),
(key: "project_path", val: %conf.projectFull.string),
(key: "defined_symbols", val: definedSymbols),
(key: "lib_paths", val: %libpaths),
Expand Down
17 changes: 0 additions & 17 deletions compiler/nimconf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,6 @@ proc getSystemConfigPath*(conf: ConfigRef; filename: RelativeFile): AbsoluteFile
if not fileExists(result): result = p / RelativeDir"etc/nim" / filename
if not fileExists(result): result = AbsoluteDir"/etc/nim" / filename

const nimRepoDirCT = currentSourcePath / ".." / ".." # this should be exposed somewhere

proc getNimRoot*(conf: ConfigRef): AbsoluteDir =
## returns root nim dir; works both with installed nim and local nim git repo.
## The result should satisfy: $result/doc/basicopt.txt exists as sanity check
if conf.nimRootDir.isEmpty:
if dirExists(nimRepoDirCT / ".git"):
result = nimRepoDirCT.AbsoluteDir
else:
result = AbsoluteDir getSystemConfigPath(conf, "".RelativeFile).`$`
# sanity check to make sure we have the right directory
let file = $result / "doc" / "basicopt.txt"
doAssert fileExists(file), $file
conf.nimRootDir = result
else:
result = conf.nimRootDir

proc loadConfigs*(cfg: RelativeFile; cache: IdentCache; conf: ConfigRef) =
setDefaultLibpath(conf)

Expand Down
4 changes: 3 additions & 1 deletion compiler/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ type
outFile*: RelativeFile
outDir*: AbsoluteDir
prefixDir*, libpath*, nimcacheDir*: AbsoluteDir
nimRootDir*: AbsoluteDir ## works both for install dir and local git nim repo
dllOverrides, moduleOverrides*, cfileSpecificOptions*: StringTableRef
projectName*: string # holds a name like 'nim'
projectPath*: AbsoluteDir # holds a path like /home/alice/projects/nim/compiler/
Expand Down Expand Up @@ -512,6 +511,9 @@ proc getPrefixDir*(conf: ConfigRef): AbsoluteDir =
##
## This is overridden by some tools (namely nimsuggest) via the ``conf.prefixDir``
## field.
## This should resolve to root of nim sources, whether running nim from a local
## clone or using installed nim, so that these exist: `result/doc/advopt.txt`
## and `result/lib/system.nim`
if not conf.prefixDir.isEmpty: result = conf.prefixDir
else: result = AbsoluteDir splitPath(getAppDir()).head

Expand Down

0 comments on commit cff1264

Please sign in to comment.