配置Nim的默認(rèn)編譯參數(shù) release build并運行
默認(rèn)情況下nim編譯是debug build,如果需要release build, 需要加上-d:release 骚灸,
release編譯的命令如下:
nim c -d:release xx.nim
release build并運行:
nim c -r -d:release xx.nim
debug build出來可執(zhí)行文件體積稍大翁巍,并且目前對來我說沒有用驴一。
我發(fā)現(xiàn)通過配置nim.cfg,可以給nim編譯器配置默認(rèn)的編譯參數(shù),nim.cfg文件位于nim的安裝目錄/config下灶壶。
類似如下在nim.cfg中添加參數(shù)r和d:release肝断,一行一個參數(shù):
# Configuration file for the Nim Compiler.
# (c) 2017 Andreas Rumpf
# Feel free to edit the default values as you need.
# You may set environment variables with
# @putenv "key" "val"
# Environment variables can be accessed like so:
# gcc.path %= "$CC_PATH"
cc = gcc
r
d:release
...
...
...
之后當(dāng)你執(zhí)行nim c xx.nim
的時候,配置文件中參數(shù)自動傳送給Nim編譯器:
等于 nim c -r -d:release xx.nim
2018-01-18 18:30:00 codegay