Skip to content

Commit cd6edd9

Browse files
committed
Fix windows tests
1 parent 407b161 commit cd6edd9

File tree

4 files changed

+52
-14
lines changed

4 files changed

+52
-14
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@ jobs:
3535
if: runner.os == 'Linux'
3636
run: sudo apt-get update && sudo apt-get install -y build-essential
3737

38-
- name: Install build dependencies
39-
if: runner.os == 'Windows'
38+
- name: Install dependencies and compile extension
4039
run: |
41-
choco install mingw
42-
refreshenv
43-
44-
- name: Build native extension for testing
45-
run: bundle install
40+
bundle install
41+
# Compile C extension using rake (standard for C extension gems)
42+
bundle exec rake compile
4643
4744
- name: Run tests with coverage
4845
run: bundle exec rspec

Rakefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,40 @@ require "rspec/core/rake_task"
33

44
RSpec::Core::RakeTask.new(:spec)
55

6+
# Compile the C extension
7+
desc "Compile the native extension"
8+
task :compile do
9+
Dir.chdir('ext/thaw') do
10+
sh 'ruby extconf.rb'
11+
sh 'make'
12+
13+
# Copy compiled extension to lib directory for development
14+
extension_files = Dir['thaw_native.{bundle,so,dll}']
15+
if extension_files.empty?
16+
puts "Warning: No compiled extension found"
17+
else
18+
extension_file = extension_files.first
19+
target_dir = '../../lib/thaw'
20+
FileUtils.mkdir_p(target_dir)
21+
FileUtils.cp(extension_file, target_dir)
22+
puts "Copied #{extension_file} to #{target_dir}/"
23+
end
24+
end
25+
end
26+
27+
# Clean compiled files
28+
desc "Clean compiled extension files"
29+
task :clean do
30+
Dir.chdir('ext/thaw') do
31+
sh 'make clean' if File.exist?('Makefile')
32+
FileUtils.rm_f(Dir['thaw_native.{bundle,so,dll,o}'])
33+
FileUtils.rm_f('Makefile')
34+
end
35+
# Clean lib directory too
36+
FileUtils.rm_f(Dir['lib/thaw/thaw_native.{bundle,so,dll}'])
37+
end
38+
39+
# Make tests depend on compilation
40+
task :spec => :compile
41+
642
task :default => :spec

ext/thaw/extconf.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,25 @@
2424
when /darwin/
2525
# macOS specific
2626
$CFLAGS += " -D__APPLE__"
27+
# GCC/Clang flags for macOS
28+
$CFLAGS += " -Wno-error -Wno-deprecated-declarations -Wno-strict-prototypes -Wno-compound-token-split-by-macro -w"
2729
when /linux/
2830
# Linux specific
2931
$CFLAGS += " -D__LINUX__"
32+
# GCC flags for Linux
33+
$CFLAGS += " -Wno-error -Wno-deprecated-declarations -Wno-strict-prototypes -w"
3034
when /mingw|mswin/
3135
# Windows specific
3236
$CFLAGS += " -D__WINDOWS__"
37+
# MinGW/MSYS2 flags for Windows (setup-ruby uses MinGW)
38+
if RUBY_PLATFORM =~ /mingw/
39+
$CFLAGS += " -Wno-error -Wno-deprecated-declarations -Wno-strict-prototypes -w"
40+
else
41+
# MSVC flags (if using Visual Studio)
42+
$CFLAGS += " /W0" # Suppress all warnings for MSVC
43+
end
3344
end
3445

35-
# Cross-platform compiler flags - suppress warnings
36-
$CFLAGS += " -Wno-error"
37-
$CFLAGS += " -Wno-deprecated-declarations"
38-
$CFLAGS += " -Wno-strict-prototypes"
39-
$CFLAGS += " -Wno-compound-token-split-by-macro"
40-
$CFLAGS += " -w" # Suppress all warnings
41-
4246
# Force correct 64-bit sizes for platforms where needed
4347
if RUBY_PLATFORM =~ /darwin/
4448
$CFLAGS += " -DSIZEOF_LONG=8"

thaw.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
2222

2323
spec.add_development_dependency 'bundler', '>= 2.0'
2424
spec.add_development_dependency 'rake', '~> 13.0'
25+
spec.add_development_dependency 'rake-compiler', '~> 1.0'
2526
spec.add_development_dependency 'rspec', '~> 3.10'
2627
spec.add_development_dependency 'simplecov_json_formatter', '~> 0.1'
2728

0 commit comments

Comments
 (0)