Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the Windows builds #776

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ qtpro5
win32x
qrc_*
install_manifest.txt

# CLion-specific
.idea/
cmake-build*/
35 changes: 29 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,20 @@ find_package(Qt5Core QUIET)
if(Qt5Core_FOUND)
message("----- Qt5:")
message(STATUS " includes:" ${Qt5Core_INCLUDE_DIRS})
#find_package(Qt5WinExtras REQUIRED)
if (WIN32)
find_package(Qt5WinExtras REQUIRED)
endif ()
find_package(Qt5Svg REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Gui REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
#set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5WinExtras_INCLUDE_DIRS})
#set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::WinExtras)
set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
set(QT_LIBRARIES Qt5::Gui Qt5::Widgets)
if (WIN32)
set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5WinExtras_INCLUDE_DIRS})
set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::WinExtras Qt5::WinMain Qt5::Svg)
else ()
set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg)
endif ()
add_definitions(${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS})
else()
find_package(Qt6Core QUIET)
Expand Down Expand Up @@ -353,6 +359,14 @@ set(DSView_SOURCES
DSView/pv/ui/popupdlglist.cpp
)

# Windows-specific QT source files
if(WIN32)
list(APPEND DSView_SOURCES
DSView/pv/winnativewidget.cpp
DSView/pv/winshadow.cpp
)
endif ()

set(DSView_HEADERS
DSView/mystyle.h
DSView/pv/log.h
Expand Down Expand Up @@ -447,6 +461,14 @@ set(DSView_HEADERS
DSView/pv/ui/xtoolbutton.h
)

# Windows-specific QT headers
if(WIN32)
list(APPEND DSView_HEADERS
DSView/pv/winnativewidget.h
DSView/pv/winshadow.h
)
endif ()

#===============================================================================
#= libsigrok4DSL source
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -552,6 +574,8 @@ if(WIN32)
enable_language(RC)
# app icon
list(APPEND DSView_SOURCES applogo.rc)
# MinGW Unicode support
add_definitions(-municode)
endif()

if(Qt5Core_FOUND)
Expand Down Expand Up @@ -599,7 +623,6 @@ set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
add_compile_options(-O3)

#===============================================================================
#= Linker Configuration
Expand Down
35 changes: 3 additions & 32 deletions libsigrok4DSL/hardware/DSL/dscope.c
Original file line number Diff line number Diff line change
Expand Up @@ -1897,16 +1897,6 @@ static int cleanup(void)
return SR_OK;
}

static void remove_sources(struct DSL_context *devc)
{
int i;
sr_info("%s: remove fds from polling", __func__);
/* Remove fds from polling. */
for (i = 0; devc->usbfd[i] != -1; i++)
sr_source_remove(devc->usbfd[i]);
g_free(devc->usbfd);
}

static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
{
int completed = 0;
Expand Down Expand Up @@ -1953,7 +1943,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
}

if (devc->status == DSL_FINISH) {
remove_sources(devc);
sr_session_source_remove((gintptr) devc->channel);
}

devc->trf_completed = 0;
Expand All @@ -1966,9 +1956,6 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data)

struct DSL_context *devc;
struct sr_usb_dev_inst *usb;
struct drv_context *drvc;
const struct libusb_pollfd **lupfd;
unsigned int i;
int ret;
struct ctl_wr_cmd wr_cmd;
GSList *l;
Expand All @@ -1978,7 +1965,6 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data)
return SR_ERR_DEVICE_CLOSED;
}

drvc = di->priv;
devc = sdi->priv;
usb = sdi->conn;

Expand Down Expand Up @@ -2087,23 +2073,8 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data)
return ret;
}

/* setup callback function for data transfer */
lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
for (i = 0; lupfd[i]; i++);

if (!(devc->usbfd = malloc(sizeof(struct libusb_pollfd) * (i + 1)))){
sr_err("%s,ERROR:failed to alloc memory.", __func__);
return SR_ERR;
}

for (i = 0; lupfd[i]; i++) {
sr_source_add(lupfd[i]->fd, lupfd[i]->events,
dsl_get_timeout(sdi), receive_data, sdi);
devc->usbfd[i] = lupfd[i]->fd;
}

devc->usbfd[i] = -1;
free(lupfd);
sr_session_source_add ((gintptr) devc->channel, G_IO_IN | G_IO_ERR,
(int) dsl_get_timeout(sdi), receive_data, sdi);

wr_cmd.header.dest = DSL_CTL_START;
wr_cmd.header.size = 0;
Expand Down
14 changes: 14 additions & 0 deletions libsigrok4DSL/hardware/DSL/dsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,20 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo
return SR_ERR;
}

if (sdi->status == SR_ST_ACTIVE) {
ret = _pipe(devc->pipe_fds,0x1000,0x8000);
if (ret != SR_OK) {
sr_err("%s: pipe() failed", __func__);
return SR_ERR;
}
GIOChannel *new_channel;
new_channel = g_io_channel_unix_new(devc->pipe_fds[0]);
devc->channel = new_channel;
g_io_channel_set_flags(new_channel, 2, NULL);
g_io_channel_set_encoding(devc->channel,NULL,NULL);
g_io_channel_set_buffered(devc->channel,FALSE);
}

