Skip to content

[usbipdcpp] New port: A C++ library for creating usbip servers#50973

Open
yunsmall wants to merge 1 commit intomicrosoft:masterfrom
yunsmall:add-usbipdcpp
Open

[usbipdcpp] New port: A C++ library for creating usbip servers#50973
yunsmall wants to merge 1 commit intomicrosoft:masterfrom
yunsmall:add-usbipdcpp

Conversation

@yunsmall
Copy link
Copy Markdown

@yunsmall yunsmall commented Apr 5, 2026

Summary

This PR adds a new port for usbipdcpp, a C++ library for creating USB/IP servers.

Features

  • USB/IP server implementation via libusb (works on all libusb-compatible platforms)
  • Virtual HID device support (cross-platform, no libusb required)
  • Hot-plug support for automatic device insertion/removal detection
  • Asynchronous architecture using C++20 coroutines and asio
  • Extensible design with abstract interfaces

Features available

  • coroutine: Use C++20 coroutine-based implementation
  • libusb: Build libusb-based server components for physical USB device forwarding

Usage

find_package(usbipdcpp CONFIG REQUIRED)
target_link_libraries(main PRIVATE usbipdcpp::usbipdcpp)

# With libusb support
find_package(usbipdcpp CONFIG REQUIRED COMPONENTS libusb)
target_link_libraries(main PRIVATE usbipdcpp::usbipdcpp usbipdcpp::libusb)

Checklist

- Changes comply with the https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md.
- The packaged project shows strong association with the chosen port name.
  - The port name follows the 'GitHubOrg-GitHubRepo' form or equivalent Owner-Project form (github.com/yunsmall/usbipdcpp).
- Optional dependencies of the build are all controlled by the port (libusb is controlled by libusb feature).
- The versioning scheme in vcpkg.json matches what upstream says.
- The license declaration in vcpkg.json matches what upstream says (Apache 2.0).
- The installed as the "copyright" file matches what upstream says.
- The source code of the component installed comes from an authoritative source (GitHub release).
- The generated "usage text" is brief and accurate.
- The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
- Exactly one version is added in each modified versions file.

@yunsmall
Copy link
Copy Markdown
Author

yunsmall commented Apr 5, 2026

@microsoft-github-policy-service agree

@yunsmall yunsmall force-pushed the add-usbipdcpp branch 2 times, most recently from 8b46118 to 1da552a Compare April 6, 2026 18:11
Comment on lines +20 to +22
"coroutine": {
"description": "Use C++20 coroutine-based implementation"
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this an alternative (see our docs)?

@vicroms vicroms marked this pull request as draft April 6, 2026 20:51
@yunsmall yunsmall force-pushed the add-usbipdcpp branch 3 times, most recently from 9a83e2d to 6ae4cd9 Compare April 7, 2026 14:16
@yunsmall
Copy link
Copy Markdown
Author

yunsmall commented Apr 7, 2026

@vicroms Thank you for the review! I've made the following changes:

  1. ✅ Used vcpkg_check_features instead of manual if/else
  2. ✅ Removed unnecessary environment variable operations
  3. ✅ Simplified vcpkg_cmake_config_fixup
  4. ✅ Simplified the usage file

Regarding whether coroutine is an alternative: It's not a mutually exclusive alternative but an internal implementation detail (similar to bullet3's double/single precision feature), which is transparent to users.

Also added a busywait feature for lower latency mode.

@yunsmall yunsmall requested a review from vicroms April 7, 2026 14:42
@yunsmall yunsmall marked this pull request as ready for review April 7, 2026 14:42
Copy link
Copy Markdown
Contributor

@dg0yt dg0yt left a comment

Choose a reason for hiding this comment

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

FTR there is PR template for new ports, with a checklist.

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO yunsmall/usbipdcpp
REF v0.0.1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
REF v0.0.1
REF v${VERSION}

Comment on lines +10 to +13
FEATURES
coroutine USBIPDCPP_USE_COROUTINE
libusb USBIPDCPP_BUILD_LIBUSB_COMPONENTS
busywait USBIPDCPP_ENABLE_BUSY_WAIT
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Style.

Suggested change
FEATURES
coroutine USBIPDCPP_USE_COROUTINE
libusb USBIPDCPP_BUILD_LIBUSB_COMPONENTS
busywait USBIPDCPP_ENABLE_BUSY_WAIT
FEATURES
coroutine USBIPDCPP_USE_COROUTINE
libusb USBIPDCPP_BUILD_LIBUSB_COMPONENTS
busywait USBIPDCPP_ENABLE_BUSY_WAIT

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DPKG_CONFIG_EXECUTABLE="${PKGCONFIG}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Quote for CMake language.

Suggested change
-DPKG_CONFIG_EXECUTABLE="${PKGCONFIG}"
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"

Comment on lines +1 to +4
The package usbipdcpp provides CMake targets:

find_package(usbipdcpp CONFIG REQUIRED)
target_link_libraries(main PRIVATE usbipdcpp::usbipdcpp usbipdcpp::libusb) No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Align with heuristical output from vcpkg's tool.

Suggested change
The package usbipdcpp provides CMake targets:
find_package(usbipdcpp CONFIG REQUIRED)
target_link_libraries(main PRIVATE usbipdcpp::usbipdcpp usbipdcpp::libusb)
usbipdcpp provides CMake targets:
find_package(usbipdcpp CONFIG REQUIRED)
target_link_libraries(main PRIVATE usbipdcpp::usbipdcpp usbipdcpp::libusb)

Do users really need to add/use two targets?

libusb seems to be optional. Is usbipdcpp::libusb an actual artifact or just representing the external libusb?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants