mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-26 17:41:09 +08:00
[libftdi-compat] Add new port (#6843)
* [libftdi-compat] v0.20 port * Fixed wrong version number in CONTROL file. * Download source archive file instead. * restrict to shared library build only. * Remove dlls from static build. * [libftdi-compat] Update to 1.4. Replace CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS with a def file. Minimize patching. * [libftdi] Rename from libftdi-compat * [libftdi][libftdi1] Restore v0.20 as libftdi, move 1.4 to libftdi1
This commit is contained in:
parent
9cfcc71146
commit
d1b4e88d3c
4
ports/libftdi/CONTROL
Normal file
4
ports/libftdi/CONTROL
Normal file
@ -0,0 +1,4 @@
|
||||
Source: libftdi
|
||||
Version: 0.20
|
||||
Build-Depends: libusb-win32
|
||||
Description: FTDI USB driver with bitbang mode (v0.20)
|
24
ports/libftdi/export-cmake.patch
Normal file
24
ports/libftdi/export-cmake.patch
Normal file
@ -0,0 +1,24 @@
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 1c326fe..3c1d9ab 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -47,14 +47,19 @@ if(WIN32 OR 1)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
install( TARGETS ftdi
|
||||
+ EXPORT ftdi
|
||||
COMPONENT sharedlibs
|
||||
)
|
||||
|
||||
+ target_link_libraries(ftdi PUBLIC $<INSTALL_INTERFACE:include>)
|
||||
else()
|
||||
install( TARGETS ftdi-static
|
||||
+ EXPORT ftdi
|
||||
COMPONENT staticlibs
|
||||
)
|
||||
+ target_link_libraries(ftdi-static PUBLIC $<INSTALL_INTERFACE:include>)
|
||||
endif()
|
||||
+ install(EXPORT ftdi FILE libftdi-config.cmake NAMESPACE libftdi:: DESTINATION share/libftdi)
|
||||
|
||||
install( FILES ${c_headers}
|
||||
DESTINATION include
|
56
ports/libftdi/exports.def
Normal file
56
ports/libftdi/exports.def
Normal file
@ -0,0 +1,56 @@
|
||||
EXPORTS
|
||||
ftdi_deinit
|
||||
ftdi_disable_bitbang
|
||||
ftdi_eeprom_build
|
||||
ftdi_eeprom_decode
|
||||
ftdi_eeprom_free
|
||||
ftdi_eeprom_initdefaults
|
||||
ftdi_eeprom_setsize
|
||||
ftdi_enable_bitbang
|
||||
ftdi_erase_eeprom
|
||||
ftdi_free
|
||||
ftdi_get_error_string
|
||||
ftdi_get_latency_timer
|
||||
ftdi_init
|
||||
ftdi_list_free
|
||||
ftdi_list_free2
|
||||
ftdi_new
|
||||
ftdi_poll_modem_status
|
||||
ftdi_read_chipid
|
||||
ftdi_read_data
|
||||
ftdi_read_data_get_chunksize
|
||||
ftdi_read_data_set_chunksize
|
||||
ftdi_read_eeprom
|
||||
ftdi_read_eeprom_getsize
|
||||
ftdi_read_eeprom_location
|
||||
ftdi_read_pins
|
||||
ftdi_set_baudrate
|
||||
ftdi_set_bitmode
|
||||
ftdi_set_error_char
|
||||
ftdi_set_event_char
|
||||
ftdi_set_interface
|
||||
ftdi_set_latency_timer
|
||||
ftdi_set_line_property
|
||||
ftdi_set_line_property2
|
||||
ftdi_set_usbdev
|
||||
ftdi_setdtr
|
||||
ftdi_setdtr_rts
|
||||
ftdi_setflowctrl
|
||||
ftdi_setrts
|
||||
ftdi_usb_close
|
||||
ftdi_usb_find_all
|
||||
ftdi_usb_get_strings
|
||||
ftdi_usb_open
|
||||
ftdi_usb_open_desc
|
||||
ftdi_usb_open_desc_index
|
||||
ftdi_usb_open_dev
|
||||
ftdi_usb_open_string
|
||||
ftdi_usb_purge_buffers
|
||||
ftdi_usb_purge_rx_buffer
|
||||
ftdi_usb_purge_tx_buffer
|
||||
ftdi_usb_reset
|
||||
ftdi_write_data
|
||||
ftdi_write_data_get_chunksize
|
||||
ftdi_write_data_set_chunksize
|
||||
ftdi_write_eeprom
|
||||
ftdi_write_eeprom_location
|
43
ports/libftdi/libusb-win32.patch
Normal file
43
ports/libftdi/libusb-win32.patch
Normal file
@ -0,0 +1,43 @@
|
||||
diff --git a/FindUSB.cmake b/FindUSB.cmake
|
||||
index 566cdd8..0710345 100644
|
||||
--- a/FindUSB.cmake
|
||||
+++ b/FindUSB.cmake
|
||||
@@ -24,10 +24,10 @@ else (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
|
||||
pkg_check_modules(PC_LIBUSB libusb)
|
||||
ENDIF(NOT WIN32)
|
||||
|
||||
- FIND_PATH(LIBUSB_INCLUDE_DIR usb.h
|
||||
+ FIND_PATH(LIBUSB_INCLUDE_DIR lusb0_usb.h
|
||||
PATHS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS})
|
||||
|
||||
- FIND_LIBRARY(LIBUSB_LIBRARIES NAMES usb
|
||||
+ FIND_LIBRARY(LIBUSB_LIBRARIES NAMES usb0 libusb0
|
||||
PATHS ${PC_LIBUSB_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
diff --git a/src/ftdi.c b/src/ftdi.c
|
||||
index 980622d..8f6ab67 100644
|
||||
--- a/src/ftdi.c
|
||||
+++ b/src/ftdi.c
|
||||
@@ -28,7 +28,7 @@
|
||||
/** \addtogroup libftdi */
|
||||
/* @{ */
|
||||
|
||||
-#include <usb.h>
|
||||
+#include <lusb0_usb.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
diff --git a/src/ftdi.h b/src/ftdi.h
|
||||
index 6bb7a3e..d4472c2 100644
|
||||
--- a/src/ftdi.h
|
||||
+++ b/src/ftdi.h
|
||||
@@ -17,7 +17,7 @@
|
||||
#ifndef __libftdi_h__
|
||||
#define __libftdi_h__
|
||||
|
||||
-#include <usb.h>
|
||||
+#include <lusb0_usb.h>
|
||||
|
||||
#define FTDI_DEFAULT_EEPROM_SIZE 128
|
||||
|
45
ports/libftdi/portfile.cmake
Normal file
45
ports/libftdi/portfile.cmake
Normal file
@ -0,0 +1,45 @@
|
||||
include(vcpkg_common_functions)
|
||||
|
||||
vcpkg_download_distfile(ARCHIVE
|
||||
URLS "https://www.intra2net.com/en/developer/libftdi/download/libftdi-0.20.tar.gz"
|
||||
FILENAME "libftdi-0.20.tar.gz"
|
||||
SHA512 540e5eb201a65936c3dbabff70c251deba1615874b11ff27c5ca16c39d71c150cf61758a68b541135a444fe32ab403b0fba0daf55c587647aaf9b3f400f1dee7
|
||||
)
|
||||
|
||||
vcpkg_extract_source_archive_ex(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
ARCHIVE ${ARCHIVE}
|
||||
REF 0.20
|
||||
PATCHES
|
||||
libusb-win32.patch
|
||||
shared-static.patch
|
||||
export-cmake.patch
|
||||
)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/exports.def DESTINATION ${SOURCE_PATH}/src)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
-DDOCUMENTATION=OFF
|
||||
-DEXAMPLES=OFF
|
||||
-DPYTHON_BINDINGS=OFF
|
||||
-DFTDIPP=OFF
|
||||
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=ON
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=ON
|
||||
|
||||
-DLIBUSB_INCLUDE_DIR=${CURRENT_INSTALLED_DIR}/include
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
||||
vcpkg_fixup_cmake_targets()
|
||||
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include ${CURRENT_PACKAGES_DIR}/debug/share)
|
||||
|
||||
file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libftdi)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/share/libftdi/LICENSE ${CURRENT_PACKAGES_DIR}/share/libftdi/copyright)
|
||||
|
||||
vcpkg_copy_pdbs()
|
52
ports/libftdi/shared-static.patch
Normal file
52
ports/libftdi/shared-static.patch
Normal file
@ -0,0 +1,52 @@
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 071ae90..b42bbcd 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -4,7 +4,7 @@ include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
# Targets
|
||||
-set(c_sources ftdi.c)
|
||||
+set(c_sources ftdi.c exports.def)
|
||||
set(c_headers ftdi.h)
|
||||
|
||||
add_library(ftdi SHARED ${c_sources})
|
||||
@@ -24,7 +24,7 @@ set_target_properties(ftdi-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
target_link_libraries(ftdi ${LIBUSB_LIBRARIES})
|
||||
|
||||
# Install
|
||||
-if(${UNIX})
|
||||
+if(UNIX AND 0)
|
||||
|
||||
install( TARGETS ftdi
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||
@@ -41,23 +41,24 @@ if(${UNIX})
|
||||
COMPONENT headers
|
||||
)
|
||||
|
||||
-endif(${UNIX})
|
||||
+endif()
|
||||
|
||||
-if(${WIN32})
|
||||
+if(WIN32 OR 1)
|
||||
|
||||
+ if(BUILD_SHARED_LIBS)
|
||||
install( TARGETS ftdi
|
||||
- DESTINATION bin
|
||||
COMPONENT sharedlibs
|
||||
)
|
||||
|
||||
+ else()
|
||||
install( TARGETS ftdi-static
|
||||
- DESTINATION bin
|
||||
COMPONENT staticlibs
|
||||
)
|
||||
+ endif()
|
||||
|
||||
install( FILES ${c_headers}
|
||||
DESTINATION include
|
||||
COMPONENT headers
|
||||
)
|
||||
|
||||
-endif(${WIN32})
|
||||
+endif()
|
4
ports/libftdi1/CONTROL
Normal file
4
ports/libftdi1/CONTROL
Normal file
@ -0,0 +1,4 @@
|
||||
Source: libftdi1
|
||||
Version: 1.4
|
||||
Build-Depends: libusb
|
||||
Description: FTDI USB driver with bitbang mode (v1.4)
|
13
ports/libftdi1/cmake-fix.patch
Normal file
13
ports/libftdi1/cmake-fix.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/cmake/FindUSB1.cmake b/cmake/FindUSB1.cmake
|
||||
index b90e297..6cc97a0 100644
|
||||
--- a/cmake/FindUSB1.cmake
|
||||
+++ b/cmake/FindUSB1.cmake
|
||||
@@ -26,7 +26,7 @@ else (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
|
||||
PATH_SUFFIXES libusb-1.0
|
||||
PATHS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS})
|
||||
|
||||
- FIND_LIBRARY(LIBUSB_LIBRARIES NAMES usb-1.0
|
||||
+ FIND_LIBRARY(LIBUSB_LIBRARIES NAMES usb-1.0 libusb-1.0
|
||||
PATHS ${PC_LIBUSB_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
67
ports/libftdi1/exports.def
Normal file
67
ports/libftdi1/exports.def
Normal file
@ -0,0 +1,67 @@
|
||||
EXPORTS
|
||||
convert_baudrate_UT_export
|
||||
ftdi_deinit
|
||||
ftdi_disable_bitbang
|
||||
ftdi_eeprom_build
|
||||
ftdi_eeprom_decode
|
||||
ftdi_eeprom_get_strings
|
||||
ftdi_eeprom_initdefaults
|
||||
ftdi_eeprom_set_strings
|
||||
ftdi_erase_eeprom
|
||||
ftdi_free
|
||||
ftdi_get_eeprom_buf
|
||||
ftdi_get_eeprom_value
|
||||
ftdi_get_error_string
|
||||
ftdi_get_latency_timer
|
||||
ftdi_get_library_version
|
||||
ftdi_init
|
||||
ftdi_list_free
|
||||
ftdi_list_free2
|
||||
ftdi_new
|
||||
ftdi_poll_modem_status
|
||||
ftdi_read_chipid
|
||||
ftdi_read_data
|
||||
ftdi_read_data_get_chunksize
|
||||
ftdi_read_data_set_chunksize
|
||||
ftdi_read_data_submit
|
||||
ftdi_read_eeprom
|
||||
ftdi_read_eeprom_location
|
||||
ftdi_read_pins
|
||||
ftdi_set_baudrate
|
||||
ftdi_set_bitmode
|
||||
ftdi_set_eeprom_buf
|
||||
ftdi_set_eeprom_user_data
|
||||
ftdi_set_eeprom_value
|
||||
ftdi_set_error_char
|
||||
ftdi_set_event_char
|
||||
ftdi_set_interface
|
||||
ftdi_set_latency_timer
|
||||
ftdi_set_line_property
|
||||
ftdi_set_line_property2
|
||||
ftdi_set_usbdev
|
||||
ftdi_setdtr
|
||||
ftdi_setdtr_rts
|
||||
ftdi_setflowctrl
|
||||
ftdi_setrts
|
||||
ftdi_transfer_data_cancel
|
||||
ftdi_transfer_data_done
|
||||
ftdi_usb_close
|
||||
ftdi_usb_find_all
|
||||
ftdi_usb_get_strings
|
||||
ftdi_usb_get_strings2
|
||||
ftdi_usb_open
|
||||
ftdi_usb_open_bus_addr
|
||||
ftdi_usb_open_desc
|
||||
ftdi_usb_open_desc_index
|
||||
ftdi_usb_open_dev
|
||||
ftdi_usb_open_string
|
||||
ftdi_usb_purge_buffers
|
||||
ftdi_usb_purge_rx_buffer
|
||||
ftdi_usb_purge_tx_buffer
|
||||
ftdi_usb_reset
|
||||
ftdi_write_data
|
||||
ftdi_write_data_get_chunksize
|
||||
ftdi_write_data_set_chunksize
|
||||
ftdi_write_data_submit
|
||||
ftdi_write_eeprom
|
||||
ftdi_write_eeprom_location
|
47
ports/libftdi1/portfile.cmake
Normal file
47
ports/libftdi1/portfile.cmake
Normal file
@ -0,0 +1,47 @@
|
||||
include(vcpkg_common_functions)
|
||||
|
||||
vcpkg_download_distfile(ARCHIVE
|
||||
URLS "https://www.intra2net.com/en/developer/libftdi/download/libftdi1-1.4.tar.bz2"
|
||||
FILENAME "libftdi1-1.4.tar.bz2"
|
||||
SHA512 dbab74f7bc35ca835b9c6dd5b70a64816948d65da1f73a9ece37a0f0f630bd0df1a676543acc517b02a718bc34ba4f7a30cbc48b6eed1c154c917f8ef0a358fc
|
||||
)
|
||||
|
||||
vcpkg_extract_source_archive_ex(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
ARCHIVE ${ARCHIVE}
|
||||
REF 1.4
|
||||
PATCHES
|
||||
cmake-fix.patch
|
||||
win32.patch
|
||||
)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/exports.def DESTINATION ${SOURCE_PATH}/src)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
-DBUILD_TESTS=OFF
|
||||
-DDOCUMENTATION=OFF
|
||||
-DEXAMPLES=OFF
|
||||
-DPYTHON_BINDINGS=OFF
|
||||
-DLINK_PYTHON_LIBRARY=OFF
|
||||
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=ON
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=ON
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Confuse=ON
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Libintl=ON
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PythonLibs=ON
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PythonInterp=ON
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
||||
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/libftdi1 TARGET_PATH share/libftdi1)
|
||||
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include ${CURRENT_PACKAGES_DIR}/debug/share)
|
||||
|
||||
file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libftdi1)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/share/libftdi1/LICENSE ${CURRENT_PACKAGES_DIR}/share/libftdi1/copyright)
|
||||
|
||||
vcpkg_copy_pdbs()
|
28
ports/libftdi1/win32.patch
Normal file
28
ports/libftdi1/win32.patch
Normal file
@ -0,0 +1,28 @@
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 9fd86a6..e1e848c 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -18,9 +18,14 @@ message(STATUS "Detected git snapshot version: ${SNAPSHOT_VERSION}")
|
||||
configure_file(ftdi_version_i.h.in "${CMAKE_CURRENT_BINARY_DIR}/ftdi_version_i.h" @ONLY)
|
||||
|
||||
# Targets
|
||||
+if(WIN32)
|
||||
+set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.c ${CMAKE_CURRENT_SOURCE_DIR}/exports.def CACHE INTERNAL "List of c sources" )
|
||||
+else()
|
||||
set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.c ${CMAKE_CURRENT_SOURCE_DIR}/ftdi_stream.c CACHE INTERNAL "List of c sources" )
|
||||
+endif()
|
||||
set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.h CACHE INTERNAL "List of c headers" )
|
||||
|
||||
+if(BUILD_SHARED_LIBS)
|
||||
add_library(ftdi1 SHARED ${c_sources})
|
||||
|
||||
math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases
|
||||
@@ -38,7 +43,7 @@ install ( TARGETS ftdi1
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX}
|
||||
)
|
||||
|
||||
-if ( STATICLIBS )
|
||||
+else()
|
||||
add_library(ftdi1-static STATIC ${c_sources})
|
||||
target_link_libraries(ftdi1-static ${LIBUSB_LIBRARIES})
|
||||
set_target_properties(ftdi1-static PROPERTIES OUTPUT_NAME "ftdi1")
|
Loading…
x
Reference in New Issue
Block a user