Skip to content

Commit

Permalink
Merge pull request #13 from Pika-Software/dev
Browse files Browse the repository at this point in the history
Moonloader 2.0
  • Loading branch information
dankmolot authored Jun 21, 2024
2 parents 8e47d51 + 712d3f3 commit 2150cd6
Show file tree
Hide file tree
Showing 35 changed files with 1,472 additions and 942 deletions.
211 changes: 46 additions & 165 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,191 +16,72 @@ on:

env:
GIT_BRANCH: ${{ github.ref_type == 'branch' && github.ref_name || 'release' }}
BUILD_TYPE: ${{ (github.ref_type != 'branch' || github.ref_name == 'main') && 'Release' || 'Debug' }}
BUILD_TYPE: ${{ (github.ref_type != 'branch' || github.ref_name == 'main') && 'Release' || 'RelWithDebInfo' }}

jobs:
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: '[x32] Download garrysmod_common'
uses: actions/checkout@v3
with:
repository: 'dankmolot/garrysmod_common'
ref: 'master-cmake'
submodules: 'recursive'
path: 'third-party/garrysmod_common'

- name: '[x32] Configure project (Serverside)'
run: |
cmake -B build -S . -A Win32 `
-DGARRYSMOD_COMMON_PATH="third-party/garrysmod_common" `
-DAUTOINSTALL="." `
-DBUILD_SHARED_LIBS=OFF `
-DGIT_BRANCH="$env:GIT_BRANCH"
- name: '[x32] Build project (Serverside)'
run: cmake --build build --config $env:BUILD_TYPE -j -t moonloader

- name: '[x32] Configure project (Clientside)'
run: cmake -B build -S . -DCLIENT_DLL=ON

- name: '[x32] Build project (Clientside)'
run: cmake --build build --config $env:BUILD_TYPE -j -t moonloader

- name: '[x64] Download garrysmod_common'
uses: actions/checkout@v3
with:
repository: 'dankmolot/garrysmod_common'
ref: 'x86-64-cmake'
submodules: 'recursive'
path: 'third-party/garrysmod_common64'

- name: '[x64] Configure project (Serverside)'
run: |
cmake -B build64 -S . -A x64 `
-DGARRYSMOD_COMMON_PATH="third-party/garrysmod_common64" `
-DAUTOINSTALL="." `
-DBUILD_SHARED_LIBS=OFF `
-DGIT_BRANCH="$env:GIT_BRANCH"
- name: '[x64] Build project (Serverside)'
run: cmake --build build64 --config $env:BUILD_TYPE -j -t moonloader

- name: '[x64] Configure project (Clientside)'
run: cmake -B build64 -S . -DCLIENT_DLL=ON

- name: '[x64] Build project (Clientside)'
run: cmake --build build64 --config $env:BUILD_TYPE -j -t moonloader

