mkduino 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/mkduino +32 -14
- data/lib/autogen_sh.rb +51 -0
- data/lib/configure_ac.rb +67 -0
- data/lib/file_generator.rb +46 -0
- data/lib/makefile_am.rb +25 -3
- data/lib/mkduino/version.rb +1 -1
- data/lib/mkduino.rb +35 -71
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de0f4ee565df942d0e8e9f2dccd172fdf20b3641
|
4
|
+
data.tar.gz: 2cc271faf1f3776cbcb7efab8667f68cbe39190f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38d1996ef00ea152d12c75eba66caa81c1424776f86b24b1732f005bfd01a9788eff1ff2fdca114d45fe3d9c9694f376788ece36c60069c232192ea82f8a3363
|
7
|
+
data.tar.gz: 7aad23e98edaf57cee23f1c0c585dbe2f53d9dfdad09dca114bc04c4eb8d0faa69d202e0e6a558b97e3bab1b9cf53c9280aa614b3c4b1a23440a5152a19cce78
|
data/bin/mkduino
CHANGED
@@ -23,6 +23,13 @@
|
|
23
23
|
# MA 02111-1307 USA
|
24
24
|
#
|
25
25
|
|
26
|
+
#
|
27
|
+
# get_updates -> backup files -> output -> save -> apply_updates
|
28
|
+
#
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
26
33
|
require "mkduino"
|
27
34
|
require 'optparse'
|
28
35
|
|
@@ -33,7 +40,8 @@ OptionParser.new do |opts|
|
|
33
40
|
options[:update] = false
|
34
41
|
options[:overwrite] = false
|
35
42
|
options[:num_args] = ARGV.length
|
36
|
-
|
43
|
+
options[:autoconfigure] = false
|
44
|
+
options[:device] = "standard"
|
37
45
|
opts.banner = "Usage: #{opts.program_name} [options]"
|
38
46
|
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
39
47
|
options[:verbose] = v
|
@@ -44,6 +52,9 @@ OptionParser.new do |opts|
|
|
44
52
|
# opts.on("-u","--[no-]update","Update current project files") do |v|
|
45
53
|
# options[:update] = v
|
46
54
|
# end
|
55
|
+
opts.on('-a',"--[no-]autoconfigure","automatically run autogen.sh and configure") do |v|
|
56
|
+
options[:autoconfigure] = v
|
57
|
+
end
|
47
58
|
opts.on("-o","--[no-]overwrite","Overwrite current project files") do |v|
|
48
59
|
options[:overwrite] = v
|
49
60
|
end
|
@@ -59,14 +70,9 @@ OptionParser.new do |opts|
|
|
59
70
|
|
60
71
|
end.parse!
|
61
72
|
|
62
|
-
if
|
63
|
-
Pathname.new("
|
64
|
-
|
65
|
-
Pathname.new("config/config.h").exist? ||
|
66
|
-
Pathname.new("NEWS").exist? ||
|
67
|
-
Pathname.new("README").exist? ||
|
68
|
-
Pathname.new("AUTHORS").exist? ||
|
69
|
-
Pathname.new("ChangeLog").exist?) && !options[:overwrite])
|
73
|
+
if !options[:overwrite] && Mkduino::GENERATED_FILES.collect do |gf|
|
74
|
+
Pathname.new("Makefile.am").exist? ? true : nil
|
75
|
+
end.compact.any?
|
70
76
|
puts "Please supply --overwrite to ovewrite existing files"
|
71
77
|
exit
|
72
78
|
end
|
@@ -78,7 +84,7 @@ ma.find_arduino_libraries '/usr/share/arduino/libraries'
|
|
78
84
|
ma.find_arduino_libraries '/usr/share/arduino/hardware/arduino/cores'
|
79
85
|
ma.find_source_files
|
80
86
|
ca = Mkduino::ConfigureAc.new ma
|
81
|
-
as = Mkduino::AutogenSh.new
|
87
|
+
as = Mkduino::AutogenSh.new "autogen.sh"
|
82
88
|
if options[:verbose]
|
83
89
|
puts ma.to_yaml
|
84
90
|
end
|
@@ -99,7 +105,6 @@ as.write_autogen_sh
|
|
99
105
|
#
|
100
106
|
# A few shell commands required to make it all tidy
|
101
107
|
#
|
102
|
-
`chmod +x autogen.sh`
|
103
108
|
`mkdir m4` unless Dir.exist?('m4')
|
104
109
|
`mkdir config` unless Dir.exist?('config')
|
105
110
|
`touch config/config.h`
|
@@ -108,6 +113,19 @@ as.write_autogen_sh
|
|
108
113
|
`touch AUTHORS`
|
109
114
|
`touch ChangeLog`
|
110
115
|
|
111
|
-
|
112
|
-
|
113
|
-
|
116
|
+
if options[:autoconfigure]
|
117
|
+
`./autogen.sh`
|
118
|
+
unless Dir.exist?('build')
|
119
|
+
Dir.mkdir('build')
|
120
|
+
end
|
121
|
+
Dir.chdir("build")
|
122
|
+
`../configure --host=avr`
|
123
|
+
`make hex`
|
124
|
+
puts "*******************************"
|
125
|
+
puts "** now run cd build ; make **"
|
126
|
+
puts "*******************************"
|
127
|
+
else
|
128
|
+
puts "*******************************"
|
129
|
+
puts "** now run ./autogen.sh **"
|
130
|
+
puts "*******************************"
|
131
|
+
end
|
data/lib/autogen_sh.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# autogen_sh.rb
|
2
|
+
#
|
3
|
+
# (C) Copyright 2013,2014
|
4
|
+
# David H. Wilkins <dwilkins@conecuh.com>
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU General Public License as
|
8
|
+
# published by the Free Software Foundation; either version 2 of
|
9
|
+
# the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
19
|
+
# MA 02111-1307 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
module Mkduino
|
23
|
+
class AutogenSh < GeneratedFile
|
24
|
+
def initialize output_filename = 'autogen.sh', options = {}
|
25
|
+
super output_filename, options
|
26
|
+
end
|
27
|
+
def write_autogen_sh
|
28
|
+
puts("Writing #{@output_filename}")
|
29
|
+
write_file do |f|
|
30
|
+
f.puts <<-AUTOGEN_SH
|
31
|
+
#!/bin/sh
|
32
|
+
if [ -e 'Makefile.am' ] ; then
|
33
|
+
echo "Makefile.am Exists - reconfiguring..."
|
34
|
+
autoreconf --force --install -I config -I m4
|
35
|
+
echo
|
36
|
+
echo
|
37
|
+
echo "************************************"
|
38
|
+
echo "** Now run mkdir build ; cd build ; ../configure --host=avr **"
|
39
|
+
echo "************************************"
|
40
|
+
exit
|
41
|
+
fi
|
42
|
+
echo "Lets get your project started!"
|
43
|
+
|
44
|
+
echo '## Process this file with automake to produce Makefile.in' >> Makefile.am
|
45
|
+
echo No Makefile.am
|
46
|
+
AUTOGEN_SH
|
47
|
+
end
|
48
|
+
`chmod +x #{@output_directory}#{@output_filename}`
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/configure_ac.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# configure_ac.rb
|
2
|
+
#
|
3
|
+
# (C) Copyright 2013,2014
|
4
|
+
# David H. Wilkins <dwilkins@conecuh.com>
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU General Public License as
|
8
|
+
# published by the Free Software Foundation; either version 2 of
|
9
|
+
# the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
19
|
+
# MA 02111-1307 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
module Mkduino
|
23
|
+
class ConfigureAc < Mkduino::GeneratedFile
|
24
|
+
attr_accessor :makefile_am, :output_filename
|
25
|
+
def initialize makefile_am, output_filename = 'configure.ac', options = {}
|
26
|
+
super output_filename, options
|
27
|
+
@makefile_am = makefile_am
|
28
|
+
end
|
29
|
+
|
30
|
+
def write_configure_ac
|
31
|
+
write_file do |f|
|
32
|
+
f.puts <<-CONFIGURE_AC
|
33
|
+
dnl Process this file with autoconf to produce a configure script.")
|
34
|
+
AC_INIT([#{makefile_am.project_name}], [1.0])
|
35
|
+
dnl AC_CONFIG_SRCDIR( [ Makefile.am ] )
|
36
|
+
AM_INIT_AUTOMAKE
|
37
|
+
AM_CONFIG_HEADER(config.h)
|
38
|
+
dnl AM_CONFIG_HEADER(config.h)
|
39
|
+
dnl Checks for programs.
|
40
|
+
AC_PROG_CC( avr-gcc )
|
41
|
+
AC_PROG_CXX( avr-g++ )
|
42
|
+
AC_PROG_RANLIB( avr-ranlib )
|
43
|
+
AC_PATH_PROG(OBJCOPY, avr-objcopy)
|
44
|
+
AC_PATH_PROG(AVRDUDE, avrdude)
|
45
|
+
|
46
|
+
AC_ISC_POSIX
|
47
|
+
|
48
|
+
dnl Checks for libraries.
|
49
|
+
|
50
|
+
dnl Checks for header files.
|
51
|
+
AC_HAVE_HEADERS( Arduino.h )
|
52
|
+
|
53
|
+
dnl Checks for library functions.
|
54
|
+
|
55
|
+
dnl Check for st_blksize in struct stat
|
56
|
+
|
57
|
+
|
58
|
+
dnl internationalization macros
|
59
|
+
AC_OUTPUT([Makefile])
|
60
|
+
|
61
|
+
CONFIGURE_AC
|
62
|
+
end
|
63
|
+
return
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Mkduino
|
4
|
+
class GeneratedFile
|
5
|
+
attr_accessor :output_filename, :output_directory
|
6
|
+
attr_accessor :backup_directory, :user_updates_file
|
7
|
+
|
8
|
+
def initialize output_filename, options = {}
|
9
|
+
@output_filename = output_filename
|
10
|
+
@output_directory = options[:output_directory] || '.' + File::SEPARATOR
|
11
|
+
@backup_directory = options[:backup_directory] || 'generated'
|
12
|
+
@user_updates_file = options[:user_updates_file] || @output_filename + ".patch"
|
13
|
+
|
14
|
+
@output_directory = @output_directory + File::SEPARATOR unless @output_directory[-1] == File::SEPARATOR
|
15
|
+
@backup_directory = @backup_directory + File::SEPARATOR unless @backup_directory[-1] == File::SEPARATOR
|
16
|
+
puts "GeneratedFile.output_filename " + @output_filename
|
17
|
+
end
|
18
|
+
|
19
|
+
def write_file
|
20
|
+
File.open("#{@output_directory}#{@output_filename}","w") do |f|
|
21
|
+
yield f
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def save_file
|
26
|
+
unless Dir.exist?(@backup_directory)
|
27
|
+
Dir.mkdir(@backup_directory)
|
28
|
+
end
|
29
|
+
File::cp("#{output_directory}#{@output_filename}",@backup_directory)
|
30
|
+
end
|
31
|
+
|
32
|
+
def save_user_updates
|
33
|
+
if(Pathname.new("#{output_directory}#{@output_file}").exist? &&
|
34
|
+
Pathname.new("#{@backup_directory}#{@output_file}"))
|
35
|
+
`diff -u #{@backup_directory}#{output_file} #{@output_directory}#{output_file} > #{user_updates_file}`
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def apply_user_updates
|
41
|
+
`patch < #{user_updates_file}`
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
data/lib/makefile_am.rb
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
# makefile_am.rb
|
2
|
+
#
|
3
|
+
# (C) Copyright 2013,2014
|
4
|
+
# David H. Wilkins <dwilkins@conecuh.com>
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU General Public License as
|
8
|
+
# published by the Free Software Foundation; either version 2 of
|
9
|
+
# the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
19
|
+
# MA 02111-1307 USA
|
20
|
+
#
|
1
21
|
#
|
2
22
|
# Class that keeps up with the stuff needed for the Makefile.am file
|
3
23
|
# this is most of the stuff needed to generate the automake stuff
|
@@ -18,7 +38,7 @@ module Mkduino
|
|
18
38
|
@project_name.tr!('.-','__')
|
19
39
|
@source_files = []
|
20
40
|
@header_files = []
|
21
|
-
@project_includes = []
|
41
|
+
@project_includes = ["."]
|
22
42
|
@arduino_sources = []
|
23
43
|
@arduino_includes = []
|
24
44
|
@arduino_libraries = []
|
@@ -268,9 +288,11 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(bin_PROGRAMS).hex
|
|
268
288
|
AVRDUDE_FLAGS = -q -D -C/etc/avrdude/avrdude.conf -p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) -b$(UPLOAD_RATE)
|
269
289
|
|
270
290
|
|
271
|
-
.PHONY: upload
|
272
|
-
|
291
|
+
.PHONY: upload hex
|
292
|
+
hex: all-am
|
273
293
|
$(OBJCOPY) -S -O $(FORMAT) $(bin_PROGRAMS) $(bin_PROGRAMS).hex
|
294
|
+
|
295
|
+
upload: hex
|
274
296
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
|
275
297
|
MAKEFILE_AM
|
276
298
|
|
data/lib/mkduino/version.rb
CHANGED
data/lib/mkduino.rb
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
# mkduino.rb
|
2
|
+
#
|
3
|
+
# (C) Copyright 2013,2014
|
4
|
+
# David H. Wilkins <dwilkins@conecuh.com>
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU General Public License as
|
8
|
+
# published by the Free Software Foundation; either version 2 of
|
9
|
+
# the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
19
|
+
# MA 02111-1307 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
|
1
23
|
require "mkduino/version"
|
2
24
|
require 'yaml'
|
3
25
|
require 'find'
|
@@ -6,10 +28,22 @@ require 'fileutils'
|
|
6
28
|
|
7
29
|
include FileUtils
|
8
30
|
|
31
|
+
require_relative "file_generator"
|
9
32
|
require_relative "makefile_am"
|
10
|
-
|
33
|
+
require_relative "configure_ac"
|
34
|
+
require_relative "autogen_sh"
|
11
35
|
|
12
36
|
module Mkduino
|
37
|
+
GENERATED_FILES = ["Makefile.am",
|
38
|
+
"configure.ac",
|
39
|
+
"autogen.sh",
|
40
|
+
"config/config.h",
|
41
|
+
"NEWS",
|
42
|
+
"README",
|
43
|
+
"AUTHORS",
|
44
|
+
"ChangeLog"]
|
45
|
+
|
46
|
+
|
13
47
|
#
|
14
48
|
# Represents the files needed for a particular arduino library
|
15
49
|
#
|
@@ -57,74 +91,4 @@ LIBRARY_OUTPUT
|
|
57
91
|
end
|
58
92
|
|
59
93
|
|
60
|
-
class ConfigureAc
|
61
|
-
attr_accessor :makefile_am
|
62
|
-
def initialize makefile_am
|
63
|
-
@makefile_am = makefile_am
|
64
|
-
end
|
65
|
-
def write_configure_ac
|
66
|
-
##
|
67
|
-
# Output the configure.ac file
|
68
|
-
##
|
69
|
-
puts "Writing configure.ac"
|
70
|
-
File.open('configure.ac',"w") do |f|
|
71
|
-
f.puts <<-CONFIGURE_AC
|
72
|
-
dnl Process this file with autoconf to produce a configure script.")
|
73
|
-
AC_INIT([#{makefile_am.project_name}], [1.0])
|
74
|
-
dnl AC_CONFIG_SRCDIR( [ Makefile.am ] )
|
75
|
-
AM_INIT_AUTOMAKE
|
76
|
-
AM_CONFIG_HEADER(config.h)
|
77
|
-
dnl AM_CONFIG_HEADER(config.h)
|
78
|
-
dnl Checks for programs.
|
79
|
-
AC_PROG_CC( avr-gcc )
|
80
|
-
AC_PROG_CXX( avr-g++ )
|
81
|
-
AC_PROG_RANLIB( avr-ranlib )
|
82
|
-
AC_PATH_PROG(OBJCOPY, avr-objcopy)
|
83
|
-
AC_PATH_PROG(AVRDUDE, avrdude)
|
84
|
-
|
85
|
-
AC_ISC_POSIX
|
86
|
-
|
87
|
-
dnl Checks for libraries.
|
88
|
-
|
89
|
-
dnl Checks for header files.
|
90
|
-
AC_HAVE_HEADERS( Arduino.h )
|
91
|
-
|
92
|
-
dnl Checks for library functions.
|
93
|
-
|
94
|
-
dnl Check for st_blksize in struct stat
|
95
|
-
|
96
|
-
|
97
|
-
dnl internationalization macros
|
98
|
-
AC_OUTPUT([Makefile])
|
99
|
-
|
100
|
-
CONFIGURE_AC
|
101
|
-
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
class AutogenSh
|
107
|
-
def write_autogen_sh
|
108
|
-
puts("Writing autogen.sh")
|
109
|
-
File.open('autogen.sh',"w") do |f|
|
110
|
-
f.puts <<-AUTOGEN_SH
|
111
|
-
#!/bin/sh
|
112
|
-
if [ -e 'Makefile.am' ] ; then
|
113
|
-
echo "Makefile.am Exists - reconfiguring..."
|
114
|
-
autoreconf --force --install -I config -I m4
|
115
|
-
echo
|
116
|
-
echo
|
117
|
-
echo "************************************"
|
118
|
-
echo "** Now run mkdir build ; cd build ; ../configure --host=avr **"
|
119
|
-
echo "************************************"
|
120
|
-
exit
|
121
|
-
fi
|
122
|
-
echo "Lets get your project started!"
|
123
|
-
|
124
|
-
echo '## Process this file with automake to produce Makefile.in' >> Makefile.am
|
125
|
-
echo No Makefile.am
|
126
|
-
AUTOGEN_SH
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mkduino
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David H. Wilkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,9 @@ files:
|
|
52
52
|
- README.md
|
53
53
|
- Rakefile
|
54
54
|
- bin/mkduino
|
55
|
+
- lib/autogen_sh.rb
|
56
|
+
- lib/configure_ac.rb
|
57
|
+
- lib/file_generator.rb
|
55
58
|
- lib/makefile_am.rb
|
56
59
|
- lib/mkduino.rb
|
57
60
|
- lib/mkduino/version.rb
|