Skip to content

Commit 4238b34

Browse files
committed
Merge branch 'develop' into main
2 parents 07484a7 + ca39051 commit 4238b34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+514
-369
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,31 @@ jobs:
2626

2727
# Job which builds docstrings for the rest of the wheel builds
2828
build-docstrings:
29-
runs-on: macos-latest
29+
runs-on: ubuntu-latest
3030
steps:
3131
- name: Cache .hunter folder
3232
uses: actions/cache@v2
3333
with:
3434
path: ~/.hunter
35-
key: hunter-macos-latest
35+
key: hunter-ubuntu-latest
3636
- name: List .hunter cache directory
3737
run: ls -a -l ~/.hunter/_Base/ || true
3838
- uses: actions/checkout@v2
3939
with:
4040
submodules: 'recursive'
4141
- name: Set up Python
4242
uses: actions/setup-python@v2
43-
with:
43+
with:
4444
python-version: 3.8
4545
- name: Install dependencies
4646
run: |
4747
python -m pip install --upgrade pip
48-
brew install libusb
49-
python -m pip install git+git://github.com/luxonis/pybind11_mkdoc.git@master
48+
sudo apt install libusb-1.0-0-dev
49+
python -m pip install -r docs/requirements_mkdoc.txt
5050
- name: Configure project
5151
run: cmake -S . -B build -DDEPTHAI_PYTHON_FORCE_DOCSTRINGS=ON -DDEPTHAI_PYTHON_DOCSTRINGS_OUTPUT="$PWD/docstrings/depthai_python_docstring.hpp"
5252
- name: Build target 'pybind11_mkdoc'
53-
run: cmake --build build --target pybind11_mkdoc --parallel
53+
run: cmake --build build --target pybind11_mkdoc --parallel 8
5454
- name: Upload docstring artifacts
5555
uses: actions/upload-artifact@v2
5656
with:
@@ -62,7 +62,7 @@ jobs:
6262
build-linux-armhf:
6363
needs: build-docstrings
6464
runs-on: luxonis-armhf
65-
container:
65+
container:
6666
image: registry.gitlab.com/luxonis/depthai-crosscompile/debian-buster
6767
# Mount local hunter cache directory, instead of transfering to Github and back
6868
volumes:
@@ -73,7 +73,7 @@ jobs:
7373
- uses: actions/checkout@v2
7474
with:
7575
submodules: 'recursive'
76-
76+
7777
- uses: actions/download-artifact@v2
7878
with:
7979
name: 'docstrings'
@@ -129,7 +129,7 @@ jobs:
129129

130130
- name: Set up Python ${{ matrix.python-version }}
131131
uses: actions/setup-python@v2
132-
with:
132+
with:
133133
python-version: ${{ matrix.python-version }}
134134
architecture: ${{ matrix.python-architecture }}
135135
- name: Append build hash if not a tagged commit
@@ -182,7 +182,7 @@ jobs:
182182

