Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer
Submodule .devcontainer added at 98355c
30 changes: 30 additions & 0 deletions .github/workflows/xpbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
workflow_dispatch:
jobs:
linux:
uses: externpro/externpro/.github/workflows/build-linux.yml@25.06
with:
cmake-workflow-preset: Linux
runon: ubuntu-latest
secrets: inherit
linux-arm64:
uses: externpro/externpro/.github/workflows/build-linux.yml@25.06
with:
cmake-workflow-preset: Linux
runon: ubuntu-24.04-arm
secrets: inherit
macos:
uses: externpro/externpro/.github/workflows/build-macos.yml@25.06
with:
cmake-workflow-preset: Darwin
secrets: inherit
windows:
uses: externpro/externpro/.github/workflows/build-windows.yml@25.06
with:
cmake-workflow-preset: Windows
secrets: inherit
20 changes: 20 additions & 0 deletions .github/workflows/xprelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release
on:
workflow_dispatch:
inputs:
workflow_run_url:
description: 'URL of the workflow run containing artifacts to upload (e.g., https://github.com/owner/repo/actions/runs/123456789)'
required: true
type: string
jobs:
# Upload build artifacts as release assets
release-from-build:
uses: externpro/externpro/.github/workflows/release-from-build.yml@25.06
with:
workflow_run_url: ${{ github.event.inputs.workflow_run_url }}
artifact_pattern: "*.tar.xz"
permissions:
contents: write
id-token: write
attestations: write
secrets: inherit
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ CMakeFiles/
*.vcxproj.user
.vs/
.vscode
# externpro
.env
_bld*/
docker-compose.override.yml
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "third_party/gtest"]
path = third_party/gtest
url = https://github.com/google/googletest.git
[submodule ".devcontainer"]
path = .devcontainer
url = https://github.com/externpro/externpro
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.10...3.31)

set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES .devcontainer/cmake/xproinc.cmake)
project(LuaBridge)

include(CMakeDependentOption)
include(GNUInstallDirs)
include(xpflags)

option(LUABRIDGE_CXX17 "Use C++17 standard if supported by compiler" OFF)

Expand Down Expand Up @@ -33,7 +36,6 @@ endif()
if(LUABRIDGE_TESTING)
set(gtest_force_shared_crt ON CACHE BOOL "Use /MD and /MDd" FORCE)
add_subdirectory(third_party/gtest EXCLUDE_FROM_ALL)
add_library(GTest::gtest ALIAS gtest)
enable_testing()
add_subdirectory(Tests)
endif()
Expand Down
8 changes: 8 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 8,
"include": [
".devcontainer/cmake/presets/xpLinuxNinja.json",
".devcontainer/cmake/presets/xpDarwinNinja.json",
".devcontainer/cmake/presets/xpWindowsVs2022.json"
]
}
19 changes: 19 additions & 0 deletions CMakePresetsBase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": 8,
"configurePresets": [
{
"name": "config-base",
"hidden": true,
"binaryDir": "${sourceDir}/_bld-${presetName}",
"cacheVariables": {
"XP_NAMESPACE": "xpro"
}
}
],
"buildPresets": [
{
"name": "build-base",
"hidden": true
}
]
}
62 changes: 34 additions & 28 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
set(LUABRIDGE_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/List.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/LuaBridge.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/Map.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/RefCountedObject.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/RefCountedPtr.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/UnorderedMap.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/Vector.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/Array.h
LuaBridge/List.h
LuaBridge/LuaBridge.h
LuaBridge/Map.h
LuaBridge/RefCountedObject.h
LuaBridge/RefCountedPtr.h
LuaBridge/UnorderedMap.h
LuaBridge/Vector.h
LuaBridge/Array.h
)

source_group("LuaBridge" FILES ${LUABRIDGE_HEADERS})

set(LUABRIDGE_DETAIL_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/CFunctions.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/ClassInfo.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/Config.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/Constructor.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/dump.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/FuncTraits.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/Iterator.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/LuaException.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/LuaHelpers.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/LuaRef.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/Namespace.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/Stack.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/TypeList.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/TypeTraits.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/Userdata.h
LuaBridge/detail/CFunctions.h
LuaBridge/detail/ClassInfo.h
LuaBridge/detail/Config.h
LuaBridge/detail/Constructor.h
LuaBridge/detail/dump.h
LuaBridge/detail/FuncTraits.h
LuaBridge/detail/Iterator.h
LuaBridge/detail/LuaException.h
LuaBridge/detail/LuaHelpers.h
LuaBridge/detail/LuaRef.h
LuaBridge/detail/Namespace.h
LuaBridge/detail/Stack.h
LuaBridge/detail/TypeList.h
LuaBridge/detail/TypeTraits.h
LuaBridge/detail/Userdata.h
)

source_group("LuaBridge\\detail" FILES ${LUABRIDGE_DETAIL_HEADERS})

add_library(LuaBridge INTERFACE)

