Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

winpcap: add winpcap/4.1.3 recipe #6348

Closed
wants to merge 3 commits into from

Conversation

madebr
Copy link
Contributor

@madebr madebr commented Jul 15, 2021

Specify library name and version: winpcap/4.1.3

  • Tested on Linux
  • On Windows:
    • Needs the Windows DDK (=Driver Development Kit)
    • Fails to build on my machine because of a missing header inside the DDK (MSVC cannot find ndis/types.h). Feedback welcome.
    • Not tested with mingw
  • other operating systems: not tested. The recipe raises an error. PRs are welcome to add macos support.

Closes bincrafters/community#1395


  • I've read the guidelines for contributing.
  • I've followed the PEP8 style guides for Python code in the recipes.
  • I've used the latest Conan client version.
  • I've tried at least one configuration locally with the
    conan-center hook activated.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@madebr madebr force-pushed the winpcap_recipe branch 2 times, most recently from 37fd012 to 8642532 Compare July 15, 2021 04:23
@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@SpaceIm
Copy link
Contributor

SpaceIm commented Jul 15, 2021

Did you write all the CMake files from scratch or does it come from a fork?

@madebr
Copy link
Contributor Author

madebr commented Jul 15, 2021

I wrote them from scratch.
FindWDK.cmake is the only file I copied from the interwebs. The file has its license at the top.

@madebr
Copy link
Contributor Author

madebr commented Jul 15, 2021

I need to investigate why Windows is not built on c3i.

Comment on lines +48 to +58
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
self.options.turbocap = True
self.options.capture_type = "win32"
elif self.settings.os == "Linux":
self.options.capture_type = "linux"
if self.settings.os != "Linux":
del self.options.bluetooth
del self.options.usb_sniffing
del self.options.usb_sniffing_device
Copy link
Contributor Author

@madebr madebr Jul 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jgsogo
c3i fails to build on MSVC@Windows.
See #6348 (comment)
c3i says my recipe emits an ConanInvalidConfiguration when os=Windows (the logs don't tell me).

The values inside default_options are indeed invalid on Windows,
but they are converted to valid options in config_options.

/* prototype of the packet handler */
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data);

int main()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test package is interactive. It should be made non-interactive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIXME: borrow test package from bincrafters/community#1395

Comment on lines 76 to 80
if tools.os_info.is_windows:
self.build_requires("winflexbison/2.5.24")
else:
self.build_requires("bison/3.7.1")
self.build_requires("flex/2.6.4")
Copy link
Contributor

@SpaceIm SpaceIm Jul 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is the issue with windows, because it is first evaluated on a linux machine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's a build requirement. I thought those didn't influence the package id?

Copy link
Contributor

@SpaceIm SpaceIm Jul 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be more robust (2 profiles in the first condition, 1 profile in the second):

