From 027a11d7c85ffc990dc5b41f1c1e2b799e77ba36 Mon Sep 17 00:00:00 2001 From: Solitude Date: Thu, 11 Oct 2018 10:56:12 +0300 Subject: [PATCH] Add procs to retrieve project name, directory and full path to nimscript (#9274) --- compiler/scriptconfig.nim | 6 ++++++ lib/system/nimscript.nim | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/compiler/scriptconfig.nim b/compiler/scriptconfig.nim index b4d947288d..f94533177e 100644 --- a/compiler/scriptconfig.nim +++ b/compiler/scriptconfig.nim @@ -96,6 +96,12 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string; cbconf fileExists: setResult(a, os.fileExists(a.getString 0)) + cbconf projectName: + setResult(a, conf.projectName) + cbconf projectDir: + setResult(a, conf.projectPath.string) + cbconf projectPath: + setResult(a, conf.projectFull.string) cbconf thisDir: setResult(a, vthisDir) cbconf put: diff --git a/lib/system/nimscript.nim b/lib/system/nimscript.nim index 64d6255dab..c876d6d061 100644 --- a/lib/system/nimscript.nim +++ b/lib/system/nimscript.nim @@ -269,6 +269,18 @@ proc nimcacheDir*(): string = ## Retrieves the location of 'nimcache'. builtin +proc projectName*(): string = + ## Retrieves the name of the current project + builtin + +proc projectDir*(): string = + ## Retrieves the absolute directory of the current project + builtin + +proc projectPath*(): string = + ## Retrieves the absolute path of the current project + builtin + proc thisDir*(): string = ## Retrieves the location of the current ``nims`` script file. builtin