updated to latest 3rdparty

This commit is contained in:
Miodrag Milanovic 2015-03-26 08:14:29 +01:00
parent 8ba6abb1c0
commit 522a6d8c30
56 changed files with 872 additions and 560 deletions

View File

@ -350,8 +350,8 @@
#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals.
#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference it.
#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness //
#endif
#ifdef __GNUC__
#pragma clang diagnostic ignored "-Wunused-parameter" // warning: unused parameter xxxx
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
#pragma GCC diagnostic ignored "-Wunused-parameter" // warning: unused parameter xxxx
#pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type

View File

@ -432,6 +432,13 @@ Configuration is `<platform>-<debug/release>[32/64]`. For example:
linux-release32, nacl-debug64, nacl-arm-debug, pnacl-release,
android-release, etc.
Amalgamated build
-----------------
For ease of integration to other build system bgfx library can be built with
single .cpp file. It's only necessary to build [src/amalgamated.cpp](https://github.com/bkaradzic/bgfx/blob/master/src/amalgamated.cpp)
inside different build system.
OculusVR integration
--------------------
@ -568,6 +575,11 @@ with examples:
genie --with-sdl vs2012
**NOTE** Special care is necessary to make custom windowing to work with
multithreaded renderer. Each platform has rules about where renderer can be and
how multithreading interacts with context/device. To disable multithreaded
render use `BGFX_CONFIG_MULTITHREDED=0` preprocessor define.
Tools
-----

View File

@ -0,0 +1,139 @@
/*
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include "entry_p.h"
#if ENTRY_CONFIG_USE_GLFW
#define GLFW_DLL
#include <GLFW/glfw3.h>
#include <bgfxplatform.h>
#include "dbg.h"
// This is just trivial implementation of GLFW3 integration.
// It's here just for testing purpose.
namespace entry
{
static void errorCb(int _error, const char* _description)
{
DBG("GLFW error %d: %s", _error, _description);
}
struct Context
{
Context()
{
}
int run(int _argc, char** _argv)
{
glfwSetErrorCallback(errorCb);
glfwInit();
m_window = glfwCreateWindow(1280, 720, "bgfx", NULL, NULL);
glfwMakeContextCurrent(m_window);
glfwSetKeyCallback(m_window, keyCb);
bgfx::glfwSetWindow(m_window);
int result = main(_argc, _argv);
glfwDestroyWindow(m_window);
glfwTerminate();
return result;
}
static void keyCb(GLFWwindow* _window, int _key, int _scancode, int _action, int _mods);
EventQueue m_eventQueue;
GLFWwindow* m_window;
};
Context s_ctx;
void Context::keyCb(GLFWwindow* _window, int _key, int _scancode, int _action, int _mods)
{
BX_UNUSED(_window, _scancode, _mods);
if (_key == GLFW_KEY_Q
&& _action == GLFW_PRESS
&& _mods == GLFW_MOD_CONTROL)
{
s_ctx.m_eventQueue.postExitEvent();
}
}
const Event* poll()
{
glfwPollEvents();
if (glfwWindowShouldClose(s_ctx.m_window) )
{
s_ctx.m_eventQueue.postExitEvent();
}
return s_ctx.m_eventQueue.poll();
}
const Event* poll(WindowHandle _handle)
{
return s_ctx.m_eventQueue.poll(_handle);
}
void release(const Event* _event)
{
s_ctx.m_eventQueue.release(_event);
}
WindowHandle createWindow(int32_t _x, int32_t _y, uint32_t _width, uint32_t _height, uint32_t _flags, const char* _title)
{
BX_UNUSED(_x, _y, _width, _height, _flags, _title);
WindowHandle handle = { UINT16_MAX };
return handle;
}
void destroyWindow(WindowHandle _handle)
{
BX_UNUSED(_handle);
}
void setWindowPos(WindowHandle _handle, int32_t _x, int32_t _y)
{
BX_UNUSED(_handle, _x, _y);
}
void setWindowSize(WindowHandle _handle, uint32_t _width, uint32_t _height)
{
BX_UNUSED(_handle, _width, _height);
}
void setWindowTitle(WindowHandle _handle, const char* _title)
{
BX_UNUSED(_handle, _title);
}
void toggleWindowFrame(WindowHandle _handle)
{
BX_UNUSED(_handle);
}
void toggleFullscreen(WindowHandle _handle)
{
BX_UNUSED(_handle);
}
void setMouseLock(WindowHandle _handle, bool _lock)
{
BX_UNUSED(_handle, _lock);
}
}
int main(int _argc, char** _argv)
{
using namespace entry;
return s_ctx.run(_argc, _argv);
}
#endif // ENTRY_CONFIG_USE_GLFW

View File

@ -311,19 +311,9 @@ namespace entry
else
{
enum { ShiftMask = Modifier::LeftShift|Modifier::RightShift };
const bool nonShiftModifiers = (0 != (modifiers&(~ShiftMask) ) );
const bool isCharPressed = (Key::Key0 <= key && key <= Key::KeyZ) || (Key::Esc <= key && key <= Key::Minus);
const bool isText = isCharPressed && !nonShiftModifiers;
if (isText)
{
m_eventQueue.postCharEvent(s_defaultWindow, 1, pressedChar);
return false;
}
else
{
m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, true);
return false;
}
m_eventQueue.postCharEvent(s_defaultWindow, 1, pressedChar);
m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, true);
return false;
}
}

View File

@ -17,8 +17,13 @@
# define ENTRY_CONFIG_USE_SDL 0
#endif // ENTRY_CONFIG_USE_SDL
#if !ENTRY_CONFIG_USE_SDL && \
!defined(ENTRY_CONFIG_USE_NATIVE)
#ifndef ENTRY_CONFIG_USE_GLFW
# define ENTRY_CONFIG_USE_GLFW 0
#endif // ENTRY_CONFIG_USE_GLFW
#if !defined(ENTRY_CONFIG_USE_NATIVE) \
&& !ENTRY_CONFIG_USE_SDL \
&& !ENTRY_CONFIG_USE_GLFW
# define ENTRY_CONFIG_USE_NATIVE 1
#else
# define ENTRY_CONFIG_USE_NATIVE 0

View File

@ -1,3 +1,4 @@
*.dll
*.so
*.pdb
imgui*

View File

@ -81,16 +81,16 @@
| BGFX_STATE_MSAA \
)
#define BGFX_STATE_ALPHA_REF(_ref) ( (uint64_t(_ref)<<BGFX_STATE_ALPHA_REF_SHIFT)&BGFX_STATE_ALPHA_REF_MASK)
#define BGFX_STATE_POINT_SIZE(_size) ( (uint64_t(_size)<<BGFX_STATE_POINT_SIZE_SHIFT)&BGFX_STATE_POINT_SIZE_MASK)
#define BGFX_STATE_ALPHA_REF(_ref) ( ( (uint64_t)(_ref )<<BGFX_STATE_ALPHA_REF_SHIFT )&BGFX_STATE_ALPHA_REF_MASK)
#define BGFX_STATE_POINT_SIZE(_size) ( ( (uint64_t)(_size)<<BGFX_STATE_POINT_SIZE_SHIFT)&BGFX_STATE_POINT_SIZE_MASK)
///
#define BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA) (0 \
| ( (uint64_t(_srcRGB)|(uint64_t(_dstRGB)<<4) ) ) \
| ( (uint64_t(_srcA )|(uint64_t(_dstA )<<4) )<<8) \
#define BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA) (UINT64_C(0) \
| ( ( (uint64_t)(_srcRGB)|( (uint64_t)(_dstRGB)<<4) ) ) \
| ( ( (uint64_t)(_srcA )|( (uint64_t)(_dstA )<<4) )<<8) \
)
#define BGFX_STATE_BLEND_EQUATION_SEPARATE(_rgb, _a) (uint64_t(_rgb)|(uint64_t(_a)<<3) )
#define BGFX_STATE_BLEND_EQUATION_SEPARATE(_rgb, _a) ( (uint64_t)(_rgb)|( (uint64_t)(_a)<<3) )
///
#define BGFX_STATE_BLEND_FUNC(_src, _dst) BGFX_STATE_BLEND_FUNC_SEPARATE(_src, _dst, _src, _dst)

View File

@ -55,7 +55,7 @@ namespace bgfx
namespace bgfx
{
///
void x11SetDisplayWindow(void* _display, uint32_t _window);
void x11SetDisplayWindow(void* _display, uint32_t _window, void* _glx = NULL);
} // namespace bgfx
@ -76,7 +76,7 @@ namespace bgfx
namespace bgfx
{
///
void osxSetNSWindow(void* _window);
void osxSetNSWindow(void* _window, void* _nsgl = NULL);
} // namespace bgfx
@ -155,15 +155,17 @@ namespace bgfx
{
# if BX_PLATFORM_LINUX || BX_PLATFORM_FREEBSD
::Display* display = glfwGetX11Display();
::Window window = glfwGetX11Window(_window);
x11SetDisplayWindow(display, window);
::Window window = glfwGetX11Window(_window);
void* glx = glfwGetGLXContext(_window);
x11SetDisplayWindow(display, window, glx);
# elif BX_PLATFORM_OSX
void* id = glfwGetCocoaWindow(_window);
osxSetNSWindow(id);
void* window = glfwGetCocoaWindow(_window);
void* nsgl = glfwGetNSGLContext(_window);
osxSetNSWindow(window, nsgl);
# elif BX_PLATFORM_WINDOWS
HWND hwnd = glfwGetWin32Window(_window);
winSetHwnd(hwnd);
# endif BX_PLATFORM_WINDOWS
# endif // BX_PLATFORM_WINDOWS
}
} // namespace bgfx

View File

@ -26,7 +26,7 @@ function bgfxProject(_name, _kind, _defines)
}
configuration { "linux-*" }
buildoptions {
buildoptions {
"-fPIC",
}
@ -42,6 +42,12 @@ function bgfxProject(_name, _kind, _defines)
_defines,
}
if _OPTIONS["with-glfw"] then
defines {
"BGFX_CONFIG_MULTITHREADED=0",
}
end
if _OPTIONS["with-ovr"] then
defines {
"BGFX_CONFIG_USE_OVR=1",
@ -113,10 +119,34 @@ function bgfxProject(_name, _kind, _defines)
path.join(BGFX_DIR, "src/**.h"),
}
excludes {
removefiles {
path.join(BGFX_DIR, "src/**.bin.h"),
}
if _OPTIONS["with-amalgamated"] then
excludes {
path.join(BGFX_DIR, "src/bgfx.cpp"),
path.join(BGFX_DIR, "src/glcontext_egl.cpp"),
path.join(BGFX_DIR, "src/glcontext_glx.cpp"),
path.join(BGFX_DIR, "src/glcontext_ppapi.cpp"),
path.join(BGFX_DIR, "src/glcontext_wgl.cpp"),
path.join(BGFX_DIR, "src/image.cpp"),
path.join(BGFX_DIR, "src/ovr.cpp"),
path.join(BGFX_DIR, "src/renderdoc.cpp"),
path.join(BGFX_DIR, "src/renderer_d3d9.cpp"),
path.join(BGFX_DIR, "src/renderer_d3d11.cpp"),
path.join(BGFX_DIR, "src/renderer_d3d12.cpp"),
path.join(BGFX_DIR, "src/renderer_null.cpp"),
path.join(BGFX_DIR, "src/renderer_gl.cpp"),
path.join(BGFX_DIR, "src/renderer_vk.cpp"),
path.join(BGFX_DIR, "src/vertexdecl.cpp"),
}
else
excludes {
path.join(BGFX_DIR, "src/amalgamated.cpp"),
}
end
configuration {}
copyLib()

View File

@ -31,6 +31,12 @@ project ("example-common")
}
end
if _OPTIONS["with-glfw"] then
defines {
"ENTRY_CONFIG_USE_GLFW=1",
}
end
configuration { "mingw* or vs2008" }
includedirs {
"$(DXSDK_DIR)/include",

View File

@ -4,13 +4,13 @@
--
newoption {
trigger = "with-tools",
description = "Enable building tools.",
trigger = "with-amalgamated",
description = "Enable amalgamated build.",
}
newoption {
trigger = "with-shared-lib",
description = "Enable building shared library.",
trigger = "with-ovr",
description = "Enable OculusVR integration.",
}
newoption {
@ -19,8 +19,18 @@ newoption {
}
newoption {
trigger = "with-ovr",
description = "Enable OculusVR integration.",
trigger = "with-glfw",
description = "Enable GLFW entry.",
}
newoption {
trigger = "with-shared-lib",
description = "Enable building shared library.",
}
newoption {
trigger = "with-tools",
description = "Enable building tools.",
}
solution "bgfx"
@ -32,14 +42,14 @@ solution "bgfx"
if _ACTION == "xcode4" then
platforms {
"Universal",
}
}
else
platforms {
"x32",
"x64",
-- "Xbox360",
"Native", -- for targets where bitness is not specified
}
}
end
language "C++"
@ -96,6 +106,10 @@ function exampleProject(_name)
path.join(BGFX_DIR, "examples", _name, "**.h"),
}
removefiles {
path.join(BGFX_DIR, "examples", _name, "**.bin.h"),
}
links {
"bgfx",
"example-common",
@ -114,6 +128,30 @@ function exampleProject(_name)
configuration {}
end
if _OPTIONS["with-glfw"] then
defines { "ENTRY_CONFIG_USE_GLFW=1" }
links {
"glfw3"
}
configuration { "linux" }
links {
"Xrandr",
"Xinerama",
"Xi",
"Xxf86vm",
"Xcursor",
}
configuration { "osx" }
linkoptions {
"-framework CoreVideo",
"-framework IOKit",
}
configuration {}
end
if _OPTIONS["with-ovr"] then
links {
"winmm",

20
3rdparty/bgfx/src/amalgamated.cpp vendored Normal file
View File

@ -0,0 +1,20 @@
/*
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include "bgfx.cpp"
#include "glcontext_egl.cpp"
#include "glcontext_glx.cpp"
#include "glcontext_ppapi.cpp"
#include "glcontext_wgl.cpp"
#include "image.cpp"
#include "ovr.cpp"
#include "renderdoc.cpp"
#include "renderer_d3d9.cpp"
#include "renderer_d3d11.cpp"
#include "renderer_d3d12.cpp"
#include "renderer_null.cpp"
#include "renderer_gl.cpp"
#include "renderer_vk.cpp"
#include "vertexdecl.cpp"

View File

@ -19,14 +19,6 @@ namespace bgfx
# define BGFX_CHECK_RENDER_THREAD()
#endif // BGFX_CONFIG_MULTITHREADED && !BX_PLATFORM_OSX && !BX_PLATFORM_IOS
#define BGFX_CHECK_HANDLE(_handle, _max) \
BX_CHECK(isValid(_handle) \
&& _handle.idx < _max \
, "Invalid handle. %d (< %d " #_max ")" \
, _handle.idx \
, _max \
);
#if BX_PLATFORM_ANDROID
::ANativeWindow* g_bgfxAndroidWindow = NULL;
@ -44,18 +36,22 @@ namespace bgfx
#elif BX_PLATFORM_LINUX
void* g_bgfxX11Display;
uint32_t g_bgfxX11Window;
void* g_bgfxGLX;
void x11SetDisplayWindow(void* _display, uint32_t _window)
void x11SetDisplayWindow(void* _display, uint32_t _window, void* _glx)
{
g_bgfxX11Display = _display;
g_bgfxX11Window = _window;
g_bgfxGLX = _glx;
}
#elif BX_PLATFORM_OSX
void* g_bgfxNSWindow = NULL;
void* g_bgfxNSGL = NULL;
void osxSetNSWindow(void* _window)
void osxSetNSWindow(void* _window, void* _nsgl)
{
g_bgfxNSWindow = _window;
g_bgfxNSGL = _nsgl;
}
#elif BX_PLATFORM_WINDOWS
::HWND g_bgfxHwnd = NULL;
@ -1332,23 +1328,21 @@ namespace bgfx
typedef RendererContextI* (*RendererCreateFn)();
typedef void (*RendererDestroyFn)();
extern RendererContextI* rendererCreateNULL();
extern void rendererDestroyNULL();
#define BGFX_RENDERER_CONTEXT(_namespace) \
namespace _namespace \
{ \
extern RendererContextI* rendererCreate(); \
extern void rendererDestroy(); \
}
extern RendererContextI* rendererCreateGL();
extern void rendererDestroyGL();
BGFX_RENDERER_CONTEXT(noop);
BGFX_RENDERER_CONTEXT(d3d9);
BGFX_RENDERER_CONTEXT(d3d11);
BGFX_RENDERER_CONTEXT(d3d12);
BGFX_RENDERER_CONTEXT(gl);
BGFX_RENDERER_CONTEXT(vk);
extern RendererContextI* rendererCreateD3D9();
extern void rendererDestroyD3D9();
extern RendererContextI* rendererCreateD3D11();
extern void rendererDestroyD3D11();
extern RendererContextI* rendererCreateD3D12();
extern void rendererDestroyD3D12();
extern RendererContextI* rendererCreateVK();
extern void rendererDestroyVK();
#undef BGFX_RENDERER_CONTEXT
struct RendererCreator
{
@ -1360,13 +1354,13 @@ namespace bgfx
static const RendererCreator s_rendererCreator[] =
{
{ rendererCreateNULL, rendererDestroyNULL, BGFX_RENDERER_NULL_NAME, !!BGFX_CONFIG_RENDERER_NULL }, // Null
{ rendererCreateD3D9, rendererDestroyD3D9, BGFX_RENDERER_DIRECT3D9_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D9 }, // Direct3D9
{ rendererCreateD3D11, rendererDestroyD3D11, BGFX_RENDERER_DIRECT3D11_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D11 }, // Direct3D11
{ rendererCreateD3D12, rendererDestroyD3D12, BGFX_RENDERER_DIRECT3D12_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D12 }, // Direct3D12
{ rendererCreateGL, rendererDestroyGL, BGFX_RENDERER_OPENGL_NAME, !!BGFX_CONFIG_RENDERER_OPENGLES }, // OpenGLES
{ rendererCreateGL, rendererDestroyGL, BGFX_RENDERER_OPENGL_NAME, !!BGFX_CONFIG_RENDERER_OPENGL }, // OpenGL
{ rendererCreateVK, rendererDestroyVK, BGFX_RENDERER_VULKAN_NAME, !!BGFX_CONFIG_RENDERER_VULKAN }, // Vulkan
{ noop::rendererCreate, noop::rendererDestroy, BGFX_RENDERER_NULL_NAME, !!BGFX_CONFIG_RENDERER_NULL }, // Null
{ d3d9::rendererCreate, d3d9::rendererDestroy, BGFX_RENDERER_DIRECT3D9_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D9 }, // Direct3D9
{ d3d11::rendererCreate, d3d11::rendererDestroy, BGFX_RENDERER_DIRECT3D11_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D11 }, // Direct3D11
{ d3d12::rendererCreate, d3d12::rendererDestroy, BGFX_RENDERER_DIRECT3D12_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D12 }, // Direct3D12
{ gl::rendererCreate, gl::rendererDestroy, BGFX_RENDERER_OPENGL_NAME, !!BGFX_CONFIG_RENDERER_OPENGLES }, // OpenGLES
{ gl::rendererCreate, gl::rendererDestroy, BGFX_RENDERER_OPENGL_NAME, !!BGFX_CONFIG_RENDERER_OPENGL }, // OpenGL
{ vk::rendererCreate, vk::rendererDestroy, BGFX_RENDERER_VULKAN_NAME, !!BGFX_CONFIG_RENDERER_VULKAN }, // Vulkan
};
BX_STATIC_ASSERT(BX_COUNTOF(s_rendererCreator) == RendererType::Count);
@ -2770,21 +2764,18 @@ again:
void setUniform(UniformHandle _handle, const void* _value, uint16_t _num)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_UNIFORMS);
s_ctx->setUniform(_handle, _value, _num);
}
void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_INDEX_BUFFERS);
s_ctx->setIndexBuffer(_handle, _firstIndex, _numIndices);
}
void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS);
s_ctx->setIndexBuffer(_handle, _firstIndex, _numIndices);
}
@ -2809,14 +2800,12 @@ again:
void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_VERTEX_BUFFERS);
s_ctx->setVertexBuffer(_handle, _startVertex, _numVertices);
}
void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS);
s_ctx->setVertexBuffer(_handle, _numVertices);
}
@ -2842,21 +2831,18 @@ again:
void setInstanceDataBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_VERTEX_BUFFERS);
s_ctx->setInstanceDataBuffer(_handle, _startVertex, _num);
}
void setInstanceDataBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS);
s_ctx->setInstanceDataBuffer(_handle, _startVertex, _num);
}
void setProgram(ProgramHandle _handle)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_PROGRAMS);
s_ctx->setProgram(_handle);
}
@ -2881,28 +2867,24 @@ again:
void setBuffer(uint8_t _stage, IndexBufferHandle _handle, Access::Enum _access)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_INDEX_BUFFERS);
s_ctx->setBuffer(_stage, _handle, _access);
}
void setBuffer(uint8_t _stage, VertexBufferHandle _handle, Access::Enum _access)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_VERTEX_BUFFERS);
s_ctx->setBuffer(_stage, _handle, _access);
}
void setBuffer(uint8_t _stage, DynamicIndexBufferHandle _handle, Access::Enum _access)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS);
s_ctx->setBuffer(_stage, _handle, _access);
}
void setBuffer(uint8_t _stage, DynamicVertexBufferHandle _handle, Access::Enum _access)
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS);
s_ctx->setBuffer(_stage, _handle, _access);
}

View File

@ -29,6 +29,15 @@
#include <string.h>
#include <alloca.h>
#define BGFX_CHECK_HANDLE(_desc, _handleAlloc, _handle) \
BX_CHECK(isValid(_handle) \
&& _handleAlloc.isValid(_handle.idx) \
, "Invalid handle. %s handle: %d (max %d)" \
, _desc \
, _handle.idx \
, _handleAlloc.getMaxHandles() \
);
namespace bgfx
{
#if BX_COMPILER_CLANG_ANALYZER
@ -204,8 +213,10 @@ namespace bgfx
#elif BX_PLATFORM_LINUX
extern void* g_bgfxX11Display;
extern uint32_t g_bgfxX11Window;
extern void* g_bgfxGLX;
#elif BX_PLATFORM_OSX
extern void* g_bgfxNSWindow;
extern void* g_bgfxNSGL;
#elif BX_PLATFORM_WINDOWS
extern ::HWND g_bgfxHwnd;
#elif BX_PLATFORM_WINRT
@ -1418,7 +1429,10 @@ namespace bgfx
{
Binding& sampler = m_draw.m_bind[_stage];
sampler.m_idx = _handle.idx;
sampler.m_un.m_draw.m_flags = (_flags&BGFX_SAMPLER_DEFAULT_FLAGS) ? BGFX_SAMPLER_DEFAULT_FLAGS : _flags;
sampler.m_un.m_draw.m_flags = (_flags&BGFX_SAMPLER_DEFAULT_FLAGS)
? BGFX_SAMPLER_DEFAULT_FLAGS
: _flags
;
if (isValid(_sampler)
&& (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) || BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) ) )
@ -1989,6 +2003,8 @@ namespace bgfx
BGFX_API_FUNC(void destroyIndexBuffer(IndexBufferHandle _handle) )
{
BGFX_CHECK_HANDLE("destroyIndexBuffer", m_indexBufferHandle, _handle);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyIndexBuffer);
cmdbuf.write(_handle);
m_submit->free(_handle);
@ -2034,6 +2050,8 @@ namespace bgfx
BGFX_API_FUNC(void destroyVertexBuffer(VertexBufferHandle _handle) )
{
BGFX_CHECK_HANDLE("destroyVertexBuffer", m_vertexBufferHandle, _handle);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexBuffer);
cmdbuf.write(_handle);
m_submit->free(_handle);
@ -2135,6 +2153,8 @@ namespace bgfx
BGFX_API_FUNC(void updateDynamicIndexBuffer(DynamicIndexBufferHandle _handle, const Memory* _mem) )
{
BGFX_CHECK_HANDLE("updateDynamicIndexBuffer", m_dynamicIndexBufferHandle, _handle);
DynamicIndexBuffer& dib = m_dynamicIndexBuffers[_handle.idx];
BX_CHECK(0 == (dib.m_flags & BGFX_BUFFER_COMPUTE_READ_WRITE), "Can't update GPU buffer from CPU.");
@ -2166,6 +2186,8 @@ namespace bgfx
BGFX_API_FUNC(void destroyDynamicIndexBuffer(DynamicIndexBufferHandle _handle) )
{
BGFX_CHECK_HANDLE("destroyDynamicIndexBuffer", m_dynamicIndexBufferHandle, _handle);
m_freeDynamicIndexBufferHandle[m_numFreeDynamicIndexBufferHandles++] = _handle;
}
@ -2279,6 +2301,8 @@ namespace bgfx
BGFX_API_FUNC(void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, const Memory* _mem) )
{
BGFX_CHECK_HANDLE("updateDynamicVertexBuffer", m_dynamicVertexBufferHandle, _handle);
DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx];
BX_CHECK(0 == (dvb.m_flags & BGFX_BUFFER_COMPUTE_READ_WRITE), "Can't update GPU buffer from CPU.");
@ -2311,6 +2335,8 @@ namespace bgfx
BGFX_API_FUNC(void destroyDynamicVertexBuffer(DynamicVertexBufferHandle _handle) )
{
BGFX_CHECK_HANDLE("destroyDynamicVertexBuffer", m_dynamicVertexBufferHandle, _handle);
m_freeDynamicVertexBufferHandle[m_numFreeDynamicVertexBufferHandles++] = _handle;
}
@ -2593,6 +2619,8 @@ namespace bgfx
BGFX_API_FUNC(void destroyShader(ShaderHandle _handle) )
{
BGFX_CHECK_HANDLE("destroyShader", m_shaderHandle, _handle);
if (!isValid(_handle) )
{
BX_WARN(false, "Passing invalid shader handle to bgfx::destroyShader.");
@ -2704,6 +2732,8 @@ namespace bgfx
BGFX_API_FUNC(void destroyProgram(ProgramHandle _handle) )
{
BGFX_CHECK_HANDLE("destroyProgram", m_programHandle, _handle);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyProgram);
cmdbuf.write(_handle);
m_submit->free(_handle);
@ -2769,6 +2799,8 @@ namespace bgfx
BGFX_API_FUNC(void destroyTexture(TextureHandle _handle) )
{
BGFX_CHECK_HANDLE("destroyTexture", m_textureHandle, _handle);
if (!isValid(_handle) )
{
BX_WARN(false, "Passing invalid texture handle to bgfx::destroyTexture");
@ -2832,6 +2864,7 @@ namespace bgfx
for (uint32_t ii = 0; ii < _num; ++ii)
{
TextureHandle texHandle = _handles[ii];
BGFX_CHECK_HANDLE("createFrameBuffer texture handle", m_textureHandle, texHandle);
cmdbuf.write(texHandle);
@ -2868,6 +2901,8 @@ namespace bgfx
BGFX_API_FUNC(void destroyFrameBuffer(FrameBufferHandle _handle) )
{
BGFX_CHECK_HANDLE("destroyFrameBuffer", m_frameBufferHandle, _handle);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyFrameBuffer);
cmdbuf.write(_handle);
m_submit->free(_handle);
@ -2951,6 +2986,8 @@ namespace bgfx
BGFX_API_FUNC(void destroyUniform(UniformHandle _handle) )
{
BGFX_CHECK_HANDLE("destroyUniform", m_uniformHandle, _handle);
UniformRef& uniform = m_uniformRef[_handle.idx];
BX_CHECK(uniform.m_refCount > 0, "Destroying already destroyed uniform %d.", _handle.idx);
int32_t refs = --uniform.m_refCount;
@ -3054,6 +3091,7 @@ namespace bgfx
BGFX_API_FUNC(void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle) )
{
BGFX_CHECK_HANDLE("setViewFrameBuffer", m_frameBufferHandle, _handle);
m_fb[_id] = _handle;
}
@ -3091,7 +3129,7 @@ namespace bgfx
BGFX_API_FUNC(void setViewRemap(uint8_t _id, uint8_t _num, const void* _remap) )
{
const uint32_t num = bx::uint32_min( (BGFX_CONFIG_MAX_VIEWS - _id) + _num, BGFX_CONFIG_MAX_VIEWS) - _id;
const uint32_t num = bx::uint32_min(_id + _num, BGFX_CONFIG_MAX_VIEWS) - _id;
if (NULL == _remap)
{
for (uint32_t ii = 0; ii < num; ++ii)
@ -3148,6 +3186,7 @@ namespace bgfx
BGFX_API_FUNC(void setUniform(UniformHandle _handle, const void* _value, uint16_t _num) )
{
BGFX_CHECK_HANDLE("setUniform", m_uniformHandle, _handle);
UniformRef& uniform = m_uniformRef[_handle.idx];
BX_CHECK(uniform.m_num >= _num, "Truncated uniform update. %d (max: %d)", _num, uniform.m_num);
m_submit->writeUniform(uniform.m_type, _handle, _value, bx::uint16_min(uniform.m_num, _num) );
@ -3155,11 +3194,13 @@ namespace bgfx
BGFX_API_FUNC(void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices) )
{
BGFX_CHECK_HANDLE("setIndexBuffer", m_indexBufferHandle, _handle);
m_submit->setIndexBuffer(_handle, _firstIndex, _numIndices);
}
BGFX_API_FUNC(void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices) )
{
BGFX_CHECK_HANDLE("setIndexBuffer", m_dynamicIndexBufferHandle, _handle);
m_submit->setIndexBuffer(m_dynamicIndexBuffers[_handle.idx], _firstIndex, _numIndices);
}
@ -3170,11 +3211,13 @@ namespace bgfx
BGFX_API_FUNC(void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) )
{
BGFX_CHECK_HANDLE("setVertexBuffer", m_vertexBufferHandle, _handle);
m_submit->setVertexBuffer(_handle, _startVertex, _numVertices);
}
BGFX_API_FUNC(void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices) )
{
BGFX_CHECK_HANDLE("setVertexBuffer", m_dynamicVertexBufferHandle, _handle);
m_submit->setVertexBuffer(m_dynamicVertexBuffers[_handle.idx], _numVertices);
}
@ -3192,12 +3235,14 @@ namespace bgfx
BGFX_API_FUNC(void setInstanceDataBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num) )
{
BGFX_CHECK_HANDLE("setInstanceDataBuffer", m_vertexBufferHandle, _handle);
const VertexBuffer& vb = m_vertexBuffers[_handle.idx];
m_submit->setInstanceDataBuffer(_handle, _startVertex, _num, vb.m_stride);
}
BGFX_API_FUNC(void setInstanceDataBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num) )
{
BGFX_CHECK_HANDLE("setInstanceDataBuffer", m_dynamicVertexBufferHandle, _handle);
const DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx];
m_submit->setInstanceDataBuffer(dvb.m_handle
, dvb.m_startVertex + _startVertex
@ -3208,11 +3253,13 @@ namespace bgfx
BGFX_API_FUNC(void setProgram(ProgramHandle _handle) )
{
BGFX_CHECK_HANDLE("setProgram", m_programHandle, _handle);
m_submit->setProgram(_handle);
}
BGFX_API_FUNC(void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags) )
{
BGFX_CHECK_HANDLE("setTexture", m_textureHandle, _handle);
m_submit->setTexture(_stage, _sampler, _handle, _flags);
}
@ -3238,22 +3285,26 @@ namespace bgfx
BGFX_API_FUNC(void setBuffer(uint8_t _stage, IndexBufferHandle _handle, Access::Enum _access) )
{
BGFX_CHECK_HANDLE("setBuffer", m_indexBufferHandle, _handle);
m_submit->setBuffer(_stage, _handle, _access);
}
BGFX_API_FUNC(void setBuffer(uint8_t _stage, VertexBufferHandle _handle, Access::Enum _access) )
{
BGFX_CHECK_HANDLE("setBuffer", m_vertexBufferHandle, _handle);
m_submit->setBuffer(_stage, _handle, _access);
}
BGFX_API_FUNC(void setBuffer(uint8_t _stage, DynamicIndexBufferHandle _handle, Access::Enum _access) )
{
BGFX_CHECK_HANDLE("setBuffer", m_dynamicIndexBufferHandle, _handle);
const DynamicIndexBuffer& dib = m_dynamicIndexBuffers[_handle.idx];
m_submit->setBuffer(_stage, dib.m_handle, _access);
}
BGFX_API_FUNC(void setBuffer(uint8_t _stage, DynamicVertexBufferHandle _handle, Access::Enum _access) )
{
BGFX_CHECK_HANDLE("setBuffer", m_dynamicVertexBufferHandle, _handle);
const DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx];
m_submit->setBuffer(_stage, dvb.m_handle, _access);
}

View File

@ -8,7 +8,7 @@
#if BX_PLATFORM_IOS
namespace bgfx
namespace bgfx { namespace gl
{
struct SwapChainGL;
@ -48,7 +48,7 @@ namespace bgfx
GLuint m_colorRbo;
GLuint m_depthStencilRbo;
};
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
#endif // BX_PLATFORM_IOS

View File

@ -10,7 +10,7 @@
# include <QuartzCore/CAEAGLLayer.h>
# include "renderer_gl.h"
namespace bgfx
namespace bgfx { namespace gl
{
# define GL_IMPORT(_optional, _proto, _func, _import) _proto _func = NULL
# include "glimports.h"
@ -123,6 +123,6 @@ namespace bgfx
{
}
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
#endif // BX_PLATFORM_IOS && (BGFX_CONFIG_RENDERER_OPENGLES2|BGFX_CONFIG_RENDERER_OPENGLES3|BGFX_CONFIG_RENDERER_OPENGL)

View File

@ -22,7 +22,7 @@
# define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB
#endif // EGL_CONTEXT_MINOR_VERSION_KHR
namespace bgfx
namespace bgfx { namespace gl
{
#if BGFX_USE_GL_DYNAMIC_LIB
@ -369,7 +369,7 @@ EGL_IMPORT
# include "glimports.h"
}
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
# endif // BGFX_USE_EGL
#endif // (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL)

View File

@ -10,7 +10,7 @@
#include <EGL/egl.h>
namespace bgfx
namespace bgfx { namespace gl
{
struct SwapChainGL;
@ -48,7 +48,7 @@ namespace bgfx
EGLDisplay m_display;
EGLSurface m_surface;
};
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
#endif // BGFX_USE_EGL

View File

@ -12,7 +12,7 @@
# define GLX_GLXEXT_PROTOTYPES
# include <glx/glxext.h>
namespace bgfx
namespace bgfx { namespace gl
{
typedef int (*PFNGLXSWAPINTERVALMESAPROC)(uint32_t _interval);
@ -55,122 +55,128 @@ namespace bgfx
void GlContext::create(uint32_t _width, uint32_t _height)
{
BX_UNUSED(_width, _height);
XLockDisplay( (::Display*)g_bgfxX11Display);
int major, minor;
bool version = glXQueryVersion( (::Display*)g_bgfxX11Display, &major, &minor);
BGFX_FATAL(version, Fatal::UnableToInitialize, "Failed to query GLX version");
BGFX_FATAL( (major == 1 && minor >= 2) || major > 1
, Fatal::UnableToInitialize
, "GLX version is not >=1.2 (%d.%d)."
, major
, minor
);
m_context = (GLXContext)g_bgfxGLX;
int32_t screen = DefaultScreen( (::Display*)g_bgfxX11Display);
const char* extensions = glXQueryExtensionsString( (::Display*)g_bgfxX11Display, screen);
BX_TRACE("GLX extensions:");
dumpExtensions(extensions);
const int attrsGlx[] =
if (NULL == g_bgfxGLX)
{
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_DOUBLEBUFFER, true,
GLX_RED_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_GREEN_SIZE, 8,
// GLX_ALPHA_SIZE, 8,
GLX_DEPTH_SIZE, 24,
GLX_STENCIL_SIZE, 8,
0,
};
XLockDisplay( (::Display*)g_bgfxX11Display);
// Find suitable config
GLXFBConfig bestConfig = NULL;
int major, minor;
bool version = glXQueryVersion( (::Display*)g_bgfxX11Display, &major, &minor);
BGFX_FATAL(version, Fatal::UnableToInitialize, "Failed to query GLX version");
BGFX_FATAL( (major == 1 && minor >= 2) || major > 1
, Fatal::UnableToInitialize
, "GLX version is not >=1.2 (%d.%d)."
, major
, minor
);
int numConfigs;
GLXFBConfig* configs = glXChooseFBConfig( (::Display*)g_bgfxX11Display, screen, attrsGlx, &numConfigs);
int32_t screen = DefaultScreen( (::Display*)g_bgfxX11Display);
BX_TRACE("glX num configs %d", numConfigs);
const char* extensions = glXQueryExtensionsString( (::Display*)g_bgfxX11Display, screen);
BX_TRACE("GLX extensions:");
dumpExtensions(extensions);
for (int ii = 0; ii < numConfigs; ++ii)
{
m_visualInfo = glXGetVisualFromFBConfig( (::Display*)g_bgfxX11Display, configs[ii]);
if (NULL != m_visualInfo)
const int attrsGlx[] =
{
BX_TRACE("---");
bool valid = true;
for (uint32_t attr = 6; attr < BX_COUNTOF(attrsGlx)-1 && attrsGlx[attr] != None; attr += 2)
{
int value;
glXGetFBConfigAttrib( (::Display*)g_bgfxX11Display, configs[ii], attrsGlx[attr], &value);
BX_TRACE("glX %d/%d %2d: %4x, %8x (%8x%s)"
, ii
, numConfigs
, attr/2
, attrsGlx[attr]
, value
, attrsGlx[attr + 1]
, value < attrsGlx[attr + 1] ? " *" : ""
);
if (value < attrsGlx[attr + 1])
{
valid = false;
#if !BGFX_CONFIG_DEBUG
break;
#endif // BGFX_CONFIG_DEBUG
}
}
if (valid)
{
bestConfig = configs[ii];
BX_TRACE("Best config %d.", ii);
break;
}
}
XFree(m_visualInfo);
m_visualInfo = NULL;
}
XFree(configs);
BGFX_FATAL(m_visualInfo, Fatal::UnableToInitialize, "Failed to find a suitable X11 display configuration.");
BX_TRACE("Create GL 2.1 context.");
m_context = glXCreateContext( (::Display*)g_bgfxX11Display, m_visualInfo, 0, GL_TRUE);
BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "Failed to create GL 2.1 context.");
#if BGFX_CONFIG_RENDERER_OPENGL >= 31
glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress( (const GLubyte*)"glXCreateContextAttribsARB");
if (NULL != glXCreateContextAttribsARB)
{
BX_TRACE("Create GL 3.1 context.");
const int contextAttrs[] =
{
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_DOUBLEBUFFER, true,
GLX_RED_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_GREEN_SIZE, 8,
// GLX_ALPHA_SIZE, 8,
GLX_DEPTH_SIZE, 24,
GLX_STENCIL_SIZE, 8,
0,
};
GLXContext context = glXCreateContextAttribsARB( (::Display*)g_bgfxX11Display, bestConfig, 0, true, contextAttrs);
// Find suitable config
GLXFBConfig bestConfig = NULL;
if (NULL != context)
int numConfigs;
GLXFBConfig* configs = glXChooseFBConfig( (::Display*)g_bgfxX11Display, screen, attrsGlx, &numConfigs);
BX_TRACE("glX num configs %d", numConfigs);
for (int ii = 0; ii < numConfigs; ++ii)
{
glXDestroyContext( (::Display*)g_bgfxX11Display, m_context);
m_context = context;
m_visualInfo = glXGetVisualFromFBConfig( (::Display*)g_bgfxX11Display, configs[ii]);
if (NULL != m_visualInfo)
{
BX_TRACE("---");
bool valid = true;
for (uint32_t attr = 6; attr < BX_COUNTOF(attrsGlx)-1 && attrsGlx[attr] != None; attr += 2)
{
int value;
glXGetFBConfigAttrib( (::Display*)g_bgfxX11Display, configs[ii], attrsGlx[attr], &value);
BX_TRACE("glX %d/%d %2d: %4x, %8x (%8x%s)"
, ii
, numConfigs
, attr/2
, attrsGlx[attr]
, value
, attrsGlx[attr + 1]
, value < attrsGlx[attr + 1] ? " *" : ""
);
if (value < attrsGlx[attr + 1])
{
valid = false;
#if !BGFX_CONFIG_DEBUG
break;
#endif // BGFX_CONFIG_DEBUG
}
}
if (valid)
{
bestConfig = configs[ii];
BX_TRACE("Best config %d.", ii);
break;
}
}
XFree(m_visualInfo);
m_visualInfo = NULL;
}
XFree(configs);
BGFX_FATAL(m_visualInfo, Fatal::UnableToInitialize, "Failed to find a suitable X11 display configuration.");
BX_TRACE("Create GL 2.1 context.");
m_context = glXCreateContext( (::Display*)g_bgfxX11Display, m_visualInfo, 0, GL_TRUE);
BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "Failed to create GL 2.1 context.");
#if BGFX_CONFIG_RENDERER_OPENGL >= 31
glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress( (const GLubyte*)"glXCreateContextAttribsARB");
if (NULL != glXCreateContextAttribsARB)
{
BX_TRACE("Create GL 3.1 context.");
const int contextAttrs[] =
{
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
0,
};
GLXContext context = glXCreateContextAttribsARB( (::Display*)g_bgfxX11Display, bestConfig, 0, true, contextAttrs);
if (NULL != context)
{
glXDestroyContext( (::Display*)g_bgfxX11Display, m_context);
m_context = context;
}
}
}
#else
BX_UNUSED(bestConfig);
BX_UNUSED(bestConfig);
#endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
XUnlockDisplay( (::Display*)g_bgfxX11Display);
XUnlockDisplay( (::Display*)g_bgfxX11Display);
}
import();
@ -210,8 +216,13 @@ namespace bgfx
void GlContext::destroy()
{
glXMakeCurrent( (::Display*)g_bgfxX11Display, 0, 0);
glXDestroyContext( (::Display*)g_bgfxX11Display, m_context);
XFree(m_visualInfo);
if (NULL == g_bgfxGLX)
{
glXDestroyContext( (::Display*)g_bgfxX11Display, m_context);
XFree(m_visualInfo);
}
m_context = NULL;
m_visualInfo = NULL;
}
void GlContext::resize(uint32_t /*_width*/, uint32_t /*_height*/, bool _vsync)
@ -292,7 +303,7 @@ namespace bgfx
# include "glimports.h"
}
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
# endif // BGFX_USE_GLX

