arli 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 5cbff710fa5c642b1c785d3e5f57acd716383c27a5638ce1164ac4539c655706
4
- data.tar.gz: 36918da039ee3f764296e3d6073af80a89d39690199ef6e80b4a15d8ed310929
2
+ SHA1:
3
+ metadata.gz: f832a4537673c42612bdd05b38137b2b531c1d9f
4
+ data.tar.gz: 07561b363309d67e75c39ccd6933be6b39b35660
5
5
  SHA512:
6
- metadata.gz: 9b73273990d8bd70ad20f1925068060bb486b74535a75f69c42ab01789502cefb555255745d6c12a805faf7778ab6851e6c68686517e2ed7b8db15738cf41af9
7
- data.tar.gz: 89f52802678e11a45f2f2a6424f0aa08d4e2fde5bdcdfaf7edc8230e65fd1d0c6c75d93bc702ddc748cc956fcae710f8e0170f29d74a8ea150c48d153513c8fb
6
+ metadata.gz: 1e2801972673b2bf8667e578713c46025ce123ae01b684e6f640d25ef08e4bd5082811025f3b48e8f987774abe84ac0bd65e4611b530d72d2c6e7df6098d853b
7
+ data.tar.gz: 643bc6d45cf57d79340bab535bcf24a100c41f3f328813b790292a053fb001d89d7521d7b373ff2dd6879225fe4f4858f196d10a4fdee6890a0f1c1316e45f65
data/README.md CHANGED
@@ -112,6 +112,12 @@ dependencies:
112
112
  - name: "SimpleTimer"
113
113
  url: https://github.com/jfturcot/SimpleTimer.git
114
114
  - name: "Time"
