From 0ebfe75db3c72ad6fca84403842d4487ed0cbb99 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sat, 8 Dec 2012 15:24:51 -0800 Subject: [PATCH] Added PNaCl build support. --- makefile | 6 ++++++ premake/bgfx.lua | 2 +- premake/premake4.lua | 34 ++++++++++++++++++++++++++++++++-- src/renderer_gl.cpp | 4 ++-- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index cc14fd5a4..b51623747 100644 --- a/makefile +++ b/makefile @@ -7,6 +7,7 @@ all: premake --file=premake/premake4.lua vs2008 premake --file=premake/premake4.lua vs2010 premake --file=premake/premake4.lua --gcc=nacl gmake + premake --file=premake/premake4.lua --gcc=pnacl gmake premake --file=premake/premake4.lua --gcc=mingw gmake premake --file=premake/premake4.lua --gcc=linux gmake premake --file=premake/premake4.lua --gcc=emscripten gmake @@ -42,6 +43,11 @@ nacl-release64: make -C .build/projects/gmake-nacl config=release64 nacl: nacl-debug32 nacl-release32 nacl-debug64 nacl-release64 +pnacl-debug: + make -C .build/projects/gmake-pnacl config=debug64 +pnacl-release: + make -C .build/projects/gmake-pnacl config=release64 + docs: # doxygen premake/bgfx.doxygen markdown README.md > .build/docs/readme.html diff --git a/premake/bgfx.lua b/premake/bgfx.lua index a5634143e..c3f7fcf47 100644 --- a/premake/bgfx.lua +++ b/premake/bgfx.lua @@ -47,4 +47,4 @@ project "bgfx" BGFX_DIR .. "src/**.bin.h", } --- copyLib() + copyLib() diff --git a/premake/premake4.lua b/premake/premake4.lua index 5753df763..1f2527268 100644 --- a/premake/premake4.lua +++ b/premake/premake4.lua @@ -25,7 +25,8 @@ newoption { { "emscripten", "Emscripten" }, { "linux", "Linux" }, { "mingw", "MinGW" }, - { "nacl", "Google Native Client" }, + { "nacl", "Native Client" }, + { "pnacl", "Native Client - PNaCl" }, } } @@ -36,7 +37,7 @@ BGFX_DIR = (path.getabsolute("..") .. "/") local BGFX_BUILD_DIR = (BGFX_DIR .. ".build/") local BGFX_THIRD_PARTY_DIR = (BGFX_DIR .. "3rdparty/") -BX_DIR = (BGFX_DIR .. "/../../bx/") +BX_DIR = (BGFX_DIR .. "../bx/") local XEDK = os.getenv("XEDK") if not XEDK then XEDK = "" end @@ -92,6 +93,18 @@ if _ACTION == "gmake" then premake.gcc.ar = "$(NACL)/bin/x86_64-nacl-ar" location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-nacl") end + + if "pnacl" == _OPTIONS["gcc"] then + + if not os.getenv("PNACL") then + print("Set PNACL enviroment variables.") + end + + premake.gcc.cc = "$(PNACL)/bin/pnacl-clang" + premake.gcc.cxx = "$(PNACL)/bin/pnacl-clang++" + premake.gcc.ar = "$(PNACL)/bin/pnacl-ar" + location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-pnacl") + end end flags { @@ -248,6 +261,23 @@ configuration { "x64", "nacl" } libdirs { BGFX_THIRD_PARTY_DIR .. "lib/nacl-x64" } linkoptions { "-melf64_nacl" } +configuration { "pnacl" } + defines { "_BSD_SOURCE=1", "_POSIX_C_SOURCE=199506", "_XOPEN_SOURCE=600", "__native_client__", "__LITTLE_ENDIAN__" } + includedirs { BX_DIR .. "include/compat/nacl" } + buildoptions { + "-std=c++0x", + "-U__STRICT_ANSI__", + "-fno-stack-protector", + "-fdiagnostics-show-option", + "-Wunused-value", + "-fdata-sections", + "-ffunction-sections", + } + targetdir (BGFX_BUILD_DIR .. "pnacl" .. "/bin") + objdir (BGFX_BUILD_DIR .. "pnacl" .. "/obj") + libdirs { BGFX_THIRD_PARTY_DIR .. "lib/pnacl" } + includedirs { "$(PNACL)/sysroot/include" } + configuration { "Xbox360" } targetdir (BGFX_BUILD_DIR .. "xbox360" .. "/bin") objdir (BGFX_BUILD_DIR .. "xbox360" .. "/obj") diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 81f31610c..38f7a79aa 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -135,8 +135,8 @@ namespace bgfx PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8, PP_GRAPHICS3DATTRIB_SAMPLES, 0, PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0, - PP_GRAPHICS3DATTRIB_WIDTH, _width, - PP_GRAPHICS3DATTRIB_HEIGHT, _height, + PP_GRAPHICS3DATTRIB_WIDTH, int32_t(_width), + PP_GRAPHICS3DATTRIB_HEIGHT, int32_t(_height), PP_GRAPHICS3DATTRIB_NONE };