summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-09-22 13:29:45 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-09-22 13:29:45 +0200
commit5298a72f34ad2eb3774d6d70bd3176773cc0651f (patch)
tree142185f084e29e0b323416acf5804dba80312252
parentae7fe5087f3e4f6ddc572254ae3ddcc8324099f1 (diff)
downloadNim-5298a72f34ad2eb3774d6d70bd3176773cc0651f.tar.gz
NimScript: added buildOS and buildCPU constants
-rw-r--r--compiler/ast.nim2
-rw-r--r--compiler/semfold.nim2
-rw-r--r--lib/system/nimscript.nim9
3 files changed, 12 insertions, 1 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 92abbb0ab..e7af66c7a 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -631,7 +631,7 @@ type
     mPointer, mEmptySet, mIntSetBaseType, mNil, mExpr, mStmt, mTypeDesc,
     mVoidType, mPNimrodNode, mShared, mGuarded, mLock, mSpawn, mDeepCopy,
     mIsMainModule, mCompileDate, mCompileTime, mProcCall,
-    mCpuEndian, mHostOS, mHostCPU, mAppType,
+    mCpuEndian, mHostOS, mHostCPU, mBuildOS, mBuildCPU, mAppType,
     mNaN, mInf, mNegInf,
     mCompileOption, mCompileOptionArg,
     mNLen, mNChild, mNSetChild, mNAdd, mNAddMultiple, mNDel, mNKind,
diff --git a/compiler/semfold.nim b/compiler/semfold.nim
index 84cb0071f..9733564e7 100644
--- a/compiler/semfold.nim
+++ b/compiler/semfold.nim
@@ -616,6 +616,8 @@ proc getConstExpr(m: PSym, n: PNode): PNode =
       of mCpuEndian: result = newIntNodeT(ord(CPU[targetCPU].endian), n)
       of mHostOS: result = newStrNodeT(toLowerAscii(platform.OS[targetOS].name), n)
       of mHostCPU: result = newStrNodeT(platform.CPU[targetCPU].name.toLowerAscii, n)
+      of mBuildOS: result = newStrNodeT(toLowerAscii(platform.OS[platform.hostOS].name), n)
+      of mBuildCPU: result = newStrNodeT(platform.CPU[platform.hostCPU].name.toLowerAscii, n)
       of mAppType: result = getAppType(n)
       of mNaN: result = newFloatNodeT(NaN, n)
       of mInf: result = newFloatNodeT(Inf, n)
diff --git a/lib/system/nimscript.nim b/lib/system/nimscript.nim
index 73bb91fef..f5b9cf3ed 100644
--- a/lib/system/nimscript.nim
+++ b/lib/system/nimscript.nim
@@ -11,6 +11,15 @@
 # Nim's configuration system now uses Nim for scripting. This module provides
 # a few things that are required for this to work.
 
+const
+  buildOS* {.magic: "BuildOS".}: string = ""
+    ## The OS this build is running on. Can be different from ``system.hostOS``
+    ## for cross compilations.
+
+  buildCPU* {.magic: "BuildCPU".}: string = ""
+    ## The CPU this build is running on. Can be different from ``system.hostCPU``
+    ## for cross compilations.
+
 template builtin = discard
 
 # We know the effects better than the compiler: