Skip to content

Commit 0866af2

Browse files
feat: Lua Scripting v1 (#37)
* refactor: required mondernization of the io_service * feat: introduce lua_api engine * chore: bump version * feat: add script manager and menu section * feat: add event emitters * feat: add map overlay, a way to show custom data in the mapView * feat: expose methods to the lua engine * doc: add documentation related to the lua engine * feat: add some lua script examples * fix: downgrade version to base version 2>1 * ci: fix required files in cmakelist and build flow * ci: typo in the FastNoiseLite -> fast_noise_lite, unhandled libsol * ci: solve libsol reaching in linux * fix: remove autoborder redefinition issue * fix: remove unnecesary const * fix: solve issue related to source header discover * feat: add sandbox security, prevent use of malicious paths or unknown calls * fix: force to correct overload resolution in fast_noise_lite lib * ci: fix strings in lua_dialog * ci: Fix sol2 warnings, LuaImage deprecation, and add cpr/json dependencies * docs: update documentation related to init new script project * ci: include windows CI * ci: label correctly linux build, add release CI * ci: update release GA tags to handle OTA release convention correctly * feat: expose keyboard methods, mouse methods and internal selection methods * docs: improve documentation * ci: fix windows build * typo: remove on~ in mouse events * build: update MSVC flags * build: fix linux unhandled packages * build: solve lua libraries * ci: support vcpkg cache * build: remove sol2 ambiguity * ci: include lua.hpp header * build: fix lua version link * ci: improve vcpkg cache * ci: drop windows CI for now --------- Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com>
1 parent 68c9d81 commit 0866af2

File tree

96 files changed

+26020
-7881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+26020
-7881
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build RME
1+
name: Build - Linux
22

33
on:
44
push:
@@ -33,8 +33,11 @@ jobs:
3333
freeglut3-dev \
3434
libarchive-dev \
3535
zlib1g-dev \
36+
libarchive-dev \
37+
zlib1g-dev \
3638
libxmu-dev \
37-
libxi-dev
39+
libxi-dev \
40+
liblua5.3-dev
3841
3942
- name: Setup ccache
4043
run: |
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build - Windows
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
build-windows:
11+
name: Windows-Release
12+
runs-on: windows-2022
13+
14+
env:
15+
CMAKE_BUILD_PARALLEL_LEVEL: 4
16+
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}\vcpkg_cache
17+
VCPKG_COMMIT: '734f8130ffe2f02cf855a3a42a2958f01b3fb005'
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
24+
fetch-depth: 0
25+
26+
- name: Get latest CMake and Ninja
27+
uses: lukka/get-cmake@v3.31.6
28+
29+
- name: Create vcpkg cache directory
30+
run: mkdir -p "${{ env.VCPKG_DEFAULT_BINARY_CACHE }}"
31+
shell: bash
32+
33+
- name: Restore vcpkg binary cache
34+
id: vcpkg-cache
35+
uses: actions/cache@v4
36+
with:
37+
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
38+
key: vcpkg-bin-${{ runner.os }}-${{ env.VCPKG_COMMIT }}-${{ hashFiles('vcpkg.json') }}
39+
restore-keys: |
40+
vcpkg-bin-${{ runner.os }}-${{ env.VCPKG_COMMIT }}-
41+
42+
- name: Restore vcpkg installed packages
43+
id: vcpkg-installed
44+
uses: actions/cache@v4
45+
with:
46+
path: build/vcpkg_installed
47+
key: vcpkg-installed-${{ runner.os }}-${{ env.VCPKG_COMMIT }}-${{ hashFiles('vcpkg.json') }}
48+
restore-keys: |
49+
vcpkg-installed-${{ runner.os }}-${{ env.VCPKG_COMMIT }}-
50+
51+
- name: Setup vcpkg
52+
uses: lukka/run-vcpkg@v11
53+
with:
54+
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT }}
55+
vcpkgJsonGlob: 'vcpkg.json'
56+
57+
- name: Configure CMake
58+
shell: pwsh
59+
run: |
60+
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 `
61+
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" `
62+
-DVCPKG_TARGET_TRIPLET=x64-windows-static `
63+
-DVCPKG_INSTALL_OPTIONS="--clean-after-build" `
64+
-DCMAKE_BUILD_TYPE=Release
65+
66+
- name: Build
67+
shell: pwsh
68+
run: cmake --build build --config Release --parallel
69+
70+
- name: Prepare Artifacts
71+
shell: pwsh
72+
run: |
73+
$artifactDir = "$env:GITHUB_WORKSPACE\artifacts"
74+
New-Item -ItemType Directory -Force -Path $artifactDir | Out-Null
75+
76+
$exePath = Get-ChildItem -Recurse -Path "$env:GITHUB_WORKSPACE\build" -Filter "rme.exe" | Select-Object -First 1
77+
78+
if (-not $exePath) {
79+
Write-Error "Not found rme.exe!"
80+
exit 1
81+
}
82+
83+
Copy-Item $exePath.FullName -Destination $artifactDir
84+
85+
- name: Upload Artifact
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: rme-windows
89+
path: artifacts/