View File

@ -11,7 +11,7 @@
# include <X11/Xlib.h>
# include <GL/glx.h>
namespace bgfx
namespace bgfx { namespace gl
{
struct SwapChainGL;
@ -45,7 +45,7 @@ namespace bgfx
GLXContext m_context;
XVisualInfo* m_visualInfo;
};
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
#endif // BGFX_USE_GLX

View File

@ -8,7 +8,7 @@
#if BX_PLATFORM_OSX
namespace bgfx
namespace bgfx { namespace gl
{
struct SwapChainGL;
@ -39,7 +39,7 @@ namespace bgfx
void* m_view;
void* m_context;
};
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
#endif // BX_PLATFORM_OSX

View File

@ -10,7 +10,7 @@
# include <Cocoa/Cocoa.h>
# include <bx/os.h>
namespace bgfx
namespace bgfx { namespace gl
{
# define GL_IMPORT(_optional, _proto, _func, _import) _proto _func
@ -35,7 +35,7 @@ namespace bgfx
{
}
};
static void* s_opengl = NULL;
void GlContext::create(uint32_t _width, uint32_t _height)
@ -46,56 +46,63 @@ namespace bgfx
BX_CHECK(NULL != s_opengl, "OpenGL dynamic library is not found!");
NSWindow* nsWindow = (NSWindow*)g_bgfxNSWindow;
m_context = g_bgfxNSGL;
NSOpenGLPixelFormatAttribute profile =
if (NULL == g_bgfxNSGL)
{
NSOpenGLPixelFormatAttribute profile =
#if BGFX_CONFIG_RENDERER_OPENGL >= 31
NSOpenGLProfileVersion3_2Core
NSOpenGLProfileVersion3_2Core
#else
NSOpenGLProfileVersionLegacy
NSOpenGLProfileVersionLegacy
#endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
;
;
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = {
NSOpenGLPFAOpenGLProfile, profile,
NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFAStencilSize, 8,
NSOpenGLPFADoubleBuffer, true,
NSOpenGLPFAAccelerated, true,
NSOpenGLPFANoRecovery, true,
0, 0,
};
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = {
NSOpenGLPFAOpenGLProfile, profile,
NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFAStencilSize, 8,
NSOpenGLPFADoubleBuffer, true,
NSOpenGLPFAAccelerated, true,
NSOpenGLPFANoRecovery, true,
0, 0,
};
NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
BGFX_FATAL(NULL != pixelFormat, Fatal::UnableToInitialize, "Failed to initialize pixel format.");
NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
BGFX_FATAL(NULL != pixelFormat, Fatal::UnableToInitialize, "Failed to initialize pixel format.");
NSRect glViewRect = [[nsWindow contentView] bounds];
NSOpenGLView* glView = [[NSOpenGLView alloc] initWithFrame:glViewRect pixelFormat:pixelFormat];
[pixelFormat release];
[nsWindow setContentView:glView];
NSOpenGLContext* glContext = [glView openGLContext];
BGFX_FATAL(NULL != glContext, Fatal::UnableToInitialize, "Failed to initialize GL context.");
NSRect glViewRect = [[nsWindow contentView] bounds];
NSOpenGLView* glView = [[NSOpenGLView alloc] initWithFrame:glViewRect pixelFormat:pixelFormat];
[glContext makeCurrentContext];
GLint interval = 0;
[glContext setValues:&interval forParameter:NSOpenGLCPSwapInterval];
m_view = glView;
m_context = glContext;
[pixelFormat release];
[nsWindow setContentView:glView];
NSOpenGLContext* glContext = [glView openGLContext];
BGFX_FATAL(NULL != glContext, Fatal::UnableToInitialize, "Failed to initialize GL context.");
[glContext makeCurrentContext];
GLint interval = 0;
[glContext setValues:&interval forParameter:NSOpenGLCPSwapInterval];
m_view = glView;
m_context = glContext;
}
import();
}
void GlContext::destroy()
{
NSOpenGLView* glView = (NSOpenGLView*)m_view;
m_view = 0;
m_context = 0;
[glView release];
if (NULL == g_bgfxNSGL)
{
NSOpenGLView* glView = (NSOpenGLView*)m_view;
[glView release];
}
m_view = 0;
m_context = 0;
bx::dlclose(s_opengl);
}
@ -165,6 +172,6 @@ namespace bgfx
# include "glimports.h"
}
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
#endif // BX_PLATFORM_OSX && (BGFX_CONFIG_RENDERER_OPENGLES2|BGFX_CONFIG_RENDERER_OPENGLES3|BGFX_CONFIG_RENDERER_OPENGL)

View File

@ -9,14 +9,14 @@
# include <bgfxplatform.h>
# include "renderer_gl.h"
namespace bgfx
namespace bgfx { namespace gl
{
# define GL_IMPORT(_optional, _proto, _func, _import) _proto _func
# include "glimports.h"
void naclSwapCompleteCb(void* /*_data*/, int32_t /*_result*/);
PP_CompletionCallback naclSwapComplete =
PP_CompletionCallback naclSwapComplete =
{
naclSwapCompleteCb,
NULL,
@ -62,7 +62,7 @@ namespace bgfx
PostSwapBuffersFn m_postSwapBuffers;
bool m_forceSwap;
};
static Ppapi s_ppapi;
void naclSwapCompleteCb(void* /*_data*/, int32_t /*_result*/)
@ -95,11 +95,6 @@ namespace bgfx
s_ppapi.m_instancedArrays->DrawElementsInstancedANGLE(s_ppapi.m_context, _mode, _count, _type, _indices, _primcount);
}
bool naclSetInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
{
return s_ppapi.setInterfaces( _instance, _instInterface, _graphicsInterface, _postSwapBuffers);
}
bool Ppapi::setInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
{
BX_TRACE("PPAPI Interfaces");
@ -192,6 +187,14 @@ namespace bgfx
return s_ppapi.isValid();
}
} /* namespace gl */ } // namespace bgfx
namespace bgfx
{
bool naclSetInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
{
return gl::s_ppapi.setInterfaces( _instance, _instInterface, _graphicsInterface, _postSwapBuffers);
}
} // namespace bgfx
#endif // BX_PLATFORM_NACL && (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL)

View File

@ -13,7 +13,7 @@
# include <ppapi/c/ppb_instance.h>
# include <ppapi/c/ppb_graphics_3d.h>
namespace bgfx
namespace bgfx { namespace gl
{
struct SwapChainGL;
@ -36,7 +36,7 @@ namespace bgfx
void import();
bool isValid() const;
};
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
#endif // BX_PLATFORM_NACL

View File

@ -10,7 +10,7 @@
# if BGFX_USE_WGL
namespace bgfx
namespace bgfx { namespace gl
{
PFNWGLGETPROCADDRESSPROC wglGetProcAddress;
PFNWGLMAKECURRENTPROC wglMakeCurrent;
@ -376,7 +376,7 @@ namespace bgfx
# include "glimports.h"
}
} // namespace bgfx
} } // namespace bgfx
# endif // BGFX_USE_WGL
#endif // (BGFX_CONFIG_RENDERER_OPENGLES|BGFX_CONFIG_RENDERER_OPENGL)

View File

