Skip to content

Commit 68bcbfc

Browse files
authored
README: explicit statement on single source build (#370)
1 parent 536bad2 commit 68bcbfc

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

BUILD.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* [FreeBSD](#freebsd)
99
* [Mac](#mac)
1010
* [Windows](#windows)
11-
* [Integrating hidapi directly into your source tree](#integrating-hidapi-directly-into-your-source-tree)
11+
* [Embedding HIDAPI directly into your source tree](#embedding-hidapi-directly-into-your-source-tree)
1212
* [Building the manual way on Unix platforms](#building-the-manual-way-on-unix-platforms)
1313
* [Building on Windows](#building-on-windows)
1414

@@ -68,19 +68,30 @@ On Mac make sure you have XCode installed and its Command Line Tools.
6868
On Windows you just need a compiler. You may use Visual Studio or Cygwin/MinGW,
6969
depending on which environment is best for your needs.
7070

71-
## Integrating HIDAPI directly into your source tree
71+
## Embedding HIDAPI directly into your source tree
7272

73-
Instead of using one of the provided build systems, you may want to integrate
74-
HIDAPI directly into your source tree.
75-
Generally it is not encouraged to do so, but if you must, all you need to do:
76-
- add a single source file `hid.c` (for a specific backend);
77-
- setup include directory to `<HIDAPI repo root>/hidapi`;
78-
- add link libraries, that are specific for each backend.
73+
Instead of using one of the provided standalone build systems,
74+
you may want to integrate HIDAPI directly into your source tree.
7975

80-
Check the manual makefiles for a simple example/reference of what are the dependencies of each specific backend.
76+
---
77+
If your project uses CMake as a build system, it is safe to add HIDAPI as a [subdirectory](BUILD.cmake.md#hidapi-as-a-subdirectory).
78+
79+
---
80+
If _the only option_ that works for you is adding HIDAPI sources directly
81+
to your project's build system, then you need:
82+
- include a _single source file_ into your project's build system,
83+
depending on your platform and the backend you want to use:
84+
- [`windows\hid.c`](windows/hid.c);
85+
- [`linux/hid.c`](linux/hid.c);
86+
- [`libusb/hid.c`](libusb/hid.c);
87+
- [`mac/hid.c`](mac/hid.c);
88+
- add a [`hidapi`](hidapi) folder to the include path when building `hid.c`;
89+
- make the platform/backend specific [dependencies](#prerequisites) available during the compilation/linking, when building `hid.c`;
8190

82-
NOTE: if your have a CMake-based project, you're likely be able to use
83-
HIDAPI directly as a subdirectory. Check [BUILD.cmake.md](BUILD.cmake.md) for details.
91+
NOTE: the above doesn't guarantee that having a copy of `<backend>/hid.c` and `hidapi/hidapi.h` is enough to build HIDAPI.
92+
The only guarantee that `<backend>/hid.c` includes all nesessary sources to compile it as a single file.
93+
94+
Check the manual makefiles for a simple example/reference of what are the dependencies of each specific backend.
8495

8596
## Building the manual way on Unix platforms
8697

@@ -106,5 +117,5 @@ To build HIDAPI using MinGW or Cygwin using Autotools, use a general Autotools
106117

107118
Any windows builds (MSVC or MinGW/Cygwin) are also supported by [CMake](BUILD.cmake.md).
108119

109-
If you are looking for information regarding DDK build of HIDAPI
120+
If you are looking for information regarding DDK build of HIDAPI:
110121
- the build has been broken for a while and now the support files are obsolete.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
HIDAPI is a multi-platform library which allows an application to interface
1010
with USB and Bluetooth HID-Class devices on Windows, Linux, FreeBSD, and macOS.
1111
HIDAPI can be either built as a shared library (`.so`, `.dll` or `.dylib`) or
12-
can be embedded directly into a target application by adding a single source
13-
file (per platform) and a single header.
12+
can be embedded directly into a target application by adding a _single source_
13+
file (per platform) and a single header.<br>
14+
See [remarks](BUILD.md#embedding-hidapi-directly-into-your-source-tree) on embedding _directly_ into your build system.
1415

1516
HIDAPI library was originally developed by Alan Ott ([signal11](https://github.com/signal11)).
1617

0 commit comments

Comments
 (0)