Skip to content

Commit

Permalink
Update CMakeLists.txt for macOS; Clean up workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
UjuiUjuMandan committed Nov 22, 2023
1 parent bade2ab commit 409c1b6
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 147 deletions.
244 changes: 99 additions & 145 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,172 +7,126 @@ on:
branches: [ '*' ]

jobs:
build-macos:
runs-on: macos-latest
job:
env:
VCPKG_ROOT: '${{ github.workspace }}\vcpkg'
name: build-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-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
- name: Setup CMake, GCC, and dependencies on Ubuntu
if: ${{ runner.os == 'Linux' }}
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
sudo apt-get update
sudo apt-get install -y gcc g++ cmake libevent-dev libpcap-dev libsodium-dev libssl-dev
- name: Create artifacts
uses: actions/upload-artifact@v3
with:
name: Pcap_DNSProxy-bin-macOS
path: Source/Release/
- name: Install MSBuild
if: ${{ runner.os == 'Windows' }}
uses: microsoft/[email protected]

build-ubuntu:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Restore vcpkg and its artifacts
if: ${{ runner.os == 'Windows' }}
uses: actions/cache@v3
id: vcpkg-cache
with:
path: |
${{ env.VCPKG_ROOT }}
${{ env.VCPKG_ROOT }}\packages
!${{ env.VCPKG_ROOT }}\.git
!${{ env.VCPKG_ROOT }}\buildtrees
!${{ env.VCPKG_ROOT }}\downloads
Source/Tools
key: |
${{ hashFiles( 'vcpkg.bat' ) }}-${{ runner.os }}-cache-key-v1
- name: Install vcpkg and dependencies on Windows
if: ${{ runner.os == 'Windows' && steps.vcpkg-cache.outputs.cache-hit != 'true' }}
run: |
git clone https://github.com/Microsoft/vcpkg.git
.\vcpkg\bootstrap-vcpkg.bat
.\vcpkg.bat
.\vcpkg\vcpkg integrate install
- name: Setup CMake, GCC, and dependencies
- name: Build the solution
if: ${{ runner.os == 'Windows' }}
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ cmake libevent-dev libpcap-dev libsodium-dev libssl-dev
mkdir Source/Dependency
mkdir Source/Dependency/LibEvent
mkdir Source/Dependency/LibEvent/Include_Windows
mkdir Source/Dependency/LibSodium
mkdir Source/Dependency/LibSodium/Include_Windows
mkdir Source/Dependency/WinPcap
mkdir Source/Dependency/WinPcap/Include
cp -Recurse vcpkg/packages/libevent_x64-windows/include/* Source/Dependency/LibEvent/Include_Windows
cp -Recurse vcpkg/packages/libevent_x64-windows/lib/event_core.lib Source/Dependency/LibEvent/LibEvent_Core_x64.lib
cp -Recurse vcpkg/packages/libsodium_x64-windows/include/* Source/Dependency/LibSodium/Include_Windows
cp -Recurse vcpkg/packages/libsodium_x64-windows/lib/libsodium.lib Source/Dependency/LibSodium/LibSodium_x64.lib
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"
cp -Recurse -Force vcpkg/packages/libevent_x86-windows/include/* Source/Dependency/LibEvent/Include_Windows
cp -Recurse -Force vcpkg/packages/libevent_x86-windows/lib/event_core.lib Source/Dependency/LibEvent/LibEvent_Core_x86.lib
cp -Recurse -Force vcpkg/packages/libsodium_x86-windows/include/* Source/Dependency/LibSodium/Include_Windows
cp -Recurse -Force vcpkg/packages/libsodium_x86-windows/lib/libsodium.lib Source/Dependency/LibSodium/LibSodium_x86.lib
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"
- name: Compile and configure Pcap_DNSProxy
run: |
cd Source/Auxiliary/Scripts
chmod +x CMake_Build.sh
./CMake_Build.sh
- name: Download Support for Windows
if: ${{ runner.os == 'Windows' && steps.vcpkg-cache.outputs.cache-hit != 'true' }}
run: |
cd Source
mkdir Tools
mkdir Tools/Support
Invoke-WebRequest https://www.winpcap.org/install/bin/WinPcap_4_1_3.exe -OutFile Tools/WinPcap_4.1.3.exe
Invoke-WebRequest https://westmesatech.com/files/sst27.zip -OutFile Tools/sst27.zip
Expand-Archive Tools/sst27.zip -DestinationPath Tools/Support
Invoke-WebRequest https://www.fourmilab.ch/md5/md5.zip -OutFile Tools/md5.zip
Expand-Archive Tools/md5.zip -DestinationPath Tools/Support
Invoke-WebRequest https://github.com/mbuilov/sed-windows/raw/master/sed-4.9-x86.exe -OutFile Tools/Support/sed.exe
- name: Package release for Windows
if: ${{ runner.os == 'Windows' }}
run: |
cd Source
mkdir Release/x64
cp -Recurse x64/Release/* Release/x64
cp Auxiliary/ExampleConfig/Config.ini Release
cp Auxiliary/ExampleConfig/Hosts.ini Release
cp Auxiliary/ExampleConfig/IPFilter.ini Release
cp Auxiliary/ExampleConfig/Routing.txt Release
cp Auxiliary/ExampleConfig/WhiteList.txt Release
cp Auxiliary/ExampleConfig/ServiceControl.bat Release
mkdir Release/Tools
cp -Recurse Auxiliary/Tools/* Release/Tools
cp Tools/WinPcap_4.1.3.exe Release/Tools
mkdir Release/Tools/Support
cp Tools/Support/CCase.exe Release/Tools/Support
cp (Get-Command curl.exe).Path Release/Tools/Support
cp Tools/Support/md5.exe Release/Tools/Support
cp Tools/Support/sed.exe Release/Tools/Support
- 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:
env:
VCPKG_ROOT: '${{ github.workspace }}\vcpkg'

runs-on: windows-latest

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

- name: Install MSBuild
uses: microsoft/[email protected]

- name: Restore vcpkg and its artifacts
uses: actions/cache@v3
id: vcpkg-cache
with:
path: |
${{ env.VCPKG_ROOT }}
${{ env.VCPKG_ROOT }}\packages
!${{ env.VCPKG_ROOT }}\.git
!${{ env.VCPKG_ROOT }}\buildtrees
!${{ env.VCPKG_ROOT }}\downloads
Source/Tools
key: |
${{ runner.os }}-ncpkg-dependencies-${{ hashFiles('.github/workflows/build.yml') }}
- name: Install vcpkg
if: ${{ steps.vcpkg-cache.outputs.cache-hit != 'true' }}
run: |
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
- name: Intergrate vcpkg with MSBuild
run: |
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
mkdir Source/Dependency/LibEvent
mkdir Source/Dependency/LibEvent/Include_Windows
mkdir Source/Dependency/LibSodium
mkdir Source/Dependency/LibSodium/Include_Windows
mkdir Source/Dependency/WinPcap
mkdir Source/Dependency/WinPcap/Include
- name: Build the solution for x64
run: |
cp -Recurse vcpkg/packages/libevent_x64-windows/include/* Source/Dependency/LibEvent/Include_Windows
cp -Recurse vcpkg/packages/libevent_x64-windows/lib/event_core.lib Source/Dependency/LibEvent/LibEvent_Core_x64.lib
cp -Recurse vcpkg/packages/libsodium_x64-windows/include/* Source/Dependency/LibSodium/Include_Windows
cp -Recurse vcpkg/packages/libsodium_x64-windows/lib/libsodium.lib Source/Dependency/LibSodium/LibSodium_x64.lib
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"
- name: Build the solution for x86
run: |
cp -Recurse -Force vcpkg/packages/libevent_x86-windows/include/* Source/Dependency/LibEvent/Include_Windows
cp -Recurse -Force vcpkg/packages/libevent_x86-windows/lib/event_core.lib Source/Dependency/LibEvent/LibEvent_Core_x86.lib
cp -Recurse -Force vcpkg/packages/libsodium_x86-windows/include/* Source/Dependency/LibSodium/Include_Windows
cp -Recurse -Force vcpkg/packages/libsodium_x86-windows/lib/libsodium.lib Source/Dependency/LibSodium/LibSodium_x86.lib
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"
- name: Download Support
if: ${{ steps.vcpkg-cache.outputs.cache-hit != 'true' }}
run: |
cd Source
mkdir Tools
mkdir Tools/Support
Invoke-WebRequest https://www.winpcap.org/install/bin/WinPcap_4_1_3.exe -OutFile Tools/WinPcap_4.1.3.exe
Invoke-WebRequest https://westmesatech.com/files/sst27.zip -OutFile Tools/sst27.zip
Expand-Archive Tools/sst27.zip -DestinationPath Tools/Support
Invoke-WebRequest https://www.fourmilab.ch/md5/md5.zip -OutFile Tools/md5.zip
Expand-Archive Tools/md5.zip -DestinationPath Tools/Support
Invoke-WebRequest https://github.com/mbuilov/sed-windows/raw/master/sed-4.9-x86.exe -OutFile Tools/Support/sed.exe
- name: Package release
run: |
cd Source
mkdir Release/x64
cp -Recurse x64/Release/* Release/x64
cp Auxiliary/ExampleConfig/Config.ini Release
cp Auxiliary/ExampleConfig/Hosts.ini Release
cp Auxiliary/ExampleConfig/IPFilter.ini Release
cp Auxiliary/ExampleConfig/Routing.txt Release
cp Auxiliary/ExampleConfig/WhiteList.txt Release
cp Auxiliary/ExampleConfig/ServiceControl.bat Release
mkdir Release/Tools
cp -Recurse Auxiliary/Tools/* Release/Tools
cp Tools/WinPcap_4.1.3.exe Release/Tools
mkdir Release/Tools/Support
cp Tools/Support/CCase.exe Release/Tools/Support
cp (Get-Command curl.exe).Path Release/Tools/Support
cp Tools/Support/md5.exe Release/Tools/Support
cp Tools/Support/sed.exe Release/Tools/Support
- name: Create artifacts
uses: actions/upload-artifact@v3
with:
name: Pcap_DNSProxy-bin-Windows
path: Source/Release
4 changes: 2 additions & 2 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")
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
include_directories("/usr/local/include")
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
ENDIF()
target_link_libraries(Pcap_DNSProxy ${LIBEVENT_LIBRARIES})
## Libraries needed
IF(ENABLE_LIBSODIUM)
Expand Down
7 changes: 7 additions & 0 deletions vcpkg.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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

0 comments on commit 409c1b6

Please sign in to comment.