From 065233387df6bc4e03c639e268744df79f591ed4 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Sun, 26 Mar 2023 12:20:50 +0200 Subject: [PATCH] split fxlink into library (not installed yet) and executable --- CMakeLists.txt | 28 ++++++++++++------- {fxlink => libfxlink}/defs.c | 0 {fxlink => libfxlink}/devices.c | 0 {fxlink => libfxlink}/filter.c | 0 .../include/fxlink/config.h.in | 0 {fxlink => libfxlink}/include/fxlink/defs.h | 0 .../include/fxlink/devices.h | 0 {fxlink => libfxlink}/include/fxlink/filter.h | 0 .../include/fxlink/logging.h | 0 .../include/fxlink/protocol.h | 0 {fxlink => libfxlink}/logging.c | 0 {fxlink => libfxlink}/protocol.c | 7 ----- 12 files changed, 18 insertions(+), 17 deletions(-) rename {fxlink => libfxlink}/defs.c (100%) rename {fxlink => libfxlink}/devices.c (100%) rename {fxlink => libfxlink}/filter.c (100%) rename {fxlink => libfxlink}/include/fxlink/config.h.in (100%) rename {fxlink => libfxlink}/include/fxlink/defs.h (100%) rename {fxlink => libfxlink}/include/fxlink/devices.h (100%) rename {fxlink => libfxlink}/include/fxlink/filter.h (100%) rename {fxlink => libfxlink}/include/fxlink/logging.h (100%) rename {fxlink => libfxlink}/include/fxlink/protocol.h (100%) rename {fxlink => libfxlink}/logging.c (100%) rename {fxlink => libfxlink}/protocol.c (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cb068c..4477ce0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,16 +42,25 @@ add_custom_command(OUTPUT "${BIN}/fxsdk.sh" DEPENDS "${SRC}/fxsdk/fxsdk.sh") add_custom_target(fxsdk ALL DEPENDS "${BIN}/fxsdk.sh") -# fxlink -configure_file(fxlink/include/fxlink/config.h.in +# libfxlink +configure_file(libfxlink/include/fxlink/config.h.in "${BIN}/include/fxlink/config.h") +add_library(libfxlink STATIC + libfxlink/defs.c + libfxlink/devices.c + libfxlink/filter.c + libfxlink/logging.c + libfxlink/protocol.c) +target_link_libraries(libfxlink PUBLIC PkgConfig::libusb) +target_include_directories(libfxlink PUBLIC + "${BIN}/include" + "${SRC}/libfxlink/include") +set_target_properties(libfxlink PROPERTIES + OUTPUT_NAME "fxlink") # libfxlink.a + +# fxlink add_executable(fxlink - fxlink/defs.c - fxlink/devices.c - fxlink/filter.c - fxlink/logging.c fxlink/main.c - fxlink/protocol.c fxlink/modes/interactive.c fxlink/modes/list.c fxlink/modes/push.c @@ -66,9 +75,8 @@ add_executable(fxlink fxlink/tui/render.c fxlink/tui/tui-interactive.c) target_link_libraries(fxlink - PkgConfig::libpng PkgConfig::libusb PkgConfig::ncurses -lm) + libfxlink PkgConfig::libpng PkgConfig::ncurses -lm) target_include_directories(fxlink PRIVATE - "${BIN}/include" "${SRC}/fxlink/include") if(NOT FXLINK_DISABLE_UDISKS2) target_link_libraries(fxlink PkgConfig::udisks2) @@ -89,5 +97,5 @@ install(FILES "${BIN}/fxg1a" TYPE BIN) # fxconv install(PROGRAMS fxconv/fxconv-main.py TYPE BIN RENAME fxconv) install(FILES fxconv/fxconv.py TYPE BIN) -#fxlink +# fxlink install(TARGETS fxlink) diff --git a/fxlink/defs.c b/libfxlink/defs.c similarity index 100% rename from fxlink/defs.c rename to libfxlink/defs.c diff --git a/fxlink/devices.c b/libfxlink/devices.c similarity index 100% rename from fxlink/devices.c rename to libfxlink/devices.c diff --git a/fxlink/filter.c b/libfxlink/filter.c similarity index 100% rename from fxlink/filter.c rename to libfxlink/filter.c diff --git a/fxlink/include/fxlink/config.h.in b/libfxlink/include/fxlink/config.h.in similarity index 100% rename from fxlink/include/fxlink/config.h.in rename to libfxlink/include/fxlink/config.h.in diff --git a/fxlink/include/fxlink/defs.h b/libfxlink/include/fxlink/defs.h similarity index 100% rename from fxlink/include/fxlink/defs.h rename to libfxlink/include/fxlink/defs.h diff --git a/fxlink/include/fxlink/devices.h b/libfxlink/include/fxlink/devices.h similarity index 100% rename from fxlink/include/fxlink/devices.h rename to libfxlink/include/fxlink/devices.h diff --git a/fxlink/include/fxlink/filter.h b/libfxlink/include/fxlink/filter.h similarity index 100% rename from fxlink/include/fxlink/filter.h rename to libfxlink/include/fxlink/filter.h diff --git a/fxlink/include/fxlink/logging.h b/libfxlink/include/fxlink/logging.h similarity index 100% rename from fxlink/include/fxlink/logging.h rename to libfxlink/include/fxlink/logging.h diff --git a/fxlink/include/fxlink/protocol.h b/libfxlink/include/fxlink/protocol.h similarity index 100% rename from fxlink/include/fxlink/protocol.h rename to libfxlink/include/fxlink/protocol.h diff --git a/fxlink/logging.c b/libfxlink/logging.c similarity index 100% rename from fxlink/logging.c rename to libfxlink/logging.c diff --git a/fxlink/protocol.c b/libfxlink/protocol.c similarity index 97% rename from fxlink/protocol.c rename to libfxlink/protocol.c index 435d4b0..914c98e 100644 --- a/fxlink/protocol.c +++ b/libfxlink/protocol.c @@ -10,7 +10,6 @@ #include #include #include -#include "fxlink.h" bool fxlink_message_is_apptype(struct fxlink_message const *msg, char const *application, char const *type) @@ -260,9 +259,6 @@ struct fxlink_message *fxlink_transfer_finish_IN(struct fxlink_transfer *tr) return NULL; } - if(options.verbose) - log_("extracting completed message (%d bytes)\n", tr->msg.size); - /* Shallow copy the malloc()'d data pointer */ assert(tr->own_data && "Can't shallow copy data if we don't own it!"); memcpy(msg, &tr->msg, sizeof *msg); @@ -278,9 +274,6 @@ void fxlink_transfer_receive(struct fxlink_transfer *tr, void *data, int size) size = remaining_size; } - if(options.verbose) - log_("got %d bytes (out of %d left)\n", size, remaining_size); - memcpy(tr->msg.data + tr->processed_size, data, size); tr->processed_size += size; }