Merge pull request #4949 from couven92/nim-vccwrap
VCC wrappers with vcvars args.
This commit is contained in:
commit
a612e1b249
3 changed files with 70 additions and 37 deletions
|
|
@ -177,10 +177,26 @@ clang.options.speed = "-O3"
|
||||||
clang.options.size = "-Os"
|
clang.options.size = "-Os"
|
||||||
|
|
||||||
# Configuration for the Visual C/C++ compiler:
|
# Configuration for the Visual C/C++ compiler:
|
||||||
vcc.options.linker = "/DEBUG /Zi /Fd\"$projectName.pdb\" /F33554432" # set the stack size to 8 MB
|
vcc.exe = "vccexe.exe"
|
||||||
vcc.options.debug = "/Zi /Fd\"$projectName.pdb\""
|
vcc.linkerexe = "vccexe.exe"
|
||||||
|
|
||||||
|
# set the options for specific platforms:
|
||||||
|
@if i386:
|
||||||
|
vcc.options.always = "--platform:x86 /nologo"
|
||||||
|
vcc.options.linker = "--platform:x86 /nologo /DEBUG /Zi /F33554432" # set the stack size to 8 MB
|
||||||
|
@elif amd64:
|
||||||
|
vcc.options.always = "--platform:amd64 /nologo"
|
||||||
|
vcc.options.linker = "--platform:amd64 /nologo /DEBUG /Zi /F33554432" # set the stack size to 8 MB
|
||||||
|
@elif arm:
|
||||||
|
vcc.options.always = "--platform:arm /nologo"
|
||||||
|
vcc.options.linker = "--platform:arm /nologo /DEBUG /Zi /F33554432" # set the stack size to 8 MB
|
||||||
|
@else:
|
||||||
vcc.options.always = "/nologo"
|
vcc.options.always = "/nologo"
|
||||||
vcc.options.speed = "/O2 /arch:SSE2"
|
vcc.options.linker = "/nologo /DEBUG /Zi /F33554432" # set the stack size to 8 MB
|
||||||
|
@end
|
||||||
|
|
||||||
|
vcc.options.debug = "/Zi /FS /Od"
|
||||||
|
vcc.options.speed = "/O2"
|
||||||
vcc.options.size = "/O1"
|
vcc.options.size = "/O1"
|
||||||
|
|
||||||
# Configuration for the Tiny C Compiler:
|
# Configuration for the Tiny C Compiler:
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,66 @@
|
||||||
import strtabs, os, osproc, vccenv
|
import strutils, strtabs, os, osproc, vccenv
|
||||||
|
|
||||||
when defined(release):
|
when defined(release):
|
||||||
let vccOptions = {poParentStreams}
|
let vccOptions = {poParentStreams}
|
||||||
else:
|
else:
|
||||||
let vccOptions = {poEchoCmd, poParentStreams}
|
let vccOptions = {poEchoCmd, poParentStreams}
|
||||||
|
|
||||||
|
const
|
||||||
|
platformPrefix = "--platform"
|
||||||
|
winstorePrefix = "--winstore"
|
||||||
|
sdkversionPrefix = "--sdkversion"
|
||||||
|
|
||||||
|
platformSepIdx = platformPrefix.len
|
||||||
|
sdkversionSepIdx = sdkversionPrefix.len
|
||||||
|
|
||||||
|
HelpText = """
|
||||||
|
+-----------------------------------------------------------------+
|
||||||
|
| Microsoft C/C++ compiler wrapper for Nim |
|
||||||
|
| (c) 2016 Fredrik Høisæther Rasch |
|
||||||
|
+-----------------------------------------------------------------+
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
vccexe [options] [compileroptions]
|
||||||
|
Options:
|
||||||
|
--platform:<arch> Specify the Compiler Platform Tools architecture
|
||||||
|
<arch>: x86 | amd64 | arm | x86_amd64 | x86_arm | amd64_x86 | amd64_arm
|
||||||
|
--winstore Use Windows Store (rather than desktop) development tools
|
||||||
|
--sdkversion:<v> Use a specific Windows SDK version:
|
||||||
|
<v> is either the full Windows 10 SDK version number or
|
||||||
|
"8.1" to use the windows 8.1 SDK
|
||||||
|
|
||||||
|
Other command line arguments are passed on to the
|
||||||
|
Microsoft C/C++ compiler for the specified SDK toolset
|
||||||
|
"""
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
var vccEnvStrTab: StringTableRef = nil
|
var platformArg: string = nil
|
||||||
when defined(i386):
|
var sdkVersionArg: string = nil
|
||||||
vccEnvStrTab = getVccEnv "x86"
|
var storeArg: bool = false
|
||||||
when defined(amd64):
|
|
||||||
vccEnvStrTab = getVccEnv "amd64"
|
var clArgs: seq[TaintedString] = @[]
|
||||||
when defined(arm):
|
|
||||||
vccEnvStrTab = getVccEnv "arm"
|
var wrapperArgs = commandLineParams()
|
||||||
|
for wargv in wrapperArgs:
|
||||||
|
# Check whether the current argument contains -- prefix
|
||||||
|
if wargv.startsWith(platformPrefix): # Check for platform
|
||||||
|
platformArg = wargv.substr(platformSepIdx + 1)
|
||||||
|
elif wargv == winstorePrefix: # Check for winstore
|
||||||
|
storeArg = true
|
||||||
|
elif wargv.startsWith(sdkversionPrefix): # Check for sdkversion
|
||||||
|
sdkVersionArg = wargv.substr(sdkversionSepIdx + 1)
|
||||||
|
else: # Regular cl.exe argument -> store for final cl.exe invocation
|
||||||
|
if (wargv.len == 2) and (wargv[1] == '?'):
|
||||||
|
echo HelpText
|
||||||
|
clArgs.add(wargv)
|
||||||
|
|
||||||
|
var vccEnvStrTab = getVccEnv(platformArg, storeArg, sdkVersionArg)
|
||||||
if vccEnvStrTab != nil:
|
if vccEnvStrTab != nil:
|
||||||
for vccEnvKey, vccEnvVal in vccEnvStrTab:
|
for vccEnvKey, vccEnvVal in vccEnvStrTab:
|
||||||
putEnv(vccEnvKey, vccEnvVal)
|
putEnv(vccEnvKey, vccEnvVal)
|
||||||
let vccProcess = startProcess(
|
let vccProcess = startProcess(
|
||||||
"cl.exe",
|
"cl.exe",
|
||||||
args = commandLineParams(),
|
args = clArgs,
|
||||||
options = vccOptions
|
options = vccOptions
|
||||||
)
|
)
|
||||||
quit vccProcess.waitForExit()
|
quit vccProcess.waitForExit()
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
import strtabs, os, osproc, vccenv
|
|
||||||
|
|
||||||
when defined(release):
|
|
||||||
let vccOptions = {poParentStreams}
|
|
||||||
else:
|
|
||||||
let vccOptions = {poEchoCmd, poParentStreams}
|
|
||||||
|
|
||||||
when isMainModule:
|
|
||||||
var vccEnvStrTab: StringTableRef = nil
|
|
||||||
when defined(i386):
|
|
||||||
vccEnvStrTab = getVccEnv "x86"
|
|
||||||
when defined(amd64):
|
|
||||||
vccEnvStrTab = getVccEnv "amd64"
|
|
||||||
when defined(arm):
|
|
||||||
vccEnvStrTab = getVccEnv "arm"
|
|
||||||
if vccEnvStrTab != nil:
|
|
||||||
for vccEnvKey, vccEnvVal in vccEnvStrTab:
|
|
||||||
putEnv(vccEnvKey, vccEnvVal)
|
|
||||||
let vccProcess = startProcess(
|
|
||||||
"link.exe",
|
|
||||||
args = commandLineParams(),
|
|
||||||
options = vccOptions
|
|
||||||
)
|
|
||||||
quit vccProcess.waitForExit()
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue