Skip to content

Commit ff44486

Browse files
committed
Initial and likely very broken windows CI commit
1 parent 921925f commit ff44486

File tree

5 files changed

+170
-7
lines changed

5 files changed

+170
-7
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![Gem Version](https://badge.fury.io/rb/arduino_ci.svg)](https://rubygems.org/gems/arduino_ci)
2-
[![Build Status](https://travis-ci.org/ianfixes/arduino_ci.svg)](https://travis-ci.org/ianfixes/arduino_ci)
2+
[![Linux Build Status](https://travis-ci.org/ianfixes/arduino_ci.svg)](https://travis-ci.org/ianfixes/arduino_ci)
3+
[![Windows Build status](https://ci.appveyor.com/api/projects/status/8f6e39dea319m83q?svg=true)](https://ci.appveyor.com/project/ianfixes/arduino-ci)
34
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/0.1.9)
45

56
# ArduinoCI Ruby gem (`arduino_ci`)

appveyor.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
install:
2+
- set PATH=C:\Ruby22\bin;%PATH%
3+
- bundle install
4+
- '%CYG_ROOT%\setup-%CYG_ARCH%.exe -qnNdO -R %CYG_ROOT% -s http://cygwin.mirror.constant.com -l %CYG_ROOT%/var/cache/setup -P autoconf -P automake -P bison -P libgmp-devel -P gcc-core -P gcc-g++ -P mingw-runtime -P mingw-binutils -P mingw-gcc-core -P mingw-gcc-g++ -P mingw-pthreads -P mingw-w32api -P libtool -P make -P gettext-devel -P gettext -P intltool -P libiconv -P pkg-config -P git -P wget -P curl'
5+
6+
build: off
7+
8+
before_test:
9+
- ruby -v
10+
- gem -v
11+
- bundle -v
12+
- g++ -v
13+
14+
test_script:
15+
- bundle exec rubocop --version
16+
- bundle exec rubocop -D .
17+
- bundle exec rspec
18+
- cd SampleProjects\TestSomething
19+
- bundle install
20+
- bundle exec arduino_ci_remote.rb

lib/arduino_ci/arduino_cmd_windows.rb

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require "arduino_ci/host"
2+
require 'arduino_ci/arduino_cmd'
3+
4+
module ArduinoCI
5+
6+
# Implementation of OSX commands
7+
class ArduinoCmdWindows < ArduinoCmd
8+
flag :get_pref, "--get-pref"
9+
flag :set_pref, "--pref"
10+
flag :save_prefs, "--save-prefs"
11+
flag :use_board, "--board"
12+
flag :install_boards, "--install-boards"
13+
flag :install_library, "--install-library"
14+
flag :verify, "--verify"
15+
16+
# run the arduino command
17+
# @return [bool] whether the command succeeded
18+
def _run_and_output(*args, **kwargs)
19+
Host.run_and_output(*args, **kwargs)
20+
end
21+
22+
# run the arduino command
23+
# @return [Hash] keys for :success, :out, and :err
24+
def _run_and_capture(*args, **kwargs)
25+
Host.run_and_capture(*args, **kwargs)
26+
end
27+
28+
def _lib_dir
29+
File.join(ENV['userprofile'], "Documents", "Arduino", "libraries")
30+
end
31+
32+
end
33+
34+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
require 'base64'
2+
require 'shellwords' # fingers crossed this works on win32
3+
require 'win32'
4+
require "arduino_ci/arduino_downloader"
5+
6+
module ArduinoCI
7+
8+
# Manage the POSIX download & install of Arduino
9+
class ArduinoDownloaderWindows < ArduinoDownloader
10+
11+
def powershell(*args)
12+
encoded_cmd = Base64.strict_encode64(args.shelljoin.encode('utf-16le'))
13+
system("powershell.exe", "-encodedCommand", encoded_cmd)
14+
end
15+
16+
def cygwin(*args)
17+
system("%CYG_ROOT%/bin/bash", "-lc", args.shelljoin)
18+
end
19+
20+
# Make any preparations or run any checks prior to making changes
21+
# @return [string] Error message, or nil if success
22+
def prepare
23+
nil
24+
end
25+
26+
# The technology that will be used to complete the download
27+
# (for logging purposes)
28+
# @return [string]
29+
def downloader
30+
"wget"
31+
end
32+
33+
# Download the package_url to package_file
34+
# @return [bool] whether successful
35+
def download
36+
powershell("(New-Object Net.WebClient).DownloadFile('#{package_url}', '#{package_file}')")
37+
end
38+
39+
# Move the extracted package file from extracted_file to the force_install_location
40+
# @return [bool] whether successful
41+
def install
42+
powershell("Move-Item", extracted_file, self.class.force_install_location)
43+
end
44+
45+
# The local filename of the desired IDE package (zip/tar/etc)
46+
# @return [string]
47+
def package_file
48+
"#{extracted_file}-windows.zip"
49+
end
50+
51+
# The technology that will be used to extract the download
52+
# (for logging purposes)
53+
# @return [string]
54+
def extracter
55+
"Expand-Archive"
56+
end
57+
58+
# Extract the package_file to extracted_file
59+
# @return [bool] whether successful
60+
def extract
61+
powershell("Expand-Archive", package_file, "-dest", extracted_file)
62+
end
63+
64+
# The local file (dir) name of the extracted IDE package (zip/tar/etc)
65+
# @return [string]
66+
def extracted_file
67+
"arduino-#{@desired_ide_version}"
68+
end
69+
70+
# The path to the directory of an existing installation, or nil
71+
# @return [string]
72+
def self.existing_installation
73+
exe = self.existing_executable
74+
return nil if exe.nil?
75+
File.dirname(exe)
76+
end
77+
78+
# The executable Arduino file in an existing installation, or nil
79+
# @return [string]
80+
def self.existing_executable
81+
arduino_reg = 'Software\SOFTWARE\Classes\Arduino file\shell\open\command'
82+
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
92+
end
93+
nil
94+
end
95+
96+
# The executable Arduino file in a forced installation, or nil
97+
# @return [string]
98+
def self.force_installed_executable
99+
exe = File.join(self.force_install_location, "arduino.exe")
100+
return nil if exe.nil?
101+
exe
102+
end
103+
104+
end
105+
end

lib/arduino_ci/arduino_installation.rb

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
require "arduino_ci/host"
22
require "arduino_ci/arduino_cmd_osx"
33
require "arduino_ci/arduino_cmd_linux"
4+
require "arduino_ci/arduino_cmd_windows"
45
require "arduino_ci/arduino_cmd_linux_builder"
5-
require "arduino_ci/arduino_downloader_linux"
66
require "arduino_ci/arduino_downloader_osx"
7+
require "arduino_ci/arduino_downloader_linux"
8+
9+
require "arduino_ci/arduino_downloader_windows" if ArduinoCI::Host.os == :windows
710

811
DESIRED_ARDUINO_IDE_VERSION = "1.8.5".freeze
912

@@ -28,11 +31,11 @@ def autolocate
2831
return nil if loc.nil?
2932
ret = ArduinoCmdLinux.new
3033
ret.base_cmd = [loc]
31-
# when :windows then
32-
# ArduinoDownloaderWindows.autolocation
33-
# return nil if loc.nil?
34-
# ret = ArduinoCmdWindows.new
35-
# ret.base_cmd = [loc]
34+
when :windows then
35+
ArduinoDownloaderWindows.autolocation
36+
return nil if loc.nil?
37+
ret = ArduinoCmdWindows.new
38+
ret.base_cmd = [loc]
3639
end
3740
ret
3841
end

0 commit comments

Comments
 (0)