split fxlink into library (not installed yet) and executable

This commit is contained in:
Lephenixnoir 2023-03-26 12:20:50 +02:00
parent 3f4aa1e750
commit 065233387d
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
12 changed files with 18 additions and 17 deletions

View file

@ -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)

View file

@ -10,7 +10,6 @@
#include <string.h>
#include <ctype.h>
#include <assert.h>
#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;
}