Skip to content

Commit 808f9d8

Browse files
committed
MySensors 2.1.0 release
2 parents 0183b76 + add3f5f commit 808f9d8

File tree

216 files changed

+27745
-26498
lines changed

Some content is hidden

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

216 files changed

+27745
-26498
lines changed

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with UTF-8 encoding for every file
7+
[*]
8+
end_of_line = lf
9+
charset = utf-8
10+
11+
# For all source code
12+
[*.{c,cpp,h,ino,sh}]
13+
insert_final_newline = true
14+
indent_style = tab
15+
indent_size = 2
16+
17+
# Tab indentation also for makefiles
18+
[Makefile]
19+
indent_style = tab

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Set default behaviour, in case users don't have core.autocrlf set.
2-
* text=auto
2+
* text eol=lf
33

44
# Explicitly declare text files we want to always be normalized and converted
55
# to native line endings on checkout.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ stino.settings
44
MyPrivateConfig.h
55
Documentation/html
66
doxygen_sqlite3.db
7+
Makefile.inc
8+
build
9+
bin
10+
*.sublime-workspace

.mystools/.bundle_runtime.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
###
3+
#
4+
# Tool runtime shim that provides a simple API for running
5+
# tool bundles and convenience functions for other tool developers.
6+
#
7+
##
8+
log() { IFS=" "; >&2 printf "%s\n" "$*"; }
9+
info() { IFS=" "; >&2 printf "\e[92m%s\e[m\n" "$*"; }
10+
warn() { IFS=" "; >&2 printf "\e[93m%s\e[m\n" "$*"; }
11+
err() { IFS=" "; >&2 printf "\e[91m%s\e[m\n" "$*"; exit 1; }
12+
13+
is_supported_os()
14+
{
15+
[[ ${1} == darwin* ]] || [[ ${1} == linux-gnu* ]] || [[ ${1} == freebsd ]] || [[ ${1} == msys ]] || [[ ${1} == cygwin ]]
16+
}
17+
18+
is_installed()
19+
{
20+
which "${1}" > /dev/null 2>&1
21+
}
22+
23+
tools_dir()
24+
{
25+
git_config_tools_dir='git config mysensors.toolsdir'
26+
27+
# Set mysensors.toolsdir in git config if it hasn't been set
28+
if [[ ! $($git_config_tools_dir) || ! -d "$($git_config_tools_dir)" ]]; then
29+
$git_config_tools_dir "$( cd "$(dirname "${BASH_SOURCE[0]}")"; git rev-parse --show-prefix )"
30+
git config alias.mystoolspath '![ -z "${GIT_PREFIX}" ] || cd ${GIT_PREFIX}; echo $(git rev-parse --show-cdup)$(git config mysensors.toolsdir)'
31+
fi
32+
33+
$git_config_tools_dir
34+
}
35+
36+
configure_git_tool_aliases()
37+
{
38+
find "$(git mystoolspath)" -name run.sh -print0 | while IFS= read -r -d '' bundle; do
39+
local tool="$(basename "$(dirname "${bundle}")")"
40+
git config alias.${tool} '!f() { $(git mystoolspath)'${tool}'/run.sh $@; }; f'
41+
done
42+
}
43+
44+
bootstrap_cksum()
45+
{
46+
echo $(git ls-files -s -- $(git mystoolspath)bootstrap-dev.sh | cut -d' ' -f2)
47+
}
48+
49+
bootstrap_version()
50+
{
51+
git_config_bootstrap_version='git config mysensors.bootstrap-cksum'
52+
if [[ $1 == --set ]]; then
53+
$git_config_bootstrap_version $(bootstrap_cksum)
54+
else
55+
echo $($git_config_bootstrap_version)
56+
fi
57+
}
58+
59+
environment_outdated()
60+
{
61+
[[ $(bootstrap_version) != $(bootstrap_cksum) ]]
62+
}
63+
64+
modifiedSourceFiles()
65+
{
66+
against=$(git rev-parse --verify HEAD >/dev/null 2>&1 && echo HEAD || echo 4b825dc642cb6eb9a060e54bf8d69288fbee4904)
67+
git diff $1 --diff-filter=AM --name-only $against | grep -E '.*\.(c|cpp|h|hpp|ino)$'
68+
}
69+
70+
stagedSourceFiles()
71+
{
72+
modifiedSourceFiles '--cached'
73+
}
74+
75+
runBundle()
76+
{
77+
local bundle="$(dirname "${0}")"
78+
local tool=$(basename "${bundle}")
79+
80+
local CMD_OPTIONS=$( TOOLCONFIG="${bundle}/config" "${bundle}/options.sh" )
81+
82+
$tool $CMD_OPTIONS "$@"
83+
}
84+
85+
###
86+
# Common environment variables
87+
#
88+
$(git rev-parse --is-inside-work-tree --quiet >/dev/null 2>&1) || err "Working directory is not a git repository. aborting..."
89+
90+
if [[ $(basename "${0}") != *bootstrap* ]] && environment_outdated ; then
91+
err "Your environment is out of date... Re-run $(git mystoolspath)bootstrap-dev.sh and try again"
92+
fi
93+
94+
GITREPO=$(git rev-parse --show-toplevel)
95+
GITDIR=$(git rev-parse --git-dir)
96+
TOOLSDIR="$(tools_dir)"

