//-------------------------------------------------------------
premake是一款用於自動建立解決方案和專案檔的產生器。
支援跨平台間解決方案與項目的設定設定問題。
同時還解決了各項目間快速度項目設定/宏定義/目標修改等。
目前premake用於FlatFour,ODE,CEGUI,yake,NFS等等項目
//-------------------------------------------------------------
Premake 4.1.2, a build script generator
Copyright (C) 2002-2009 Jason Perkins and the Premake Project
Lua 5.1 Copyright (C) 1994-2008 Lua.org, PUC-Rio
Usage: premake4 [options] action [arguments]
選項開關表:
--cc=[VALUE] : 選擇下列指定的C/C++編譯器之一:<br /> gcc GNU GCC (gcc/g++)<br /> ow OpenWatcom</p><p> --dotnet=[VALUE] : 選擇下列指定的.NET編譯器之一:<br /> msnet : Microsoft .NET (csc)<br /> mono : Novell Mono (mcs)<br /> pnet : Portable.NET (cscc)</p><p> --file=[FILE] : 載入指定的premake指令檔,預設指令檔是"premake4.lua"。</p><p> --help : 顯示協助資訊</p><p> --os=[VALUE] : 產生下列指定的作業系統檔案之一,預設Microsoft Windows:<br /> bsd : OpenBSD, NetBSD, or FreeBSD<br /> linux : Linux<br /> macosx : Apple Mac OS X<br /> windows : Microsoft Windows</p><p> --platform=[VALUE] : 產生到下列目標系統平台體系,預設x32:<br /> x32 32位作業系統<br /> x64 64位作業系統<br /> universal Mac OS X Universal(32或者64位)<br /> universal32 Mac OS X Universal(僅32位)<br /> universal64 Mac OS X Universal(僅64位)<br /> ps3 Playstation 3 (測試中)<br /> xbox360 Xbox 360 (測試中)</p><p> --scripts=[PATH] : 額外搜尋指定目錄的指令檔</p><p> --version : 顯示版本資訊</p><p>
動作表:
clean : 刪除所有目標檔案和組建檔案(組建檔案包括*.obj/*.ilk等所有產生出的)
codeblocks : 產生Code::Blocks 項目與解決方案檔案
codelite : 產生CodeLite 項目與解決方案檔案
gmake : 產生GNU用於POSIX/MinGW/Cygwin 的 makefiles
vs2002 : 產生Microsoft Visual Studio 2002項目與解決方案檔案
vs2003 : 產生Microsoft Visual Studio 2003項目與解決方案檔案
vs2005 : 產生Microsoft Visual Studio 2005項目與解決方案檔案
vs2008 : 產生Microsoft Visual Studio 2008項目與解決方案檔案
更多資訊, 參見 http://industriousone.com/premake
//-------------------------------------------------------------
下面是應用例子:
準備工作:在目錄下放main.cpp檔案,內容要為可以編過的代碼檔案。
將premake4.exe放到該目錄下 (此文章用到的是Premake 4.1.2)
建立兩個空批次檔,分別是make.bat和clear.bat
建立一個主指令檔mysln.lua (premake採用的是lua指令碼,因此你可以使用lua的特性與功能)
填寫make.bat檔案:
premake4 --file=mysln.lua --os=windows --platform=x32 vs2005
填寫clear.bat檔案:
premake4 --file=mysln.lua clean
填寫mysln.lua檔案:
solution "MySolution"<br /> basedir "work"<br /> configurations { "Debug", "Release" }<br /> language "C++"<br /> uuid "726890BF-272F-4cff-BA17-3D21C3D1380F"<br /> includedirs "inc"</p><p>project "MyLib"<br /> kind "StaticLib"<br /> includedirs "inc"<br /> files {"*.cpp", "*.h"}</p><p> configuration "Debug"<br /> defines { "DEBUG" }</p><p> configuration "Release"<br /> defines { "NDEBUG" }</p><p>project "MyApp"<br /> kind "StaticLib"<br /> includedirs "inc"<br /> files {"*.cpp", "*.h"}</p><p> configuration "Debug"<br /> defines { "DEBUG" }</p><p> configuration "Release"<br /> defines { "NDEBUG" }</p><p>
//-------------------------------------------------------------