@ -10,7 +10,7 @@
#include <wgl/wglext.h>
namespace bgfx
namespace bgfx { namespace gl
{
typedef PROC (APIENTRYP PFNWGLGETPROCADDRESSPROC) (LPCSTR lpszProc);
typedef BOOL (APIENTRYP PFNWGLMAKECURRENTPROC) (HDC hdc, HGLRC hglrc);
@ -93,7 +93,7 @@ typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum z
HGLRC m_context;
HDC m_hdc;
};
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
#endif // BGFX_USE_WGL

View File

@ -1235,49 +1235,49 @@ namespace bgfx
#define DDS_BC5U BX_MAKEFOURCC('B', 'C', '5', 'U')
#define DDS_DX10 BX_MAKEFOURCC('D', 'X', '1', '0')
#define D3DFMT_A8R8G8B8 21
#define D3DFMT_R5G6B5 23
#define D3DFMT_A1R5G5B5 25
#define D3DFMT_A4R4G4B4 26
#define D3DFMT_A2B10G10R10 31
#define D3DFMT_G16R16 34
#define D3DFMT_A2R10G10B10 35
#define D3DFMT_A16B16G16R16 36
#define D3DFMT_A8L8 51
#define D3DFMT_R16F 111
#define D3DFMT_G16R16F 112
#define D3DFMT_A16B16G16R16F 113
#define D3DFMT_R32F 114
#define D3DFMT_G32R32F 115
#define D3DFMT_A32B32G32R32F 116
#define DDS_A8R8G8B8 21
#define DDS_R5G6B5 23
#define DDS_A1R5G5B5 25
#define DDS_A4R4G4B4 26
#define DDS_A2B10G10R10 31
#define DDS_G16R16 34
#define DDS_A2R10G10B10 35
#define DDS_A16B16G16R16 36
#define DDS_A8L8 51
#define DDS_R16F 111
#define DDS_G16R16F 112
#define DDS_A16B16G16R16F 113
#define DDS_R32F 114
#define DDS_G32R32F 115
#define DDS_A32B32G32R32F 116
#define DXGI_FORMAT_R32G32B32A32_FLOAT 2
#define DXGI_FORMAT_R32G32B32A32_UINT 3
#define DXGI_FORMAT_R16G16B16A16_FLOAT 10
#define DXGI_FORMAT_R16G16B16A16_UNORM 11
#define DXGI_FORMAT_R16G16B16A16_UINT 12
#define DXGI_FORMAT_R32G32_FLOAT 16
#define DXGI_FORMAT_R32G32_UINT 17
#define DXGI_FORMAT_R10G10B10A2_UNORM 24
#define DXGI_FORMAT_R16G16_FLOAT 34
#define DXGI_FORMAT_R16G16_UNORM 35
#define DXGI_FORMAT_R32_FLOAT 41
#define DXGI_FORMAT_R32_UINT 42
#define DXGI_FORMAT_R8G8_UNORM 49
#define DXGI_FORMAT_R16_FLOAT 54
#define DXGI_FORMAT_R16_UNORM 56
#define DXGI_FORMAT_R8_UNORM 61
#define DXGI_FORMAT_BC1_UNORM 71
#define DXGI_FORMAT_BC2_UNORM 74
#define DXGI_FORMAT_BC3_UNORM 77
#define DXGI_FORMAT_BC4_UNORM 80
#define DXGI_FORMAT_BC5_UNORM 83
#define DXGI_FORMAT_B5G6R5_UNORM 85
#define DXGI_FORMAT_B5G5R5A1_UNORM 86
#define DXGI_FORMAT_B8G8R8A8_UNORM 87
#define DXGI_FORMAT_BC6H_SF16 96
#define DXGI_FORMAT_BC7_UNORM 98
#define DXGI_FORMAT_B4G4R4A4_UNORM 115
#define DDS_FORMAT_R32G32B32A32_FLOAT 2
#define DDS_FORMAT_R32G32B32A32_UINT 3
#define DDS_FORMAT_R16G16B16A16_FLOAT 10
#define DDS_FORMAT_R16G16B16A16_UNORM 11
#define DDS_FORMAT_R16G16B16A16_UINT 12
#define DDS_FORMAT_R32G32_FLOAT 16
#define DDS_FORMAT_R32G32_UINT 17
#define DDS_FORMAT_R10G10B10A2_UNORM 24
#define DDS_FORMAT_R16G16_FLOAT 34
#define DDS_FORMAT_R16G16_UNORM 35
#define DDS_FORMAT_R32_FLOAT 41
#define DDS_FORMAT_R32_UINT 42
#define DDS_FORMAT_R8G8_UNORM 49
#define DDS_FORMAT_R16_FLOAT 54
#define DDS_FORMAT_R16_UNORM 56
#define DDS_FORMAT_R8_UNORM 61
#define DDS_FORMAT_BC1_UNORM 71
#define DDS_FORMAT_BC2_UNORM 74
#define DDS_FORMAT_BC3_UNORM 77
#define DDS_FORMAT_BC4_UNORM 80
#define DDS_FORMAT_BC5_UNORM 83
#define DDS_FORMAT_B5G6R5_UNORM 85
#define DDS_FORMAT_B5G5R5A1_UNORM 86
#define DDS_FORMAT_B8G8R8A8_UNORM 87
#define DDS_FORMAT_BC6H_SF16 96
#define DDS_FORMAT_BC7_UNORM 98
#define DDS_FORMAT_B4G4R4A4_UNORM 115
#define DDSD_CAPS 0x00000001
#define DDSD_HEIGHT 0x00000002
@ -1331,57 +1331,57 @@ namespace bgfx
{ DDS_BC4U, TextureFormat::BC4 },
{ DDS_ATI2, TextureFormat::BC5 },
{ DDS_BC5U, TextureFormat::BC5 },
{ D3DFMT_A16B16G16R16, TextureFormat::RGBA16 },
{ D3DFMT_A16B16G16R16F, TextureFormat::RGBA16F },
{ DDS_A16B16G16R16, TextureFormat::RGBA16 },
{ DDS_A16B16G16R16F, TextureFormat::RGBA16F },
{ DDPF_RGB|DDPF_ALPHAPIXELS, TextureFormat::BGRA8 },
{ DDPF_INDEXED, TextureFormat::R8 },
{ DDPF_LUMINANCE, TextureFormat::R8 },
{ DDPF_ALPHA, TextureFormat::R8 },
{ D3DFMT_R16F, TextureFormat::R16F },
{ D3DFMT_R32F, TextureFormat::R32F },
{ D3DFMT_A8L8, TextureFormat::RG8 },
{ D3DFMT_G16R16, TextureFormat::RG16 },
{ D3DFMT_G16R16F, TextureFormat::RG16F },
{ D3DFMT_G32R32F, TextureFormat::RG32F },
{ D3DFMT_A8R8G8B8, TextureFormat::BGRA8 },
{ D3DFMT_A16B16G16R16, TextureFormat::RGBA16 },
{ D3DFMT_A16B16G16R16F, TextureFormat::RGBA16F },
{ D3DFMT_A32B32G32R32F, TextureFormat::RGBA32F },
{ D3DFMT_R5G6B5, TextureFormat::R5G6B5 },
{ D3DFMT_A4R4G4B4, TextureFormat::RGBA4 },
{ D3DFMT_A1R5G5B5, TextureFormat::RGB5A1 },
{ D3DFMT_A2B10G10R10, TextureFormat::RGB10A2 },
{ DDS_R16F, TextureFormat::R16F },
{ DDS_R32F, TextureFormat::R32F },
{ DDS_A8L8, TextureFormat::RG8 },
{ DDS_G16R16, TextureFormat::RG16 },
{ DDS_G16R16F, TextureFormat::RG16F },
{ DDS_G32R32F, TextureFormat::RG32F },
{ DDS_A8R8G8B8, TextureFormat::BGRA8 },
{ DDS_A16B16G16R16, TextureFormat::RGBA16 },
{ DDS_A16B16G16R16F, TextureFormat::RGBA16F },
{ DDS_A32B32G32R32F, TextureFormat::RGBA32F },
{ DDS_R5G6B5, TextureFormat::R5G6B5 },
{ DDS_A4R4G4B4, TextureFormat::RGBA4 },
{ DDS_A1R5G5B5, TextureFormat::RGB5A1 },
{ DDS_A2B10G10R10, TextureFormat::RGB10A2 },
};
static TranslateDdsFormat s_translateDxgiFormat[] =
{
{ DXGI_FORMAT_BC1_UNORM, TextureFormat::BC1 },
{ DXGI_FORMAT_BC2_UNORM, TextureFormat::BC2 },
{ DXGI_FORMAT_BC3_UNORM, TextureFormat::BC3 },
{ DXGI_FORMAT_BC4_UNORM, TextureFormat::BC4 },
{ DXGI_FORMAT_BC5_UNORM, TextureFormat::BC5 },
{ DXGI_FORMAT_BC6H_SF16, TextureFormat::BC6H },
{ DXGI_FORMAT_BC7_UNORM, TextureFormat::BC7 },
{ DDS_FORMAT_BC1_UNORM, TextureFormat::BC1 },
{ DDS_FORMAT_BC2_UNORM, TextureFormat::BC2 },
{ DDS_FORMAT_BC3_UNORM, TextureFormat::BC3 },
{ DDS_FORMAT_BC4_UNORM, TextureFormat::BC4 },
{ DDS_FORMAT_BC5_UNORM, TextureFormat::BC5 },
{ DDS_FORMAT_BC6H_SF16, TextureFormat::BC6H },
{ DDS_FORMAT_BC7_UNORM, TextureFormat::BC7 },
{ DXGI_FORMAT_R8_UNORM, TextureFormat::R8 },
{ DXGI_FORMAT_R16_UNORM, TextureFormat::R16 },
{ DXGI_FORMAT_R16_FLOAT, TextureFormat::R16F },
{ DXGI_FORMAT_R32_UINT, TextureFormat::R32 },
{ DXGI_FORMAT_R32_FLOAT, TextureFormat::R32F },
{ DXGI_FORMAT_R8G8_UNORM, TextureFormat::RG8 },
{ DXGI_FORMAT_R16G16_UNORM, TextureFormat::RG16 },
{ DXGI_FORMAT_R16G16_FLOAT, TextureFormat::RG16F },
{ DXGI_FORMAT_R32G32_UINT, TextureFormat::RG32 },
{ DXGI_FORMAT_R32G32_FLOAT, TextureFormat::RG32F },
{ DXGI_FORMAT_B8G8R8A8_UNORM, TextureFormat::BGRA8 },
{ DXGI_FORMAT_R16G16B16A16_UNORM, TextureFormat::RGBA16 },
{ DXGI_FORMAT_R16G16B16A16_FLOAT, TextureFormat::RGBA16F },
{ DXGI_FORMAT_R32G32B32A32_UINT, TextureFormat::RGBA32 },
{ DXGI_FORMAT_R32G32B32A32_FLOAT, TextureFormat::RGBA32F },
{ DXGI_FORMAT_B5G6R5_UNORM, TextureFormat::R5G6B5 },
{ DXGI_FORMAT_B4G4R4A4_UNORM, TextureFormat::RGBA4 },
{ DXGI_FORMAT_B5G5R5A1_UNORM, TextureFormat::RGB5A1 },
{ DXGI_FORMAT_R10G10B10A2_UNORM, TextureFormat::RGB10A2 },
{ DDS_FORMAT_R8_UNORM, TextureFormat::R8 },
{ DDS_FORMAT_R16_UNORM, TextureFormat::R16 },
{ DDS_FORMAT_R16_FLOAT, TextureFormat::R16F },
{ DDS_FORMAT_R32_UINT, TextureFormat::R32 },
{ DDS_FORMAT_R32_FLOAT, TextureFormat::R32F },
{ DDS_FORMAT_R8G8_UNORM, TextureFormat::RG8 },
{ DDS_FORMAT_R16G16_UNORM, TextureFormat::RG16 },
{ DDS_FORMAT_R16G16_FLOAT, TextureFormat::RG16F },
{ DDS_FORMAT_R32G32_UINT, TextureFormat::RG32 },
{ DDS_FORMAT_R32G32_FLOAT, TextureFormat::RG32F },
{ DDS_FORMAT_B8G8R8A8_UNORM, TextureFormat::BGRA8 },
{ DDS_FORMAT_R16G16B16A16_UNORM, TextureFormat::RGBA16 },
{ DDS_FORMAT_R16G16B16A16_FLOAT, TextureFormat::RGBA16F },
{ DDS_FORMAT_R32G32B32A32_UINT, TextureFormat::RGBA32 },
{ DDS_FORMAT_R32G32B32A32_FLOAT, TextureFormat::RGBA32F },
{ DDS_FORMAT_B5G6R5_UNORM, TextureFormat::R5G6B5 },
{ DDS_FORMAT_B4G4R4A4_UNORM, TextureFormat::RGBA4 },
{ DDS_FORMAT_B5G5R5A1_UNORM, TextureFormat::RGB5A1 },
{ DDS_FORMAT_R10G10B10A2_UNORM, TextureFormat::RGB10A2 },
};
struct TranslateDdsPixelFormat

View File

@ -3,6 +3,9 @@
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#ifndef BGFX_OVR_H_HEADER_GUARD
#define BGFX_OVR_H_HEADER_GUARD
#include "bgfx_p.h"
#if BGFX_CONFIG_USE_OVR
@ -146,3 +149,5 @@ namespace bgfx
} // namespace bgfx
#endif // BGFX_CONFIG_USE_OVR
#endif // BGFX_OVR_H_HEADER_GUARD

View File

@ -3,9 +3,14 @@
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#ifndef BGFX_RENDERDOC_H_HEADER_GUARD
#define BGFX_RENDERDOC_H_HEADER_GUARD
namespace bgfx
{
void* loadRenderDoc();
void unloadRenderDoc(void*);
} // namespace bgfx
#endif // BGFX_RENDERDOC_H_HEADER_GUARD

View File

@ -3,6 +3,9 @@
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#ifndef BGFX_RENDERER_H_HEADER_GUARD
#define BGFX_RENDERER_H_HEADER_GUARD
#include "bgfx_p.h"
namespace bgfx
@ -262,3 +265,5 @@ namespace bgfx
};
} // namespace bgfx
#endif // BGFX_RENDERER_H_HEADER_GUARD

View File

@ -8,7 +8,7 @@
#if BGFX_CONFIG_RENDERER_DIRECT3D11
# include "renderer_d3d11.h"
namespace bgfx
namespace bgfx { namespace d3d11
{
static wchar_t s_viewNameW[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
@ -2299,14 +2299,14 @@ namespace bgfx
static RendererContextD3D11* s_renderD3D11;
RendererContextI* rendererCreateD3D11()
RendererContextI* rendererCreate()
{
s_renderD3D11 = BX_NEW(g_allocator, RendererContextD3D11);
s_renderD3D11->init();
return s_renderD3D11;
}
void rendererDestroyD3D11()
void rendererDestroy()
{
s_renderD3D11->shutdown();
BX_DELETE(g_allocator, s_renderD3D11);
@ -3839,20 +3839,20 @@ namespace bgfx
PIX_ENDEVENT();
}
}
} // namespace bgfx
} /* namespace d3d11 */ } // namespace bgfx
#else
namespace bgfx
namespace bgfx { namespace d3d11
{
RendererContextI* rendererCreateD3D11()
RendererContextI* rendererCreate()
{
return NULL;
}
void rendererDestroyD3D11()
void rendererDestroy()
{
}
} // namespace bgfx
} /* namespace d3d11 */ } // namespace bgfx
#endif // BGFX_CONFIG_RENDERER_DIRECT3D11

View File

@ -70,7 +70,7 @@ BX_PRAGMA_DIAGNOSTIC_POP()
# define D3D11_APPEND_ALIGNED_ELEMENT UINT32_MAX
#endif // D3D11_APPEND_ALIGNED_ELEMENT
namespace bgfx
namespace bgfx { namespace d3d11
{
struct BufferD3D11
{
@ -280,6 +280,6 @@ namespace bgfx
uint8_t m_num;
};
} // namespace bgfx
} /* namespace d3d11 */ } // namespace bgfx
#endif // BGFX_RENDERER_D3D11_H_HEADER_GUARD

View File

@ -9,16 +9,16 @@
# include "../../d3d12/src/renderer_d3d12.cpp"
#else
namespace bgfx
namespace bgfx { namespace d3d12
{
RendererContextI* rendererCreateD3D12()
RendererContextI* rendererCreate()
{
return NULL;
}
void rendererDestroyD3D12()
void rendererDestroy()
{
}
} // namespace bgfx
} /* namespace d3d12 */ } // namespace bgfx
#endif // BGFX_CONFIG_RENDERER_DIRECT3D12

View File

@ -8,7 +8,7 @@
#if BGFX_CONFIG_RENDERER_DIRECT3D9
# include "renderer_d3d9.h"
namespace bgfx
namespace bgfx { namespace d3d9
{
static wchar_t s_viewNameW[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
@ -1731,14 +1731,14 @@ namespace bgfx
static RendererContextD3D9* s_renderD3D9;
RendererContextI* rendererCreateD3D9()
RendererContextI* rendererCreate()
{
s_renderD3D9 = BX_NEW(g_allocator, RendererContextD3D9);
s_renderD3D9->init();
return s_renderD3D9;
}
void rendererDestroyD3D9()
void rendererDestroy()
{
s_renderD3D9->shutdown();
BX_DELETE(g_allocator, s_renderD3D9);
@ -3460,20 +3460,20 @@ namespace bgfx
device->EndScene();
}
} // namespace bgfx
} /* namespace d3d9 */ } // namespace bgfx
#else
namespace bgfx
namespace bgfx { namespace d3d9
{
RendererContextI* rendererCreateD3D9()
RendererContextI* rendererCreate()
{
return NULL;
}
void rendererDestroyD3D9()
void rendererDestroy()
{
}
} // namespace bgfx
} /* namespace d3d9 */ } // namespace bgfx
#endif // BGFX_CONFIG_RENDERER_DIRECT3D9

View File

@ -41,7 +41,7 @@
#include "renderer.h"
#include "renderer_d3d.h"
namespace bgfx
namespace bgfx { namespace d3d9
{
# if defined(D3D_DISABLE_9EX)
# define D3DFMT_S8_LOCKABLE D3DFORMAT( 85)
@ -386,6 +386,6 @@ namespace bgfx
bool m_needResolve;
};
} // namespace bgfx
} /* namespace d3d9 */ } // namespace bgfx
#endif // BGFX_RENDERER_D3D9_H_HEADER_GUARD

View File

@ -10,7 +10,7 @@
# include <bx/timer.h>
# include <bx/uint32_t.h>
namespace bgfx
namespace bgfx { namespace gl
{
static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
@ -417,6 +417,7 @@ namespace bgfx
EXT_blend_color,
EXT_blend_minmax,
EXT_blend_subtract,
EXT_color_buffer_half_float,
EXT_compressed_ETC1_RGB8_sub_texture,
EXT_debug_label,
EXT_debug_marker,
@ -491,10 +492,12 @@ namespace bgfx
OES_vertex_half_float,
OES_vertex_type_10_10_10_2,
WEBGL_color_buffer_float,
WEBGL_compressed_texture_etc1,
WEBGL_compressed_texture_s3tc,
WEBGL_compressed_texture_pvrtc,
WEBGL_depth_texture,
WEBGL_draw_buffers,
WEBKIT_EXT_texture_filter_anisotropic,
WEBKIT_WEBGL_compressed_texture_s3tc,
@ -578,6 +581,7 @@ namespace bgfx
{ "EXT_blend_color", BGFX_CONFIG_RENDERER_OPENGL >= 31, true },
{ "EXT_blend_minmax", BGFX_CONFIG_RENDERER_OPENGL >= 14, true },
{ "EXT_blend_subtract", BGFX_CONFIG_RENDERER_OPENGL >= 14, true },
{ "EXT_color_buffer_half_float", false, true }, // GLES2 extension.
{ "EXT_compressed_ETC1_RGB8_sub_texture", false, true }, // GLES2 extension.
{ "EXT_debug_label", false, true },
{ "EXT_debug_marker", false, true },
@ -652,10 +656,12 @@ namespace bgfx
{ "OES_vertex_half_float", false, true },
{ "OES_vertex_type_10_10_10_2", false, true },
{ "WEBGL_color_buffer_float", false, true },
{ "WEBGL_compressed_texture_etc1", false, true },
{ "WEBGL_compressed_texture_s3tc", false, true },
{ "WEBGL_compressed_texture_pvrtc", false, true },
{ "WEBGL_depth_texture", false, true },
{ "WEBGL_draw_buffers", false, true },
{ "WEBKIT_EXT_texture_filter_anisotropic", false, true },
{ "WEBKIT_WEBGL_compressed_texture_s3tc", false, true },
@ -1294,7 +1300,8 @@ namespace bgfx
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
|| BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30)
|| s_extension[Extension::EXT_draw_buffers].m_supported)
|| s_extension[Extension::EXT_draw_buffers ].m_supported
|| s_extension[Extension::WEBGL_draw_buffers].m_supported)
{
g_caps.maxFBAttachments = bx::uint32_min(glGet(GL_MAX_COLOR_ATTACHMENTS), BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS);
}
@ -2579,14 +2586,14 @@ namespace bgfx
RendererContextGL* s_renderGL;
RendererContextI* rendererCreateGL()
RendererContextI* rendererCreate()
{
s_renderGL = BX_NEW(g_allocator, RendererContextGL);
s_renderGL->init();
return s_renderGL;
}
void rendererDestroyGL()
void rendererDestroy()
{
s_renderGL->shutdown();
BX_DELETE(g_allocator, s_renderGL);
@ -2662,6 +2669,7 @@ namespace bgfx
GLENUM(GL_RENDERBUFFER);
GLENUM(GL_INVALID_ENUM);
GLENUM(GL_INVALID_FRAMEBUFFER_OPERATION);
GLENUM(GL_INVALID_VALUE);
GLENUM(GL_INVALID_OPERATION);
GLENUM(GL_OUT_OF_MEMORY);
@ -3794,7 +3802,10 @@ namespace bgfx
if (usesFragData)
{
BX_WARN(s_extension[Extension::EXT_draw_buffers].m_supported, "EXT_draw_buffers is used but not supported by GLES2 driver.");
BX_WARN(s_extension[Extension::EXT_draw_buffers ].m_supported
|| s_extension[Extension::WEBGL_draw_buffers].m_supported
, "EXT_draw_buffers is used but not supported by GLES2 driver."
);
writeString(&writer
, "#extension GL_EXT_draw_buffers : enable\n"
);
@ -5354,21 +5365,21 @@ namespace bgfx
GL_CHECK(glFrameTerminatorGREMEDY() );
}
} // namespace bgfx
} } // namespace bgfx
#else
namespace bgfx
namespace bgfx { namespace gl
{
RendererContextI* rendererCreateGL()
RendererContextI* rendererCreate()
{
return NULL;
}
void rendererDestroyGL()
void rendererDestroy()
{
}
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
#endif // (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL)

View File

@ -611,6 +611,10 @@ typedef uint64_t GLuint64;
namespace bgfx
{
class ConstantBuffer;
} // namespace bgfx
namespace bgfx { namespace gl
{
void dumpExtensions(const char* _extensions);
const char* glEnumName(GLenum _enum);
@ -1001,6 +1005,6 @@ namespace bgfx
GLuint m_queries[64];
};
} // namespace bgfx
} /* namespace gl */ } // namespace bgfx
#endif // BGFX_RENDERER_GL_H_HEADER_GUARD

View File

@ -7,7 +7,7 @@
#if BGFX_CONFIG_RENDERER_NULL
namespace bgfx
namespace bgfx { namespace noop
{
struct RendererContextNULL : public RendererContextI
{
@ -168,31 +168,31 @@ namespace bgfx
static RendererContextNULL* s_renderNULL;
RendererContextI* rendererCreateNULL()
RendererContextI* rendererCreate()
{
s_renderNULL = BX_NEW(g_allocator, RendererContextNULL);
return s_renderNULL;
}
void rendererDestroyNULL()
void rendererDestroy()
{
BX_DELETE(g_allocator, s_renderNULL);
s_renderNULL = NULL;
}
} // namespace bgfx
} /* namespace noop */ } // namespace bgfx
#else
namespace bgfx
namespace bgfx { namespace noop
{
RendererContextI* rendererCreateNULL()
RendererContextI* rendererCreate()
{
return NULL;
}
void rendererDestroyNULL()
void rendererDestroy()
{
}
} // namespace bgfx
} /* namespace noop */ } // namespace bgfx
#endif // BGFX_CONFIG_RENDERER_NULL

View File

@ -8,16 +8,16 @@
# include "../../vk/src/renderer_vk.cpp"
#else
namespace bgfx
namespace bgfx { namespace vk
{
RendererContextI* rendererCreateVK()
RendererContextI* rendererCreate()
{
return NULL;
}
void rendererDestroyVK()
void rendererDestroy()
{
}
} // namespace bgfx
} /* namespace vk */ } // namespace bgfx
#endif // BGFX_CONFIG_RENDERER_VULKAN

View File

