forked from JorenSix/pector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_arduino_patch.rb
59 lines (47 loc) · 1.11 KB
/
setup_arduino_patch.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/env ruby
#small helper script to link to souce file in a way expected
#by the arduino IDE
if ARGV.size != 1
STDERR.puts "A single folder name is expected as argument"
exit(1)
return
end
require 'fileutils'
folder = ARGV[0]
unless File.exist? folder
FileUtils.mkdir_p folder
end
source_files = %w(
pector_config.c
pector_reader.c
pector_stream_processor.c
pector_util.c
pffft.c
)
header_files = %w(
pector_config.h
pector_reader.h
pector_stream_processor.h
pector_util.h
pffft.h
)
ino_file = "#{folder}/#{folder}.ino"
unless File.exist? ino_file
content = header_files.map{|e| "#include \"#{e}\""}.join("\n")
File.write(ino_file, content)
end
(header_files + source_files).each do |file|
if ! File.exist? "../src/#{file}"
STDERR.puts "../src/#{file} does not exist"
exit -10
end
end
source_files.each do |source_file|
system("ln -s ../../src/#{source_file} #{File.join(folder,source_file)}pp")
end
header_files.each do |header_file|
system("ln -s ../../src/#{header_file} #{folder}")
end
source_files.each do |source_file|
system("ln -s ../../src/#{source_file} #{File.join(folder,source_file)}pp")
end