if (hasattr(self, "settings_build") and self.settings_build.os == "Windows) or (not hasattr(self, "settings_build") and self.settings.os == "Windows")

When 1 profile will behave like 2 profiles, it could be replaced by self.settings_build.os == "Windows

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Let's try the settings_build approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's a build requirement. I thought those didn't influence the package id?

Not related to package id. In CI of CCI, a linux machine runs some tests first, and tools.os_info.is_windows is always False. @jgsogo can explain better than me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. In CCI we first compute the packageIDs for all the configurations (this computation runs on a Linux machine) so we can remove duplicates and those that are invalid-config. Then, we will use win/linux/mac nodes to build the libraries.

If (running in Linux) Conan computes an invalid-config for a given configuration (a Windows one) we won't try to build that configuration, we will just report it is invalid. For this reason, it is very important that everything used in a recipe is provided as input (via profiles) and nothing is guessed... and this is mandatory for the source lines that are executed while computed the package-id in the Linux machine (tomorrow it could be a Windows node or Macos).

Although build-requires will not affect the package-id, while computing if it is a valid configuration, we also take into account the build-requires that will be required to build. If these build-requires are not available, then the configuration is also removed.

TL;DR; toos.os_info is evil outside build step (build() always takes place in the build machine).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reply.
I know you had to write this message a lot already. 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this go in the FAQ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See conan-io/hooks#320 for a first attempt to implement this into a hook.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! this is supper helpful to have and know

@conan-center-bot
Copy link
Collaborator

Failure in build 7 (5b2a09a45baed1f085aca5d534f7357c8d45d3a6):

  • winpcap/4.1.3@:
    CI failed to create some packages (All logs)

    Logs for packageID e5375efbdfdd123f7f396cfe34b84c596e22896e:
    [settings]
    arch=x86_64
    arch_build=x86_64
    build_type=Release
    compiler=Visual Studio
    compiler.runtime=MT
    compiler.version=14
    os=Windows
    os_build=Windows
    [options]
    winpcap:shared=False
    
    [...]
    winflexbison/2.5.24: Setting YACC environment variable: C:/J/w/BuildSingleReference@2/.conan/data/winflexbison/2.5.24/_/_/package/df81ad20137149d7a51276fd3e24009b45e5964a/bin/win_bison -y
    [HOOK - conan-center.py] post_package_info(): [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)] OK
    [HOOK - conan-center.py] post_package_info(): [LIBRARY DOES NOT EXIST (KB-H054)] OK
    winpcap/4.1.3: Applying build-requirement: winflexbison/2.5.24
    winpcap/4.1.3: Copying sources to build folder
    winpcap/4.1.3: Building your package in C:\J\w\BuildSingleReference@2\.conan\data\winpcap\4.1.3\_\_\build\e5375efbdfdd123f7f396cfe34b84c596e22896e
    winpcap/4.1.3: Generator cmake created conanbuildinfo.cmake
    [HOOK - conan-center.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] 'fPIC' option not found
    [HOOK - conan-center.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] OK
    winpcap/4.1.3: Calling build()
    
    ----Running------
    > cd C:\J\w\BuildSingleReference@2\.conan\data\winpcap\4.1.3\_\_\build\e5375efbdfdd123f7f396cfe34b84c596e22896e && cmake -G "Visual Studio 14 2015 Win64" -DCONAN_LINK_RUNTIME="/MT" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="14" -DCONAN_CXX_FLAGS="/MP16" -DCONAN_C_FLAGS="/MP16" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="C:\J\w\BuildSingleReference@2\.conan\data\winpcap\4.1.3\_\_\package\e5375efbdfdd123f7f396cfe34b84c596e22896e" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DWINPCAP_CAPTURE_TYPE="win32" -DWINPCAP_REMOTE="True" -DWINPCAP_TURBOCAP="True" -DWINPCAP_BLUETOOTH="False" -DWINPCAP_USB="False" -DWINPCAP_USB_DEVICE="" -Wno-dev C:\J\w\BuildSingleReference@2\.conan\data\winpcap\4.1.3\_\_\build\e5375efbdfdd123f7f396cfe34b84c596e22896e
    -----------------
    -- Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.17763.
    -- The C compiler identification is MSVC 19.0.24215.1
    -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
    -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Conan: called by CMake conan helper
    -- Conan: called inside local cache
    -- Conan: Adjusting output directories
    -- Conan: Using cmake global configuration
    -- Conan: Adjusting default RPATHs Conan policies
    -- Conan: Adjusting language standard
    -- This project seems to be plain C, using 'MSVC' compiler
    -- Configuring incomplete, errors occurred!
    See also "C:/J/w/BuildSingleReference@2/.conan/data/winpcap/4.1.3/_/_/build/e5375efbdfdd123f7f396cfe34b84c596e22896e/CMakeFiles/CMakeOutput.log".
    winpcap/4.1.3: 
    winflexbison/2.5.24: WARN: Lib folder doesn't exist, can't collect libraries: C:\J\w\BuildSingleReference@2\.conan\data\winflexbison\2.5.24\_\_\package\df81ad20137149d7a51276fd3e24009b45e5964a\lib
    winpcap/4.1.3: WARN: Build folder is dirty, removing it: C:\J\w\BuildSingleReference@2\.conan\data\winpcap\4.1.3\_\_\build\e5375efbdfdd123f7f396cfe34b84c596e22896e
    CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
      Could NOT find WDK (missing: WDK_LATEST_NTDDK_FILE)
    Call Stack (most recent call first):
      C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
      cmake/FindWDK.cmake:49 (find_package_handle_standard_args)
      cmake/packetntx.cmake:8 (find_package)
      CMakeLists.txt:12 (include)
    
    
    winpcap/4.1.3: ERROR: Package 'e5375efbdfdd123f7f396cfe34b84c596e22896e' build failed
    winpcap/4.1.3: WARN: Build folder C:\J\w\BuildSingleReference@2\.conan\data\winpcap\4.1.3\_\_\build\e5375efbdfdd123f7f396cfe34b84c596e22896e
    ERROR: winpcap/4.1.3: Error in build() method, line 124
    	cmake = self._configure_cmake()
    while calling '_configure_cmake', line 115
    	self._cmake.configure()
    	ConanException: Error 1 while executing cd C:\J\w\BuildSingleReference@2\.conan\data\winpcap\4.1.3\_\_\build\e5375efbdfdd123f7f396cfe34b84c596e22896e && cmake -G "Visual Studio 14 2015 Win64" -DCONAN_LINK_RUNTIME="/MT" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="14" -DCONAN_CXX_FLAGS="/MP16" -DCONAN_C_FLAGS="/MP16" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="C:\J\w\BuildSingleReference@2\.conan\data\winpcap\4.1.3\_\_\package\e5375efbdfdd123f7f396cfe34b84c596e22896e" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DWINPCAP_CAPTURE_TYPE="win32" -DWINPCAP_REMOTE="True" -DWINPCAP_TURBOCAP="True" -DWINPCAP_BLUETOOTH="False" -DWINPCAP_USB="False" -DWINPCAP_USB_DEVICE="" -Wno-dev C:\J\w\BuildSingleReference@2\.conan\data\winpcap\4.1.3\_\_\build\e5375efbdfdd123f7f396cfe34b84c596e22896e
    

