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 # Ignore compiled quest folder
object/ object/
# Quest interpreter binaries # Quest compiler binaries
quest qc
quest.core qc.core
quest.exe qc.exe
# Compilde Python files
*.pyc

Binary file not shown.

View File

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

View File

@ -8,44 +8,42 @@ file(GLOB_RECURSE sources
# Add the src directory to the include path # Add the src directory to the include path
include_directories(src) 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}) add_executable(${PROJECT_NAME} ${sources})
# Link dependencies if found # Find dependencies
target_link_libraries (${PROJECT_NAME} ${MYSQL_LIBRARIES})
# MySQL
find_package(unofficial-libmysql REQUIRED)
target_link_libraries(${PROJECT_NAME} unofficial::libmysql::libmysql)
# Crypto++ # Crypto++
target_link_libraries (${PROJECT_NAME} cryptopp-static) find_package(cryptopp CONFIG REQUIRED)
target_link_libraries (${PROJECT_NAME} cryptopp::cryptopp)
# Boost # Boost
include_directories(${Boost_INCLUDE_DIR}) find_package(Boost REQUIRED)
target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES}) target_link_libraries (${PROJECT_NAME} Boost::boost)
# Libevent # Libevent
find_package(Libevent CONFIG REQUIRED) find_package(Libevent CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} libevent::core libevent::extra libevent::pthreads) target_link_libraries(${PROJECT_NAME} libevent::core libevent::extra libevent::pthreads)
if (IL_FOUND) # DevIL
include_directories(${IL_INCLUDE_DIR}) find_package(DevIL REQUIRED)
target_link_libraries (${PROJECT_NAME} ${IL_LIBRARIES}) include_directories(${IL_INCLUDE_DIR})
endif (IL_FOUND) target_link_libraries(${PROJECT_NAME} ${IL_LIBRARIES})
# LZO
find_package(LZO REQUIRED)
if (LZO_FOUND) if (LZO_FOUND)
include_directories(${LZO_INCLUDE_DIR}) include_directories(${LZO_INCLUDE_DIR})
target_link_libraries (${PROJECT_NAME} ${LZO_LIBRARIES}) target_link_libraries(${PROJECT_NAME} ${LZO_LIBRARIES})
endif (LZO_FOUND) endif (LZO_FOUND)
# Pthreads # Pthreads
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package (Threads REQUIRED) find_package(Threads REQUIRED)
target_link_libraries (${PROJECT_NAME} Threads::Threads) target_link_libraries(${PROJECT_NAME} Threads::Threads)
# LibBSD # LibBSD
target_link_libraries(${PROJECT_NAME} bsd) target_link_libraries(${PROJECT_NAME} bsd)