Преглед изворни кода

Build bgfx and shaderc with GENie

Daniele Bartolini пре 11 година
родитељ
комит
331ad73436
4 измењених фајлова са 168 додато и 137 уклоњено
  1. 10 39
      genie/crown.lua
  2. 18 46
      genie/genie.lua
  3. 125 0
      genie/shaderc.lua
  4. 15 52
      makefile

+ 10 - 39
genie/crown.lua

@@ -38,6 +38,14 @@ function crown_project(_name, _kind, _defines)
 			CROWN_DIR .. "third/bx/include",
 		}
 
+		defines {
+			_defines,
+		}
+
+		links {
+			"bgfx"
+		}
+
 		if _OPTIONS["with-openal"] then
 			includedirs {
 				CROWN_DIR .. "third/openal/include"
@@ -61,20 +69,7 @@ function crown_project(_name, _kind, _defines)
 				links { "openal", }
 		end
 
-		defines {
-			_defines,
-		}
-
-		configuration { "debug" }
-			flags {
-				"Symbols"
-			}
-			defines {
-				"_DEBUG",
-				"CROWN_DEBUG"
-			}
-
-		configuration { "development" }
+		configuration { "debug or development" }
 			flags {
 				"Symbols"
 			}
@@ -163,9 +158,6 @@ function crown_project(_name, _kind, _defines)
 			}
 
 		configuration { "debug", "linux-*" }
-			links {
-				"bgfxDebug"
-			}
 			linkoptions {
 				"-rdynamic",
 				"-Wl,--start-group $(addprefix -l," ..
@@ -187,9 +179,6 @@ function crown_project(_name, _kind, _defines)
 			}
 
 		configuration { "development", "linux-*" }
-			links {
-				"bgfxDebug"
-			}
 			linkoptions
 			{
 				"-rdynamic",
@@ -212,9 +201,6 @@ function crown_project(_name, _kind, _defines)
 			}
 
 		configuration { "release", "linux-*" }
-			links {
-				"bgfxRelease"
-			}
 			linkoptions {
 				"-Wl,--start-group $(addprefix -l," ..
 				"	LowLevelCloth" ..
@@ -248,9 +234,6 @@ function crown_project(_name, _kind, _defines)
 			}
 
 		configuration { "debug", "android-arm" }
-			links {
-				":libbgfxDebug.a",
-			}
 			linkoptions {
 				"-Wl,--start-group $(addprefix -l," ..
 				"	LowLevelCloth" ..
@@ -271,9 +254,6 @@ function crown_project(_name, _kind, _defines)
 			}
 
 		configuration { "development", "android-arm" }
-			links {
-				":libbgfxDebug.a",
-			}
 			linkoptions {
 				"-Wl,--start-group $(addprefix -l," ..
 				"	LowLevelCloth" ..
@@ -294,9 +274,6 @@ function crown_project(_name, _kind, _defines)
 			}
 
 		configuration { "release", "android-arm" }
