Skip to content
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

Add support for windows #11

Merged
merged 5 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
path: build/cache
key: ${{ runner.os }}-ccache
- name: build
run: rake build:all release
run: rake build:all

- name: Upload test binary (linux-amd64)
uses: actions/upload-artifact@v3
Expand All @@ -46,6 +46,11 @@ jobs:
with:
name: rf-${{ github.sha }}-darwin-arm64
path: build/darwin-arm64/bin/rf
- name: Upload test binary (windows-amd64)
uses: actions/upload-artifact@v3
with:
name: rf-${{ github.sha }}-windows-amd64
path: build/windows-amd64/bin/rf.exe

test-on-linux:
needs: build
Expand Down Expand Up @@ -86,3 +91,21 @@ jobs:
run: |
chmod +x build/bin/rf
rake spec

test-on-windows:
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: rf-${{ github.sha }}-windows-amd64
path: build/bin
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- name: Install dependencies
run: bundle install
- name: Run test
run: rake spec
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source 'https://rubygems.org/'
gem 'rake'

group 'test' do
gem 'aruba', '~> 2.1.0'
gem 'aruba', github: 'cucumber/aruba', branch: 'main'
gem 'parallel_tests'
gem 'rspec'
gem 'rspec-parameterized', '>= 1.0.0'
Expand Down
14 changes: 9 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
GEM
remote: https://rubygems.org/
GIT
remote: https://github.com/cucumber/aruba.git
revision: 4994d939852d60d939e2f641bb33a282bb4005af
branch: main
specs:
aruba (2.1.0)
bundler (>= 1.17, < 3.0)
childprocess (>= 2.0, < 5.0)
contracts (>= 0.16.0, < 0.18.0)
cucumber (>= 4.0, < 9.0)
rspec-expectations (~> 3.4)
thor (~> 1.0)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
builder (3.2.4)
childprocess (4.1.0)
coderay (1.1.3)
contracts (0.17)
cucumber (8.0.0)
Expand Down Expand Up @@ -117,7 +121,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
aruba (~> 2.1.0)
aruba!
parallel_tests
rake
rspec
Expand Down
6 changes: 4 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ def build_targets
%w[
linux-amd64 linux-arm64
darwin-amd64 darwin-arm64
windows-amd64
]
end

def archive_binary_file(targets, version)
FileUtils.mkdir_p 'release'
targets.each do |target|
src = File.expand_path("build/#{target}/bin/rf")
dest = File.expand_path("release/rf-#{version}-#{target}")
ext = '.exe' if target =~ /windows/
src = File.expand_path("build/#{target}/bin/rf#{ext}")
dest = File.expand_path("release/rf-#{version}-#{target}#{ext}")

if target =~ /linux/
sh "tar -cf #{dest}.tar.gz -C #{File.dirname(src)} #{File.basename(src)}"
Expand Down
33 changes: 28 additions & 5 deletions build_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ def debug_config(conf)
conf.enable_debug
end

def cc_command
command = %w[zig cc]
command.unshift 'ccache' if ENV['USE_CCACHE']
command.join(' ')
def ccache
'ccache ' if ENV['USE_CCACHE']
end

def build_config(conf, target = nil, strip: false)
[conf.cc, conf.linker].each do |cc|
cc.command = cc_command
cc.command = "#{ccache}zig cc"
cc.flags += ['-target', target] if target
end
conf.cc.flags << '-s' if strip
Expand Down Expand Up @@ -88,3 +86,28 @@ def build_config(conf, target = nil, strip: false)
gem_config(conf)
end
end

if build_targets.include?('windows-amd64')
MRuby::CrossBuild.new('windows-amd64') do |conf|
toolchain :gcc

conf.build_target = 'x86_64-pc-linux-gnu'
conf.host_target = 'x86_64-w64-mingw32'

[conf.cc, conf.linker].each do |cc|
cc.command = "#{ccache}#{conf.host_target}-gcc-posix"
cc.flags << '-static'
end
conf.cxx.command = "#{ccache}#{conf.host_target}-g++"
conf.archiver.command = "#{ccache}#{conf.host_target}-gcc-ar"

conf.exts do |exts|
exts.object = '.obj'
exts.executable = '.exe'
exts.library = '.lib'
end

