diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5d87630 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,56 @@ +name: Automated Release Build + +on: + pull_request: + branches: + - main + types: [opened, synchronize, reopened] + # push: + # branches: + # - main + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Fetch the official vcpkg repo directly + - name: Checkout vcpkg + uses: actions/checkout@v4 + with: + repository: "Microsoft/vcpkg" + path: "vcpkg" + + - name: Bootstrap vcpkg + run: | + ./vcpkg/bootstrap-vcpkg.sh + shell: bash + + # Set up GitHub Actions Cache for vcpkg binary caching + - name: Setup vcpkg Cache + uses: actions/cache@v4 + with: + path: | + ~/.cache/vcpkg + ~/.vcpkg + key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} + restore-keys: | + ${{ runner.os }}-vcpkg- + + # Configure CMake passing the vcpkg toolchain file + - name: Configure CMake with New Version + run: | + cmake -B build -S . \ + -DCMAKE_TOOLCHAIN_FILE="./vcpkg/scripts/buildsystems/vcpkg.cmake" \ + -DCMAKE_BUILD_TYPE=Release + + # Build the C++ Binary + - name: Build C++ Binary + run: cmake --build build --config Release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index caecf2d..ba0cabf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,18 +16,29 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - - - name: Configure Git Safe Directory - run: git config --global --add safe.directory '*' - # Set up vcpkg executable and binary cache - - name: Setup vcpkg - uses: lukka/run-vcpkg@v11 + # Fetch the official vcpkg repo directly + - name: Checkout vcpkg + uses: actions/checkout@v4 + with: + repository: "Microsoft/vcpkg" + path: "vcpkg" + + - name: Bootstrap vcpkg + run: | + ./vcpkg/bootstrap-vcpkg.sh + shell: bash + + # Set up GitHub Actions Cache for vcpkg binary caching + - name: Setup vcpkg Cache + uses: actions/cache@v4 with: - # Uses the vcpkg.json in the repository root - vcpkgDirectory: '${{ github.workspace }}/../vcpkg' - vcpkgJsonGlob: 'vcpkg.json' + path: | + ~/.cache/vcpkg + ~/.vcpkg + key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} + restore-keys: | + ${{ runner.os }}-vcpkg- # Automatically calculate the next version string based on commits - name: Calculate Next Version @@ -43,7 +54,7 @@ jobs: - name: Configure CMake with New Version run: | cmake -B build -S . \ - -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \ + -DCMAKE_TOOLCHAIN_FILE="./vcpkg/scripts/buildsystems/vcpkg.cmake" \ -DBUILD_VERSION="${{ steps.semver.outputs.version }}" \ -DCMAKE_BUILD_TYPE=Release diff --git a/CMakeLists.txt b/CMakeLists.txt index adb18dd..f4d5f40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,8 +28,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # Find Packages - vcpkg provides standard CMake target configs find_package(asio CONFIG REQUIRED) find_package(OpenSSL REQUIRED) -find_package(pugixml CONFIG REQUIRED) -find_package(threads REQUIRED) # Append cmake directory to module path list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") @@ -41,46 +39,41 @@ set(USER_MODULES_DIR "" CACHE PATH "Directory containing custom XMPP user module find_package(UserModules QUIET) # Modular Build Options -option(ENABLE_STORAGE_MEMORY "Include in-memory storage backend" ON) -option(ENABLE_STORAGE_SQLITE "Include SQLite storage backend" OFF) -option(ENABLE_STORAGE_POSTGRES "Include PostgreSQL storage backend" OFF) +# option(ENABLE_STORAGE_MEMORY "Include in-memory storage backend" ON) +# option(ENABLE_STORAGE_SQLITE "Include SQLite storage backend" OFF) +# option(ENABLE_STORAGE_POSTGRES "Include PostgreSQL storage backend" OFF) # Core Server Target -add_library(xtrpg_core STATIC - src/core/C2SServer.cpp - src/core/S2SServer.cpp - src/core/ModuleRegistry.cpp -) -target_include_directories(xtrpg_core PUBLIC include) +# add_library(xtrpg_core STATIC +# ) +# target_include_directories(xtrpg_core PUBLIC include) # Link imported targets across platforms -target_link_libraries(xtrpg_core PUBLIC - asio::asio - OpenSSL::SSL - OpenSSL::Crypto - pugixml::pugixml - Threads::Threads -) +# target_link_libraries(xtrpg_core PUBLIC +# asio::asio +# OpenSSL::SSL +# OpenSSL::Crypto +# ) # Platform-specific OS network primitives for raw sockets -if(WIN32) - target_link_libraries(xtrpg_core PUBLIC ws2_32 wsock32 crypt32) -elseif(UNIX AND NOT APPLE) - target_link_libraries(xtrpg_core PUBLIC pthread dl) -endif() +# if(WIN32) +# target_link_libraries(xtrpg_core PUBLIC ws2_32 wsock32 crypt32) +# elseif(UNIX AND NOT APPLE) +# target_link_libraries(xtrpg_core PUBLIC pthread dl) +# endif() # Conditional Storage Compilation -if(ENABLE_STORAGE_SQLITE) - find_package(SQLite3 REQUIRED) - target_sources(xtrpg_core PRIVATE src/storage/SQLiteBackend.cpp) - target_compile_definitions(xtrpg_core PUBLIC HAS_STORAGE_SQLITE) - target_link_libraries(xtrpg_core PRIVATE SQLite::SQLite3) -endif() - -if(ENABLE_STORAGE_MEMORY) - target_sources(xtrpg_core PRIVATE src/storage/MemoryBackend.cpp) - target_compile_definitions(xtrpg_core PUBLIC HAS_STORAGE_MEMORY) -endif() +# if(ENABLE_STORAGE_SQLITE) +# find_package(SQLite3 REQUIRED) +# target_sources(xtrpg_core PRIVATE src/storage/SQLiteBackend.cpp) +# target_compile_definitions(xtrpg_core PUBLIC HAS_STORAGE_SQLITE) +# target_link_libraries(xtrpg_core PRIVATE SQLite::SQLite3) +# endif() + +# if(ENABLE_STORAGE_MEMORY) +# target_sources(xtrpg_core PRIVATE src/storage/MemoryBackend.cpp) +# target_compile_definitions(xtrpg_core PUBLIC HAS_STORAGE_MEMORY) +# endif() # Include discovered modules into the build if(UserModules_FOUND) @@ -96,10 +89,10 @@ endif() # Executable Target add_executable(xtrpg_cpp_server apps/main.cpp) -target_link_libraries(xtrpg_cpp_server PRIVATE xtrpg_core) +# target_link_libraries(xtrpg_cpp_server PRIVATE xtrpg_core) target_include_directories(xtrpg_cpp_server PRIVATE ${CMAKE_BINARY_DIR}/generated) # If modules produce targets registered via xmpp_register_user_module if(USER_MODULE_TARGETS) - target_link_libraries(xmpp_server PRIVATE ${USER_MODULE_TARGETS}) + target_link_libraries(xtrpg_cpp_server PRIVATE ${USER_MODULE_TARGETS}) endif() diff --git a/vcpkg.json b/vcpkg.json index 069b655..7f1cca4 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,7 +1,6 @@ { "name": "xtrpg-cpp-server", "version-string": "0.1.0", - "builtin-baseline": "501db0f171095204123565f4262ae7d17482ea05", "dependencies": [ "asio", "openssl"