mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
* Adjustment: Initial CMake reworking.
This commit is contained in:
parent
516163fd5d
commit
d7cdf54661
5394 changed files with 2615532 additions and 8711 deletions
49
Engine/lib/bullet/build3/Android/jni/Android.mk
Normal file
49
Engine/lib/bullet/build3/Android/jni/Android.mk
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
LOCAL_PATH := ../../..
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -DUSE_PTHREADS -mfpu=neon -mfloat-abi=softfp -pthread -DSCE_PFX_USE_SIMD_VECTORMATH
|
||||
|
||||
# apply these flags if needed
|
||||
# -ffast-math -funsafe-math-optimizations
|
||||
|
||||
# apply this to disable optimization
|
||||
# TARGET_CFLAGS := $(TARGET_CFLAGS) -O0
|
||||
|
||||
# apply these 2 to turn on assembly output (*.c/*.cpp to *.s file)
|
||||
#compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.s)))
|
||||
#TARGET_CFLAGS := $(TARGET_CFLAGS) -S
|
||||
|
||||
# Enable or disable NEON. Don't forget to apply, or not apply, -mfpu=neon and -mfloat-abi=softfp
|
||||
# flags in addition, e.g., if this is true both of those need to be included in LOCAL_CFLAGS
|
||||
# to avoid the possibility that ndk-build will "forget" to add them on some files
|
||||
LOCAL_ARM_NEON := true
|
||||
|
||||
TARGET_CFLAGS := $(filter-out -ffpu=vfp,$(TARGET_CFLAGS))
|
||||
|
||||
# setup to build static library
|
||||
LOCAL_MODULE := libBullet
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/src
|
||||
|
||||
#find all the file recursively under jni/
|
||||
FILE_LIST := $(wildcard \
|
||||
$(LOCAL_PATH)/src/LinearMath/*.cpp \
|
||||
$(LOCAL_PATH)/src/Bullet3Common/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletCollision/BroadphaseCollision/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletCollision/CollisionDispatch/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletCollision/CollisionShapes/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletCollision/NarrowPhaseCollision/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletDynamics/ConstraintSolver/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletDynamics/Dynamics/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletDynamics/Featherstone/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletDynamics/MLCPSolvers/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletDynamics/Vehicle/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletDynamics/Character/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletSoftBody/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletInverseDynamics/*.cpp \
|
||||
$(LOCAL_PATH)/src/BulletInverseDynamics/details/*.cpp \
|
||||
)
|
||||
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
7
Engine/lib/bullet/build3/Android/jni/Application.mk
Normal file
7
Engine/lib/bullet/build3/Android/jni/Application.mk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
APP_MODULES := libBullet
|
||||
APP_ABI := armeabi-v7a
|
||||
APP_OPTIM := release
|
||||
|
||||
#We only need STL for placement new (#include <new>)
|
||||
#We don't use STL in Bullet
|
||||
APP_STL := stlport_static
|
||||
7
Engine/lib/bullet/build3/bin2cpp.bat
Normal file
7
Engine/lib/bullet/build3/bin2cpp.bat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
rem @echo off
|
||||
|
||||
|
||||
premake4 --file=bin2cpp.lua --binfile="../btgui/OpenGLWindow/OpenSans.ttf" --cppfile="../btgui/OpenGLWindow/OpenSans.cpp" --stringname="OpenSansData" bin2cpp
|
||||
|
||||
pause
|
||||
48
Engine/lib/bullet/build3/bin2cpp.lua
Normal file
48
Engine/lib/bullet/build3/bin2cpp.lua
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
function convertFile(filenameIn, filenameOut, stringname)
|
||||
print("\nfilenameOut = " .. filenameOut)
|
||||
local f = assert(io.open(filenameIn, "rb"))
|
||||
|
||||
local fw = io.open(filenameOut,"w")
|
||||
fw:write(string.format("char %s[]={", stringname))
|
||||
local block = 10
|
||||
while true do
|
||||
local bytes = f:read(block)
|
||||
if not bytes then break end
|
||||
for b in string.gfind(bytes, ".") do
|
||||
fw:write(string.format("%u,", string.byte(b)))
|
||||
end
|
||||
--io.write(string.rep(" ", block - string.len(bytes) + 1))
|
||||
--io.write(string.gsub(bytes, "%c", "."), "\n")
|
||||
fw:write(string.format("\n"))
|
||||
end
|
||||
fw:write(string.format("\n};"))
|
||||
|
||||
end
|
||||
|
||||
|
||||
newoption {
|
||||
trigger = "binfile",
|
||||
value = "binpath",
|
||||
description = "full path to the binary input file"
|
||||
}
|
||||
|
||||
newoption {
|
||||
trigger = "cppfile",
|
||||
value = "path",
|
||||
description = "full path to the cpp output file"
|
||||
}
|
||||
|
||||
newoption {
|
||||
trigger = "stringname",
|
||||
value = "var",
|
||||
description = "name of the variable name in the cppfile that contains the binary data"
|
||||
}
|
||||
|
||||
newaction {
|
||||
trigger = "bin2cpp",
|
||||
description = "convert binary file into cpp source",
|
||||
execute = function ()
|
||||
convertFile( _OPTIONS["binfile"] , _OPTIONS["cppfile"], _OPTIONS["stringname"])
|
||||
|
||||
end
|
||||
}
|
||||
17
Engine/lib/bullet/build3/bullet.rc
Normal file
17
Engine/lib/bullet/build3/bullet.rc
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// This file is generated automatically.
|
||||
|
||||
1 VERSIONINFO
|
||||
FILEFLAGS 0x0
|
||||
{
|
||||
BLOCK "StringFileInfo"
|
||||
{
|
||||
BLOCK "040904E4"
|
||||
{
|
||||
VALUE "ProductName", "Bullet Physics Library"
|
||||
VALUE "LegalCopyright", "Copyright (c) 2005-2014 Erwin Coumans"
|
||||
VALUE "Comments", "Test build"
|
||||
VALUE "WWW", "http://www.bulletphysics.org"
|
||||
}
|
||||
}
|
||||
}
|
||||
1 ICON "bullet_ico.ico"
|
||||
BIN
Engine/lib/bullet/build3/bullet_ico.ico
Normal file
BIN
Engine/lib/bullet/build3/bullet_ico.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
41
Engine/lib/bullet/build3/cmake/FindNumPy.cmake
Normal file
41
Engine/lib/bullet/build3/cmake/FindNumPy.cmake
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# Find the Python NumPy package
|
||||
# PYTHON_NUMPY_INCLUDE_DIR
|
||||
# PYTHON_NUMPY_FOUND
|
||||
# will be set by this script
|
||||
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
if(NOT PYTHON_EXECUTABLE)
|
||||
if(NumPy_FIND_QUIETLY)
|
||||
find_package(PythonInterp QUIET)
|
||||
else()
|
||||
find_package(PythonInterp)
|
||||
set(__numpy_out 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (PYTHON_EXECUTABLE)
|
||||
# Find out the include path
|
||||
execute_process(
|
||||
COMMAND "${PYTHON_EXECUTABLE}" -c
|
||||
"from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n"
|
||||
OUTPUT_VARIABLE __numpy_path)
|
||||
# And the version
|
||||
execute_process(
|
||||
COMMAND "${PYTHON_EXECUTABLE}" -c
|
||||
"from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n"
|
||||
OUTPUT_VARIABLE __numpy_version)
|
||||
elseif(__numpy_out)
|
||||
message(STATUS "Python executable not found.")
|
||||
endif(PYTHON_EXECUTABLE)
|
||||
|
||||
find_path(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h
|
||||
HINTS "${__numpy_path}" "${PYTHON_INCLUDE_PATH}" NO_DEFAULT_PATH)
|
||||
|
||||
if(PYTHON_NUMPY_INCLUDE_DIR)
|
||||
set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy found")
|
||||
endif(PYTHON_NUMPY_INCLUDE_DIR)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(NumPy REQUIRED_VARS PYTHON_NUMPY_INCLUDE_DIR
|
||||
VERSION_VAR __numpy_version)
|
||||
36
Engine/lib/bullet/build3/findDirectX11.lua
Normal file
36
Engine/lib/bullet/build3/findDirectX11.lua
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
function findDirectX11()
|
||||
local dx11path = os.getenv("DXSDK_DIR")
|
||||
if (dx11path) then
|
||||
local filepath = string.format("%s%s",dx11path,"Include/D3D11.h")
|
||||
headerdx11 = io.open(filepath, "r")
|
||||
if (headerdx11) then
|
||||
printf("Found DX11: '%s'", filepath)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function initDirectX11()
|
||||
configuration {}
|
||||
|
||||
local dx11path = os.getenv("DXSDK_DIR")
|
||||
defines { "ADL_ENABLE_DX11"}
|
||||
includedirs {"$(DXSDK_DIR)/include"}
|
||||
|
||||
configuration "x32"
|
||||
libdirs {"$(DXSDK_DIR)/Lib/x86"}
|
||||
configuration "x64"
|
||||
libdirs {"$(DXSDK_DIR)/Lib/x64"}
|
||||
configuration {}
|
||||
links {"d3dcompiler",
|
||||
"dxerr",
|
||||
"dxguid",
|
||||
"d3dx9",
|
||||
"d3d9",
|
||||
"winmm",
|
||||
"comctl32",
|
||||
"d3dx11"
|
||||
}
|
||||
return true
|
||||
end
|
||||
175
Engine/lib/bullet/build3/findOpenCL.lua
Normal file
175
Engine/lib/bullet/build3/findOpenCL.lua
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
|
||||
function findOpenCL_clew()
|
||||
return true;
|
||||
end
|
||||
|
||||
function findOpenCL_Apple()
|
||||
-- if os.is("macosx") then
|
||||
-- return true
|
||||
-- else
|
||||
return false
|
||||
-- end
|
||||
end
|
||||
|
||||
|
||||
function findOpenCL_AMD()
|
||||
-- local amdopenclpath = os.getenv("AMDAPPSDKROOT")
|
||||
-- if (amdopenclpath) then
|
||||
-- return true
|
||||
-- end
|
||||
return false
|
||||
end
|
||||
|
||||
function findOpenCL_NVIDIA()
|
||||
-- local nvidiaopenclpath = os.getenv("CUDA_PATH")
|
||||
-- if (nvidiaopenclpath) then
|
||||
-- return true
|
||||
-- end
|
||||
return false
|
||||
end
|
||||
|
||||
function findOpenCL_Intel()
|
||||
-- if os.is("Windows") then
|
||||
-- local intelopenclpath = os.getenv("INTELOCLSDKROOT")
|
||||
-- if (intelopenclpath) then
|
||||
-- return true
|
||||
-- end
|
||||
-- end
|
||||
-- if os.is("Linux") then
|
||||
-- local intelsdk = io.open("/usr/include/CL/opencl.h","r")
|
||||
-- if (intelsdk) then
|
||||
-- return true;
|
||||
-- end
|
||||
-- end
|
||||
return false
|
||||
end
|
||||
|
||||
function initOpenCL_clew()
|
||||
configuration{}
|
||||
includedirs {
|
||||
projectRootDir .. "src/clew"
|
||||
}
|
||||
defines {"B3_USE_CLEW"}
|
||||
files {
|
||||
projectRootDir .. "src/clew/clew.c",
|
||||
projectRootDir .. "src/clew/clew.h"
|
||||
}
|
||||
if os.is("Linux") then
|
||||
links {"dl"}
|
||||
end
|
||||
end
|
||||
|
||||
function initOpenCL_Apple()
|
||||
configuration{}
|
||||
includedirs {
|
||||
"/System/Library/Frameworks/OpenCL.framework"
|
||||
}
|
||||
libdirs "/System/Library/Frameworks/OpenCL.framework"
|
||||
links
|
||||
{
|
||||
"OpenCL.framework"
|
||||
}
|
||||
end
|
||||
|
||||
function initOpenCL_AMD()
|
||||
configuration {}
|
||||
local amdopenclpath = os.getenv("AMDAPPSDKROOT")
|
||||
if (amdopenclpath) then
|
||||
defines { "ADL_ENABLE_CL" , "CL_PLATFORM_AMD"}
|
||||
includedirs {
|
||||
"$(AMDAPPSDKROOT)/include"
|
||||
}
|
||||
configuration "x32"
|
||||
libdirs {"$(AMDAPPSDKROOT)/lib/x86"}
|
||||
configuration "x64"
|
||||
libdirs {"$(AMDAPPSDKROOT)/lib/x86_64"}
|
||||
configuration {}
|
||||
links {"OpenCL"}
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function initOpenCL_NVIDIA()
|
||||
configuration {}
|
||||
local nvidiaopenclpath = os.getenv("CUDA_PATH")
|
||||
if (nvidiaopenclpath) then
|
||||
defines { "ADL_ENABLE_CL" , "CL_PLATFORM_NVIDIA"}
|
||||
includedirs {
|
||||
"$(CUDA_PATH)/include"
|
||||
}
|
||||
configuration "x32"
|
||||
libdirs {"$(CUDA_PATH)/lib/Win32"}
|
||||
configuration "x64"
|
||||
libdirs {"$(CUDA_PATH)/lib/x64"}
|
||||
configuration {}
|
||||
links {"OpenCL"}
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function initOpenCL_Intel()
|
||||
configuration {}
|
||||
if os.is("Windows") then
|
||||
local intelopenclpath = os.getenv("INTELOCLSDKROOT")
|
||||
if (intelopenclpath) then
|
||||
defines { "ADL_ENABLE_CL" , "CL_PLATFORM_INTEL"}
|
||||
includedirs {
|
||||
"$(INTELOCLSDKROOT)/include"
|
||||
}
|
||||
configuration "x32"
|
||||
libdirs {"$(INTELOCLSDKROOT)/lib/x86"}
|
||||
configuration "x64"
|
||||
libdirs {"$(INTELOCLSDKROOT)/lib/x64"}
|
||||
configuration {}
|
||||
links {"OpenCL"}
|
||||
return true
|
||||
end
|
||||
end
|
||||
if os.is("Linux") then
|
||||
defines { "ADL_ENABLE_CL" , "CL_PLATFORM_INTEL"}
|
||||
configuration {}
|
||||
links {"OpenCL"}
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function findOpenCL (vendor )
|
||||
if vendor=="clew" then
|
||||
return findOpenCL_clew()
|
||||
end
|
||||
if vendor=="AMD" then
|
||||
return findOpenCL_AMD()
|
||||
end
|
||||
if vendor=="NVIDIA" then
|
||||
return findOpenCL_NVIDIA()
|
||||
end
|
||||
if vendor=="Intel" then
|
||||
return findOpenCL_Intel()
|
||||
end
|
||||
if vendor=="Apple" then
|
||||
return findOpenCL_Apple()
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function initOpenCL ( vendor )
|
||||
if vendor=="clew" then
|
||||
initOpenCL_clew()
|
||||
end
|
||||
if vendor=="AMD" then
|
||||
initOpenCL_AMD()
|
||||
end
|
||||
if vendor=="NVIDIA" then
|
||||
return initOpenCL_NVIDIA()
|
||||
end
|
||||
if vendor=="Intel" then
|
||||
initOpenCL_Intel()
|
||||
end
|
||||
if vendor=="Apple" then
|
||||
return initOpenCL_Apple()
|
||||
end
|
||||
end
|
||||
|
||||
90
Engine/lib/bullet/build3/findOpenGLGlewGlut.lua
Normal file
90
Engine/lib/bullet/build3/findOpenGLGlewGlut.lua
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
|
||||
function findOpenGL()
|
||||
configuration{}
|
||||
if os.is("Linux") then
|
||||
return true
|
||||
end
|
||||
--assume OpenGL is available on Mac OSX, Windows etc
|
||||
return true
|
||||
end
|
||||
|
||||
function findOpenGL3()
|
||||
configuration{}
|
||||
if os.is("MacOSX") then
|
||||
local osversion = os.getversion()
|
||||
--Mac OSX 10.9 and above supports OpenGL 3, below doesn't, so ...
|
||||
if osversion.majorversion > 10 or (osversion.majorversion == 10 and osversion.minorversion >=9) then
|
||||
return findOpenGL()
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
return findOpenGL()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function initOpenGL()
|
||||
configuration {}
|
||||
configuration {"Windows"}
|
||||
links {"opengl32","glu32"}
|
||||
configuration {"MacOSX"}
|
||||
links { "OpenGL.framework"}
|
||||
configuration {"not Windows", "not MacOSX"}
|
||||
if os.is("Linux") then
|
||||
if _OPTIONS["enable_system_opengl"] and (os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h")) then
|
||||
links {"GL"}
|
||||
else
|
||||
print("No GL/gl.h found, using dynamic loading of GL using glew")
|
||||
defines {"GLEW_INIT_OPENGL11_FUNCTIONS=1"}
|
||||
links {"dl"}
|
||||
end
|
||||
end
|
||||
configuration{}
|
||||
end
|
||||
|
||||
|
||||
function initGlew()
|
||||
configuration {}
|
||||
if os.is("Windows") then
|
||||
configuration {"Windows"}
|
||||
defines { "GLEW_STATIC"}
|
||||
includedirs {
|
||||
projectRootDir .. "examples/ThirdPartyLibs/Glew"
|
||||
}
|
||||
files { projectRootDir .. "examples/ThirdPartyLibs/Glew/glew.c"}
|
||||
end
|
||||
if os.is("Linux") then
|
||||
configuration{"Linux"}
|
||||
if _OPTIONS["enable_system_opengl"] and (os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h") and os.isfile("/usr/include/GL/glew.h")) then
|
||||
links {"GLEW"}
|
||||
print ("linking against system GLEW")
|
||||
else
|
||||
print("Using static glew and dynamic loading of glx functions")
|
||||
defines { "GLEW_STATIC","GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1"}
|
||||
includedirs {
|
||||
projectRootDir .. "examples/ThirdPartyLibs/Glew"
|
||||
}
|
||||
files { projectRootDir .. "examples/ThirdPartyLibs/Glew/glew.c"}
|
||||
links {"dl"}
|
||||
end
|
||||
|
||||
end
|
||||
configuration{}
|
||||
end
|
||||
|
||||
function initX11()
|
||||
if os.is("Linux") then
|
||||
if _OPTIONS["enable_system_x11"] and (os.isdir("/usr/include") and os.isfile("/usr/include/X11/X.h")) then
|
||||
links{"X11","pthread"}
|
||||
else
|
||||
print("No X11/X.h found, using dynamic loading of X11")
|
||||
includedirs {
|
||||
projectRootDir .. "examples/ThirdPartyLibs/optionalX11"
|
||||
}
|
||||
defines {"DYNAMIC_LOAD_X11_FUNCTIONS"}
|
||||
links {"dl","pthread"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
939
Engine/lib/bullet/build3/lcpp.lua
Normal file
939
Engine/lib/bullet/build3/lcpp.lua
Normal file
|
|
@ -0,0 +1,939 @@
|
|||
----------------------------------------------------------------------------
|
||||
--## lcpp - a C-PreProcessor in Lua 5.1 for LuaJIT ffi
|
||||
--
|
||||
-- Copyright (C) 2012-2013 Michael Schmoock <michael@willigens.de>
|
||||
--
|
||||
--### Links
|
||||
-- * GitHub page: [http://github.com/willsteel/lcpp](http://github.com/willsteel/lcpp)
|
||||
-- * Project page: [http://lcpp.schmoock.net](http://lcpp.schmoock.net)
|
||||
-- * Lua: [http://www.lua.org](http://www.lua.org)
|
||||
-- * LuaJIT: [http://luajit.org](http://luajit.org)
|
||||
-- * Sponsored by: [http://mmbbq.org](http://mmbbq.org)
|
||||
--
|
||||
-- It can be used to pre-process LuaJIT ffi C header file input.
|
||||
-- It can also be used to preprocess any other code (i.e. Lua itself)
|
||||
--
|
||||
-- git clone https://github.com/willsteel/lcpp.git
|
||||
----------------------------------------------------------------------------
|
||||
--## USAGE
|
||||
-- -- load lcpp
|
||||
-- local lcpp = require("lcpp")
|
||||
--
|
||||
-- -- use LuaJIT ffi and lcpp to parse cpp code
|
||||
-- ffi.cdef("#include <your_header.h>")
|
||||
--
|
||||
-- -- compile some input
|
||||
-- local out = lcpp.compile([[
|
||||
-- #include "myheader.h"
|
||||
-- #define MAXPATH 260
|
||||
-- typedef struct somestruct_t {
|
||||
-- void* base;
|
||||
-- size_t size;
|
||||
-- wchar_t path[MAXPATH];
|
||||
-- } t_exe;
|
||||
-- ]])
|
||||
--
|
||||
-- -- the result should be
|
||||
-- out = [[
|
||||
-- // <preprocessed content of file "myheader.h">
|
||||
-- typedef struct somestruct_t {
|
||||
-- void* base;
|
||||
-- size_t size;
|
||||
-- wchar_t path[260];
|
||||
-- } t_exe;
|
||||
-- ]]
|
||||
--
|
||||
--## This CPPs BNF:
|
||||
-- RULES:
|
||||
-- CODE := {LINE}
|
||||
-- LINE := {STUFF NEWML} STUFF NEWL
|
||||
-- STUFF := DIRECTIVE | IGNORED_CONTENT
|
||||
-- DIRECTIVE := OPTSPACES CMD OPTSPACES DIRECTIVE_NAME WHITESPACES DIRECTIVE_CONTENT WHITESPACES NEWL
|
||||
--
|
||||
-- LEAVES:
|
||||
-- NEWL := "\n"
|
||||
-- NEWL_ESC := "\\n"
|
||||
-- WHITESPACES := "[ \t]+"
|
||||
-- OPTSPACES := "[ \t]*"
|
||||
-- COMMENT := "//(.-)$"
|
||||
-- MLCOMMENT := "/[*](.-)[*]/"
|
||||
-- IGNORED_CONTENT := "[^#].*"
|
||||
-- CMD := "#"
|
||||
-- DIRECTIVE_NAME := "include"|"define"|"undef"|"if"|"else"|"elif"|"else if"|"endif"|"ifdef"|"ifndef"|"pragma"|"version"
|
||||
-- DIRECTIVE_CONTENT := ".*?"
|
||||
--
|
||||
--## TODOs:
|
||||
-- - lcpp.LCPP_LUA for: load, loadfile
|
||||
-- - "#" operator for stringification
|
||||
-- - literal concatenation: "foo" "bar" -> "foobar"
|
||||
--
|
||||
--## License (MIT)
|
||||
-- -----------------------------------------------------------------------------
|
||||
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
-- of this software and associated documentation files (the "Software"), to deal
|
||||
-- in the Software without restriction, including without limitation the rights
|
||||
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
-- copies of the Software, and to permit persons to whom the Software is
|
||||
-- furnished to do so, subject to the following conditions:
|
||||
--
|
||||
-- The above copyright notice and this permission notice shall be included in
|
||||
-- all copies or substantial portions of the Software.
|
||||
--
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
-- THE SOFTWARE.
|
||||
--
|
||||
-- MIT license: http://www.opensource.org/licenses/mit-license.php
|
||||
-- -----------------------------------------------------------------------------
|
||||
--
|
||||
-- @module lcpp
|
||||
local lcpp = {}
|
||||
|
||||
-- CONFIG
|
||||
lcpp.LCPP_LUA = false -- whether to use lcpp to preprocess Lua code (load, loadfile, loadstring...)
|
||||
lcpp.LCPP_FFI = true -- whether to use lcpp as LuaJIT ffi PreProcessor (if used in luaJIT)
|
||||
lcpp.LCPP_TEST = false -- whether to run lcpp unit tests when loading lcpp module
|
||||
lcpp.ENV = {} -- static predefines (env-like)
|
||||
lcpp.FAST = true -- perf. tweaks when enabled. con: breaks minor stuff like __LINE__ macros
|
||||
lcpp.DEBUG = false
|
||||
|
||||
-- PREDEFINES
|
||||
local __FILE__ = "__FILE__"
|
||||
local __LINE__ = "__LINE__"
|
||||
local __DATE__ = "__DATE__"
|
||||
local __TIME__ = "__TIME__"
|
||||
local __LCPP_INDENT__ = "__LCPP_INDENT__"
|
||||
local __LCPP_INSIDE_HEADERFILE__ = "__LCPP_INSIDE_HEADERFILE__"
|
||||
|
||||
-- BNF LEAVES
|
||||
local ENDL = "$"
|
||||
local STARTL = "^"
|
||||
local NEWL = "\n"
|
||||
local NEWL_BYTE = NEWL:byte(1)
|
||||
local NEWL_ESC = "\\"
|
||||
local NEWML = "\\\n"
|
||||
local CMD = "#"
|
||||
local CMD_BYTE = CMD:byte(1)
|
||||
local COMMENT = "^(.-)//.-$"
|
||||
local MLCOMMENT = "/[*].-[*]/"
|
||||
local WHITESPACES = "%s+"
|
||||
local OPTSPACES = "%s*"
|
||||
local IDENTIFIER = "[_%a][_%w]*"
|
||||
local NOIDENTIFIER = "[^%w_]+"
|
||||
local FILENAME = "[0-9a-zA-Z.-_/\\]+"
|
||||
local TEXT = ".+"
|
||||
|
||||
-- BNF WORDS
|
||||
local _INCLUDE = "include"
|
||||
local _DEFINE = "define"
|
||||
local _IFDEF = "ifdef"
|
||||
local _IFNDEF = "ifndef"
|
||||
local _ENDIF = "endif"
|
||||
local _UNDEF = "undef"
|
||||
local _IF = "if"
|
||||
local _ELSE = "else"
|
||||
local _ELIF = "elif"
|
||||
local _NOT = "!"
|
||||
local _ERROR = "error"
|
||||
local _PRAGMA = "pragma"
|
||||
local _VERSION = "version"
|
||||
|
||||
-- BNF RULES
|
||||
local INCLUDE = STARTL.._INCLUDE..WHITESPACES.."[\"<]("..FILENAME..")[\">]"..OPTSPACES..ENDL
|
||||
local DEFINE = STARTL.._DEFINE
|
||||
local IFDEF = STARTL.._IFDEF..WHITESPACES.."("..IDENTIFIER..")"..OPTSPACES..ENDL
|
||||
local IFNDEF = STARTL.._IFNDEF..WHITESPACES.."("..IDENTIFIER..")"..OPTSPACES..ENDL
|
||||
local ENDIF = STARTL.._ENDIF..OPTSPACES.."(.*)"..ENDL
|
||||
local UNDEF = STARTL.._UNDEF..WHITESPACES.."("..IDENTIFIER..")"..OPTSPACES..ENDL
|
||||
local IF = STARTL.._IF..WHITESPACES.."(.*)"..ENDL
|
||||
local ELSE = STARTL.._ELSE..OPTSPACES.."(.*)"..ENDL
|
||||
local ELIF = STARTL.._ELIF..WHITESPACES.."(.*)"..ENDL
|
||||
local ELSEIF = STARTL.._ELSE..WHITESPACES.._IF..WHITESPACES.."(.*)"..ENDL
|
||||
local ERROR = STARTL.._ERROR..WHITESPACES.."("..TEXT..")"..OPTSPACES..ENDL
|
||||
local ERROR_NOTEXT = STARTL.._ERROR..OPTSPACES..ENDL --> not required when we have POSIX regex
|
||||
local PRAGMA = STARTL.._PRAGMA
|
||||
local VERSION = STARTL.._VERSION
|
||||
|
||||
|
||||
|
||||
-- speedups
|
||||
local TRUEMACRO = STARTL.."("..IDENTIFIER..")%s*$"
|
||||
local REPLMACRO = STARTL.."("..IDENTIFIER..")"..WHITESPACES.."(.+)$"
|
||||
local FUNCMACRO = STARTL.."("..IDENTIFIER..")%s*%(([%s%w,]*)%)%s*(.*)"
|
||||
|
||||
|
||||
-- ------------
|
||||
-- LOCAL UTILS
|
||||
-- ------------
|
||||
lcpp.STATE = {lineno = 0} -- current state for debugging the last operation
|
||||
local function error(msg) _G.print(debug.traceback()); _G.error(string.format("lcpp ERR [%04i] %s", lcpp.STATE.lineno, msg)) end
|
||||
local function print(msg) _G.print(string.format("lcpp INF [%04i] %s", lcpp.STATE.lineno, msg)) end
|
||||
|
||||
-- splits a string using a pattern into a table of substrings
|
||||
local function gsplit(str, pat)
|
||||
local function _split(str, pat)
|
||||
local t = {} -- NOTE: use {n = 0} in Lua-5.0
|
||||
local fpat = "(.-)"..pat
|
||||
local last_end = 1
|
||||
local s, e, cap = str:find(fpat, 1)
|
||||
while s do
|
||||
if s ~= 1 or cap ~= "" then
|
||||
coroutine.yield(cap)
|
||||
end
|
||||
last_end = e + 1
|
||||
s, e, cap = str:find(fpat, last_end)
|
||||
end
|
||||
if last_end <= #str then
|
||||
cap = str:sub(last_end)
|
||||
coroutine.yield(cap)
|
||||
end
|
||||
end
|
||||
return coroutine.wrap(function() _split(str, pat) end)
|
||||
end
|
||||
local function split(str, pat)
|
||||
local t = {}
|
||||
for str in gsplit(str, pat) do table.insert(t, str) end
|
||||
return t
|
||||
end
|
||||
|
||||
-- Checks whether a string starts with a given substring
|
||||
-- offset is optional
|
||||
local function strsw(str, pat, offset)
|
||||
if not str then return false end
|
||||
if not offset then offset = 0 end
|
||||
return string.sub(str, 1+offset, string.len(pat)+offset) == pat
|
||||
end
|
||||
|
||||
-- Checks whether a string ends with a given substring
|
||||
local function strew(str, pat)
|
||||
if not str then return false end
|
||||
return pat=='' or string.sub(str,-string.len(pat)) == pat
|
||||
end
|
||||
|
||||
-- string trim12 from lua wiki
|
||||
local function trim(str)
|
||||
local from = str:match"^%s*()"
|
||||
return from > #str and "" or str:match(".*%S", from)
|
||||
end
|
||||
|
||||
-- returns the number of string occurrences
|
||||
local function findn(input, what)
|
||||
local count = 0
|
||||
local offset = 0
|
||||
while true do
|
||||
_, offset = string.find(input, what, offset+1, true)
|
||||
if not offset then return count end
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- a lightweight and flexible tokenizer
|
||||
local function _tokenizer(str, setup)
|
||||
local defsetup = {
|
||||
-- EXAMPLE patterns have to be pretended with "^" for the tokenizer
|
||||
["identifier"] = '^[_%a][_%w]*',
|
||||
["number"] = '^[%+%-]?%d+[%.]?%d*',
|
||||
["ignore"] = '^%s+',
|
||||
["string"] = true,
|
||||
["keywords"] = {
|
||||
-- ["NAME"] = '^pattern',
|
||||
-- ...
|
||||
},
|
||||
}
|
||||
if not setup then
|
||||
setup = defsetup
|
||||
end
|
||||
setup.identifier = setup.identifier or defsetup.identifier
|
||||
setup.number = setup.number or defsetup.number
|
||||
setup.ignore = setup.number or defsetup.ignore
|
||||
if nil == setup.string then setup.string = true end
|
||||
setup.keywords = setup.keywords or {}
|
||||
|
||||
local strlen = #str
|
||||
local i = 1
|
||||
local i1, i2
|
||||
local keyword
|
||||
|
||||
local function find(pat)
|
||||
i1, i2 = str:find(pat,i)
|
||||
return i1 ~= nil
|
||||
end
|
||||
|
||||
local function cut()
|
||||
return str:sub(i, i2)
|
||||
end
|
||||
|
||||
local function findKeyword()
|
||||
for name, pat in pairs(setup.keywords) do
|
||||
local result = find(pat)
|
||||
if result then
|
||||
keyword = name
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
while true do
|
||||
if i > strlen then return 'eof', nil, strlen, strlen end
|
||||
if find(setup.ignore) then
|
||||
coroutine.yield("ignore", cut(), i1, i2)
|
||||
elseif findKeyword() then
|
||||
coroutine.yield(keyword, cut(), i1, i2)
|
||||
elseif find(setup.number) then
|
||||
coroutine.yield('number', tonumber(cut()), i1, i2)
|
||||
elseif find(setup.identifier) then
|
||||
coroutine.yield('identifier', cut(), i1, i2)
|
||||
elseif setup.string and (find('^"[^"]*"') or find("^'[^']*'")) then
|
||||
-- strip the quotes
|
||||
coroutine.yield('string', cut():sub(2,-2), i1, i2)
|
||||
else -- any other unknown character
|
||||
i1 = i
|
||||
i2 = i
|
||||
coroutine.yield('unknown', cut(), i1, i2)
|
||||
end
|
||||
i = i2+1
|
||||
end
|
||||
end
|
||||
local function tokenizer(str, setup)
|
||||
return coroutine.wrap(function() _tokenizer(str, setup) end)
|
||||
end
|
||||
|
||||
|
||||
-- ------------
|
||||
-- PARSER
|
||||
-- ------------
|
||||
|
||||
-- hint: LuaJIT ffi does not rely on us to remove the comments, but maybe other usecases
|
||||
local function removeComments(input)
|
||||
input = string.gsub(input, "//.-\n", "\n") -- remove sl comments
|
||||
-- remove multiline comments in a way that it does not break __LINE__ macro
|
||||
if lcpp.FAST then
|
||||
input = string.gsub(input, "/%*.-%*/", "") -- remove ml comments (stupid method)
|
||||
else
|
||||
local offset = 0
|
||||
local output = {}
|
||||
local starti, endi, match, lastendi
|
||||
while offset do
|
||||
starti, endi, match = input:find("/%*(.-)%*/", offset, false)
|
||||
if starti then
|
||||
lastendi = endi
|
||||
local newlineCount = findn(match, "\n")
|
||||
local newlines = string.rep("\n", newlineCount)
|
||||
table.insert(output, input:sub(offset+1, starti-1))
|
||||
table.insert(output, newlines)
|
||||
offset = endi
|
||||
else
|
||||
offset = nil
|
||||
table.insert(output, input:sub((lastendi or 0) + 1))
|
||||
end
|
||||
end
|
||||
input = table.concat(output)
|
||||
--error(input)
|
||||
end
|
||||
|
||||
return input
|
||||
end
|
||||
|
||||
-- screener: revmoce comments, trim, ml concat...
|
||||
-- it only splits to cpp input lines and removes comments. it does not tokenize.
|
||||
local function screener(input)
|
||||
local function _screener(input)
|
||||
--input = removeComments(input)
|
||||
|
||||
-- concat mulit-line input.
|
||||
local count = 1
|
||||
while count > 0 do input, count = string.gsub(input, "^(.-)\\\n(.-)$", "%1 %2\n") end
|
||||
|
||||
-- trim and join blocks not starting with "#"
|
||||
local buffer = {}
|
||||
for line in gsplit(input, NEWL) do
|
||||
--line = trim(line)
|
||||
if #line > 0 then
|
||||
if line:byte(1) == CMD_BYTE then
|
||||
--line = line:gsub("#%s*(.*)", "#%1") -- remove optinal whitespaces after "#". reduce triming later.
|
||||
if #buffer > 0 then
|
||||
coroutine.yield(table.concat(buffer, NEWL))
|
||||
buffer = {}
|
||||
end
|
||||
coroutine.yield(line)
|
||||
else
|
||||
if lcpp.FAST then
|
||||
table.insert(buffer, line)
|
||||
else
|
||||
coroutine.yield(line)
|
||||
end
|
||||
end
|
||||
elseif not lcpp.FAST then
|
||||
coroutine.yield(line)
|
||||
end
|
||||
end
|
||||
if #buffer > 0 then
|
||||
coroutine.yield(table.concat(buffer, NEWL))
|
||||
end
|
||||
end
|
||||
|
||||
return coroutine.wrap(function() _screener(input) end)
|
||||
end
|
||||
|
||||
-- apply currently known macros to input (and returns it)
|
||||
local function apply(state, input)
|
||||
local out = {}
|
||||
local functions = {}
|
||||
|
||||
for k, v, start, end_ in tokenizer(input) do
|
||||
if k == "identifier" then
|
||||
local repl = v
|
||||
local macro = state.defines[v]
|
||||
if macro then
|
||||
if type(macro) == "boolean" then
|
||||
repl = ""
|
||||
elseif type(macro) == "string" then
|
||||
repl = macro
|
||||
elseif type(macro) == "number" then
|
||||
repl = tostring(macro)
|
||||
elseif type(macro) == "function" then
|
||||
table.insert(functions, macro) -- we apply functions in a later step
|
||||
end
|
||||
end
|
||||
table.insert(out, repl)
|
||||
else
|
||||
table.insert(out, input:sub(start, end_))
|
||||
end
|
||||
end
|
||||
input = table.concat(out)
|
||||
for _, func in pairs(functions) do -- TODO: looks sucky (but works quite nice)
|
||||
input = func(input)
|
||||
end
|
||||
|
||||
return input
|
||||
end
|
||||
|
||||
-- processes an input line. called from lcpp doWork loop
|
||||
local function processLine(state, line)
|
||||
if not line or #line == 0 then return line end
|
||||
local cmd = nil
|
||||
if line:byte(1) == CMD_BYTE then cmd = line:sub(2) end
|
||||
--print("processLine(): "..line)
|
||||
|
||||
|
||||
--[[ SKIPPING ]]--
|
||||
if state:skip() then return end
|
||||
|
||||
|
||||
--[[ READ NEW DIRECTIVES ]]--
|
||||
if cmd then
|
||||
-- handle #include ...
|
||||
local filename = cmd:match(INCLUDE)
|
||||
if filename then
|
||||
print("processing header " .. filename)
|
||||
return state:includeFile(filename)
|
||||
end
|
||||
|
||||
return line
|
||||
end
|
||||
|
||||
|
||||
--[[ APPLY MACROS ]]--
|
||||
--line = state:apply(line);
|
||||
|
||||
return line
|
||||
end
|
||||
|
||||
|
||||
local function processLine2(state, line)
|
||||
if not line or #line == 0 then return line end
|
||||
local cmd = nil
|
||||
if line:byte(1) == CMD_BYTE then cmd = line:sub(2) end
|
||||
--print("processLine(): "..line)
|
||||
|
||||
if state:defined(__LCPP_INSIDE_HEADERFILE__) then
|
||||
--[[ IF/THEN/ELSE STRUCTURAL BLOCKS ]]--
|
||||
if cmd then
|
||||
local ifdef = cmd:match(IFDEF)
|
||||
local ifexp = cmd:match(IF)
|
||||
local ifndef = cmd:match(IFNDEF)
|
||||
local elif = cmd:match(ELIF)
|
||||
local elseif_ = cmd:match(ELSEIF)
|
||||
local else_ = cmd:match(ELSE)
|
||||
local endif = cmd:match(ENDIF)
|
||||
local struct = ifdef or ifexp or ifndef or elif or elseif_ or else_ or endif
|
||||
|
||||
if struct then
|
||||
if ifdef then state:openBlock(state:defined(ifdef)) end
|
||||
if ifexp then state:openBlock(state:parseExpr(ifexp)) end
|
||||
if ifndef then state:openBlock(not state:defined(ifndef)) end
|
||||
if elif then state:elseBlock(state:parseExpr(elif)) end
|
||||
if elseif_ then state:elseBlock(state:parseExpr(elseif_)) end
|
||||
if else_ then state:elseBlock(true) end
|
||||
if endif then state:closeBlock() end
|
||||
return line
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--[[ SKIPPING ]]--
|
||||
if state:skip() then return end
|
||||
|
||||
|
||||
--[[ READ NEW DIRECTIVES ]]--
|
||||
if cmd then
|
||||
-- handle #include ...
|
||||
local filename = cmd:match(INCLUDE)
|
||||
if filename then
|
||||
print("processing header " .. filename)
|
||||
return state:includeFile(filename)
|
||||
end
|
||||
|
||||
if state:defined(__LCPP_INSIDE_HEADERFILE__) then
|
||||
-- handle #undef ...
|
||||
local key = cmd:match(UNDEF)
|
||||
if type(key) == "string" then
|
||||
state:undefine(key)
|
||||
return
|
||||
end
|
||||
|
||||
-- read "#define >FooBar...<" directives
|
||||
if cmd:match(DEFINE) then
|
||||
local define = trim(cmd:sub(DEFINE:len()+1))
|
||||
local macroname, replacement
|
||||
|
||||
-- simple "true" defines
|
||||
macroname = define:match(TRUEMACRO)
|
||||
if macroname then
|
||||
state:define(macroname, true)
|
||||
end
|
||||
|
||||
-- replace macro defines
|
||||
macroname, replacement = define:match(REPLMACRO)
|
||||
if macroname and replacement then
|
||||
state:define(macroname, replacement)
|
||||
end
|
||||
|
||||
-- read functional macros
|
||||
macroname, replacement = state:parseFunction(define)
|
||||
if macroname and replacement then
|
||||
state:define(macroname, replacement)
|
||||
end
|
||||
|
||||
return line
|
||||
end
|
||||
|
||||
-- ignore, because we dont have any pragma directives yet
|
||||
if cmd:match(PRAGMA) then
|
||||
return line
|
||||
end
|
||||
|
||||
-- abort on unknown keywords
|
||||
error("unknown directive: "..line)
|
||||
else
|
||||
return line
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--[[ APPLY MACROS ]]--
|
||||
--line = state:apply(line);
|
||||
|
||||
return line
|
||||
end
|
||||
|
||||
|
||||
local function doWork(state)
|
||||
local function _doWork(state)
|
||||
if not state:defined(__FILE__) then state:define(__FILE__, "<USER_CHUNK>", true) end
|
||||
local oldIndent = state:getIndent()
|
||||
while true do
|
||||
local input = state:getLine()
|
||||
if not input then break end
|
||||
local output = processLine(state, input)
|
||||
if not lcpp.FAST and not output then
|
||||
output = "" end -- output empty skipped lines
|
||||
|
||||
if lcpp.DEBUG then output = output.." -- "..input end -- input as comment when DEBUG
|
||||
|
||||
if output then coroutine.yield(output) end
|
||||
end
|
||||
if (oldIndent ~= state:getIndent()) then error("indentation level must be balanced within a file. was:"..oldIndent.." is:"..state:getIndent()) end
|
||||
end
|
||||
return coroutine.wrap(function() _doWork(state) end)
|
||||
end
|
||||
|
||||
local function doWork2(state)
|
||||
local function _doWork2(state)
|
||||
if not state:defined(__FILE__) then state:define(__FILE__, "<USER_CHUNK>", true) end
|
||||
local oldIndent = state:getIndent()
|
||||
while true do
|
||||
local input = state:getLine()
|
||||
if not input then break end
|
||||
local output = processLine2(state, input)
|
||||
if not lcpp.FAST and not output then output = "" end -- output empty skipped lines
|
||||
if lcpp.DEBUG then output = output.." -- "..input end -- input as comment when DEBUG
|
||||
if output then coroutine.yield(output) end
|
||||
end
|
||||
if (oldIndent ~= state:getIndent()) then error("indentation level must be balanced within a file. was:"..oldIndent.." is:"..state:getIndent()) end
|
||||
end
|
||||
return coroutine.wrap(function() _doWork2(state) end)
|
||||
end
|
||||
|
||||
local function includeFile(state, filename)
|
||||
local result, result_state = lcpp.compileHeaderFile("../src/" .. filename, state.defines)
|
||||
-- now, we take the define table of the sub file for further processing
|
||||
state.defines = result_state.defines
|
||||
-- and return the compiled result
|
||||
return result
|
||||
end
|
||||
|
||||
-- sets a global define
|
||||
local function define(state, key, value, override)
|
||||
--print("define:"..key.." type:"..type(value))
|
||||
--if value and not override and state:defined(key) then error("already defined: "..key) end
|
||||
value = state:prepareMacro(value)
|
||||
state.defines[key] = value
|
||||
end
|
||||
|
||||
-- parses CPP exressions
|
||||
-- i.e.: #if !defined(_UNICODE) && !defined(UNICODE)
|
||||
--
|
||||
--BNF:
|
||||
-- EXPR -> (BRACKET_OPEN)(EXPR)(BRACKET_CLOSE)
|
||||
-- EXPR -> (EXPR)(OR)(EXPR)
|
||||
-- EXPR -> (EXPR)(AND)(EXPR)
|
||||
-- EXPR -> (NOT)(EXPR)
|
||||
-- EXPR -> (FUNCTION)
|
||||
-- FUNCTION -> (IDENTIFIER)(BRACKET_OPEN)(ARGS)(BRACKET_CLOSE)
|
||||
-- ARGS -> ((IDENTIFIER)[(COMMA)(IDENTIFIER)])?
|
||||
--LEAVES:
|
||||
-- IGNORE -> " \t"
|
||||
-- BRACKET_OPEN -> "("
|
||||
-- BRACKET_CLOSE -> ")"
|
||||
-- OR -> "||"
|
||||
-- AND -> "&&"
|
||||
-- NOT -> "!"
|
||||
-- IDENTIFIER -> "[0-9a-zA-Z_]"
|
||||
--
|
||||
|
||||
local LCPP_TOKENIZE_MACRO = {
|
||||
string = true,
|
||||
keywords = {
|
||||
CONCAT = "^##",
|
||||
},
|
||||
}
|
||||
local LCPP_TOKENIZE_EXPR = {
|
||||
string = false,
|
||||
keywords = {
|
||||
NOT = '^!',
|
||||
DEFINED = '^defined',
|
||||
BROPEN = '^[(]',
|
||||
BRCLOSE = '^[)]',
|
||||
AND = '^&&',
|
||||
OR = '^||',
|
||||
},
|
||||
}
|
||||
|
||||
local function parseDefined(state, input)
|
||||
local result = false
|
||||
local bropen = false
|
||||
local brclose = false
|
||||
local ident = nil
|
||||
|
||||
for key, value in input do
|
||||
if key == "BROPEN" then
|
||||
bropen = true
|
||||
end
|
||||
if key == "identifier" then
|
||||
ident = value
|
||||
if not bropen then break end
|
||||
end
|
||||
if key == "BRCLOSE" and ident then
|
||||
brclose = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- wiht and w/o brackets allowed
|
||||
if ident and ((bropen and brclose) or (not bropen and not brclose)) then
|
||||
return state:defined(ident)
|
||||
end
|
||||
|
||||
error("expression parse error: defined(ident)")
|
||||
end
|
||||
|
||||
local function parseExpr(state, input)
|
||||
-- first call gets string input. rest uses tokenizer
|
||||
if type(input) == "string" then input = tokenizer(input, LCPP_TOKENIZE_EXPR) end
|
||||
local result = false
|
||||
local _not = false
|
||||
|
||||
for type, value in input do
|
||||
-- print("type:"..type.." value:"..value)
|
||||
if type == "NOT" then
|
||||
_not = true
|
||||
end
|
||||
if type == "BROPEN" then
|
||||
return state:parseExpr(input)
|
||||
end
|
||||
if type == "BRCLOSE" then
|
||||
return result
|
||||
end
|
||||
if type == "AND" then
|
||||
return result and state:parseExpr(input)
|
||||
end
|
||||
if type == "OR" then
|
||||
return result or state:parseExpr(input)
|
||||
end
|
||||
|
||||
if type == "DEFINED" then
|
||||
if _not then
|
||||
result = not parseDefined(state, input)
|
||||
else
|
||||
result = parseDefined(state, input)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
-- apply macros chaining and string ops "##" and "#"
|
||||
local function prepareMacro(state, input)
|
||||
if type(input) ~= "string" then return input end
|
||||
input = state:apply(input)
|
||||
local out = {}
|
||||
for k, v, start, end_ in tokenizer(input, LCPP_TOKENIZE_MACRO) do
|
||||
if k == "CONCAT" then
|
||||
-- remove concat op "##"
|
||||
else
|
||||
table.insert(out, input:sub(start, end_))
|
||||
end
|
||||
end
|
||||
return table.concat(out)
|
||||
end
|
||||
|
||||
-- i.e.: "MAX(x, y) (((x) > (y)) ? (x) : (y))"
|
||||
local function parseFunction(state, input)
|
||||
if not input then return end
|
||||
local name, argsstr, repl = input:match(FUNCMACRO)
|
||||
if not name or not argsstr or not repl then return end
|
||||
repl = state:prepareMacro(repl)
|
||||
|
||||
-- rename args to %1,%2... for later gsub
|
||||
local noargs = 0
|
||||
for argname in argsstr:gmatch(IDENTIFIER) do
|
||||
noargs = noargs + 1
|
||||
repl = repl:gsub(argname, "%%"..noargs)
|
||||
end
|
||||
|
||||
-- build pattern string: name(arg, arg, ...)
|
||||
local pattern
|
||||
if noargs == 0 then pattern = name.."%s*%(%s*%)" -- quick 0 arg version
|
||||
elseif noargs == 1 then pattern = name.."%s*%(%s*([^,%)]*)%s*%)" -- quick 1 arg version
|
||||
elseif noargs == 2 then pattern = name.."%s*%(%s*([^,%)]*)%s*,%s*([^,%)]*)%s*%)" -- quick 2 arg version
|
||||
else -- arbitrary arg version
|
||||
local buf = {}
|
||||
table.insert(buf, name)
|
||||
table.insert(buf, "%s*%(%s*")
|
||||
for i = 1, noargs do
|
||||
table.insert(buf, "([^,%)]*)%s*")
|
||||
if i < noargs then
|
||||
table.insert(buf, ",%s*")
|
||||
end
|
||||
end
|
||||
table.insert(buf, "%)")
|
||||
pattern = table.concat(buf)
|
||||
end
|
||||
|
||||
-- build macro funcion
|
||||
local func = function(input)
|
||||
return input:gsub(pattern, repl)
|
||||
end
|
||||
|
||||
return name, func
|
||||
end
|
||||
|
||||
|
||||
-- ------------
|
||||
-- LCPP INTERFACE
|
||||
-- ------------
|
||||
|
||||
--- initialies a lcpp state. not needed manually. handy for testing
|
||||
function lcpp.init(input, predefines)
|
||||
-- create sate var
|
||||
local state = {} -- init the state object
|
||||
state.defines = {} -- the table of known defines and replacements
|
||||
state.screener = screener(input)
|
||||
state.lineno = 0 -- the current line number
|
||||
state.stack = {} -- stores wether the current stack level is to be included
|
||||
state.once = {} -- stack level was once true (first if that evals to true)
|
||||
|
||||
-- funcs
|
||||
state.define = define
|
||||
state.undefine = function(state, key)
|
||||
state:define(key, nil)
|
||||
end
|
||||
state.defined = function(state, key)
|
||||
return state.defines[key] ~= nil
|
||||
end
|
||||
state.apply = apply
|
||||
state.includeFile = includeFile
|
||||
state.doWork = doWork
|
||||
state.doWork2 = doWork2
|
||||
state.getIndent = function(state)
|
||||
return #state.stack
|
||||
end
|
||||
state.openBlock = function(state, bool)
|
||||
state.stack[#state.stack+1] = bool
|
||||
state.once [#state.once+1] = bool
|
||||
state:define(__LCPP_INDENT__, state:getIndent(), true)
|
||||
end
|
||||
state.elseBlock = function(state, bool)
|
||||
if state.once[#state.once] then
|
||||
state.stack[#state.stack] = false
|
||||
else
|
||||
state.stack[#state.stack] = bool
|
||||
if bool then state.once[#state.once] = true end
|
||||
end
|
||||
end
|
||||
state.closeBlock = function(state)
|
||||
state.stack[#state.stack] = nil
|
||||
state.once [#state.once] = nil
|
||||
state:define(__LCPP_INDENT__, state:getIndent(), true)
|
||||
if state:getIndent() < 0 then error("Unopened block detected. Indentaion problem.") end
|
||||
end
|
||||
state.skip = function(state)
|
||||
for i = 1, #state.stack do
|
||||
if not state.stack[i] then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
state.getLine = function(state)
|
||||
state.lineno = state.lineno + 1
|
||||
state:define(__LINE__, state.lineno, true)
|
||||
return state.screener()
|
||||
end
|
||||
state.prepareMacro = prepareMacro
|
||||
state.parseExpr = parseExpr
|
||||
state.parseFunction = parseFunction
|
||||
|
||||
-- predefines
|
||||
state:define(__DATE__, os.date("%B %d %Y"), true)
|
||||
state:define(__TIME__, os.date("%H:%M:%S"), true)
|
||||
state:define(__LINE__, state.lineno, true)
|
||||
state:define(__LCPP_INDENT__, state:getIndent(), true)
|
||||
predefines = predefines or {}
|
||||
for k,v in pairs(lcpp.ENV) do state:define(k, v, true) end -- static ones
|
||||
for k,v in pairs(predefines) do state:define(k, v, true) end
|
||||
|
||||
if lcpp.LCPP_TEST then lcpp.STATE = state end -- activate static state debugging
|
||||
|
||||
return state
|
||||
end
|
||||
|
||||
--- the preprocessors main function.
|
||||
-- returns the preprocessed output as a string.
|
||||
-- @param code data as string
|
||||
-- @param predefines OPTIONAL a table of predefined variables
|
||||
-- @usage lcpp.compile("#define bar 0x1337\nstatic const int foo = bar;")
|
||||
-- @usage lcpp.compile("#define bar 0x1337\nstatic const int foo = bar;", {["bar"] = "0x1338"})
|
||||
function lcpp.compile(code, predefines)
|
||||
local state = lcpp.init(code, predefines)
|
||||
local buf = {}
|
||||
for output in state:doWork() do
|
||||
table.insert(buf, output)
|
||||
end
|
||||
local output = table.concat(buf, NEWL)
|
||||
if lcpp.DEBUG then print(output) end
|
||||
return output, state
|
||||
end
|
||||
|
||||
function lcpp.compile2(code, predefines)
|
||||
local state = lcpp.init(code, predefines)
|
||||
state:define(__LCPP_INSIDE_HEADERFILE__,true)
|
||||
local buf = {}
|
||||
for output in state:doWork2() do
|
||||
table.insert(buf, output)
|
||||
end
|
||||
local output = table.concat(buf, NEWL)
|
||||
if lcpp.DEBUG then print(output) end
|
||||
return output, state
|
||||
end
|
||||
|
||||
--- preprocesses a file
|
||||
-- @param filename the file to read
|
||||
-- @param predefines OPTIONAL a table of predefined variables
|
||||
-- @usage out, state = lcpp.compileFile("../odbg/plugin.h", {["MAXPATH"]=260, ["UNICODE"]=true})
|
||||
function lcpp.compileFile(filename, predefines)
|
||||
if not filename then error("processFile() arg1 has to be a string") end
|
||||
local file = io.open(filename, 'r')
|
||||
if not file then error("file not found: "..filename) end
|
||||
local code = file:read('*a')
|
||||
predefines = predefines or {}
|
||||
predefines[__FILE__] = filename
|
||||
return lcpp.compile(code, predefines)
|
||||
end
|
||||
|
||||
function lcpp.compileHeaderFile(filename, predefines)
|
||||
if not filename then error("processFile() arg1 has to be a string") end
|
||||
local file = io.open(filename, 'r')
|
||||
if not file then error("file not found: "..filename) end
|
||||
local code = file:read('*a')
|
||||
predefines = predefines or {}
|
||||
predefines[__FILE__] = filename
|
||||
return lcpp.compile2(code, predefines)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ------------
|
||||
-- REGISTER LCPP
|
||||
-- ------------
|
||||
|
||||
--- disable lcpp processing for ffi, loadstring and such
|
||||
lcpp.disable = function()
|
||||
if lcpp.LCPP_LUA then
|
||||
-- activate LCPP_LUA actually does anything useful
|
||||
-- _G.loadstring = _G.loadstring_lcpp_backup
|
||||
end
|
||||
|
||||
if lcpp.LCPP_FFI and pcall(require, "ffi") then
|
||||
ffi = require("ffi")
|
||||
if ffi.lcpp_cdef_backup then
|
||||
ffi.cdef = ffi.lcpp_cdef_backup
|
||||
ffi.lcpp_cdef_backup = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- (re)enable lcpp processing for ffi, loadstring and such
|
||||
lcpp.enable = function()
|
||||
-- Use LCPP to process Lua code (load, loadfile, loadstring...)
|
||||
if lcpp.LCPP_LUA then
|
||||
-- TODO: make it properly work on all functions
|
||||
error("lcpp.LCPP_LUA = true -- not properly implemented yet");
|
||||
_G.loadstring_lcpp_backup = _G.loadstring
|
||||
_G.loadstring = function(str, chunk)
|
||||
return loadstring_lcpp_backup(lcpp.compile(str), chunk)
|
||||
end
|
||||
end
|
||||
-- Use LCPP as LuaJIT PreProcessor if used inside LuaJIT. i.e. Hook ffi.cdef
|
||||
if lcpp.LCPP_FFI and pcall(require, "ffi") then
|
||||
ffi = require("ffi")
|
||||
if not ffi.lcpp_cdef_backup then
|
||||
if not ffi.lcpp_defs then ffi.lcpp_defs = {} end -- defs are stored and reused
|
||||
ffi.lcpp = function(input)
|
||||
local output, state = lcpp.compile(input, ffi.lcpp_defs)
|
||||
ffi.lcpp_defs = state.defines
|
||||
return output
|
||||
end
|
||||
ffi.lcpp_cdef_backup = ffi.cdef
|
||||
ffi.cdef = function(input) return ffi.lcpp_cdef_backup(ffi.lcpp(input)) end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
lcpp.enable()
|
||||
return lcpp
|
||||
317
Engine/lib/bullet/build3/premake4.lua
Normal file
317
Engine/lib/bullet/build3/premake4.lua
Normal file
|
|
@ -0,0 +1,317 @@
|
|||
|
||||
solution "0_Bullet3Solution"
|
||||
|
||||
local osversion = os.getversion()
|
||||
print(string.format(" %d.%d.%d (%s)",
|
||||
osversion.majorversion, osversion.minorversion, osversion.revision,
|
||||
osversion.description))
|
||||
|
||||
if _ACTION == "vs2010" or _ACTION=="vs2008" then
|
||||
buildoptions
|
||||
{
|
||||
-- Multithreaded compiling
|
||||
"/MP",
|
||||
-- Disable a few useless warnings
|
||||
"/wd4244",
|
||||
"/wd4267"
|
||||
}
|
||||
end
|
||||
|
||||
act = ""
|
||||
|
||||
if _ACTION then
|
||||
act = _ACTION
|
||||
end
|
||||
|
||||
newoption {
|
||||
trigger = "ios",
|
||||
description = "Enable iOS target (requires xcode4)"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "enable_system_opengl",
|
||||
description = "Try to link and use the system OpenGL headers version instead of dynamically loading OpenGL (dlopen is default)"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "enable_openvr",
|
||||
description = "Enable experimental Virtual Reality examples, using OpenVR for HTC Vive and Oculus Rift"
|
||||
}
|
||||
newoption
|
||||
{
|
||||
trigger = "enable_system_x11",
|
||||
description = "Try to link and use system X11 headers instead of dynamically loading X11 (dlopen is default)"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "noopengl3",
|
||||
description = "Don't compile any OpenGL3+ code"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "midi",
|
||||
description = "Use Midi controller to control parameters"
|
||||
}
|
||||
|
||||
-- --_OPTIONS["midi"] = "1";
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "no-demos",
|
||||
description = "Don't build demos"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "no-extras",
|
||||
description = "Don't build Extras"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "enet",
|
||||
description = "Enable enet NAT punchthrough test"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "lua",
|
||||
description = "Enable Lua scipting support in Example Browser"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "enable_pybullet",
|
||||
description = "Enable high-level Python scripting of Bullet with URDF/SDF import and synthetic camera."
|
||||
}
|
||||
|
||||
if os.is("Linux") then
|
||||
default_python_include_dir = "/usr/include/python2.7"
|
||||
default_python_lib_dir = "/usr/local/lib/"
|
||||
end
|
||||
|
||||
|
||||
if os.is("Windows") then
|
||||
default_python_include_dir = "C:/Python-3.5.2/include"
|
||||
default_python_lib_dir = "C:/Python-3.5.2/libs"
|
||||
end
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "python_include_dir",
|
||||
value = default_python_include_dir,
|
||||
description = "Python (2.x or 3.x) include directory"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "python_lib_dir",
|
||||
value = default_python_lib_dir,
|
||||
description = "Python (2.x or 3.x) library directory "
|
||||
}
|
||||
|
||||
|
||||
newoption {
|
||||
trigger = "targetdir",
|
||||
value = "path such as ../bin",
|
||||
description = "Set the output location for the generated project files"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "no-test",
|
||||
description = "Disable all tests"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "no-gtest",
|
||||
description = "Disable unit tests using gtest"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "no-bullet3",
|
||||
description = "Do not build bullet3 libs"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "double",
|
||||
description = "Double precision version of Bullet"
|
||||
}
|
||||
|
||||
if _OPTIONS["double"] then
|
||||
defines {"BT_USE_DOUBLE_PRECISION"}
|
||||
end
|
||||
|
||||
|
||||
configurations {"Release", "Debug"}
|
||||
configuration "Release"
|
||||
flags { "Optimize", "EnableSSE2","StaticRuntime", "NoMinimalRebuild", "FloatFast"}
|
||||
configuration "Debug"
|
||||
defines {"_DEBUG=1"}
|
||||
flags { "Symbols", "StaticRuntime" , "NoMinimalRebuild", "NoEditAndContinue" ,"FloatFast"}
|
||||
|
||||
if os.is("Linux") or os.is("macosx") then
|
||||
if os.is64bit() then
|
||||
platforms {"x64"}
|
||||
else
|
||||
platforms {"x32"}
|
||||
end
|
||||
else
|
||||
platforms {"x32","x64"}
|
||||
end
|
||||
|
||||
configuration {"x32"}
|
||||
targetsuffix ("_" .. act)
|
||||
configuration "x64"
|
||||
targetsuffix ("_" .. act .. "_64" )
|
||||
configuration {"x64", "debug"}
|
||||
targetsuffix ("_" .. act .. "_x64_debug")
|
||||
configuration {"x64", "release"}
|
||||
targetsuffix ("_" .. act .. "_x64_release" )
|
||||
configuration {"x32", "debug"}
|
||||
targetsuffix ("_" .. act .. "_debug" )
|
||||
|
||||
configuration{}
|
||||
|
||||
postfix=""
|
||||
|
||||
if _ACTION == "xcode4" then
|
||||
if _OPTIONS["ios"] then
|
||||
_OPTIONS["no-bullet3"] = "1"
|
||||
_OPTIONS["no-gtest"] = "1"
|
||||
|
||||
postfix = "ios";
|
||||
xcodebuildsettings
|
||||
{
|
||||
'INFOPLIST_FILE = "../../test/Bullet2/Info.plist"',
|
||||
'CODE_SIGN_IDENTITY = "iPhone Developer"',
|
||||
"SDKROOT = iphoneos",
|
||||
'ARCHS = "armv7"',
|
||||
'TARGETED_DEVICE_FAMILY = "1,2"',
|
||||
'VALID_ARCHS = "armv7"',
|
||||
}
|
||||
else
|
||||
xcodebuildsettings
|
||||
{
|
||||
'ARCHS = "$(ARCHS_STANDARD_32_BIT) $(ARCHS_STANDARD_64_BIT)"',
|
||||
'VALID_ARCHS = "x86_64 i386"',
|
||||
-- 'SDKROOT = "macosx10.9"',
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- comment-out for now, URDF reader needs exceptions
|
||||
-- flags { "NoRTTI", "NoExceptions"}
|
||||
-- defines { "_HAS_EXCEPTIONS=0" }
|
||||
--printf ( _OPTIONS["targetdir"] )
|
||||
|
||||
targetdir( _OPTIONS["targetdir"] or "../bin" )
|
||||
location("./" .. act .. postfix)
|
||||
|
||||
if not _OPTIONS["python_include_dir"] then
|
||||
_OPTIONS["python_include_dir"] = default_python_include_dir
|
||||
end
|
||||
|
||||
if not _OPTIONS["python_lib_dir"] then
|
||||
_OPTIONS["python_lib_dir"] = default_python_lib_dir
|
||||
end
|
||||
|
||||
|
||||
projectRootDir = os.getcwd() .. "/../"
|
||||
print("Project root directory: " .. projectRootDir);
|
||||
|
||||
dofile ("findOpenCL.lua")
|
||||
dofile ("findDirectX11.lua")
|
||||
dofile ("findOpenGLGlewGlut.lua")
|
||||
|
||||
if (not findOpenGL3()) then
|
||||
defines {"NO_OPENGL3"}
|
||||
end
|
||||
|
||||
language "C++"
|
||||
|
||||
if not _OPTIONS["no-demos"] then
|
||||
include "../examples/ExampleBrowser"
|
||||
include "../examples/OpenGLWindow"
|
||||
include "../examples/ThirdPartyLibs/Gwen"
|
||||
include "../examples/SimpleOpenGL3"
|
||||
include "../examples/TinyRenderer"
|
||||
|
||||
include "../examples/HelloWorld"
|
||||
include "../examples/BasicDemo"
|
||||
include "../examples/InverseDynamics"
|
||||
include "../examples/ExtendedTutorials"
|
||||
include "../examples/SharedMemory"
|
||||
include "../examples/ThirdPartyLibs/BussIK"
|
||||
include "../examples/MultiThreading"
|
||||
|
||||
if _OPTIONS["lua"] then
|
||||
include "../examples/ThirdPartyLibs/lua-5.2.3"
|
||||
end
|
||||
if _OPTIONS["enable_pybullet"] then
|
||||
include "../examples/pybullet"
|
||||
end
|
||||
|
||||
if not _OPTIONS["no-test"] then
|
||||
include "../test/SharedMemory"
|
||||
if _OPTIONS["enet"] then
|
||||
include "../examples/ThirdPartyLibs/enet"
|
||||
include "../test/enet/client"
|
||||
include "../test/enet/server"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if _OPTIONS["no-bullet3"] then
|
||||
print "--no-bullet3 implies --no-demos"
|
||||
_OPTIONS["no-demos"] = "1"
|
||||
else
|
||||
include "../src/Bullet3Common"
|
||||
include "../src/Bullet3Geometry"
|
||||
include "../src/Bullet3Collision"
|
||||
include "../src/Bullet3Dynamics"
|
||||
include "../src/Bullet3OpenCL"
|
||||
include "../src/Bullet3Serialize/Bullet2FileLoader"
|
||||
end
|
||||
|
||||
if _OPTIONS["no-extras"] then
|
||||
print "--no-extras implies --no-demos"
|
||||
_OPTIONS["no-demos"] = "1"
|
||||
else
|
||||
include "../Extras"
|
||||
end
|
||||
|
||||
if not _OPTIONS["no-test"] then
|
||||
include "../test/Bullet2"
|
||||
|
||||
if not _OPTIONS["no-gtest"] then
|
||||
include "../test/gtest-1.7.0"
|
||||
-- include "../test/hello_gtest"
|
||||
include "../test/collision"
|
||||
include "../test/BulletDynamics/pendulum"
|
||||
if not _OPTIONS["no-bullet3"] then
|
||||
if not _OPTIONS["no-extras"] then
|
||||
include "../test/InverseDynamics"
|
||||
end
|
||||
include "../test/TestBullet3OpenCL"
|
||||
end
|
||||
if not _OPTIONS["no-demos"] then
|
||||
-- Gwen is only used for demos
|
||||
include "../test/GwenOpenGLTest"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
include "../src/BulletInverseDynamics"
|
||||
include "../src/BulletSoftBody"
|
||||
include "../src/BulletDynamics"
|
||||
include "../src/BulletCollision"
|
||||
include "../src/LinearMath"
|
||||
|
||||
BIN
Engine/lib/bullet/build3/premake4_linux
Executable file
BIN
Engine/lib/bullet/build3/premake4_linux
Executable file
Binary file not shown.
BIN
Engine/lib/bullet/build3/premake4_linux64
Executable file
BIN
Engine/lib/bullet/build3/premake4_linux64
Executable file
Binary file not shown.
BIN
Engine/lib/bullet/build3/premake4_osx
Executable file
BIN
Engine/lib/bullet/build3/premake4_osx
Executable file
Binary file not shown.
BIN
Engine/lib/bullet/build3/premake4_osx32
Executable file
BIN
Engine/lib/bullet/build3/premake4_osx32
Executable file
Binary file not shown.
66
Engine/lib/bullet/build3/stringify.bat
Normal file
66
Engine/lib/bullet/build3/stringify.bat
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
rem @echo off
|
||||
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/RadixSort32Kernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/RadixSort32KernelsCL.h" --stringname="radixSort32KernelsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/BoundSearchKernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/BoundSearchKernelsCL.h" --stringname="boundSearchKernelsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/PrefixScanKernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/PrefixScanKernelsCL.h" --stringname="prefixScanKernelsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/PrefixScanFloat4Kernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/PrefixScanKernelsFloat4CL.h" --stringname="prefixScanKernelsFloat4CL" stringify
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/FillKernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/FillKernelsCL.h" --stringname="fillKernelsCL" stringify
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/sap.cl" --headerfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/sapKernels.h" --stringname="sapCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/sapFast.cl" --headerfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/sapFastKernels.h" --stringname="sapFastCL" stringify
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/gridBroadphase.cl" --headerfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/gridBroadphaseKernels.h" --stringname="gridBroadphaseCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/parallelLinearBvh.cl" --headerfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/parallelLinearBvhKernels.h" --stringname="parallelLinearBvhCL" stringify
|
||||
|
||||
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/sat.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satKernels.h" --stringname="satKernelsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcave.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcaveKernels.h" --stringname="satConcaveKernelsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/mpr.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h" --stringname="mprKernelsCL" stringify
|
||||
|
||||
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.h" --stringname="satClipKernelsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/primitiveContacts.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/primitiveContacts.h" --stringname="primitiveContactsKernelsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/bvhTraversal.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/bvhTraversal.h" --stringname="bvhTraversalKernelCL" stringify
|
||||
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/integrateKernel.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/integrateKernel.h" --stringname="integrateKernelCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.h" --stringname="updateAabbsKernelCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/solverSetup.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/solverSetup.h" --stringname="solverSetupCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.h" --stringname="solverSetup2CL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/batchingKernels.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/batchingKernels.h" --stringname="batchingKernelsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/batchingKernelsNew.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/batchingKernelsNew.h" --stringname="batchingKernelsNewCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/solverUtils.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/solverUtils.h" --stringname="solverUtilsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/solveContact.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/solveContact.h" --stringname="solveContactCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/solveFriction.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/solveFriction.h" --stringname="solveFrictionCL" stringify
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/jointSolver.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/jointSolver.h" --stringname="solveConstraintRowsCL" stringify
|
||||
|
||||
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/Raycast/kernels/rayCastKernels.cl" --headerfile="../src/Bullet3OpenCL/Raycast/kernels/rayCastKernels.h" --stringname="rayCastKernelCL" stringify
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/instancingVS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/instancingVS.h" --stringname="instancingVertexShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/instancingPS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/instancingPS.h" --stringname="instancingFragmentShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/pointSpriteVS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/pointSpriteVS.h" --stringname="pointSpriteVertexShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/pointSpritePS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/pointSpritePS.h" --stringname="pointSpriteFragmentShader" stringify
|
||||
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/createShadowMapInstancingPS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/createShadowMapInstancingPS.h" --stringname="createShadowMapInstancingFragmentShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/createShadowMapInstancingVS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/createShadowMapInstancingVS.h" --stringname="createShadowMapInstancingVertexShader" stringify
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/useShadowMapInstancingPS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/useShadowMapInstancingPS.h" --stringname="useShadowMapInstancingFragmentShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/useShadowMapInstancingVS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/useShadowMapInstancingVS.h" --stringname="useShadowMapInstancingVertexShader" stringify
|
||||
|
||||
|
||||
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../Demos3/GpuDemos/broadphase/pairsKernel.cl" --headerfile="../Demos3/GpuDemos/broadphase/pairsKernel.h" --stringname="pairsKernelsCL" stringify
|
||||
|
||||
|
||||
|
||||
pause
|
||||
68
Engine/lib/bullet/build3/stringify.sh
Executable file
68
Engine/lib/bullet/build3/stringify.sh
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
#!/bin/sh
|
||||
unamestr=`uname`
|
||||
|
||||
if [ $unamestr = 'Linux' ]; then
|
||||
echo "Using Linux"
|
||||
mypremake="./premake4_linux64"
|
||||
else
|
||||
echo "Assuming Mac OSX"
|
||||
mypremake="./premake4_osx"
|
||||
fi
|
||||
|
||||
#rem @echo off
|
||||
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/RadixSort32Kernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/RadixSort32KernelsCL.h" --stringname="radixSort32KernelsCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/BoundSearchKernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/BoundSearchKernelsCL.h" --stringname="boundSearchKernelsCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/PrefixScanKernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/PrefixScanKernelsCL.h" --stringname="prefixScanKernelsCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/PrefixScanFloat4Kernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/PrefixScanKernelsFloat4CL.h" --stringname="prefixScanKernelsFloat4CL" stringify'
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/FillKernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/FillKernelsCL.h" --stringname="fillKernelsCL" stringify'
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/sap.cl" --headerfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/sapKernels.h" --stringname="sapCL" stringify'
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/gridBroadphase.cl" --headerfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/gridBroadphaseKernels.h" --stringname="gridBroadphaseCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/parallelLinearBvh.cl" --headerfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/parallelLinearBvhKernels.h" --stringname="parallelLinearBvhCL" stringify'
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/sat.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satKernels.h" --stringname="satKernelsCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcave.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcaveKernels.h" --stringname="satConcaveKernelsCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/mpr.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h" --stringname="mprKernelsCL" stringify'
|
||||
|
||||
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.h" --stringname="satClipKernelsCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/primitiveContacts.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/primitiveContacts.h" --stringname="primitiveContactsKernelsCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/bvhTraversal.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/bvhTraversal.h" --stringname="bvhTraversalKernelCL" stringify'
|
||||
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/integrateKernel.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/integrateKernel.h" --stringname="integrateKernelCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.h" --stringname="updateAabbsKernelCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/solverSetup.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/solverSetup.h" --stringname="solverSetupCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.h" --stringname="solverSetup2CL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/batchingKernels.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/batchingKernels.h" --stringname="batchingKernelsCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/batchingKernelsNew.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/batchingKernelsNew.h" --stringname="batchingKernelsNewCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/solverUtils.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/solverUtils.h" --stringname="solverUtilsCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/solveContact.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/solveContact.h" --stringname="solveContactCL" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/solveFriction.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/solveFriction.h" --stringname="solveFrictionCL" stringify'
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody/kernels/jointSolver.cl" --headerfile="../src/Bullet3OpenCL/RigidBody/kernels/jointSolver.h" --stringname="solveConstraintRowsCL" stringify'
|
||||
|
||||
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/Raycast/kernels/rayCastKernels.cl" --headerfile="../src/Bullet3OpenCL/Raycast/kernels/rayCastKernels.h" --stringname="rayCastKernelCL" stringify'
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/instancingVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/instancingVS.h" --stringname="instancingVertexShader" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/instancingPS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/instancingPS.h" --stringname="instancingFragmentShader" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/pointSpriteVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/pointSpriteVS.h" --stringname="pointSpriteVertexShader" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/pointSpritePS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/pointSpritePS.h" --stringname="pointSpriteFragmentShader" stringify'
|
||||
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingPS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingPS.h" --stringname="createShadowMapInstancingFragmentShader" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingVS.h" --stringname="createShadowMapInstancingVertexShader" stringify'
|
||||
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingPS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingPS.h" --stringname="useShadowMapInstancingFragmentShader" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingVS.h" --stringname="useShadowMapInstancingVertexShader" stringify'
|
||||
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenCL/broadphase/pairsKernel.cl" --headerfile="../examples/OpenCL/broadphase/pairsKernel.h" --stringname="pairsKernelsCL" stringify'
|
||||
|
||||
|
||||
|
||||
98
Engine/lib/bullet/build3/stringifyKernel.lua
Normal file
98
Engine/lib/bullet/build3/stringifyKernel.lua
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
|
||||
|
||||
function stringifyKernel(filenameIn, filenameOut, kernelMethod)
|
||||
local BUFSIZE = 10*1024*1024 -- 10MB
|
||||
local f = io.open(filenameIn,"r");
|
||||
local fw = io.open(filenameOut,"w");
|
||||
fw:write("//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project\n")
|
||||
fw:write("static const char* " .. kernelMethod .. "= \\\n")
|
||||
local cc, lc, wc = 0, 0, 0 -- char, line, and word counts
|
||||
while true do
|
||||
local lines, rest = f:read(BUFSIZE, "*line")
|
||||
if not lines then break end
|
||||
|
||||
local i = 0
|
||||
local startpos = 0
|
||||
local slen = string.len(lines)
|
||||
local endpos = 0
|
||||
while true do
|
||||
i = string.find(lines, "\n", i+1) -- find 'next' newline
|
||||
if i == nil then
|
||||
endpos = slen
|
||||
else
|
||||
endpos = i
|
||||
end
|
||||
|
||||
oneline = string.sub(lines,startpos,endpos)
|
||||
oneline = string.gsub(oneline,"\n","")
|
||||
oneline = string.gsub(oneline,"\"","\\\"");
|
||||
oneline = '\"' .. oneline .. '\\n\"'
|
||||
oneline = string.gsub(oneline,"\\\\n","")
|
||||
oneline = oneline .. "\n"
|
||||
--print(oneline)
|
||||
fw:write(oneline);
|
||||
|
||||
if i == nil then break end
|
||||
startpos = i+1
|
||||
end
|
||||
|
||||
if rest then lines = lines .. rest .. '\n' end
|
||||
cc = cc + string.len(lines)
|
||||
-- count words in the chunk
|
||||
local _,t = string.gsub(lines, "%S+", "")
|
||||
wc = wc + t
|
||||
-- count newlines in the chunk
|
||||
_,t = string.gsub(lines, "\n", "\n")
|
||||
lc = lc + t
|
||||
end
|
||||
--print("stringified " .. filenameIn .. " into " .. filenameOut .. " processed " .. lc .. " lines")
|
||||
print(filenameIn .. " (" .. lc .. " lines)")
|
||||
|
||||
f:close()
|
||||
fw:write(";\n")
|
||||
fw:close()
|
||||
end
|
||||
|
||||
|
||||
|
||||
function preprocessKernel(kernelfile, filenameOut, kernelMethod)
|
||||
lcpp=require('lcpp');
|
||||
local out=lcpp.compileFile(kernelfile);
|
||||
local embedFileName = kernelfile .. ".embed"
|
||||
local fw = io.open(embedFileName,"w");
|
||||
fw:write(out)
|
||||
fw:close()
|
||||
stringifyKernel(embedFileName,filenameOut, kernelMethod);
|
||||
end
|
||||
|
||||
|
||||
newoption {
|
||||
trigger = "kernelfile",
|
||||
value = "kernelpath",
|
||||
description = "full path to the kernel source input file"
|
||||
}
|
||||
|
||||
newoption {
|
||||
trigger = "headerfile",
|
||||
value = "path",
|
||||
description = "full path to the header output file"
|
||||
}
|
||||
|
||||
newoption {
|
||||
trigger = "stringname",
|
||||
value = "var",
|
||||
description = "name of the kernel string variable"
|
||||
}
|
||||
|
||||
|
||||
|
||||
newaction {
|
||||
trigger = "stringify",
|
||||
description = "stringify kernels source code into strings",
|
||||
execute = function()
|
||||
preprocessKernel( _OPTIONS["kernelfile"] , _OPTIONS["headerfile"], _OPTIONS["stringname"])
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
|
||||
19
Engine/lib/bullet/build3/stringifyShaders.bat
Normal file
19
Engine/lib/bullet/build3/stringifyShaders.bat
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
rem @echo off
|
||||
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/instancingVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/instancingVS.h" --stringname="instancingVertexShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/instancingPS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/instancingPS.h" --stringname="instancingFragmentShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/pointSpriteVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/pointSpriteVS.h" --stringname="pointSpriteVertexShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/pointSpritePS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/pointSpritePS.h" --stringname="pointSpriteFragmentShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingPS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingPS.h" --stringname="createShadowMapInstancingFragmentShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingVS.h" --stringname="createShadowMapInstancingVertexShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingPS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingPS.h" --stringname="useShadowMapInstancingFragmentShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingVS.h" --stringname="useShadowMapInstancingVertexShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/linesVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/linesVS.h" --stringname="linesVertexShader" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/linesPS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/linesPS.h" --stringname="linesFragmentShader" stringify
|
||||
|
||||
|
||||
|
||||
|
||||
pause
|
||||
6
Engine/lib/bullet/build3/vs2010_bullet2gpu.bat
Normal file
6
Engine/lib/bullet/build3/vs2010_bullet2gpu.bat
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
rem premake4 --with-pe vs2010
|
||||
premake4 --bullet2gpu vs2010
|
||||
|
||||
mkdir vs2010\cache
|
||||
pause
|
||||
Loading…
Add table
Add a link
Reference in a new issue