Skip to content

Commit e9f4cbe

Browse files
Merge pull request #554 from libgit2/cmn/winfix
Build on Windows with WinHTTP
2 parents 97d1699 + dd9d236 commit e9f4cbe

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

ext/rugged/extconf.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def sys(cmd)
1515
ret
1616
end
1717

18+
def windows?
19+
RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
20+
end
21+
1822
if !(MAKE = find_executable('gmake') || find_executable('make'))
1923
abort "ERROR: GNU make is required to build Rugged."
2024
end
@@ -55,7 +59,7 @@ def sys(cmd)
5559
abort "ERROR: CMake is required to build Rugged."
5660
end
5761

58-
if !find_executable('pkg-config')
62+
if !windows? && !find_executable('pkg-config')
5963
abort "ERROR: pkg-config is required to build Rugged."
6064
end
6165

@@ -66,8 +70,16 @@ def sys(cmd)
6670
sys("cmake .. -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo -G \"Unix Makefiles\"")
6771
sys(MAKE)
6872

69-
pcfile = File.join(LIBGIT2_DIR, "build", "libgit2.pc")
70-
$LDFLAGS << " " + `pkg-config --libs --static #{pcfile}`.strip
73+
# "normal" libraries (and libgit2 builds) get all these when they build but we're doing it
74+
# statically so we put the libraries in by hand. It's important that we put the libraries themselves
75+
# in $LIBS or the final linking stage won't pick them up
76+
if windows?
77+
$LDFLAGS << " " + "-L#{Dir.pwd}/deps/winhttp"
78+
$LIBS << " -lwinhttp -lcrypt32 -lrpcrt4 -lole32"
79+
else
80+
pcfile = File.join(LIBGIT2_DIR, "build", "libgit2.pc")
81+
$LDFLAGS << " " + `pkg-config --libs --static #{pcfile}`.strip
82+
end
7183
end
7284
end
7385

0 commit comments

Comments
 (0)