summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Gu <timothygu99@gmail.com>2014-08-17 23:19:12 (GMT)
committerTimothy Gu <timothygu99@gmail.com>2014-08-17 23:19:12 (GMT)
commit99f041fc86db1292768beaf75e6e3af0024f90b1 (patch)
treed4b334fc752f7bbd1e4981645507265e63dad68c
parent056f00155f46b48f7fb07d463349e2d63ec5973c (diff)
parent22306acb01428db92c5efee5f9eb180cca40293f (diff)
downloadmxe-99f041fc86db1292768beaf75e6e3af0024f90b1.zip
mxe-99f041fc86db1292768beaf75e6e3af0024f90b1.tar.gz
mxe-99f041fc86db1292768beaf75e6e3af0024f90b1.tar.bz2
Merge pull request #469 from uwehermann/libusb1_libftdi1_tests
Add libusb1 and libftdi1 tests, enable libftdi1 shared build
-rw-r--r--src/libftdi1-2-shared-build.patch33
-rw-r--r--src/libftdi1-test.c38
-rw-r--r--src/libftdi1.mk16
-rw-r--r--src/libusb1-test.c39
-rw-r--r--src/libusb1.mk5
5 files changed, 128 insertions, 3 deletions
diff --git a/src/libftdi1-2-shared-build.patch b/src/libftdi1-2-shared-build.patch
new file mode 100644
index 0000000..8a292e6
--- /dev/null
+++ b/src/libftdi1-2-shared-build.patch
@@ -0,0 +1,33 @@
+This file is part of MXE.
+See index.html for further information.
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index e8688d4..66c1ba2 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -46,6 +46,7 @@ set(CPACK_COMPONENT_SHAREDLIBS_GROUP "Development")
+ set(CPACK_COMPONENT_STATICLIBS_GROUP "Development")
+ set(CPACK_COMPONENT_HEADERS_GROUP "Development")
+
++option ( SHAREDLIBS "Build shared libraries" ON )
+ option ( STATICLIBS "Build static libraries" ON )
+
+ # guess LIB_SUFFIX, don't take debian multiarch into account
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 9fd86a6..5d0e52a 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -32,11 +32,13 @@ set_target_properties ( ftdi1 PROPERTIES CLEAN_DIRECT_OUTPUT 1 )
+ # Dependencies
+ target_link_libraries(ftdi1 ${LIBUSB_LIBRARIES})
+
++if ( SHAREDLIBS )
+ install ( TARGETS ftdi1
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib${LIB_SUFFIX}
+ ARCHIVE DESTINATION lib${LIB_SUFFIX}
+ )
++endif ()
+
+ if ( STATICLIBS )
+ add_library(ftdi1-static STATIC ${c_sources})
diff --git a/src/libftdi1-test.c b/src/libftdi1-test.c
new file mode 100644
index 0000000..8252cf3
--- /dev/null
+++ b/src/libftdi1-test.c
@@ -0,0 +1,38 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <stdio.h>
+#include <ftdi.h>
+
+int main(int argc, char *argv[])
+{
+ int num_devs;
+ struct ftdi_context *ctx;
+ struct ftdi_device_list *devs = NULL;
+
+ (void)argc;
+ (void)argv;
+
+ ctx = ftdi_new();
+ if (!ctx) {
+ printf("Initialization error.\n");
+ return 1;
+ }
+
+ num_devs = ftdi_usb_find_all(ctx, &devs, 0, 0);
+ if (num_devs < 0) {
+ printf("Device list error: %s.\n", ftdi_get_error_string(ctx));
+ ftdi_free(ctx);
+ return 2;
+ }
+
+ printf("Found %d FTDI devices.\n", (int)num_devs);
+
+ ftdi_list_free(&devs);
+
+ ftdi_free(ctx);
+
+ return 0;
+}
diff --git a/src/libftdi1.mk b/src/libftdi1.mk
index 7b18986..e29c3b9 100644
--- a/src/libftdi1.mk
+++ b/src/libftdi1.mk
@@ -20,8 +20,18 @@ define $(PKG)_BUILD
cd '$(1)' && cmake . \
-DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
-DCMAKE_BUILD_TYPE=Release \
- -DLIBUSB_INCLUDE_DIR=$(PREFIX)/$(TARGET)/include/libusb-1.0
+ -DSHAREDLIBS=$(if $(BUILD_SHARED),yes,no) \
+ -DSTATICLIBS=$(if $(BUILD_SHARED),no,yes) \
+ -DLIBUSB_INCLUDE_DIR=$(PREFIX)/$(TARGET)/include/libusb-1.0 \
+ -DDOCUMENTATION=no \
+ -DEXAMPLES=no \
+ -DFTDIPP=no \
+ -DFTDI_EEPROM=no \
+ -DPYTHON_BINDINGS=no
$(MAKE) -C '$(1)' -j '$(JOBS)' install VERBOSE=1
-endef
-$(PKG)_BUILD_SHARED =
+ '$(TARGET)-gcc' \
+ -W -Wall -Wextra -Werror \
+ '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-libftdi1.exe' \
+ `'$(TARGET)-pkg-config' libftdi1 --cflags --libs`
+endef
diff --git a/src/libusb1-test.c b/src/libusb1-test.c
new file mode 100644
index 0000000..6cd6bf5
--- /dev/null
+++ b/src/libusb1-test.c
@@ -0,0 +1,39 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <stdio.h>
+#include <libusb.h>
+
+int main(int argc, char *argv[])
+{
+ int ret;
+ ssize_t num_devs;
+ libusb_context *ctx;
+ libusb_device **devs;
+
+ (void)argc;
+ (void)argv;
+
+ ret = libusb_init(&ctx);
+ if (ret != LIBUSB_SUCCESS) {
+ printf("Initialization error: %s.\n", libusb_error_name(ret));
+ return 1;
+ }
+
+ num_devs = libusb_get_device_list(ctx, &devs);
+ if (num_devs < 0 || !devs) {
+ printf("Device list error: %s.\n", libusb_error_name(num_devs));
+ return 2;
+ }
+
+ printf("Found %d USB devices.\n", (int)num_devs);
+
+ libusb_free_device_list(devs, 1);
+
+ libusb_exit(ctx);
+
+ return 0;
+}
+
diff --git a/src/libusb1.mk b/src/libusb1.mk
index 0b851cf..2913fb5 100644
--- a/src/libusb1.mk
+++ b/src/libusb1.mk
@@ -22,4 +22,9 @@ define $(PKG)_BUILD
$(MXE_CONFIGURE_OPTS) \
CFLAGS=-D_WIN32_WINNT=0x0500
$(MAKE) -C '$(1)' -j '$(JOBS)' install
+
+ '$(TARGET)-gcc' \
+ -W -Wall -Wextra -Werror \
+ '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-libusb1.exe' \
+ `'$(TARGET)-pkg-config' libusb-1.0 --cflags --libs`
endef