Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify logic to select Lua interpreter #4576

Merged
merged 6 commits into from
May 23, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ jobs:
- name: Install dependencies
run: >
sudo apt update -q &&
sudo apt install -yq build-essential libluajit-5.1-dev libmysqlclient-dev
sudo apt install -yq build-essential libluajit-5.1-dev liblua5.4-dev libmysqlclient-dev
libboost-system-dev libboost-iostreams-dev libboost-locale-dev
libpugixml-dev libfmt-dev

- name: Build with cmake
uses: lukka/run-cmake@v10
with:
buildPreset: default
buildPresetAdditionalArgs: "['--config', '${{ matrix.buildtype }}']"
buildPresetAdditionalArgs: "['--config', '${{ matrix.buildtype }}', '-DUSE_LUAJIT=${{ matrix.luajit }}']"
configurePreset: default

- name: Perform CodeQL Analysis
Expand All @@ -75,5 +75,5 @@ jobs:
- name: Upload artifact binary
uses: actions/upload-artifact@v4
with:
name: tfs-ubuntu-${{ matrix.buildtype }}-luajit=on-${{ github.sha }}
path: ${{ runner.workspace }}/build/tfs
name: tfs-ubuntu-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }}-${{ github.sha }}
path: ${{ runner.workspace }}/build/${{ matrix.buildtype }}/tfs
12 changes: 4 additions & 8 deletions .github/workflows/build-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,31 @@ jobs:
# Using 'latest' branch, the latest CMake is installed.
uses: lukka/get-cmake@latest

- name: Enable LuaJIT
if: ${{ matrix.luajit }} == "on"
run: echo "VCPKG_FEATURE_FLAGS=luajit" >> $GITHUB_ENV

- name: Run vcpkg
uses: lukka/run-vcpkg@v11

- name: Build with CMake
uses: lukka/run-cmake@v10
with:
buildPreset: vcpkg
buildPresetAdditionalArgs: "['--config', '${{ matrix.buildtype }}']"
buildPresetAdditionalArgs: "['--config', '${{ matrix.buildtype }}', '-DUSE_LUAJIT=${{ matrix.luajit }}']"
configurePreset: vcpkg

- name: Upload artifact binary
uses: actions/upload-artifact@v4
if: ${{ !startsWith(matrix.os, 'windows') }}
with:
name: tfs-${{ matrix.os }}-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }}-${{ github.sha }}
path: ${{ runner.workspace }}/build/tfs
path: ${{ runner.workspace }}/build/${{ matrix.buildtype }}/tfs

- name: Upload artifact binary (exe)
uses: actions/upload-artifact@v4
if: ${{ startsWith(matrix.os, 'windows') }}
with:
name: tfs-${{ matrix.os }}-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }}-${{ github.sha }}
path: |
${{ runner.workspace }}/build/tfs.exe
${{ runner.workspace }}/build/*.dll
${{ runner.workspace }}/build/${{ matrix.buildtype }}/tfs.exe
${{ runner.workspace }}/build/${{ matrix.buildtype }}/*.dll

- name: Prepare datapack contents
run: find . -maxdepth 1 ! -name data ! -name config.lua.dist ! -name key.pem ! -name LICENSE ! -name README.md ! -name schema.sql -exec rm -r {} \;
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:

env:
VCPKG_BUILD_TYPE: release
VCPKG_FEATURE_FLAGS: luajit

steps:
- uses: actions/checkout@v4
Expand All @@ -31,7 +30,7 @@ jobs:
uses: lukka/run-cmake@v10
with:
buildPreset: vcpkg
buildPresetAdditionalArgs: "['--config', 'RelWithDebInfo', '--clean-first']"
buildPresetAdditionalArgs: "['--config', 'RelWithDebInfo', '--clean-first', '-DUSE_LUAJIT=ON']"
configurePreset: vcpkg

- name: Prepare datapack contents
Expand Down
17 changes: 9 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ if (BUILD_TESTING)
list(APPEND VCPKG_MANIFEST_FEATURES "unit-tests")
endif()

option(USE_LUAJIT "Use LuaJIT" OFF)
if (USE_LUAJIT)
list(APPEND VCPKG_MANIFEST_FEATURES "luajit")
else()
list(APPEND VCPKG_MANIFEST_FEATURES "lua")
endif()

project(tfs CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand Down Expand Up @@ -53,15 +60,9 @@ find_package(Threads REQUIRED)
find_package(PugiXML CONFIG REQUIRED)

# Selects LuaJIT if user defines or auto-detected
if (DEFINED USE_LUAJIT AND NOT USE_LUAJIT)
set(FORCE_LUAJIT ${USE_LUAJIT})
if (USE_LUAJIT)
find_package(LuaJIT REQUIRED)
else ()
find_package(LuaJIT)
set(FORCE_LUAJIT ${LuaJIT_FOUND})
endif ()
option(USE_LUAJIT "Use LuaJIT" ${FORCE_LUAJIT})

if (NOT FORCE_LUAJIT)
find_package(Lua REQUIRED)
endif ()

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ COPY cmake /usr/src/forgottenserver/cmake/
COPY src /usr/src/forgottenserver/src/
COPY CMakeLists.txt CMakePresets.json /usr/src/forgottenserver/
WORKDIR /usr/src/forgottenserver
RUN cmake --preset default && cmake --build --config RelWithDebInfo --preset default
RUN cmake --preset default -DUSE_LUAJIT=ON && cmake --build --config RelWithDebInfo --preset default

FROM alpine:3.19
RUN apk add --no-cache \
Expand Down
15 changes: 13 additions & 2 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"dependencies": [
"libiconv",
"boost-asio",
"boost-iostreams",
"boost-locale",
"boost-lockfree",
"boost-system",
"boost-variant",
"fmt",
{
"name": "libiconv",
"platform": "osx"
},
"libmariadb",
"lua",
"openssl",
"pugixml"
],
"features": {
"lua": {
"description": "Use Lua instead of LuaJIT",
"dependencies": [
"lua"
]
},
"luajit": {
"description": "Use LuaJIT instead of Lua",
"dependencies": [
Expand All @@ -28,5 +36,8 @@
]
}
},
"default-features": [
"lua"
],
"builtin-baseline": "215a2535590f1f63788ac9bd2ed58ad15e6afdff"
}
Loading