@ -504,11 +504,14 @@ int main(int _argc, const char* _argv[])
Triangle triangle;
memset(&triangle, 0, sizeof(Triangle) );
const int numNormals = (int)normals.size();
const int numTexcoords = (int)texcoords.size();
const int numPositions = (int)positions.size();
for (uint32_t edge = 0, numEdges = argc-1; edge < numEdges; ++edge)
{
Index3 index;
index.m_texcoord = -1;
index.m_normal = -1;
index.m_texcoord = 0;
index.m_normal = 0;
index.m_vertexIndex = -1;
char* vertex = argv[edge+1];
@ -521,13 +524,16 @@ int main(int _argc, const char* _argv[])
if (NULL != normal)
{
*normal++ = '\0';
index.m_normal = atoi(normal)-1;
const int nn = atoi(normal);
index.m_normal = (nn < 0) ? nn+numNormals : nn-1;
}
index.m_texcoord = atoi(texcoord)-1;
const int tex = atoi(texcoord);
index.m_texcoord = (tex < 0) ? tex+numTexcoords : tex-1;
}
index.m_position = atoi(vertex)-1;
const int pos = atoi(vertex);
index.m_position = (pos < 0) ? pos+numPositions : pos-1;
uint64_t hash0 = index.m_position;
uint64_t hash1 = uint64_t(index.m_texcoord)<<20;
@ -710,8 +716,8 @@ int main(int _argc, const char* _argv[])
bool hasTexcoord;
{
Index3Map::const_iterator it = indexMap.begin();
hasNormal = -1 != it->second.m_normal;
hasTexcoord = -1 != it->second.m_texcoord;
hasNormal = 0 != it->second.m_normal;
hasTexcoord = 0 != it->second.m_texcoord;
if (!hasTexcoord
&& texcoords.size() == positions.size() )

View File

@ -845,7 +845,7 @@ int main(int _argc, const char* _argv[])
preprocessor.setDefaultDefine("BGFX_SHADER_TYPE_VERTEX");
char glslDefine[128];
bx::snprintf(glslDefine, BX_COUNTOF(glslDefine), "BGFX_SHADER_LANGUAGE_GLSL=%d", glsl);
bx::snprintf(glslDefine, BX_COUNTOF(glslDefine), "BGFX_SHADER_LANGUAGE_GLSL=%d", essl ? 1 : glsl);
if (0 == bx::stricmp(platform, "android") )
{
@ -972,9 +972,9 @@ int main(int _argc, const char* _argv[])
const char* name = parse = bx::strws(bx::strword(parse) );
const char* column = parse = bx::strws(bx::strword(parse) );
const char* semantics = parse = bx::strws(bx::strnws (parse) );
const char* semantics = parse = bx::strws((*parse == ':' ? ++parse : parse));
const char* assign = parse = bx::strws(bx::strword(parse) );
const char* init = parse = bx::strws(bx::strnws (parse) );
const char* init = parse = bx::strws((*parse == '=' ? ++parse : parse));
if (type < eol
&& name < eol
@ -1155,7 +1155,8 @@ int main(int _argc, const char* _argv[])
}
else
{
if (0 != glsl)
if (0 != glsl
|| 0 != essl)
{
}
else
@ -1269,7 +1270,8 @@ int main(int _argc, const char* _argv[])
bx::write(writer, BGFX_CHUNK_MAGIC_CSH);
bx::write(writer, outputHash);
if (0 != glsl)
if (0 != glsl
|| 0 != essl)
{
std::string code;
@ -1338,10 +1340,11 @@ int main(int _argc, const char* _argv[])
}
else
{
if (0 != glsl)
if (0 != glsl
|| 0 != essl)
{
if (120 == glsl
|| essl)
|| 0 != essl)
{
preprocessor.writef(
"#define ivec2 vec2\n"
@ -1700,7 +1703,8 @@ int main(int _argc, const char* _argv[])
bx::write(writer, outputHash);
}
if (0 != glsl)
if (0 != glsl
|| 0 != essl)
{
std::string code;

View File

@ -71,7 +71,9 @@ namespace bx
uint16_t* sparse = &m_handles[MaxHandlesT];
uint16_t index = sparse[_handle];
return (index < m_numHandles && m_handles[index] == _handle);
return index < m_numHandles
&& m_handles[index] == _handle
;
}
void free(uint16_t _handle)

View File

@ -29,10 +29,11 @@
#include <tinystl/allocator.h>
#include <tinystl/unordered_map.h>
struct Foo { int bar; };
TEST(uomap_nonpod_compiles) {
struct Foo { int bar; };
// verify this compiles
typedef tinystl::unordered_map<int, Foo> map;
map m;
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,10 +1,2 @@
bin
build/*/obj
scripts/obj
*.sln
*.suo
*.vcxproj
*.vcxproj.filters
*.vcxproj.user
*.opensdf
*.sdf

View File

@ -14,7 +14,7 @@ Supported project generators:
Download (stable)
-----------------
version 225 (commit 2321131cbf61d5a13df44c255b8d18d73121149d)
version 242 (commit ce8f85701187fa48521ef0a6d38ac0f13726ae7b)
Linux:
https://github.com/bkaradzic/bx/raw/master/tools/bin/linux/genie
@ -73,6 +73,11 @@ intention to keep it compatible with it.
- Added `msgcompile`, `msgresource`, `msglinking` and `msgarchiving` as
overrides for make messages.
- Added `messageskip` list to disable some of compiler messages.
- Added `buildoptions_c`, `buildoptions_cpp`, `buildoptions_objc` for
configuring language specific build options.
- Split functionality of `excludes` in `removefiles` and `excludes`. With VS
`excludes` will exclude files from build but files will be added to project
file. `removefiles` removes files completely from project.
## Why fork?

View File

@ -36,7 +36,7 @@
"../src/host/scripts.c",
}
removefiles {
excludes {
"../src/premake.lua",
"../src/host/lua-5.2.3/src/lua.c",
"../src/host/lua-5.2.3/src/luac.c",

View File

@ -73,20 +73,20 @@
_p('endef')
_p('')
end
-- target build rule
_p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES)')
if prj.kind == "StaticLib" then
if prj.kind == "StaticLib" then
if prj.msgarchiving then
_p('\t@echo ' .. prj.msgarchiving)
else
_p('\t@echo Archiving %s', prj.name)
end
if (not prj.archivesplit_size) then
end
if (not prj.archivesplit_size) then
prj.archivesplit_size=200
end
if (not prj.options.ArchiveSplit) then
if (not prj.options.ArchiveSplit) then
_p('\t$(SILENT) $(LINKCMD) $(OBJECTS)')
else
_p('\t$(call RM,$(TARGET))')
@ -98,7 +98,7 @@
_p('\t@echo ' .. prj.msglinking)
else
_p('\t@echo Linking %s', prj.name)
end
end
_p('\t$(SILENT) $(LINKCMD)')
end
_p('\t$(POSTBUILDCMDS)')
@ -109,9 +109,16 @@
_p('$(TARGETDIR):')
premake.make_mkdirrule("$(TARGETDIR)")
_p('$(OBJDIRS):')
if (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, "SkipCreatingMessage")) then
_p('\t@echo Creating $(OBJDIR)')
_p('objdirmessage:')
_p('\t@echo Creating $(OBJDIR)')
_p('')
end
if (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, "SkipCreatingMessage")) then
_p('$(OBJDIRS): objdirmessage')
else
_p('$(OBJDIRS):')
end
_p('\t-$(call MKDIR,$@)')
_p('')
@ -246,14 +253,8 @@
for _, file in ipairs(prj.files) do
if path.iscppfile(file) then
-- check if file is excluded.
local excluded = false
for _, exclude in ipairs(cfg.excludes) do
excluded = (exclude == file)
if (excluded) then break end
end
-- if not excluded, add it.
if excluded == false then
if not table.icontains(cfg.excludes, file) then
-- if not excluded, add it.
_p('\t$(OBJDIR)/%s.o \\'
, _MAKE.esc(path.trimdots(path.removeext(file)))
)

View File

@ -477,22 +477,10 @@
vc2010.link(cfg)
event_hooks(cfg)
_p(1,'</ItemDefinitionGroup>')
end
end
function exists(table, fine)
for _, value in ipairs(table) do
if value == find then return true end
end
return false
end
--
-- Retrieve a list of files for a particular build group, one of
-- "ClInclude", "ClCompile", "ResourceCompile", and "None".
@ -506,7 +494,7 @@
ClInclude = {},
None = {},
ResourceCompile = {},
AppxManifest = {}
AppxManifest = {}
}
local foundAppxManifest = false
@ -514,19 +502,19 @@
if path.iscppfile(file.name) then
table.insert(sortedfiles.ClCompile, file)
elseif path.iscppheader(file.name) then
if not exists(prj.removefiles, file) then
if not table.icontains(prj.removefiles, file) then
table.insert(sortedfiles.ClInclude, file)
end
elseif path.isresourcefile(file.name) then
table.insert(sortedfiles.ResourceCompile, file)
else
local ext = path.getextension(file.name):lower()
if ext == ".appxmanifest" then
local ext = path.getextension(file.name):lower()
if ext == ".appxmanifest" then
foundAppxManifest = true
table.insert(sortedfiles.AppxManifest, file)
else
table.insert(sortedfiles.None, file)
end
table.insert(sortedfiles.AppxManifest, file)
else
table.insert(sortedfiles.None, file)
end
end
end
@ -557,7 +545,7 @@
vc2010.compilerfilesgroup(prj)
vc2010.simplefilesgroup(prj, "None")
vc2010.simplefilesgroup(prj, "ResourceCompile")
vc2010.simplefilesgroup(prj, "AppxManifest")
vc2010.simplefilesgroup(prj, "AppxManifest")
end
@ -566,13 +554,13 @@
if #files > 0 then
_p(1,'<ItemGroup>')
for _, file in ipairs(files) do
if subtype then
_p(2,'<%s Include=\"%s\">', section, path.translate(file.name, "\\"))
_p(3,'<SubType>%s</SubType>', subtype)
_p(2,'</%s>', section)
else
_p(2,'<%s Include=\"%s\" />', section, path.translate(file.name, "\\"))
end
if subtype then
_p(2,'<%s Include=\"%s\">', section, path.translate(file.name, "\\"))
_p(3,'<SubType>%s</SubType>', subtype)
_p(2,'</%s>', section)
else
_p(2,'<%s Include=\"%s\" />', section, path.translate(file.name, "\\"))
end
end
_p(1,'</ItemGroup>')
end
@ -605,37 +593,15 @@
end
end
-- Global exclude
local excluded = false
for _, exclude in ipairs(prj.excludes) do
if exclude == file.name then
for _, vsconfig in ipairs(configs) do
local cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)
_p(3, '<ExcludedFromBuild '
.. if_config_and_platform()
.. '>true</ExcludedFromBuild>'
, premake.esc(vsconfig.name)
)
end
excluded = true
break
end
end
if not excluded then
-- Per configuration excludes
for _, vsconfig in ipairs(configs) do
local cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)
for _, exclude in ipairs(cfg.excludes) do
if exclude == file.name then
_p(3, '<ExcludedFromBuild '
.. if_config_and_platform()
.. '>true</ExcludedFromBuild>'
, premake.esc(vsconfig.name)
)
end
end
local excluded = table.icontains(prj.excludes, file.name)
for _, vsconfig in ipairs(configs) do
local cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)
if excluded or table.icontains(cfg.excludes, file.name) then
_p(3, '<ExcludedFromBuild '
.. if_config_and_platform()
.. '>true</ExcludedFromBuild>'
, premake.esc(vsconfig.name)
)
end
end

View File

@ -810,13 +810,16 @@
end
-- list value types get a remove() call too
if info.kind == "list" or
info.kind == "dirlist" or
info.kind == "filelist" or
info.kind == "absolutefilelist"
if info.kind == "list"
or info.kind == "dirlist"
or info.kind == "filelist"
or info.kind == "absolutefilelist"
then
_G["remove"..name] = function(value)
premake.remove(name, value)
if name ~= "removefiles"
and name ~= "files" then
_G["remove"..name] = function(value)
premake.remove(name, value)
end
end
end
end

View File

@ -253,6 +253,7 @@
-- build the configuration base by merging the solution and project level settings
local cfg = {}
mergeobject(cfg, basis[key])
adjustpaths(obj.location, cfg)
mergeobject(cfg, obj)
@ -376,7 +377,7 @@
local dir
local start = iif(cfg.name, 2, 1)
for v = start, iif(cfg.flags.SingleOutputDir,num_variations-1,num_variations) do
for v = start, iif(cfg.flags.SingleOutputDir==true,num_variations-1,num_variations) do
dir = cfg_dirs[cfg][v]
if hit_counts[dir] == 1 then break end
end
@ -701,15 +702,13 @@
end
-- remove excluded files from the file list
local files = { }
local removefiles = cfg.removefiles
if _ACTION == 'gmake' then
removefiles = table.join(removefiles, cfg.excludes)
end
local files = {}
for _, fname in ipairs(cfg.files) do
local removed = false
for _, removefname in ipairs(cfg.removefiles) do
removed = (fname == removefname)
if (removed) then break end
end
if (not removed) then
if not table.icontains(removefiles, fname) then
table.insert(files, fname)
end
end

View File

@ -283,7 +283,9 @@ function inspect(rootObject, options)
end
function printtable(name, table)
print("--- " .. name)
print(inspect(table))
print("---")
print("table: ", name, inspect(table), "\n")
end
function printstack()
print(debug.traceback(), "\n")
end

View File

@ -3,22 +3,27 @@
-- Additions to Lua's built-in table functions.
-- Copyright (c) 2002-2008 Jason Perkins and the Premake project
--
--
-- Returns true if the table contains the specified value.
--
function table.contains(t, value)
for _,v in pairs(t) do
if (v == value) then
return true
end
for _, v in pairs(t) do
if v == value then return true end
end
return false
end
function table.icontains(t, value)
for _, v in ipairs(t) do
if v == value then return true end
end
return false
end
--
-- Enumerates an array of objects and returns a new table containing
-- only the value of one particular field.
@ -31,8 +36,8 @@
end
return result
end
--
-- Flattens a hierarchy of tables into a single array containing all
@ -41,7 +46,7 @@
function table.flatten(arr)
local result = { }
local function flatten(arr)
for _, v in ipairs(arr) do
if type(v) == "table" then
@ -51,7 +56,7 @@
end
end
end
flatten(arr)
return result
end
@ -75,7 +80,7 @@
--
-- Inserts a value of array of values into a table. If the value is
-- itself a table, its contents are enumerated and added instead. So
-- itself a table, its contents are enumerated and added instead. So
-- these inputs give these outputs:
--
-- "x" -> { "x" }
@ -156,7 +161,7 @@
end
return result
end
--
@ -179,5 +184,5 @@
end
return result
end

View File

@ -21,8 +21,8 @@ const char* builtin_scripts[] = {
"function string.explode(s, pattern, plain)\nif (pattern == '') then return false end\nlocal pos = 0\nlocal arr = { }\nfor st,sp in function() return s:find(pattern, pos, plain) end do\ntable.insert(arr, s:sub(pos, st-1))\npos = sp + 1\nend\ntable.insert(arr, s:sub(pos))\nreturn arr\nend\nfunction string.findlast(s, pattern, plain)\nlocal curr = 0\nrepeat\nlocal next = s:find(pattern, curr + 1, plain)\nif (next) then curr = next end\nuntil (not next)\nif (curr > 0) then\nreturn curr\nend\nend\nfunction string.startswith(haystack, needle)\nreturn (haystack:find(needle, 1, true) == 1)\nend\n",
/* base/table.lua */
"function table.contains(t, value)\nfor _,v in pairs(t) do\nif (v == value) then\nreturn true\nend\nend\nreturn false\nend\nfunction table.extract(arr, fname)\nlocal result = { }\nfor _,v in ipairs(arr) do\ntable.insert(result, v[fname])\nend\nreturn result\nend\nfunction table.flatten(arr)\nlocal result = { }\nlocal function flatten(arr)\nfor _, v in ipairs(arr) do\nif type(v) == \"table\" then\nflatten(v)\nelse\ntable.insert(result, v)\nend\nend\nend\nflatten(arr)\nreturn result\nend\nfunction table.implode(arr, before, after, between)\nlocal result = \"\"\nfor _,v in ipairs(arr) do\nif (result ~= \"\" and between) then\nresult = result .. between\nend\nresult = result .. before .. v .. after\nend\nreturn result\nend\nfunction table.insertflat(tbl, values)\nif type(values) == \"table\" then\nfor _, value in ipairs(values) do\ntable.insertflat(tbl, value)\nend\nelse\ntable.insert(tbl, values)\nend\nend\nfunction table.isempty(t)\nreturn next(t) == nil\nend\nfunction table.join(...)\nlocal arg={...}\nlocal resu"
"lt = { }\nfor _,t in ipairs(arg) do\nif type(t) == \"table\" then\nfor _,v in ipairs(t) do\ntable.insert(result, v)\nend\nelse\ntable.insert(result, t)\nend\nend\nreturn result\nend\nfunction table.keys(tbl)\nlocal keys = {}\nfor k, _ in pairs(tbl) do\ntable.insert(keys, k)\nend\nreturn keys\nend\nfunction table.merge(...)\nlocal arg={...}\nlocal result = { }\nfor _,t in ipairs(arg) do\nif type(t) == \"table\" then\nfor k,v in pairs(t) do\nresult[k] = v\nend\nelse\nerror(\"invalid value\")\nend\nend\nreturn result\nend\nfunction table.translate(arr, translation)\nlocal result = { }\nfor _, value in ipairs(arr) do\nlocal tvalue\nif type(translation) == \"function\" then\ntvalue = translation(value)\nelse\ntvalue = translation[value]\nend\nif (tvalue) then\ntable.insert(result, tvalue)\nend\nend\nreturn result\nend\n",
"function table.contains(t, value)\nfor _, v in pairs(t) do\nif v == value then return true end\nend\nreturn false\nend\nfunction table.icontains(t, value)\nfor _, v in ipairs(t) do\nif v == value then return true end\nend\nreturn false\nend\nfunction table.extract(arr, fname)\nlocal result = { }\nfor _,v in ipairs(arr) do\ntable.insert(result, v[fname])\nend\nreturn result\nend\nfunction table.flatten(arr)\nlocal result = { }\nlocal function flatten(arr)\nfor _, v in ipairs(arr) do\nif type(v) == \"table\" then\nflatten(v)\nelse\ntable.insert(result, v)\nend\nend\nend\nflatten(arr)\nreturn result\nend\nfunction table.implode(arr, before, after, between)\nlocal result = \"\"\nfor _,v in ipairs(arr) do\nif (result ~= \"\" and between) then\nresult = result .. between\nend\nresult = result .. before .. v .. after\nend\nreturn result\nend\nfunction table.insertflat(tbl, values)\nif type(values) == \"table\" then\nfor _, value in ipairs(values) do\ntable.insertflat(tbl, value)\nend\nelse\ntable.insert(tbl, values)"
"\nend\nend\nfunction table.isempty(t)\nreturn next(t) == nil\nend\nfunction table.join(...)\nlocal arg={...}\nlocal result = { }\nfor _,t in ipairs(arg) do\nif type(t) == \"table\" then\nfor _,v in ipairs(t) do\ntable.insert(result, v)\nend\nelse\ntable.insert(result, t)\nend\nend\nreturn result\nend\nfunction table.keys(tbl)\nlocal keys = {}\nfor k, _ in pairs(tbl) do\ntable.insert(keys, k)\nend\nreturn keys\nend\nfunction table.merge(...)\nlocal arg={...}\nlocal result = { }\nfor _,t in ipairs(arg) do\nif type(t) == \"table\" then\nfor k,v in pairs(t) do\nresult[k] = v\nend\nelse\nerror(\"invalid value\")\nend\nend\nreturn result\nend\nfunction table.translate(arr, translation)\nlocal result = { }\nfor _, value in ipairs(arr) do\nlocal tvalue\nif type(translation) == \"function\" then\ntvalue = translation(value)\nelse\ntvalue = translation[value]\nend\nif (tvalue) then\ntable.insert(result, tvalue)\nend\nend\nreturn result\nend\n",
/* base/io.lua */
"function io.capture()\nio.captured = ''\nend\nfunction io.endcapture()\nlocal captured = io.captured\nio.captured = nil\nreturn captured\nend\nlocal builtin_open = io.open\nfunction io.open(fname, mode)\nif (mode) then\nif (mode:find(\"w\")) then\nlocal dir = path.getdirectory(fname)\nok, err = os.mkdir(dir)\nif (not ok) then\nerror(err, 0)\nend\nend\nend\nreturn builtin_open(fname, mode)\nend\nfunction io.printf(msg, ...)\nlocal arg={...}\nif not io.eol then\nio.eol = \"\\n\"\nend\nif not io.indent then\nio.indent = \"\\t\"\nend\nif type(msg) == \"number\" then\ns = string.rep(io.indent, msg) .. string.format(table.unpack(arg))\nelse\ns = string.format(msg, table.unpack(arg))\nend\nif io.captured then\nio.captured = io.captured .. s .. io.eol\nelse\nio.write(s)\nio.write(io.eol)\nend\nend\n_p = io.printf\n",
@ -68,16 +68,16 @@ const char* builtin_scripts[] = {
"n\nreturn false\nend\nif matched == \"required\" then\nhasrequired = true\nend\nend\nif terms.required and not hasrequired then\nreturn false\nelse\nreturn true\nend\nend\nlocal function adjustpaths(location, obj)\nfunction adjustpathlist(list)\nfor i, p in ipairs(list) do\nlist[i] = path.getrelative(location, p)\nend\nend\nfor name, value in pairs(obj) do\nlocal field = premake.fields[name]\nif field and value and not keeprelative[name] then\nif field.kind == \"path\" then\nobj[name] = path.getrelative(location, value)\nelseif field.kind == \"dirlist\" or field.kind == \"filelist\" then\nadjustpathlist(value)\nelseif field.kind == \"keypath\" then\nfor k,v in pairs(value) do\nadjustpathlist(v)\nend\nend\nend\nend\nend\nlocal function mergefield(kind, dest, src)\nlocal tbl = dest or { }\nif kind == \"keyvalue\" or kind == \"keypath\" then\nfor key, value in pairs(src) do\ntbl[key] = mergefield(\"list\", tbl[key], value)\nend\nelse\nfor _, item in ipairs(src) do\nif not tbl[item] then\ntable.insert(tbl, item)\n"
"tbl[item] = item\nend\nend\nend\nreturn tbl\nend\nlocal function removevalues(tbl, removes)\nfor i=#tbl,1,-1 do\nfor _, pattern in ipairs(removes) do\nif pattern == tbl[i] then\ntable.remove(tbl, i)\nbreak\nend\nend\nend\nend\nlocal function mergeobject(dest, src)\nif not src then\nreturn\nend\nfor fieldname, value in pairs(src) do\nif not nocopy[fieldname] then\nlocal field = premake.fields[fieldname]\nif field then\nif type(value) == \"table\" then\ndest[fieldname] = mergefield(field.kind, dest[fieldname], value)\nif src.removes then\nremoves = src.removes[fieldname]\nif removes then\nremovevalues(dest[fieldname], removes)\nend\nend\nelse\ndest[fieldname] = value\nend\nelse\ndest[fieldname] = value\nend\nend\nend\nend\nlocal function merge(dest, obj, basis, terms, cfgname, pltname)\nlocal key = cfgname or \"\"\npltname = pltname or \"Native\"\nif pltname ~= \"Native\" then\nkey = key .. pltname\nend\nterms.config = (cfgname or \"\"):lower()\nterms.platform = pltname:lower()\nlocal cfg = {}\nmergeobject(cfg, "
"basis[key])\nadjustpaths(obj.location, cfg)\nmergeobject(cfg, obj)\nif (cfg.kind) then\nterms['kind']=cfg.kind:lower()\nend\nfor _, blk in ipairs(obj.blocks) do\nif (premake.iskeywordsmatch(blk.keywords, terms))then\nmergeobject(cfg, blk)\nif (cfg.kind and not cfg.terms.kind) then\ncfg.terms['kind'] = cfg.kind:lower()\nterms['kind'] = cfg.kind:lower()\nend\nend\nend\ncfg.name = cfgname\ncfg.platform = pltname\nfor k,v in pairs(terms) do\ncfg.terms[k] =v\nend\ndest[key] = cfg\nend\nlocal function collapse(obj, basis)\nlocal result = {}\nbasis = basis or {}\nlocal sln = obj.solution or obj\nlocal terms = premake.getactiveterms()\nmerge(result, obj, basis, terms)--this adjusts terms\nfor _, cfgname in ipairs(sln.configurations) do\nlocal terms_local = {}\nfor k,v in pairs(terms)do terms_local[k]=v end\nmerge(result, obj, basis, terms_local, cfgname, \"Native\")--terms cam also be adjusted here\nfor _, pltname in ipairs(sln.platforms or {}) do\nif pltname ~= \"Native\" then\nmerge(result, obj, basis,terms_lo"
"cal, cfgname, pltname)--terms also here\nend\nend\nend\nreturn result\nend\nlocal function builduniquedirs()\nlocal num_variations = 4\nlocal cfg_dirs = {}\nlocal hit_counts = {}\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\nlocal dirs = { }\ndirs[1] = path.getabsolute(path.join(cfg.location, cfg.objdir or cfg.project.objdir or \"obj\"))\ndirs[2] = path.join(dirs[1], iif(cfg.platform == \"Native\", \"\", cfg.platform))\ndirs[3] = path.join(dirs[2], cfg.name)\ndirs[4] = path.join(dirs[3], cfg.project.name)\ncfg_dirs[cfg] = dirs\nlocal start = iif(cfg.name, 2, 1)\nfor v = start, num_variations do\nlocal d = dirs[v]\nhit_counts[d] = (hit_counts[d] or 0) + 1\nend\nend\nend\nend\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\nlocal dir\nlocal start = iif(cfg.name, 2, 1)\nfor v = start, iif(cfg.flags.SingleOutputDir,num_variations-1,num_variations) do\ndir = cfg_dirs[cfg][v]\n"
"if hit_counts[dir] == 1 then break end\nend\ncfg.objectsdir = path.getrelative(cfg.location, dir)\nend\nend\nend\nend\nlocal function buildtargets()\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\nlocal pathstyle = premake.getpathstyle(cfg)\nlocal namestyle = premake.getnamestyle(cfg)\ncfg.buildtarget = premake.gettarget(cfg, \"build\", pathstyle, namestyle, cfg.system)\ncfg.linktarget = premake.gettarget(cfg, \"link\", pathstyle, namestyle, cfg.system)\nif pathstyle == \"windows\" then\ncfg.objectsdir = path.translate(cfg.objectsdir, \"\\\\\")\nend\nend\nend\nend\nend\n local function getCfgKind(cfg)\n if(cfg.kind) then\n return cfg.kind;\n end\n if(cfg.project.__configs[\"\"] and cfg.project.__configs[\"\"].kind) then\n return cfg.project.__configs[\"\"].kind;\n end\n return nil\n end\n local function getprojrec(dstArray, foundList, cfg, cfgname, searchField, bLinkage)\n if(not cfg) then return end\n local foundUsePrjs = {};"
"\n for _, useName in ipairs(cfg[searchField]) do\n local testName = useName:lower();\n if((not foundList[testName])) then\n local theProj = nil;\n local theUseProj = nil;\n for _, prj in ipairs(cfg.project.solution.projects) do\n if (prj.name:lower() == testName) then\n if(prj.usage) then\n theUseProj = prj;\n else\n theProj = prj;\n end\n end\n end\n --Must connect to a usage project.\n if(theUseProj) then\n foundList[testName] = true;\n local prjEntry = {\n name = testName,\n proj = theProj,\n usageProj = theUseProj,\n bLinkageOnly = bLinkage,\n };\n dstArray[testName] = prjEntry;\n table.insert(foundUsePrjs, theUseProj);\n end\n end\n end\n for _, usePrj in ipairs(foundUsePrjs) do\n --Links can only recurse through static libraries.\n if((searchField ~= \"links\") or\n (getCfgKind(usePrj.__configs[cfgname]) == \"StaticLib\")) then\n getprojrec(dstArray, foundList, usePrj.__configs[cfgname],\n cfgname, searchField, bLinkage);\n end\n end\n end\n --\n -- This function wi"
"ll recursively get all projects that the given configuration has in its \"uses\"\n -- field. The return values are a list of tables. Each table in that list contains the following:\n --name = The lowercase name of the project.\n --proj = The project. Can be nil if it is usage-only.\n --usageProj = The usage project. Can't be nil, as using a project that has no\n -- usage project is not put into the list.\n --bLinkageOnly = If this is true, then only the linkage information should be copied.\n -- The recursion will only look at the \"uses\" field on *usage* projects.\n -- This function will also add projects to the list that are mentioned in the \"links\"\n -- field of usage projects. These will only copy linker information, but they will recurse.\n -- through other \"links\" fields.\n --\n local function getprojectsconnections(cfg, cfgname)\n local dstArray = {};\n local foundList = {};\n foundList[cfg.project.name:lower()] = true;\n --First, follow the uses recursively.\n getprojrec(dstArray,"
" foundList, cfg, cfgname, \"uses\", false);\n --Next, go through all of the usage projects and recursively get their links.\n --But only if they're not already there. Get the links as linkage-only.\n local linkArray = {};\n for prjName, prjEntry in pairs(dstArray) do\n getprojrec(linkArray, foundList, prjEntry.usageProj.__configs[cfgname], cfgname,\n \"links\", true);\n end\n --Copy from linkArray into dstArray.\n for prjName, prjEntry in pairs(linkArray) do\n dstArray[prjName] = prjEntry;\n end\n return dstArray;\n end\n local function isnameofproj(cfg, strName)\n local sln = cfg.project.solution;\n local strTest = strName:lower();\n for prjIx, prj in ipairs(sln.projects) do\n if (prj.name:lower() == strTest) then\n return true;\n end\n end\n return false;\n end\n --\n -- Copies the field from dstCfg to srcCfg.\n --\n local function copydependentfield(srcCfg, dstCfg, strSrcField)\n local srcField = premake.fields[strSrcField];\n local strDstField = strSrcField;\n if type(srcCfg[s"
"trSrcField]) == \"table\" then\n --handle paths.\n if (srcField.kind == \"dirlist\" or srcField.kind == \"filelist\") and\n (not keeprelative[strSrcField]) then\n for i,p in ipairs(srcCfg[strSrcField]) do\n table.insert(dstCfg[strDstField],\n path.rebase(p, srcCfg.project.location, dstCfg.project.location))\n end\n else\n if(strSrcField == \"links\") then\n for i,p in ipairs(srcCfg[strSrcField]) do\n if(not isnameofproj(dstCfg, p)) then\n table.insert(dstCfg[strDstField], p)\n else\n printf(\"Failed to copy '%s' from proj '%s'.\",\n p, srcCfg.project.name);\n end\n end\n else\n for i,p in ipairs(srcCfg[strSrcField]) do\n table.insert(dstCfg[strDstField], p)\n end\n end\n end\n else\n if(srcField.kind == \"path\" and (not keeprelative[strSrcField])) then\n dstCfg[strDstField] = path.rebase(srcCfg[strSrcField],\n prj.location, dstCfg.project.location);\n else\n dstCfg[strDstField] = srcCfg[strSrcField];\n end\n end\n end\n --\n -- This function will take the list of project entr"
"ies and apply their usage project data\n -- to the given configuration. It will copy compiling information for the projects that are\n -- not listed as linkage-only. It will copy the linking information for projects only if\n -- the source project is not a static library. It won't copy linking information\n -- if the project is in this solution; instead it will add that project to the configuration's\n -- links field, expecting that Premake will handle the rest.\n --\n local function copyusagedata(cfg, cfgname, linkToProjs)\n local myPrj = cfg.project;\n local bIsStaticLib = (getCfgKind(cfg) == \"StaticLib\");\n for prjName, prjEntry in pairs(linkToProjs) do\n local srcPrj = prjEntry.usageProj;\n local srcCfg = srcPrj.__configs[cfgname];\n for name, field in pairs(premake.fields) do\n if(srcCfg[name]) then\n if(field.usagecopy) then\n if(not prjEntry.bLinkageOnly) then\n copydependentfield(srcCfg, cfg, name)\n end\n elseif(field.linkagecopy) then\n --Copy the linkage data if we're building "
"a non-static thing\n --and this is a pure usage project. If it's not pure-usage, then\n --we will simply put the project's name in the links field later.\n if((not bIsStaticLib) and (not prjEntry.proj)) then\n copydependentfield(srcCfg, cfg, name)\n end\n end\n end\n end\n if((not bIsStaticLib) and prjEntry.proj) then\n table.insert(cfg.links, prjEntry.proj.name);\n end\n end\n end\nfunction premake.bake.buildconfigs()\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nprj.location = prj.location or sln.location or prj.basedir\nadjustpaths(prj.location, prj)\nfor _, blk in ipairs(prj.blocks) do\nadjustpaths(prj.location, blk)\nend\nend\nsln.location = sln.location or sln.basedir\nend\nfor sln in premake.solution.each() do\nlocal basis = collapse(sln)\nfor _, prj in ipairs(sln.projects) do\nprj.__configs = collapse(prj, basis)\nfor _, cfg in pairs(prj.__configs) do\nbake.postprocess(prj, cfg)\nend\nend\nend\nfor sln in premake.solution.each() do\nfor prjIx, prj in ipairs"
"(sln.projects) do\nif(not prj.usage) then\nfor cfgname, cfg in pairs(prj.__configs) do\nlocal usesPrjs = getprojectsconnections(cfg, cfgname);\ncopyusagedata(cfg, cfgname, usesPrjs)\nend\nend\nend\nend\nfor sln in premake.solution.each() do\nlocal removeList = {};\nfor index, prj in ipairs(sln.projects) do\nif(prj.usage) then\ntable.insert(removeList, 1, index); --Add in reverse order.\nend\nend\nfor _, index in ipairs(removeList) do\ntable.remove(sln.projects, index);\nend\nend\nbuilduniquedirs()\nbuildtargets(cfg)\nend\nfunction premake.bake.postprocess(prj, cfg)\ncfg.project = prj\ncfg.shortname = premake.getconfigname(cfg.name, cfg.platform, true)\ncfg.longname = premake.getconfigname(cfg.name, cfg.platform)\ncfg.location = cfg.location or cfg.basedir\nlocal platform = premake.platforms[cfg.platform]\nif platform.iscrosscompiler then\ncfg.system = cfg.platform\nelse\ncfg.system = os.get()\nend\nif cfg.kind == \"SharedLib\" and platform.nosharedlibs then\ncfg.kind = \"StaticLib\"\nend\nlocal files = { }"
"\nfor _, fname in ipairs(cfg.files) do\nlocal removed = false\nfor _, removefname in ipairs(cfg.removefiles) do\nremoved = (fname == removefname)\nif (removed) then break end\nend\nif (not removed) then\ntable.insert(files, fname)\nend\nend\ncfg.files = files\nfor name, field in pairs(premake.fields) do\nif field.isflags then\nlocal values = cfg[name]\nfor _, flag in ipairs(values) do values[flag] = true end\nend\nend\ncfg.__fileconfigs = { }\nfor _, fname in ipairs(cfg.files) do\ncfg.terms.required = fname:lower()\nlocal fcfg = {}\nfor _, blk in ipairs(cfg.project.blocks) do\nif (premake.iskeywordsmatch(blk.keywords, cfg.terms)) then\nmergeobject(fcfg, blk)\nend\nend\nfcfg.name = fname\ncfg.__fileconfigs[fname] = fcfg\ntable.insert(cfg.__fileconfigs, fcfg)\nend\nend\n",
"cal, cfgname, pltname)--terms also here\nend\nend\nend\nreturn result\nend\nlocal function builduniquedirs()\nlocal num_variations = 4\nlocal cfg_dirs = {}\nlocal hit_counts = {}\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\nlocal dirs = { }\ndirs[1] = path.getabsolute(path.join(cfg.location, cfg.objdir or cfg.project.objdir or \"obj\"))\ndirs[2] = path.join(dirs[1], iif(cfg.platform == \"Native\", \"\", cfg.platform))\ndirs[3] = path.join(dirs[2], cfg.name)\ndirs[4] = path.join(dirs[3], cfg.project.name)\ncfg_dirs[cfg] = dirs\nlocal start = iif(cfg.name, 2, 1)\nfor v = start, num_variations do\nlocal d = dirs[v]\nhit_counts[d] = (hit_counts[d] or 0) + 1\nend\nend\nend\nend\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\nlocal dir\nlocal start = iif(cfg.name, 2, 1)\nfor v = start, iif(cfg.flags.SingleOutputDir==true,num_variations-1,num_variations) do\ndir = cfg_dirs[cfg"
"][v]\nif hit_counts[dir] == 1 then break end\nend\ncfg.objectsdir = path.getrelative(cfg.location, dir)\nend\nend\nend\nend\nlocal function buildtargets()\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\nlocal pathstyle = premake.getpathstyle(cfg)\nlocal namestyle = premake.getnamestyle(cfg)\ncfg.buildtarget = premake.gettarget(cfg, \"build\", pathstyle, namestyle, cfg.system)\ncfg.linktarget = premake.gettarget(cfg, \"link\", pathstyle, namestyle, cfg.system)\nif pathstyle == \"windows\" then\ncfg.objectsdir = path.translate(cfg.objectsdir, \"\\\\\")\nend\nend\nend\nend\nend\n local function getCfgKind(cfg)\n if(cfg.kind) then\n return cfg.kind;\n end\n if(cfg.project.__configs[\"\"] and cfg.project.__configs[\"\"].kind) then\n return cfg.project.__configs[\"\"].kind;\n end\n return nil\n end\n local function getprojrec(dstArray, foundList, cfg, cfgname, searchField, bLinkage)\n if(not cfg) then return end\n local foundUsePrjs "
"= {};\n for _, useName in ipairs(cfg[searchField]) do\n local testName = useName:lower();\n if((not foundList[testName])) then\n local theProj = nil;\n local theUseProj = nil;\n for _, prj in ipairs(cfg.project.solution.projects) do\n if (prj.name:lower() == testName) then\n if(prj.usage) then\n theUseProj = prj;\n else\n theProj = prj;\n end\n end\n end\n --Must connect to a usage project.\n if(theUseProj) then\n foundList[testName] = true;\n local prjEntry = {\n name = testName,\n proj = theProj,\n usageProj = theUseProj,\n bLinkageOnly = bLinkage,\n };\n dstArray[testName] = prjEntry;\n table.insert(foundUsePrjs, theUseProj);\n end\n end\n end\n for _, usePrj in ipairs(foundUsePrjs) do\n --Links can only recurse through static libraries.\n if((searchField ~= \"links\") or\n (getCfgKind(usePrj.__configs[cfgname]) == \"StaticLib\")) then\n getprojrec(dstArray, foundList, usePrj.__configs[cfgname],\n cfgname, searchField, bLinkage);\n end\n end\n end\n --\n -- This functi"
"on will recursively get all projects that the given configuration has in its \"uses\"\n -- field. The return values are a list of tables. Each table in that list contains the following:\n --name = The lowercase name of the project.\n --proj = The project. Can be nil if it is usage-only.\n --usageProj = The usage project. Can't be nil, as using a project that has no\n -- usage project is not put into the list.\n --bLinkageOnly = If this is true, then only the linkage information should be copied.\n -- The recursion will only look at the \"uses\" field on *usage* projects.\n -- This function will also add projects to the list that are mentioned in the \"links\"\n -- field of usage projects. These will only copy linker information, but they will recurse.\n -- through other \"links\" fields.\n --\n local function getprojectsconnections(cfg, cfgname)\n local dstArray = {};\n local foundList = {};\n foundList[cfg.project.name:lower()] = true;\n --First, follow the uses recursively.\n getprojrec(dstA"
"rray, foundList, cfg, cfgname, \"uses\", false);\n --Next, go through all of the usage projects and recursively get their links.\n --But only if they're not already there. Get the links as linkage-only.\n local linkArray = {};\n for prjName, prjEntry in pairs(dstArray) do\n getprojrec(linkArray, foundList, prjEntry.usageProj.__configs[cfgname], cfgname,\n \"links\", true);\n end\n --Copy from linkArray into dstArray.\n for prjName, prjEntry in pairs(linkArray) do\n dstArray[prjName] = prjEntry;\n end\n return dstArray;\n end\n local function isnameofproj(cfg, strName)\n local sln = cfg.project.solution;\n local strTest = strName:lower();\n for prjIx, prj in ipairs(sln.projects) do\n if (prj.name:lower() == strTest) then\n return true;\n end\n end\n return false;\n end\n --\n -- Copies the field from dstCfg to srcCfg.\n --\n local function copydependentfield(srcCfg, dstCfg, strSrcField)\n local srcField = premake.fields[strSrcField];\n local strDstField = strSrcField;\n if type(src"
"Cfg[strSrcField]) == \"table\" then\n --handle paths.\n if (srcField.kind == \"dirlist\" or srcField.kind == \"filelist\") and\n (not keeprelative[strSrcField]) then\n for i,p in ipairs(srcCfg[strSrcField]) do\n table.insert(dstCfg[strDstField],\n path.rebase(p, srcCfg.project.location, dstCfg.project.location))\n end\n else\n if(strSrcField == \"links\") then\n for i,p in ipairs(srcCfg[strSrcField]) do\n if(not isnameofproj(dstCfg, p)) then\n table.insert(dstCfg[strDstField], p)\n else\n printf(\"Failed to copy '%s' from proj '%s'.\",\n p, srcCfg.project.name);\n end\n end\n else\n for i,p in ipairs(srcCfg[strSrcField]) do\n table.insert(dstCfg[strDstField], p)\n end\n end\n end\n else\n if(srcField.kind == \"path\" and (not keeprelative[strSrcField])) then\n dstCfg[strDstField] = path.rebase(srcCfg[strSrcField],\n prj.location, dstCfg.project.location);\n else\n dstCfg[strDstField] = srcCfg[strSrcField];\n end\n end\n end\n --\n -- This function will take the list of project"
" entries and apply their usage project data\n -- to the given configuration. It will copy compiling information for the projects that are\n -- not listed as linkage-only. It will copy the linking information for projects only if\n -- the source project is not a static library. It won't copy linking information\n -- if the project is in this solution; instead it will add that project to the configuration's\n -- links field, expecting that Premake will handle the rest.\n --\n local function copyusagedata(cfg, cfgname, linkToProjs)\n local myPrj = cfg.project;\n local bIsStaticLib = (getCfgKind(cfg) == \"StaticLib\");\n for prjName, prjEntry in pairs(linkToProjs) do\n local srcPrj = prjEntry.usageProj;\n local srcCfg = srcPrj.__configs[cfgname];\n for name, field in pairs(premake.fields) do\n if(srcCfg[name]) then\n if(field.usagecopy) then\n if(not prjEntry.bLinkageOnly) then\n copydependentfield(srcCfg, cfg, name)\n end\n elseif(field.linkagecopy) then\n --Copy the linkage data if we're buil"
"ding a non-static thing\n --and this is a pure usage project. If it's not pure-usage, then\n --we will simply put the project's name in the links field later.\n if((not bIsStaticLib) and (not prjEntry.proj)) then\n copydependentfield(srcCfg, cfg, name)\n end\n end\n end\n end\n if((not bIsStaticLib) and prjEntry.proj) then\n table.insert(cfg.links, prjEntry.proj.name);\n end\n end\n end\nfunction premake.bake.buildconfigs()\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nprj.location = prj.location or sln.location or prj.basedir\nadjustpaths(prj.location, prj)\nfor _, blk in ipairs(prj.blocks) do\nadjustpaths(prj.location, blk)\nend\nend\nsln.location = sln.location or sln.basedir\nend\nfor sln in premake.solution.each() do\nlocal basis = collapse(sln)\nfor _, prj in ipairs(sln.projects) do\nprj.__configs = collapse(prj, basis)\nfor _, cfg in pairs(prj.__configs) do\nbake.postprocess(prj, cfg)\nend\nend\nend\nfor sln in premake.solution.each() do\nfor prjIx, prj in i"
"pairs(sln.projects) do\nif(not prj.usage) then\nfor cfgname, cfg in pairs(prj.__configs) do\nlocal usesPrjs = getprojectsconnections(cfg, cfgname);\ncopyusagedata(cfg, cfgname, usesPrjs)\nend\nend\nend\nend\nfor sln in premake.solution.each() do\nlocal removeList = {};\nfor index, prj in ipairs(sln.projects) do\nif(prj.usage) then\ntable.insert(removeList, 1, index); --Add in reverse order.\nend\nend\nfor _, index in ipairs(removeList) do\ntable.remove(sln.projects, index);\nend\nend\nbuilduniquedirs()\nbuildtargets(cfg)\nend\nfunction premake.bake.postprocess(prj, cfg)\ncfg.project = prj\ncfg.shortname = premake.getconfigname(cfg.name, cfg.platform, true)\ncfg.longname = premake.getconfigname(cfg.name, cfg.platform)\ncfg.location = cfg.location or cfg.basedir\nlocal platform = premake.platforms[cfg.platform]\nif platform.iscrosscompiler then\ncfg.system = cfg.platform\nelse\ncfg.system = os.get()\nend\nif cfg.kind == \"SharedLib\" and platform.nosharedlibs then\ncfg.kind = \"StaticLib\"\nend\nlocal removef"
"iles = cfg.removefiles\nif _ACTION == 'gmake' then\nremovefiles = table.join(removefiles, cfg.excludes)\nend\nlocal files = {}\nfor _, fname in ipairs(cfg.files) do\nif not table.icontains(removefiles, fname) then\ntable.insert(files, fname)\nend\nend\ncfg.files = files\nfor name, field in pairs(premake.fields) do\nif field.isflags then\nlocal values = cfg[name]\nfor _, flag in ipairs(values) do values[flag] = true end\nend\nend\ncfg.__fileconfigs = { }\nfor _, fname in ipairs(cfg.files) do\ncfg.terms.required = fname:lower()\nlocal fcfg = {}\nfor _, blk in ipairs(cfg.project.blocks) do\nif (premake.iskeywordsmatch(blk.keywords, cfg.terms)) then\nmergeobject(fcfg, blk)\nend\nend\nfcfg.name = fname\ncfg.__fileconfigs[fname] = fcfg\ntable.insert(cfg.__fileconfigs, fcfg)\nend\nend\n",
/* base/api.lua */
"premake.fields =\n{\narchivesplit_size =\n{\nkind = \"string\",\nscope = \"config\",\n},\nbasedir =\n{\nkind = \"path\",\nscope = \"container\",\n},\nbuildaction =\n{\nkind = \"string\",\nscope = \"config\",\nallowed = {\n\"Compile\",\n\"Copy\",\n\"Embed\",\n\"None\"\n}\n},\nbuildoptions =\n{\nkind = \"list\",\nscope = \"config\",\n},\nbuildoptions_c =\n{\nkind = \"list\",\nscope = \"config\",\n},\nbuildoptions_cpp =\n{\nkind = \"list\",\nscope = \"config\",\n},\nbuildoptions_objc =\n{\nkind = \"list\",\nscope = \"config\",\n},\nconfigurations =\n{\nkind = \"list\",\nscope = \"solution\",\n},\ndebugargs =\n{\nkind = \"list\",\nscope = \"config\",\n},\ndebugdir =\n{\nkind = \"path\",\nscope = \"config\",\n},\ndebugenvs =\n{\nkind = \"list\",\nscope = \"config\",\n},\ndefines =\n{\nkind = \"list\",\nscope = \"config\",\n},\ndeploymentoptions =\n{\nkind = \"list\",\nscope = \"config\",\nusagecopy = true,\n},\nexcludes =\n{\nkind = \"filelist\",\nscope = \"config\",\n},\nfiles =\n{\nkind = \"filelist"
@ -90,12 +90,12 @@ const char* builtin_scripts[] = {
" premake.CurrentConfiguration\nend\nif t == \"solution\" then\nif type(container) == \"project\" then\ncontainer = container.solution\nend\nif type(container) ~= \"solution\" then\ncontainer = nil\nend\nend\nlocal msg\nif (not container) then\nif (t == \"container\") then\nmsg = \"no active solution or project\"\nelseif (t == \"solution\") then\nmsg = \"no active solution\"\nelse\nmsg = \"no active solution, project, or configuration\"\nend\nend\nreturn container, msg\nend\nfunction premake.setarray(obj, fieldname, value, allowed)\nobj[fieldname] = obj[fieldname] or {}\nlocal function add(value, depth)\nif type(value) == \"table\" then\nfor _,v in ipairs(value) do\nadd(v, depth + 1)\nend\nelse\nvalue, err = premake.checkvalue(value, allowed)\nif not value then\nerror(err, depth)\nend\ntable.insert(obj[fieldname], value)\nend\nend\nif value then\nadd(value, 5)\nend\nreturn obj[fieldname]\nend\nlocal function domatchedarray(ctype, fieldname, value, matchfunc)\nlocal result = { }\nfunction makeabsolute(value, dep"
"th)\nif (type(value) == \"table\") then\nfor _, item in ipairs(value) do\nmakeabsolute(item, depth + 1)\nend\nelseif type(value) == \"string\" then\nif value:find(\"*\") then\nlocal arr = matchfunc(value);\nif (premake.check_paths) and (#arr == 0) then\nerror(\"Can't find matching files for pattern :\" .. value)\nend\nmakeabsolute(arr, depth + 1)\nelse\ntable.insert(result, path.getabsolute(value))\nend\nelse\nerror(\"Invalid value in list: expected string, got \" .. type(value), depth)\nend\nend\nmakeabsolute(value, 3)\nreturn premake.setarray(ctype, fieldname, result)\nend\nfunction premake.setdirarray(ctype, fieldname, value)\nreturn domatchedarray(ctype, fieldname, value, os.matchdirs)\nend\nfunction premake.setfilearray(ctype, fieldname, value)\nreturn domatchedarray(ctype, fieldname, value, os.matchfiles)\nend\nfunction premake.setkeyvalue(ctype, fieldname, values)\nlocal container, err = premake.getobject(ctype)\nif not container then\nerror(err, 4)\nend\nif not container[fieldname] then\ncontainer[fiel"
"dname] = {}\nend\nif type(values) ~= \"table\" then\nerror(\"invalid value; table expected\", 4)\nend\nlocal field = container[fieldname]\nfor key,value in pairs(values) do\nif not field[key] then\nfield[key] = {}\nend\ntable.insertflat(field[key], value)\nend\nreturn field\nend\nfunction premake.setstring(ctype, fieldname, value, allowed)\nlocal container, err = premake.getobject(ctype)\nif (not container) then\nerror(err, 4)\nend\nif (value) then\nvalue, err = premake.checkvalue(value, allowed)\nif (not value) then\nerror(err, 4)\nend\ncontainer[fieldname] = value\nend\nreturn container[fieldname]\nend\nfunction premake.remove(fieldname, value)\nlocal cfg = premake.CurrentConfiguration\ncfg.removes = cfg.removes or {}\ncfg.removes[fieldname] = premake.setarray(cfg.removes, fieldname, value)\nend\nlocal function accessor(name, value)\nlocal kind = premake.fields[name].kind\nlocal scope = premake.fields[name].scope\nlocal allowed = premake.fields[name].allowed\nif (kind == \"string\" or kind == \"path\") "
"and value then\nif type(value) ~= \"string\" then\nerror(\"string value expected\", 3)\nend\nend\nlocal container, err = premake.getobject(scope)\nif (not container) then\nerror(err, 3)\nend\nif kind == \"string\" then\nreturn premake.setstring(scope, name, value, allowed)\nelseif kind == \"path\" then\nif value then value = path.getabsolute(value) end\nreturn premake.setstring(scope, name, value)\nelseif kind == \"list\" then\nreturn premake.setarray(container, name, value, allowed)\nelseif kind == \"dirlist\" then\nreturn premake.setdirarray(container, name, value)\nelseif kind == \"filelist\" or kind == \"absolutefilelist\" then\nreturn premake.setfilearray(container, name, value)\nelseif kind == \"keyvalue\" or kind == \"keypath\" then\nreturn premake.setkeyvalue(scope, name, value)\nend\nend\nfor name, info in pairs(premake.fields) do\n_G[name] = function(value)\nreturn accessor(name, value)\nend\nif info.kind == \"list\" or\n info.kind == \"dirlist\" or\n info.kind == \"filelist\" or\n info.kind =="
" \"absolutefilelist\"\nthen\n_G[\"remove\"..name] = function(value)\npremake.remove(name, value)\nend\nend\nend\nfunction configuration(terms)\nif not terms then\nreturn premake.CurrentConfiguration\nend\nlocal container, err = premake.getobject(\"container\")\nif (not container) then\nerror(err, 2)\nend\nlocal cfg = { }\ncfg.terms = table.flatten({terms})\ntable.insert(container.blocks, cfg)\npremake.CurrentConfiguration = cfg\ncfg.keywords = { }\nfor _, word in ipairs(cfg.terms) do\ntable.insert(cfg.keywords, path.wildcards(word):lower())\nend\nfor name, field in pairs(premake.fields) do\nif (field.kind ~= \"string\" and field.kind ~= \"path\") then\ncfg[name] = { }\nend\nend\nreturn cfg\nend\nlocal function creategroup(name, sln, parent, inpath)\nlocal group = {}\nsetmetatable(group, {\n__type = \"group\"\n})\ntable.insert(sln.groups, group)\nsln.groups[inpath] = group\ngroup.solution = sln\ngroup.name = name\ngroup.uuid = os.uuid(group.name)\ngroup.parent = parent\nreturn group\nend\nlocal function createg"
"roupsfrompath(inpath, sln)\nif inpath == nil then return nil end\ninpath = path.translate(inpath, \"/\")\nlocal groups = string.explode(inpath, \"/\")\nlocal curpath = \"\"\nlocal lastgroup = nil\nfor i, v in ipairs(groups) do\ncurpath = curpath .. \"/\" .. v:lower()\nlocal group = sln.groups[curpath]\nif group == nil then\ngroup = creategroup(v, sln, lastgroup, curpath)\nend\nlastgroup = group\nend\nreturn lastgroup\nend\nlocal function createproject(name, sln, isUsage)\nlocal prj = {}\nsetmetatable(prj, {\n__type = \"project\",\n})\ntable.insert(sln.projects, prj)\nif(isUsage) then\nif(sln.projects[name]) then\nsln.projects[name].usageProj = prj;\nelse\nsln.projects[name] = prj\nend\nelse\nif(sln.projects[name]) then\nprj.usageProj = sln.projects[name];\nend\nsln.projects[name] = prj\nend\nlocal group = creategroupsfrompath(premake.CurrentGroup, sln)\nprj.solution = sln\nprj.name = name\nprj.basedir = os.getcwd()\nprj.uuid = os.uuid(prj.name)\nprj.blocks = { }\nprj.us"
"age = isUsage\nprj.group = group\nreturn prj;\nend\nfunction usage(name)\nif (not name) then\nif(type(premake.CurrentContainer) ~= \"project\") then return nil end\nif(not premake.CurrentContainer.usage) then return nil end\nreturn premake.CurrentContainer\nend\nlocal sln\nif (type(premake.CurrentContainer) == \"project\") then\nsln = premake.CurrentContainer.solution\nelse\nsln = premake.CurrentContainer\nend\nif (type(sln) ~= \"solution\") then\nerror(\"no active solution\", 2)\nend\nif((not sln.projects[name]) or\n((not sln.projects[name].usage) and (not sln.projects[name].usageProj))) then\npremake.CurrentContainer = createproject(name, sln, true)\nelse\npremake.CurrentContainer = iff(sln.projects[name].usage,\nsln.projects[name], sln.projects[name].usageProj)\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction project(name)\nif (not name) then\nif(type(premake.CurrentContainer) ~= \"project\") then return nil end\nif(premake.CurrentContainer.usage) then return nil end"
"\nreturn premake.CurrentContainer\nend\nlocal sln\nif (type(premake.CurrentContainer) == \"project\") then\nsln = premake.CurrentContainer.solution\nelse\nsln = premake.CurrentContainer\nend\nif (type(sln) ~= \"solution\") then\nerror(\"no active solution\", 2)\nend\nif((not sln.projects[name]) or sln.projects[name].usage) then\npremake.CurrentContainer = createproject(name, sln)\nelse\npremake.CurrentContainer = sln.projects[name];\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction solution(name)\nif not name then\nif type(premake.CurrentContainer) == \"project\" then\nreturn premake.CurrentContainer.solution\nelse\nreturn premake.CurrentContainer\nend\nend\npremake.CurrentContainer = premake.solution.get(name)\nif (not premake.CurrentContainer) then\npremake.CurrentContainer = premake.solution.new(name)\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction group(name)\nif not name then\nreturn premake.CurrentGroup\nend\npremake.CurrentGroup = name\nreturn premake.Curren"
"tGroup\nend\nfunction newaction(a)\npremake.action.add(a)\nend\nfunction newoption(opt)\npremake.option.add(opt)\nend\n",
"and value then\nif type(value) ~= \"string\" then\nerror(\"string value expected\", 3)\nend\nend\nlocal container, err = premake.getobject(scope)\nif (not container) then\nerror(err, 3)\nend\nif kind == \"string\" then\nreturn premake.setstring(scope, name, value, allowed)\nelseif kind == \"path\" then\nif value then value = path.getabsolute(value) end\nreturn premake.setstring(scope, name, value)\nelseif kind == \"list\" then\nreturn premake.setarray(container, name, value, allowed)\nelseif kind == \"dirlist\" then\nreturn premake.setdirarray(container, name, value)\nelseif kind == \"filelist\" or kind == \"absolutefilelist\" then\nreturn premake.setfilearray(container, name, value)\nelseif kind == \"keyvalue\" or kind == \"keypath\" then\nreturn premake.setkeyvalue(scope, name, value)\nend\nend\nfor name, info in pairs(premake.fields) do\n_G[name] = function(value)\nreturn accessor(name, value)\nend\nif info.kind == \"list\"\nor info.kind == \"dirlist\"\nor info.kind == \"filelist\"\nor info.kind == \"absolu"
"tefilelist\"\nthen\nif name ~= \"removefiles\"\nand name ~= \"files\" then\n_G[\"remove\"..name] = function(value)\npremake.remove(name, value)\nend\nend\nend\nend\nfunction configuration(terms)\nif not terms then\nreturn premake.CurrentConfiguration\nend\nlocal container, err = premake.getobject(\"container\")\nif (not container) then\nerror(err, 2)\nend\nlocal cfg = { }\ncfg.terms = table.flatten({terms})\ntable.insert(container.blocks, cfg)\npremake.CurrentConfiguration = cfg\ncfg.keywords = { }\nfor _, word in ipairs(cfg.terms) do\ntable.insert(cfg.keywords, path.wildcards(word):lower())\nend\nfor name, field in pairs(premake.fields) do\nif (field.kind ~= \"string\" and field.kind ~= \"path\") then\ncfg[name] = { }\nend\nend\nreturn cfg\nend\nlocal function creategroup(name, sln, parent, inpath)\nlocal group = {}\nsetmetatable(group, {\n__type = \"group\"\n})\ntable.insert(sln.groups, group)\nsln.groups[inpath] = group\ngroup.solution = sln\ngroup.name = name\ngroup.uuid = os.uuid(group.name)\ngroup.paren"
"t = parent\nreturn group\nend\nlocal function creategroupsfrompath(inpath, sln)\nif inpath == nil then return nil end\ninpath = path.translate(inpath, \"/\")\nlocal groups = string.explode(inpath, \"/\")\nlocal curpath = \"\"\nlocal lastgroup = nil\nfor i, v in ipairs(groups) do\ncurpath = curpath .. \"/\" .. v:lower()\nlocal group = sln.groups[curpath]\nif group == nil then\ngroup = creategroup(v, sln, lastgroup, curpath)\nend\nlastgroup = group\nend\nreturn lastgroup\nend\nlocal function createproject(name, sln, isUsage)\nlocal prj = {}\nsetmetatable(prj, {\n__type = \"project\",\n})\ntable.insert(sln.projects, prj)\nif(isUsage) then\nif(sln.projects[name]) then\nsln.projects[name].usageProj = prj;\nelse\nsln.projects[name] = prj\nend\nelse\nif(sln.projects[name]) then\nprj.usageProj = sln.projects[name];\nend\nsln.projects[name] = prj\nend\nlocal group = creategroupsfrompath(premake.CurrentGroup, sln)\nprj.solution = sln\nprj.name = name\nprj.basedir = os.getcwd()\nprj.uuid "
"= os.uuid(prj.name)\nprj.blocks = { }\nprj.usage = isUsage\nprj.group = group\nreturn prj;\nend\nfunction usage(name)\nif (not name) then\nif(type(premake.CurrentContainer) ~= \"project\") then return nil end\nif(not premake.CurrentContainer.usage) then return nil end\nreturn premake.CurrentContainer\nend\nlocal sln\nif (type(premake.CurrentContainer) == \"project\") then\nsln = premake.CurrentContainer.solution\nelse\nsln = premake.CurrentContainer\nend\nif (type(sln) ~= \"solution\") then\nerror(\"no active solution\", 2)\nend\nif((not sln.projects[name]) or\n((not sln.projects[name].usage) and (not sln.projects[name].usageProj))) then\npremake.CurrentContainer = createproject(name, sln, true)\nelse\npremake.CurrentContainer = iff(sln.projects[name].usage,\nsln.projects[name], sln.projects[name].usageProj)\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction project(name)\nif (not name) then\nif(type(premake.CurrentContainer) ~= \"project\") then return nil end\ni"
"f(premake.CurrentContainer.usage) then return nil end\nreturn premake.CurrentContainer\nend\nlocal sln\nif (type(premake.CurrentContainer) == \"project\") then\nsln = premake.CurrentContainer.solution\nelse\nsln = premake.CurrentContainer\nend\nif (type(sln) ~= \"solution\") then\nerror(\"no active solution\", 2)\nend\nif((not sln.projects[name]) or sln.projects[name].usage) then\npremake.CurrentContainer = createproject(name, sln)\nelse\npremake.CurrentContainer = sln.projects[name];\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction solution(name)\nif not name then\nif type(premake.CurrentContainer) == \"project\" then\nreturn premake.CurrentContainer.solution\nelse\nreturn premake.CurrentContainer\nend\nend\npremake.CurrentContainer = premake.solution.get(name)\nif (not premake.CurrentContainer) then\npremake.CurrentContainer = premake.solution.new(name)\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction group(name)\nif not name then\nreturn premake.CurrentGroup\nen"
"d\npremake.CurrentGroup = name\nreturn premake.CurrentGroup\nend\nfunction newaction(a)\npremake.action.add(a)\nend\nfunction newoption(opt)\npremake.option.add(opt)\nend\n",
/* base/cmdline.lua */
"newoption \n{\ntrigger = \"cc\",\nvalue = \"VALUE\",\ndescription = \"Choose a C/C++ compiler set\",\nallowed = {\n{ \"gcc\", \"GNU GCC (gcc/g++)\" },\n{ \"ow\", \"OpenWatcom\" },\n}\n}\nnewoption\n{\ntrigger = \"dotnet\",\nvalue = \"VALUE\",\ndescription = \"Choose a .NET compiler set\",\nallowed = {\n{ \"msnet\", \"Microsoft .NET (csc)\" },\n{ \"mono\", \"Novell Mono (mcs)\" },\n{ \"pnet\", \"Portable.NET (cscc)\" },\n}\n}\nnewoption\n{\ntrigger = \"file\",\nvalue = \"FILE\",\ndescription = \"Read FILE as a Premake script; default is 'premake4.lua'\"\n}\nnewoption\n{\ntrigger = \"help\",\ndescription = \"Display this information\"\n}\nnewoption\n{\ntrigger = \"os\",\nvalue = \"VALUE\",\ndescription = \"Generate files for a different operating system\",\nallowed = {\n{ \"bsd\", \"OpenBSD, NetBSD, or FreeBSD\" },\n{ \"linux\", \"Linux\" },\n{ \"macosx\", \"Apple Mac OS X\" },\n{ \"windows\", \"Microsoft Windows\" },\n}\n}\nnewoption\n{"
@ -108,7 +108,7 @@ const char* builtin_scripts[] = {
" 1\n end\n end\n return tableAppearances\nend\nlocal function parse_filter(filter)\n if type(filter) == 'function' then return filter end\n -- not a function, so it must be a table or table-like\n filter = type(filter) == 'table' and filter or {filter}\n local dictionary = {}\n for _,v in pairs(filter) do dictionary[v] = true end\n return function(x) return dictionary[x] end\nend\nlocal function makePath(path, key)\n local newPath, len = {}, #path\n for i=1, len do newPath[i] = path[i] end\n newPath[len+1] = key\n return newPath\nend\nfunction inspect(rootObject, options)\n options = options or {}\n local depth = options.depth or math.huge\n local filter = parse_filter(options.filter or {})\n local tableAppearances = countTableAppearances(rootObject)\n local buffer = {}\n local maxIds = setmetatable({}, maxIdsMetaTable)\n local ids = setmetatable({}, idsMetaTable)\n local level = 0\n local blen = 0 -- buffer length\n local function puts(...)\n local args = {...}\n "
"for i=1, #args do\n blen = blen + 1\n buffer[blen] = tostring(args[i])\n end\n end\n local function down(f)\n level = level + 1\n f()\n level = level - 1\n end\n local function tabify()\n puts(\"\\n\", string.rep(\" \", level))\n end\n local function commaControl(needsComma)\n if needsComma then puts(',') end\n return true\n end\n local function alreadyVisited(v)\n return ids[type(v)][v] ~= nil\n end\n local function getId(v)\n local tv = type(v)\n local id = ids[tv][v]\n if not id then\n id = maxIds[tv] + 1\n maxIds[tv] = id\n ids[tv][v] = id\n end\n return id\n end\n local putValue -- forward declaration that needs to go before putTable & putKey\n local function putKey(k)\n if isIdentifier(k) then return puts(k) end\n puts( \"[\" )\n putValue(k, {})\n puts(\"]\")\n end\n local function putTable(t, path)\n if alreadyVisited(t) then\n puts('<table ', getId(t), '>')\n elseif level >= depth then\n "
"puts('{...}')\n else\n if tableAppearances[t] > 1 then puts('<', getId(t), '>') end\n local dictKeys = getDictionaryKeys(t)\n local length = #t\n local mt = getmetatable(t)\n local to_string_result = getToStringResultSafely(t, mt)\n puts('{')\n down(function()\n if to_string_result then\n puts(' -- ', escape(to_string_result))\n if length >= 1 then tabify() end -- tabify the array values\n end\n local needsComma = false\n for i=1, length do\n needsComma = commaControl(needsComma)\n puts(' ')\n putValue(t[i], makePath(path, i))\n end\n for _,k in ipairs(dictKeys) do\n needsComma = commaControl(needsComma)\n tabify()\n putKey(k)\n puts(' = ')\n putValue(t[k], makePath(path, k))\n end\n if mt then\n needsComma = commaControl(needsComma)\n tabify()\n puts('<metatable> = '"
")\n putValue(mt, makePath(path, '<metatable>'))\n end\n end)\n if #dictKeys > 0 or mt then -- dictionary table. Justify closing }\n tabify()\n elseif length > 0 then -- array tables have one extra space before closing }\n puts(' ')\n end\n puts('}')\n end\n end\n -- putvalue is forward-declared before putTable & putKey\n putValue = function(v, path)\n if filter(v, path) then\n puts('<filtered>')\n else\n local tv = type(v)\n if tv == 'string' then\n puts(smartQuote(escape(v)))\n elseif tv == 'number' or tv == 'boolean' or tv == 'nil' then\n puts(tostring(v))\n elseif tv == 'table' then\n putTable(v, path)\n else\n puts('<',tv,' ',getId(v),'>')\n end\n end\n end\n putValue(rootObject, {})\n return table.concat(buffer)\nend\nfunction printtable(name, table)\nprint(\"--- \" .. name)\nprint(inspect(table))\nprint(\"---\")\nend\n",
")\n putValue(mt, makePath(path, '<metatable>'))\n end\n end)\n if #dictKeys > 0 or mt then -- dictionary table. Justify closing }\n tabify()\n elseif length > 0 then -- array tables have one extra space before closing }\n puts(' ')\n end\n puts('}')\n end\n end\n -- putvalue is forward-declared before putTable & putKey\n putValue = function(v, path)\n if filter(v, path) then\n puts('<filtered>')\n else\n local tv = type(v)\n if tv == 'string' then\n puts(smartQuote(escape(v)))\n elseif tv == 'number' or tv == 'boolean' or tv == 'nil' then\n puts(tostring(v))\n elseif tv == 'table' then\n putTable(v, path)\n else\n puts('<',tv,' ',getId(v),'>')\n end\n end\n end\n putValue(rootObject, {})\n return table.concat(buffer)\nend\nfunction printtable(name, table)\nprint(\"table: \", name, inspect(table), \"\\n\")\nend\nfunction printstack()\nprint(debug.traceback(), \"\\n\")\nend\n",
/* tools/dotnet.lua */
"premake.dotnet = { }\npremake.dotnet.namestyle = \"windows\"\nlocal flags =\n{\nFatalWarning = \"/warnaserror\",\nOptimize = \"/optimize\",\nOptimizeSize = \"/optimize\",\nOptimizeSpeed = \"/optimize\",\nSymbols = \"/debug\",\nUnsafe = \"/unsafe\"\n}\nfunction premake.dotnet.getbuildaction(fcfg)\nlocal ext = path.getextension(fcfg.name):lower()\nif fcfg.buildaction == \"Compile\" or ext == \".cs\" then\nreturn \"Compile\"\nelseif fcfg.buildaction == \"Embed\" or ext == \".resx\" then\nreturn \"EmbeddedResource\"\nelseif fcfg.buildaction == \"Copy\" or ext == \".asax\" or ext == \".aspx\" then\nreturn \"Content\"\nelse\nreturn \"None\"\nend\nend\nfunction premake.dotnet.getcompilervar(cfg)\nif (_OPTIONS.dotnet == \"msnet\") then\nreturn \"csc\"\nelseif (_OPTIONS.dotnet == \"mono\") then\nif (cfg.framework <= \"1.1\") then\nreturn \"mcs\"\nelseif (cfg.framework >= \"4.0\") then\nreturn \"dmcs\"\nelse \nreturn \"gmcs\"\nend\nelse\nreturn \"cscc\"\nend\nend\nfunction premake.dotnet.getfla"
@ -180,16 +180,16 @@ const char* builtin_scripts[] = {
/* actions/make/make_cpp.lua */
"premake.make.cpp = { }\npremake.make.override = { }\nlocal cpp = premake.make.cpp\nlocal make = premake.make\nfunction premake.make_cpp(prj)\nlocal cc = premake.gettool(prj)\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\npremake.gmake_cpp_header(prj, cc, platforms)\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\npremake.gmake_cpp_config(prj, cfg, cc)\nend\nend\nlocal objdirs = {}\nfor _, file in ipairs(prj.files) do\nif path.iscppfile(file) then\nobjdirs[_MAKE.esc(path.getdirectory(path.trimdots(file)))] = 1\nend\nend\n_p('OBJDIRS := \\\\')\n_p('\\t$(OBJDIR) \\\\')\nfor dir, _ in pairs(objdirs) do\n_p('\\t$(OBJDIR)/%s \\\\', dir)\nend\n_p('')\n_p('RESOURCES := \\\\')\nfor _, file in ipairs(prj.files) do\nif path.isresourcefile(file) then\n_p('\\t$(OBJDIR)/%s.res \\\\', _MAKE.esc(path.getbasename(file)))\nend\nend\n_p('')\n_p('.PHONY: clean prebuild prelink')\n_p('')\nif os.is(\"MacOSX\") and prj.kind == \"WindowedApp\" then\n_p('al"
"l: $(TARGETDIR) $(OBJDIRS) prebuild prelink $(TARGET) $(dir $(TARGETDIR))PkgInfo $(dir $(TARGETDIR))Info.plist')\nelse\n_p('all: $(TARGETDIR) $(OBJDIRS) prebuild prelink $(TARGET)')\nend\n_p('\\t@:')\n_p('')\nif (prj.kind == \"StaticLib\" and prj.options.ArchiveSplit) then\n_p('define max_args')\n_p('\\t$(eval _args:=)')\n_p('\\t$(foreach obj,$3,$(eval _args+=$(obj))$(if $(word $2,$(_args)),$1$(_args)$(EOL)$(eval _args:=)))')\n_p('\\t$(if $(_args),$1$(_args))')\n_p('endef')\n_p('')\n_p('define EOL')\n_p('')\n_p('')\n_p('endef')\n_p('')\nend\n_p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES)')\nif prj.kind == \"StaticLib\" then\nif prj.msgarchiving then\n_p('\\t@echo ' .. prj.msgarchiving)\nelse\n_p('\\t@echo Archiving %s', prj.name)\nend\nif (not prj.archivesplit_size) then \nprj.archivesplit_size=200\nend\nif (not prj.options.ArchiveSplit) then\n_p('\\t$(SILENT) $(LINKCMD) $(OBJECTS)')\nelse\n_p('\\t$(call RM,$(TARGET))')\n_p('\\t@$(call max_args,$(LINKCMD),'.. prj.archivesplit_size ..',$(OBJECTS))')\n_"
"p('\\t$(SILENT) $(LINKCMD_NDX)')\nend\nelse\nif prj.msglinking then\n_p('\\t@echo ' .. prj.msglinking)\nelse\n_p('\\t@echo Linking %s', prj.name)\nend\n_p('\\t$(SILENT) $(LINKCMD)')\nend\n_p('\\t$(POSTBUILDCMDS)')\n_p('')\n_p('$(TARGETDIR):')\npremake.make_mkdirrule(\"$(TARGETDIR)\")\n_p('$(OBJDIRS):')\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCreatingMessage\")) then\n_p('\\t@echo Creating $(OBJDIR)')\nend\n_p('\\t-$(call MKDIR,$@)')\n_p('')\nif os.is(\"MacOSX\") and prj.kind == \"WindowedApp\" then\n_p('$(dir $(TARGETDIR))PkgInfo:')\n_p('$(dir $(TARGETDIR))Info.plist:')\n_p('')\nend\n_p('clean:')\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCleaningMessage\")) then\n_p('\\t@echo Cleaning %s', prj.name)\nend\n_p('ifeq (posix,$(SHELLTYPE))')\n_p('\\t$(SILENT) rm -f $(TARGET)')\n_p('\\t$(SILENT) rm -rf $(OBJDIR)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGET)) del $(subst /,\\\\\\\\,$(TARGET))')\n"
"_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\\\\\,$(OBJDIR))')\n_p('endif')\n_p('')\n_p('prebuild:')\n_p('\\t$(PREBUILDCMDS)')\n_p('')\n_p('prelink:')\n_p('\\t$(PRELINKCMDS)')\n_p('')\ncpp.pchrules(prj)\ncpp.fileRules(prj)\n_p('-include $(OBJECTS:%%.o=%%.d)')\n_p('ifneq (,$(PCH))')\n_p(' -include $(OBJDIR)/$(notdir $(PCH)).d')\n_p('endif')\nend\nfunction premake.gmake_cpp_header(prj, cc, platforms)\n_p('# %s project makefile autogenerated by GENie', premake.action.current().shortname)\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(premake.getconfigname(prj.solution.configurations[1], platforms[1], true)))\n_p('endif')\n_p('')\n_p('ifndef verbose')\n_p(' SILENT = @')\n_p('endif')\n_p('')\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPEC))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('')\n_p('ifeq (posix,$(SHELLTYPE))')\n_p(' MKDIR = $(SILENT) mkdir -p \"$(1)\"')\n_p(' COP"
"Y = $(SILENT) cp -fR \"$(1)\" \"$(2)\"')\n_p(' RM= $(SILENT) rm -f \"$(1)\"')\n_p('else')\n_p(' MKDIR = $(SILENT) mkdir \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p(' COPY = $(SILENT) copy /Y \"$(subst /,\\\\\\\\,$(1))\" \"$(subst /,\\\\\\\\,$(2))\"')\n_p(' RM = $(SILENT) del /F \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p('endif')\n_p('')\n_p('CC = %s', cc.cc)\n_p('CXX = %s', cc.cxx)\n_p('AR = %s', cc.ar)\n_p('')\n_p('ifndef RESCOMP')\n_p(' ifdef WINDRES')\n_p(' RESCOMP = $(WINDRES)')\n_p(' else')\n_p(' RESCOMP = windres')\n_p(' endif')\n_p('endif')\n_p('')\nend\nfunction premake.gmake_cpp_config(prj, cfg, cc)\n_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))\ncpp.platformtools(cfg, cc)\n_p(' ' .. (table.contains(premake.make.override,\"OBJDIR\") and \"override \" or \"\") .. 'OBJDIR = %s', _MAKE.esc(cfg.objectsdir))\n_p(' ' .. (table.contains(premake.make.override,\"TARGETDIR\") and \"override \" or \"\") .. 'TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory)"
")\n_p(' ' .. (table.contains(premake.make.override,\"TARGET\") and \"override \" or \"\") .. 'TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))\n_p(' DEFINES +=%s', make.list(cc.getdefines(cfg.defines)))\n_p(' INCLUDES +=%s', make.list(cc.getincludedirs(cfg.includedirs)))\ncpp.pchconfig(cfg)\ncpp.flags(cfg, cc)\ncpp.linker(prj, cfg, cc)\n_p(' OBJECTS := \\\\')\nfor _, file in ipairs(prj.files) do\nif path.iscppfile(file) then\nlocal excluded = false\nfor _, exclude in ipairs(cfg.excludes) do\nexcluded = (exclude == file)\nif (excluded) then break end\nend\nif excluded == false then\n_p('\\t$(OBJDIR)/%s.o \\\\'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n)\nend\nend\nend\n_p('')\n_p(' define PREBUILDCMDS')\nif #cfg.prebuildcommands > 0 then\n_p('\\t@echo Running pre-build commands')\n_p('\\t%s', table.implode(cfg.prebuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define PRELINKCMDS')\nif #cfg.prelinkcommands > 0 then\n_p('\\t@echo Running pre-link commands')\n_"
"p('\\t%s', table.implode(cfg.prelinkcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define POSTBUILDCMDS')\nif #cfg.postbuildcommands > 0 then\n_p('\\t@echo Running post-build commands')\n_p('\\t%s', table.implode(cfg.postbuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\nmake.settings(cfg, cc)\n_p('endif')\n_p('')\nend\nfunction cpp.platformtools(cfg, cc)\nlocal platform = cc.platforms[cfg.platform]\nif platform.cc then\n_p(' CC = %s', platform.cc)\nend\nif platform.cxx then\n_p(' CXX = %s', platform.cxx)\nend\nif platform.ar then\n_p(' AR = %s', platform.ar)\nend\nend\nfunction cpp.flags(cfg, cc)\nif cfg.pchheader and not cfg.flags.NoPCH then\n_p(' FORCE_INCLUDE += -include $(OBJDIR)/$(notdir $(PCH))')\nend\nif #cfg.forcedincludes > 0 then\n_p(' FORCE_INCLUDE += -include %s'\n,premake.esc(table.concat(cfg.forcedincludes, \";\")))\nend\n_p(' ALL_CPPFLAGS += $(CPPFLAGS) %s $(DEFINES) $(INCLUDES)', table.concat(cc.getcppflags(cfg), \" \"))\n_p(' ALL_CFLAGS "
" += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_c)))\n_p(' ALL_CXXFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_cpp)))\n_p(' ALL_OBJCFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_objc)))\n_p(' ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)%s',\n make.list(table.join(cc.getdefines(cfg.resdefines),\n cc.getincludedirs(cfg.resincludedirs), cfg.resoptions)))\nend\nfunction cpp.linker(prj, cfg, cc)\n_p(' ALL_LDFLAGS += $(LDFLAGS)%s', make.list(table.join(cc.getlibdirflags(cfg), cc.getldflags(cfg), cfg.linkoptions)))\n_p(' LDDEPS +=%s', make.list(_MAKE.esc(premake.getlinks(cfg, \"siblings\", \"fullpath\"))))\n_p(' LIBS += $(LDDEPS)%s', make.list(cc.getlinkflags(cfg)))\nif c"
"fg.kind == \"StaticLib\" then\nif cfg.platform:startswith(\"Universal\") then\n_p(' LINKCMD = libtool -o $(TARGET)')\nelse\nif (not prj.options.ArchiveSplit) then\nif cc.llvm then\n_p(' LINKCMD = $(AR) rcs $(TARGET)')\nelse\n_p(' LINKCMD = $(AR) -rcs $(TARGET)')\nend\nelse\nif cc.llvm then\n_p(' LINKCMD = $(AR) qc $(TARGET)')\n_p(' LINKCMD_NDX= $(AR) cs $(TARGET)')\nelse\n_p(' LINKCMD = $(AR) -qc $(TARGET)')\n_p(' LINKCMD_NDX= $(AR) -cs $(TARGET)')\nend\nend\nend\nelse\nlocal tool = iif(cfg.language == \"C\", \"CC\", \"CXX\")\n_p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)', tool)\nend\nend\nfunction cpp.pchconfig(cfg)\nif not cfg.pchheader or cfg.flags.NoPCH then\nreturn\nend\nlocal pch = cfg.pchheader\nfor _, incdir in ipairs(cfg.includedirs) do\nlocal abspath = path.getabsolute(path.join(cfg.project.location, incdir))\nlocal testname = path.join(abspath, pch)\nif os.isfile(testname) then\npch = path.getrelative(cfg.location, testname)\nbrea"
"k\nend\nend\n_p(' PCH = %s', _MAKE.esc(pch))\n_p(' GCH = $(OBJDIR)/$(notdir $(PCH)).gch')\nend\nfunction cpp.pchrules(prj)\n_p('ifneq (,$(PCH))')\n_p('$(GCH): $(PCH)')\n_p('\\t@echo $(notdir $<)')\nlocal cmd = iif(prj.language == \"C\", \"$(CC) -x c-header $(ALL_CFLAGS)\", \"$(CXX) -x c++-header $(ALL_CXXFLAGS)\")\n_p('\\t$(SILENT) %s -MMD -MP $(DEFINES) $(INCLUDES) -o \"$@\" -MF \"$(@:%%.gch=%%.d)\" -c \"$<\"', cmd)\n_p('endif')\n_p('')\nend\nfunction cpp.fileRules(prj)\nfor _, file in ipairs(prj.files or {}) do\nif path.iscppfile(file) then\n_p('$(OBJDIR)/%s.o: %s'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, _MAKE.esc(file)\n)\nif (path.isobjcfile(file) and prj.msgcompile_objc) then\n_p('\\t@echo ' .. prj.msgcompile_objc)\nelseif prj.msgcompile then\n_p('\\t@echo ' .. prj.msgcompile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\nif (path.isobjcfile(file)) then\n_p('\\t$(SILENT) $(CXX) $(ALL_OBJCFLAGS) $(FORCE_INCLUDE) -o \"$@\" -MF $(@:%%.o=%%.d) -c \"$<\"')\nelse\ncpp.buildcommand(path.i"
"scfile(file) and not prj.options.ForceCPP, \"o\")\nend\n_p('')\nelseif (path.getextension(file) == \".rc\") then\n_p('$(OBJDIR)/%s.res: %s', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file))\nif prj.msgresource then\n_p('\\t@echo ' .. prj.msgresource)\nelse\n_p('\\t@echo $(notdir $<)')\nend\n_p('\\t$(SILENT) $(RESCOMP) $< -O coff -o \"$@\" $(ALL_RESFLAGS)')\n_p('')\nend\nend\nend\nfunction cpp.buildcommand(iscfile, objext)\nlocal flags = iif(iscfile, '$(CC) $(ALL_CFLAGS)', '$(CXX) $(ALL_CXXFLAGS)')\n_p('\\t$(SILENT) %s $(FORCE_INCLUDE) -o \"$@\" -MF $(@:%%.%s=%%.d) -c \"$<\"', flags, objext)\nend\n",
"l: $(TARGETDIR) $(OBJDIRS) prebuild prelink $(TARGET) $(dir $(TARGETDIR))PkgInfo $(dir $(TARGETDIR))Info.plist')\nelse\n_p('all: $(TARGETDIR) $(OBJDIRS) prebuild prelink $(TARGET)')\nend\n_p('\\t@:')\n_p('')\nif (prj.kind == \"StaticLib\" and prj.options.ArchiveSplit) then\n_p('define max_args')\n_p('\\t$(eval _args:=)')\n_p('\\t$(foreach obj,$3,$(eval _args+=$(obj))$(if $(word $2,$(_args)),$1$(_args)$(EOL)$(eval _args:=)))')\n_p('\\t$(if $(_args),$1$(_args))')\n_p('endef')\n_p('')\n_p('define EOL')\n_p('')\n_p('')\n_p('endef')\n_p('')\nend\n_p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES)')\nif prj.kind == \"StaticLib\" then\nif prj.msgarchiving then\n_p('\\t@echo ' .. prj.msgarchiving)\nelse\n_p('\\t@echo Archiving %s', prj.name)\nend\nif (not prj.archivesplit_size) then\nprj.archivesplit_size=200\nend\nif (not prj.options.ArchiveSplit) then\n_p('\\t$(SILENT) $(LINKCMD) $(OBJECTS)')\nelse\n_p('\\t$(call RM,$(TARGET))')\n_p('\\t@$(call max_args,$(LINKCMD),'.. prj.archivesplit_size ..',$(OBJECTS))')\n_p"
"('\\t$(SILENT) $(LINKCMD_NDX)')\nend\nelse\nif prj.msglinking then\n_p('\\t@echo ' .. prj.msglinking)\nelse\n_p('\\t@echo Linking %s', prj.name)\nend\n_p('\\t$(SILENT) $(LINKCMD)')\nend\n_p('\\t$(POSTBUILDCMDS)')\n_p('')\n_p('$(TARGETDIR):')\npremake.make_mkdirrule(\"$(TARGETDIR)\")\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCreatingMessage\")) then\n_p('objdirmessage:')\n_p('\\t@echo Creating $(OBJDIR)')\n_p('')\nend\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCreatingMessage\")) then\n_p('$(OBJDIRS): objdirmessage')\nelse\n_p('$(OBJDIRS):')\nend\n_p('\\t-$(call MKDIR,$@)')\n_p('')\nif os.is(\"MacOSX\") and prj.kind == \"WindowedApp\" then\n_p('$(dir $(TARGETDIR))PkgInfo:')\n_p('$(dir $(TARGETDIR))Info.plist:')\n_p('')\nend\n_p('clean:')\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCleaningMessage\")) then\n_p('\\t@echo Cleaning %s', prj.name)\nend\n_p('ifeq (posix,$(SHELLT"
"YPE))')\n_p('\\t$(SILENT) rm -f $(TARGET)')\n_p('\\t$(SILENT) rm -rf $(OBJDIR)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGET)) del $(subst /,\\\\\\\\,$(TARGET))')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\\\\\,$(OBJDIR))')\n_p('endif')\n_p('')\n_p('prebuild:')\n_p('\\t$(PREBUILDCMDS)')\n_p('')\n_p('prelink:')\n_p('\\t$(PRELINKCMDS)')\n_p('')\ncpp.pchrules(prj)\ncpp.fileRules(prj)\n_p('-include $(OBJECTS:%%.o=%%.d)')\n_p('ifneq (,$(PCH))')\n_p(' -include $(OBJDIR)/$(notdir $(PCH)).d')\n_p('endif')\nend\nfunction premake.gmake_cpp_header(prj, cc, platforms)\n_p('# %s project makefile autogenerated by GENie', premake.action.current().shortname)\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(premake.getconfigname(prj.solution.configurations[1], platforms[1], true)))\n_p('endif')\n_p('')\n_p('ifndef verbose')\n_p(' SILENT = @')\n_p('endif')\n_p('')\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPEC))')\n_p(' SHELLTYPE := posix')\n_p('endi"
"f')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('')\n_p('ifeq (posix,$(SHELLTYPE))')\n_p(' MKDIR = $(SILENT) mkdir -p \"$(1)\"')\n_p(' COPY = $(SILENT) cp -fR \"$(1)\" \"$(2)\"')\n_p(' RM= $(SILENT) rm -f \"$(1)\"')\n_p('else')\n_p(' MKDIR = $(SILENT) mkdir \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p(' COPY = $(SILENT) copy /Y \"$(subst /,\\\\\\\\,$(1))\" \"$(subst /,\\\\\\\\,$(2))\"')\n_p(' RM = $(SILENT) del /F \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p('endif')\n_p('')\n_p('CC = %s', cc.cc)\n_p('CXX = %s', cc.cxx)\n_p('AR = %s', cc.ar)\n_p('')\n_p('ifndef RESCOMP')\n_p(' ifdef WINDRES')\n_p(' RESCOMP = $(WINDRES)')\n_p(' else')\n_p(' RESCOMP = windres')\n_p(' endif')\n_p('endif')\n_p('')\nend\nfunction premake.gmake_cpp_config(prj, cfg, cc)\n_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))\ncpp.platformtools(cfg, cc)\n_p(' ' .. (table.contains(premake.make.override,\"OBJDIR\") and \"override \" or \"\") .. 'OBJDIR "
" = %s', _MAKE.esc(cfg.objectsdir))\n_p(' ' .. (table.contains(premake.make.override,\"TARGETDIR\") and \"override \" or \"\") .. 'TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory))\n_p(' ' .. (table.contains(premake.make.override,\"TARGET\") and \"override \" or \"\") .. 'TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))\n_p(' DEFINES +=%s', make.list(cc.getdefines(cfg.defines)))\n_p(' INCLUDES +=%s', make.list(cc.getincludedirs(cfg.includedirs)))\ncpp.pchconfig(cfg)\ncpp.flags(cfg, cc)\ncpp.linker(prj, cfg, cc)\n_p(' OBJECTS := \\\\')\nfor _, file in ipairs(prj.files) do\nif path.iscppfile(file) then\nif not table.icontains(cfg.excludes, file) then\n_p('\\t$(OBJDIR)/%s.o \\\\'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n)\nend\nend\nend\n_p('')\n_p(' define PREBUILDCMDS')\nif #cfg.prebuildcommands > 0 then\n_p('\\t@echo Running pre-build commands')\n_p('\\t%s', table.implode(cfg.prebuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define PRELINKCMDS')"
"\nif #cfg.prelinkcommands > 0 then\n_p('\\t@echo Running pre-link commands')\n_p('\\t%s', table.implode(cfg.prelinkcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define POSTBUILDCMDS')\nif #cfg.postbuildcommands > 0 then\n_p('\\t@echo Running post-build commands')\n_p('\\t%s', table.implode(cfg.postbuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\nmake.settings(cfg, cc)\n_p('endif')\n_p('')\nend\nfunction cpp.platformtools(cfg, cc)\nlocal platform = cc.platforms[cfg.platform]\nif platform.cc then\n_p(' CC = %s', platform.cc)\nend\nif platform.cxx then\n_p(' CXX = %s', platform.cxx)\nend\nif platform.ar then\n_p(' AR = %s', platform.ar)\nend\nend\nfunction cpp.flags(cfg, cc)\nif cfg.pchheader and not cfg.flags.NoPCH then\n_p(' FORCE_INCLUDE += -include $(OBJDIR)/$(notdir $(PCH))')\nend\nif #cfg.forcedincludes > 0 then\n_p(' FORCE_INCLUDE += -include %s'\n,premake.esc(table.concat(cfg.forcedincludes, \";\")))\nend\n_p(' ALL_CPPFLAGS += $(CPPFLAGS) %s $(DEFI"
"NES) $(INCLUDES)', table.concat(cc.getcppflags(cfg), \" \"))\n_p(' ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_c)))\n_p(' ALL_CXXFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_cpp)))\n_p(' ALL_OBJCFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_objc)))\n_p(' ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)%s',\n make.list(table.join(cc.getdefines(cfg.resdefines),\n cc.getincludedirs(cfg.resincludedirs), cfg.resoptions)))\nend\nfunction cpp.linker(prj, cfg, cc)\n_p(' ALL_LDFLAGS += $(LDFLAGS)%s', make.list(table.join(cc.getlibdirflags(cfg), cc.getldflags(cfg), cfg.linkoptions)))\n_p(' LDDEPS +=%s', make.list(_MAKE.esc(premake.getlinks(cfg, \"siblings\", \"fullpath"
"\"))))\n_p(' LIBS += $(LDDEPS)%s', make.list(cc.getlinkflags(cfg)))\nif cfg.kind == \"StaticLib\" then\nif cfg.platform:startswith(\"Universal\") then\n_p(' LINKCMD = libtool -o $(TARGET)')\nelse\nif (not prj.options.ArchiveSplit) then\nif cc.llvm then\n_p(' LINKCMD = $(AR) rcs $(TARGET)')\nelse\n_p(' LINKCMD = $(AR) -rcs $(TARGET)')\nend\nelse\nif cc.llvm then\n_p(' LINKCMD = $(AR) qc $(TARGET)')\n_p(' LINKCMD_NDX= $(AR) cs $(TARGET)')\nelse\n_p(' LINKCMD = $(AR) -qc $(TARGET)')\n_p(' LINKCMD_NDX= $(AR) -cs $(TARGET)')\nend\nend\nend\nelse\nlocal tool = iif(cfg.language == \"C\", \"CC\", \"CXX\")\n_p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)', tool)\nend\nend\nfunction cpp.pchconfig(cfg)\nif not cfg.pchheader or cfg.flags.NoPCH then\nreturn\nend\nlocal pch = cfg.pchheader\nfor _, incdir in ipairs(cfg.includedirs) do\nlocal abspath = path.getabsolute(path.join(cfg.project.location, incdir))\nlocal testname = path.join(abspath, pch)\nif"
" os.isfile(testname) then\npch = path.getrelative(cfg.location, testname)\nbreak\nend\nend\n_p(' PCH = %s', _MAKE.esc(pch))\n_p(' GCH = $(OBJDIR)/$(notdir $(PCH)).gch')\nend\nfunction cpp.pchrules(prj)\n_p('ifneq (,$(PCH))')\n_p('$(GCH): $(PCH)')\n_p('\\t@echo $(notdir $<)')\nlocal cmd = iif(prj.language == \"C\", \"$(CC) -x c-header $(ALL_CFLAGS)\", \"$(CXX) -x c++-header $(ALL_CXXFLAGS)\")\n_p('\\t$(SILENT) %s -MMD -MP $(DEFINES) $(INCLUDES) -o \"$@\" -MF \"$(@:%%.gch=%%.d)\" -c \"$<\"', cmd)\n_p('endif')\n_p('')\nend\nfunction cpp.fileRules(prj)\nfor _, file in ipairs(prj.files or {}) do\nif path.iscppfile(file) then\n_p('$(OBJDIR)/%s.o: %s'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, _MAKE.esc(file)\n)\nif (path.isobjcfile(file) and prj.msgcompile_objc) then\n_p('\\t@echo ' .. prj.msgcompile_objc)\nelseif prj.msgcompile then\n_p('\\t@echo ' .. prj.msgcompile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\nif (path.isobjcfile(file)) then\n_p('\\t$(SILENT) $(CXX) $(ALL_OBJCFLAGS) $(FORCE_I"
"NCLUDE) -o \"$@\" -MF $(@:%%.o=%%.d) -c \"$<\"')\nelse\ncpp.buildcommand(path.iscfile(file) and not prj.options.ForceCPP, \"o\")\nend\n_p('')\nelseif (path.getextension(file) == \".rc\") then\n_p('$(OBJDIR)/%s.res: %s', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file))\nif prj.msgresource then\n_p('\\t@echo ' .. prj.msgresource)\nelse\n_p('\\t@echo $(notdir $<)')\nend\n_p('\\t$(SILENT) $(RESCOMP) $< -O coff -o \"$@\" $(ALL_RESFLAGS)')\n_p('')\nend\nend\nend\nfunction cpp.buildcommand(iscfile, objext)\nlocal flags = iif(iscfile, '$(CC) $(ALL_CFLAGS)', '$(CXX) $(ALL_CXXFLAGS)')\n_p('\\t$(SILENT) %s $(FORCE_INCLUDE) -o \"$@\" -MF $(@:%%.%s=%%.d) -c \"$<\"', flags, objext)\nend\n",
/* actions/make/make_csharp.lua */
"local function getresourcefilename(cfg, fname)\nif path.getextension(fname) == \".resx\" then\n local name = cfg.buildtarget.basename .. \".\"\n local dir = path.getdirectory(fname)\n if dir ~= \".\" then \nname = name .. path.translate(dir, \".\") .. \".\"\nend\nreturn \"$(OBJDIR)/\" .. _MAKE.esc(name .. path.getbasename(fname)) .. \".resources\"\nelse\nreturn fname\nend\nend\nfunction premake.make_csharp(prj)\nlocal csc = premake.dotnet\nlocal cfglibs = { }\nlocal cfgpairs = { }\nlocal anycfg\nfor cfg in premake.eachconfig(prj) do\nanycfg = cfg\ncfglibs[cfg] = premake.getlinks(cfg, \"siblings\", \"fullpath\")\ncfgpairs[cfg] = { }\nfor _, fname in ipairs(cfglibs[cfg]) do\nif path.getdirectory(fname) ~= cfg.buildtarget.directory then\ncfgpairs[cfg][\"$(TARGETDIR)/\" .. _MAKE.esc(path.getname(fname))] = _MAKE.esc(fname)\nend\nend\nend\nlocal sources = {}\nlocal embedded = { }\nlocal copypairs = { }\nfor fcfg in premake.project.eachfile(prj) do\nlocal action = csc.getbuildaction(fcfg)\nif action == \"Co"
@ -263,16 +263,15 @@ const char* builtin_scripts[] = {
"seFileName>'\n, path.getbasename(cfg.buildtarget.name))\nend\nif cfg.flags.NoFramePointer then\n_p(3,'<OmitFramePointers>true</OmitFramePointers>')\nend\ncompile_language(cfg)\nforcedinclude_files(3,cfg);\n_p(2,'</ClCompile>')\nend\nlocal function event_hooks(cfg)\nif #cfg.postbuildcommands> 0 then\n _p(2,'<PostBuildEvent>')\n_p(3,'<Command>%s</Command>',premake.esc(table.implode(cfg.postbuildcommands, \"\", \"\", \"\\r\\n\")))\n_p(2,'</PostBuildEvent>')\nend\nif #cfg.prebuildcommands> 0 then\n _p(2,'<PreBuildEvent>')\n_p(3,'<Command>%s</Command>',premake.esc(table.implode(cfg.prebuildcommands, \"\", \"\", \"\\r\\n\")))\n_p(2,'</PreBuildEvent>')\nend\nif #cfg.prelinkcommands> 0 then\n _p(2,'<PreLinkEvent>')\n_p(3,'<Command>%s</Command>',premake.esc(table.implode(cfg.prelinkcommands, \"\", \"\", \"\\r\\n\")))\n_p(2,'</PreLinkEvent>')\nend\nend\nlocal function additional_options(indent,cfg)\nif #cfg.linkoptions > 0 then\n_p(indent,'<AdditionalOptions>%s %%(AdditionalOptions)</AdditionalOptions>',\ntable"
".concat(premake.esc(cfg.linkoptions), \" \"))\nend\nend\nlocal function link_target_machine(index,cfg)\nlocal platforms = {x32 = 'MachineX86', x64 = 'MachineX64'}\nif platforms[cfg.platform] then\n_p(index,'<TargetMachine>%s</TargetMachine>', platforms[cfg.platform])\nend\nend\nlocal function item_def_lib(cfg)\n -- The Xbox360 project files are stored in another place in the project file.\nif cfg.kind == 'StaticLib' and cfg.platform ~= \"Xbox360\" then\n_p(1,'<Lib>')\n_p(2,'<OutputFile>$(OutDir)%s</OutputFile>',cfg.buildtarget.name)\nadditional_options(2,cfg)\nlink_target_machine(2,cfg)\n_p(1,'</Lib>')\nend\nend\nlocal function import_lib(cfg)\nif cfg.kind == \"SharedLib\" then\nlocal implibname = cfg.linktarget.fullpath\n_p(3,'<ImportLibrary>%s</ImportLibrary>',iif(cfg.flags.NoImportLib, cfg.objectsdir .. \"\\\\\" .. path.getname(implibname), implibname))\nend\nend\nfunction vc2010.link(cfg)\n_p(2,'<Link>')\n_p(3,'<SubSystem>%s</SubSystem>', iif(cfg.kind == \"ConsoleApp\", \"Console\", \"Windows\"))\n_p"
"(3,'<GenerateDebugInformation>%s</GenerateDebugInformation>', tostring(cfg.flags.Symbols ~= nil))\nif premake.config.isoptimizedbuild(cfg.flags) then\n_p(3,'<EnableCOMDATFolding>true</EnableCOMDATFolding>')\n_p(3,'<OptimizeReferences>true</OptimizeReferences>')\nend\nif cfg.kind ~= 'StaticLib' then\nvc2010.additionalDependencies(cfg)\n_p(3,'<OutputFile>$(OutDir)%s</OutputFile>', cfg.buildtarget.name)\nif #cfg.libdirs > 0 then\n_p(3,'<AdditionalLibraryDirectories>%s;%%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>',\npremake.esc(path.translate(table.concat(cfg.libdirs, ';'), '\\\\')))\nend\nif vc2010.config_type(cfg) == 'Application' and not cfg.flags.WinMain and not cfg.flags.Managed then\nif cfg.flags.Unicode then\n_p(3,'<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>')\nelse\n_p(3,'<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>')\nend\nend\nimport_lib(cfg)\nlocal deffile = premake.findfile(cfg, \".def\")\nif deffile then\n_p(3,'<ModuleDefinitionFile>%s</ModuleDefinitionFile>', deffil"
"e)\nend\nlink_target_machine(3,cfg)\nadditional_options(3,cfg)\nend\n_p(2,'</Link>')\nend\nfunction vc2010.additionalDependencies(cfg)\nlocal links = premake.getlinks(cfg, \"system\", \"fullpath\")\nif #links > 0 then\n_p(3,'<AdditionalDependencies>%s;%%(AdditionalDependencies)</AdditionalDependencies>',\ntable.concat(links, \";\"))\nend\nend\nlocal function item_definitions(prj)\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\n_p(1,'<ItemDefinitionGroup ' ..if_config_and_platform() ..'>'\n,premake.esc(cfginfo.name))\nvs10_clcompile(cfg)\nresource_compile(cfg)\nitem_def_lib(cfg)\nvc2010.link(cfg)\nevent_hooks(cfg)\n_p(1,'</ItemDefinitionGroup>')\nend\nend\nfunction exists(table, fine)\nfor _, value in ipairs(table) do\nif value == find then return true end\nend\nreturn false\nend\nfunction vc2010.getfilegroup(prj, group)\nlocal sortedfiles = prj.vc2010sortedfiles\nif not sortedfiles then\nsortedfiles = {\nClCompile = {},"
"\nClInclude = {},\nNone = {},\nResourceCompile = {},\n AppxManifest = {}\n}\nlocal foundAppxManifest = false\nfor file in premake.project.eachfile(prj) do\nif path.iscppfile(file.name) then\ntable.insert(sortedfiles.ClCompile, file)\nelseif path.iscppheader(file.name) then\nif not exists(prj.removefiles, file) then\ntable.insert(sortedfiles.ClInclude, file)\nend\nelseif path.isresourcefile(file.name) then\ntable.insert(sortedfiles.ResourceCompile, file)\nelse\n local ext = path.getextension(file.name):lower()\n if ext == \".appxmanifest\" then\nfoundAppxManifest = true\n table.insert(sortedfiles.AppxManifest, file)\n else\n table.insert(sortedfiles.None, file)\n end\nend\nend\nif vstudio.toolset == \"v120_wp81\" and prj.kind == \"WindowedApp\" and not foundAppxManifest then\nvstudio.needAppxManifest = true\nlocal fcfg = {}\nfcfg.name = prj.name .. \".appxmanifest\"\nfcfg.vpath = premake.project."
"getvpath(prj, fcfg.name)\ntable.insert(sortedfiles.AppxManifest, fcfg)\nend\nprj.vc2010sortedfiles = sortedfiles\nend\nreturn sortedfiles[group]\nend\nfunction vc2010.files(prj)\nvc2010.simplefilesgroup(prj, \"ClInclude\")\nvc2010.compilerfilesgroup(prj)\nvc2010.simplefilesgroup(prj, \"None\")\nvc2010.simplefilesgroup(prj, \"ResourceCompile\")\n vc2010.simplefilesgroup(prj, \"AppxManifest\")\nend\nfunction vc2010.simplefilesgroup(prj, section, subtype)\nlocal files = vc2010.getfilegroup(prj, section)\nif #files > 0 then\n_p(1,'<ItemGroup>')\nfor _, file in ipairs(files) do\n if subtype then\n _p(2,'<%s Include=\\\"%s\\\">', section, path.translate(file.name, \"\\\\\"))\n _p(3,'<SubType>%s</SubType>', subtype)\n _p(2,'</%s>', section)\n else\n _p(2,'<%s Include=\\\"%s\\\" />', section, path.translate(file.name, \"\\\\\"))\n end\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.compilerfilesgroup("
"prj)\nlocal configs = prj.solution.vstudio_configs\nlocal files = vc2010.getfilegroup(prj, \"ClCompile\")\nif #files > 0 then\nlocal config_mappings = {}\nfor _, cfginfo in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\nif cfg.pchheader and cfg.pchsource and not cfg.flags.NoPCH then\nconfig_mappings[cfginfo] = path.translate(cfg.pchsource, \"\\\\\")\nend\nend\n_p(1,'<ItemGroup>')\nfor _, file in ipairs(files) do\nlocal translatedpath = path.translate(file.name, \"\\\\\")\n_p(2, '<ClCompile Include=\\\"%s\\\">', translatedpath)\n_p(3, '<ObjectFileName>$(IntDir)%s.obj</ObjectFileName>'\n, premake.esc(path.translate(path.trimdots(path.removeext(file.name))))\n)\nfor _, cfginfo in ipairs(configs) do\nif config_mappings[cfginfo] and translatedpath == config_mappings[cfginfo] then\n_p(3,'<PrecompiledHeader '.. if_config_and_platform() .. '>Create</PrecompiledHeader>', premake.esc(cfginfo.name))\nconfig_mappings[cfginfo] = nil --only one source file per pch\nend"
"\nend\nlocal excluded = false\nfor _, exclude in ipairs(prj.excludes) do\nif exclude == file.name then\nfor _, vsconfig in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)\n_p(3, '<ExcludedFromBuild '\n.. if_config_and_platform()\n.. '>true</ExcludedFromBuild>'\n, premake.esc(vsconfig.name)\n)\nend\nexcluded = true\nbreak\nend\nend\nif not excluded then\nfor _, vsconfig in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)\nfor _, exclude in ipairs(cfg.excludes) do\nif exclude == file.name then\n_p(3, '<ExcludedFromBuild '\n.. if_config_and_platform()\n.. '>true</ExcludedFromBuild>'\n, premake.esc(vsconfig.name)\n)\nend\nend\nend\nend\n_p(2,'</ClCompile>')\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.header(targets)\nio.eol = \"\\r\\n\"\n_p('<?xml version=\"1.0\" encoding=\"utf-8\"?>')\nlocal t = \"\"\nif targets then\nt = ' DefaultTargets=\"' .. targets .. '\"'\nend\n_p('<Project%s ToolsVersion=\"4.0"
"\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">', t)\nend\nfunction premake.vs2010_vcxproj(prj)\nio.indent = \" \"\nvc2010.header(\"Build\")\nvs2010_config(prj)\nvs2010_globals(prj)\n_p(1,'<Import Project=\"$(VCTargetsPath)\\\\Microsoft.Cpp.Default.props\" />')\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\nvc2010.configurationPropertyGroup(cfg, cfginfo)\nend\n_p(1,'<Import Project=\"$(VCTargetsPath)\\\\Microsoft.Cpp.props\" />')\n_p(1,'<ImportGroup Label=\"ExtensionSettings\">')\n_p(1,'</ImportGroup>')\nimport_props(prj)\n_p(1,'<PropertyGroup Label=\"UserMacros\" />')\nvc2010.outputProperties(prj)\nitem_definitions(prj)\nvc2010.files(prj)\nvc2010.projectReferences(prj)\n_p(1,'<Import Project=\"$(VCTargetsPath)\\\\Microsoft.Cpp.targets\" />')\n_p(1,'<ImportGroup Label=\"ExtensionTargets\">')\n_p(1,'</ImportGroup>')\n_p('</Project>')\nend\nfunction vc2010.projectReferences(prj)\nlocal deps = premake.g"
"etdependencies(prj)\nif #deps > 0 then\n_p(1,'<ItemGroup>')\nfor _, dep in ipairs(deps) do\nlocal deppath = path.getrelative(prj.location, vstudio.projectfile(dep))\n_p(2,'<ProjectReference Include=\\\"%s\\\">', path.translate(deppath, \"\\\\\"))\n_p(3,'<Project>{%s}</Project>', dep.uuid)\nif vstudio.toolset == \"v120_wp81\" then\n_p(3,'<ReferenceOutputAssembly>false</ReferenceOutputAssembly>')\nend\n_p(2,'</ProjectReference>')\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.debugdir(cfg)\nif cfg.debugdir then\n_p(' <LocalDebuggerWorkingDirectory>%s</LocalDebuggerWorkingDirectory>', path.translate(cfg.debugdir, '\\\\'))\n_p(' <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>')\nend\nif cfg.debugargs then\n_p(' <LocalDebuggerCommandArguments>%s</LocalDebuggerCommandArguments>', table.concat(cfg.debugargs, \" \"))\nend\nend\nfunction vc2010.debugenvs(cfg)\nif cfg.debugenvs and #cfg.debugenvs > 0 then\n_p(2,'<LocalDebuggerEnvironment>%s%s</LocalDebuggerEnvironment>',table.concat(cfg.debugenvs, "
"\"\\n\")\n,iif(cfg.flags.DebugEnvsInherit,'\\n$(LocalDebuggerEnvironment)','')\n)\nif cfg.flags.DebugEnvsDontMerge then\n_p(2,'<LocalDebuggerMergeEnvironment>false</LocalDebuggerMergeEnvironment>')\nend\nend\nend\nfunction premake.vs2010_vcxproj_user(prj)\nio.indent = \" \"\nvc2010.header()\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\n_p(' <PropertyGroup '.. if_config_and_platform() ..'>', premake.esc(cfginfo.name))\nvc2010.debugdir(cfg)\nvc2010.debugenvs(cfg)\n_p(' </PropertyGroup>')\nend\n_p('</Project>')\nend\nfunction premake.vs2010_appxmanifest(prj)\nio.indent = \" \"\nio.eol = \"\\r\\n\"\n_p('<?xml version=\"1.0\" encoding=\"utf-8\"?>')\n_p('<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\" xmlns:m2=\"http://schemas.microsoft.com/appx/2013/manifest\" xmlns:m3=\"http://schemas.microsoft.com/appx/2014/manifest\" xmlns:mp=\"http://schemas.microsoft.com/appx/2014/phone/manifest\">')\n_p(1,'<Ide"
"ntity Name=\"' .. prj.uuid .. '\"')\n_p(2,'Publisher=\"CN=Unknown\"')\n_p(2,'Version=\"1.0.0.0\" />')\n_p(1,'<mp:PhoneIdentity PhoneProductId=\"' .. prj.uuid .. '\" PhonePublisherId=\"00000000-0000-0000-0000-000000000000\"/>')\n_p(1,'<Properties>')\n_p(2,'<DisplayName>' .. prj.name .. '</DisplayName>')\n_p(2,'<PublisherDisplayName>Unknown</PublisherDisplayName>')\n_p(2,'<Logo>EmptyLogo.png</Logo>')\n_p(1,'</Properties>')\n_p(1,'<Prerequisites>')\n_p(2,'<OSMinVersion>6.3.1</OSMinVersion>')\n_p(2,'<OSMaxVersionTested>6.3.1</OSMaxVersionTested>')\n_p(1,'</Prerequisites>')\n_p(1,'<Resources>')\n_p(2,'<Resource Language=\"x-generate\"/>')\n_p(1,'</Resources>')\n_p(1,'<Applications>')\n_p(2,'<Application Id=\"App\"')\n_p(3,'Executable=\"$targetnametoken$.exe\"')\n_p(3,'EntryPoint=\"App\">')\n_p(3,'<m3:VisualElements')\n_p(4,'DisplayName=\"Blah\"')\n_p(4,'Square150x150Logo=\"Assets\\\\Logo.png\"')\n_p(4,'Square44x44Logo=\"Assets\\\\SmallLogo.png\"')\n_p(4,'Description=\"Blah\"')\n_p(4,'ForegroundText=\"light\"')\n_p("
"4,'BackgroundColor=\"transparent\">')\n_p(3,'</m3:VisualElements>')\n_p(2,'</Application>')\n_p(1,'</Applications>')\n_p('</Package>')\nend\n",
"e)\nend\nlink_target_machine(3,cfg)\nadditional_options(3,cfg)\nend\n_p(2,'</Link>')\nend\nfunction vc2010.additionalDependencies(cfg)\nlocal links = premake.getlinks(cfg, \"system\", \"fullpath\")\nif #links > 0 then\n_p(3,'<AdditionalDependencies>%s;%%(AdditionalDependencies)</AdditionalDependencies>',\ntable.concat(links, \";\"))\nend\nend\nlocal function item_definitions(prj)\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\n_p(1,'<ItemDefinitionGroup ' ..if_config_and_platform() ..'>'\n,premake.esc(cfginfo.name))\nvs10_clcompile(cfg)\nresource_compile(cfg)\nitem_def_lib(cfg)\nvc2010.link(cfg)\nevent_hooks(cfg)\n_p(1,'</ItemDefinitionGroup>')\nend\nend\nfunction vc2010.getfilegroup(prj, group)\nlocal sortedfiles = prj.vc2010sortedfiles\nif not sortedfiles then\nsortedfiles = {\nClCompile = {},\nClInclude = {},\nNone = {},\nResourceCompile = {},\nAppxManifest = {}\n}\nlocal foundAppxManifest = false\nfor file in premak"
"e.project.eachfile(prj) do\nif path.iscppfile(file.name) then\ntable.insert(sortedfiles.ClCompile, file)\nelseif path.iscppheader(file.name) then\nif not table.icontains(prj.removefiles, file) then\ntable.insert(sortedfiles.ClInclude, file)\nend\nelseif path.isresourcefile(file.name) then\ntable.insert(sortedfiles.ResourceCompile, file)\nelse\nlocal ext = path.getextension(file.name):lower()\nif ext == \".appxmanifest\" then\nfoundAppxManifest = true\ntable.insert(sortedfiles.AppxManifest, file)\nelse\ntable.insert(sortedfiles.None, file)\nend\nend\nend\nif vstudio.toolset == \"v120_wp81\" and prj.kind == \"WindowedApp\" and not foundAppxManifest then\nvstudio.needAppxManifest = true\nlocal fcfg = {}\nfcfg.name = prj.name .. \".appxmanifest\"\nfcfg.vpath = premake.project.getvpath(prj, fcfg.name)\ntable.insert(sortedfiles.AppxManifest, fcfg)\nend\nprj.vc2010sortedfiles = sortedfiles\nend\nreturn sortedfiles[group]\nend\nfunction vc2010.files(prj)\nvc2010.simplefilesgroup(prj, \"ClInclude\")\nvc2010.compilerfil"
"esgroup(prj)\nvc2010.simplefilesgroup(prj, \"None\")\nvc2010.simplefilesgroup(prj, \"ResourceCompile\")\nvc2010.simplefilesgroup(prj, \"AppxManifest\")\nend\nfunction vc2010.simplefilesgroup(prj, section, subtype)\nlocal files = vc2010.getfilegroup(prj, section)\nif #files > 0 then\n_p(1,'<ItemGroup>')\nfor _, file in ipairs(files) do\nif subtype then\n_p(2,'<%s Include=\\\"%s\\\">', section, path.translate(file.name, \"\\\\\"))\n_p(3,'<SubType>%s</SubType>', subtype)\n_p(2,'</%s>', section)\nelse\n_p(2,'<%s Include=\\\"%s\\\" />', section, path.translate(file.name, \"\\\\\"))\nend\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.compilerfilesgroup(prj)\nlocal configs = prj.solution.vstudio_configs\nlocal files = vc2010.getfilegroup(prj, \"ClCompile\")\nif #files > 0 then\nlocal config_mappings = {}\nfor _, cfginfo in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\nif cfg.pchheader and cfg.pchsource and not cfg.flags.NoPCH then\nconfig_mappings[cfginfo"
"] = path.translate(cfg.pchsource, \"\\\\\")\nend\nend\n_p(1,'<ItemGroup>')\nfor _, file in ipairs(files) do\nlocal translatedpath = path.translate(file.name, \"\\\\\")\n_p(2, '<ClCompile Include=\\\"%s\\\">', translatedpath)\n_p(3, '<ObjectFileName>$(IntDir)%s.obj</ObjectFileName>'\n, premake.esc(path.translate(path.trimdots(path.removeext(file.name))))\n)\nfor _, cfginfo in ipairs(configs) do\nif config_mappings[cfginfo] and translatedpath == config_mappings[cfginfo] then\n_p(3,'<PrecompiledHeader '.. if_config_and_platform() .. '>Create</PrecompiledHeader>', premake.esc(cfginfo.name))\nconfig_mappings[cfginfo] = nil --only one source file per pch\nend\nend\nlocal excluded = table.icontains(prj.excludes, file.name)\nfor _, vsconfig in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)\nif excluded or table.icontains(cfg.excludes, file.name) then\n_p(3, '<ExcludedFromBuild '\n.. if_config_and_platform()\n.. '>true</ExcludedFromBuild>'\n, premake.esc(vsconfig.n"
"ame)\n)\nend\nend\n_p(2,'</ClCompile>')\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.header(targets)\nio.eol = \"\\r\\n\"\n_p('<?xml version=\"1.0\" encoding=\"utf-8\"?>')\nlocal t = \"\"\nif targets then\nt = ' DefaultTargets=\"' .. targets .. '\"'\nend\n_p('<Project%s ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">', t)\nend\nfunction premake.vs2010_vcxproj(prj)\nio.indent = \" \"\nvc2010.header(\"Build\")\nvs2010_config(prj)\nvs2010_globals(prj)\n_p(1,'<Import Project=\"$(VCTargetsPath)\\\\Microsoft.Cpp.Default.props\" />')\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\nvc2010.configurationPropertyGroup(cfg, cfginfo)\nend\n_p(1,'<Import Project=\"$(VCTargetsPath)\\\\Microsoft.Cpp.props\" />')\n_p(1,'<ImportGroup Label=\"ExtensionSettings\">')\n_p(1,'</ImportGroup>')\nimport_props(prj)\n_p(1,'<PropertyGroup Label=\"UserMacros\" />')\nvc2010.outputProperties(prj)\nitem_def"
"initions(prj)\nvc2010.files(prj)\nvc2010.projectReferences(prj)\n_p(1,'<Import Project=\"$(VCTargetsPath)\\\\Microsoft.Cpp.targets\" />')\n_p(1,'<ImportGroup Label=\"ExtensionTargets\">')\n_p(1,'</ImportGroup>')\n_p('</Project>')\nend\nfunction vc2010.projectReferences(prj)\nlocal deps = premake.getdependencies(prj)\nif #deps > 0 then\n_p(1,'<ItemGroup>')\nfor _, dep in ipairs(deps) do\nlocal deppath = path.getrelative(prj.location, vstudio.projectfile(dep))\n_p(2,'<ProjectReference Include=\\\"%s\\\">', path.translate(deppath, \"\\\\\"))\n_p(3,'<Project>{%s}</Project>', dep.uuid)\nif vstudio.toolset == \"v120_wp81\" then\n_p(3,'<ReferenceOutputAssembly>false</ReferenceOutputAssembly>')\nend\n_p(2,'</ProjectReference>')\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.debugdir(cfg)\nif cfg.debugdir then\n_p(' <LocalDebuggerWorkingDirectory>%s</LocalDebuggerWorkingDirectory>', path.translate(cfg.debugdir, '\\\\'))\n_p(' <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>')\nend\nif cfg.debugargs th"
"en\n_p(' <LocalDebuggerCommandArguments>%s</LocalDebuggerCommandArguments>', table.concat(cfg.debugargs, \" \"))\nend\nend\nfunction vc2010.debugenvs(cfg)\nif cfg.debugenvs and #cfg.debugenvs > 0 then\n_p(2,'<LocalDebuggerEnvironment>%s%s</LocalDebuggerEnvironment>',table.concat(cfg.debugenvs, \"\\n\")\n,iif(cfg.flags.DebugEnvsInherit,'\\n$(LocalDebuggerEnvironment)','')\n)\nif cfg.flags.DebugEnvsDontMerge then\n_p(2,'<LocalDebuggerMergeEnvironment>false</LocalDebuggerMergeEnvironment>')\nend\nend\nend\nfunction premake.vs2010_vcxproj_user(prj)\nio.indent = \" \"\nvc2010.header()\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\n_p(' <PropertyGroup '.. if_config_and_platform() ..'>', premake.esc(cfginfo.name))\nvc2010.debugdir(cfg)\nvc2010.debugenvs(cfg)\n_p(' </PropertyGroup>')\nend\n_p('</Project>')\nend\nfunction premake.vs2010_appxmanifest(prj)\nio.indent = \" \"\nio.eol = \"\\r\\n\"\n_p('<?xml version=\"1.0\" "
"encoding=\"utf-8\"?>')\n_p('<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\" xmlns:m2=\"http://schemas.microsoft.com/appx/2013/manifest\" xmlns:m3=\"http://schemas.microsoft.com/appx/2014/manifest\" xmlns:mp=\"http://schemas.microsoft.com/appx/2014/phone/manifest\">')\n_p(1,'<Identity Name=\"' .. prj.uuid .. '\"')\n_p(2,'Publisher=\"CN=Unknown\"')\n_p(2,'Version=\"1.0.0.0\" />')\n_p(1,'<mp:PhoneIdentity PhoneProductId=\"' .. prj.uuid .. '\" PhonePublisherId=\"00000000-0000-0000-0000-000000000000\"/>')\n_p(1,'<Properties>')\n_p(2,'<DisplayName>' .. prj.name .. '</DisplayName>')\n_p(2,'<PublisherDisplayName>Unknown</PublisherDisplayName>')\n_p(2,'<Logo>EmptyLogo.png</Logo>')\n_p(1,'</Properties>')\n_p(1,'<Prerequisites>')\n_p(2,'<OSMinVersion>6.3.1</OSMinVersion>')\n_p(2,'<OSMaxVersionTested>6.3.1</OSMaxVersionTested>')\n_p(1,'</Prerequisites>')\n_p(1,'<Resources>')\n_p(2,'<Resource Language=\"x-generate\"/>')\n_p(1,'</Resources>')\n_p(1,'<Applications>')\n_p(2,'<Application Id=\"App\"')\n_p(3,"
"'Executable=\"$targetnametoken$.exe\"')\n_p(3,'EntryPoint=\"App\">')\n_p(3,'<m3:VisualElements')\n_p(4,'DisplayName=\"Blah\"')\n_p(4,'Square150x150Logo=\"Assets\\\\Logo.png\"')\n_p(4,'Square44x44Logo=\"Assets\\\\SmallLogo.png\"')\n_p(4,'Description=\"Blah\"')\n_p(4,'ForegroundText=\"light\"')\n_p(4,'BackgroundColor=\"transparent\">')\n_p(3,'</m3:VisualElements>')\n_p(2,'</Application>')\n_p(1,'</Applications>')\n_p('</Package>')\nend\n",
/* actions/vstudio/vs2010_vcxproj_filters.lua */
"local vc2010 = premake.vstudio.vc2010\nlocal project = premake.project\nfunction vc2010.filteridgroup(prj)\nlocal filters = { }\nlocal filterfound = false\nfor file in project.eachfile(prj) do\nlocal folders = string.explode(file.vpath, \"/\", true)\nlocal path = \"\"\nfor i = 1, #folders - 1 do\nif not filterfound then\nfilterfound = true\n_p(1,'<ItemGroup>')\nend\npath = path .. folders[i]\nif not filters[path] then\nfilters[path] = true\n_p(2, '<Filter Include=\"%s\">', path)\n_p(3, '<UniqueIdentifier>{%s}</UniqueIdentifier>', os.uuid())\n_p(2, '</Filter>')\nend\npath = path .. \"\\\\\"\nend\nend\nif filterfound then\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.filefiltergroup(prj, section)\nlocal files = vc2010.getfilegroup(prj, section)\nif #files > 0 then\n_p(1,'<ItemGroup>')\nfor _, file in ipairs(files) do\nlocal filter\nif file.name ~= file.vpath then\nfilter = path.getdirectory(file.vpath)\nelse\nfilter = path.getdirectory(file.name)\nend\nif filter ~= \".\" then\n_p(2,'<%s Include=\\\"%s\\\">', "