Skip to content

Arduino exe now found on windows #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 5, 2018
2 changes: 2 additions & 0 deletions SampleProjects/DoSomething/.arduino-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ unittest:
- uno
- due
- leonardo
compilers:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this line is necessary to make things work, please open an issue for that... the compilers setting should be automatically inherited from https://github.com/ianfixes/arduino_ci/blob/master/misc/default.yml#L83-L84

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. That is what I thought originally until I spotted TestSomething had it explicitly defined so I assumed it must have been a misunderstanding on my part. Note that this behaviour is the same on Windows and Linux. I'll raise an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #44 raised

- g++
7 changes: 4 additions & 3 deletions SampleProjects/DoSomething/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: /Users/ikatz/Development/non-wayfair/arduino_ci
remote: ../..
specs:
arduino_ci (0.1.7)
arduino_ci (0.1.9)
os (~> 1.0)

GEM
Expand All @@ -11,9 +11,10 @@ GEM

PLATFORMS
ruby
x64-mingw32

DEPENDENCIES
arduino_ci!

BUNDLED WITH
1.16.0
1.16.1
41 changes: 26 additions & 15 deletions lib/arduino_ci/arduino_downloader_windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'shellwords' # fingers crossed this works on win32
require 'win32/registry'
require "arduino_ci/arduino_downloader"
require 'open-uri'

module ArduinoCI

Expand All @@ -27,19 +28,28 @@ def prepare
# (for logging purposes)
# @return [string]
def downloader
"wget"
"open-uri"
end

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

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

# The local filename of the desired IDE package (zip/tar/etc)
Expand All @@ -58,7 +68,11 @@ def extracter
# Extract the package_file to extracted_file
# @return [bool] whether successful
def extract
powershell("Expand-Archive", package_file, "-dest", extracted_file)
puts 'Extracting ' + package_file + " to " + extracted_file
powershell("Expand-Archive", "-Path", package_file, "-DestinationPath", extracted_file)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to mute the output from this command? It dominates the build log https://ci.appveyor.com/project/ianfixes/arduino-ci/build/1.0.31#L144

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't see any flags in the powershell command definition although it suggests there might be common parameters. Standard suggestions on google appear to be to pipe to null. I just pushed up a version with this but it looks like you have merged already so I am not sure if that was included or not.

Note - This doesn't happen when run locally, you just get a nice nice progress bar:
[oooooooooooo........................................ ]

I did wonder if both extract and move could be done using a ruby dependency rather than powershell, but my ruby knowledge is minimal to none.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting those in pure ruby is probably the right way to go. I more or less ported the install.sh script from Adafruit to boostrap this project... so now that it looks like I'm headed for cross-platform fun (beyond my most ambitious expectations, honestly, in a good way!), I will plan to take a closer look at that.

Of course, having working cross-platform CI is a great enabler for that kind of thing in the first place... so I can't thank you enough for your help here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I cherry-picked your commit with no problems. Thanks

# clean up the no longer required zip
puts 'Removing ' + package_file
powershell("Remove-Item", package_file)
end

# The local file (dir) name of the extracted IDE package (zip/tar/etc)
Expand All @@ -78,25 +92,22 @@ def self.existing_installation
# The executable Arduino file in an existing installation, or nil
# @return [string]
def self.existing_executable
arduino_reg = 'Software\SOFTWARE\Classes\Arduino file\shell\open\command'
arduino_reg = 'SOFTWARE\WOW6432Node\Arduino'
Win32::Registry::HKEY_LOCAL_MACHINE.open(arduino_reg) do |reg|
reg.each_key do |key|
k = reg.open(key)
puts key
puts k
return k
# puts k["DisplayName"] rescue "?"
# puts k["DisplayVersion"] rescue "?"
# puts
end
path = reg.read_s('Install_Dir')
exe = File.join(path, "arduino_debug.exe")
puts "Using existing exe located at " + exe
return exe if File.exist? exe
end
rescue
nil
end

# The executable Arduino file in a forced installation, or nil
# @return [string]
def self.force_installed_executable
exe = File.join(self.force_install_location, "arduino.exe")
exe = File.join(self.force_install_location, "arduino_debug.exe")
puts "Using force installed exe located at " + exe
return nil if exe.nil?
exe
end
Expand Down
2 changes: 1 addition & 1 deletion lib/arduino_ci/arduino_installation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def autolocate!
def force_install
worker_class = case Host.os
when :osx then ArduinoDownloaderOSX
# when :windows then force_install_windows
when :windows then ArduinoDownloaderWindows
when :linux then ArduinoDownloaderLinux
end
worker = worker_class.new(DESIRED_ARDUINO_IDE_VERSION)
Expand Down