115
+ - name: BackSeatDriver
116
+ url: https://github.com/kigster/back-seat-driver
117
+ folder: libraries/BackSeatDriver
118
+ - name: BackSeatDriver_DCMotorAdapter
119
+ url: https://github.com/kigster/back-seat-driver
120
+ folder: libraries/BackSeatDriver_DCMotorAdapter
115
121
  ```
116
122
 
117
123
  Let's review the contents:
@@ -163,6 +169,9 @@ If a library you are using is not in the public database just provide its `name`
163
169
 
164
170
  **Arli will use the `url` field if it's available** without trying to search for the library elsewhere.
165
171
 
172
+ #### Installing a Sub-Folder of a Library
173
+
174
+ As of version 1.3.0, Arli supports `folder` key in the Arlifile against each library. If provided, it is meant to be a relative sub-folder within the checked-out library directory structure, and only that folder will be installed as the library, and the rest removed. In the provided example, [BackSeatDriver](https://github.com/kigster/back-seat-driver/) is a collection of three libraries, and therefore to install one of them we must tell Arli a folder within that repository.j:wq
166
175
 
167
176
  ## Commands
168
177
 
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
33
  spec.require_paths = ['lib']
34
34
 
35
- spec.add_dependency 'arduino-library', '=0.5.5'
35
+ spec.add_dependency 'arduino-library', '~> 0.6'
36
36
 
37
37
  spec.add_dependency 'awesome_print'
38
38
  spec.add_dependency 'colored2'
@@ -104,13 +104,15 @@ module Arli
104
104
  config.generate.workspace = v
105
105
  end
106
106
 
107
- # on('-L', '--libs "LIBS"',
108
- # 'Comma separated list of library names, or name ',
109
- # 'substrings, to be searched for and added to the ',
110
- # 'initial Arlifile. Multiple matches are added anyway',
111
- # 'while no matches are skipped' + "\n\n") do |v|
112
- # config.generate.libs = v.split(',')
113
- # end
107
+ on('-L', '--libs LIB',
108
+ 'Full or partial name of a public Arduino library, can be used more',
109
+ 'than once. Libraries will be searched in the Arduino database, ',
110
+ 'and added to the project Arlifile. Multiple matches or no match',
111
+ 'will raise an error.' + "\n\n") do |v|
112
+ config.generate.libs ||= []
113
+ config.generate.libs << v.strip
114
+ config.generate.libs.uniq!
115
+ end
114
116
 
115
117
  option_if_exists('project')
116
118
  end
@@ -5,20 +5,33 @@ require_relative 'base'
5
5
  require_relative '../arli_file'
6
6
  require_relative '../helpers/system_commands'
7
7
  require 'forwardable'
8
+ require 'arduino/library'
8
9
  module Arli
9
10
  module Commands
10
11
  class Generate < Base
12
+
13
+ include ::Arduino::Library
11
14
  include ::Arli::Helpers::SystemCommands
12
15
 
13
16
  extend Forwardable
14
17
  def_delegators :@settings, :project_name, :project_name=, :workspace, :workspace=, :libs, :libs=, :template_repo
15
18
 
16
- attr_accessor :settings, :dir
19
+ attr_accessor :settings, :dir, :libraries
17
20
 
18
21
  def setup
19
22
  config.generate.project_name = config.runtime.argv.first
20
23
 
21
24
  self.settings = config.generate
25
+ self.libraries = []
26
+
27
+ (settings.libs || []).each do |lib|
28
+ library = find_library({ name: lib }, version: :latest)
29
+ if library
30
+ self.libraries << library
31
+ else
32
+ raise ::Arli::Errors::LibraryNotFound, "Can not find library by name #{lib}"
33
+ end
34
+ end
22
35
 
23
36
  raise ::Arli::Errors::RequiredArgumentsMissing, 'Project name is required' unless project_name
24
37
  raise ::Arli::Errors::RequiredArgumentsMissing, 'Template Repo is missing' unless template_repo
@@ -42,8 +55,14 @@ module Arli
42
55
  'git init .'
43
56
  )
44
57
  run_with_info('Customizing your README and other files...')
58
+
45
59
  rename_files!
60
+
46
61
  configure_template!
62
+ configure_arlifile!
63
+
64
+ configure_main!
65
+
47
66
  run_with_info(
48
67
  'Running setup of the dependencies...',
49
68
  'bin/setup'
@@ -74,136 +93,46 @@ module Arli
74
93
 
75
94
  private
76
95
 
96
+ def configure_arlifile!
97
+ arli_config = YAML.load(File.read('src/Arlifile'))
98
+ arli_config['dependencies'] = []
99
+
100
+ (libraries || []).each do |library|
101
+ arli_config['dependencies'] << { 'name' => library.name, 'version' => library.version }
102
+ end
103
+
104
+ File.open('src/Arlifile', 'w') do |f|
105
+ f.write(YAML.dump(arli_config))
106
+ end
107
+ end
108
+
109
+ def configure_main!
110
+ template = File.read(File.expand_path('../main.cpp.erb', __FILE__))
111
+ main = ERB.new(template).result(binding)
112
+ require 'erb'
113
+ File.open("src/#{project_name}.cpp", 'w') do |f|
114
+ f.write(main)
115
+ end
116
+ end
117
+
77
118
  def rename_files!
78
119
  FileUtils.mv('README.md', 'README-Arli-CMake.md')
120
+ run_with_info('Updating CMakeLists.txt file...',
121
+ "sed -E -i '' 's/example/src/g' CMakeLists.txt")
122
+ run_with_info('Updating CMakeLists.txt files...',
123
+ "find . -type f -name CMakeLists.txt -exec sed -E -i '' 's/MyProject/#{project_name}/g' {} \\; ")
79
124
  Dir.chdir('src') do
80
- FileUtils.mv('MyProject.cpp', "#{project_name}.cpp")
81
- run_with_info('Updating CMakeLists.txt file...',
82
- "sed -i 's/MyProject/#{project_name}/g' CMakeLists.txt")
125
+ FileUtils.rm_f('MyProject.cpp')
83
126
  end
84
- run_with_info('Updating CMakeLists.txt file...',
85
- "sed -i 's/MyProject/#{project_name}/g' CMakeLists.txt")
86
127
  end
87
128
 
88
129
  def configure_template!
130
+ template = File.read(File.expand_path('../readme.md.erb', __FILE__))
131
+ @project_name = config.generate.project_name
132
+ readme = ERB.new(template).result(binding)
133
+ require 'erb'
89
134
  File.open('README.md', 'w') do |f|
90
- f.write <<-EOF
91
-
92
- > **NOTE**: This project has been auto-generated using:
93
- >
94
- > * [arli](https://github.com/kigster/arli) Arduino toolkit, and using the `generate` command. Thank you for using Arli!
95
- > * [arli-cmake](https://github.com/kigster/arli-cmake) is the template project that was used as a source for this one.
96
- > * [arduino-cmake](https://github.com/arduino-cmake/arduino-cmake) is the CMake-based build system for Arduino projects.
97
- >
98
- > There is a discussion board for Arli/CMake-based projects. Please join if you have any questions or suggestions!
99
- > [![Gitter](https://img.shields.io/gitter/room/gitterHQ/gitter.svg)](https://gitter.im/arduino-cmake-arli/)
100
-
101
-
102
- # #{project_name}
103
-
104
- **TODO: Please update this README to reflect information about you project. :)**
105
-
106
- ## Prerequisites
107
-
108
- * On a Mac, you always need to run `xcode-select --install` before you can do any development. You must have `git` installed;
109
-
110
- * Requires [CMake](https://cmake.org/download/)
111
-
112
- * Requires [Arduino IDE](https://www.arduino.cc/en/Main/Software) or an SDK, either for [Mac](https://downloads.arduino.cc/arduino-1.8.5-macosx.zip) or [Linux](https://downloads.arduino.cc/arduino-1.8.5-linux.zip) installed;
113
-
114
- * Requires ruby, 2.3 or 2.4+ installed. On a Mac's Terminal, run `ruby --version`. If for some reason you don't have it installed, the `bin/setup` script will prompt you to install it.
115
-
116
- ## Building #{project_name}
117
-
118
- ```bash
119
- $ cd ~/workspace/#{project_name}
120
- $ rm -rf build && mkdir -p build && cd build
121
- $ cmake ..
122
- $ make # this builds the image
123
- $ make upload # this uploads it to the device
124
- $ # this next command opens a serial port monitor inside a screen session
125
- $ make #{project_name}-serial
126
- ```
127
-
128
- ### Customizing the Build
129
-
130
- You can use environment variables to set the board, CPU and the port. Simply prefix the following variables before you run `cmake ..`
131
-
132
- ```bash
133
- $ rm -rf build
134
- $ mkdir -p build
135
- $ cd build
136
- $ BOARD_NAME=nano \\
137
- BOARD_CPU=atmega328p \\
138
- BOARD_DEVICE=/dev/tty.usbserial-DA00WXFY \\
139
- cmake ..
140
- ```
141
-
142
- ### Adding External Libraries
143
-
144
- Your repo contains `Arlifile` inside the `src` folder. Please [read the documentation](https://github.com/kigster/arli#command-bundle) about the format of `Arlifile`.
145
-
146
- Go ahead and edit that file, and under `dependencies:` you want to list all of your libraries by their exact name, and an optional version.
147
-
148
- The best way to do that is to **first search for the library** using the `arli search terms` command. Once you find the library you want, just copy it's name as is into `Arlifile`. If it contains spaces, put quotes around it.
149
-
150
- For example:
151
-
152
- ```bash
153
- ❯ arli search /adafruit.*bmp085/i
154
-
155
- Arli (1.0.2), Command: search
156
- Library Path: ~/Documents/Arduino/Libraries
157
-
158
- Adafruit BMP085 Library (1.0.0) ( 1 total versions )
159
- Adafruit BMP085 Unified (1.0.0) ( 1 total versions )
160
- ———————————————————————
161
- Total Versions : 2
162
- Unique Libraries : 2
163
- ———————————————————————
164
- ```
165
-
166
- If the library is not in the official database, just add it with a name and a url. Arli will use the url field to fetch it.
167
-
168
- To verify that your Arlifile can resolve all libraries, please run `arli bundle` inside the `src` folder. If Arli suceeds, you've got it right, and the `libraries` folder inside `src` should contain all referenced libraries.
169
-
170
- ### Adding Source Files
171
-
172
- You will notice that inside `src/CMakeLists.txt` file, there is a line:
173
-
174
- ```cmake
175
- set(PROJECT_SOURCES #{project_name}.cpp)
176
- ```
177
-
178
- If you add any additional source files or headers, just add their names right after, separated by spaces or newlines. For example:
179
-
180
- ```cmake
181
- set(PROJECT_SOURCES
182
- #{project_name}.cpp
183
- #{project_name}.h
184
- helpers/Loader.cpp
185
- helpers/Loader.h
186
- config/Configuration.h
187
- )
188
- ```
189
-
190
- The should be all you need to do add custom logic and to rebuild and upload the project.
191
-
192
- ## Where to get Support?
193
-
194
- Please feel free to file bug reports and submit pull requests on GitHub — [https://github.com/kigster/arli-cmake](https://github.com/kigster/arli-cmake) is the project URL, and this is the [issues](https://github.com/kigster/arli-cmake/issues) URL.
195
-
196
- ## License
197
-
198
- The original project is distributed as open source, under the terms of the [MIT License](http://opensource.org/licenses/MIT).
199
-
200
- However, feel free to change the license of your project, as long as you provide the credit to the original.
201
-
202
- Thanks!
203
- Good luck!
204
-
205
-
206
- EOF
135
+ f.write(readme)
207
136
  end
208
137
  end
209
138
  end
@@ -0,0 +1,10 @@
1
+ #include <Arduino.h>
2
+ // add your library headers here
3
+
4
+ void setup() {
5
+
6
+ }
7
+
8
+ void loop() {
9
+
10
+ }
@@ -0,0 +1,122 @@
1
+ # <%= project_name %>
2
+
3
+ > **NOTE**: This project and its README were auto-generated using
4
+ >
5
+ > * [arli](https://github.com/kigster/arli) Arduino toolkit, and using the `generate` command. Thank you for using Arli!
6
+ > * [arli-cmake](https://github.com/kigster/arli-cmake) is the template project that was used as a source for this one.
7
+ > * [arduino-cmake](https://github.com/arduino-cmake/arduino-cmake) is the CMake-based build system for Arduino projects.
8
+ >
9
+ > There is a discussion board for Arli/CMake-based projects. Please join if you have any questions or suggestions!
10
+ > [![Gitter](https://img.shields.io/gitter/room/gitterHQ/gitter.svg)](https://gitter.im/arduino-cmake-arli/)
11
+
12
+ ## Overview
13
+
14
+ This Arduino project uses CMake build system, and the Arduino-CMake project. It also uses `arli` CLI tool to manage it's library dependencies.
15
+
16
+ ## Usage
17
+
18
+ ### Prerequisites
19
+
20
+ * On a Mac, you always need to run `xcode-select --install` before you can do any development. You must have `git` installed;
21
+
22
+ * Requires [CMake](https://cmake.org/download/)
23
+ * Requires [Arduino IDE](https://www.arduino.cc/en/Main/Software) or an SDK, either for [Mac](https://downloads.arduino.cc/arduino-1.8.5-macosx.zip) or [Linux](https://downloads.arduino.cc/arduino-1.8.5-linux.zip) installed;
24
+ * Requires ruby, 2.3 or 2.4+ installed. On a Mac's Terminal, run `ruby --version`. If for some reason you don't have it installed, the `bin/setup` script will prompt you to install it.
25
+
26
+ ### Building
27
+
28
+ You can build the project using provided BASH helpers:
29
+
30
+ ```bash
31
+ $ cd ~/workspace/<%= project_name %>
32
+ $ bin/setup
33
+ $ bin/build
34
+ ```
35
+
36
+ Or you can build manually using cmake/make:
37
+
38
+ ```bash
39
+ $ cd ~/workspace/<%= project_name %>
40
+ $ rm -rf build && mkdir build
41
+ $ cd build
42
+ $ cmake ..
43
+ $ make # this builds the image
44
+ $ make upload # this uploads it to the device
45
+ $ # this next command opens a serial port monitor inside a screen session
46
+ $ make <%= project_name %>-serial
47
+ ```
48
+
49
+ ### Customizing the Build
50
+
51
+ You can use environment variables to set the board, CPU and the port. Simply prefix the following variables before you run `cmake ..`
52
+
53
+ ```bash
54
+ $ rm -rf build && mkdir -p build && cd build
55
+ $ BOARD_NAME=nano \
56
+ BOARD_CPU=atmega328p \
57
+ BOARD_DEVICE=/dev/tty.usbserial-DA00WXFY \
58
+ cmake ..
59
+ ```
60
+
61
+ ### Adding External Libraries
62
+
63
+ Your repo contains `Arlifile` (which is a YAML file) inside the `src` folder. Please [read the documentation](https://github.com/kigster/arli#arlifile-specification) about the format of `Arlifile`.
64
+
65
+ Go ahead and edit that file, and under `dependencies:` you want to list all of your libraries by their exact name, and an optional version.
66
+
67
+ The best way to do that is to **first search for the library** using the `arli search terms` command. Once you find the library you want, just copy it's name as is into `Arlifile`. If it contains spaces, put quotes around it.
68
+
69
+ For example:
70
+
71
+ ```bash
72
+ $ arli search /adafruit.*bmp085/i
73
+
74
+ Arli (1.0.2), Command: search
75
+ Library Path: ~/Documents/Arduino/Libraries
76
+
77
+ Adafruit BMP085 Library (1.0.0) ( 1 total versions )
78
+ Adafruit BMP085 Unified (1.0.0) ( 1 total versions )
79
+ ———————————————————————
80
+ Total Versions : 2
81
+ Unique Libraries : 2
82
+ ———————————————————————
83
+ ```
84
+
85
+ If the library is not in the official database, just add it with a name and a url, and an optional sub-folder. Arli will use the url field to fetch it.
86
+
87
+ To verify that your Arlifile can resolve all libraries, please run `arli bundle` inside the `src` folder. If Arli succeeds, you've got it right, and the `libraries` folder inside `src` should contain all referenced libraries.
88
+
89
+ ### Adding Source Files
90
+
91
+ You will notice that inside `src/CMakeLists.txt` file, there is a line:
92
+
93
+ ```cmake
94
+ set(PROJECT_SOURCES <%= project_name %>.cpp)
95
+ ```
96
+
97
+ If you add any additional source files or headers, just add their names right after, separated by spaces or newlines. For example:
98
+
99
+ ```cmake
100
+ set(PROJECT_SOURCES
101
+ <%= project_name %>.cpp
102
+ <%= project_name %>.h
103
+ helpers/Loader.cpp
104
+ helpers/Loader.h
105
+ config/Configuration.h
106
+ )
107
+ ```
108
+
109
+ The should be all you need to do add custom logic and to rebuild and upload the project.
110
+
111
+ ## Where to get Support?
112
+
113
+ Please feel free to file bug reports and submit pull requests on GitHub — [https://github.com/kigster/arli-cmake](https://github.com/kigster/arli-cmake) is the project URL, and this is the [issues](https://github.com/kigster/arli-cmake/issues) URL.
114
+
115
+ ## License
116
+
117
+ The original project is distributed as open source, under the terms of the [MIT License](http://opensource.org/licenses/MIT).
118
+
119
+ However, feel free to change the license of your project, as long as you provide the credit to the original.
120
+
121
+ Thanks!
122
+ Good luck!
@@ -1,3 +1,3 @@
1
1
  module Arli
2
- VERSION = '1.3.0'.freeze
2
+ VERSION = '1.4.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Gredeskoul
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-08 00:00:00.000000000 Z
11
+ date: 2018-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arduino-library
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.5
19
+ version: '0.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.5
26
+ version: '0.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: awesome_print
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -288,6 +288,8 @@ files:
288
288
  - lib/arli/commands/bundle.rb
289
289
  - lib/arli/commands/generate.rb
290
290
  - lib/arli/commands/install.rb
291
+ - lib/arli/commands/main.cpp.erb
292
+ - lib/arli/commands/readme.md.erb
291
293
  - lib/arli/commands/search.rb
292
294
  - lib/arli/configuration.rb
293
295
  - lib/arli/errors.rb
@@ -329,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
331
  version: '0'
330
332
  requirements: []
331
333
  rubyforge_project:
332
- rubygems_version: 2.7.6
334
+ rubygems_version: 2.6.14
333
335
  signing_key:
334
336
  specification_version: 4
335
337
  summary: This is an Arduino helper toolkit that builds on top of the arduino-cmake