Merge pull request #310 from dominicgs/Windows_build
Windows CI builds with Appveyor, Support compiling with Visual Studio
This commit is contained in:
27
appveyor.yml
Normal file
27
appveyor.yml
Normal file
@ -0,0 +1,27 @@
|
||||
os: Visual Studio 2015
|
||||
clone_depth: 1
|
||||
|
||||
configuration:
|
||||
- Release
|
||||
- Debug
|
||||
|
||||
install:
|
||||
- appveyor DownloadFile "https://downloads.sourceforge.net/project/libusb/libusb-1.0/libusb-1.0.21/libusb-1.0.21.7z?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Flibusb%2Ffiles%2Flibusb-1.0%2Flibusb-1.0.21%2F&ts=1485478643&use_mirror=cytranet" -FileName "C:\libusb.7z"
|
||||
- 7z x -y "C:\libusb.7z" -o"C:\libusb"
|
||||
- appveyor DownloadFile "http://mirrors.kernel.org/sourceware/pthreads-win32/pthreads-w32-2-9-1-release.zip" -FileName "C:\pthreads-w32-release.zip"
|
||||
- 7z x -y "C:\pthreads-w32-release.zip" -o"C:\pthreads"
|
||||
- appveyor DownloadFile "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.26-1_win32.zip" -FileName "C:\pkg-config_win32.zip"
|
||||
- 7z x -y "C:\pkg-config_win32.zip" -o"C:\pkg-config"
|
||||
|
||||
|
||||
build_script:
|
||||
- mkdir c:\projects\hackrf\host\build
|
||||
- cd c:\projects\hackrf\host\build
|
||||
- cmake -G "Visual Studio 14 2015 Win64" \
|
||||
-DLIBUSB_LIBRARIES="C:\libusb\MS64\dll\libusb-1.0.lib" \
|
||||
-DLIBUSB_INCLUDE_DIR="C:\libusb\include\libusb-1.0" \
|
||||
-DTHREADS_PTHREADS_INCLUDE_DIR=c:\pthreads\Pre-built.2\include \
|
||||
-DTHREADS_PTHREADS_WIN32_LIBRARY=c:\pthreads\Pre-built.2\lib\x64\pthreadVC2.lib \
|
||||
-DPKG_CONFIG_EXECUTABLE="C:\pkg-config\bin\pkg-config.exe" \
|
||||
..
|
||||
- msbuild .\ALL_BUILD.vcxproj /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
@ -24,12 +24,15 @@
|
||||
set(INSTALL_DEFAULT_BINDIR "bin" CACHE STRING "Appended to CMAKE_INSTALL_PREFIX")
|
||||
|
||||
INCLUDE(FindPkgConfig)
|
||||
pkg_check_modules(FFTW REQUIRED fftw3f)
|
||||
|
||||
if(MSVC)
|
||||
add_library(libgetopt_static STATIC
|
||||
../getopt/getopt.c
|
||||
)
|
||||
else()
|
||||
pkg_check_modules(FFTW REQUIRED fftw3f)
|
||||
LIST(APPEND TOOLS hackrf_sweep)
|
||||
LIST(APPEND TOOLS_LINK_LIBS m fftw3f)
|
||||
endif()
|
||||
|
||||
SET(TOOLS
|
||||
@ -41,7 +44,6 @@ SET(TOOLS
|
||||
hackrf_cpldjtag
|
||||
hackrf_info
|
||||
hackrf_operacake
|
||||
hackrf_sweep
|
||||
)
|
||||
|
||||
if(NOT libhackrf_SOURCE_DIR)
|
||||
@ -55,8 +57,6 @@ if(MSVC)
|
||||
LIST(APPEND TOOLS_LINK_LIBS libgetopt_static)
|
||||
endif()
|
||||
|
||||
LIST(APPEND TOOLS_LINK_LIBS m fftw3f)
|
||||
|
||||
foreach(tool ${TOOLS})
|
||||
add_executable(${tool} ${tool}.c)
|
||||
target_link_libraries(${tool} ${TOOLS_LINK_LIBS})
|
||||
|
@ -379,26 +379,28 @@ int rx_callback(hackrf_transfer* transfer) {
|
||||
}
|
||||
}
|
||||
if (stream_size>0){
|
||||
if ((stream_size-1+stream_head-stream_tail)%stream_size <bytes_to_write){
|
||||
stream_drop++;
|
||||
}else{
|
||||
if(stream_tail+bytes_to_write <= stream_size){
|
||||
memcpy(stream_buf+stream_tail,transfer->buffer,bytes_to_write);
|
||||
}else{
|
||||
memcpy(stream_buf+stream_tail,transfer->buffer,(stream_size-stream_tail));
|
||||
memcpy(stream_buf,transfer->buffer+(stream_size-stream_tail),bytes_to_write-(stream_size-stream_tail));
|
||||
};
|
||||
__atomic_store_n(&stream_tail,(stream_tail+bytes_to_write)%stream_size,__ATOMIC_RELEASE);
|
||||
#ifndef _WIN32
|
||||
if ((stream_size-1+stream_head-stream_tail)%stream_size <bytes_to_write) {
|
||||
stream_drop++;
|
||||
} else {
|
||||
if(stream_tail+bytes_to_write <= stream_size) {
|
||||
memcpy(stream_buf+stream_tail,transfer->buffer,bytes_to_write);
|
||||
} else {
|
||||
memcpy(stream_buf+stream_tail,transfer->buffer,(stream_size-stream_tail));
|
||||
memcpy(stream_buf,transfer->buffer+(stream_size-stream_tail),bytes_to_write-(stream_size-stream_tail));
|
||||
};
|
||||
__atomic_store_n(&stream_tail,(stream_tail+bytes_to_write)%stream_size,__ATOMIC_RELEASE);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}else{
|
||||
bytes_written = fwrite(transfer->buffer, 1, bytes_to_write, fd);
|
||||
if ((bytes_written != bytes_to_write)
|
||||
|| (limit_num_samples && (bytes_to_xfer == 0))) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
bytes_written = fwrite(transfer->buffer, 1, bytes_to_write, fd);
|
||||
if ((bytes_written != bytes_to_write)
|
||||
|| (limit_num_samples && (bytes_to_xfer == 0))) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
@ -490,7 +492,10 @@ static void usage() {
|
||||
printf("\t[-s sample_rate_hz] # Sample rate in Hz (4/8/10/12.5/16/20MHz, default %sMHz).\n",
|
||||
u64toa((DEFAULT_SAMPLE_RATE_HZ/FREQ_ONE_MHZ),&ascii_u64_data1));
|
||||
printf("\t[-n num_samples] # Number of samples to transfer (default is unlimited).\n");
|
||||
#ifndef _WIN32
|
||||
/* The required atomic load/store functions aren't available when using C with MSVC */
|
||||
printf("\t[-S buf_size] # Enable receive streaming with buffer size buf_size.\n");
|
||||
#endif
|
||||
printf("\t[-c amplitude] # CW signal source mode, amplitude 0-127 (DC value to DAC).\n");
|
||||
printf("\t[-R] # Repeat TX mode (default is off) \n");
|
||||
printf("\t[-b baseband_filter_bw_hz] # Set baseband filter bandwidth in Hz.\n\tPossible values: 1.75/2.5/3.5/5/5.5/6/7/8/9/10/12/14/15/20/24/28MHz, default < sample_rate_hz.\n" );
|
||||
@ -1041,48 +1046,49 @@ int main(int argc, char** argv) {
|
||||
uint32_t byte_count_now;
|
||||
struct timeval time_now;
|
||||
float time_difference, rate;
|
||||
if (stream_size>0){
|
||||
if(stream_head==stream_tail){
|
||||
usleep(10000); // queue empty
|
||||
}else{
|
||||
ssize_t len;
|
||||
ssize_t bytes_written;
|
||||
uint32_t _st= __atomic_load_n(&stream_tail,__ATOMIC_ACQUIRE);
|
||||
if(stream_head<_st)
|
||||
len=_st-stream_head;
|
||||
else
|
||||
len=stream_size-stream_head;
|
||||
bytes_written = fwrite(stream_buf+stream_head, 1, len, fd);
|
||||
if (len != bytes_written){
|
||||
printf("write failed");
|
||||
do_exit=true;
|
||||
};
|
||||
stream_head=(stream_head+len)%stream_size;
|
||||
if (stream_size>0) {
|
||||
#ifndef _WIN32
|
||||
if(stream_head==stream_tail) {
|
||||
usleep(10000); // queue empty
|
||||
} else {
|
||||
ssize_t len;
|
||||
ssize_t bytes_written;
|
||||
uint32_t _st= __atomic_load_n(&stream_tail,__ATOMIC_ACQUIRE);
|
||||
if(stream_head<_st)
|
||||
len=_st-stream_head;
|
||||
else
|
||||
len=stream_size-stream_head;
|
||||
bytes_written = fwrite(stream_buf+stream_head, 1, len, fd);
|
||||
if (len != bytes_written) {
|
||||
printf("write failed");
|
||||
do_exit=true;
|
||||
};
|
||||
stream_head=(stream_head+len)%stream_size;
|
||||
}
|
||||
if(stream_drop>0){
|
||||
uint32_t drops= __atomic_exchange_n (&stream_drop,0,__ATOMIC_SEQ_CST);
|
||||
printf("dropped frames: [%d]\n",drops);
|
||||
if(stream_drop>0) {
|
||||
uint32_t drops= __atomic_exchange_n (&stream_drop,0,__ATOMIC_SEQ_CST);
|
||||
printf("dropped frames: [%d]\n",drops);
|
||||
}
|
||||
}else{
|
||||
sleep(1);
|
||||
|
||||
gettimeofday(&time_now, NULL);
|
||||
|
||||
byte_count_now = byte_count;
|
||||
byte_count = 0;
|
||||
|
||||
time_difference = TimevalDiff(&time_now, &time_start);
|
||||
rate = (float)byte_count_now / time_difference;
|
||||
fprintf(stderr, "%4.1f MiB / %5.3f sec = %4.1f MiB/second\n",
|
||||
(byte_count_now / 1e6f), time_difference, (rate / 1e6f) );
|
||||
#endif
|
||||
} else {
|
||||
sleep(1);
|
||||
gettimeofday(&time_now, NULL);
|
||||
|
||||
byte_count_now = byte_count;
|
||||
byte_count = 0;
|
||||
|
||||
time_difference = TimevalDiff(&time_now, &time_start);
|
||||
rate = (float)byte_count_now / time_difference;
|
||||
fprintf(stderr, "%4.1f MiB / %5.3f sec = %4.1f MiB/second\n",
|
||||
(byte_count_now / 1e6f), time_difference, (rate / 1e6f) );
|
||||
|
||||
time_start = time_now;
|
||||
time_start = time_now;
|
||||
|
||||
if (byte_count_now == 0) {
|
||||
exit_code = EXIT_FAILURE;
|
||||
fprintf(stderr, "\nCouldn't transfer any bytes for one second.\n");
|
||||
break;
|
||||
}
|
||||
if (byte_count_now == 0) {
|
||||
exit_code = EXIT_FAILURE;
|
||||
fprintf(stderr, "\nCouldn't transfer any bytes for one second.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,11 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <libusb.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Avoid redefinition of timespec from time.h (included by libusb.h) */
|
||||
#define HAVE_STRUCT_TIMESPEC 1
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
|
||||
#ifndef bool
|
||||
@ -396,7 +401,7 @@ hackrf_device_list_t* ADDCALL hackrf_device_list()
|
||||
serial_number_length = libusb_get_string_descriptor_ascii(usb_device, serial_descriptor_index, (unsigned char*)serial_number, sizeof(serial_number));
|
||||
if( serial_number_length == 32 ) {
|
||||
serial_number[32] = 0;
|
||||
list->serial_numbers[idx] = strndup(serial_number, serial_number_length);
|
||||
list->serial_numbers[idx] = strdup(serial_number);
|
||||
}
|
||||
|
||||
libusb_close(usb_device);
|
||||
|
@ -216,8 +216,8 @@ extern ADDAPI int ADDCALL hackrf_init_sweep(hackrf_device* device,
|
||||
int length, uint32_t dwell_time);
|
||||
|
||||
/* Operacake functions */
|
||||
int ADDCALL hackrf_get_operacake_boards(hackrf_device* device, uint8_t* boards);
|
||||
int ADDCALL hackrf_set_operacake_ports(hackrf_device* device,
|
||||
extern ADDAPI int ADDCALL hackrf_get_operacake_boards(hackrf_device* device, uint8_t* boards);
|
||||
extern ADDAPI int ADDCALL hackrf_set_operacake_ports(hackrf_device* device,
|
||||
uint8_t address,
|
||||
uint8_t port_a,
|
||||
uint8_t port_b);
|
||||
|
Reference in New Issue
Block a user