workshop 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +23 -0
- data/Rakefile +1 -0
- data/bin/workshop +3 -0
- data/examples/blink/Rakefile +15 -0
- data/examples/blink/config/com_port.yml +2 -0
- data/examples/blink/src/blink.cpp +30 -0
- data/lib/workshop.rb +18 -0
- data/lib/workshop/arduino.rb +34 -0
- data/lib/workshop/builder.rb +199 -0
- data/lib/workshop/cli.rb +23 -0
- data/lib/workshop/project.rb +99 -0
- data/lib/workshop/project/configuration.rb +71 -0
- data/lib/workshop/project/configuration/build.rb +18 -0
- data/lib/workshop/project/configuration/upload.rb +15 -0
- data/lib/workshop/project/setup.rb +76 -0
- data/lib/workshop/tasks.rb +64 -0
- data/lib/workshop/templates/Rakefile.erb +13 -0
- data/lib/workshop/templates/blink.cpp +30 -0
- data/lib/workshop/tools.rb +56 -0
- data/lib/workshop/uploader.rb +35 -0
- data/lib/workshop/version.rb +3 -0
- data/spec/arduino_spec.rb +31 -0
- data/spec/build_configuration_spec.rb +52 -0
- data/spec/builder_spec.rb +159 -0
- data/spec/configuration_spec.rb +38 -0
- data/spec/project_spec.rb +29 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/tools_spec.rb +33 -0
- data/spec/upload_configuration_spec.rb +9 -0
- data/workshop.gemspec +31 -0
- metadata +186 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9870f8948edd099f794820edd95ce571d6a63f91
|
4
|
+
data.tar.gz: 53375c9b212cc79172241e5b1ea2a680cb8b2321
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 39fd47e99f2761874540c3d89536a281b82f35da3a4c2eeccfe5491cbe2ef4412d86dca323003df528971d1d524f67aad466c1a461f5669dbd692cf3bf81b0b4
|
7
|
+
data.tar.gz: d3ae1227900daa6f9b6ff8cdeb5c10bf68e106991f47c2053e05397f457feb88a44f8e4b2e6fd2ace746dfa28f9b1205faed86731d75d34e7aa89120c962d728
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Chase McCarthy
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Workshop
|
2
|
+
|
3
|
+
An Arduino project build system designed to make Arduino development more fun and less... crappy
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem:
|
8
|
+
|
9
|
+
$ gem install workshop
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Use the workshop:
|
14
|
+
|
15
|
+
$ workshop create blink
|
16
|
+
|
17
|
+
$ cd blink/
|
18
|
+
|
19
|
+
$ rake
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
Pull requests and comments welcome!
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/workshop
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'workshop'
|
2
|
+
|
3
|
+
Workshop::Project.configure do |config|
|
4
|
+
# Configured for an Arduino Fio v3
|
5
|
+
config.project_name = 'blink'
|
6
|
+
config.build.mcu = 'atmega32u4'
|
7
|
+
config.build.core = 'arduino'
|
8
|
+
config.build.variant = 'promicro'
|
9
|
+
config.build.vid = '0x1B4F'
|
10
|
+
config.build.pid = '0x9204'
|
11
|
+
config.build.f_cpu = '8000000L'
|
12
|
+
config.build.includes << '~/Documents/Arduino/hardware/SF32u4_boards/variants/promicro'
|
13
|
+
config.upload.protocol = 'avr109'
|
14
|
+
config.upload.speed = 57600
|
15
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#line 1 "Blink.ino"
|
2
|
+
/*
|
3
|
+
Blink
|
4
|
+
Turns on an LED on for one second, then off for one second, repeatedly.
|
5
|
+
|
6
|
+
This example code is in the public domain.
|
7
|
+
*/
|
8
|
+
|
9
|
+
// Pin 13 has an LED connected on most Arduino boards.
|
10
|
+
// give it a name:
|
11
|
+
#include "Arduino.h"
|
12
|
+
void setup();
|
13
|
+
void loop();
|
14
|
+
#line 10
|
15
|
+
int led = 13;
|
16
|
+
|
17
|
+
// the setup routine runs once when you press reset:
|
18
|
+
void setup() {
|
19
|
+
// initialize the digital pin as an output.
|
20
|
+
pinMode(led, OUTPUT);
|
21
|
+
}
|
22
|
+
|
23
|
+
// the loop routine runs over and over again forever:
|
24
|
+
void loop() {
|
25
|
+
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
|
26
|
+
delay(100); // wait for a second
|
27
|
+
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
|
28
|
+
delay(100); // wait for a second
|
29
|
+
}
|
30
|
+
|
data/lib/workshop.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "yaml"
|
3
|
+
require "active_support/core_ext/string/inflections"
|
4
|
+
# Get rid of deprication warning
|
5
|
+
I18n.enforce_available_locales = false
|
6
|
+
require "workshop/version"
|
7
|
+
require "workshop/project"
|
8
|
+
require "workshop/builder"
|
9
|
+
require "workshop/uploader"
|
10
|
+
require "workshop/arduino"
|
11
|
+
require "workshop/tools"
|
12
|
+
require "workshop/tasks"
|
13
|
+
require "workshop/project/configuration"
|
14
|
+
require "workshop/project/configuration/build"
|
15
|
+
require "workshop/project/configuration/upload"
|
16
|
+
|
17
|
+
module Workshop
|
18
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Workshop
|
2
|
+
class Arduino
|
3
|
+
attr_accessor :config
|
4
|
+
|
5
|
+
def initialize(config)
|
6
|
+
self.config = config
|
7
|
+
end
|
8
|
+
|
9
|
+
def hardware_path
|
10
|
+
'/Contents/Resources/Java/hardware'
|
11
|
+
end
|
12
|
+
|
13
|
+
def hardware_directory
|
14
|
+
config.arduino_app_directory + hardware_path
|
15
|
+
end
|
16
|
+
|
17
|
+
def core_directory
|
18
|
+
hardware_directory + '/arduino/cores/' + config.build_core
|
19
|
+
end
|
20
|
+
|
21
|
+
def variant_directory
|
22
|
+
# TODO - find proper variant dir (could be in documents)
|
23
|
+
if config.build_variant
|
24
|
+
dir = hardware_directory + '/arduino/variants/' + config.build_variant
|
25
|
+
if File.directory?(dir)
|
26
|
+
dir
|
27
|
+
else
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
module Workshop
|
2
|
+
class Builder
|
3
|
+
include FileUtils
|
4
|
+
attr_accessor :project, :tools
|
5
|
+
|
6
|
+
def initialize(project)
|
7
|
+
self.project = project
|
8
|
+
self.tools = Workshop::Tools.new project.arduino_hardware_directory
|
9
|
+
end
|
10
|
+
|
11
|
+
def main_name
|
12
|
+
project.name.parameterize.underscore
|
13
|
+
end
|
14
|
+
|
15
|
+
def main_filename
|
16
|
+
if project.main_filename
|
17
|
+
project.app_directory + '/' + project.main_filename
|
18
|
+
else
|
19
|
+
source_files.first
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_build_directory
|
24
|
+
Dir.mkdir(project.build_directory) unless Dir.exists?(project.build_directory)
|
25
|
+
end
|
26
|
+
|
27
|
+
def clean
|
28
|
+
FileUtils.rm_rf(project.build_directory)
|
29
|
+
end
|
30
|
+
|
31
|
+
def core_files
|
32
|
+
code_files_in_directory project.arduino_core_directory
|
33
|
+
end
|
34
|
+
|
35
|
+
def variant_files
|
36
|
+
code_files_in_directory(project.arduino_variant_directory)
|
37
|
+
end
|
38
|
+
|
39
|
+
def source_files
|
40
|
+
code_files_in_directory project.source_directory
|
41
|
+
end
|
42
|
+
|
43
|
+
def all_source_files
|
44
|
+
core_files + variant_files + source_files
|
45
|
+
end
|
46
|
+
|
47
|
+
def compile_command_for(filename)
|
48
|
+
[
|
49
|
+
tools.compiler(filename),
|
50
|
+
compiler_flags,
|
51
|
+
include_flags,
|
52
|
+
filename,
|
53
|
+
"-o #{output_file(filename)}"
|
54
|
+
].join(' ')
|
55
|
+
end
|
56
|
+
|
57
|
+
def archive_command_for(filename)
|
58
|
+
[
|
59
|
+
tools.avr_ar,
|
60
|
+
'rcs',
|
61
|
+
archive_file,
|
62
|
+
filename,
|
63
|
+
].join(' ')
|
64
|
+
end
|
65
|
+
|
66
|
+
def compile
|
67
|
+
all_source_files.each do |filename|
|
68
|
+
sh compile_command_for(filename)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def o_files_to_archive
|
73
|
+
all_source_files.reject do |filename|
|
74
|
+
filename == main_output_file
|
75
|
+
end.map { |filename| output_file(filename) }
|
76
|
+
end
|
77
|
+
|
78
|
+
def archive
|
79
|
+
o_files_to_archive.each do |filename|
|
80
|
+
sh archive_command_for(filename)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def output_file(filename)
|
85
|
+
project.build_directory + '/' + File.basename(filename) + '.o'
|
86
|
+
end
|
87
|
+
|
88
|
+
def main_output_file
|
89
|
+
project.build_directory + '/' + File.basename(main_filename) + '.o'
|
90
|
+
end
|
91
|
+
|
92
|
+
def archive_file
|
93
|
+
project.build_directory + '/core.a'
|
94
|
+
end
|
95
|
+
|
96
|
+
def elf_file
|
97
|
+
project.build_directory + '/' + main_name + '.elf'
|
98
|
+
end
|
99
|
+
|
100
|
+
def eeprom_file
|
101
|
+
project.build_directory + '/' + main_name + '.eep'
|
102
|
+
end
|
103
|
+
|
104
|
+
def hex_file
|
105
|
+
project.build_directory + '/' + main_name + '.hex'
|
106
|
+
end
|
107
|
+
|
108
|
+
def linker_flags
|
109
|
+
[
|
110
|
+
'-Os',
|
111
|
+
'-Wl,--gc-sections',
|
112
|
+
"-mmcu=#{project.build_mcu}"
|
113
|
+
].join(' ')
|
114
|
+
end
|
115
|
+
|
116
|
+
def link_command
|
117
|
+
[
|
118
|
+
tools.avr_gcc,
|
119
|
+
linker_flags,
|
120
|
+
"-o #{elf_file}",
|
121
|
+
main_output_file,
|
122
|
+
archive_file,
|
123
|
+
"-L #{project.build_directory}",
|
124
|
+
'-lm'
|
125
|
+
].join(' ')
|
126
|
+
end
|
127
|
+
|
128
|
+
def link
|
129
|
+
sh link_command
|
130
|
+
end
|
131
|
+
|
132
|
+
def eeprom_command
|
133
|
+
[
|
134
|
+
tools.avr_objcopy,
|
135
|
+
eeprom_flags,
|
136
|
+
elf_file,
|
137
|
+
eeprom_file,
|
138
|
+
].join(' ')
|
139
|
+
end
|
140
|
+
|
141
|
+
def create_eeprom
|
142
|
+
sh eeprom_command
|
143
|
+
end
|
144
|
+
|
145
|
+
def hex_command
|
146
|
+
[
|
147
|
+
tools.avr_objcopy,
|
148
|
+
hex_flags,
|
149
|
+
elf_file,
|
150
|
+
hex_file,
|
151
|
+
].join(' ')
|
152
|
+
end
|
153
|
+
|
154
|
+
def create_hex
|
155
|
+
sh hex_command
|
156
|
+
end
|
157
|
+
|
158
|
+
def compiler_flags
|
159
|
+
[
|
160
|
+
'-c',
|
161
|
+
'-g',
|
162
|
+
'-Os',
|
163
|
+
'-Wall',
|
164
|
+
'-fno-exceptions',
|
165
|
+
'-ffunction-sections',
|
166
|
+
'-fdata-sections',
|
167
|
+
("-mmcu=#{project.build_mcu}" if project.build_mcu),
|
168
|
+
("-DF_CPU=#{project.build_f_cpu}" if project.build_f_cpu),
|
169
|
+
'-MMD',
|
170
|
+
("-DUSB_VID=#{project.build_vid}" if project.build_vid),
|
171
|
+
("-DUSB_PID=#{project.build_pid}" if project.build_pid),
|
172
|
+
("-DARDUINO=#{project.build_arduino}" if project.build_arduino)
|
173
|
+
].join(' ')
|
174
|
+
end
|
175
|
+
|
176
|
+
def include_flags
|
177
|
+
include_directories.compact.map { |include| "-I#{File.expand_path(include)}"}.join(' ')
|
178
|
+
end
|
179
|
+
|
180
|
+
def include_directories
|
181
|
+
[project.arduino_core_directory, project.arduino_variant_directory] + project.includes
|
182
|
+
end
|
183
|
+
|
184
|
+
def eeprom_flags
|
185
|
+
'-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0'
|
186
|
+
end
|
187
|
+
|
188
|
+
def hex_flags
|
189
|
+
'-O ihex -R .eeprom'
|
190
|
+
end
|
191
|
+
|
192
|
+
def code_files_in_directory(directory)
|
193
|
+
return [] unless directory
|
194
|
+
Dir[directory + '/**/*.c'] +
|
195
|
+
Dir[directory + '/**/*.cpp']
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
end
|
data/lib/workshop/cli.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'erb'
|
3
|
+
require 'colorize'
|
4
|
+
require 'pathname'
|
5
|
+
require 'workshop/project/setup'
|
6
|
+
|
7
|
+
module Workshop
|
8
|
+
class Cli < Thor
|
9
|
+
|
10
|
+
desc "create NAME", "create a new project called NAME"
|
11
|
+
long_desc <<-LONGDESC
|
12
|
+
`workshop create foo` will create a new folder in the current directory\
|
13
|
+
named `foo` and initialize an arduino project in that directory.
|
14
|
+
LONGDESC
|
15
|
+
def create(name)
|
16
|
+
dir = File.expand_path('./' + name)
|
17
|
+
Workshop::Project::Setup.new(dir, name).run
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Workshop::Cli.start(ARGV)
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Workshop
|
2
|
+
class Project
|
3
|
+
attr_accessor :config, :arduino, :builder, :uploader
|
4
|
+
|
5
|
+
def self.configure(&block)
|
6
|
+
new(&block)
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(&block)
|
10
|
+
self.config = Workshop::Project::Configuration.new
|
11
|
+
block.call(config)
|
12
|
+
self.arduino = Workshop::Arduino.new(config)
|
13
|
+
self.builder = Workshop::Builder.new(self)
|
14
|
+
self.uploader = Workshop::Uploader.new(self, builder.hex_file)
|
15
|
+
Workshop::Tasks.new(builder, uploader)
|
16
|
+
end
|
17
|
+
|
18
|
+
def name
|
19
|
+
config.project_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def app_directory
|
23
|
+
config.app_directory
|
24
|
+
end
|
25
|
+
|
26
|
+
def main_filename
|
27
|
+
config.main_filename
|
28
|
+
end
|
29
|
+
|
30
|
+
def arduino_hardware_directory
|
31
|
+
arduino.hardware_directory
|
32
|
+
end
|
33
|
+
|
34
|
+
def arduino_variant_directory
|
35
|
+
arduino.variant_directory
|
36
|
+
end
|
37
|
+
|
38
|
+
def arduino_core_directory
|
39
|
+
arduino.core_directory
|
40
|
+
end
|
41
|
+
|
42
|
+
def source_directory
|
43
|
+
config.source_directory
|
44
|
+
end
|
45
|
+
|
46
|
+
def includes
|
47
|
+
config.includes
|
48
|
+
end
|
49
|
+
|
50
|
+
def build_directory
|
51
|
+
config.build_directory
|
52
|
+
end
|
53
|
+
|
54
|
+
def build_mcu
|
55
|
+
config.build_mcu
|
56
|
+
end
|
57
|
+
|
58
|
+
def build_f_cpu
|
59
|
+
config.build_f_cpu
|
60
|
+
end
|
61
|
+
|
62
|
+
def build_vid
|
63
|
+
config.build_vid
|
64
|
+
end
|
65
|
+
|
66
|
+
def build_pid
|
67
|
+
config.build_pid
|
68
|
+
end
|
69
|
+
|
70
|
+
def build_arduino
|
71
|
+
# TODO - where does this come from?
|
72
|
+
'105'
|
73
|
+
end
|
74
|
+
|
75
|
+
def programmer
|
76
|
+
# TODO - read from boards.txt file
|
77
|
+
config.upload_protocol
|
78
|
+
end
|
79
|
+
|
80
|
+
def com_port
|
81
|
+
com_port_config['port']
|
82
|
+
end
|
83
|
+
|
84
|
+
def baud_rate
|
85
|
+
# TODO - read from boards.txt file
|
86
|
+
config.upload_speed
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def com_port_config
|
92
|
+
YAML::load_file(File.join(app_directory, 'config/com_port.yml'))
|
93
|
+
end
|
94
|
+
|
95
|
+
def config=(config)
|
96
|
+
@config = config
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|