Skip to content

Commit 9b43554

Browse files
committed
use fallback if splash-screen-skip-hack fails
1 parent c4fbce1 commit 9b43554

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
### Changed
1313
- Author
14+
- Splash-screen-skip hack on OSX now falls back on "official" launch method if the hack doesn't work
1415

1516
### Deprecated
1617

lib/arduino_ci/arduino_installation.rb

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,35 @@ def autolocate_osx
3232
osx_root = "/Applications/Arduino.app/Contents"
3333
return nil unless File.exist? osx_root
3434

35-
ret = ArduinoCmdOSX.new
36-
37-
# old_way
38-
# ret.base_cmd = [File.join("#{osx_root}/MacOS", "Arduino")]
39-
ret.base_cmd = [
40-
"java",
41-
"-cp", "#{osx_root}/Java/*",
42-
"-DAPP_DIR=#{osx_root}/Java",
43-
"-Dfile.encoding=UTF-8",
44-
"-Dapple.awt.UIElement=true",
45-
"-Xms128M",
46-
"-Xmx512M",
47-
"processing.app.Base",
35+
launchers = [
36+
# try a hack that skips splash screen
37+
# from https://github.com/arduino/Arduino/issues/1970#issuecomment-321975809
38+
[
39+
"java",
40+
"-cp", "#{osx_root}/Java/*",
41+
"-DAPP_DIR=#{osx_root}/Java",
42+
"-Dfile.encoding=UTF-8",
43+
"-Dapple.awt.UIElement=true",
44+
"-Xms128M",
45+
"-Xmx512M",
46+
"processing.app.Base",
47+
],
48+
# failsafe way
49+
[File.join(osx_root, "MacOS", "Arduino")]
4850
]
51+
52+
# create return and find a command launcher that works
53+
ret = ArduinoCmdOSX.new
54+
launchers.each do |launcher|
55+
ret.base_cmd = launcher
56+
# test whether this method successfully launches the IDE
57+
# note that "successful launch" involves a command that will fail,
58+
# because that's faster than any command which succeeds. what we
59+
# don't want to see is a java error.
60+
args = ret.base_cmd + ["--bogus-option"]
61+
result = Host.run_and_capture(*args)
62+
break if result[:err].include? "Error: unknown option: --bogus-option"
63+
end
4964
ret
5065
end
5166

0 commit comments

Comments
 (0)