183183
- name: Set up Python ${{ matrix.python-version }}
184184
uses: actions/setup-python@v2
185-
with:
185+
with:
186186
python-version: ${{ matrix.python-version }}
187187
- name: Append build hash if not a tagged commit
188188
if: startsWith(github.ref, 'refs/tags/v') != true
@@ -197,7 +197,7 @@ jobs:
197197
- name: Building wheels
198198
run: python -m pip wheel . -w ./wheelhouse/ --verbose
199199
- name: Auditing wheels
200-
run: ci/repair-whl-macos.sh `pwd`/wheelhouse/* `pwd`/wheelhouse/audited
200+
run: ci/repair-whl-macos.sh `pwd`/wheelhouse/* `pwd`/wheelhouse/audited
201201
- name: Archive wheel artifacts
202202
uses: actions/upload-artifact@v2
203203
with:
@@ -247,7 +247,7 @@ jobs:
247247
- name: Build and install depthai-core
248248
run: |
249249
cmake -S depthai-core/ -B build_core -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/pic.cmake
250-
cmake --build build_core --target install --parallel
250+
cmake --build build_core --target install --parallel 8
251251
echo "DEPTHAI_INSTALLATION_DIR=$PWD/build_core/install/" >> $GITHUB_ENV
252252
253253
- name: Append build hash if not a tagged commit
@@ -309,7 +309,7 @@ jobs:
309309
- name: Build and install depthai-core
310310
run: |
311311
cmake -S depthai-core/ -B build_core -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/pic.cmake
312-
cmake --build build_core --target install --parallel
312+
cmake --build build_core --target install --parallel 8
313313
echo "DEPTHAI_INSTALLATION_DIR=$PWD/build_core/install/" >> $GITHUB_ENV
314314
315315
- name: Append build hash if not a tagged commit
@@ -336,12 +336,12 @@ jobs:
336336
if: startsWith(github.ref, 'refs/tags/v')
337337
needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64, build-linux-arm64]
338338
runs-on: ubuntu-latest
339-
339+
340340
steps:
341341
- uses: actions/checkout@v2
342342
with:
343343
submodules: 'recursive'
344-
344+
345345
- name: Get tag version
346346
id: tag
347347
uses: battila7/get-version-action@v2

CMakeLists.txt

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ endif()
3131
set(TARGET_NAME depthai)
3232
project(depthai VERSION "0") # revision of bindings [depthai-core].[rev]
3333

34+
# Set default build type depending on context
35+
set(default_build_type "Release")
36+
if(EXISTS "${CMAKE_SOURCE_DIR}/.git" AND NOT DEFINED ENV{CI})
37+
set(default_build_type "Debug")
38+
endif()
39+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
40+
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
41+
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
42+
# Set the possible values of build type for cmake-gui
43+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
44+
endif()
45+
3446
# Add module paths
3547
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
3648
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/depthai-core/cmake")
@@ -63,13 +75,13 @@ endif()
6375
hunter_add_package(pybind11)
6476

6577
# Disable LTO if MINGW compiler
66-
if(MINGW)
78+
if(MINGW)
6779
set(PYBIND11_LTO_CXX_FLAGS "" CACHE STRING "" FORCE)
6880
endif()
6981
find_package(pybind11 CONFIG REQUIRED)
7082

7183
# Add files for python module
72-
pybind11_add_module(${TARGET_NAME}
84+
pybind11_add_module(${TARGET_NAME}
7385
src/py_bindings.cpp
7486
src/XLinkConnectionBindings.cpp
7587
src/DeviceBindings.cpp
@@ -92,8 +104,8 @@ endif()
92104

93105
if(DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT)
94106
# If output is specified set both input and output to same the path
95-
set(docstring_input_path ${DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT})
96-
set(docstring_output_path ${DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT})
107+
set(docstring_input_path ${DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT})
108+
set(docstring_output_path ${DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT})
97109
else()
98110
# If input docstrings explicitly specified, use those and disable building
99111
if(DEPTHAI_PYTHON_DOCSTRINGS_INPUT)
@@ -102,11 +114,11 @@ else()
102114
set(DEPTHAI_PYTHON_BUILD_DOCSTRINGS OFF CACHE BOOL "Generate docstrings from header files if module 'pybind11_mkdoc' available" FORCE)
103115
else()
104116
# Otherwise set default location as input
105-
set(docstring_input_path ${DEFAULT_DOCSTRINGS_OUTPUT})
117+
set(docstring_input_path ${DEFAULT_DOCSTRINGS_OUTPUT})
106118
endif()
107119

108120
# Set default output location
109-
set(docstring_output_path ${DEFAULT_DOCSTRINGS_OUTPUT})
121+
set(docstring_output_path ${DEFAULT_DOCSTRINGS_OUTPUT})
110122
endif()
111123

112124
if(DEPTHAI_PYTHON_BUILD_DOCSTRINGS)
@@ -118,11 +130,14 @@ configure_file(cmake/docstring.hpp.in ${DOCSTRINGS_INCLUDE_PLACEHOLDER_PATH})
118130
# Add target to generate docstrings
119131
if (DEPTHAI_PYTHON_BUILD_DOCSTRINGS)
120132
include(pybind11-mkdoc)
121-
133+
122134
# Check if pybind11_mkdoc available and create target
123135
target_pybind11_mkdoc_setup(${docstring_output_path} depthai::core ${DEPTHAI_PYTHON_FORCE_DOCSTRINGS})
124-
125-
if(NOT TARGET pybind11_mkdoc)
136+
137+
if(TARGET pybind11_mkdoc)
138+
# Add dependency to mkdoc target (makes sure that mkdoc is executed, and docstrings available)
139+
add_dependencies(${TARGET_NAME} pybind11_mkdoc)
140+
else()
126141
# Generate default docstrings to OUTPUT path
127142
configure_file(cmake/default_docstring.hpp.in ${docstring_output_path} COPYONLY)
128143
endif()
@@ -135,17 +150,39 @@ endif()
135150
target_include_directories(${TARGET_NAME} PRIVATE src ${DOCSTRINGS_INCLUDE_PLACEHOLDER_DIR})
136151

137152
# Link with libraries
138-
target_link_libraries(${TARGET_NAME}
139-
PUBLIC
153+
target_link_libraries(${TARGET_NAME}
154+
PUBLIC
140155
# pybind11
141156
pybind11::pybind11
142157
depthai::core # Use non-opencv target as we use opencv-python in bindings
143158
hedley
144159
)
145160

146-
# Add default commit hash ('dev') if not build by CI
147-
if(NOT DEFINED ENV{CI} AND NOT DEPTHAI_PYTHON_COMMIT_HASH)
148-
set(DEPTHAI_PYTHON_COMMIT_HASH "dev")
161+
# Find Git
162+
find_package(Git)
163+
164+
# Add build information (commit, date)
165+
set(BUILD_COMMIT "dev")
166+
if(GIT_FOUND)
167+
execute_process(
168+
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
169+
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
170+
OUTPUT_VARIABLE BUILD_COMMIT
171+
ERROR_QUIET
172+
OUTPUT_STRIP_TRAILING_WHITESPACE
173+
)
174+
execute_process(
175+
COMMAND ${GIT_EXECUTABLE} show -s --format=%ci ${BUILD_COMMIT}
176+
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
177+
OUTPUT_VARIABLE BUILD_COMMIT_DATETIME
178+
ERROR_QUIET
179+
OUTPUT_STRIP_TRAILING_WHITESPACE
180+
)
181+
endif()
182+
183+
# Add local commit hash (or 'dev' if unable to retrieve) if not build by CI
184+
if(NOT DEFINED ENV{CI} AND NOT DEPTHAI_PYTHON_COMMIT_HASH)
185+
set(DEPTHAI_PYTHON_COMMIT_HASH ${BUILD_COMMIT})
149186
endif()
150187

151188
# Get version to use
@@ -159,8 +196,15 @@ execute_process(COMMAND ${PYTHON_EXECUTABLE} "-c" "${version_command}"
159196
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
160197
)
161198

162-
# Add version definition
163-
target_compile_definitions(${TARGET_NAME} PRIVATE DEPTHAI_PYTHON_VERSION="${DEPTHAI_PYTHON_VERSION}")
199+
200+
string(TIMESTAMP BUILD_DATETIME "%Y-%m-%d %H:%M:%S +0000" UTC)
201+
target_compile_definitions(${TARGET_NAME}
202+
PRIVATE
203+
DEPTHAI_PYTHON_VERSION="${DEPTHAI_PYTHON_VERSION}"
204+
DEPTHAI_PYTHON_COMMIT_HASH="${BUILD_COMMIT}"
205+
DEPTHAI_PYTHON_COMMIT_DATETIME="${BUILD_COMMIT_DATETIME}"
206+
DEPTHAI_PYTHON_BUILD_DATETIME="${BUILD_DATETIME}"
207+
)
164208

165209
# Set compiler features (c++14), and disables extensions
166210
set_property(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD 14)

README.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,59 @@ python3 -m pip install --extra-index-url https://artifacts.luxonis.com/artifacto
2323
### Dependencies
2424
- cmake >= 3.4
2525
- C++14 compiler (clang, gcc, msvc, ...)
26-
- Python
26+
- Python3
2727

2828
Along these, dependencies of depthai-core are also required
2929
See: [depthai-core dependencies](https://github.com/luxonis/depthai-core#dependencies)
3030

3131

3232
### Building
3333

34-
To build a shared library from source perform the following:
34+
To build and install using pip:
3535
```
36-
git submodule update --init --recursive
37-
mkdir build && cd build
38-
cmake .. [-D PYTHON_EXECUTABLE=/full/path/to/python]
39-
cmake --build . --parallel
36+
python3 -m pip install .
4037
```
38+
Add parameter `-v` to see the output of the building process.
4139

42-
Where `-D PYTHON_EXECUTABLE` option can optionally specify an exact Python executable to use for building.
4340

4441
To build a wheel, execute the following
4542
```
4643
python3 -m pip wheel . -w wheelhouse
4744
```
4845

49-
To build and install using pip:
46+
To build a shared library from source perform the following:
47+
48+
> ℹ️ To speed up build times, use `cmake --build build --parallel [num CPU cores]` (CMake >= 3.12).
49+
For older versions use: Linux/macOS: `cmake --build build -- -j[num CPU cores]`, MSVC: `cmake --build build -- /MP[num CPU cores]`
50+
5051
```
51-
python3 -m pip install .
52+
git submodule update --init --recursive
53+
cmake -H. -Bbuild
54+
cmake --build build
5255
```
56+
To specify custom Python executable to build for, use `cmake -H. -Bbuild -D PYTHON_EXECUTABLE=/full/path/to/python`.
57+
5358

5459
## Running tests
5560

5661
To run the tests build the library with the following options
5762
```
5863
git submodule update --init --recursive
59-
mkdir build_tests && cd build_tests
60-
cmake .. -D DEPTHAI_PYTHON_ENABLE_TESTS=ON -D DEPTHAI_PYTHON_ENABLE_EXAMPLES=ON -D DEPTHAI_PYTHON_TEST_EXAMPLES=ON
61-
cmake --build . --parallel
64+
cmake -H. -Bbuild -D DEPTHAI_PYTHON_ENABLE_TESTS=ON -D DEPTHAI_PYTHON_ENABLE_EXAMPLES=ON -D DEPTHAI_PYTHON_TEST_EXAMPLES=ON
65+
cmake --build build
66+
```
67+
68+
Then navigate to `build` folder and run `ctest`
69+
```
70+
cd build
6271
ctest
6372
```
6473

74+
To test a specific example/test with a custom timeout (in seconds) use following:
75+
```
76+
TEST_TIMEOUT=0 ctest -R "01_rgb_preview" --verbose
77+
```
78+
If `TEST_TIMEOUT=0`, the test will run until stopped or it ends.
6579

6680
## Tested platforms
6781

@@ -94,8 +108,8 @@ ctest
94108
```
95109
python3 -m pip install -U pip
96110
python3 -m pip install -r docs/requirements.txt
97-
cmake -S . -B build -D DEPTHAI_BUILD_DOCS=ON -D DEPTHAI_PYTHON_BUILD_DOCS=ON
98-
cmake --build build --parallel --target sphinx
111+
cmake -H. -Bbuild -D DEPTHAI_BUILD_DOCS=ON -D DEPTHAI_PYTHON_BUILD_DOCS=ON
112+
cmake --build build --target sphinx
99113
python3 -m http.server --bind 0.0.0.0 8000 --directory build/docs/sphinx
100114
```
101115
@@ -105,7 +119,7 @@ ctest
105119
in a new terminal window to update the website source
106120
107121
```
108-
cmake --build build --parallel --target sphinx
122+
cmake --build build --target sphinx
109123
```
110124
111125
Then refresh your page - it should load the updated website that was just built

cmake/Hunter/config.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
hunter_config(
33
pybind11
44
VERSION "2.6.3dev1"
5-
URL "https://github.com/bstaletic/pybind11/archive/a4932c114a3a43c9d0157805a23c0c726e461b96.tar.gz"
6-
SHA1 "e65484c0aa7dc3220123a7e48a50ae7a8cecdd1c"
5+
URL "https://github.com/pybind/pybind11/archive/54430436fee2afc4f8443691075a6208f9ea8eba.tar.gz"
6+
SHA1 "c8550f7d77e92045c996d17f1d214223d1e2e620"
77
)

cmake/pybind11-mkdoc.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,4 @@ function(pybind11_mkdoc_setup_internal target output_path mkdoc_headers enforce)
8080
# Force target build
8181
file(TOUCH_NOCREATE ${mkdoc_headers})
8282

83-
# Add dependency to mkdoc target (makes sure that mkdoc is executed, and docstrings available)
84-
add_dependencies(${target} ${PYBIND11_MKDOC_TARGET_NAME})
85-
8683
endfunction()

depthai-core

Submodule depthai-core updated 73 files

docs/ci.cmake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,16 @@ set(project_root "${CMAKE_CURRENT_LIST_DIR}/..")
44
# Get buildCommitHash for non release build
55
execute_process(COMMAND "git" "rev-parse" "HEAD" WORKING_DIRECTORY ${project_root} OUTPUT_VARIABLE buildCommitHash OUTPUT_STRIP_TRAILING_WHITESPACE)
66

7-
execute_process(COMMAND ${CMAKE_COMMAND} -D DEPTHAI_PYTHON_COMMIT_HASH:STRING=${buildCommitHash} -D DEPTHAI_PYTHON_BUILD_DOCS:BOOL=YES -D DEPTHAI_BUILD_DOCS:BOOL=YES -S . -B build WORKING_DIRECTORY ${project_root} COMMAND_ECHO STDOUT)
7+
# Configure
8+
execute_process(COMMAND ${CMAKE_COMMAND}
9+
-D DEPTHAI_PYTHON_COMMIT_HASH:STRING=${buildCommitHash}
10+
-D DEPTHAI_PYTHON_BUILD_DOCS:BOOL=YES
11+
-D DEPTHAI_BUILD_DOCS:BOOL=YES
12+
-D DEPTHAI_PYTHON_BUILD_DOCSTRINGS:BOOL=YES
13+
-D DEPTHAI_PYTHON_FORCE_DOCSTRINGS:BOOL=YES
14+
-S . -B build
15+
WORKING_DIRECTORY ${project_root} COMMAND_ECHO STDOUT
16+
)
17+
18+
# Build
819
execute_process(COMMAND ${CMAKE_COMMAND} --build build --parallel 4 WORKING_DIRECTORY ${project_root} COMMAND_ECHO STDOUT)

0 commit comments

Comments
 (0)