1 /** 2 Copyright 2018 Mark Fisher 3 4 Permission is hereby granted, free of charge, to any person obtaining a copy of 5 this software and associated documentation files (the "Software"), to deal in 6 the Software without restriction, including without limitation the rights to 7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 of the Software, and to permit persons to whom the Software is furnished to do 9 so, subject to the following conditions: 10 11 The above copyright notice and this permission notice shall be included in all 12 copies or substantial portions of the Software. 13 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 SOFTWARE. 21 **/ 22 module dxx.sys.constants; 23 24 private import dxx.packageVersion; 25 26 private import std.compiler; 27 private import core.cpuid; 28 29 class Constants { 30 //enum { 31 // COMPILER_VERSION = std.compiler.name, 32 // PALTFORM = _PLATFORM, 33 // //CPU = core.cpuid.getCpuFeatures.vendorID 34 //} 35 enum compilerName = __VENDOR__; 36 enum compilerVersionMajor = version_major; 37 enum compilerVersionMinor = version_minor; 38 39 enum compileTimestamp = __TIMESTAMP__; 40 41 version(Posix) { enum hostOperatingSystem = "Posix"; } 42 else version(Windows) { enum hostOperatingSystem = "Windows"; } 43 else version(MacOS) { enum hostOperatingSystem = "MacOS"; } 44 else { enum hostOperatingSystem = "<unknown-OS>"; } 45 46 version(unittest) { enum unitTest = true; } 47 else { enum unitTest = false; } 48 49 debug { 50 enum buildType = "Debug"; 51 } else version(Release) { 52 enum buildType = "Release"; 53 } else { 54 enum buildType = "<unknown-buildtype>"; 55 } 56 }; 57 58 struct RTConstants { 59 const(string) compilerName = Constants.compilerName; 60 const(uint) compilerVersionMajor = Constants.compilerVersionMajor; 61 const(uint) compilerVersionMinor = Constants.compilerVersionMinor; 62 63 const(string) compileTimestamp = Constants.compileTimestamp; 64 65 const(string) hostOperatingSystem = Constants.hostOperatingSystem; 66 67 const(bool) unitTest = Constants.unitTest; 68 const(string) buildType = Constants.buildType; 69 70 const(string) libVersion = packageVersion; 71 const(string) libTimestamp = packageTimestamp; 72 const(string) libTimestampISO = packageTimestampISO; 73 74 static __gshared RTConstants runtimeConstants; 75 76 unittest { 77 assert(runtimeConstants.unitTest); 78 } 79 }; 80 81 82