.mystools/README.md

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
# Development Tools
2+
3+
### Overview
4+
5+
This directory hosts MySensors development tools. The following
6+
conventions are employed to facilitate consistent re-use/invocation
7+
across modalitiies (e.g. local development, continuous integration,
8+
editor linters, etc.)
9+
10+
1. All common tools are hosted and managed in
11+
the tools directory (used for both local development
12+
and continuous integration)
13+
2. Each tool comprises a directory, akin to a bundle,
14+
that encapsulates declarative command-line options,
15+
configuration files and a run script
16+
3. A single bootstrap script configures a
17+
development environment
18+
4. A lightweight runtime provides a common set of
19+
convenience functions and variables to all scripts
20+
5. Support for all MySensors development environments
21+
22+
### Usage
23+
24+
The [boostrap-dev](bootstrap-dev.sh) script completely configures a
25+
development environment. The boostrap-dev script validates development
26+
prerequisites such as verifying the git repo ```origin``` &
27+
```upstream``` remotes, tools needed for the git client hooks,
28+
installing local commit hooks, and creating git aliases, etc.
29+
30+
```shell-script
31+
$ cd MySensors # git repo
32+
$ .mystools/bootstrap-dev.sh
33+
Checking operating system support: darwin16...
34+
Checking github 'origin' & 'upstream' remotes...
35+
Checking tool/utility prerequisites...
36+
Installing git client-side hooks...
37+
Configuring git aliases for running mysensor tool bundles...
38+
Successfully configured your repo for MySensors development... Thanks for your support!
39+
$
40+
```
41+
**Note:** If the bootstrap can not find required command-line
42+
utilities, you will be requested to install the required tools and
43+
re-run bootstrap.sh. See [Installation instructions for prerequisite
44+
tools](#installtools).
45+
46+
Once the bootstrapping process is complete, a git alias for each tool
47+
is available to conveniently run the tool with the pre-configured
48+
mysensors options and settings (no need to remember all those
49+
command-line options or where the configuration files reside).
50+
Furthermore, you can run the command against staged files, unstaged
51+
modified files or a list of files common to most git commands.
52+
53+
```shell-script
54+
$ # Run cppcheck on an individual file
55+
$ git cppcheck core/MyMessage.cpp
56+
$
57+
$ # Run cppcheck on all changed files
58+
$ git cppcheck
59+
$
60+
$ # Run astyle on staged files
61+
$ git astyle --cached
62+
```
63+
64+
Available tool aliases:
65+
66+
* git cppcheck [--cached] [files]
67+
* git astyle [--cached] [files]
68+
69+
Finally, to maintain code quality and a legible git revision history,
70+
two git hooks are installed that will trigger whenever you commit
71+
changes to your local repo. The hooks will examine your changes to
72+
ensure they satisfy the [MySensors Code Contribution
73+
Guidelines](https://www.mysensors.org/download/contributing) before
74+
you push your changes to GitHub for merging by the core MySensors
75+
team. Gitler will also enforce the coding guidelines so the hooks are
76+
provided to reduce development cycle times by detecting standards
77+
variances locally before pushing to GitHub.
78+
79+
### <a name="installtools"></a>Installation instructions for prerequisite tools
80+
81+
This first time you run the bootstrap script, it may inform you that
82+
certain development tools are missing from your path or system:
83+
84+
```
85+
Checking operating system support: darwin16...
86+
Checking github 'origin' & 'upstream' remotes...
87+
Checking tool/utility prerequisites...
88+
astyle not installed or not in current path.
89+
cppcheck not installed or not in current path.
90+
One or more required tools not found. Install required tools and re-run .mystools/bootstrap-dev.sh
91+
```
92+
93+
To finish the bootstrap process, you will need to install the required
94+
tools for your specific operating system as follows. Currently we use
95+
Astyle 2.0.5 or later and Cppcheck 1.76 or later. Once you have
96+
installed AStyle and Cppcheck, re-run bootstrap-dev.sh to finish
97+
configuring your development environment.
98+
99+
##### macOS
100+
101+
```brew install astyle cppcheck```
102+
103+
#### Linux Xenial or later
104+
105+
```apt-get install astyle cppcheck```
106+
107+
#### Linux Trusty or earlier
108+
109+
##### Note: The apt versions are too old on Trusty so follow the [Linux - Build and Install from Source](#buildFromSource) instructions
110+
111+
##### Windows - GitHub Git Shell
112+
113+
###### *IMPORTANT: Be sure to launch PowerShell As Administrator*
114+
115+
```
116+
### Install AStyle
117+
118+
# Download
119+
iwr 'https://sourceforge.net/projects/astyle/files/astyle/astyle%202.05.1/AStyle_2.05.1_windows.zip/download' -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox -OutFile astyle.2.05.zip
120+
121+
# Unzip the filed & move the C:\Program Files
122+
expand-archive astyle.2.05.zip
123+
mv .\astyle.2.05 'C:\Program Files\AStyle\'
124+
125+
# Add AStyle to your path
126+
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\AStyle\bin", [EnvironmentVariableTarget]::Machine)
127+
128+
### Install Cppcheck (either 64-bit or 32-bit depending upon your version of Windows - pick one below)
129+
130+
# 64-bit
131+
iwr 'http://github.com/danmar/cppcheck/releases/download/1.76.1/cppcheck-1.76.1-x64-Setup.msi' -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox -OutFile cppcheck-1.76.1-Setup.msi
132+
133+
# 32-bit
134+
iwr 'http://github.com/danmar/cppcheck/releases/download/1.76.1/cppcheck-1.76.1-x86-Setup.msi' -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox -OutFile cppcheck-1.76.1-Setup.msi
135+
136+
# Launch installer to install Cppcheck
137+
& .\cppcheck-1.76.1-Setup.msi
138+
139+
### Add Cppcheck to your path
140+
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\Cppcheck", [EnvironmentVariableTarget]::Machine)
141+
142+
### At this point you need to reboot for the path changes to take effect
143+
```
144+
145+
##### Windows - bash
146+
147+
###### NOTE: At the time of this writing, the apt vresions of cppcheck and astyle are too old. Follow the [Linux - Build and Install from Source](#buildFromSource) instructions
148+
149+
##### Windows - Cygwin
150+
```
151+
Run Either Cygwin Setup-x86-64.exe or Setup-x86.exe depending upon your OS. Select and install astyle and cppcheck
152+
```
153+
154+
##### <a name="buildFromSource"></a>Linux - Build and Install from Source
155+
156+
```
157+
### Install AStyle
158+
159+
# Download
160+
curl -L 'https://sourceforge.net/projects/astyle/files/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz/download' | tar xvz
161+
162+
# Compile and install
163+
cd astyle/build/gcc && sudo make shared release shared static install
164+
165+
### Install Cppcheck
166+
167+
# Download
168+
curl -L 'https://sourceforge.net/projects/cppcheck/files/cppcheck/1.76.1/cppcheck-1.76.1.tar.gz/download' | tar xvz
169+
170+
# Compile and install
171+
cd cppcheck-1.76.1
172+
sudo apt-get install libpcre++-dev
173+
sudo make SRCDIR=build CFGDIR=/usr/share/cppcheck HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function" install
174+
175+
```
176+
177+
### Implementation Details
178+
179+
*This section is intended for developers curious about the
180+
implementation details or interested in extending the development
181+
environment to support additional tools, aliases, etc.*
182+
183+
A lightweight [runtime](.bundle_runtime.sh) (less than 70 lines of
184+
code) provides a simple API to consistently run the MySensors toolset
185+
across modalities including, but not limited to, local development and
186+
continuous integration. The core concept is that each tool
187+
encapsulates all runtime configuration settings in a simple,
188+
stand-alone bundle, that can be executed by the bundle runtime. The
189+
runtime provides an API to execute a tool bundle along with
190+
convenience functions and environment variables common to all tools.
191+
192+
Each tool bundle is laid out as follows:
193+
194+
```
195+
${TOOLSDIR} [e.g. ${GITREPO}/.mystools}]
196+
.../tool [e.g. cppcheck, astyle]
197+
....../run.sh [tool run script]
198+
....../options.sh [command-line options]
199+
....../config [supporting config files]
200+
........./some.cfg
201+
```
202+
203+
All bundle runtime dependencies are defined withing the namespace /
204+
context of a git repo so users are free to rename or move repos or
205+
even use multiple copies of the same repo without encountering
206+
intra-repo tool settings/configuration conflicts.
207+
208+
During the bootstrap process, certain keys and aliases are defined
209+
that the runtime leverages.
210+
211+
#####git config keys
212+
213+
* mysensors.toolsdir = .mystools (defined as a repo-relative path - location agnostic)
214+
* mysensors.bootstrap-cksum = \<git sha of bootstrap-dev.sh used to detect an outdated environment>
215+
216+
#####git aliases
217+
218+
* mystoolspath = *returns the absolute path to the tools dir*
219+
* \<bundle name> = *(e.g. cppcheck) runs the tool bundle*
220+
221+
NOTE: The \<bundle> aliases are auto-generated by enumerating the bundles located
222+
in *mystoolspath*.
223+
224+
While the ```git <tool> args``` API is designed to cover many the
225+
common use cases, tool and hook authors may need to source the
226+
[runtime](.bundle_runtime.sh) into their script context in order to
227+
use the convenience functions and environment variables as follows:
228+
229+
```shell-script
230+
. "$(git config mystoolspath).bundle_runtime.sh"
231+
```
232+
233+
The runtime shim will instantiate the following environment variables
234+
and convenience functions in the script context for use within a tool
235+
or script.
236+
237+
```
238+
TOOLSDIR - absolute path to repo tools dir. Maintained in
239+
a location-agnostic fashion (e.g. if the user
240+
moves the repo, changes tools directory within
241+
repo, etc.
242+
GITREPO - absolute path to the git repo
243+
GITDIR - absolute path to the repo .git directory
244+
245+
runBundle() - Run a given tool / bundle
246+
is_installed() - true if a given utility is installed
247+
supported_os() - true if running on a supported os
248+
log() - log a message in default color to console
249+
warn() - log a message in yellow to console
250+
err() - log a message in red and exit with non-zero status
251+
```
252+
253+
Many of the aforementioned details can be safely ignored if you want
254+
to add a new development tool to the toolset. Simply create a bundle
255+
that follows the layout above, declare the tool command-line options
256+
in the [bundle]/options.sh and any configuration files in
257+
[bundle]/config/. While it should not be necessary to alter the
258+
bundle execution behavior beyond declaring command-line options and
259+
configuration files, you can override it by modifing the [bundle]
260+
run.sh script.

0 commit comments

Comments
 (0)