debug_config(conf)
gem_config(conf)
end
end
160 changes: 160 additions & 0 deletions build_config.rb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,163 @@ builds:
branch: master
commit: 34a477d249b0d21671058be33aa75d04c3e981ba
version: 0.0.0
https://github.com/buty4649/mruby-onig-regexp.git:
url: https://github.com/buty4649/mruby-onig-regexp.git
branch: master
commit: ce9bc7a8b4ff11a438c36826ed2c685237c96b05
version: 0.0.0
linux-amd64:
https://github.com/mattn/mruby-json.git:
url: https://github.com/mattn/mruby-json.git
branch: master
commit: f99d9428025469f2400f93c53b185f65f963e507
version: 0.0.0
https://github.com/fastly/mruby-optparse.git:
url: https://github.com/fastly/mruby-optparse.git
branch: master
commit: e6397a090d1efe04d5dab57c63897f0d79bbad89
version: 0.0.0
https://github.com/mrbgems/mruby-yaml.git:
url: https://github.com/mrbgems/mruby-yaml.git
branch: master
commit: 123010195bf621e784ee9d4ff9144a4b8e9cbb6a
version: 0.1.0
https://github.com/buty4649/mruby-onig-regexp.git:
url: https://github.com/buty4649/mruby-onig-regexp.git
branch: fix-build-error-with-mingw
commit: ce9bc7a8b4ff11a438c36826ed2c685237c96b05
version: 0.0.0
https://github.com/IceDragon200/mruby-catch-throw:
url: https://github.com/IceDragon200/mruby-catch-throw
branch: master
commit: 2b6eaff4232b4a9473b864df53c2917080af5dcf
version: 1.1.0
https://github.com/iij/mruby-env.git:
url: https://github.com/iij/mruby-env.git
branch: master
commit: 056ae324451ef16a50c7887e117f0ea30921b71b
version: 0.0.0
linux-arm64:
https://github.com/mattn/mruby-json.git:
url: https://github.com/mattn/mruby-json.git
branch: master
commit: f99d9428025469f2400f93c53b185f65f963e507
version: 0.0.0
https://github.com/fastly/mruby-optparse.git:
url: https://github.com/fastly/mruby-optparse.git
branch: master
commit: e6397a090d1efe04d5dab57c63897f0d79bbad89
version: 0.0.0
https://github.com/mrbgems/mruby-yaml.git:
url: https://github.com/mrbgems/mruby-yaml.git
branch: master
commit: 123010195bf621e784ee9d4ff9144a4b8e9cbb6a
version: 0.1.0
https://github.com/buty4649/mruby-onig-regexp.git:
url: https://github.com/buty4649/mruby-onig-regexp.git
branch: fix-build-error-with-mingw
commit: ce9bc7a8b4ff11a438c36826ed2c685237c96b05
version: 0.0.0
https://github.com/IceDragon200/mruby-catch-throw:
url: https://github.com/IceDragon200/mruby-catch-throw
branch: master
commit: 2b6eaff4232b4a9473b864df53c2917080af5dcf
version: 1.1.0
https://github.com/iij/mruby-env.git:
url: https://github.com/iij/mruby-env.git
branch: master
commit: 056ae324451ef16a50c7887e117f0ea30921b71b
version: 0.0.0
darwin-amd64:
https://github.com/mattn/mruby-json.git:
url: https://github.com/mattn/mruby-json.git
branch: master
commit: f99d9428025469f2400f93c53b185f65f963e507
version: 0.0.0
https://github.com/fastly/mruby-optparse.git:
url: https://github.com/fastly/mruby-optparse.git
branch: master
commit: e6397a090d1efe04d5dab57c63897f0d79bbad89
version: 0.0.0
https://github.com/mrbgems/mruby-yaml.git:
url: https://github.com/mrbgems/mruby-yaml.git
branch: master
commit: 123010195bf621e784ee9d4ff9144a4b8e9cbb6a
version: 0.1.0
https://github.com/buty4649/mruby-onig-regexp.git:
url: https://github.com/buty4649/mruby-onig-regexp.git
branch: fix-build-error-with-mingw
commit: ce9bc7a8b4ff11a438c36826ed2c685237c96b05
version: 0.0.0
https://github.com/IceDragon200/mruby-catch-throw:
url: https://github.com/IceDragon200/mruby-catch-throw
branch: master
commit: 2b6eaff4232b4a9473b864df53c2917080af5dcf
version: 1.1.0
https://github.com/iij/mruby-env.git:
url: https://github.com/iij/mruby-env.git
branch: master
commit: 056ae324451ef16a50c7887e117f0ea30921b71b
version: 0.0.0
darwin-arm64:
https://github.com/mattn/mruby-json.git:
url: https://github.com/mattn/mruby-json.git
branch: master
commit: f99d9428025469f2400f93c53b185f65f963e507
version: 0.0.0
https://github.com/fastly/mruby-optparse.git:
url: https://github.com/fastly/mruby-optparse.git
branch: master
commit: e6397a090d1efe04d5dab57c63897f0d79bbad89
version: 0.0.0
https://github.com/mrbgems/mruby-yaml.git:
url: https://github.com/mrbgems/mruby-yaml.git
branch: master
commit: 123010195bf621e784ee9d4ff9144a4b8e9cbb6a
version: 0.1.0
https://github.com/buty4649/mruby-onig-regexp.git:
url: https://github.com/buty4649/mruby-onig-regexp.git
branch: fix-build-error-with-mingw
commit: ce9bc7a8b4ff11a438c36826ed2c685237c96b05
version: 0.0.0
https://github.com/IceDragon200/mruby-catch-throw:
url: https://github.com/IceDragon200/mruby-catch-throw
branch: master
commit: 2b6eaff4232b4a9473b864df53c2917080af5dcf
version: 1.1.0
https://github.com/iij/mruby-env.git:
url: https://github.com/iij/mruby-env.git
branch: master
commit: 056ae324451ef16a50c7887e117f0ea30921b71b
version: 0.0.0
windows-amd64:
https://github.com/mattn/mruby-json.git:
url: https://github.com/mattn/mruby-json.git
branch: master
commit: f99d9428025469f2400f93c53b185f65f963e507
version: 0.0.0
https://github.com/fastly/mruby-optparse.git:
url: https://github.com/fastly/mruby-optparse.git
branch: master
commit: e6397a090d1efe04d5dab57c63897f0d79bbad89
version: 0.0.0
https://github.com/mrbgems/mruby-yaml.git:
url: https://github.com/mrbgems/mruby-yaml.git
branch: master
commit: 123010195bf621e784ee9d4ff9144a4b8e9cbb6a
version: 0.1.0
https://github.com/buty4649/mruby-onig-regexp.git:
url: https://github.com/buty4649/mruby-onig-regexp.git
branch: fix-build-error-with-mingw
commit: ce9bc7a8b4ff11a438c36826ed2c685237c96b05
version: 0.0.0
https://github.com/IceDragon200/mruby-catch-throw:
url: https://github.com/IceDragon200/mruby-catch-throw
branch: master
commit: 2b6eaff4232b4a9473b864df53c2917080af5dcf
version: 1.1.0
https://github.com/iij/mruby-env.git:
url: https://github.com/iij/mruby-env.git
branch: master
commit: 056ae324451ef16a50c7887e117f0ea30921b71b
version: 0.0.0
2 changes: 1 addition & 1 deletion mrbgem.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ MRuby::Gem::Specification.new('rf') do |spec|

%w[
mruby-json
mruby-onig-regexp
mruby-optparse
mruby-yaml
].each do |mgem|
spec.add_dependency mgem, mgem:
end
spec.add_dependency 'mruby-onig-regexp', github: 'buty4649/mruby-onig-regexp', branch: 'fix-build-error-with-mingw'
end
9 changes: 8 additions & 1 deletion spec/support/aruba.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
config.working_directory = working_directory
end

def run_rf(args, input = nil)
def rf_path
rf_path = File.expand_path('../../build/bin/rf', __dir__)
return rf_path if File.exist?(rf_path)

"#{rf_path}.exe"
end

def run_rf(args, input = nil)
@rf_path ||= rf_path
command = run_command("#{rf_path} #{args}")

if input
Expand Down