85 Commits
Author SHA1 Message Date
Mikolaj Kucharski cd431859fa fix eol of msvc/*.vcxproj and msvc/*.vcxproj.filters files
Closes #812
Closes #813

Signed-off-by: Chris Dickens <[email protected]>
2020-11-30 11:17:34 -08:00
Chris Dickens a2f1e2d5fd Windows: Support building dpfp and sam3u_benchmark with MSVC
Closes #151

Signed-off-by: Chris Dickens <[email protected]>
2020-11-27 18:39:53 -08:00
Chris Dickens 1be2ed9f14 Windows: Add missing header files to MSVC projects
Signed-off-by: Chris Dickens <[email protected]>
2020-11-27 15:56:02 -08:00
Chris Dickens f2e551a5ff build: Prepare config.h for inclusion in examples/tests
There are certain games played in the examples and tests source to
account for differences in build environments and target platforms. This
can be simplified by including config.h and using the definitions there.

To that end, move the printf function attribute definition from
libusbi.h to config.h and leverage it where it is used in the examples
and tests.

Signed-off-by: Chris Dickens <[email protected]>
2020-11-27 15:22:29 -08:00
Chris Dickens da5df37c4d build: Merge events and threads into single platform abstraction
The split between events and threads abstractions is unnecessary.
Simplify the library by merging the two into a "platform" abstraction.
The only meaningful change is that Cygwin builds will no longer use the
POSIX threads abstraction but will instead use the native Windows one.

The downside to doing this is that the dpfp_threaded example program
will no longer be available on Cygwin builds. This should be fine, and
future work will make dpfp_threaded available for all forms of Windows
build systems.

Signed-off-by: Chris Dickens <[email protected]>
2020-09-12 22:44:28 -07:00
Chris Dickens d67eb5beaa core: Introduce platform events abstraction
The way in which system handles or resources are represented differs
greatly between Unix-like operating systems and Windows. Ever since
Windows support was added to libusb, Windows been emulating principles
of Unix-like operating systems such as file descriptors and poll().

This commit introduces an abstraction layer that completely removes the
need to perform any emulation. Fundamentally there are three things that
each platform provides to libusb:

  1) A signallable event
  2) A timer (not required, but useful)
  3) A means to wait for event sources such as the above to be triggered

The POSIX abstraction for Unix-like operating systems uses file
descriptors as the "handles" to the underlying system resources. The
signallable event is implemented using a pipe, the timer as a timerfd
(where supported) and the poll() system call is used to wait for events.

The Windows abstraction uses native HANDLEs as the "handles" to the
underlying system resources. The signallable event is implemented using
a manual-reset event, the timer as a manual-reset waitable timer, and
the WaitForMultipleObjects() system call is used to wait for events.

Closes #252

Signed-off-by: Chris Dickens <[email protected]>
2020-08-12 16:06:38 -07:00
Chris Dickens 9a1bc8cafb build: Require C11 to build and clean up autoconfig/automake files
C11 compiler support has been available for many years now. It is not
unreasonable to require this now, and doing so allows some cleanup to
the configure script. It is no longer necessary to check for compiler
support of the '-fvibility' flag because any compiler that supports C11
will support this flag as well.

Fix up the way that compiler and linker flags are passed down to the
various makefiles. The compiler flags should be shared by all, but the
linker flags and libraries should be separated between the library and
the examples/tests. The visibility flag is only relevant for the
library and the thread flags are only relevant for sources using thread
constructs, so provide them as needed.

Rearrange configure.ac to group similar functionality and consolidate
where possible.

Based on these changes, update the Travis configuration file to include
newer versions of test platforms to ensure proper C11 compiler support.

Signed-off-by: Chris Dickens <[email protected]>
2020-03-30 12:28:11 -07:00
Chris Dickens 8b09dd490d core: Kill the OS_* definitions and use in the source code
These symbols are no longer necessary for the source code since commit
cad7d0edd9 ("core: Kill usbi_os_backend structure definition madness").

Signed-off-by: Chris Dickens <[email protected]>
2020-03-27 18:23:16 -07:00
Chris Dickens 964fa8c349 msvc: Update include path for getopt in fxload projects
Commit 07d6d3a2a5 ("msvc: Reorder solution projects and add project
filter files") moved the getopt source into the msvc directory but did
not include updating the include paths for the project that needs the
header files.

Signed-off-by: Chris Dickens <[email protected]>
2020-03-25 00:27:11 -07:00
Chris Dickens 07d6d3a2a5 msvc: Reorder solution projects and add project filter files
Since Visual Studio picks the first project as the default startup
project, move the library projects back to the top of the list. This use
to be the order but was changed in commit 9843b689df.

Add the project filter files to help organize the source files within
the Solution Explorer window pane.

Additionally move the getopt source underneath the msvc directory since
it is only used for Visual Studio builds.

Signed-off-by: Chris Dickens <[email protected]>
2020-03-23 15:17:50 -07:00
Chris Dickens f5c9f6794d Windows: Fix some harmless build warnings
Signed-off-by: Chris Dickens <[email protected]>
2020-03-09 23:06:17 -07:00
Chris Dickens 7bc0ff3ce9 core: Convert internal macros to static inline functions
Older versions of the Visual Studio compiler are picky about macros
constructed with the 'do { ... } while (0)' construct. Convert these
internal ones to static inline functions. The result is functionally
equivalent but gets us type checking and a bit more readability.

Also address some compiler warnings due to some header files that are
being included in a different order than before.

Signed-off-by: Chris Dickens <[email protected]>
2020-01-25 12:10:04 -08:00
winterrace 221e819622 Fix msvc 2019 project files (internal linkage)
Closes #683

Signed-off-by: Chris Dickens <[email protected]>
2020-01-24 17:05:26 -08:00
Chris Dickens d5bb64b3dc configure.ac: Cleanup and refactoring
Make the formatting consistent across the entire file. In particular:

  - Always quote strings whose values are derived
  - Use tabs consistently
  - Wrap all arguments with square brackets

Replace the use of '-a' with '&&' to be more portable.

Rearrange some of the feature checks to be conditional upon the platform
or backend. For example, there is no need to check for nfds_t on Windows
because poll() doesn't exist there. Similarly we now only check for
timerfd on Linux and Solaris. This translates into slightly faster
configure times.

Explicitly define tokens for both the poll and thread implementations.
This makes the preprocessor conditionals much nicer since it is not
necessary to enumerate all possible OS_* tokens. Also replace
POLL_NFDS_TYPE with a proper typedef that is based on the availability
of the nfds_t type.

Migrate to config definition names that are more consistent with
autoconf. The check for timerfd actually verifies the presence of the
library function instead of just the header definitions, and the token
USBI_TIMERFD_AVAILABLE is now HAVE_TIMERFD. Similarly the check for
syslog results in a definition of HAVE_SYSLOG.

Signed-off-by: Chris Dickens <[email protected]>
2020-01-24 11:22:49 -08:00
Chris Dickens aaff15d48d Misc: Trim and consolidate header file usage
Refactor libusbi.h to include the set of common header files needed by
every main source file in the library and change these source files to
include libusbi.h first, followed by any non-common headers. Including
libusbi.h first ensures that the config definitions are pulled in and
will eliminate redundant includes in the individual sources files.

Also clean up some whitespace errors and remove unnecessary definitions
in the manually generated config.h files.

Signed-off-by: Chris Dickens <[email protected]>
2020-01-24 11:21:27 -08:00
Chris Dickens 96e0af79b3 Windows: Drop support for Windows XP
XP is nearly 20 years old and there are hoops we jump through to keep
supporting it. Time to say goodbye and simplify some things.

Closes #267

Signed-off-by: Chris Dickens <[email protected]>
2020-01-21 16:13:07 -08:00
Chris Dickens 1816288b3a Windows: Add Visual Studio 2019 support
Signed-off-by: Chris Dickens <[email protected]>
2020-01-21 15:42:50 -08:00
Chris Dickens 28630ad489 Misc: Remove obsolete Windows DDK build files
Signed-off-by: Chris Dickens <[email protected]>
2020-01-21 15:39:34 -08:00
Chris Dickens de4a59af87 Misc: Clean up Visual Studio project files
Commit a9b34d170a ("Adding support for ARM & ARM64 Windows Platform")
introduced a dependency on a particular version of the Windows 10 SDK
for *all* platforms. This is particularly annoying for most users who
will only be building for Windows. Fix this by specifying the SDK
dependency only for the ARM/ARM64 platforms and bump to the latest.

Commit 77037c4dd6 ("Adds /utf-8 to compile options") added this compiler
option to all versions of the Visual Studio project files. This results
in a number of warnings with the older versions that don't recognize
this option. Fix this by keeping this option only for 2015 and newer.

Explicitly specify library dependencies for non-static targets. With a
small change in the UsbDk backend we can completely remove all
depenencies other than kernel32.lib.

Lastly, remove the 'MinimalRebuild' option for 2015 and newer project
files as this option is now deprecated and results in a warning for each
project.

Signed-off-by: Chris Dickens <[email protected]>
2020-01-21 15:38:56 -08:00
Chris Dickens f90d07613c Windows: Remove support for WinCE and Visual Studio older than 2013
There appears to be no need for the WinCE backend anymore, and it is
increasingly difficult to keep healthy as the rest of the library
changes.

Require at least Visual Studio 2013 to compile. This simplifies matters
as there is some semblance of C99 support there.

Signed-off-by: Chris Dickens <[email protected]>
2020-01-20 18:02:19 -08:00
RipleyTom 77037c4dd6 Adds /utf-8 to compile options
Signed-off-by: Nathan Hjelm <[email protected]>
2019-07-07 21:41:00 -06:00
RipleyTom 8436ba64f9 Change all $(SolutionDir) to $(ProjectDir)
Signed-off-by: Nathan Hjelm <[email protected]>
2019-07-07 21:39:46 -06:00
Dj Art a9b34d170a Adding support for ARM & ARM64 Windows Platform
Closes #423

Signed-off-by: Nathan Hjelm <[email protected]>
2019-04-04 22:24:46 -06:00
Chris Dickens dc5e33e382 Windows: Add back resource and definition files to VS DLL projects
Signed-off-by: Chris Dickens <[email protected]>
2018-03-20 10:01:48 -07:00
Chris Dickens 0aac390bb2 Windows: Restructure DDK/MSVC project files
For simplicity and to address some build warnings, this commit reworks
the project files to eliminate duplication and consolidate common build
flags and options. Also adds the stress and testlibusb projects to the
DDK build script.

Closes #402

Signed-off-by: Chris Dickens <[email protected]>
2018-03-12 10:39:26 -07:00
Chris Dickens ca0b6c09fa Fix appveyor scripts for Cygwin and MinGW to build as intended
The sub-directory created to store the generated files and build objects
was not being used as intended, because each invocation of the bash
starts in the home directory. Fix this by changing to the intended
directory prior to each command invocation.

Also replace the invocation of autogen.sh with bootstrap.sh, since using
autogen.sh calls ./configure and we weren't using the results of that
work. Instead we call configure directly from the sub-directory while
enabling the examples and test builds (for Cygwin) as autogen.sh would do.

Also fix the invalid value for the --build option provided to the x64
build of MinGW.

Finally, propagate errors from each script command so that failures are
caught and reported.

Signed-off-by: Chris Dickens <[email protected]>
2018-01-08 21:03:50 -08:00
Sameeh Jubran 020103af78 Windows: Ditch UsbDk build configuration
Previous patch introduced run-time UsbDk backend activation,
therefore separate build configuration is not needed anymore.

Signed-off-by: Sameeh Jubran <[email protected]>
2018-01-08 10:18:09 -08:00
Chris Dickens 54884e84d0 Windows: Enable dynamic selection between WinUSB and UsbDk backends
This commit unifies the two Windows backends into a single project and
enables the user to switch to the UsbDk backend, if available, using the
libusb_set_option() function. All contexts will use the WinUSB backend
by default for backwards compatibility.

With this change, the UsbDk-specific projects are no longer required.

Closes #309

Signed-off-by: Chris Dickens <[email protected]>
2018-01-08 10:17:26 -08:00
Chris Dickens 4da478cce0 Misc: Add TargetName to getopt VS project files to supress warning
Signed-off-by: Chris Dickens <[email protected]>
2018-01-04 23:44:57 -08:00
Chris Dickens 9843b689df Misc: Sort projects alphabetically in VS solution files
Signed-off-by: Chris Dickens <[email protected]>
2018-01-04 23:33:09 -08:00
Chris Dickens 8b6639ea6f Misc: Fix references section in fxload VS project files
Signed-off-by: Chris Dickens <[email protected]>
2018-01-04 23:32:33 -08:00
Chris Dickens 6dd2b7f9a5 Misc: Fix linker options in getopt VS project files
Signed-off-by: Chris Dickens <[email protected]>
2018-01-04 23:32:14 -08:00
Chris Dickens e25e0ce759 Misc: Add missing files to VS2005 projects for libusb
Signed-off-by: Chris Dickens <[email protected]>
2018-01-04 23:21:48 -08:00
Chris Dickens cbf2cc8847 Misc: Fix minor discrepancies in WinCE MSVC files
Add missing header files, fix preprocessor definitions for static
library, and sort projects and files by name.

Signed-off-by: Chris Dickens <[email protected]>
2018-01-04 23:19:47 -08:00
Chris Dickens af1f17536f Windows: Fix some minor style issues
Signed-off-by: Chris Dickens <[email protected]>
2018-01-03 23:27:11 -08:00
Chris Dickens 3001f93477 Misc: Ensure that both WINVER and _WIN32_WINNT are defined for Windows builds
Signed-off-by: Chris Dickens <[email protected]>
2018-01-03 19:19:39 -08:00
Chris Dickens 6402a10c14 Misc: Add _CRT_SECURE_NO_WARNINGS to testlibusb to suppress warning C4996
Signed-off-by: Chris Dickens <[email protected]>
2017-12-28 22:52:36 -08:00
Chris Dickens 539a3230cf Misc: Fix testlibusb build on VS2013 and earlier and suppress warnings
Signed-off-by: Chris Dickens <[email protected]>
2017-12-26 23:58:00 -08:00
Chris Dickens 2ae2348c66 Windows: Add VS 2010/2012/2013/2017 project files for testlibusb
Inspired by PR #201 (commit fa19c152), this commit adds the same project
files for the other supported versions of Visual Studio.

Signed-off-by: Chris Dickens <[email protected]>
2017-12-26 17:25:59 -08:00
Anil Nair fa19c15237 Windows: testlibusb example for VS2015
Closes #201

Signed-off-by: Chris Dickens <[email protected]>
2017-12-26 17:14:32 -08:00
Chris Dickens 80f1657f06 core: Remove check for and inclusion of signal.h
Signed-off-by: Chris Dickens <[email protected]>
2017-01-12 15:02:59 -08:00
Chris Dickens 322d146572 Windows: Fix DDK build's missing files
Signed-off-by: Chris Dickens <[email protected]>
2017-01-12 15:02:40 -08:00
Chris Dickens 96f8273c5e Windows: Add Visual Studio 2017 support
Signed-off-by: Chris Dickens <[email protected]>
2017-01-06 10:59:43 -08:00
Pete Batard 3564c18d83 windows: use appropriate version for VS2015 solution files
* Closes #193
2016-07-22 12:57:40 +01:00
hacker2490 40fb6ff0a0 AppVeyor: use a .bat file now
- Changes in platform configuration, x86 breaks the build
- Solution file does not contain platform for Any CPU,fixing it to Win32
- Added Multiple solutions to appveyor configuration file
- Added batch script for VS2010 builds
- Added fixes to appveyor.bat file and appveyor.yml
- Fixes for Platform and Configuration in appveyor.bat
- Fixed windows exit code, Appveyor reports exit on succesful build
- Multiple Builds in same platform and configuration,fixed it
2016-03-06 21:55:28 +01:00
Chris Dickens 4a0446f51b Misc: Fix up Visual Studio project files
This commit sorts the source and header files by name (for easier
human parsing), adds windows_nt_common.c to the 2010 and 2012
projects, and removes some CPP defines that should not be present
in the libusb_static_2015.vcxproj file.

Signed-off-by: Chris Dickens <[email protected]>
2016-01-27 00:15:11 -08:00
Dmitry Fleytman 24c5289342 build: Integrate usbdk backend
Signed-off-by: Dmitry Fleytman <[email protected]>
Signed-off-by: Chris Dickens <[email protected]>
2016-01-26 23:38:23 -08:00
Dmitry Fleytman 5d83abac3f windows: Rename windows_usb.h/c windows_winusb.h/c
Signed-off-by: Dmitry Fleytman <[email protected]>
Signed-off-by: Chris Dickens <[email protected]>
2016-01-23 22:58:35 -08:00
Dmitry Fleytman 92a327815b windows: Move common definitions to a separate file
New files windows_nt_common.h/c introduced.

Signed-off-by: Dmitry Fleytman <[email protected]>
Signed-off-by: Chris Dickens <[email protected]>
2016-01-23 22:58:10 -08:00
Brent Rector a34ba28b40 Windows: Add Visual Studio 2015 support
Modified from original to remove two unnecessary files and address
type-casting discrepancies across platforms.

Closes #60
Closes #83
Closes #120

Signed-off-by: Chris Dickens <[email protected]>
2016-01-06 00:27:12 -08:00