@@ -32,20 +32,35 @@ def autolocate_osx
32
32
osx_root = "/Applications/Arduino.app/Contents"
33
33
return nil unless File . exist? osx_root
34
34
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" ) ]
48
50
]
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
49
64
ret
50
65
end
51
66
0 commit comments