Skip to content

Commit 8728b83

Browse files
tomduffianfixes
authored andcommitted
Arduino exe now found on windows (#43)
Windows compilation support * Updated arduino self.existing_executable function to find arduino_debug.exe * Added compilers to .arduino-ci.yaml so that build runs * Added error handling around the reg lookup so that it does not just bomb out and runs to the force install function. * Corrected the incorrect reg key used to allow testing of force download * Switched to http for downloads to avoid ssl error
1 parent 20f684c commit 8728b83

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

SampleProjects/DoSomething/.arduino-ci.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ unittest:
1111
- uno
1212
- due
1313
- leonardo
14+
compilers:
15+
- g++
+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
2-
remote: /Users/ikatz/Development/non-wayfair/arduino_ci
2+
remote: ../..
33
specs:
4-
arduino_ci (0.1.7)
4+
arduino_ci (0.1.9)
55
os (~> 1.0)
66

77
GEM
@@ -11,9 +11,10 @@ GEM
1111

1212
PLATFORMS
1313
ruby
14+
x64-mingw32
1415

1516
DEPENDENCIES
1617
arduino_ci!
1718

1819
BUNDLED WITH
19-
1.16.0
20+
1.16.1

lib/arduino_ci/arduino_downloader_windows.rb

+26-15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require 'shellwords' # fingers crossed this works on win32
33
require 'win32/registry'
44
require "arduino_ci/arduino_downloader"
5+
require 'open-uri'
56

67
module ArduinoCI
78

@@ -27,19 +28,28 @@ def prepare
2728
# (for logging purposes)
2829
# @return [string]
2930
def downloader
30-
"wget"
31+
"open-uri"
3132
end
3233

3334
# Download the package_url to package_file
3435
# @return [bool] whether successful
3536
def download
36-
powershell("(New-Object Net.WebClient).DownloadFile('#{package_url}', '#{package_file}')")
37+
puts 'Downloading from ' + package_url
38+
# Turned off ssl verification
39+
open(URI.parse(package_url), ssl_verify_mode: 0) do |url|
40+
File.open(package_file, 'wb') { |file| file.write(url.read) }
41+
end
3742
end
3843

3944
# Move the extracted package file from extracted_file to the force_install_location
4045
# @return [bool] whether successful
4146
def install
42-
powershell("Move-Item", extracted_file, self.class.force_install_location)
47+
puts 'Installing to ' + self.class.force_install_location
48+
# Move only the content of the directory
49+
powershell("Move-Item", extracted_file + "\*", self.class.force_install_location)
50+
# clean up the no longer required root extracted folder
51+
puts 'Removing ' + package_file
52+
powershell("Remove-Item", extracted_file)
4353
end
4454

4555
# The local filename of the desired IDE package (zip/tar/etc)
@@ -58,7 +68,11 @@ def extracter
5868
# Extract the package_file to extracted_file
5969
# @return [bool] whether successful
6070
def extract
61-
powershell("Expand-Archive", package_file, "-dest", extracted_file)
71+
puts 'Extracting ' + package_file + " to " + extracted_file
72+
powershell("Expand-Archive", "-Path", package_file, "-DestinationPath", extracted_file)
73+
# clean up the no longer required zip
74+
puts 'Removing ' + package_file
75+
powershell("Remove-Item", package_file)
6276
end
6377

6478
# The local file (dir) name of the extracted IDE package (zip/tar/etc)
@@ -78,25 +92,22 @@ def self.existing_installation
7892
# The executable Arduino file in an existing installation, or nil
7993
# @return [string]
8094
def self.existing_executable
81-
arduino_reg = 'Software\SOFTWARE\Classes\Arduino file\shell\open\command'
95+
arduino_reg = 'SOFTWARE\WOW6432Node\Arduino'
8296
Win32::Registry::HKEY_LOCAL_MACHINE.open(arduino_reg) do |reg|
83-
reg.each_key do |key|
84-
k = reg.open(key)
85-
puts key
86-
puts k
87-
return k
88-
# puts k["DisplayName"] rescue "?"
89-
# puts k["DisplayVersion"] rescue "?"
90-
# puts
91-
end
97+
path = reg.read_s('Install_Dir')
98+
exe = File.join(path, "arduino_debug.exe")
99+
puts "Using existing exe located at " + exe
100+
return exe if File.exist? exe
92101
end
102+
rescue
93103
nil
94104
end
95105

96106
# The executable Arduino file in a forced installation, or nil
97107
# @return [string]
98108
def self.force_installed_executable
99-
exe = File.join(self.force_install_location, "arduino.exe")
109+
exe = File.join(self.force_install_location, "arduino_debug.exe")
110+
puts "Using force installed exe located at " + exe
100111
return nil if exe.nil?
101112
exe
102113
end

lib/arduino_ci/arduino_installation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def autolocate!
9696
def force_install
9797
worker_class = case Host.os
9898
when :osx then ArduinoDownloaderOSX
99-
# when :windows then force_install_windows
99+
when :windows then ArduinoDownloaderWindows
100100
when :linux then ArduinoDownloaderLinux
101101
end
102102
worker = worker_class.new(DESIRED_ARDUINO_IDE_VERSION)

0 commit comments

Comments
 (0)