Improved build system scripts, cleaned up code, added experimental Dockerfile

This commit is contained in:
Exynox 2023-12-07 22:12:45 +02:00
parent ff3388e795
commit ce920541a2
8 changed files with 74 additions and 27 deletions

9
.dockerignore Normal file
View File

@ -0,0 +1,9 @@
# CMake
cmake-build-debug/
cmake-build-release/
# Dockerfile (in order to allow changes without rebuilding)
Dockerfile
# Test folder
test/

38
Dockerfile Normal file
View File

@ -0,0 +1,38 @@
FROM ubuntu:latest as build
WORKDIR /app
# Update the system and install various dependencies
RUN apt-get update && \
apt-get install -y git cmake build-essential tar curl zip unzip pkg-config autoconf python3 \
libdevil-dev libncurses5-dev libbsd-dev
# Install vcpkg and the required libraries
RUN git clone https://github.com/Microsoft/vcpkg.git
RUN bash ./vcpkg/bootstrap-vcpkg.sh
RUN ./vcpkg/vcpkg install boost-system cryptopp effolkronium-random libmysql libevent lzo
COPY . .
RUN mkdir build/
RUN cd build && cmake -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake ..
RUN cd build && make -j $(nproc)
FROM ubuntu:latest as app
WORKDIR /app
RUN apt-get update && apt-get install -y libdevil-dev libbsd-dev && apt-get clean
# Copy the binaries from the build stage
COPY --from=build /app/build/src/db/db /bin/db
COPY --from=build /app/build/src/game/game /bin/game
COPY --from=build /app/build/src/quest/quest /bin/quest
# Copy the game files
COPY ./gamefiles/ .
# Symlink the configuration files
RUN ln -s "./conf/CMD" "CMD"
RUN ln -s ./conf/item_names_en.txt item_names.txt
RUN ln -s ./conf/item_proto.txt item_proto.txt
RUN ln -s ./conf/mob_names_en.txt mob_names.txt
RUN ln -s ./conf/mob_proto.txt mob_proto.txt

View File

@ -1,7 +1,10 @@
# Ignore compiled quest folder
object/
# Quest interpreter binaries
quest
quest.core
quest.exe
# Quest compiler binaries
qc
qc.core
qc.exe
# Compilde Python files
*.pyc

Binary file not shown.

View File

@ -12,9 +12,8 @@ include_directories(src)
add_executable(${PROJECT_NAME} ${sources})
# Find dependencies
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries (${PROJECT_NAME} PRIVATE ${Boost_LIBRARIES} ${Boost_SYSTEM_LIBRARY})
find_package(Boost COMPONENTS system REQUIRED)
target_link_libraries (${PROJECT_NAME} PRIVATE Boost::boost Boost::system)
# Pthreads
set(THREADS_PREFER_PTHREAD_FLAG ON)

View File

@ -8,35 +8,33 @@ file(GLOB_RECURSE sources
# Add the src directory to the include path
include_directories(src)
# Find dependencies
find_package(libmysql REQUIRED)
find_package(Boost COMPONENTS system REQUIRED)
find_package(DevIL REQUIRED)
find_package(LZO REQUIRED)
find_package(cryptopp CONFIG REQUIRED)
add_executable(${PROJECT_NAME} ${sources})
# Link dependencies if found
target_link_libraries (${PROJECT_NAME} ${MYSQL_LIBRARIES})
# Find dependencies
# MySQL
find_package(unofficial-libmysql REQUIRED)
target_link_libraries(${PROJECT_NAME} unofficial::libmysql::libmysql)
# Crypto++
target_link_libraries (${PROJECT_NAME} cryptopp-static)
find_package(cryptopp CONFIG REQUIRED)
target_link_libraries (${PROJECT_NAME} cryptopp::cryptopp)
# Boost
include_directories(${Boost_INCLUDE_DIR})
target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES})
find_package(Boost REQUIRED)
target_link_libraries (${PROJECT_NAME} Boost::boost)
# Libevent
find_package(Libevent CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} libevent::core libevent::extra libevent::pthreads)
if (IL_FOUND)
# DevIL
find_package(DevIL REQUIRED)
include_directories(${IL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${IL_LIBRARIES})
endif (IL_FOUND)
# LZO
find_package(LZO REQUIRED)
if (LZO_FOUND)
include_directories(${LZO_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${LZO_LIBRARIES})