Skip to content

Commit 800501c

Browse files
committed
add location of gcc binary to installation
1 parent 394e985 commit 800501c

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

lib/arduino_ci/arduino_cmd.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def self.flag(name, text = nil)
1818

1919
attr_accessor :installation
2020
attr_accessor :base_cmd
21+
attr_accessor :gcc_cmd
2122

2223
attr_reader :library_is_indexed
2324

@@ -98,6 +99,12 @@ def run(*args, **kwargs)
9899
_run(*full_args, **kwargs)
99100
end
100101

102+
def run_gcc(*args, **kwargs)
103+
# TODO: detect env!!
104+
full_args = @gcc_cmd + args
105+
_run(*full_args, **kwargs)
106+
end
107+
101108
# run a command and capture its output
102109
# @return [Hash] {:out => String, :err => String, :success => bool}
103110
def run_and_capture(*args, **kwargs)

lib/arduino_ci/arduino_installation.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ def autolocate
2525
end
2626

2727
def autolocate_osx
28-
osx_root = "/Applications/Arduino.app"
28+
osx_root = "/Applications/Arduino.app/Contents"
2929
old_way = false
3030
return nil unless File.exist? osx_root
3131

3232
ret = ArduinoCmdOSX.new
33-
osx_place = "#{osx_root}/Contents/MacOS"
33+
osx_place = "#{osx_root}/MacOS"
3434

3535
if old_way
3636
ret.base_cmd = [File.join(osx_place, "Arduino")]
3737
else
3838
jvm_runtime = `/usr/libexec/java_home`
3939
ret.base_cmd = [
4040
"java",
41-
"-cp", "#{osx_root}/Contents/Java/*",
42-
"-DAPP_DIR=#{osx_root}/Contents/Java",
41+
"-cp", "#{osx_root}/Java/*",
42+
"-DAPP_DIR=#{osx_root}/Java",
4343
"-Djava.ext.dirs=$JVM_RUNTIME/Contents/Home/lib/ext/:#{jvm_runtime}/Contents/Home/jre/lib/ext/",
4444
"-Dfile.encoding=UTF-8",
4545
"-Dapple.awt.UIElement=true",
@@ -48,6 +48,8 @@ def autolocate_osx
4848
"processing.app.Base",
4949
]
5050
end
51+
52+
ret.gcc_cmd = [File.join(osx_root, "Java", "hardware", "tools", "avr", "bin", "avr-gcc")]
5153
ret
5254
end
5355

@@ -58,13 +60,15 @@ def autolocate_linux
5860
unless cli_place.nil?
5961
ret = ArduinoCmdLinuxBuilder.new
6062
ret.base_cmd = [cli_place]
63+
ret.gcc_cmd = Host.which("avr-gcc")
6164
return ret
6265
end
6366

6467
forced_builder = File.join(force_install_location, builder_name)
6568
if File.exist?(forced_builder)
6669
ret = ArduinoCmdLinuxBuilder.new
6770
ret.base_cmd = [forced_builder]
71+
ret.gcc_cmd = [File.join(force_install_location, "hardware", "tools", "avr", "bin", "avr-gcc")]
6872
return ret
6973
end
7074
end
@@ -74,13 +78,15 @@ def autolocate_linux
7478
unless gui_place.nil?
7579
ret = ArduinoCmdLinux.new
7680
ret.base_cmd = [gui_place]
81+
ret.gcc_cmd = Host.which("avr-gcc")
7782
return ret
7883
end
7984

8085
forced_arduino = File.join(force_install_location, gui_name)
8186
if File.exist?(forced_arduino)
8287
ret = ArduinoCmdLinux.new
8388
ret.base_cmd = [forced_arduino]
89+
ret.gcc_cmd = [File.join(force_install_location, "hardware", "tools", "avr", "bin", "avr-gcc")]
8490
return ret
8591
end
8692
nil

spec/arduino_installation_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@
1414
end
1515

1616
context "autolocate!" do
17+
arduino_cmd = ArduinoCI::ArduinoInstallation.autolocate!
1718
it "doesn't fail" do
18-
arduino_cmd = ArduinoCI::ArduinoInstallation.autolocate!
1919
expect(arduino_cmd.base_cmd).not_to be nil
20+
expect(arduino_cmd.gcc_cmd).not_to be nil
2021
expect(arduino_cmd._lib_dir).not_to be nil
2122
end
23+
24+
it "produces a working AVR-GCC" do
25+
expect(arduino_cmd.gcc_cmd).not_to be nil
26+
expect(arduino_cmd.run_gcc("--version")).to be true
27+
end
2228
end
2329

2430
end

0 commit comments

Comments
 (0)