- name: "Upload artifacts"
uses: actions/upload-artifact@v3
with:
name: Windows
path: |
./*.dll
if-no-files-found: error

- name: "Upload debug artifacts"
uses: actions/upload-artifact@v3
if: ${{ env.BUILD_TYPE == 'Debug' }}
with:
name: Windows
path: |
./*.pdb
build:
strategy:
matrix:
os: [windows-latest, ubuntu-20.04]
arch: [x64, x86]
include:
- os: windows-latest
arch: x64
CMAKE_ARCH_FLAG: -A x64
- os: windows-latest
arch: x86
CMAKE_ARCH_FLAG: -A Win32
- os: ubuntu-20.04
arch: x86
CMAKE_ARCH_FLAG: -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32"
- os: macos-latest
arch: x64

runs-on: ${{ matrix.os }}

linux:
runs-on: ubuntu-20.04 # Using ubuntu 20.04 since we want to use old gcc version to ensure compatibility
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install dependencies
- name: Install dependencies Ubuntu x86
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.arch == 'x86' }}
run: |
sudo apt update
sudo apt install gcc-multilib g++-multilib
- name: '[x32] Download garrysmod_common'
uses: actions/checkout@v3
- name: Download garrysmod_common
uses: actions/checkout@v4
with:
repository: 'dankmolot/garrysmod_common'
ref: 'master-cmake'
submodules: 'recursive'
path: 'third-party/garrysmod_common'
repository: dankmolot/garrysmod_common
ref: ${{ matrix.arch == 'x64' && 'x86-64-cmake' || 'master-cmake' }}
submodules: recursive
path: third-party/garrysmod_common

- name: '[x32] Configure project (Serverside)'
run: |
cmake -B build -S . \
-DGARRYSMOD_COMMON_PATH="third-party/garrysmod_common" \
-DAUTOINSTALL="." \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32" \
-DGIT_BRANCH="$GIT_BRANCH" \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE"
- name: Configure project
run: cmake -B build -S . ${{matrix.CMAKE_ARCH_FLAG}} -DGARRYSMOD_COMMON_PATH="third-party/garrysmod_common" -DAUTOINSTALL="." -DBUILD_SHARED_LIBS=OFF -DGIT_BRANCH="${{env.GIT_BRANCH}}" -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}"

- name: '[x32] Build project (Serverside)'
run: cmake --build build -j -t moonloader
- name: Build project
run: cmake --build build -j -t moonloader --config ${{env.BUILD_TYPE}}

- name: '[x32] Configure project (Clientside)'
- name: Configure project (Clientside)
run: cmake -B build -S . -DCLIENT_DLL=ON

- name: Build project (Clientside)
run: cmake --build build -j -t moonloader --config ${{env.BUILD_TYPE}}

- name: '[x32] Build project (Clientside)'
run: cmake --build build -j -t moonloader

- name: '[x64] Download garrysmod_common'
uses: actions/checkout@v3
with:
repository: 'dankmolot/garrysmod_common'
ref: 'x86-64-cmake'
submodules: 'recursive'
path: 'third-party/garrysmod_common64'

- name: '[x64] Configure project (Serverside)'
- name: Strip debug information from binaries and keep them outside (Ubuntu)
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: |
cmake -B build64 -S . \
-DGARRYSMOD_COMMON_PATH="third-party/garrysmod_common64" \
-DAUTOINSTALL="." \
-DBUILD_SHARED_LIBS=OFF \
-DGIT_BRANCH="$GIT_BRANCH" \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE"
- name: '[x64] Build project (Serverside)'
run: cmake --build build64 -j -t moonloader

- name: '[x64] Configure project (Clientside)'
run: cmake -B build64 -S . -DCLIENT_DLL=ON

- name: '[x64] Build project (Clientside)'
run: cmake --build build64 -j -t moonloader
find *.dll -exec objcopy --only-keep-debug {} {}.pdb \;
find *.dll -exec objcopy --strip-debug {} \;
find *.dll -exec objcopy --add-gnu-debuglink {}.pdb {} \;
- name: "Upload artifacts"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Linux
path: |
./*.dll
if-no-files-found: error

macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: '[x64] Download garrysmod_common'
uses: actions/checkout@v3
with:
repository: 'dankmolot/garrysmod_common'
ref: 'x86-64-cmake'
submodules: 'recursive'
path: 'third-party/garrysmod_common64'

- name: '[x64] Configure project (Serverside)'
run: |
cmake -B build64 -S . \
-DGARRYSMOD_COMMON_PATH="third-party/garrysmod_common64" \
-DAUTOINSTALL="." \
-DBUILD_SHARED_LIBS=OFF \
-DGIT_BRANCH="$GIT_BRANCH" \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE"
- name: '[x64] Build project (Serverside)'
run: cmake --build build64 -j -t moonloader

- name: '[x64] Configure project (Clientside)'
run: cmake -B build64 -S . -DCLIENT_DLL=ON

- name: '[x64] Build project (Clientside)'
run: cmake --build build64 -j -t moonloader

- name: "Upload artifacts"
uses: actions/upload-artifact@v3
with:
name: MacOS
name: ${{matrix.os}}-${{matrix.arch}}-${{env.BUILD_TYPE}}
path: |
./*.dll
./*.pdb
if-no-files-found: error
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode
/build*
.DS_Store
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[submodule "third-party/lua"]
path = third-party/lua
url = https://github.com/lubgr/lua-cmake
[submodule "third-party/moonscript"]
path = third-party/moonscript
url = https://github.com/leafo/moonscript.git
[submodule "third-party/efsw"]
path = third-party/efsw
url = https://github.com/SpartanJ/efsw.git
[submodule "third-party/Yuescript"]
path = third-party/Yuescript
url = https://github.com/pigpigyyy/Yuescript.git
[submodule "third-party/lua5.1"]
path = third-party/lua5.2
url = https://github.com/lua/lua.git
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.22)
enable_language(CXX C)

# Require C++ 17
set(CMAKE_CXX_STANDARD 17)
Expand All @@ -20,9 +21,9 @@ if(APPLE)
)
endif()

# Enable multithreaded compilation on Windows
# Debug build is unsupported on MSVC
if(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" "/MP")
list(REMOVE_ITEM CMAKE_CONFIGURATION_TYPES "Debug")
endif()

# Include extensions
Expand All @@ -32,7 +33,7 @@ add_subdirectory(cmake)
add_subdirectory(third-party/efsw)

# Include embedded lua
add_subdirectory(third-party/lua)
# add_subdirectory(third-party/lua)
add_subdirectory(third-party/lpeg)

# Add moonengine library
Expand Down Expand Up @@ -62,8 +63,9 @@ if(NOT DEFINED GIT_BRANCH)
)
endif()

file(STRINGS "VERSION" GM_MOONLOADER_VERSION)
project(gm_moonloader
VERSION 1.3.0
VERSION ${GM_MOONLOADER_VERSION}
LANGUAGES CXX
HOMEPAGE_URL "https://github.com/Pika-Software/gm_moonloader"
)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
2.0.0
2 changes: 2 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
include(find_garrysmod_common.cmake)
include(CMakeRC.cmake)
include(find_Yuescript.cmake)
include(find_lua52.cmake)
2 changes: 1 addition & 1 deletion cmake/CMakeRC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endif()

set(_version 2.0.0)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.5)
include(CMakeParseArguments)

if(COMMAND cmrc_add_resource_library)
Expand Down
20 changes: 20 additions & 0 deletions cmake/find_Yuescript.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.20)
project(yue CXX)

set(YUESCRIPT_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/Yuescript)
cmake_path(NORMAL_PATH YUESCRIPT_ROOT)
set(YUESCRIPT_SRC ${YUESCRIPT_ROOT}/src)

add_library(libyue
"${YUESCRIPT_SRC}/yuescript/ast.cpp"
"${YUESCRIPT_SRC}/yuescript/parser.cpp"
"${YUESCRIPT_SRC}/yuescript/yue_ast.cpp"
"${YUESCRIPT_SRC}/yuescript/yue_parser.cpp"
"${YUESCRIPT_SRC}/yuescript/yue_compiler.cpp"
"${YUESCRIPT_SRC}/yuescript/yuescript.cpp"
)

target_link_libraries(libyue PRIVATE lua::lib)

target_include_directories(libyue PUBLIC ${YUESCRIPT_SRC})
target_compile_definitions(libyue PRIVATE)
40 changes: 40 additions & 0 deletions cmake/find_lua52.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.20)
project(lua52 C)

set(LUA_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/lua5.2)
cmake_path(NORMAL_PATH YUESCRIPT_ROOT)

set(LUA_SRC lapi.c lcode.c lctype.c ldebug.c
ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c
lobject.c lopcodes.c lparser.c lstate.c
lstring.c ltable.c ltm.c lundump.c lvm.c
lzio.c lauxlib.c lbaselib.c lbitlib.c
lcorolib.c ldblib.c liolib.c lmathlib.c
loslib.c lstrlib.c ltablib.c loadlib.c linit.c
)

set(LUA_PUBLIC_HEADERS lauxlib.h lua.h luaconf.h lualib.h)

list(TRANSFORM LUA_SRC PREPEND ${LUA_ROOT}/)
list(TRANSFORM LUA_PUBLIC_HEADERS PREPEND ${LUA_ROOT}/)

add_library(lua52 ${LUA_SRC})

target_compile_definitions(lua52
PRIVATE
$<$<PLATFORM_ID:Linux>:LUA_USE_LINUX>)

target_compile_options(lua52
PRIVATE
$<$<OR:$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>,$<C_COMPILER_ID:GNU>>:
-Wextra -Wshadow -Wsign-compare -Wundef -Wwrite-strings -Wredundant-decls
-Wdisabled-optimization -Waggregate-return -Wdouble-promotion -Wdeclaration-after-statement
-Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wc++-compat -Wold-style-definition>)

set(LUA_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
file(COPY ${LUA_PUBLIC_HEADERS} DESTINATION ${LUA_INCLUDE_DIR})

target_include_directories(lua52 PRIVATE ${LUA_ROOT})
target_include_directories(lua52 INTERFACE ${LUA_INCLUDE_DIR})

add_library(lua::lib ALIAS lua52)
2 changes: 0 additions & 2 deletions moonengine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ target_link_libraries(moonengine PRIVATE
moonengine::resources
lua::lib
lpeg

sourcesdk::tier1
)

target_include_directories(moonengine PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
Expand Down
Loading

0 comments on commit 2150cd6

Please sign in to comment.