target_sources(LuaBridge INTERFACE
${LUABRIDGE_HEADERS}
${LUABRIDGE_DETAIL_HEADERS}
target_include_directories(LuaBridge INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_include_directories(LuaBridge INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

if(LUABRIDGE_CXX17)
target_compile_definitions(LuaBridge INTERFACE LUABRIDGE_CXX17)
endif()
Expand All @@ -51,6 +49,14 @@ if(MSVC AND CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
)
endif()

if(DEFINED XP_NAMESPACE)
set(targetsFile LuaBridgeTargets)
set(XP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake)
xpPackageDevel(TARGETS_FILE ${targetsFile} LIBRARIES ${XP_NAMESPACE}::LuaBridge)
install(TARGETS LuaBridge EXPORT ${targetsFile})
install(EXPORT ${targetsFile} DESTINATION ${XP_INSTALL_CMAKEDIR} NAMESPACE ${XP_NAMESPACE}::)
endif()

if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
install(DIRECTORY LuaBridge TYPE INCLUDE)
endif()
10 changes: 10 additions & 0 deletions Tests/Source/ClassTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,9 @@ TEST_F(ClassFunctions, StdFunctions)
lua_close(L); // Force garbage collection
L = nullptr;

#if defined(LUABRIDGE_CHECK_STDFUNCTION_LIFETIME)
ASSERT_TRUE(data.expired());
#endif
}

TEST_F(ClassFunctions, StdFunctions_PassState)
Expand Down Expand Up @@ -591,7 +593,9 @@ TEST_F(ClassFunctions, StdFunctions_PassState)
lua_close(L); // Force garbage collection
L = nullptr;

#if defined(LUABRIDGE_CHECK_STDFUNCTION_LIFETIME)
ASSERT_TRUE(data.expired());
#endif
}

TEST_F(ClassFunctions, ConstStdFunctions)
Expand Down Expand Up @@ -635,7 +639,9 @@ TEST_F(ClassFunctions, ConstStdFunctions)
lua_close(L); // Force garbage collection
L = nullptr;

#if defined(LUABRIDGE_CHECK_STDFUNCTION_LIFETIME)
ASSERT_TRUE(data.expired());
#endif
}

struct ClassProperties : ClassTests
Expand Down Expand Up @@ -1089,8 +1095,10 @@ TEST_F(ClassProperties, StdFunctions)
lua_close(L); // Force garbage collection
L = nullptr;

#if defined(LUABRIDGE_CHECK_STDFUNCTION_LIFETIME)
ASSERT_TRUE(getterData.expired());
ASSERT_TRUE(setterData.expired());
#endif
}

TEST_F(ClassProperties, StdFunctions_ReadOnly)
Expand Down Expand Up @@ -1124,7 +1132,9 @@ TEST_F(ClassProperties, StdFunctions_ReadOnly)
lua_close(L); // Force garbage collection
L = nullptr;

#if defined(LUABRIDGE_CHECK_STDFUNCTION_LIFETIME)
ASSERT_TRUE(getterData.expired());
#endif
}

struct ClassStaticFunctions : ClassTests
Expand Down
3 changes: 2 additions & 1 deletion Tests/Source/LuaRefTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ TEST_F(LuaRefTests, Assignment)
ASSERT_TRUE(value.isNumber());
ASSERT_EQ(5, value.cast<int>());

value = value;
auto copy = value;
value = copy;
ASSERT_EQ(LUA_TNUMBER, value.type());
ASSERT_TRUE(value.isNumber());
ASSERT_EQ(5, value.cast<int>());
Expand Down
1 change: 1 addition & 0 deletions Tests/Source/PerformanceTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct A

void mf3(A&) {}

virtual ~A() = default;
virtual void vf1() {}

int data;
Expand Down
7 changes: 7 additions & 0 deletions Tests/Source/RefCountedObjectTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,14 @@ TEST_F(RefCountedObjectTests, AssignOperatorRefSelfAssignment)

luabridge::RefCountedObjectPtr<RefCounted> ptr(rawPtr);

#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wself-assign-overloaded"
#endif
const luabridge::RefCountedObjectPtr<RefCounted>& returnValue = (ptr = ptr);
#if defined(__clang__)
# pragma clang diagnostic pop
#endif

ASSERT_EQ(&returnValue, &ptr);
ASSERT_EQ(ptr, rawPtr);
Expand Down
7 changes: 7 additions & 0 deletions Tests/Source/RefCountedPtrTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,14 @@ TEST_F(RefCountedPtrTests, AssignOperatorRefSelfAssignment)

luabridge::RefCountedPtr<TestObject> ptr(rawPtr);

#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wself-assign-overloaded"
#endif
const luabridge::RefCountedPtr<TestObject>& returnValue = (ptr = ptr);
#if defined(__clang__)
# pragma clang diagnostic pop
#endif

ASSERT_EQ(&returnValue, &ptr);
ASSERT_EQ(ptr, rawPtr);
Expand Down
1 change: 1 addition & 0 deletions docker-compose.sh
1 change: 1 addition & 0 deletions docker-compose.yml