Skip to content

add srcDir variable to nim.cfg #24919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/nimconf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ proc readConfigFile*(filename: AbsoluteFile; cache: IdentCache;
stream = llStreamOpen(filename, fmRead)
if stream != nil:
openLexer(L, filename, stream, cache, config)
setConfigVar(config, "srcDir", parentDir(filename.string))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind the feature but this seems offplace. Shouldn't it be done somewhere else in the compiler?

Copy link
Contributor Author

@Graveflo Graveflo May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into it again and it seems the path is determined in loadConfigs which calls readConfigFile (current placement of the change) and then it's promptly handed off to the machinery of while tok.tokType != tkEof: parseAssignment ... where the config file is processed. I don't see where else this could go.

tok = Token(tokType: tkEof) # to avoid a pointless warning
var condStack: seq[bool] = @[]
confTok(L, tok, config, condStack) # read in the first token
Expand Down