if (devc->profile->dev_caps.feature_caps & CAPS_FEATURE_SECURITY) {
ret = dsl_secuCheck(sdi, encryption, SECU_STEPS);
if (ret != SR_OK){
Expand Down
34 changes: 3 additions & 31 deletions libsigrok4DSL/hardware/DSL/dslogic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,16 +1312,6 @@ static int cleanup(void)
return SR_OK;
}

static void remove_sources(struct DSL_context *devc)
{
int i;
sr_info("%s: remove fds from polling", __func__);
/* Remove fds from polling. */
for (i = 0; devc->usbfd[i] != -1; i++)
sr_source_remove(devc->usbfd[i]);
g_free(devc->usbfd);
}

static void report_overflow(struct DSL_context *devc)
{
struct sr_datafeed_packet packet;
Expand Down Expand Up @@ -1396,7 +1386,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)

if (devc->status == DSL_FINISH) {
/* Remove polling */
remove_sources(devc);
sr_session_source_remove((gintptr) devc->channel);
}

devc->trf_completed = 0;
Expand All @@ -1409,9 +1399,6 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data)

struct DSL_context *devc;
struct sr_usb_dev_inst *usb;
struct drv_context *drvc;
const struct libusb_pollfd **lupfd;
unsigned int i;
int ret;
struct ctl_wr_cmd wr_cmd;

Expand All @@ -1420,7 +1407,6 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data)
return SR_ERR_DEVICE_CLOSED;
}

drvc = di->priv;
devc = sdi->priv;
usb = sdi->conn;

Expand Down Expand Up @@ -1485,22 +1471,8 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data)
return ret;
}

/* setup callback function for data transfer */
lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
for (i = 0; lupfd[i]; i++);

if (!(devc->usbfd = malloc(sizeof(struct libusb_pollfd) * (i + 1)))){
sr_err("%s,ERROR:failed to alloc memory.", __func__);
return SR_ERR;
}

for (i = 0; lupfd[i]; i++) {
sr_source_add(lupfd[i]->fd, lupfd[i]->events,
dsl_get_timeout(sdi), receive_data, sdi);
devc->usbfd[i] = lupfd[i]->fd;
}
devc->usbfd[i] = -1;
free(lupfd);
sr_session_source_add ((gintptr) devc->channel, G_IO_IN | G_IO_ERR,
(int) dsl_get_timeout(sdi), receive_data, sdi);

wr_cmd.header.dest = DSL_CTL_START;
wr_cmd.header.size = 0;
Expand Down
15 changes: 1 addition & 14 deletions libsigrok4DSL/hwdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,21 +366,8 @@ SR_PRIV int sr_status_get(const struct sr_dev_inst *sdi,

/* Unnecessary level of indirection follows. */

/** @private */
SR_PRIV int sr_source_remove(int fd)
{
return sr_session_source_remove(fd);
}

/** @private */
SR_PRIV int sr_source_add(int fd, int events, int timeout,
sr_receive_data_callback_t cb, void *cb_data)
{
return sr_session_source_add(fd, events, timeout, cb, cb_data);
}

SR_PRIV int ds_scan_all_device_list(libusb_context *usb_ctx,struct libusb_device **list_buf, int size, int *count)
{
{
libusb_device **devlist;
int i;
int wr;
Expand Down
20 changes: 5 additions & 15 deletions libsigrok4DSL/libsigrok-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,34 +287,24 @@ SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial);
typedef int (*sr_receive_data_callback_t)(int fd, int revents, const struct sr_dev_inst *sdi);

SR_PRIV void sr_hw_cleanup_all(void);
SR_PRIV int sr_source_remove(int fd);
SR_PRIV int sr_source_add(int fd, int events, int timeout,
sr_receive_data_callback_t cb, void *cb_data);

/*--- session.c -------------------------------------------------------------*/

SR_PRIV int usb_hotplug_callback(struct libusb_context *ctx, struct libusb_device *dev,
libusb_hotplug_event event, void *user_data);

SR_PRIV int sr_session_source_add(int fd, int events, int timeout,
sr_receive_data_callback_t cb, const struct sr_dev_inst *sdi);
SR_PRIV int sr_session_source_add_pollfd(GPollFD *pollfd, int timeout,
sr_receive_data_callback_t cb, const struct sr_dev_inst *sdi);
SR_PRIV int sr_session_source_add_channel(GIOChannel *channel, int events,
int timeout, sr_receive_data_callback_t cb, const struct sr_dev_inst *sdi);
SR_PRIV int sr_session_source_remove(int fd);
SR_PRIV int sr_session_source_remove_pollfd(GPollFD *pollfd);
SR_PRIV int sr_session_source_remove_channel(GIOChannel *channel);
SR_PRIV int sr_session_source_add(gintptr poll_object, int events,
int timeout,
sr_receive_data_callback_t cb,
const struct sr_dev_inst *sdi);
SR_PRIV int sr_session_source_remove(gintptr poll_object);

/*--- std.c -----------------------------------------------------------------*/

typedef int (*dev_close_t)(struct sr_dev_inst *sdi);

SR_PRIV int std_hw_init(struct sr_context *sr_ctx, struct sr_dev_driver *di,
const char *prefix);
SR_PRIV int std_hw_dev_acquisition_stop_serial(struct sr_dev_inst *sdi,
void *cb_data, dev_close_t hw_dev_close_fn,
struct sr_serial_dev_inst *serial, const char *prefix);
SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi,
const char *prefix);

Expand Down
Loading