Browse Source

Improve build system

Daniele Bartolini 11 năm trước cách đây
mục cha
commit
6a8b1da904
5 tập tin đã thay đổi với 748 bổ sung660 xóa
  1. 12 2
      engine/renderers/shader.cpp
  2. 14 14
      makefile
  3. 138 0
      premake/crown.lua
  4. 280 644
      premake/premake4.lua
  5. 304 0
      premake/toolchain.lua

+ 12 - 2
engine/renderers/shader.cpp

@@ -31,6 +31,16 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "reader_writer.h"
 #include "config.h"
 
+#if CROWN_DEBUG
+		#define SHADERC_NAME "shadercDebug"
+#else
+		#define SHADERC_NAME "shadercRelease"
+#endif // CROWN_DEBUG
+		#define SHADERC_PATH SHADERC_NAME
+#if CROWN_PLATFORM_WINDOWS
+		#define SHADERC_PATH SHADERC_NAME".exe"
+#endif // CROWN_PLATFORM_WINDOWS
+
 namespace crown
 {
 namespace shader_resource
@@ -97,7 +107,7 @@ namespace shader_resource
 
 		const char* compile_vs[] =
 		{
-			"shaderc",
+			SHADERC_PATH,
 			"-f", vs_code_path.c_str(),
 			"-o", tmpvs_path.c_str(),
 			"--varyingdef", varying_def_path.c_str(),
@@ -113,7 +123,7 @@ namespace shader_resource
 
 		const char* compile_fs[] =
 		{
-			"shaderc",
+			SHADERC_PATH,
 			"-f", fs_code_path.c_str(),
 			"-o", tmpfs_path.c_str(),
 			"--varyingdef", varying_def_path.c_str(),

+ 14 - 14
makefile

@@ -61,28 +61,28 @@ deps-clean: luajit-clean bgfx-clean
 linux-build:
 	$(PREMAKE) --file=premake/premake4.lua --compiler=linux-gcc gmake
 linux-debug32: deps-linux-debug32 linux-build
-	make -R -C .build/linux config=debug32
+	make -R -C .build/projects/linux config=debug32
 linux-development32: deps-linux-debug32 linux-build
-	make -R -C .build/linux config=development32
+	make -R -C .build/projects/linux config=development32
 linux-release32: deps-linux-release32 linux-build
-	make -R -C .build/linux config=release32
+	make -R -C .build/projects/linux config=release32
 linux-debug64: deps-linux-debug64 linux-build
-	make -R -C .build/linux config=debug64
+	make -R -C .build/projects/linux config=debug64
 linux-development64: deps-linux-debug64 linux-build	
-	make -R -C .build/linux config=development64
+	make -R -C .build/projects/linux config=development64
 linux-release64: deps-linux-release64 linux-build
-	make -R -C .build/linux config=release64
+	make -R -C .build/projects/linux config=release64
 linux: linux-debug32 linux-development32 linux-release32 linux-debug64 linux-development64 linux-release64
 
 android-build:
-	$(PREMAKE) --file=premake/premake4.lua --compiler=android gmake
-android-debug: deps-android-arm-debug android-build
-	make -R -C .build/android config=debug
-android-development: deps-android-arm-debug android-build
-	make -R -C .build/android config=development
-android-release: deps-android-arm-release android-build
-	make -R -C .build/android config=release
-android: android-debug android-development android-release
+	$(PREMAKE) --file=premake/premake4.lua --compiler=android-arm gmake
+android-arm-debug: deps-android-arm-debug android-build
+	make -R -C .build/projects/android config=debug
+android-arm-development: deps-android-arm-debug android-build
+	make -R -C .build/projects/android config=development
+android-arm-release: deps-android-arm-release android-build
+	make -R -C .build/projects/android config=release
+android-arm: android-arm-debug android-arm-development android-arm-release
 
 windows-build:
 	$(PREMAKE) --file=premake\premake4.lua vs2012

+ 138 - 0
premake/crown.lua

@@ -0,0 +1,138 @@
+function crown_project(_name, _kind, _defines)
+
+	project ("crown" .. _name)
+		kind (_kind)
+
+		includedirs {
+			CROWN_DIR .. "engine",
+			CROWN_DIR .. "engine/core",
+			CROWN_DIR .. "engine/core/containers",
+			CROWN_DIR .. "engine/core/filesystem",
+			CROWN_DIR .. "engine/core/json",
+			CROWN_DIR .. "engine/core/math",
+			CROWN_DIR .. "engine/core/memory",
+			CROWN_DIR .. "engine/core/network",
+			CROWN_DIR .. "engine/core/settings",
+			CROWN_DIR .. "engine/core/strings",
+			CROWN_DIR .. "engine/core/thread",
+			CROWN_DIR .. "engine/main",
+			CROWN_DIR .. "engine/input",
+			CROWN_DIR .. "engine/renderers",
+			CROWN_DIR .. "engine/resource",
+			CROWN_DIR .. "engine/lua",
+			CROWN_DIR .. "engine/audio",
+			CROWN_DIR .. "engine/compilers",
+			CROWN_DIR .. "engine/physics",
+			CROWN_DIR .. "engine/world",
+			CROWN_DIR .. "third/luajit/src",
+			CROWN_DIR .. "third/openal/include",
+			CROWN_DIR .. "third/freetype",
+			CROWN_DIR .. "third/stb_image",
+			CROWN_DIR .. "third/stb_vorbis",
+			CROWN_DIR .. "third/bgfx/src",
+			CROWN_DIR .. "third/bgfx/include",
+			CROWN_DIR .. "third/bx/include",
+		}
+
+		defines {
+			_defines,
+		}
+
+		configuration { "debug" }
+			flags {
+				"Symbols"
+			}
+			defines {
+				"_DEBUG",
+				"CROWN_DEBUG"
+			}
+
+		configuration { "development" }
+			flags {
+				"Symbols"
+			}
+			defines {
+				"_DEBUG",
+				"CROWN_DEBUG"
+			}
+
+		configuration { "release" }
+			defines {
+				"NDEBUG"
+			}
+
+		configuration { "linux*" }
+			includedirs {
+				"$(PHYSX_SDK_LINUX)/Include",
+				"$(PHYSX_SDK_LINUX)/Include/common",
+				"$(PHYSX_SDK_LINUX)/Include/characterkinematic",
+				"$(PHYSX_SDK_LINUX)/Include/cloth",
+				"$(PHYSX_SDK_LINUX)/Include/common",
+				"$(PHYSX_SDK_LINUX)/Include/cooking",
+				"$(PHYSX_SDK_LINUX)/Include/extensions",
+				"$(PHYSX_SDK_LINUX)/Include/foundation",
+				"$(PHYSX_SDK_LINUX)/Include/geometry",
+				"$(PHYSX_SDK_LINUX)/Include/particles",
+				"$(PHYSX_SDK_LINUX)/Include/physxprofilesdk",
+				"$(PHYSX_SDK_LINUX)/Include/physxvisualdebuggersdk",
+				"$(PHYSX_SDK_LINUX)/Include/pvd",
+				"$(PHYSX_SDK_LINUX)/Include/pxtask",
+				"$(PHYSX_SDK_LINUX)/Include/RepX",
+				"$(PHYSX_SDK_LINUX)/Include/RepXUpgrader",
+				"$(PHYSX_SDK_LINUX)/Include/vehicle",
+			}
+
+		configuration { "android*" }
+			includedirs {
+				"$(PHYSX_SDK_ANDROID)/Include",
+				"$(PHYSX_SDK_ANDROID)/Include/common",
+				"$(PHYSX_SDK_ANDROID)/Include/characterkinematic",
+				"$(PHYSX_SDK_ANDROID)/Include/cloth",
+				"$(PHYSX_SDK_ANDROID)/Include/common",
+				"$(PHYSX_SDK_ANDROID)/Include/cooking",
+				"$(PHYSX_SDK_ANDROID)/Include/extensions",
+				"$(PHYSX_SDK_ANDROID)/Include/foundation",
+				"$(PHYSX_SDK_ANDROID)/Include/geometry",
+				"$(PHYSX_SDK_ANDROID)/Include/particles",
+				"$(PHYSX_SDK_ANDROID)/Include/physxprofilesdk",
+				"$(PHYSX_SDK_ANDROID)/Include/physxvisualdebuggersdk",
+				"$(PHYSX_SDK_ANDROID)/Include/pvd",
+				"$(PHYSX_SDK_ANDROID)/Include/pxtask",
+				"$(PHYSX_SDK_ANDROID)/Include/RepX",
+				"$(PHYSX_SDK_ANDROID)/Include/RepXUpgrader",
+				"$(PHYSX_SDK_ANDROID)/Include/vehicle",
+			}
+
+		configuration { "vs2012" }
+			includedirs {
+				"$(PHYSX_SDK_WINDOWS)/Include",
+				"$(PHYSX_SDK_WINDOWS)/Include/common",
+				"$(PHYSX_SDK_WINDOWS)/Include/characterkinematic",
+				"$(PHYSX_SDK_WINDOWS)/Include/cloth",
+				"$(PHYSX_SDK_WINDOWS)/Include/common",
+				"$(PHYSX_SDK_WINDOWS)/Include/cooking",
+				"$(PHYSX_SDK_WINDOWS)/Include/extensions",
+				"$(PHYSX_SDK_WINDOWS)/Include/foundation",
+				"$(PHYSX_SDK_WINDOWS)/Include/geometry",
+				"$(PHYSX_SDK_WINDOWS)/Include/particles",
+				"$(PHYSX_SDK_WINDOWS)/Include/physxprofilesdk",
+				"$(PHYSX_SDK_WINDOWS)/Include/physxvisualdebuggersdk",
+				"$(PHYSX_SDK_WINDOWS)/Include/pvd",
+				"$(PHYSX_SDK_WINDOWS)/Include/pxtask",
+				"$(PHYSX_SDK_WINDOWS)/Include/RepX",
+				"$(PHYSX_SDK_WINDOWS)/Include/RepXUpgrader",
+				"$(PHYSX_SDK_WINDOWS)/Include/vehicle",
+				"$(DXSDK_DIR)/Include",
+			}
+
+		configuration {}
+
+		files {
+			CROWN_DIR .. "engine/**.h", 
+			CROWN_DIR .. "engine/**.cpp"
+		}
+
+		strip()
+
+		configuration {} -- reset configuration
+end

+ 280 - 644
premake/premake4.lua

@@ -22,677 +22,313 @@
 -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 -- OTHER DEALINGS IN THE SOFTWARE.
 
-------------------------------------------------------------------------------
--- Options
-
-newoption
-{
-	trigger = "install-dir",
-	value = "DIR",
-	description = "Output directory"
-}
-
-newoption
-{
-	trigger = "compiler",
-	value = "COMPILER",
-	description = "Choose compiler",
-	allowed =
-	{
-		{ "android", "Android (ARM only)" },			-- gcc
-		{ "linux-gcc", "Linux (GCC compiler)" },		-- gcc
-	}
-}
-
-CROWN_SOURCE_DIR = path.getabsolute("..") .. "/"
-CROWN_THIRD_DIR = CROWN_SOURCE_DIR .. "third/"
-CROWN_BUILD_DIR = CROWN_SOURCE_DIR .. ".build/"
-CROWN_INSTALL_DIR = os.getenv("CROWN_INSTALL_DIR")
-if not CROWN_INSTALL_DIR then
-	if not path.isabsolute(CROWN_INSTALL_DIR) then
-		CROWN_INSTALL_DIR = CROWN_SOURCE_DIR .. ".install"
-	end
-end
-CROWN_INSTALL_DIR = CROWN_INSTALL_DIR .. "/" -- Add slash to end string
-
--------------------------------------------------------------------------------
--- Solution
 solution "crown"
-	configurations { "debug", "development", "release" }
-	platforms { "x32", "x64", "native" }
-
-	-- Avoid error invoking premake4 --help
-	if _ACTION == nil then return end
-
-	if _ACTION == "clean" then os.rmdir(CROWN_BUILD_DIR) end
-
-	if _ACTION == "gmake" then
-
-		if _OPTIONS["compiler"] == "linux-gcc" then
-
-			if not os.is("linux") then print("Action not valid in current OS.") end
-
-			if not os.getenv("PHYSX_SDK_LINUX") then
-				print("Set PHYSX_SDK_LINUX environment variable.")
-			end
-
-			location(CROWN_BUILD_DIR .. "linux")
-
-		elseif _OPTIONS["compiler"] == "android" then
-
-			if not os.getenv("ANDROID_NDK_ROOT") then
-				print("Set ANDROID_NDK_ROOT environment variable.")
-			end
-			if not os.getenv("ANDROID_NDK_ARM") then
-				print("Set ANDROID_NDK_ARM environment variables.")
-			end
-			if not os.getenv("PHYSX_SDK_ANDROID") then
-				print("Set PHYSX_SDK_ANDROID environment variable.")
-			end
-
-			premake.gcc.cc = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-gcc"
-			premake.gcc.cxx = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-g++"
-			premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar"
-
-			location(CROWN_BUILD_DIR .. "android")
-
-		end
-	end
-
-	if _ACTION == "vs2012" then
-
-		if not os.is("windows") then print("Action not valid in current OS.") end
-
-		if not os.getenv("PHYSX_SDK_WINDOWS") then
-			print("Set PHYSX_SDK_WINDOWS environment variable.")
-		end
-		if not os.getenv("DXSDK_DIR") then
-			print("Set DXSDK_DIR environment variable.")
-		end
-
-		location(CROWN_BUILD_DIR .. "windows")
-
-	end
-
-	flags {
-		"StaticRuntime",
-		"NoMinimalRebuild",
-		"NoPCH",
-		"NoRTTI",
-		"NoExceptions",
-		"NoEditAndContinue",
+	configurations {
+		"debug",
+		"development",
+		"release",
 	}
 
-	configuration { "debug" }
-		flags { "Symbols" }
-		defines { "_DEBUG", "CROWN_DEBUG" }
-	configuration { "development" }
-		flags { "Symbols" }
-		defines { "_DEBUG", "CROWN_DEBUG" }
-	configuration { "release" }
-		defines { "NDEBUG" }
-
-	configuration { "debug", "x32" }
-		targetsuffix "-debug-32"
-	configuration { "debug", "x64" }
-		targetsuffix "-debug-64"
-
-	configuration { "development", "x32" }
-		targetsuffix "-development-32"
-	configuration { "development", "x64" }
-		targetsuffix "-development-64"
-
-	configuration { "release", "x32" }
-		targetsuffix "-release-32"
-	configuration { "release", "x64" }
-		targetsuffix "-release-64"
-
-	configuration { "debug", "native" }
-		targetsuffix "-debug"
-
-	configuration { "development", "native" }
-		targetsuffix "-development"
-
-	configuration { "release", "native" }
-		targetsuffix "-release"
-
-	-------------------------------------------------------------------------------
-	project "crown"
-		language "C++"
+	platforms {
+		"x32",
+		"x64",
+		"native"
+	}
 
-		includedirs {
-			CROWN_SOURCE_DIR .. "/engine",
-			CROWN_SOURCE_DIR .. "/engine/core",
-			CROWN_SOURCE_DIR .. "/engine/core/containers",
-			CROWN_SOURCE_DIR .. "/engine/core/filesystem",
-			CROWN_SOURCE_DIR .. "/engine/core/json",
-			CROWN_SOURCE_DIR .. "/engine/core/math",
-			CROWN_SOURCE_DIR .. "/engine/core/memory",
-			CROWN_SOURCE_DIR .. "/engine/core/network",
-			CROWN_SOURCE_DIR .. "/engine/core/settings",
-			CROWN_SOURCE_DIR .. "/engine/core/strings",
-			CROWN_SOURCE_DIR .. "/engine/core/thread",
-			CROWN_SOURCE_DIR .. "/engine/main",
-			CROWN_SOURCE_DIR .. "/engine/input",
-			CROWN_SOURCE_DIR .. "/engine/renderers",
-			CROWN_SOURCE_DIR .. "/engine/resource",
-			CROWN_SOURCE_DIR .. "/engine/lua",
-			CROWN_SOURCE_DIR .. "/engine/audio",
-			CROWN_SOURCE_DIR .. "/engine/compilers",
-			CROWN_SOURCE_DIR .. "/engine/physics",
-			CROWN_SOURCE_DIR .. "/engine/world"
+	language "C++"
+
+CROWN_DIR = (path.getabsolute("..") .. "/")
+local CROWN_THIRD_DIR = (CROWN_DIR .. "third/")
+local CROWN_BUILD_DIR = (CROWN_DIR .. ".build/")
+dofile (CROWN_DIR .. "premake/toolchain.lua")
+toolchain(CROWN_BUILD_DIR, CROWN_THIRD_DIR)
+
+	configuration { "linux-*" }	
+		links {
+			"X11",
+			"Xrandr",
+			"pthread",
+			"GL",
+			"openal",
+			"luajit",
+			"dl",
 		}
 
-		files {
-			CROWN_SOURCE_DIR .. "engine/**.h", 
-			CROWN_SOURCE_DIR .. "engine/**.cpp"
+	configuration { "debug", "linux-*" }
+		links {
+			"bgfxDebug"
+		}
+		linkoptions {
+			"-rdynamic",
+			"-Wl,--start-group $(addprefix -l," ..
+			"	LowLevelClothCHECKED" ..
+			"	PhysX3CHECKED " ..
+			"	PhysX3CommonCHECKED" ..
+			"	PxTaskCHECKED" ..
+			"	LowLevelCHECKED" ..
+			"	PhysX3CharacterKinematicCHECKED" ..
+			"	PhysX3CookingCHECKED" ..
+			"	PhysX3ExtensionsCHECKED" ..
+			"	PhysX3VehicleCHECKED" ..
+			"	PhysXProfileSDKCHECKED" ..
+			"	PhysXVisualDebuggerSDKCHECKED" ..
+			"	PvdRuntimeCHECKED" ..
+			"	SceneQueryCHECKED" ..
+			"	SimulationControllerCHECKED" ..
+			") -Wl,--end-group"
 		}
 
-		configuration { "linux-*" }
-			kind "ConsoleApp"
-
-			buildoptions {
-				"-std=c++03",
-				"-Wall",
-				-- "-Wextra",
-				-- "-Werror",
-				-- "-pedantic",
-				"-Wno-unknown-pragmas",
-				"-Wno-unused-local-typedefs"
-			}
-			
-			linkoptions {
-				"-Wl,-rpath=\\$$ORIGIN",
-				"-Wl,--no-as-needed"
-			}
+	configuration { "development", "linux-*" }
+		links {
+			"bgfxDebug"
+		}
+		linkoptions
+		{
+			"-rdynamic",
+			"-Wl,--start-group $(addprefix -l," ..
+			"	LowLevelClothPROFILE" ..
+			"	PhysX3PROFILE " ..
+			"	PhysX3CommonPROFILE" ..
+			"	PxTaskPROFILE" ..
+			"	LowLevelPROFILE" ..
+			"	PhysX3CharacterKinematicPROFILE" ..
+			"	PhysX3CookingPROFILE" ..
+			"	PhysX3ExtensionsPROFILE" ..
+			"	PhysX3VehiclePROFILE" ..
+			"	PhysXProfileSDKPROFILE" ..
+			"	PhysXVisualDebuggerSDKPROFILE" ..
+			"	PvdRuntimePROFILE" ..
+			"	SceneQueryPROFILE" ..
+			"	SimulationControllerPROFILE" ..
+			") -Wl,--end-group"
+		}
 
-			links {
-				"Xrandr",
-				"pthread",
-				"GL",
-				"X11",
-				"openal",
-				"luajit",
-				"dl",
-			}
+	configuration { "release", "linux-*" }
+		links {
+			"bgfxRelease"
+		}
+		linkoptions {
+			"-Wl,--start-group $(addprefix -l," ..
+			"	LowLevelCloth" ..
+			"	PhysX3 " ..
+			"	PhysX3Common" ..
+			"	PxTask" ..
+			"	LowLevel" ..
+			"	PhysX3CharacterKinematic" ..
+			"	PhysX3Cooking" ..
+			"	PhysX3Extensions" ..
+			"	PhysX3Vehicle" ..
+			"	PhysXProfileSDK" ..
+			"	PhysXVisualDebuggerSDK" ..
+			"	PvdRuntime" ..
+			"	SceneQuery" ..
+			"	SimulationController" ..
+			") -Wl,--end-group"
+		}
 
-			includedirs {
-				CROWN_THIRD_DIR .. "luajit/src",
-				CROWN_THIRD_DIR .. "openal/include",
-				CROWN_THIRD_DIR .. "freetype",
-				CROWN_THIRD_DIR .. "stb_image",
-				CROWN_THIRD_DIR .. "stb_vorbis",
-				CROWN_THIRD_DIR .. "bgfx/src",
-				CROWN_THIRD_DIR .. "bgfx/include",
-				CROWN_THIRD_DIR .. "bx/include",
-				"$(PHYSX_SDK_LINUX)/Include",
-				"$(PHYSX_SDK_LINUX)/Include/common",
-				"$(PHYSX_SDK_LINUX)/Include/characterkinematic",
-				"$(PHYSX_SDK_LINUX)/Include/cloth",
-				"$(PHYSX_SDK_LINUX)/Include/common",
-				"$(PHYSX_SDK_LINUX)/Include/cooking",
-				"$(PHYSX_SDK_LINUX)/Include/extensions",
-				"$(PHYSX_SDK_LINUX)/Include/foundation",
-				"$(PHYSX_SDK_LINUX)/Include/geometry",
-				"$(PHYSX_SDK_LINUX)/Include/particles",
-				"$(PHYSX_SDK_LINUX)/Include/physxprofilesdk",
-				"$(PHYSX_SDK_LINUX)/Include/physxvisualdebuggersdk",
-				"$(PHYSX_SDK_LINUX)/Include/pvd",
-				"$(PHYSX_SDK_LINUX)/Include/pxtask",
-				"$(PHYSX_SDK_LINUX)/Include/RepX",
-				"$(PHYSX_SDK_LINUX)/Include/RepXUpgrader",
-				"$(PHYSX_SDK_LINUX)/Include/vehicle",
-			}
-			
-		configuration { "linux-*", "debug" }
-			buildoptions {
-				"-O0"
-			}
+	configuration { "android*" }
+		kind "ConsoleApp"
+		targetextension ".so"
+		linkoptions {
+			"-shared"
+		}
+		links {
+			"EGL",
+			"GLESv2",
+			":libluajit.a",
+			"OpenSLES",
+		}
 
-			links {
-				"bgfxDebug"
-			}
+	configuration { "debug", "android-arm" }
+		links {
+			":libbgfxDebug.a",
+		}
+		linkoptions {
+			"-Wl,--start-group $(addprefix -l," ..
+			"	LowLevelCloth" ..
+			"	PhysX3 " ..
+			"	PhysX3Common" ..
+			"	PxTask" ..
+			"	LowLevel" ..
+			"	PhysX3CharacterKinematic" ..
+			"	PhysX3Cooking" ..
+			"	PhysX3Extensions" ..
+			"	PhysX3Vehicle" ..
+			"	PhysXProfileSDK" ..
+			"	PhysXVisualDebuggerSDK" ..
+			"	PvdRuntime" ..
+			"	SceneQuery" ..
+			"	SimulationController" ..
+			") -Wl,--end-group"
+		}
 
-			linkoptions {
-				"-rdynamic",
-				"-Wl,--start-group $(addprefix -l," ..
-				"	LowLevelClothCHECKED" ..
-				"	PhysX3CHECKED " ..
-				"	PhysX3CommonCHECKED" ..
-				"	PxTaskCHECKED" ..
-				"	LowLevelCHECKED" ..
-				"	PhysX3CharacterKinematicCHECKED" ..
-				"	PhysX3CookingCHECKED" ..
-				"	PhysX3ExtensionsCHECKED" ..
-				"	PhysX3VehicleCHECKED" ..
-				"	PhysXProfileSDKCHECKED" ..
-				"	PhysXVisualDebuggerSDKCHECKED" ..
-				"	PvdRuntimeCHECKED" ..
-				"	SceneQueryCHECKED" ..
-				"	SimulationControllerCHECKED" ..
-				") -Wl,--end-group"
-			}
+	configuration { "development", "android-arm" }
+		links {
+			":libbgfxDebug.a",
+		}
+		linkoptions { 
+			"-Wl,--start-group $(addprefix -l," ..
+			"	LowLevelCloth" ..
+			"	PhysX3 " ..
+			"	PhysX3Common" ..
+			"	PxTask" ..
+			"	LowLevel" ..
+			"	PhysX3CharacterKinematic" ..
+			"	PhysX3Cooking" ..
+			"	PhysX3Extensions" ..
+			"	PhysX3Vehicle" ..
+			"	PhysXProfileSDK" ..
+			"	PhysXVisualDebuggerSDK" ..
+			"	PvdRuntime" ..
+			"	SceneQuery" ..
+			"	SimulationController" ..
+			") -Wl,--end-group"
+		}
 
-		configuration { "linux-*", "development" }
-			buildoptions {
-				"-O2"
-			}
+	configuration { "release", "android-arm" }
+		links {
+			":libbgfxRelease.a",
+		}
+		linkoptions {
+			"-Wl,--start-group $(addprefix -l," ..
+			"	LowLevelCloth" ..
+			"	PhysX3 " ..
+			"	PhysX3Common" ..
+			"	PxTask" ..
+			"	LowLevel" ..
+			"	PhysX3CharacterKinematic" ..
+			"	PhysX3Cooking" ..
+			"	PhysX3Extensions" ..
+			"	PhysX3Vehicle" ..
+			"	PhysXProfileSDK" ..
+			"	PhysXVisualDebuggerSDK" ..
+			"	PvdRuntime" ..
+			"	SceneQuery" ..
+			"	SimulationController" ..
+			") -Wl,--end-group"
+		}
 
-			links {
-				"bgfxDebug"
-			}
+	configuration { "vs*" }
+		links {
+			"OpenGL32",
+			"lua51",
+			"OpenAL32",
+			"dbghelp"
+		}
 
-			linkoptions
-			{
-				"-rdynamic",
-				"-Wl,--start-group $(addprefix -l," ..
-				"	LowLevelClothPROFILE" ..
-				"	PhysX3PROFILE " ..
-				"	PhysX3CommonPROFILE" ..
-				"	PxTaskPROFILE" ..
-				"	LowLevelPROFILE" ..
-				"	PhysX3CharacterKinematicPROFILE" ..
-				"	PhysX3CookingPROFILE" ..
-				"	PhysX3ExtensionsPROFILE" ..
-				"	PhysX3VehiclePROFILE" ..
-				"	PhysXProfileSDKPROFILE" ..
-				"	PhysXVisualDebuggerSDKPROFILE" ..
-				"	PvdRuntimePROFILE" ..
-				"	SceneQueryPROFILE" ..
-				"	SimulationControllerPROFILE" ..
-				") -Wl,--end-group"
-			}
+	configuration { "debug", "x32", "vs*"}
+		links {
+			"PhysX3CharacterKinematicCHECKED_x86",
+			"PhysX3CHECKED_x86",
+			"PhysX3CommonCHECKED_x86",
+			"PhysX3CookingCHECKED_x86",
+			"PhysX3ExtensionsCHECKED",
+			"bgfxDebug"
+		}
 
-		configuration { "linux-*", "release" }
-			buildoptions {
-				"-O2"
-			}
+	configuration { "debug", "x64", "vs*" }
+		links {
+			"PhysX3CharacterKinematicCHECKED_x64",
+			"PhysX3CHECKED_x64",
+			"PhysX3CommonCHECKED_x64",
+			"PhysX3CookingCHECKED_x64",
+			"PhysX3ExtensionsCHECKED",
+			"bgfxDebug"
+		}
 
-			links {
-				"bgfxRelease"
-			}
+	configuration { "development", "x32", "vs*" }
+		links {
+			"PhysX3CharacterKinematicPROFILE_x86",
+			"PhysX3PROFILE_x86",
+			"PhysX3CommonPROFILE_x86",
+			"PhysX3CookingPROFILE_x86",
+			"PhysX3ExtensionsPROFILE",
+			"bgfxDebug"
+		}
 
-			linkoptions {
-				"-Wl,--start-group $(addprefix -l," ..
-				"	LowLevelCloth" ..
-				"	PhysX3 " ..
-				"	PhysX3Common" ..
-				"	PxTask" ..
-				"	LowLevel" ..
-				"	PhysX3CharacterKinematic" ..
-				"	PhysX3Cooking" ..
-				"	PhysX3Extensions" ..
-				"	PhysX3Vehicle" ..
-				"	PhysXProfileSDK" ..
-				"	PhysXVisualDebuggerSDK" ..
-				"	PvdRuntime" ..
-				"	SceneQuery" ..
-				"	SimulationController" ..
-				") -Wl,--end-group"
-			}
+	configuration { "development", "x64", "vs*" }
+		links {
+			"PhysX3CharacterKinematicPROFILE_x64",
+			"PhysX3PROFILE_x64",
+			"PhysX3CommonPROFILE_x64",
+			"PhysX3CookingPROFILE_x64",
+			"PhysX3ExtensionsPROFILE",
+			"bgfxDebug"
+		}
 
-		configuration { "linux-*", "x32" }
-			targetdir(CROWN_INSTALL_DIR .. "bin/linux32")
+	configuration { "release", "x32", "vs*" }
+		links {
+			"PhysX3CharacterKinematic_x86",
+			"PhysX3_x86",
+			"PhysX3Common_x86",
+			"PhysX3Cooking_x86",
+			"PhysX3Extensions",
+			"bgfxRelease"
+		}
 		
-			buildoptions {
-				"-malign-double" -- Required by PhysX
-			}
-
-			libdirs {
-				CROWN_THIRD_DIR .. "luajit/src",
-				CROWN_THIRD_DIR .. "bgfx/.build/linux32_gcc/bin",
-				"$(PHYSX_SDK_LINUX)/Lib/linux32"
-			}
-
-			postbuildcommands {
-				"cp " .. CROWN_THIRD_DIR .. "luajit/src/luajit " .. CROWN_INSTALL_DIR .. "bin/linux32/",
-				"cp " .. CROWN_THIRD_DIR .. "luajit/src/jit " .. CROWN_INSTALL_DIR .. "bin/linux32/" .. " -r",
-			}
-
-		configuration { "linux-*", "x64" }
-			targetdir(CROWN_INSTALL_DIR .. "bin/linux64")
-
-			libdirs {
-				CROWN_THIRD_DIR .. "luajit/src",
-				CROWN_THIRD_DIR .. "bgfx/.build/linux64_gcc/bin",
-				"$(PHYSX_SDK_LINUX)/Lib/linux64"
-			}
-
-			postbuildcommands {
-				"cp " .. CROWN_THIRD_DIR .. "luajit/src/luajit " .. CROWN_INSTALL_DIR .. "bin/linux64/",
-				"cp " .. CROWN_THIRD_DIR .. "luajit/src/jit " .. CROWN_INSTALL_DIR .. "bin/linux64/" .. " -r",
-			}
-
-		configuration { "debug or development", "x32", "linux-*" }
-			postbuildcommands {
-				"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux32_gcc/bin/shadercDebug " .. CROWN_INSTALL_DIR .. "bin/linux32/shaderc"
-			}
-
-		configuration { "release", "x32", "linux-*" }
-			postbuildcommands {
-				"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux32_gcc/bin/shadercRelease " .. CROWN_INSTALL_DIR .. "bin/linux32/shaderc"
-			}
-
-		configuration { "debug or development", "x64", "linux-*" }
-			postbuildcommands {
-				"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux64_gcc/bin/shadercDebug " .. CROWN_INSTALL_DIR .. "bin/linux64/shaderc"
-			}
-
-		configuration { "release", "x64", "linux-*" }
-			postbuildcommands {
-				"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux64_gcc/bin/shadercRelease " .. CROWN_INSTALL_DIR .. "bin/linux64/shaderc"
-			}
-
-		configuration { "android" }
-			kind "ConsoleApp"
-			targetprefix "lib"
-			targetextension ".so"
-
-			targetdir(CROWN_INSTALL_DIR .. "bin/android") -- must be specified by user -- tmp
-
-			flags { "NoImportLib" }
-
-			defines {
-				"__STDC_FORMAT_MACROS",
-				"__STDC_CONSTANT_MACROS",
-				"__STDC_LIMIT_MACROS"
-			}
-
-			buildoptions {
-				"--sysroot=$(ANDROID_NDK_ROOT)/platforms/android-14/arch-arm",
-				"-ffunction-sections",
-				"-fPIC",
-				"-march=armv7-a",
-				"-mfloat-abi=softfp",
-				"-mthumb",
-				"-no-canonical-prefixes",
-				"-std=c++03",
-				"-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
-				"-no-canonical-prefixes",
-				"-fstack-protector",
-				"-mfpu=neon",
-				"-Wa,--noexecstack",
-			}
-			
-			linkoptions {
-				"-shared",
-				"-nostdlib",
-				"-static-libgcc",
-				"--sysroot=$(ANDROID_NDK_ROOT)/platforms/android-14/arch-arm",
-				"$(ANDROID_NDK_ROOT)/platforms/android-14/arch-arm/usr/lib/crtbegin_so.o",
-				"$(ANDROID_NDK_ROOT)/platforms/android-14/arch-arm/usr/lib/crtend_so.o",
-				"-no-canonical-prefixes",
-				"-Wl,--no-undefined",
-				"-Wl,-z,noexecstack",
-				"-Wl,-z,relro",
-				"-Wl,-z,now",
-				"-march=armv7-a",
-				"-Wl,--fix-cortex-a8",
-			}
-
-			links {
-				":libluajit.a",
-				"android",
-				"c",
-				"dl",
-				"EGL",
-				"gcc",
-				"GLESv2",
-				"gnustl_static",
-				"log",
-				"m",
-				"OpenSLES"
-			}
-
-			includedirs {
-				CROWN_THIRD_DIR .. "luajit/src",
-				CROWN_THIRD_DIR .. "bgfx/include",
-				CROWN_THIRD_DIR .. "bx/include",
-				CROWN_THIRD_DIR .. "openal/include",
-				CROWN_THIRD_DIR .. "freetype",
-				CROWN_THIRD_DIR .. "stb_image",
-				CROWN_THIRD_DIR .. "stb_vorbis",
-				"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/include",
-				"$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
-				"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include",
-				"$(PHYSX_SDK_ANDROID)/Include",
-				"$(PHYSX_SDK_ANDROID)/Include/common",
-				"$(PHYSX_SDK_ANDROID)/Include/characterkinematic",
-				"$(PHYSX_SDK_ANDROID)/Include/cloth",
-				"$(PHYSX_SDK_ANDROID)/Include/common",
-				"$(PHYSX_SDK_ANDROID)/Include/cooking",
-				"$(PHYSX_SDK_ANDROID)/Include/extensions",
-				"$(PHYSX_SDK_ANDROID)/Include/foundation",
-				"$(PHYSX_SDK_ANDROID)/Include/geometry",
-				"$(PHYSX_SDK_ANDROID)/Include/particles",
-				"$(PHYSX_SDK_ANDROID)/Include/physxprofilesdk",
-				"$(PHYSX_SDK_ANDROID)/Include/physxvisualdebuggersdk",
-				"$(PHYSX_SDK_ANDROID)/Include/pvd",
-				"$(PHYSX_SDK_ANDROID)/Include/pxtask",
-				"$(PHYSX_SDK_ANDROID)/Include/RepX",
-				"$(PHYSX_SDK_ANDROID)/Include/RepXUpgrader",
-				"$(PHYSX_SDK_ANDROID)/Include/vehicle",
-			}
-
-			libdirs {
-				CROWN_THIRD_DIR .. "luajit/src",
-				CROWN_THIRD_DIR .. "bgfx/.build/android-arm/bin",
-				"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a",
-				"$(ANDROID_NDK_ROOT)/platforms/android-14/arch-arm/usr/lib",
-				"$(PHYSX_SDK_ANDROID)/Lib/android9_neon",
-			}
-
-		configuration { "debug", "android" }
-			links {
-				":libbgfxDebug.a",
-			}
-
-			linkoptions {
-				"-Wl,--start-group $(addprefix -l," ..
-				"	LowLevelCloth" ..
-				"	PhysX3 " ..
-				"	PhysX3Common" ..
-				"	PxTask" ..
-				"	LowLevel" ..
-				"	PhysX3CharacterKinematic" ..
-				"	PhysX3Cooking" ..
-				"	PhysX3Extensions" ..
-				"	PhysX3Vehicle" ..
-				"	PhysXProfileSDK" ..
-				"	PhysXVisualDebuggerSDK" ..
-				"	PvdRuntime" ..
-				"	SceneQuery" ..
-				"	SimulationController" ..
-				") -Wl,--end-group"
-			}
-		configuration { "development", "android"}
-			links {
-				":libbgfxDebug.a",
-			}
-
-			linkoptions { 
-				"-Wl,--start-group $(addprefix -l," ..
-				"	LowLevelCloth" ..
-				"	PhysX3 " ..
-				"	PhysX3Common" ..
-				"	PxTask" ..
-				"	LowLevel" ..
-				"	PhysX3CharacterKinematic" ..
-				"	PhysX3Cooking" ..
-				"	PhysX3Extensions" ..
-				"	PhysX3Vehicle" ..
-				"	PhysXProfileSDK" ..
-				"	PhysXVisualDebuggerSDK" ..
-				"	PvdRuntime" ..
-				"	SceneQuery" ..
-				"	SimulationController" ..
-				") -Wl,--end-group"
-			}	
-		configuration { "release", "android"}
-			links {
-				":libbgfxRelease.a",
-			}
-
-			linkoptions { 
-				"-Wl,--start-group $(addprefix -l," ..
-				"	LowLevelCloth" ..
-				"	PhysX3 " ..
-				"	PhysX3Common" ..
-				"	PxTask" ..
-				"	LowLevel" ..
-				"	PhysX3CharacterKinematic" ..
-				"	PhysX3Cooking" ..
-				"	PhysX3Extensions" ..
-				"	PhysX3Vehicle" ..
-				"	PhysXProfileSDK" ..
-				"	PhysXVisualDebuggerSDK" ..
-				"	PvdRuntime" ..
-				"	SceneQuery" ..
-				"	SimulationController" ..
-				") -Wl,--end-group"
-			}
-
-		configuration { "vs*" }
-			kind "ConsoleApp"
-
-			targetdir (CROWN_INSTALL_DIR .. "windows")
-
-			linkoptions {
-				"/ignore:4199", -- LNK4199: /DELAYLOAD:*.dll ignored; no imports found from *.dll
-				"/ignore:4221", -- LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
-
-			}
-
-			defines {
-				"WIN32",
-				"_WIN32",
-				"_HAS_EXCEPTIONS=0",
-				"_HAS_ITERATOR_DEBUGGING=0",
-				"_SCL_SECURE=0",
-				"_SECURE_SCL=0",
-				"_SCL_SECURE_NO_WARNINGS",
-				"_CRT_SECURE_NO_WARNINGS",
-				"_CRT_SECURE_NO_DEPRECATE"
-			}
-
-			buildoptions {
-				"/Oy-", -- Suppresses creation of frame pointers on the call stack.
-				"/Ob2", -- The Inline Function Expansion
-			}
+	configuration { "release", "x64", "vs*" }
+		links {
+			"PhysX3CharacterKinematic_x64",
+			"PhysX3_x64",
+			"PhysX3Common_x64",
+			"PhysX3Cooking_x64",
+			"PhysX3Extensions",
+			"bgfxRelease"
+		}
 
-			links {
-				"OpenGL32",
-				"lua51",
-				"OpenAL32",
-				"dbghelp"
-			}
+dofile "crown.lua"
+crown_project("", "WindowedApp", {})
 
-			includedirs {
-				CROWN_SOURCE_DIR .. "core/compat/msvc",
-				CROWN_THIRD_DIR .. "luajit/src",
-				CROWN_THIRD_DIR .. "openal/include",
-				CROWN_THIRD_DIR .. "freetype",
-				CROWN_THIRD_DIR .. "stb_image",
-				CROWN_THIRD_DIR .. "stb_vorbis",
-				CROWN_THIRD_DIR .. "bgfx/src",
-				CROWN_THIRD_DIR .. "bgfx/include",
-				CROWN_THIRD_DIR .. "bx/include",
-				"$(PHYSX_SDK_WINDOWS)/Include",
-				"$(PHYSX_SDK_WINDOWS)/Include/common",
-				"$(PHYSX_SDK_WINDOWS)/Include/characterkinematic",
-				"$(PHYSX_SDK_WINDOWS)/Include/cloth",
-				"$(PHYSX_SDK_WINDOWS)/Include/common",
-				"$(PHYSX_SDK_WINDOWS)/Include/cooking",
-				"$(PHYSX_SDK_WINDOWS)/Include/extensions",
-				"$(PHYSX_SDK_WINDOWS)/Include/foundation",
-				"$(PHYSX_SDK_WINDOWS)/Include/geometry",
-				"$(PHYSX_SDK_WINDOWS)/Include/particles",
-				"$(PHYSX_SDK_WINDOWS)/Include/physxprofilesdk",
-				"$(PHYSX_SDK_WINDOWS)/Include/physxvisualdebuggersdk",
-				"$(PHYSX_SDK_WINDOWS)/Include/pvd",
-				"$(PHYSX_SDK_WINDOWS)/Include/pxtask",
-				"$(PHYSX_SDK_WINDOWS)/Include/RepX",
-				"$(PHYSX_SDK_WINDOWS)/Include/RepXUpgrader",
-				"$(PHYSX_SDK_WINDOWS)/Include/vehicle",
-				"$(DXSDK_DIR)/Include",
-			}
+-- Install
+configuration { "android-arm" }
+	postbuildcommands {
+		"cp -r " .. CROWN_DIR .. ".build/android-arm/bin/* " .. "$(CROWN_INSTALL_DIR)/" .. "bin/android-arm/",
+	}
 
-		configuration { "x32", "vs*" }
-			libdirs {
-				CROWN_THIRD_DIR .. "luajit/src",
-				CROWN_THIRD_DIR .. "openal/lib",
-				CROWN_THIRD_DIR .. "bgfx/.build/win32_vs2012/bin",
-				"$(PHYSX_SDK_WINDOWS)/Lib/win32",
-				"$(DXSDK_DIR)/Lib/x86",
-			}
+configuration { "x32", "linux-*" }
+	postbuildcommands {
+		"cp -r " .. CROWN_DIR .. ".build/linux32/bin/* " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux32/",
+		"cp    " .. CROWN_THIRD_DIR .. "luajit/src/luajit " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux32/",
+		"cp -r " .. CROWN_THIRD_DIR .. "luajit/src/jit " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux32/",
+	}
 
-		configuration { "x64", "vs*" }
-			defines { "_WIN64" }
+configuration { "x64", "linux-*" }
+	postbuildcommands {
+		"cp -r " .. CROWN_DIR .. ".build/linux64/bin/* " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux64/",
+		"cp    " .. CROWN_THIRD_DIR .. "luajit/src/luajit " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux64/",
+		"cp -r " .. CROWN_THIRD_DIR .. "luajit/src/jit " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux64/",
+	}
 
-			libdirs {
-				CROWN_THIRD_DIR .. "luajit/src",
-				CROWN_THIRD_DIR .. "openal/lib",
-				CROWN_THIRD_DIR .. "bgfx/.build/win64_vs2012/bin",
-				"$(PHYSX_SDK_WINDOWS)/Lib/win64",
-				"$(DXSDK_DIR)/Lib/x64",
-			}
+configuration { "x32", "vs*" }
+	postbuildcommands {
+		"cp -r " .. CROWN_DIR .. ".build/win32/bin/* " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win32/",
+		"cp    " .. CROWN_THIRD_DIR .. "luajit/src/luajit.exe " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win32/",
+		"cp -r " .. CROWN_THIRD_DIR .. "luajit/src/jit " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win32/",
+	}
 
-		configuration { "debug", "x32", "vs*"}
-			links {
-				"PhysX3CharacterKinematicCHECKED_x86",
-				"PhysX3CHECKED_x86",
-				"PhysX3CommonCHECKED_x86",
-				"PhysX3CookingCHECKED_x86",
-				"PhysX3ExtensionsCHECKED",
-				"bgfxDebug"
-			}
+configuration { "x64", "vs*" }
+	postbuildcommands {
+		"cp -r " .. CROWN_DIR .. ".build/win64/bin/* " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win64/",
+		"cp    " .. CROWN_THIRD_DIR .. "luajit/src/luajit.exe " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win64/",
+		"cp -r " .. CROWN_THIRD_DIR .. "luajit/src/jit " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win64/",
+	}
 
-		configuration { "debug", "x64", "vs*" }
-			links {
-				"PhysX3CharacterKinematicCHECKED_x64",
-				"PhysX3CHECKED_x64",
-				"PhysX3CommonCHECKED_x64",
-				"PhysX3CookingCHECKED_x64",
-				"PhysX3ExtensionsCHECKED",
-				"bgfxDebug"
-			}
+configuration { "debug or development", "x32", "linux-*" }
+	postbuildcommands {
+		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux32_gcc/bin/shadercDebug " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux32"
+	}
 
-		configuration { "development", "x32", "vs*" }
-			links {
-				"PhysX3CharacterKinematicPROFILE_x86",
-				"PhysX3PROFILE_x86",
-				"PhysX3CommonPROFILE_x86",
-				"PhysX3CookingPROFILE_x86",
-				"PhysX3ExtensionsPROFILE",
-				"bgfxDebug"
-			}
+configuration { "release", "x32", "linux-*" }
+	postbuildcommands {
+		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux32_gcc/bin/shadercRelease " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux32"
+	}
 
-		configuration { "development", "x64", "vs*" }
-			links {
-				"PhysX3CharacterKinematicPROFILE_x64",
-				"PhysX3PROFILE_x64",
-				"PhysX3CommonPROFILE_x64",
-				"PhysX3CookingPROFILE_x64",
-				"PhysX3ExtensionsPROFILE",
-				"bgfxDebug"
-			}
+configuration { "debug or development", "x64", "linux-*" }
+	postbuildcommands {
+		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux64_gcc/bin/shadercDebug " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux64"
+	}
 
-		configuration { "release", "x32", "vs*" }
-			links {
-				"PhysX3CharacterKinematic_x86",
-				"PhysX3_x86",
-				"PhysX3Common_x86",
-				"PhysX3Cooking_x86",
-				"PhysX3Extensions",
-				"bgfxRelease"
-			}
-			
-		configuration { "release", "x64", "vs*" }
-			links {
-				"PhysX3CharacterKinematic_x64",
-				"PhysX3_x64",
-				"PhysX3Common_x64",
-				"PhysX3Cooking_x64",
-				"PhysX3Extensions",
-				"bgfxRelease"
-			}
+configuration { "release", "x64", "linux-*" }
+	postbuildcommands {
+		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux64_gcc/bin/shadercRelease " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux64"
+	}

+ 304 - 0
premake/toolchain.lua

@@ -0,0 +1,304 @@
+function toolchain(build_dir, lib_dir)
+
+	newoption
+	{
+		trigger = "install-dir",
+		value = "DIR",
+		description = "Output directory"
+	}
+
+	newoption
+	{
+		trigger = "compiler",
+		value = "COMPILER",
+		description = "Choose compiler",
+		allowed =
+		{
+			{ "android-arm", "Android - ARM"          },
+			{ "linux-gcc",   "Linux (GCC compiler)"   }
+		}
+	}
+
+	if (_ACTION == nil) then return end
+
+	location (build_dir .. "projects/" .. _ACTION)
+
+	if _ACTION == "clean" then
+		os.rmdir(BUILD_DIR)
+	end
+
+	if _ACTION == "gmake" then
+
+		if nil == _OPTIONS["compiler"] then
+			print("Choose a compiler!")
+			os.exit(1)
+		end
+
+		if "linux-gcc" == _OPTIONS["compiler"] then
+
+			if not os.is("linux") then print("Action not valid in current OS.") end
+
+			if not os.getenv("PHYSX_SDK_LINUX") then
+				print("Set PHYSX_SDK_LINUX environment variable.")
+			end
+
+			location(build_dir .. "projects/" .. "linux")
+		end
+
+		if "android-arm" == _OPTIONS["compiler"] then
+
+			if not os.getenv("ANDROID_NDK_ROOT") then
+				print("Set ANDROID_NDK_ROOT environment variable.")
+			end
+			if not os.getenv("ANDROID_NDK_ARM") then
+				print("Set ANDROID_NDK_ARM environment variables.")
+			end
+			if not os.getenv("PHYSX_SDK_ANDROID") then
+				print("Set PHYSX_SDK_ANDROID environment variable.")
+			end
+
+			premake.gcc.cc = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-gcc"
+			premake.gcc.cxx = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-g++"
+			premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar"
+			location(build_dir .. "projects/" .. "android")
+		end
+	end
+
+	if _ACTION == "vs2012" then
+
+		if not os.is("windows") then print("Action not valid in current OS.") end
+
+		if not os.getenv("PHYSX_SDK_WINDOWS") then
+			print("Set PHYSX_SDK_WINDOWS environment variable.")
+		end
+		if not os.getenv("DXSDK_DIR") then
+			print("Set DXSDK_DIR environment variable.")
+		end
+
+		location(build_dir .. "projects/" .. "windows")
+	end
+
+	flags {
+		"StaticRuntime",
+		"NoPCH",
+		"NoRTTI",
+		"NoExceptions",
+		"NoMinimalRebuild",
+		"NoEditAndContinue",
+		"Symbols",
+	}
+
+	defines {
+		"__STDC_FORMAT_MACROS",
+		"__STDC_CONSTANT_MACROS",
+		"__STDC_LIMIT_MACROS",
+	}
+
+	configuration { "development" }
+		flags {
+			"OptimizeSpeed"
+		}
+
+	configuration { "release" }
+		flags {
+			"OptimizeSpeed"
+		}
+
+	configuration { "debug", "x32" }
+		targetsuffix "-debug-32"
+	configuration { "debug", "x64" }
+		targetsuffix "-debug-64"
+
+	configuration { "development", "x32" }
+		targetsuffix "-development-32"
+	configuration { "development", "x64" }
+		targetsuffix "-development-64"
+
+	configuration { "release", "x32" }
+		targetsuffix "-release-32"
+	configuration { "release", "x64" }
+		targetsuffix "-release-64"
+
+	configuration { "debug", "native" }
+		targetsuffix "-debug"
+
+	configuration { "development", "native" }
+		targetsuffix "-development"
+
+	configuration { "release", "native" }
+		targetsuffix "-release"
+
+	configuration { "x32", "linux-*" }
+		targetdir (build_dir .. "linux32" .. "/bin")
+		objdir (build_dir .. "linux32" .. "/obj")
+		libdirs {
+			lib_dir .. "luajit/src",
+			lib_dir .. "bgfx/.build/linux32_gcc/bin",
+			"$(PHYSX_SDK_LINUX)/Lib/linux32"
+		}
+		buildoptions {
+			"-m32",
+			"-malign-double", -- Required by PhysX
+		}
+
+	configuration { "x64", "linux-*" }
+		targetdir (build_dir .. "linux64" .. "/bin")
+		objdir (build_dir .. "linux64" .. "/obj")
+		libdirs {
+			lib_dir .. "luajit/src",
+			lib_dir .. "bgfx/.build/linux64_gcc/bin",
+			"$(PHYSX_SDK_LINUX)/Lib/linux64"
+		}
+		buildoptions {
+			"-m64",
+		}
+
+	configuration { "linux-*" }
+		buildoptions {
+			"-std=c++03",
+			"-Wall",
+			"-Wextra",
+			-- "-Werror",
+			-- "-pedantic",
+			"-Wno-unknown-pragmas",
+			"-Wno-unused-local-typedefs",
+		}
+		linkoptions {
+			"-Wl,-rpath=\\$$ORIGIN",
+			"-Wl,--no-as-needed",
+		}
+
+	configuration { "android-*" }
+		flags {
+			"NoImportLib"
+		}
+		includedirs {
+			"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/include",
+			"$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
+		}
+		linkoptions {
+			"-nostdlib",
+			"-static-libgcc",
+		}
+		links {
+			":libluajit.a",
+			"bgfxDebug",
+			"c",
+			"dl",
+			"m",
+			"android",
+			"log",
+			"gnustl_static",
+			"gcc",
+		}
+		buildoptions {
+			"-fPIC",
+			"-std=c++03",
+			"-no-canonical-prefixes",
+			"-Wa,--noexecstack",
+			"-fstack-protector",
+			"-ffunction-sections",
+			"-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
+			"-Wunused-value",
+			-- "-Wundef", -- note: avoids PhysX warnings
+		}
+		linkoptions {
+			"-no-canonical-prefixes",
+			"-Wl,--no-undefined",
+			"-Wl,-z,noexecstack",
+			"-Wl,-z,relro",
+			"-Wl,-z,now",
+		}
+
+	configuration { "android-arm" }
+		targetdir (build_dir .. "android-arm" .. "/bin")
+		objdir (build_dir .. "android-arm" .. "/obj")
+		libdirs {
+			lib_dir .. "luajit/src",
+			lib_dir .. "bgfx/.build/android-arm/bin",
+			"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a",
+			"$(PHYSX_SDK_ANDROID)/Lib/android9_neon",
+		}
+		includedirs {
+			"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include",
+		}
+		buildoptions {
+			"--sysroot=$(ANDROID_NDK_ROOT)/platforms/android-14/arch-arm",
+			"-mthumb",
+			"-march=armv7-a",
+			"-mfloat-abi=softfp",
+			"-mfpu=neon",
+			"-Wunused-value",
+			-- "-Wundef", -- note: avoids PhysX warnings
+		}
+		linkoptions {
+			"--sysroot=$(ANDROID_NDK_ROOT)/platforms/android-14/arch-arm",
+			"$(ANDROID_NDK_ROOT)/platforms/android-14/arch-arm/usr/lib/crtbegin_so.o",
+			"$(ANDROID_NDK_ROOT)/platforms/android-14/arch-arm/usr/lib/crtend_so.o",
+			"-march=armv7-a",
+			"-Wl,--fix-cortex-a8",
+		}
+
+	configuration { "vs*" }
+		includedirs { CROWN_DIR .. "engine/core/compat/msvc" }
+		defines {
+			"WIN32",
+			"_WIN32",
+			"_HAS_EXCEPTIONS=0",
+			"_HAS_ITERATOR_DEBUGGING=0",
+			"_SCL_SECURE=0",
+			"_SECURE_SCL=0",
+			"_SCL_SECURE_NO_WARNINGS",
+			"_CRT_SECURE_NO_WARNINGS",
+			"_CRT_SECURE_NO_DEPRECATE",
+		}
+		buildoptions {
+			"/Oy-", -- Suppresses creation of frame pointers on the call stack.
+			"/Ob2", -- The Inline Function Expansion
+		}
+		linkoptions {
+			"/ignore:4199", -- LNK4199: /DELAYLOAD:*.dll ignored; no imports found from *.dll
+			"/ignore:4221", -- LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
+		}
+
+	configuration { "x32", "vs*" }
+		targetdir (build_dir .. "win32" .. "/bin")
+		objdir (build_dir .. "win32" .. "/obj")
+		libdirs {
+			lib_dir .. "luajit/src",
+			lib_dir .. "openal/lib",
+			lib_dir .. "bgfx/.build/win32_vs2012/bin",
+			"$(PHYSX_SDK_WINDOWS)/Lib/win32",
+			"$(DXSDK_DIR)/Lib/x86",
+		}
+
+	configuration { "x64", "vs*" }
+		targetdir (build_dir .. "win64" .. "/bin")
+		objdir (build_dir .. "win64" .. "/obj")
+		libdirs {
+			lib_dir .. "luajit/src",
+			lib_dir .. "openal/lib",
+			lib_dir .. "bgfx/.build/win64_vs2012/bin",
+			"$(PHYSX_SDK_WINDOWS)/Lib/win64",
+			"$(DXSDK_DIR)/Lib/x64",
+		}
+
+	configuration {} -- reset configuration
+end
+
+function strip()
+
+	configuration { "android-arm", "release"}
+		postbuildcommands {
+			"$(SILENT) echo Stripping symbols",
+			"$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
+		}
+
+	configuration { "linux-*", "release" }
+		postbuildcommands {
+			"$(SILENT) echo Stripping symbols",
+			"$(SILENT) strip -s \"$(TARGET)\""
+		}
+
+	configuration {} -- reset configuration
+end