.github/workflows/release.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
- 'Hotfix*'
8+
- 'Release*'
9+
- 'Hotfix *'
10+
- 'Release *'
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
release:
17+
name: Release ${{ matrix.os }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- os: ubuntu-24.04
24+
asset_prefix: rme-linux
25+
- os: windows-2022
26+
asset_prefix: rme-windows
27+
28+
env:
29+
CMAKE_BUILD_PARALLEL_LEVEL: 2
30+
LUKKA_RUN_VCPKG_SHA: '734f8130ffe2f02cf855a3a42a2958f01b3fb005'
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
with:
36+
submodules: recursive
37+
fetch-depth: 0
38+
39+
# --- Linux Dependencies ---
40+
- name: Install Dependencies (Linux)
41+
if: runner.os == 'Linux'
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y \
45+
build-essential cmake ccache libasio-dev nlohmann-json3-dev \
46+
libfmt-dev libboost-system-dev libboost-thread-dev libwxgtk3.2-dev \
47+
libglu1-mesa-dev freeglut3-dev libarchive-dev zlib1g-dev \
48+
libxmu-dev libxi-dev liblua5.3-dev
49+
50+
# --- Windows Dependencies ---
51+
- name: Get latest CMake (Windows)
52+
if: runner.os == 'Windows'
53+
uses: lukka/get-cmake@v3.31.6
54+
55+
- name: Setup vcpkg (Windows)
56+
if: runner.os == 'Windows'
57+
uses: lukka/run-vcpkg@v11
58+
with:
59+
vcpkgGitCommitId: ${{ env.LUKKA_RUN_VCPKG_SHA }}
60+
61+
- name: Install Dependencies via vcpkg (Windows)
62+
if: runner.os == 'Windows'
63+
shell: pwsh
64+
run: |
65+
$deps = @("wxwidgets", "boost-thread", "boost-system", "libarchive", "freeglut", "zlib", "lua", "cpr", "nlohmann-json")
66+
& "$env:VCPKG_ROOT/vcpkg" install $deps --triplet x64-windows-static
67+
68+
# --- Configure ---
69+
- name: Configure CMake (Linux)
70+
if: runner.os == 'Linux'
71+
run: |
72+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
73+
74+
- name: Configure CMake (Windows)
75+
if: runner.os == 'Windows'
76+
shell: pwsh
77+
run: |
78+
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 `
79+
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" `
80+
-DVCPKG_TARGET_TRIPLET=x64-windows-static `
81+
-DCMAKE_BUILD_TYPE=Release
82+
83+
# --- Build ---
84+
- name: Build
85+
run: cmake --build build --config Release --parallel 2
86+
87+
# --- Package ---
88+
- name: Prepare Release Bundle
89+
shell: bash
90+
run: |
91+
mkdir release_package
92+
93+
# Copy Executable
94+
if [ "${{ runner.os }}" == "Windows" ]; then
95+
find build -name "rme.exe" -exec cp {} release_package/ \;
96+
else
97+
find build -name "rme" -exec cp {} release_package/ \;
98+
chmod +x release_package/rme
99+
fi
100+
101+
# Copy Resources
102+
cp -r data release_package/
103+
[ -d "brushes" ] && cp -r brushes release_package/
104+
[ -d "icons" ] && cp -r icons release_package/
105+
[ -d "extensions" ] && cp -r extensions release_package/
106+
[ -d "modules" ] && cp -r modules release_package/
107+
[ -d "scripts" ] && cp -r scripts release_package/
108+
109+
# Copy License/Readme
110+
[ -f "LICENSE" ] && cp LICENSE release_package/
111+
[ -f "LICENSE.rtf" ] && cp LICENSE.rtf release_package/
112+
[ -f "README.md" ] && cp README.md release_package/
113+
114+
- name: Prepare Source Bundle
115+
if: runner.os == 'Windows'
116+
shell: bash
117+
run: |
118+
mkdir source_package
119+
[ -d "source" ] && cp -r source source_package/
120+
[ -d "vcproj" ] && cp -r vcproj source_package/
121+
[ -f "CMakeLists.txt" ] && cp CMakeLists.txt source_package/
122+
[ -f "vcpkg.json" ] && cp vcpkg.json source_package/
123+
[ -f "LICENSE.rtf" ] && cp LICENSE.rtf source_package/
124+
[ -f "README.md" ] && cp README.md source_package/
125+
126+
- name: Zip Source
127+
if: runner.os == 'Windows'
128+
uses: thedoctor0/zip-release@0.7.6
129+
with:
130+
type: zip
131+
filename: rme-source-${{ github.ref_name }}.zip
132+
path: source_package/
133+
134+
- name: Zip Release
135+
uses: thedoctor0/zip-release@0.7.6
136+
with:
137+
type: zip
138+
filename: ${{ matrix.asset_prefix }}-${{ github.ref_name }}.zip
139+
path: release_package/
140+
141+
# --- Upload ---
142+
- name: Upload Release Artifact
143+
uses: ncipollo/release-action@v1
144+
with:
145+
artifacts: "*.zip"
146+
allowUpdates: true
147+
replacesArtifacts: true
148+
token: ${{ secrets.GITHUB_TOKEN }}

CMakeLists.txt

Lines changed: 106 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
1-
cmake_minimum_required(VERSION 3.1)
1+
cmake_minimum_required(VERSION 3.12)
22

33
project(rme)
44

5+
if(POLICY CMP0072)
6+
cmake_policy(SET CMP0072 NEW) # Prefer GLVND
7+
endif()
8+
9+
if(POLICY CMP0167)
10+
cmake_policy(SET CMP0167 NEW) # Use BoostConfig
11+
endif()
12+
513
if(NOT CMAKE_BUILD_TYPE)
614
set(CMAKE_BUILD_TYPE RelWithDebInfo)
715
endif()
816

9-
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-deprecated-declarations -Wno-overloaded-virtual -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-function -Wunused-result")
10-
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -D__DEBUG__")
11-
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
12-
set(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
13-
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
17+
if(MSVC)
18+
set(CMAKE_CXX_FLAGS "/W3 /EHsc /D_CRT_SECURE_NO_WARNINGS")
19+
set(CMAKE_CXX_FLAGS_DEBUG "/Od /Zi /D__DEBUG__")
20+
set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /DNDEBUG")
21+
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /DNDEBUG")
22+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Zi")
23+
else()
24+
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-deprecated-declarations -Wno-overloaded-virtual -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-function -Wunused-result")
25+
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -D__DEBUG__")
26+
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
27+
set(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
28+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
29+
endif()
1430

1531
find_package(OpenGL REQUIRED)
1632

@@ -29,12 +45,94 @@ find_package(wxWidgets COMPONENTS html aui gl adv core net base REQUIRED)
2945
find_package(GLUT REQUIRED)
3046
find_package(ZLIB REQUIRED)
3147

48+
# Lua scripting support
49+
if(MSVC)
50+
# Windows/vcpkg specific configuration
51+
find_package(lua CONFIG REQUIRED)
52+
find_package(sol2 CONFIG REQUIRED)
53+
find_package(cpr CONFIG REQUIRED)
54+
find_package(nlohmann_json CONFIG REQUIRED)
55+
56+
# Validate Lua target from vcpkg
57+
if(TARGET lua::lua)
58+
set(LUA_LIB_TARGET lua::lua)
59+
elseif(TARGET lua)
60+
set(LUA_LIB_TARGET lua)
61+
else()
62+
message(FATAL_ERROR "Lua target not found in vcpkg config!")
63+
endif()
64+
65+
# Explicitly add Lua includes to global path to ensure sol2 finds 'lua.hpp'
66+
get_target_property(VCPKG_LUA_INCLUDES ${LUA_LIB_TARGET} INTERFACE_INCLUDE_DIRECTORIES)
67+
if(VCPKG_LUA_INCLUDES)
68+
include_directories(${VCPKG_LUA_INCLUDES})
69+
endif()
70+
71+
add_compile_definitions(SOL_USING_CXX_LUA_HPP=1)
72+
73+
set(LIBS_TO_LINK ${LUA_LIB_TARGET} cpr::cpr nlohmann_json::nlohmann_json sol2::sol2)
74+
75+
else()
76+
# Linux / Standard CMake Module configuration
77+
find_package(Lua REQUIRED)
78+
79+
include(FetchContent)
80+
81+
# sol2
82+
find_package(sol2 CONFIG QUIET)
83+
if(NOT sol2_FOUND)
84+
message(STATUS "sol2 not found via find_package, using FetchContent...")
85+
FetchContent_Declare(
86+
sol2
87+
GIT_REPOSITORY https://github.com/ThePhD/sol2.git
88+
GIT_TAG v3.3.0
89+
)
90+
FetchContent_MakeAvailable(sol2)
91+
if(NOT TARGET sol2::sol2)
92+
if(TARGET sol2)
93+
add_library(sol2::sol2 ALIAS sol2)
94+
else()
95+
set(SOL2_INCLUDE_DIRS ${sol2_SOURCE_DIR}/include)
96+
include_directories(${SOL2_INCLUDE_DIRS})
97+
add_library(sol2::sol2 INTERFACE IMPORTED)
98+
set_target_properties(sol2::sol2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SOL2_INCLUDE_DIRS}")
99+
endif()
100+
endif()
101+
endif()
102+
103+
# cpr
104+
find_package(cpr CONFIG QUIET)
105+
if(NOT cpr_FOUND)
106+
message(STATUS "cpr not found via find_package, using FetchContent...")
107+
FetchContent_Declare(
108+
cpr
109+
GIT_REPOSITORY https://github.com/libcpr/cpr.git
110+
GIT_TAG 1.10.5
111+
)
112+
FetchContent_MakeAvailable(cpr)
113+
endif()
114+
115+
# nlohmann_json
116+
find_package(nlohmann_json CONFIG QUIET)
117+
if(NOT nlohmann_json_FOUND)
118+
message(STATUS "nlohmann_json not found via find_package, using FetchContent...")
119+
FetchContent_Declare(
120+
json
121+
GIT_REPOSITORY https://github.com/nlohmann/json.git
122+
GIT_TAG v3.11.3
123+
)
124+
FetchContent_MakeAvailable(json)
125+
endif()
126+
127+
set(LIBS_TO_LINK ${LUA_LIBRARIES} cpr::cpr nlohmann_json::nlohmann_json sol2::sol2)
128+
endif()
129+
32130
include(${wxWidgets_USE_FILE})
33131
include(source/CMakeLists.txt)
34132
add_executable(rme ${rme_H} ${rme_SRC})
35133

36134
set_target_properties(rme PROPERTIES CXX_STANDARD 17)
37135
set_target_properties(rme PROPERTIES CXX_STANDARD_REQUIRED ON)
38136

39-
include_directories(${Boost_INCLUDE_DIRS} ${LibArchive_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
40-
target_link_libraries(rme ${wxWidgets_LIBRARIES} ${Boost_LIBRARIES} ${LibArchive_LIBRARIES} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${ZLIB_LIBRARIES})
137+
include_directories(${CMAKE_SOURCE_DIR}/source ${Boost_INCLUDE_DIRS} ${LibArchive_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUA_INCLUDE_DIRS})
138+
target_link_libraries(rme ${wxWidgets_LIBRARIES} ${Boost_LIBRARIES} ${LibArchive_LIBRARIES} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBS_TO_LINK})

0 commit comments

Comments
 (0)