-			links {
-				":libbgfxRelease.a",
-			}
 			linkoptions {
 				"-Wl,--start-group $(addprefix -l," ..
 				"	LowLevelCloth" ..
@@ -320,12 +297,11 @@ function crown_project(_name, _kind, _defines)
 			links {
 				"OpenGL32",
 				"lua51",
-				"dbghelp"
+				"dbghelp",
 			}
 
 		configuration { "debug", "x32", "vs*"}
 			links {
-				"bgfxDebug",
 				"PhysX3CharacterKinematicCHECKED_x86",
 				"PhysX3CHECKED_x86",
 				"PhysX3CommonCHECKED_x86",
@@ -335,7 +311,6 @@ function crown_project(_name, _kind, _defines)
 
 		configuration { "debug", "x64", "vs*" }
 			links {
-				"bgfxDebug",
 				"PhysX3CharacterKinematicCHECKED_x64",
 				"PhysX3CHECKED_x64",
 				"PhysX3CommonCHECKED_x64",
@@ -345,7 +320,6 @@ function crown_project(_name, _kind, _defines)
 
 		configuration { "development", "x32", "vs*" }
 			links {
-				"bgfxDebug",
 				"PhysX3CharacterKinematicPROFILE_x86",
 				"PhysX3PROFILE_x86",
 				"PhysX3CommonPROFILE_x86",
@@ -355,7 +329,6 @@ function crown_project(_name, _kind, _defines)
 
 		configuration { "development", "x64", "vs*" }
 			links {
-				"bgfxDebug",
 				"PhysX3CharacterKinematicPROFILE_x64",
 				"PhysX3PROFILE_x64",
 				"PhysX3CommonPROFILE_x64",
@@ -365,7 +338,6 @@ function crown_project(_name, _kind, _defines)
 
 		configuration { "release", "x32", "vs*" }
 			links {
-				"bgfxRelease",
 				"PhysX3CharacterKinematic_x86",
 				"PhysX3_x86",
 				"PhysX3Common_x86",
@@ -375,7 +347,6 @@ function crown_project(_name, _kind, _defines)
 
 		configuration { "release", "x64", "vs*" }
 			links {
-				"bgfxRelease",
 				"PhysX3CharacterKinematic_x64",
 				"PhysX3_x64",
 				"PhysX3Common_x64",

+ 18 - 46
genie/genie.lua

@@ -3,6 +3,15 @@
 -- License: https://github.com/taylor001/crown/blob/master/LICENSE
 --
 
+CROWN_DIR = (path.getabsolute("..") .. "/")
+local CROWN_THIRD_DIR = (CROWN_DIR .. "third/")
+local CROWN_BUILD_DIR = (CROWN_DIR .. ".build/")
+BGFX_DIR = (CROWN_DIR .. "third/bgfx/")
+BX_DIR = (CROWN_DIR .. "third/bx/")
+
+function copyLib()
+end
+
 newoption {
 	trigger = "with-openal",
 	description = "Build with OpenAL support."
@@ -23,21 +32,26 @@ solution "crown"
 
 	language "C++"
 
-CROWN_DIR = (path.getabsolute("..") .. "/")
-local CROWN_THIRD_DIR = (CROWN_DIR .. "third/")
-local CROWN_BUILD_DIR = (CROWN_DIR .. ".build/")
+	configuration {}
+
 dofile ("toolchain.lua")
+dofile (BGFX_DIR .. "scripts/bgfx.lua")
+dofile ("crown.lua")
+
 toolchain(CROWN_BUILD_DIR, CROWN_THIRD_DIR)
 
 group "libs"
+bgfxProject("", "StaticLib", os.is("windows") and { "BGFX_CONFIG_RENDERER_DIRECT3D9=1" } or {})
+
 if _OPTIONS["with-openal"] then
 	dofile ("openal.lua")
 end
 
 group "engine"
-dofile "crown.lua"
 crown_project("", "ConsoleApp", {})
 
+dofile ("shaderc.lua")
+
 -- Install
 configuration { "android-arm" }
 	postbuildcommands {
@@ -81,45 +95,3 @@ configuration { "x64", "vs*" }
 		"cp    " .. "$(PHYSX_SDK_WINDOWS)/bin/win64/PhysX3* " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win64",
 		"cp    " .. "$(PHYSX_SDK_WINDOWS)/bin/win64/nvToolsExt64_1.dll " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win64",
 	}
-
-configuration { "debug or development", "x32", "linux-*" }
-	postbuildcommands {
-		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux32_gcc/bin/shadercDebug " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux32"
-	}
-
-configuration { "release", "x32", "linux-*" }
-	postbuildcommands {
-		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux32_gcc/bin/shadercRelease " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux32"
-	}
-
-configuration { "debug or development", "x64", "linux-*" }
-	postbuildcommands {
-		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux64_gcc/bin/shadercDebug " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux64"
-	}
-
-configuration { "release", "x64", "linux-*" }
-	postbuildcommands {
-		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/linux64_gcc/bin/shadercRelease " .. "$(CROWN_INSTALL_DIR)/" .. "bin/linux64"
-	}
-
-
-configuration { "debug or development", "x32", "vs*" }
-	postbuildcommands {
-		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/win32_vs2013/bin/shadercDebug.exe " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win32"
-	}
-
-configuration { "release", "x32", "vs*" }
-	postbuildcommands {
-		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/win32_vs2013/bin/shadercRelease.exe " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win32"
-	}
-
-configuration { "debug or development", "x64", "vs*" }
-	postbuildcommands {
-		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/win64_vs2013/bin/shadercDebug.exe " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win64"
-	}
-
-configuration { "release", "x64", "vs*" }
-	postbuildcommands {
-		"cp " .. CROWN_THIRD_DIR .. "bgfx/.build/win64_vs2013/bin/shadercRelease.exe " .. "$(CROWN_INSTALL_DIR)/" .. "bin/win64"
-	}
-

+ 125 - 0
genie/shaderc.lua

@@ -0,0 +1,125 @@
+--
+-- Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
+-- License: https://github.com/taylor001/crown/blob/master/LICENSE
+--
+
+--
+-- Copyright 2010-2015 Branimir Karadzic. All rights reserved.
+-- License: http://www.opensource.org/licenses/BSD-2-Clause
+--
+
+project "shaderc"
+	uuid "f3cd2e90-52a4-11e1-b86c-0800200c9a66"
+	kind "ConsoleApp"
+
+	local GLSL_OPTIMIZER = path.join(BGFX_DIR, "3rdparty/glsl-optimizer")
+	local FCPP_DIR = path.join(BGFX_DIR, "3rdparty/fcpp")
+
+	includedirs {
+		path.join(GLSL_OPTIMIZER, "src"),
+	}
+
+	configuration { "vs*" }
+		includedirs {
+			path.join(GLSL_OPTIMIZER, "src/glsl/msvc"),
+		}
+
+		defines { -- glsl-optimizer
+			"__STDC__",
+			"__STDC_VERSION__=199901L",
+			"strdup=_strdup",
+			"alloca=_alloca",
+			"isascii=__isascii",
+		}
+
+		buildoptions {
+			"/wd4996" -- warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup.
+		}
+
+	configuration { "mingw* or linux or osx" }
+		removebuildoptions {
+			"-std=c++03"
+		}
+
+		buildoptions {
+			"-std=c++11",
+			"-fno-strict-aliasing" -- glsl-optimizer has bugs if strict aliasing is used.
+		}
+
+	configuration { "osx" }
+		links {
+			"Cocoa.framework",
+		}
+
+	configuration { "windows", "vs*" }
+		includedirs {
+			path.join(GLSL_OPTIMIZER, "include/c99"),
+		}
+
+	configuration { "windows" }
+		includedirs {
+			"$(DXSDK_DIR)/include",
+		}
+
+		links {
+			"d3dx9",
+			"d3dcompiler",
+			"dxguid",
+		}
+
+	configuration {}
+
+	defines { -- fcpp
+		"NINCLUDE=64",
+		"NWORK=65536",
+		"NBUFF=65536",
+		"OLD_PREPROCESSOR=0",
+	}
+
+	includedirs {
+		path.join(BX_DIR, "include"),
+		path.join(BGFX_DIR, "include"),
+
+		FCPP_DIR,
+
+		path.join(GLSL_OPTIMIZER, "include"),
+		path.join(GLSL_OPTIMIZER, "src/mesa"),
+		path.join(GLSL_OPTIMIZER, "src/mapi"),
+		path.join(GLSL_OPTIMIZER, "src/glsl"),
+	}
+
+	files {
+		path.join(BGFX_DIR, "tools/shaderc/**.cpp"),
+		path.join(BGFX_DIR, "tools/shaderc/**.h"),
+		path.join(BGFX_DIR, "src/vertexdecl.**"),
+
+		path.join(FCPP_DIR, "**.h"),
+		path.join(FCPP_DIR, "cpp1.c"),
+		path.join(FCPP_DIR, "cpp2.c"),
+		path.join(FCPP_DIR, "cpp3.c"),
+		path.join(FCPP_DIR, "cpp4.c"),
+		path.join(FCPP_DIR, "cpp5.c"),
+		path.join(FCPP_DIR, "cpp6.c"),
+		path.join(FCPP_DIR, "cpp6.c"),
+
+		path.join(GLSL_OPTIMIZER, "src/mesa/**.c"),
+		path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"),
+		path.join(GLSL_OPTIMIZER, "src/mesa/**.h"),
+		path.join(GLSL_OPTIMIZER, "src/glsl/**.c"),
+		path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"),
+		path.join(GLSL_OPTIMIZER, "src/glsl/**.h"),
+		path.join(GLSL_OPTIMIZER, "src/util/**.c"),
+		path.join(GLSL_OPTIMIZER, "src/util/**.h"),
+	}
+
+	excludes {
+		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp.c"),
+		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/tests/**"),
+		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.l"),
+		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.y"),
+		path.join(GLSL_OPTIMIZER, "src/glsl/ir_set_program_inouts.cpp"),
+		path.join(GLSL_OPTIMIZER, "src/glsl/main.cpp"),
+		path.join(GLSL_OPTIMIZER, "src/glsl/builtin_stubs.cpp"),
+	}
+
+	strip()

+ 15 - 52
makefile

@@ -26,81 +26,45 @@ luajit-arm:
 	TARGET_FLAGS="--sysroot $(ANDROID_NDK_ROOT)/platforms/android-14/arch-arm \
 		-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8"
 
-bgfx-linux-debug32:
-	make -R -C third/bgfx linux-debug32
-bgfx-linux-debug64:
-	make -R -C third/bgfx linux-debug64
-bgfx-linux-release32:
-	make -R -C third/bgfx linux-release32
-bgfx-linux-release64:
-	make -R -C third/bgfx linux-release64
-bgfx-vs2013-debug32:
-	make -R -C third/bgfx .build/projects/vs2013
-	devenv third/bgfx/.build/projects/vs2013/bgfx.sln /Build "debug|Win32"
-bgfx-vs2013-release32:
-	make -R -C third/bgfx .build/projects/vs2013
-	devenv third/bgfx/.build/projects/vs2013/bgfx.sln /Build "release|Win32"
-bgfx-vs2013-debug64:
-	make -R -C third/bgfx .build/projects/vs2013
-	devenv third/bgfx/.build/projects/vs2013/bgfx.sln /Build "debug|x64"
-bgfx-vs2013-release64:
-	make -R -C third/bgfx .build/projects/vs2013
-	devenv third/bgfx/.build/projects/vs2013/bgfx.sln /Build "release|x64"
-bgfx-android-arm-debug:
-	make -R -C third/bgfx android-arm-debug
-bgfx-android-arm-release:
-	make -R -C third/bgfx android-arm-release
-
-deps-linux-debug32: luajit-linux32 bgfx-linux-debug32
-deps-linux-debug64: luajit-linux64 bgfx-linux-debug64
-deps-linux-release32: luajit-linux32 bgfx-linux-release32
-deps-linux-release64: luajit-linux64 bgfx-linux-release64
-deps-windows-debug32: luajit-windows32 bgfx-vs2013-debug32
-deps-windows-debug64: luajit-windows64 bgfx-vs2013-debug64
-deps-windows-release32: luajit-windows32 bgfx-vs2013-release32
-deps-windows-release64: luajit-windows64 bgfx-vs2013-release64
-deps-android-arm-debug: luajit-arm bgfx-android-arm-debug
-deps-android-arm-release: luajit-arm bgfx-android-arm-release
-
 linux-build:
 	$(GENIE) --file=genie/genie.lua --with-openal --compiler=linux-gcc gmake
-linux-debug32: deps-linux-debug32 linux-build
+linux-debug32: luajit-linux32 linux-build
 	make -R -C .build/projects/linux config=debug32
-linux-development32: deps-linux-debug32 linux-build
+linux-development32: luajit-linux32 linux-build
 	make -R -C .build/projects/linux config=development32
-linux-release32: deps-linux-release32 linux-build
+linux-release32: luajit-linux32 linux-build
 	make -R -C .build/projects/linux config=release32
-linux-debug64: deps-linux-debug64 linux-build
+linux-debug64: luajit-linux64 linux-build
 	make -R -C .build/projects/linux config=debug64
-linux-development64: deps-linux-debug64 linux-build
+linux-development64: luajit-linux64 linux-build
 	make -R -C .build/projects/linux config=development64
-linux-release64: deps-linux-release64 linux-build
+linux-release64: luajit-linux64 linux-build
 	make -R -C .build/projects/linux config=release64
 linux: linux-debug32 linux-development32 linux-release32 linux-debug64 linux-development64 linux-release64
 
 android-build:
 	$(GENIE) --file=genie/genie.lua --compiler=android-arm gmake
-android-arm-debug: deps-android-arm-debug android-build
+android-arm-debug: luajit-arm android-build
 	make -R -C .build/projects/android config=debug
-android-arm-development: deps-android-arm-debug android-build
+android-arm-development: luajit-arm android-build
 	make -R -C .build/projects/android config=development
-android-arm-release: deps-android-arm-release android-build
+android-arm-release: luajit-arm android-build
 	make -R -C .build/projects/android config=release
 android-arm: android-arm-debug android-arm-development android-arm-release
 
 windows-build:
 	$(GENIE) --file=genie\genie.lua --with-openal vs2013
-windows-debug32: deps-windows-debug32 windows-build
+windows-debug32: luajit-windows32 windows-build
 	devenv .build/projects/vs2013/crown.sln /Build "debug|Win32"
-windows-development32: deps-windows-debug32 windows-build
+windows-development32: luajit-windows32 windows-build
 	devenv .build/projects/vs2013/crown.sln /Build "development|Win32"
-windows-release32: deps-windows-release32 windows-build
+windows-release32: luajit-windows32 windows-build
 	devenv .build/projects/vs2013/crown.sln /Build "release|Win32"
-windows-debug64: deps-windows-debug64 windows-build
+windows-debug64: luajit-windows64 windows-build
 	devenv .build/projects/vs2013/crown.sln /Build "debug|x64"
-windows-development64: deps-windows-debug64 windows-build
+windows-development64: luajit-windows64 windows-build
 	devenv .build/projects/vs2013/crown.sln /Build "development|x64"
-windows-release64: deps-windows-release64 windows-build
+windows-release64: luajit-windows64 windows-build
 	devenv .build/projects/vs2013/crown.sln /Build "release|x64"
 
 .PHONY: docs
@@ -112,5 +76,4 @@ docs:
 clean:
 	@echo Cleaning...
 	-@rm -rf .build
-	-@rm -rf third/bgfx/.build
 	make -R -C third/luajit clean