arduino_sketch_builder 0.0.2
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 +23 -0
- data/.gitmodules +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +71 -0
- data/Rakefile +5 -0
- data/arduino-cmake/cmake/ArduinoToolchain.cmake +75 -0
- data/arduino-cmake/cmake/Platform/Arduino.cmake +1846 -0
- data/arduino_sketch_builder.gemspec +22 -0
- data/lib/arduino_sketch_builder.rb +8 -0
- data/lib/arduino_sketch_builder/arduino_cmake_build.rb +52 -0
- data/lib/arduino_sketch_builder/c_make_lists_file_generator.rb +34 -0
- data/lib/arduino_sketch_builder/setup.rb +46 -0
- data/lib/arduino_sketch_builder/version.rb +3 -0
- data/lib/arduino_sketches/CMakeLists.txt +20 -0
- data/lib/arduino_sketches/src/BlinkCustomized/BlinkCustomized.ino +19 -0
- data/lib/arduino_sketches/src/CMakeLists.txt +14 -0
- data/spec/arduino_sketch_builder/arduino_cmake_build_spec.rb +105 -0
- data/spec/arduino_sketch_builder/c_make_lists_file_generator_spec.rb +35 -0
- data/spec/arduino_sketch_builder/setup_spec.rb +86 -0
- data/spec/arduino_sketches_fixture/CMakeLists.txt +20 -0
- data/spec/arduino_sketches_fixture/build/.gitkeep +0 -0
- data/spec/arduino_sketches_fixture/src/BlinkCustomizedForTest/BlinkCustomizedForTest.ino +19 -0
- data/spec/arduino_sketches_fixture/src/CMakeLists.txt +16 -0
- data/spec/fixtures/CMakeListsForTestSketch.txt +10 -0
- data/spec/fixtures/MainCMakeLists.txt +22 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/temp/blink_customized_for_test/src/BlinkCustomizedForTest/BlinkCustomizedForTest.ino +19 -0
- data/spec/temp/blink_customized_for_test/src/CMakeLists.txt +10 -0
- data/templates/MainCMakeListsTemplate.txt.erb +22 -0
- data/templates/SourceCMakeListsTemplate.txt.erb +10 -0
- data/templates/gitkeep_template +0 -0
- data/templates/root_gitignore_template +2 -0
- metadata +117 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'arduino_sketch_builder/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "arduino_sketch_builder"
|
8
|
+
gem.version = ArduinoSketchBuilder::VERSION
|
9
|
+
gem.authors = ["Tadatoshi Takahashi"]
|
10
|
+
gem.email = ["tadatoshi@gmail.com"]
|
11
|
+
gem.description = %q{Builds Arduino sketch}
|
12
|
+
gem.summary = %q{Performs calling the code to compile Arduino sketch and upload it to Arduino by Ruby, instead of using Arduino IDE.}
|
13
|
+
gem.homepage = "https://github.com/tadatoshi/arduino_sketch_builder"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
# gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "activesupport"
|
21
|
+
gem.add_development_dependency "rspec"
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
3
|
+
class ArduinoSketchBuilder::ArduinoCmakeBuild
|
4
|
+
|
5
|
+
State = Struct.new(:value, :message)
|
6
|
+
|
7
|
+
INITIAL = State.new(:initial, "ready")
|
8
|
+
CMAKE_COMPLETE = State.new(:cmake_complete, "success")
|
9
|
+
MAKE_COMPLETE = State.new(:make_complete, "success")
|
10
|
+
MAKE_UPLOAD_COMPLETE = State.new(:make_upload_complete, "success")
|
11
|
+
|
12
|
+
STATE_SEQUENCE = [INITIAL, CMAKE_COMPLETE, MAKE_COMPLETE, MAKE_UPLOAD_COMPLETE]
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@state = INITIAL
|
16
|
+
end
|
17
|
+
|
18
|
+
def state
|
19
|
+
@state.value
|
20
|
+
end
|
21
|
+
|
22
|
+
def message
|
23
|
+
@state.message
|
24
|
+
end
|
25
|
+
|
26
|
+
[:cmake, :make, :make_upload].each_with_index do |method_name, index|
|
27
|
+
|
28
|
+
define_method(method_name) do |build_directory, main_directory=nil|
|
29
|
+
|
30
|
+
unless @state == STATE_SEQUENCE[index]
|
31
|
+
raise "Wrong state '#{self.state}': can't call #{method_name} when the state is not '#{STATE_SEQUENCE[index].value}'"
|
32
|
+
end
|
33
|
+
|
34
|
+
Dir.chdir(build_directory)
|
35
|
+
|
36
|
+
Open3.popen3("#{method_name.to_s.sub('_',' ')} #{main_directory ? main_directory : ''}") do |stdin, stdout, stderr, wait_thread|
|
37
|
+
pid = wait_thread.pid
|
38
|
+
exit_status = wait_thread.value
|
39
|
+
if exit_status.success?
|
40
|
+
@state = STATE_SEQUENCE[index+1]
|
41
|
+
else
|
42
|
+
@state = State.new("#{method_name}_incomplete".to_sym, stderr.gets)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
self.state
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'active_support/core_ext/string/inflections'
|
2
|
+
|
3
|
+
class ArduinoSketchBuilder::CMakeListsFileGenerator
|
4
|
+
|
5
|
+
TEMPLATES_DIRECTORY = File.expand_path('../../../templates', __FILE__)
|
6
|
+
|
7
|
+
attr_reader :root_directory
|
8
|
+
attr_reader :sketch_name
|
9
|
+
|
10
|
+
def generate_main(root_directory, c_make_lists_file_directory)
|
11
|
+
|
12
|
+
@root_directory = root_directory
|
13
|
+
|
14
|
+
erb = ERB.new(File.read("#{TEMPLATES_DIRECTORY}/MainCMakeListsTemplate.txt.erb"))
|
15
|
+
|
16
|
+
generated_content = erb.result(binding)
|
17
|
+
|
18
|
+
File.write(File.join(c_make_lists_file_directory, "CMakeLists.txt"), generated_content)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def generate_sketch_specific(sketch_name, c_make_lists_file_directory)
|
23
|
+
|
24
|
+
@sketch_name = sketch_name
|
25
|
+
|
26
|
+
erb = ERB.new(File.read("#{TEMPLATES_DIRECTORY}/SourceCMakeListsTemplate.txt.erb"))
|
27
|
+
|
28
|
+
generated_content = erb.result(binding)
|
29
|
+
|
30
|
+
File.write(File.join(c_make_lists_file_directory, "CMakeLists.txt"), generated_content)
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'active_support/core_ext/string/inflections'
|
2
|
+
|
3
|
+
class ArduinoSketchBuilder::Setup
|
4
|
+
|
5
|
+
ARDUINO_CMAKE_DIRECTORY = File.expand_path('../../../arduino-cmake', __FILE__)
|
6
|
+
TEMPLATES_DIRECTORY = File.expand_path('../../../templates', __FILE__)
|
7
|
+
|
8
|
+
def configure(root_directory)
|
9
|
+
|
10
|
+
FileUtils.cp_r(File.join(ARDUINO_CMAKE_DIRECTORY, 'cmake'), root_directory)
|
11
|
+
|
12
|
+
FileUtils.chmod_R('og-rwx', File.join(root_directory, 'cmake'))
|
13
|
+
|
14
|
+
FileUtils.mkdir_p(File.join(root_directory, 'libraries'))
|
15
|
+
FileUtils.cp(File.join(TEMPLATES_DIRECTORY, 'gitkeep_template'), File.join(root_directory, 'libraries', '.gitkeep'))
|
16
|
+
|
17
|
+
FileUtils.chmod_R('og-rwx', File.join(root_directory, 'libraries'))
|
18
|
+
FileUtils.chmod('og-rwx', File.join(root_directory, 'libraries', '.gitkeep'))
|
19
|
+
|
20
|
+
FileUtils.cp(File.join(TEMPLATES_DIRECTORY, 'root_gitignore_template'), File.join(root_directory, '.gitignore'))
|
21
|
+
FileUtils.chmod('og-rwx', File.join(root_directory, '.gitignore'))
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup(root_directory, sketch_file_path)
|
26
|
+
|
27
|
+
sketch_file_name = File.basename(sketch_file_path)
|
28
|
+
sketch_name = sketch_file_name.split('.').first
|
29
|
+
main_directory_name = sketch_name.underscore
|
30
|
+
|
31
|
+
FileUtils.mkdir_p([File.join(root_directory, main_directory_name),
|
32
|
+
File.join(root_directory, main_directory_name, 'src'),
|
33
|
+
File.join(root_directory, main_directory_name, 'build'),
|
34
|
+
File.join(root_directory, main_directory_name, 'src', sketch_name)])
|
35
|
+
|
36
|
+
c_make_lists_file_generator = ArduinoSketchBuilder::CMakeListsFileGenerator.new
|
37
|
+
c_make_lists_file_generator.generate_main(root_directory, File.join(root_directory, main_directory_name))
|
38
|
+
c_make_lists_file_generator.generate_sketch_specific(sketch_name, File.join(root_directory, main_directory_name, 'src'))
|
39
|
+
|
40
|
+
File.write(File.join(root_directory, main_directory_name, 'src', sketch_name, sketch_file_name), File.read(sketch_file_path))
|
41
|
+
|
42
|
+
FileUtils.chmod_R('og-rwx', File.join(root_directory, main_directory_name))
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#=============================================================================#
|
2
|
+
# Author: Tadatoshi Takahashi #
|
3
|
+
# Date: 30.01.2013 #
|
4
|
+
# #
|
5
|
+
# Description: Arduino CMake for arduino_sketch_builder #
|
6
|
+
# #
|
7
|
+
#=============================================================================#
|
8
|
+
set(CMAKE_TOOLCHAIN_FILE ../../arduino-cmake/cmake/ArduinoToolchain.cmake) # Arduino Toolchain
|
9
|
+
|
10
|
+
|
11
|
+
cmake_minimum_required(VERSION 2.8)
|
12
|
+
#====================================================================#
|
13
|
+
# Setup Project #
|
14
|
+
#====================================================================#
|
15
|
+
project(ArduinoSketchBuilder C CXX)
|
16
|
+
|
17
|
+
print_board_list()
|
18
|
+
print_programmer_list()
|
19
|
+
|
20
|
+
add_subdirectory(src) #add the src directory (lib/arduino_sketches/src) into build
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/*
|
2
|
+
BlinkCustomized
|
3
|
+
Turns on an LED on for two second, then off for two second, repeatedly.
|
4
|
+
|
5
|
+
This code is used for testing arduino_sketch_builder gem.
|
6
|
+
*/
|
7
|
+
|
8
|
+
void setup() {
|
9
|
+
// initialize the digital pin as an output.
|
10
|
+
// Pin 13 has an LED connected on most Arduino boards:
|
11
|
+
pinMode(13, OUTPUT);
|
12
|
+
}
|
13
|
+
|
14
|
+
void loop() {
|
15
|
+
digitalWrite(13, HIGH); // set the LED on
|
16
|
+
delay(2000); // wait for a second
|
17
|
+
digitalWrite(13, LOW); // set the LED off
|
18
|
+
delay(2000); // wait for a second
|
19
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This configuration file outlines some of the ways Arduino CMake
|
2
|
+
# can be used. For a detailed explenation of all the options please
|
3
|
+
# reade README.rst.
|
4
|
+
|
5
|
+
set(ARDUINO_DEFAULT_BOARD uno) # Default Board ID, when not specified
|
6
|
+
set(ARDUINO_DEFAULT_PORT /dev/tty.usbmodem411) # Default Port, when not specified
|
7
|
+
|
8
|
+
#====================================================================#
|
9
|
+
# BlinkCustomized
|
10
|
+
#====================================================================#
|
11
|
+
generate_arduino_firmware(blink_customized
|
12
|
+
SKETCH BlinkCustomized
|
13
|
+
PROGRAMMER tadatoshi
|
14
|
+
NO_AUTOLIBS)
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ArduinoSketchBuilder::ArduinoCmakeBuild do
|
4
|
+
|
5
|
+
MAIN_DIRECTORY = File.expand_path('../../arduino_sketches_fixture', __FILE__)
|
6
|
+
BUILD_DIRECTORY = "#{MAIN_DIRECTORY}/build"
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
FileUtils.rm_rf(Dir.glob("#{BUILD_DIRECTORY}/*"))
|
10
|
+
@arduino_cmake_build = ArduinoSketchBuilder::ArduinoCmakeBuild.new
|
11
|
+
end
|
12
|
+
|
13
|
+
after(:each) do
|
14
|
+
FileUtils.rm_rf(Dir.glob("#{BUILD_DIRECTORY}/*"))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should execute cmake and make in sequence in build directory" do
|
18
|
+
|
19
|
+
@arduino_cmake_build.state.should == :initial
|
20
|
+
File.exists?(File.join(BUILD_DIRECTORY, "Makefile")).should be_false
|
21
|
+
|
22
|
+
@arduino_cmake_build.cmake(BUILD_DIRECTORY, MAIN_DIRECTORY).should == :cmake_complete
|
23
|
+
|
24
|
+
@arduino_cmake_build.state.should == :cmake_complete
|
25
|
+
File.exists?(File.join(BUILD_DIRECTORY, "Makefile")).should be_true
|
26
|
+
|
27
|
+
File.exists?(File.join(BUILD_DIRECTORY, "src", "blink_customized_for_test.hex")).should be_false
|
28
|
+
|
29
|
+
@arduino_cmake_build.make(BUILD_DIRECTORY).should == :make_complete
|
30
|
+
|
31
|
+
@arduino_cmake_build.state.should == :make_complete
|
32
|
+
File.exists?(File.join(BUILD_DIRECTORY, "src", "blink_customized_for_test.hex")).should be_true
|
33
|
+
|
34
|
+
@arduino_cmake_build.make_upload(BUILD_DIRECTORY).should == :make_upload_complete
|
35
|
+
|
36
|
+
@arduino_cmake_build.state.should == :make_upload_complete
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should execute cmake only when the state is initial" do
|
41
|
+
|
42
|
+
@arduino_cmake_build.instance_eval("@state=CMAKE_COMPLETE")
|
43
|
+
expect { @arduino_cmake_build.cmake(BUILD_DIRECTORY, MAIN_DIRECTORY) }
|
44
|
+
.to raise_error("Wrong state 'cmake_complete': can't call cmake when the state is not 'initial'")
|
45
|
+
|
46
|
+
@arduino_cmake_build.instance_eval("@state=MAKE_COMPLETE")
|
47
|
+
expect { @arduino_cmake_build.cmake(BUILD_DIRECTORY, MAIN_DIRECTORY) }
|
48
|
+
.to raise_error("Wrong state 'make_complete': can't call cmake when the state is not 'initial'")
|
49
|
+
|
50
|
+
@arduino_cmake_build.instance_eval("@state=MAKE_UPLOAD_COMPLETE")
|
51
|
+
expect { @arduino_cmake_build.cmake(BUILD_DIRECTORY, MAIN_DIRECTORY) }
|
52
|
+
.to raise_error("Wrong state 'make_upload_complete': can't call cmake when the state is not 'initial'")
|
53
|
+
|
54
|
+
@arduino_cmake_build.instance_eval("@state=INITIAL")
|
55
|
+
expect { @arduino_cmake_build.cmake(BUILD_DIRECTORY, MAIN_DIRECTORY) }
|
56
|
+
.to_not raise_error
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should execute make only when the state is cmake_complete" do
|
61
|
+
|
62
|
+
@arduino_cmake_build.instance_eval("@state=INITIAL")
|
63
|
+
expect { @arduino_cmake_build.make(BUILD_DIRECTORY) }
|
64
|
+
.to raise_error("Wrong state 'initial': can't call make when the state is not 'cmake_complete'")
|
65
|
+
|
66
|
+
@arduino_cmake_build.instance_eval("@state=MAKE_COMPLETE")
|
67
|
+
expect { @arduino_cmake_build.make(BUILD_DIRECTORY) }
|
68
|
+
.to raise_error("Wrong state 'make_complete': can't call make when the state is not 'cmake_complete'")
|
69
|
+
|
70
|
+
@arduino_cmake_build.instance_eval("@state=MAKE_UPLOAD_COMPLETE")
|
71
|
+
expect { @arduino_cmake_build.make(BUILD_DIRECTORY) }
|
72
|
+
.to raise_error("Wrong state 'make_upload_complete': can't call make when the state is not 'cmake_complete'")
|
73
|
+
|
74
|
+
@arduino_cmake_build.instance_eval("@state=INITIAL")
|
75
|
+
@arduino_cmake_build.cmake(BUILD_DIRECTORY, MAIN_DIRECTORY)
|
76
|
+
@arduino_cmake_build.state.should == :cmake_complete
|
77
|
+
expect { @arduino_cmake_build.make(BUILD_DIRECTORY) }
|
78
|
+
.to_not raise_error
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should execute make_upload only when the state is make_complete" do
|
83
|
+
|
84
|
+
@arduino_cmake_build.instance_eval("@state=INITIAL")
|
85
|
+
expect { @arduino_cmake_build.make_upload(BUILD_DIRECTORY) }
|
86
|
+
.to raise_error("Wrong state 'initial': can't call make_upload when the state is not 'make_complete'")
|
87
|
+
|
88
|
+
@arduino_cmake_build.instance_eval("@state=CMAKE_COMPLETE")
|
89
|
+
expect { @arduino_cmake_build.make_upload(BUILD_DIRECTORY) }
|
90
|
+
.to raise_error("Wrong state 'cmake_complete': can't call make_upload when the state is not 'make_complete'")
|
91
|
+
|
92
|
+
@arduino_cmake_build.instance_eval("@state=MAKE_UPLOAD_COMPLETE")
|
93
|
+
expect { @arduino_cmake_build.make_upload(BUILD_DIRECTORY) }
|
94
|
+
.to raise_error("Wrong state 'make_upload_complete': can't call make_upload when the state is not 'make_complete'")
|
95
|
+
|
96
|
+
@arduino_cmake_build.instance_eval("@state=INITIAL")
|
97
|
+
@arduino_cmake_build.cmake(BUILD_DIRECTORY, MAIN_DIRECTORY)
|
98
|
+
@arduino_cmake_build.make(BUILD_DIRECTORY)
|
99
|
+
@arduino_cmake_build.state.should == :make_complete
|
100
|
+
expect { @arduino_cmake_build.make_upload(BUILD_DIRECTORY) }
|
101
|
+
.to_not raise_error
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ArduinoSketchBuilder::CMakeListsFileGenerator do
|
4
|
+
|
5
|
+
FIXTURES_DIRECTORY = File.expand_path('../../fixtures', __FILE__)
|
6
|
+
TEMP_DIRECTORY = File.expand_path('../../temp', __FILE__)
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
FileUtils.rm_rf(Dir.glob("#{TEMP_DIRECTORY}/*"))
|
10
|
+
@c_make_lists_file_generator = ArduinoSketchBuilder::CMakeListsFileGenerator.new
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should generate main CMakeLists.txt file" do
|
14
|
+
|
15
|
+
File.exists?(File.join(TEMP_DIRECTORY, "CMakeLists.txt")).should be_false
|
16
|
+
|
17
|
+
@c_make_lists_file_generator.generate_main("~/temp", TEMP_DIRECTORY)
|
18
|
+
|
19
|
+
File.exists?(File.join(TEMP_DIRECTORY, "CMakeLists.txt")).should be_true
|
20
|
+
File.read(File.join(TEMP_DIRECTORY, "CMakeLists.txt")).should == File.read(File.join(FIXTURES_DIRECTORY, "MainCMakeLists.txt"))
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should generate CMakeLists.txt file for a given Arduino sketch name" do
|
25
|
+
|
26
|
+
File.exists?(File.join(TEMP_DIRECTORY, "CMakeLists.txt")).should be_false
|
27
|
+
|
28
|
+
@c_make_lists_file_generator.generate_sketch_specific("TestSketch", TEMP_DIRECTORY)
|
29
|
+
|
30
|
+
File.exists?(File.join(TEMP_DIRECTORY, "CMakeLists.txt")).should be_true
|
31
|
+
File.read(File.join(TEMP_DIRECTORY, "CMakeLists.txt")).should == File.read(File.join(FIXTURES_DIRECTORY, "CMakeListsForTestSketch.txt"))
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ArduinoSketchBuilder::Setup do
|
4
|
+
|
5
|
+
ARDUINO_CMAKE_DIRECTORY = File.expand_path('../../../arduino-cmake', __FILE__)
|
6
|
+
FIXTURES_DIRECTORY = File.expand_path('../../fixtures', __FILE__)
|
7
|
+
ARDUINO_SKETCHES_FIXTURE_DIRECTORY = File.expand_path('../../arduino_sketches_fixture', __FILE__)
|
8
|
+
ARDUINO_SKETCH_FILE_PATH = File.expand_path(File.join(ARDUINO_SKETCHES_FIXTURE_DIRECTORY, 'src/BlinkCustomizedForTest/BlinkCustomizedForTest.ino'), __FILE__)
|
9
|
+
TEMPLATES_DIRECTORY = File.expand_path('../../../templates', __FILE__)
|
10
|
+
TEMP_DIRECTORY = File.expand_path('../../temp', __FILE__)
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
FileUtils.rm_rf(Dir.glob("#{TEMP_DIRECTORY}/*"))
|
14
|
+
@setup = ArduinoSketchBuilder::Setup.new
|
15
|
+
end
|
16
|
+
|
17
|
+
context "configure" do
|
18
|
+
|
19
|
+
it "should configure the root directory by putting cmake directory and its contents from arduino-cmake directory" do
|
20
|
+
|
21
|
+
root_directory = TEMP_DIRECTORY
|
22
|
+
|
23
|
+
@setup.configure(root_directory)
|
24
|
+
|
25
|
+
Dir.exists?(File.join(root_directory, "cmake")).should be_true
|
26
|
+
File.exists?(File.join(root_directory, "cmake", "ArduinoToolchain.cmake")).should be_true
|
27
|
+
Dir.exists?(File.join(root_directory, "cmake", "Platform")).should be_true
|
28
|
+
File.exists?(File.join(root_directory, "cmake", "Platform", "Arduino.cmake")).should be_true
|
29
|
+
|
30
|
+
File.read(File.join(root_directory, "cmake", "ArduinoToolchain.cmake")).should == File.read(File.join(ARDUINO_CMAKE_DIRECTORY, "cmake", "ArduinoToolchain.cmake"))
|
31
|
+
File.read(File.join(root_directory, "cmake", "Platform", "Arduino.cmake")).should == File.read(File.join(ARDUINO_CMAKE_DIRECTORY, "cmake", "Platform", "Arduino.cmake"))
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should configure the root directory by putting libraries directory" do
|
36
|
+
|
37
|
+
root_directory = TEMP_DIRECTORY
|
38
|
+
|
39
|
+
@setup.configure(root_directory)
|
40
|
+
|
41
|
+
Dir.exists?(File.join(root_directory, "libraries")).should be_true
|
42
|
+
File.exists?(File.join(root_directory, "libraries", ".gitkeep")).should be_true
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should configure the root directory by putting .gitignore file" do
|
47
|
+
|
48
|
+
root_directory = TEMP_DIRECTORY
|
49
|
+
|
50
|
+
@setup.configure(root_directory)
|
51
|
+
|
52
|
+
File.exists?(File.join(root_directory, ".gitignore")).should be_true
|
53
|
+
File.read(File.join(root_directory, ".gitignore")).should == File.read(File.join(TEMPLATES_DIRECTORY, "root_gitignore_template"))
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
context "setup" do
|
60
|
+
|
61
|
+
it "should create a directory structure for an Arduino sketch" do
|
62
|
+
|
63
|
+
root_directory = TEMP_DIRECTORY
|
64
|
+
|
65
|
+
@setup.setup(root_directory, ARDUINO_SKETCH_FILE_PATH)
|
66
|
+
|
67
|
+
Dir.exists?(File.join(root_directory, "blink_customized_for_test")).should be_true
|
68
|
+
File.exists?(File.join(root_directory, "blink_customized_for_test", "CMakeLists.txt")).should be_true
|
69
|
+
Dir.exists?(File.join(root_directory, "blink_customized_for_test", "src")).should be_true
|
70
|
+
File.exists?(File.join(root_directory, "blink_customized_for_test", "src", "CMakeLists.txt")).should be_true
|
71
|
+
Dir.exists?(File.join(root_directory, "blink_customized_for_test", "src", "BlinkCustomizedForTest")).should be_true
|
72
|
+
File.exists?(File.join(root_directory, "blink_customized_for_test", "src", "BlinkCustomizedForTest", "BlinkCustomizedForTest.ino")).should be_true
|
73
|
+
Dir.exists?(File.join(root_directory, "blink_customized_for_test", "build")).should be_true
|
74
|
+
|
75
|
+
# The following checks the generated file with the full path, hence, system specific (e.g. /Users/).
|
76
|
+
# Hence, it's considered that the unit test for c_make_lists_file_generator covers it.
|
77
|
+
# File.read(File.join(root_directory, "blink_customized_for_test", "CMakeLists.txt")).should == File.read(File.join(FIXTURES_DIRECTORY, "MainCMakeLists.txt"))
|
78
|
+
# This one also, it's considered that the unit test for c_make_lists_file_generator covers it.
|
79
|
+
# File.read(File.join(root_directory, "blink_customized_for_test", "src", "CMakeLists.txt")).should == File.read(File.join(FIXTURES_DIRECTORY, "CMakeListsForTestSketch.txt"))
|
80
|
+
File.read(File.join(root_directory, "blink_customized_for_test", "src", "BlinkCustomizedForTest", "BlinkCustomizedForTest.ino")).should == File.read(File.join(ARDUINO_SKETCHES_FIXTURE_DIRECTORY, "src", "BlinkCustomizedForTest", "BlinkCustomizedForTest.ino"))
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|