Skip to content

Commit 201910b

Browse files
authored
Initial commit of Device Defender client library (#1)
* Initial commit of Device Defender client library Signed-off-by: Gaurav Aggarwal <[email protected]>
1 parent 6376375 commit 201910b

19 files changed

+2512
-85
lines changed

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Ignore documentation output.
2+
**/docs/**/output/*
3+
4+
# Ignore CMake build directory.
5+
build/
6+
7+
# Ignore build artifacts.
8+
*.o
9+
10+
# Ignore code coverage artifacts.
11+
*.gcda
12+
*.gcno
13+
*.gcov

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "test/unit-test/CMock"]
2+
path = test/unit-test/CMock
3+
url = https://github.com/ThrowTheSwitch/CMock

CODE_OF_CONDUCT.md

-4
This file was deleted.

CONTRIBUTING.md

-61
This file was deleted.

LICENSE

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
MIT License
22

3-
Permission is hereby granted, free of charge, to any person obtaining a copy of
4-
this software and associated documentation files (the "Software"), to deal in
5-
the Software without restriction, including without limitation the rights to
6-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7-
the Software, and to permit persons to whom the Software is furnished to do so.
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
812

913
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
11-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
12-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
13-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.
1520

README.md

+62-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,70 @@
1-
## My Project
1+
# Device Defender Client Library
22

3-
TODO: Fill this README out!
3+
This repository contains the Device Defender client library for interacting with
4+
the [AWS IoT Device Defender Service](https://aws.amazon.com/iot-device-defender/).
5+
This library has no dependencies on any additional libraries other than the
6+
standard C library, and therefore, can be used with any MQTT client library.
7+
This library is distributed under the [MIT Open Source License](LICENSE).
48

5-
Be sure to:
9+
This library has gone through code quality checks including verification that no
10+
function has a [GNU Complexity](https://www.gnu.org/software/complexity/manual/complexity.html)
11+
score over 8.
612

7-
* Change the title in this README
8-
* Edit your repository description on GitHub
13+
## Device Defender Config File
914

10-
## Security
15+
The Device Defender client library exposes build configuration macros that are
16+
required for building the library. A list of all the configurations and their
17+
default values are defined in
18+
[defender_config_defaults.h](source/include/defender_config_defaults.h).
19+
To provide custom values for the configuration macros, a config file named
20+
`defender_config.h` can be provided by the application to the library.
1121

12-
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
22+
By default, a `defender_config.h` config file is required to build the library.
23+
To disable this requirement and build the library with default configuration
24+
values, provide `DEFENDER_DO_NOT_USE_CUSTOM_CONFIG` as a compile time
25+
preprocessor macro.
1326

14-
## License
27+
**Thus, the Device Defender client library can be built by either**:
28+
* Defining a `defender_config.h` file in the application, and adding it to the
29+
include directories list of the library.
1530

16-
This library is licensed under the MIT-0 License. See the LICENSE file.
31+
**OR**
1732

33+
* Defining the `DEFENDER_DO_NOT_USE_CUSTOM_CONFIG` preprocessor macro for the
34+
library build.
35+
36+
## Building the Library
37+
38+
The [defenderFilePaths.cmake](defenderFilePaths.cmake) file contains the
39+
information of all source files and the header include paths required to build
40+
the Device Defender client library.
41+
42+
As mentioned in the previous section, either a custom config file
43+
(i.e. `defender_config.h`) or `DEFENDER_DO_NOT_USE_CUSTOM_CONFIG` macro needs to
44+
be provided to build the Device Defender client library.
45+
46+
For a CMake example of building the Device Defender client library with the
47+
`defenderFilePaths.cmake` file, refer to the `coverity_analysis` library target
48+
in [test/CMakeLists.txt](test/CMakeLists.txt) file.
49+
50+
## Building Unit Tests
51+
52+
### Platform Prerequisites
53+
54+
- For running unit tests:
55+
- **C90 compiler** like gcc.
56+
- **CMake 3.13.0 or later**.
57+
- **Ruby 2.0.0 or later** is additionally required for the CMock test framework (that we use).
58+
- For running the coverage target, **gcov** and **lcov** are additionally required.
59+
60+
### Steps to build **Unit Tests**
61+
62+
1. Go to the root directory of this repository.
63+
64+
1. Run the *cmake* command: `cmake -S test -B build -DBUILD_CLONE_SUBMODULES=ON`.
65+
66+
1. Run this command to build the library and unit tests: `make -C build all`.
67+
68+
1. The generated test executables will be present in `build/bin/tests` folder.
69+
70+
1. Run `cd build && ctest` to execute all tests and view the test run summary.

defenderFilePaths.cmake

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is to add source files and include directories
2+
# into variables so that it can be reused from different repositories
3+
# in their Cmake based build system by including this file.
4+
#
5+
# Files specific to the repository such as test runner, platform tests
6+
# are not added to the variables.
7+
8+
# Device Defender library source files.
9+
set( DEFENDER_SOURCES
10+
"${CMAKE_CURRENT_LIST_DIR}/source/defender.c" )
11+
12+
# Device Defender library public include directories.
13+
set( DEFENDER_INCLUDE_PUBLIC_DIRS
14+
"${CMAKE_CURRENT_LIST_DIR}/source/include" )

0 commit comments

Comments
 (0)