Skip to content

Commit ea22ebf

Browse files
Merge pull request #686 from sschuberth/misc
On the way to fix / improve the Windows build
2 parents 70d6e6e + 81b1292 commit ea22ebf

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

ext/rugged/extconf.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ def sys(cmd)
2020
ret
2121
end
2222

23-
def windows?
24-
RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
23+
MAKE = if Gem.win_platform?
24+
# On Windows, Ruby-DevKit only has 'make'.
25+
find_executable('make')
26+
else
27+
find_executable('gmake') || find_executable('make')
2528
end
2629

27-
if !(MAKE = find_executable('gmake') || find_executable('make'))
30+
if !MAKE
2831
abort "ERROR: GNU make is required to build Rugged."
2932
end
3033

@@ -64,7 +67,7 @@ def windows?
6467
abort "ERROR: CMake is required to build Rugged."
6568
end
6669

67-
if !windows? && !find_executable('pkg-config')
70+
if !Gem.win_platform? && !find_executable('pkg-config')
6871
abort "ERROR: pkg-config is required to build Rugged."
6972
end
7073

@@ -73,14 +76,14 @@ def windows?
7376

7477
Dir.chdir("build") do
7578
# On Windows, Ruby-DevKit is MSYS-based, so ensure to use MSYS Makefiles.
76-
generator = "-G \"MSYS Makefiles\"" if windows?
79+
generator = "-G \"MSYS Makefiles\"" if Gem.win_platform?
7780
sys("cmake .. -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo #{generator}")
7881
sys(MAKE)
7982

8083
# "normal" libraries (and libgit2 builds) get all these when they build but we're doing it
8184
# statically so we put the libraries in by hand. It's important that we put the libraries themselves
8285
# in $LIBS or the final linking stage won't pick them up
83-
if windows?
86+
if Gem.win_platform?
8487
$LDFLAGS << " " + "-L#{Dir.pwd}/deps/winhttp"
8588
$LIBS << " -lwinhttp -lcrypt32 -lrpcrt4 -lole32 -lz"
8689
else

0 commit comments

Comments
 (0)