Note: To save resources, CI tries to finish as soon as an error is found. For this reason you might find that not all the references have been launched or not all the configurations for a given reference. Also, take into account that we cannot guarantee the order of execution as it depends on CI workload and workers availability.

del self.options.fPIC
self.options.turbocap = True
self.options.capture_type = "win32"
elif self.settings.os == "Linux":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@madebr WinPcap is for Windows only. It's actually a Windows port of libpcap which is not available on Windows. For Linux/macOS the libpcap Conan package should be used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I'll look into stripping everything non-Windows related.

@SpaceIm SpaceIm mentioned this pull request Jul 16, 2021
4 tasks
#ifdef HAVE_REMOTE
#include <pcap-remote.h>
#endif
+#ifdef NEED_LINUX_SOCKIOS_H
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad file extension

raise ConanInvalidConfiguration("missing turbocap cci recipe")

def build_requirements(self):
if self._build_os == "Windows":
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIXME: add _settings_build property method

@stale
Copy link

stale bot commented Aug 20, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 20, 2021
@stale
Copy link

stale bot commented Sep 19, 2021

This pull request has been automatically closed because it has not had recent activity. Thank you for your contributions.

@stale stale bot closed this Sep 19, 2021
@seladb
Copy link
Contributor

seladb commented Sep 20, 2021

@madebr the PR was closed :(
Any chance you'll have time to complete this work?

@madebr madebr mentioned this pull request Sep 21, 2021
4 tasks
@uilianries uilianries mentioned this pull request Sep 16, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants