From 3868340c28f14f79554bf72d215591b7d55f2c40 Mon Sep 17 00:00:00 2001 From: vaguue Date: Tue, 20 Aug 2024 01:08:39 +0300 Subject: [PATCH] testing ci --- .github/workflows/ci.yaml | 9 +++++++++ CMakeLists.txt | 25 ++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 397a1be..3e7fb18 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -70,6 +70,15 @@ jobs: # # for this ridiculous `&` syntax alone, I'd rather use COBOL than Powershell # # see https://stackoverflow.com/a/1674950/5637701 # & "$env:TEMP/npcap-oem.exe" /S + - name: Install npcap on Windows (step 2) + if: matrix.os == 'windows-latest' + run: | + set NPCAP_FILE=npcap-0.96.exe + curl -L https://npcap.com/dist/%NPCAP_FILE% --output %NPCAP_FILE% + %NPCAP_FILE% /S /winpcap_mode + xcopy C:\Windows\System32\Npcap\*.dll C:\Windows\System32 + xcopy C:\Windows\SysWOW64\Npcap\*.dll C:\Windows\SysWOW64 + shell: cmd - name: Submodule update run: git submodule update --init --recursive shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b7e5fd..01c4324 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,9 +7,16 @@ execute_process(COMMAND node -p "require('node-addon-api').include" OUTPUT_VARIABLE NODE_ADDON_API_DIR ) +execute_process(COMMAND node -p "require('os').arch()" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE _CURRENT_ARCH + ) + string(REGEX REPLACE "[\r\n\"]" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR}) +string(REGEX REPLACE "[\r\n\"]" "" _CURRENT_ARCH ${_CURRENT_ARCH}) Message("NODE_ADDON_API_DIR: " ${NODE_ADDON_API_DIR}) +Message("_CURRENT_ARCH: " ${_CURRENT_ARCH}) include_directories(${CMAKE_JS_INC}) @@ -35,7 +42,23 @@ endif() if(PCAP_ROOT) target_include_directories(${PROJECT_NAME} PRIVATE "${PCAP_ROOT}/Include") - target_link_libraries(${PROJECT_NAME} PUBLIC "${PCAP_ROOT}/Lib/Packet.lib" "${PCAP_ROOT}/Lib/wpcap.lib") + + set(PACKET_LIB "${PCAP_ROOT}/Lib/${_CURRENT_ARCH}/Packet.lib") + set(WPCAP_LIB "${PCAP_ROOT}/Lib/${_CURRENT_ARCH}/wpcap.lib") + + file(TO_NATIVE_PATH "${PACKET_LIB}" PACKET_LIB) + file(TO_NATIVE_PATH "${WPCAP_LIB}" WPCAP_LIB) + + message("PACKET_LIB: " ${PACKET_LIB}) + message("WPCAP_LIB: " ${WPCAP_LIB}) + + if(EXISTS ${PACKET_LIB} AND EXISTS ${WPCAP_LIB}) + message("LINKING WITH: ${PACKET_LIB} ${WPCAP_LIB}") + #target_link_libraries(${PROJECT_NAME} PUBLIC "${PACKET_LIB}" "${WPCAP_LIB}") + else() + message(FATAL_ERROR "Required libraries not found. Ensure that PCAP_ROOT is set correctly.") + endif() + endif() # PcapPlusPlus