Skip to content

Commit

Permalink
[treehopper] Fix dependency handling of libusb (microsoft#35480)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankXie05 authored and Osyotr committed Jan 23, 2024
1 parent 254fd65 commit de21adf
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 10 deletions.
42 changes: 42 additions & 0 deletions ports/treehopper/fix-dependences.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
diff --git a/C++/API/CMakeLists.txt b/C++/API/CMakeLists.txt
index 8537305..db3d29b 100644
--- a/C++/API/CMakeLists.txt
+++ b/C++/API/CMakeLists.txt
@@ -37,7 +37,10 @@ if(APPLE)
find_library(IOKIT IOKit)
target_link_libraries(treehopper pthread ${CORE_FOUNDATION} ${IOKIT})
elseif(UNIX)
- target_link_libraries(treehopper usb-1.0 pthread)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
+
+ target_link_libraries(treehopper PRIVATE PkgConfig::libusb pthread)
elseif(WIN32)
target_link_libraries(treehopper winusb setupapi)
endif(APPLE)
diff --git a/C++/API/inc/ConnectionService.h b/C++/API/inc/ConnectionService.h
index 66d338e..12a0192 100644
--- a/C++/API/inc/ConnectionService.h
+++ b/C++/API/inc/ConnectionService.h
@@ -8,7 +8,7 @@
#include <CoreFoundation/CFRunLoop.h>
#endif
#ifdef __linux__
-#include "libusb-1.0/libusb.h"
+#include "libusb.h"
#endif
#include <vector>

diff --git a/C++/API/inc/LibUsbConnection.h b/C++/API/inc/LibUsbConnection.h
index b6d5198..e9cd29e 100644
--- a/C++/API/inc/LibUsbConnection.h
+++ b/C++/API/inc/LibUsbConnection.h
@@ -6,7 +6,7 @@

#include "Treehopper.h"

-#include <libusb-1.0/libusb.h>
+#include <libusb.h>
#include "UsbConnection.h"

namespace Treehopper {
11 changes: 6 additions & 5 deletions ports/treehopper/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY ONLY_DYNAMIC_CRT)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO treehopper-electronics/treehopper-sdk
REF 1.11.3
REF "${VERSION}"
SHA512 65b748375b798787c8b59f9657151f340920c939c3f079105b9b78f4e3b775125598106c6dfa4feba111a64d30f007003a70110ac767802a7dd1127a25c9fb14
HEAD_REF master)
HEAD_REF master
PATCHES
fix-dependences.patch
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}/C++/API/"
Expand All @@ -18,6 +21,4 @@ vcpkg_cmake_config_fixup()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

file(INSTALL "${SOURCE_PATH}/C++/API/inc/" DESTINATION "${CURRENT_PACKAGES_DIR}/include/Treehopper/")

file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
9 changes: 6 additions & 3 deletions ports/treehopper/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "treehopper",
"version": "1.11.3",
"port-version": 8,
"port-version": 9,
"description": "Treehopper connects the physical world to your computer, tablet, or smartphone.",
"homepage": "https://treehopper.io",
"supports": "!staticcrt",
"supports": "!staticcrt & !uwp",
"dependencies": [
"libusb",
{
"name": "libusb",
"platform": "linux"
},
{
"name": "vcpkg-cmake",
"host": true
Expand Down
1 change: 0 additions & 1 deletion scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,6 @@ torch-th:arm64-uwp=fail
torch-th:x64-android=fail
torch-th:x64-uwp=fail
torch-th:x64-windows-static=fail
treehopper:x64-linux=fail
turbobase64:arm-neon-android=fail
tvision:arm-neon-android=fail
tvision:arm64-android=fail
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -8602,7 +8602,7 @@
},
"treehopper": {
"baseline": "1.11.3",
"port-version": 8
"port-version": 9
},
"triangle": {
"baseline": "1.6",
Expand Down
5 changes: 5 additions & 0 deletions versions/t-/treehopper.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "145e9145dba553063f0483909603c6369c5a4e63",
"version": "1.11.3",
"port-version": 9
},
{
"git-tree": "94c478388c393d8b174b2fd9c4ad0f77805583dc",
"version": "1.11.3",
Expand Down

0 comments on commit de21adf

Please sign in to comment.