Skip to content

Commit 7d47edc

Browse files
committed
Add version builder and version file.
Update hardware version table. Thanks to Gadgetoid for new IDs.
1 parent 4f5d727 commit 7d47edc

File tree

6 files changed

+91
-3
lines changed

6 files changed

+91
-3
lines changed

SConscript

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ lib_srcs = Split('''
4141
rpihw.c
4242
''')
4343

44+
version_hdr = tools_env.Version('version')
4445
ws2811_lib = tools_env.Library('libws2811', lib_srcs)
4546
tools_env['LIBS'].append(ws2811_lib)
4647

SConstruct

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ opts.Add(BoolVariable('V',
3737

3838
platforms = [
3939
[
40-
'userspace', # Target Name
41-
'linux', # Scons tool (linux, avr, etc.)
40+
'userspace', # Target Name
41+
[ 'linux', 'version' ], # Scons tool (linux, avr, etc.)
4242
{ # Special environment setup
4343
'CPPPATH' : [
4444
],
@@ -52,7 +52,7 @@ clean_envs = {}
5252
for platform, tool, flags in platforms:
5353
env = Environment(
5454
options = opts,
55-
tools = [ tool ],
55+
tools = tool,
5656
toolpath = ['.'],
5757
ENV = {'PATH' : os.environ['PATH']},
5858
LIBS = [],

main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static char VERSION[] = "testing...";
4848
#include "gpio.h"
4949
#include "dma.h"
5050
#include "pwm.h"
51+
#include "version.h"
5152

5253
#include "ws2811.h"
5354

rpihw.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ static const rpi_hw_t rpi_hw_info[] = {
171171
.videocore_base = VIDEOCORE_BASE_RPI,
172172
.desc = "Compute Module",
173173
},
174+
{
175+
.hwver = 0x14,
176+
.type = RPI_HWVER_TYPE_PI1,
177+
.periph_base = PERIPH_BASE_RPI,
178+
.videocore_base = VIDEOCORE_BASE_RPI,
179+
.desc = "Compute Module",
180+
},
174181

175182
//
176183
// Pi Zero
@@ -218,6 +225,13 @@ static const rpi_hw_t rpi_hw_info[] = {
218225
.videocore_base = VIDEOCORE_BASE_RPI2,
219226
.desc = "Pi 2",
220227
},
228+
{
229+
.hwver = 0xa01040,
230+
.type = RPI_HWVER_TYPE_PI2,
231+
.periph_base = PERIPH_BASE_RPI2,
232+
.videocore_base = VIDEOCORE_BASE_RPI2,
233+
.desc = "Pi 2",
234+
},
221235
{
222236
.hwver = 0xa21041,
223237
.type = RPI_HWVER_TYPE_PI2,

version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

version.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#
2+
# SConstruct
3+
#
4+
# Copyright (c) 2016 Jeremy Garff <jer @ jers.net>
5+
#
6+
# All rights reserved.
7+
#
8+
# Redistribution and use in source and binary forms, with or without modification, are permitted
9+
# provided that the following conditions are met:
10+
#
11+
# 1. Redistributions of source code must retain the above copyright notice, this list of
12+
# conditions and the following disclaimer.
13+
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
14+
# of conditions and the following disclaimer in the documentation and/or other materials
15+
# provided with the distribution.
16+
# 3. Neither the name of the owner nor the names of its contributors may be used to endorse
17+
# or promote products derived from this software without specific prior written permission.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
20+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21+
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
22+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26+
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
#
28+
29+
import SCons, os
30+
31+
def version_flags(env):
32+
if not env['V']:
33+
env['VERSIONCOMSTR'] = 'Version ${TARGET}'
34+
35+
def version_builders(env):
36+
def generate_version_header(target, source, env):
37+
headername = os.path.basename(target[0].abspath)
38+
headerdef = headername.replace('.', '_').replace('-', '_').upper()
39+
40+
try:
41+
version = open(source[0].abspath, 'r').readline().strip().split('.')
42+
except:
43+
version = [ '0', '0', '0' ]
44+
45+
f = open(headername, 'w')
46+
f.write('/* Auto Generated Header built by version.py - DO NOT MODIFY */\n')
47+
f.write('\n')
48+
f.write('#ifndef __%s__\n' % (headerdef))
49+
f.write('#define __%s__\n' % (headerdef))
50+
f.write('\n')
51+
f.write('#define VERSION_MAJOR %s\n' % version[0])
52+
f.write('#define VERSION_MINOR %s\n' % version[1])
53+
f.write('#define VERSION_MICRO %s\n' % version[2])
54+
f.write('\n')
55+
f.write('#endif /* __%s__ */\n' % (headerdef))
56+
f.close()
57+
58+
env.Append(BUILDERS = {
59+
'Version' : SCons.Builder.Builder(
60+
action = SCons.Action.Action(generate_version_header, '${VERSIONCOMSTR}'),
61+
suffix = '.h',
62+
),
63+
})
64+
65+
def exists(env):
66+
return 1
67+
68+
def generate(env, **kwargs):
69+
[f(env) for f in (version_flags, version_builders)]
70+
71+

0 commit comments

Comments
 (0)