Skip to content

Commit

Permalink
Migrant to vcpkg Manifest Mode; Update CMakeLists.txt for macOS; Clea…
Browse files Browse the repository at this point in the history
…n up workflow
  • Loading branch information
UjuiUjuMandan committed Nov 22, 2023
1 parent bade2ab commit e1f12b6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 43 deletions.
54 changes: 14 additions & 40 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,24 @@ on:
branches: [ '*' ]

jobs:
build-macos:
runs-on: macos-latest
job:
name: build-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest]

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup CMake and dependencies on macOS
if: ${{ runner.os == 'macOS' }}
run: |
brew install cmake libevent libpcap libsodium openssl
- name: Compile and configure Pcap_DNSProxy
run: |
cd Source/Auxiliary/Scripts
chmod +x CMake_Build.sh
# Workaround from https://stackoverflow.com/a/30895165
export C_INCLUDE_PATH=/usr/local/include
export CPLUS_INCLUDE_PATH=/usr/local/include
# Fuck Xcode
./CMake_Build.sh
- name: Create artifacts
uses: actions/upload-artifact@v3
with:
name: Pcap_DNSProxy-bin-macOS
path: Source/Release/

build-ubuntu:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup CMake, GCC, and dependencies
- name: Setup CMake, GCC, and dependencies on Ubuntu
if ${{ runner.os == 'Linux' }}
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ cmake libevent-dev libpcap-dev libsodium-dev libssl-dev
Expand All @@ -53,7 +38,7 @@ jobs:
- name: Create artifacts
uses: actions/upload-artifact@v3
with:
name: Pcap_DNSProxy-bin-Ubuntu
name: Pcap_DNSProxy-bin-${{ runner.os` }}
path: Source/Release/

build-windows:
Expand Down Expand Up @@ -81,7 +66,7 @@ jobs:
!${{ env.VCPKG_ROOT }}\downloads
Source/Tools
key: |
${{ runner.os }}-ncpkg-dependencies-${{ hashFiles('.github/workflows/build.yml') }}
${{ hashFiles( 'vcpkg.json' ) }}-${{ runner.os }}-cache-key-v1
- name: Install vcpkg
if: ${{ steps.vcpkg-cache.outputs.cache-hit != 'true' }}
Expand All @@ -95,17 +80,6 @@ jobs:
cd vcpkg
.\vcpkg integrate install
- name: Install dependencies with vcpkg
if: ${{ steps.vcpkg-cache.outputs.cache-hit != 'true' }}
run: |
cd vcpkg
.\vcpkg install libevent libpcap libsodium openssl
.\vcpkg remove libpcap
.\vcpkg install winpcap
.\vcpkg install libevent:x86-windows libpcap:x86-windows libsodium:x86-windows openssl:x86-windows
.\vcpkg remove libpcap:x86-windows
.\vcpkg install winpcap:x86-windows
- name: Locate dependencies
run: |
mkdir Source/Dependency
Expand All @@ -125,7 +99,7 @@ jobs:
cp -Recurse vcpkg/packages/libpcap_x64-windows/include/* Source/Dependency/WinPcap/Include
cp -Recurse vcpkg/packages/winpcap_x64-windows/lib/Packet.lib Source/Dependency/WinPcap/Packet_x64.lib
cp -Recurse vcpkg/packages/winpcap_x64-windows/lib/wpcap.lib Source/Dependency/WinPcap/WPCAP_X64.lib
msbuild Source/Pcap_DNSProxy.sln /p:Configuration=Release /p:Platform=x64 /p:AdditionalIncludeDirectories="$GITHUB_WORKSPACE\vcpkg\installed\x64-windows\include"
msbuild Source/Pcap_DNSProxy.sln /p:Configuration=Release /p:Platform=x64 /p:AdditionalIncludeDirectories="$GITHUB_WORKSPACE\build\vcpkg_installed\x64-windows\include"
- name: Build the solution for x86
run: |
Expand All @@ -136,7 +110,7 @@ jobs:
cp -Recurse -Force vcpkg/packages/libpcap_x86-windows/include/* Source/Dependency/WinPcap/Include
cp -Recurse -Force vcpkg/packages/winpcap_x86-windows/lib/Packet.lib Source/Dependency/WinPcap/Packet_x86.lib
cp -Recurse -Force vcpkg/packages/winpcap_x86-windows/lib/wpcap.lib Source/Dependency/WinPcap/WPCAP_X86.lib
msbuild Source/Pcap_DNSProxy.sln /p:Configuration=Release /p:Platform=x86 /p:AdditionalIncludeDirectories="$GITHUB_WORKSPACE\vcpkg\installed\x86-windows\include"
msbuild Source/Pcap_DNSProxy.sln /p:Configuration=Release /p:Platform=x86 /p:AdditionalIncludeDirectories="$GITHUB_WORKSPACE\build\vcpkg_installed\x86-windows\include"
- name: Download Support
if: ${{ steps.vcpkg-cache.outputs.cache-hit != 'true' }}
Expand Down
6 changes: 3 additions & 3 deletions Source/Pcap_DNSProxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ ENDIF(STATIC_LIB)
find_package(Threads REQUIRED)
target_link_libraries(Pcap_DNSProxy ${CMAKE_THREAD_LIBS_INIT})
find_library(LIBEVENT_LIBRARIES event_core)
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
include_directories("/usr/local/include")
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
include_directories("/usr/local/include")
ENDIF()
target_link_libraries(Pcap_DNSProxy ${LIBEVENT_LIBRARIES})
## Libraries needed
IF(ENABLE_LIBSODIUM)
Expand Down
14 changes: 14 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Pcap_DNSProxy",
"version-string": "0.0.1",
"dependencies": [
"libevent",
"libpcap",
"libsodium",
"winpcap",
"libevent:x86-windows",
"libpcap:x86-windows",
"libsodium:x86-windows",
"winpcap:x86-windows"
]
}

0 comments on commit e1f12b6

Please sign in to comment.