diff --git a/.github/workflows/automatic_release.yml b/.github/workflows/automatic_release.yml index 24e3ad6..3065363 100644 --- a/.github/workflows/automatic_release.yml +++ b/.github/workflows/automatic_release.yml @@ -88,7 +88,7 @@ jobs: run: | mv linux/sniffcraft sniffcraft-linux-${{ steps.mc-version.outputs.version }} mv windows/sniffcraft.exe sniffcraft-windows-${{ steps.mc-version.outputs.version }}.exe - mv macos/sniffcraft sniffcraft-macos-${{ steps.mc-version.outputs.version }} + mv macos/sniffcraft.zip sniffcraft-macos-universal-${{ steps.mc-version.outputs.version }}.zip - name: Remove old latest release run: gh release delete latest --repo ${{ github.repository }} --cleanup-tag -y @@ -100,7 +100,7 @@ jobs: gh release create latest sniffcraft-linux-${{ steps.mc-version.outputs.version }} sniffcraft-windows-${{ steps.mc-version.outputs.version }}.exe - sniffcraft-macos-${{ steps.mc-version.outputs.version }} + sniffcraft-macos-universal-${{ steps.mc-version.outputs.version }}.zip --repo ${{ github.repository }} --latest -F release_note.txt diff --git a/.github/workflows/sniffcraft_build.yml b/.github/workflows/sniffcraft_build.yml index 953c672..8f2c887 100644 --- a/.github/workflows/sniffcraft_build.yml +++ b/.github/workflows/sniffcraft_build.yml @@ -87,8 +87,21 @@ jobs: GH_TOKEN: ${{ github.token }} - name: Upload artifact + if: ${{ inputs.os != 'macos-latest' }} uses: actions/upload-artifact@v4 with: name: sniffcraft-${{ runner.os }} path: ${{ github.workspace }}/bin/sniffcraft* retention-days: 1 + + - name: Archive macOS application + if: ${{ inputs.os == 'macos-latest' }} + run: cd ${{ github.workspace }}/bin && zip -r sniffcraft.zip SniffCraft.app + + - name: Upload macOS artifact + if: ${{ inputs.os == 'macos-latest' }} + uses: actions/upload-artifact@v4 + with: + name: sniffcraft-${{ runner.os }} + path: ${{ github.workspace }}/bin/sniffcraft.zip + retention-days: 1 diff --git a/.gitignore b/.gitignore index 0948008..954e577 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,11 @@ bin/ build/ -lib/ \ No newline at end of file +lib/ + +.vscode/ +.idea/ + +# CLion build directory +/cmake-** + +.DS_Store diff --git a/sniffcraft/CMakeLists.txt b/sniffcraft/CMakeLists.txt index a2632e1..c43b109 100644 --- a/sniffcraft/CMakeLists.txt +++ b/sniffcraft/CMakeLists.txt @@ -108,6 +108,15 @@ if (MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded") endif(MSVC) +if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE TRUE) + set_target_properties(${PROJECT_NAME} PROPERTIES + OUTPUT_NAME "SniffCraft" + XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES + XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY libc++ + ) +endif() + # Add Asio target_link_libraries(${PROJECT_NAME} PUBLIC asio) target_compile_definitions(${PROJECT_NAME} PUBLIC ASIO_STANDALONE) diff --git a/sniffcraft/src/conf.cpp b/sniffcraft/src/conf.cpp index 52ca976..21c287f 100644 --- a/sniffcraft/src/conf.cpp +++ b/sniffcraft/src/conf.cpp @@ -45,12 +45,20 @@ ProtocolCraft::Json::Value Conf::LoadConf() { if (conf_path.empty()) { +#if defined(__APPLE__) + conf_path = "/Users/" + std::string(std::getenv("USER")) + "/Library/Application Support/SniffCraft/conf.json"; +#else conf_path = "conf.json"; +#endif } // Create file if it doesn't exist if (!std::filesystem::exists(conf_path)) { + std::filesystem::path parent_directory = std::filesystem::path(conf_path).parent_path(); + if (!parent_directory.empty()) { + std::filesystem::create_directories(parent_directory); + } std::ofstream outfile(conf_path, std::ios::out); outfile << ProtocolCraft::Json::Value().Dump(4); }