Skip to content

Commit e62ecc9

Browse files
committed
BitBox02 public release
0 parents  commit e62ecc9

File tree

706 files changed

+291903
-0
lines changed

Some content is hidden

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

706 files changed

+291903
-0
lines changed

.ci/check-pep8

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env bash
2+
3+
# This script checks only that the modified files follow pep8
4+
5+
# Fail on error
6+
set -e
7+
8+
# Exit on pipe fail
9+
set -o pipefail
10+
11+
PYLINT=${PYLINT:-pylint}
12+
BLACK=${BLACK:-black}
13+
14+
command -v git >/dev/null 2>&1 || { echo >&2 "git is missing"; exit 1; }
15+
command -v ${PYLINT} >/dev/null 2>&1 || { echo >&2 "${PYLINT} is missing"; exit 1; }
16+
command -v ${BLACK} >/dev/null 2>&1 || { echo >&2 "${BLACK} is missing"; exit 1; }
17+
18+
# check if stdout is a terminal.
19+
if test -t 1; then
20+
# see if it supports colors.
21+
ncolors=$(tput colors)
22+
if test -n "$ncolors" && test $ncolors -ge 8; then
23+
normal="$(tput sgr0)"
24+
red="$(tput setaf 1)"
25+
green="$(tput setaf 2)"
26+
fi
27+
fi
28+
29+
# pylint returns a bitmask as status code:
30+
#
31+
# 0 no error
32+
# 1 fatal message issued
33+
# 2 error message issued
34+
# 4 warning message issued
35+
# 8 refactor message issued
36+
# 16 convention message issued
37+
# 32 usage error
38+
39+
# grep will exit with 1 if no lines are found
40+
FILES=$(git --no-pager diff --diff-filter=d --name-only origin/master | grep -v "old/" | grep -E ".py\$" || exit 0)
41+
if [ -z "${FILES}" ] ; then
42+
exit 0
43+
fi
44+
45+
${BLACK} --check --fast ${FILES}
46+
47+
${PYLINT} --persistent=no ${FILES} || {
48+
pylint_status=$?
49+
exitcode=0
50+
if (( ${pylint_status} \& 1 )); then
51+
echo fatal messsage >&2
52+
exitcode=2
53+
fi
54+
if (( ${pylint_status} \& 2 )); then
55+
echo error messsage >&2
56+
exitcode=2
57+
fi
58+
if (( ${pylint_status} \& 4 )); then
59+
echo warning messsage >&2
60+
exitcode=2
61+
fi
62+
if (( ${pylint_status} \& 8 )); then
63+
echo refactor messsage >&2
64+
fi
65+
if (( ${pylint_status} \& 16 )); then
66+
echo convention messsage >&2
67+
fi
68+
# This should not happen!
69+
if (( ${pylint_status} \& 32 )); then
70+
echo usage error >&2
71+
exitcode=2
72+
fi
73+
exit ${exitcode}
74+
}

.ci/check-style

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
# This script checks only that the modified files follow the code style.
4+
5+
# Fail on error
6+
set -e
7+
8+
# Exit on pipe fail
9+
set -o pipefail
10+
11+
CLANGFORMAT=${CLANGFORMAT:-clang-format-7}
12+
13+
command -v git >/dev/null 2>&1 || { echo >&2 "git is missing"; exit 1; }
14+
command -v xargs >/dev/null 2>&1 || { echo >&2 "xargs is missing"; exit 1; }
15+
command -v ${CLANGFORMAT} >/dev/null 2>&1 || { echo >&2 "${CLANGFORMAT} is missing"; exit 1; }
16+
17+
# check if stdout is a terminal.
18+
if test -t 1; then
19+
# see if it supports colors.
20+
ncolors=$(tput colors)
21+
if test -n "$ncolors" && test $ncolors -ge 8; then
22+
normal="$(tput sgr0)"
23+
red="$(tput setaf 1)"
24+
green="$(tput setaf 2)"
25+
fi
26+
fi
27+
28+
if git --no-pager diff --diff-filter=d --name-only origin/master | grep -v -E "(^src/(drivers|ui/fonts)|.*ugui.*|.*base32.*)" | grep -E "^(src|test)" | grep -E "\.(c|h)\$" | xargs -n1 "$CLANGFORMAT" -output-replacements-xml | grep -c "<replacement " >/dev/null; then
29+
echo -e "${red}Not $CLANGFORMAT clean${normal}"
30+
# Apply CF to the files
31+
git --no-pager diff --diff-filter=d --name-only origin/master | grep -v -E "(^src/(drivers|ui/fonts)|.*ugui.*|.*base32.*)" | grep -E "^(src|test)" | grep -E "\.(c|h)\$" | xargs -n1 "$CLANGFORMAT" -i
32+
# Print list of files that weren't formatted correctly
33+
echo -e "Incorrectly formatted files:"
34+
git --no-pager diff --name-only
35+
# Print the diff
36+
echo -e "Detailed git diff"
37+
git --no-pager diff
38+
exit 1
39+
fi

.clang-format

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Chromium
4+
ColumnLimit: 100
5+
IndentWidth: 4
6+
AlignAfterOpenBracket: AlwaysBreak
7+
AlignTrailingComments: false
8+
AllowShortLoopsOnASingleLine: true
9+
AllowShortIfStatementsOnASingleLine: true
10+
BinPackArguments: false
11+
BreakBeforeBraces: Linux
12+
IndentCaseLabels: false
13+
PenaltyReturnTypeOnItsOwnLine: 1000
14+
SpacesBeforeTrailingComments: 1
15+
# cmocka must come after some std includes
16+
IncludeCategories:
17+
- Regex: '^(<|")cmocka'
18+
Priority: 2
19+
- Regex: '.*'
20+
Priority: 1
21+
...
22+

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
build
2+
build-vagrant
3+
version.h
4+
NOTES.md
5+
.vagrant
6+
.DS_Store
7+
.ycm*
8+
*.o
9+
*.pyc
10+
*.sw*
11+
*.bak
12+
*.bin
13+
!*.c
14+
15+
# gnu global
16+
/src/GPATH
17+
/src/GRTAGS
18+
/src/GTAGS
19+
20+
.vimrc
21+
external/*
22+
!external/cryptoauthlib
23+
!external/ctaes
24+
!external/CMakeLists.txt
25+
src/generated
26+
py/bitbox02/generated

.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[submodule "tools/nanopb"]
2+
path = tools/nanopb
3+
url = https://github.com/shiftdevices/nanopb.git
4+
[submodule "external/cryptoauthlib"]
5+
path = external/cryptoauthlib
6+
url = https://github.com/shiftdevices/cryptoauthlib.git
7+
[submodule "external/ctaes"]
8+
path = external/ctaes
9+
url = https://github.com/digitalbitbox/ctaes.git

.pylintrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[MASTER]
2+
# hid is a c-extension, so we have to allow it to be loaded into python memory.
3+
extension-pkg-whitelist=hid
4+
5+
[BASIC]
6+
# Shorter functions are excempt from docstring
7+
docstring-min-length=10
8+
9+
[MESSAGES CONTROL]
10+
# Black/pylint mismatch on code formatting
11+
disable=bad-continuation, fixme

0 commit comments

Comments
 (0)