Class: ArduinoSketchBuilder::Setup
- Inherits:
-
Object
- Object
- ArduinoSketchBuilder::Setup
- Defined in:
- lib/arduino_sketch_builder/setup.rb
Constant Summary collapse
- ARDUINO_CMAKE_DIRECTORY =
File.('../../../arduino-cmake', __FILE__)
- TEMPLATES_DIRECTORY =
File.('../../../templates', __FILE__)
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.configure(root_directory) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/arduino_sketch_builder/setup.rb', line 9 def self.configure(root_directory) FileUtils.cp_r(File.join(ARDUINO_CMAKE_DIRECTORY, 'cmake'), root_directory) FileUtils.chmod_R('og-rwx', File.join(root_directory, 'cmake')) FileUtils.mkdir_p(File.join(root_directory, 'libraries')) FileUtils.cp(File.join(TEMPLATES_DIRECTORY, 'gitkeep_template'), File.join(root_directory, 'libraries', '.gitkeep')) FileUtils.chmod_R('og-rwx', File.join(root_directory, 'libraries')) FileUtils.chmod('og-rwx', File.join(root_directory, 'libraries', '.gitkeep')) FileUtils.cp(File.join(TEMPLATES_DIRECTORY, 'root_gitignore_template'), File.join(root_directory, '.gitignore')) FileUtils.chmod('og-rwx', File.join(root_directory, '.gitignore')) end |
Instance Method Details
#setup(root_directory, sketch_file_path, board_type: "uno", board_port: "/dev/tty.usbmodem411") ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/arduino_sketch_builder/setup.rb', line 26 def setup(root_directory, sketch_file_path, board_type: "uno", board_port: "/dev/tty.usbmodem411") sketch_file_name = File.basename(sketch_file_path) sketch_name = sketch_file_name.split('.').first main_directory_name = sketch_name.underscore FileUtils.mkdir_p([File.join(root_directory, main_directory_name), File.join(root_directory, main_directory_name, 'src'), File.join(root_directory, main_directory_name, 'build'), File.join(root_directory, main_directory_name, 'src', sketch_name)]) c_make_lists_file_generator = ArduinoSketchBuilder::CMakeListsFileGenerator.new c_make_lists_file_generator.generate_main(root_directory, File.join(root_directory, main_directory_name)) c_make_lists_file_generator.generate_sketch_specific(sketch_name, File.join(root_directory, main_directory_name, 'src'), board_type: board_type, board_port: board_port) File.write(File.join(root_directory, main_directory_name, 'src', sketch_name, sketch_file_name), File.read(sketch_file_path)) FileUtils.chmod_R('og-rwx', File.join(root_directory, main_directory_name)) end |