Skip to content

Commit 9c82357

Browse files
committed
Clean up
1 parent 56b75ab commit 9c82357

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

ext/or-tools/extconf.rb

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,18 @@
1313
lib_dirs = lib.split(':')
1414
rpath = lib_dirs.join(':')
1515

16-
$INCFLAGS << " -I#{inc}"
17-
18-
lib_dirs.each do |lib_dir|
19-
$LDFLAGS.prepend("-L#{lib_dir} ")
20-
end
21-
22-
# Add rpath for all lib directories
23-
$LDFLAGS.prepend("-Wl,-rpath,#{rpath} ")
16+
# Find the first lib directory containing libprotobuf.a
17+
libprotobuf_dir = lib_dirs.find { |dir| File.exist?("#{dir}/libprotobuf.a") }
18+
raise "libprotobuf.a not found" unless libprotobuf_dir
2419

25-
# Check for libprotobuf.a in any of the lib directories
26-
libprotobuf_found = lib_dirs.any? { |dir| File.exist?("#{dir}/libprotobuf.a") }
27-
raise "libprotobuf.a not found" unless libprotobuf_found
20+
raise "OR-Tools not found" unless have_library("ortools")
2821

29-
# Add libprotobuf.a to LDFLAGS
30-
$LDFLAGS << " #{lib_dirs.find { |dir| File.exist?("#{dir}/libprotobuf.a") }}/libprotobuf.a"
22+
# -L flags for each lib directory
23+
lib_dirs_flags = lib_dirs.map { |lib_dir| "-L#{lib_dir} " }.join
3124

32-
raise "OR-Tools not found" unless have_library("ortools")
25+
$INCFLAGS << " -I#{inc}"
26+
ld_flags = "-Wl,-rpath,#{rpath} #{lib_dirs_flags} #{libprotobuf_dir}/libprotobuf.a "
27+
$LDFLAGS.prepend(ld_flags)
3328
else
3429
# download
3530
require_relative "vendor"

0 commit comments

Comments
 (0)