mini_portile2 2.8.4 → 2.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +98 -6
- data/.github/workflows/downstream.yml +66 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +40 -0
- data/README.md +29 -7
- data/Rakefile +3 -5
- data/lib/mini_portile2/mini_portile.rb +207 -63
- data/lib/mini_portile2/mini_portile_cmake.rb +12 -31
- data/lib/mini_portile2/version.rb +1 -1
- data/mini_portile2.gemspec +7 -6
- data/test/assets/pkgconf/libxml2/libxml-2.0.pc +13 -0
- data/test/assets/pkgconf/libxslt/libexslt.pc +13 -0
- data/test/assets/pkgconf/libxslt/libxslt.pc +13 -0
- data/test/helper.rb +12 -1
- data/test/test_activate.rb +139 -0
- data/test/test_cmake.rb +65 -46
- data/test/test_cook.rb +30 -1
- data/test/test_digest.rb +75 -77
- data/test/test_download.rb +5 -4
- data/test/test_execute.rb +4 -3
- data/test/test_mkmf_config.rb +202 -0
- data/test/test_proxy.rb +7 -6
- data/test/test_recipe.rb +18 -0
- metadata +24 -10
@@ -8,6 +8,7 @@ require 'open-uri'
|
|
8
8
|
require 'cgi'
|
9
9
|
require 'rbconfig'
|
10
10
|
require 'shellwords'
|
11
|
+
require 'open3'
|
11
12
|
|
12
13
|
# Monkey patch for Net::HTTP by ruby open-uri fix:
|
13
14
|
# https://github.com/ruby/ruby/commit/58835a9
|
@@ -27,12 +28,14 @@ class Net::HTTP
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
31
|
+
$MINI_PORTILE_STATIC_LIBS = {}
|
32
|
+
|
30
33
|
class MiniPortile
|
31
34
|
DEFAULT_TIMEOUT = 10
|
32
35
|
|
33
|
-
attr_reader :name, :version, :original_host
|
36
|
+
attr_reader :name, :version, :original_host, :source_directory
|
34
37
|
attr_writer :configure_options
|
35
|
-
attr_accessor :host, :files, :patch_files, :target, :logger
|
38
|
+
attr_accessor :host, :files, :patch_files, :target, :logger
|
36
39
|
|
37
40
|
def self.windows?
|
38
41
|
target_os =~ /mswin|mingw/
|
@@ -76,6 +79,24 @@ class MiniPortile
|
|
76
79
|
RbConfig::CONFIG['target_cpu']
|
77
80
|
end
|
78
81
|
|
82
|
+
def self.native_path(path)
|
83
|
+
path = File.expand_path(path)
|
84
|
+
if File::ALT_SEPARATOR
|
85
|
+
path.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
86
|
+
else
|
87
|
+
path
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.posix_path(path)
|
92
|
+
path = File.expand_path(path)
|
93
|
+
if File::ALT_SEPARATOR
|
94
|
+
"/" + path.tr(File::ALT_SEPARATOR, File::SEPARATOR).tr(":", File::SEPARATOR)
|
95
|
+
else
|
96
|
+
path
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
79
100
|
def initialize(name, version, **kwargs)
|
80
101
|
@name = name
|
81
102
|
@version = version
|
@@ -83,15 +104,16 @@ class MiniPortile
|
|
83
104
|
@files = []
|
84
105
|
@patch_files = []
|
85
106
|
@log_files = {}
|
86
|
-
@logger = STDOUT
|
107
|
+
@logger = kwargs[:logger] || STDOUT
|
87
108
|
@source_directory = nil
|
88
109
|
|
89
|
-
@
|
90
|
-
|
91
|
-
@gcc_command = kwargs[:gcc_command]
|
110
|
+
@cc_command = kwargs[:cc_command] || kwargs[:gcc_command]
|
111
|
+
@cxx_command = kwargs[:cxx_command]
|
92
112
|
@make_command = kwargs[:make_command]
|
93
113
|
@open_timeout = kwargs[:open_timeout] || DEFAULT_TIMEOUT
|
94
114
|
@read_timeout = kwargs[:read_timeout] || DEFAULT_TIMEOUT
|
115
|
+
|
116
|
+
@original_host = @host = detect_host
|
95
117
|
end
|
96
118
|
|
97
119
|
def source_directory=(path)
|
@@ -219,11 +241,10 @@ class MiniPortile
|
|
219
241
|
end
|
220
242
|
|
221
243
|
def activate
|
222
|
-
lib_path = File.join(port_path, "lib")
|
223
244
|
vars = {
|
224
245
|
'PATH' => File.join(port_path, 'bin'),
|
225
|
-
'CPATH' =>
|
226
|
-
'LIBRARY_PATH' => lib_path
|
246
|
+
'CPATH' => include_path,
|
247
|
+
'LIBRARY_PATH' => lib_path,
|
227
248
|
}.reject { |env, path| !File.directory?(path) }
|
228
249
|
|
229
250
|
output "Activating #{@name} #{@version} (from #{port_path})..."
|
@@ -240,7 +261,7 @@ class MiniPortile
|
|
240
261
|
|
241
262
|
# rely on LDFLAGS when cross-compiling
|
242
263
|
if File.exist?(lib_path) && (@host != @original_host)
|
243
|
-
full_path =
|
264
|
+
full_path = native_path(lib_path)
|
244
265
|
|
245
266
|
old_value = ENV.fetch("LDFLAGS", "")
|
246
267
|
|
@@ -250,12 +271,114 @@ class MiniPortile
|
|
250
271
|
end
|
251
272
|
end
|
252
273
|
|
274
|
+
# pkg: the pkg-config file name (without the .pc extension)
|
275
|
+
# dir: inject the directory path for the pkg-config file (probably only useful for tests)
|
276
|
+
# static: the name of the static library archive (without the "lib" prefix or the file extension), or nil for dynamic linking
|
277
|
+
#
|
278
|
+
# we might be able to be terribly clever and infer the name of the static archive file, but
|
279
|
+
# unfortunately projects have so much freedom in what they can report (for name, for libs, etc.)
|
280
|
+
# that it feels unreliable to try to do so, so I'm preferring to just have the developer make it
|
281
|
+
# explicit.
|
282
|
+
def mkmf_config(pkg: nil, dir: nil, static: nil)
|
283
|
+
require "mkmf"
|
284
|
+
|
285
|
+
if pkg
|
286
|
+
dir ||= File.join(lib_path, "pkgconfig")
|
287
|
+
pcfile = File.join(dir, "#{pkg}.pc")
|
288
|
+
unless File.exist?(pcfile)
|
289
|
+
raise ArgumentError, "pkg-config file '#{pcfile}' does not exist"
|
290
|
+
end
|
291
|
+
|
292
|
+
output "Configuring MakeMakefile for #{File.basename(pcfile)} (in #{File.dirname(pcfile)})\n"
|
293
|
+
|
294
|
+
# on macos, pkg-config will not return --cflags without this
|
295
|
+
ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t"
|
296
|
+
|
297
|
+
# append to PKG_CONFIG_PATH as we go, so later pkg-config files can depend on earlier ones
|
298
|
+
ENV["PKG_CONFIG_PATH"] = [ENV["PKG_CONFIG_PATH"], dir].compact.join(File::PATH_SEPARATOR)
|
299
|
+
|
300
|
+
incflags = minimal_pkg_config(pcfile, "cflags-only-I")
|
301
|
+
cflags = minimal_pkg_config(pcfile, "cflags-only-other")
|
302
|
+
if static
|
303
|
+
ldflags = minimal_pkg_config(pcfile, "libs-only-L", "static")
|
304
|
+
libflags = minimal_pkg_config(pcfile, "libs-only-l", "static")
|
305
|
+
else
|
306
|
+
ldflags = minimal_pkg_config(pcfile, "libs-only-L")
|
307
|
+
libflags = minimal_pkg_config(pcfile, "libs-only-l")
|
308
|
+
end
|
309
|
+
else
|
310
|
+
output "Configuring MakeMakefile for #{@name} #{@version} (from #{path})\n"
|
311
|
+
|
312
|
+
lib_name = name.sub(/\Alib/, "") # TODO: use delete_prefix when we no longer support ruby 2.4
|
313
|
+
|
314
|
+
incflags = Dir.exist?(include_path) ? "-I#{include_path}" : ""
|
315
|
+
cflags = ""
|
316
|
+
ldflags = Dir.exist?(lib_path) ? "-L#{lib_path}" : ""
|
317
|
+
libflags = Dir.exist?(lib_path) ? "-l#{lib_name}" : ""
|
318
|
+
end
|
319
|
+
|
320
|
+
if static
|
321
|
+
libdir = lib_path
|
322
|
+
if pcfile
|
323
|
+
pcfile_libdir = minimal_pkg_config(pcfile, "variable=libdir").strip
|
324
|
+
libdir = pcfile_libdir unless pcfile_libdir.empty?
|
325
|
+
end
|
326
|
+
|
327
|
+
#
|
328
|
+
# keep track of the libraries we're statically linking against, and fix up ldflags and
|
329
|
+
# libflags to make sure we link statically against the recipe's libaries.
|
330
|
+
#
|
331
|
+
# this avoids the unintentionally dynamically linking against system libraries, and makes sure
|
332
|
+
# that if multiple pkg-config files reference each other that we are able to intercept flags
|
333
|
+
# from dependent packages that reference the static archive.
|
334
|
+
#
|
335
|
+
$MINI_PORTILE_STATIC_LIBS[static] = libdir
|
336
|
+
static_ldflags = $MINI_PORTILE_STATIC_LIBS.values.map { |v| "-L#{v}" }
|
337
|
+
static_libflags = $MINI_PORTILE_STATIC_LIBS.keys.map { |v| "-l#{v}" }
|
338
|
+
|
339
|
+
# remove `-L#{libdir}` and `-lfoo`. we don't need them since we link against the static
|
340
|
+
# archive using the full path.
|
341
|
+
ldflags = ldflags.shellsplit.reject { |f| static_ldflags.include?(f) }.shelljoin
|
342
|
+
libflags = libflags.shellsplit.reject { |f| static_libflags.include?(f) }.shelljoin
|
343
|
+
|
344
|
+
# prepend the full path to the static archive to the linker flags
|
345
|
+
static_archive = File.join(libdir, "lib#{static}.#{$LIBEXT}")
|
346
|
+
libflags = [static_archive, libflags].join(" ").strip
|
347
|
+
end
|
348
|
+
|
349
|
+
# prefer this package by prepending to search paths and library flags
|
350
|
+
#
|
351
|
+
# convert the ldflags into a list of directories and append to $LIBPATH (instead of just using
|
352
|
+
# $LDFLAGS) to ensure we get the `-Wl,-rpath` linker flag for re-finding shared libraries.
|
353
|
+
$INCFLAGS = [incflags, $INCFLAGS].join(" ").strip
|
354
|
+
libpaths = ldflags.shellsplit.map { |f| f.sub(/\A-L/, "") }
|
355
|
+
$LIBPATH = libpaths | $LIBPATH
|
356
|
+
$libs = [libflags, $libs].join(" ").strip
|
357
|
+
|
358
|
+
# prefer this package's compiler flags by appending them to the command line
|
359
|
+
$CFLAGS = [$CFLAGS, cflags].join(" ").strip
|
360
|
+
$CXXFLAGS = [$CXXFLAGS, cflags].join(" ").strip
|
361
|
+
end
|
362
|
+
|
253
363
|
def path
|
254
364
|
File.expand_path(port_path)
|
255
365
|
end
|
256
366
|
|
257
|
-
def
|
258
|
-
(
|
367
|
+
def include_path
|
368
|
+
File.join(path, "include")
|
369
|
+
end
|
370
|
+
|
371
|
+
def lib_path
|
372
|
+
File.join(path, "lib")
|
373
|
+
end
|
374
|
+
|
375
|
+
def cc_cmd
|
376
|
+
(ENV["CC"] || @cc_command || RbConfig::CONFIG["CC"] || "gcc").dup
|
377
|
+
end
|
378
|
+
alias :gcc_cmd :cc_cmd
|
379
|
+
|
380
|
+
def cxx_cmd
|
381
|
+
(ENV["CXX"] || @cxx_command || RbConfig::CONFIG["CXX"] || "g++").dup
|
259
382
|
end
|
260
383
|
|
261
384
|
def make_cmd
|
@@ -265,21 +388,11 @@ class MiniPortile
|
|
265
388
|
private
|
266
389
|
|
267
390
|
def native_path(path)
|
268
|
-
|
269
|
-
if File::ALT_SEPARATOR
|
270
|
-
path.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
271
|
-
else
|
272
|
-
path
|
273
|
-
end
|
391
|
+
MiniPortile.native_path(path)
|
274
392
|
end
|
275
393
|
|
276
394
|
def posix_path(path)
|
277
|
-
|
278
|
-
if File::ALT_SEPARATOR
|
279
|
-
"/" + path.tr(File::ALT_SEPARATOR, File::SEPARATOR).tr(":", File::SEPARATOR)
|
280
|
-
else
|
281
|
-
path
|
282
|
-
end
|
395
|
+
MiniPortile.posix_path(path)
|
283
396
|
end
|
284
397
|
|
285
398
|
def tmp_path
|
@@ -349,24 +462,29 @@ class MiniPortile
|
|
349
462
|
gpg_exe = which('gpg2') || which('gpg') || raise("Neither GPG nor GPG2 is installed")
|
350
463
|
|
351
464
|
# import the key into our own keyring
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
465
|
+
gpg_error = nil
|
466
|
+
gpg_status = Open3.popen3(gpg_exe, "--status-fd", "1", "--no-default-keyring", "--keyring", KEYRING_NAME, "--import") do |gpg_in, gpg_out, gpg_err, _thread|
|
467
|
+
gpg_in.write gpg[:key]
|
468
|
+
gpg_in.close
|
469
|
+
gpg_error = gpg_err.read
|
470
|
+
gpg_out.read
|
356
471
|
end
|
357
472
|
key_ids = gpg_status.scan(/\[GNUPG:\] IMPORT_OK \d+ (?<key_id>[0-9a-f]+)/i).map(&:first)
|
358
|
-
raise "invalid gpg key provided" if key_ids.empty?
|
359
|
-
|
360
|
-
# verify the signature against our keyring
|
361
|
-
gpg_status = IO.popen([gpg_exe, "--status-fd", "1", "--no-default-keyring", "--keyring", KEYRING_NAME, "--verify", signature_file, file[:local_path]], &:read)
|
473
|
+
raise "invalid gpg key provided:\n#{gpg_error}" if key_ids.empty?
|
362
474
|
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
475
|
+
begin
|
476
|
+
# verify the signature against our keyring
|
477
|
+
gpg_status, gpg_error, _status = Open3.capture3(gpg_exe, "--status-fd", "1", "--no-default-keyring", "--keyring", KEYRING_NAME, "--verify", signature_file, file[:local_path])
|
478
|
+
|
479
|
+
raise "signature mismatch:\n#{gpg_error}" unless gpg_status.match(/^\[GNUPG:\] VALIDSIG/)
|
480
|
+
ensure
|
481
|
+
# remove the key from our keyring
|
482
|
+
key_ids.each do |key_id|
|
483
|
+
IO.popen([gpg_exe, "--batch", "--yes", "--no-default-keyring", "--keyring", KEYRING_NAME, "--delete-keys", key_id], &:read)
|
484
|
+
raise "unable to delete the imported key" unless $?.exitstatus==0
|
485
|
+
end
|
367
486
|
end
|
368
487
|
|
369
|
-
raise "signature mismatch" unless gpg_status.match(/^\[GNUPG:\] VALIDSIG/)
|
370
488
|
|
371
489
|
else
|
372
490
|
digest = case
|
@@ -390,30 +508,6 @@ class MiniPortile
|
|
390
508
|
}
|
391
509
|
end
|
392
510
|
|
393
|
-
TAR_EXECUTABLES = %w[gtar bsdtar tar basic-bsdtar]
|
394
|
-
def tar_exe
|
395
|
-
@@tar_exe ||= begin
|
396
|
-
TAR_EXECUTABLES.find { |c|
|
397
|
-
which(c)
|
398
|
-
} or raise("tar not found - please make sure that one of the following commands is in the PATH: #{TAR_EXECUTABLES.join(", ")}")
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
def tar_compression_switch(filename)
|
403
|
-
case File.extname(filename)
|
404
|
-
when '.gz', '.tgz'
|
405
|
-
'z'
|
406
|
-
when '.bz2', '.tbz2'
|
407
|
-
'j'
|
408
|
-
when '.xz'
|
409
|
-
'J'
|
410
|
-
when '.Z'
|
411
|
-
'Z'
|
412
|
-
else
|
413
|
-
''
|
414
|
-
end
|
415
|
-
end
|
416
|
-
|
417
511
|
# From: http://stackoverflow.com/a/5471032/7672
|
418
512
|
# Thanks, Mislav!
|
419
513
|
#
|
@@ -440,6 +534,8 @@ class MiniPortile
|
|
440
534
|
output = `#{gcc_cmd} -v 2>&1`
|
441
535
|
if m = output.match(/^Target\: (.*)$/)
|
442
536
|
@detect_host = m[1]
|
537
|
+
else
|
538
|
+
@detect_host = nil
|
443
539
|
end
|
444
540
|
|
445
541
|
@detect_host
|
@@ -448,12 +544,35 @@ class MiniPortile
|
|
448
544
|
end
|
449
545
|
end
|
450
546
|
|
547
|
+
TAR_EXECUTABLES = %w[gtar bsdtar tar basic-bsdtar]
|
548
|
+
def tar_exe
|
549
|
+
@@tar_exe ||= begin
|
550
|
+
TAR_EXECUTABLES.find { |c|
|
551
|
+
which(c)
|
552
|
+
} or raise("tar not found - please make sure that one of the following commands is in the PATH: #{TAR_EXECUTABLES.join(", ")}")
|
553
|
+
end
|
554
|
+
end
|
555
|
+
|
556
|
+
def tar_command(file, target)
|
557
|
+
case File.extname(file)
|
558
|
+
when '.gz', '.tgz'
|
559
|
+
[tar_exe, 'xzf', file, '-C', target]
|
560
|
+
when '.bz2', '.tbz2'
|
561
|
+
[tar_exe, 'xjf', file, '-C', target]
|
562
|
+
when '.xz'
|
563
|
+
# NOTE: OpenBSD's tar command does not support the -J option
|
564
|
+
"xzcat #{file.shellescape} | #{tar_exe.shellescape} xf - -C #{target.shellescape}"
|
565
|
+
else
|
566
|
+
[tar_exe, 'xf', file, '-C', target]
|
567
|
+
end
|
568
|
+
end
|
569
|
+
|
451
570
|
def extract_file(file, target)
|
452
571
|
filename = File.basename(file)
|
453
572
|
FileUtils.mkdir_p target
|
454
573
|
|
455
574
|
message "Extracting #{filename} into #{target}... "
|
456
|
-
execute('extract',
|
575
|
+
execute('extract', tar_command(file, target) , {:cd => Dir.pwd, :initial_message => false})
|
457
576
|
end
|
458
577
|
|
459
578
|
# command could be an array of args, or one string containing a command passed to the shell. See
|
@@ -589,7 +708,7 @@ class MiniPortile
|
|
589
708
|
return download_file(redirect.url, full_path, count-1)
|
590
709
|
rescue => e
|
591
710
|
count = count - 1
|
592
|
-
puts "#{count} retrie(s) left for #{filename} (#{e.message})"
|
711
|
+
@logger.puts "#{count} retrie(s) left for #{filename} (#{e.message})"
|
593
712
|
if count > 0
|
594
713
|
sleep 1
|
595
714
|
return download_file_http(url, full_path, count)
|
@@ -648,4 +767,29 @@ class MiniPortile
|
|
648
767
|
FileUtils.mkdir_p File.dirname(full_path)
|
649
768
|
FileUtils.mv temp_file.path, full_path, :force => true
|
650
769
|
end
|
770
|
+
|
771
|
+
#
|
772
|
+
# this minimal version of pkg_config is based on ruby 29dc9378 (2023-01-09)
|
773
|
+
#
|
774
|
+
# specifically with the fix from b90e56e6 to support multiple pkg-config options, and removing
|
775
|
+
# code paths that aren't helpful for mini-portile's use case of parsing pc files.
|
776
|
+
#
|
777
|
+
def minimal_pkg_config(pkg, *pcoptions)
|
778
|
+
if pcoptions.empty?
|
779
|
+
raise ArgumentError, "no pkg-config options are given"
|
780
|
+
end
|
781
|
+
|
782
|
+
if ($PKGCONFIG ||=
|
783
|
+
(pkgconfig = MakeMakefile.with_config("pkg-config") {MakeMakefile.config_string("PKG_CONFIG") || "pkg-config"}) &&
|
784
|
+
MakeMakefile.find_executable0(pkgconfig) && pkgconfig)
|
785
|
+
pkgconfig = $PKGCONFIG
|
786
|
+
else
|
787
|
+
raise RuntimeError, "pkg-config is not found"
|
788
|
+
end
|
789
|
+
|
790
|
+
pcoptions = Array(pcoptions).map { |o| "--#{o}" }
|
791
|
+
response = IO.popen([pkgconfig, *pcoptions, pkg], err:[:child, :out], &:read)
|
792
|
+
raise RuntimeError, response unless $?.success?
|
793
|
+
response.strip
|
794
|
+
end
|
651
795
|
end
|
@@ -11,6 +11,7 @@ class MiniPortileCMake < MiniPortile
|
|
11
11
|
def initialize(name, version, **kwargs)
|
12
12
|
super(name, version, **kwargs)
|
13
13
|
@cmake_command = kwargs[:cmake_command]
|
14
|
+
@cmake_build_type = kwargs[:cmake_build_type]
|
14
15
|
end
|
15
16
|
|
16
17
|
def configure_defaults
|
@@ -49,6 +50,10 @@ class MiniPortileCMake < MiniPortile
|
|
49
50
|
(ENV["CMAKE"] || @cmake_command || "cmake").dup
|
50
51
|
end
|
51
52
|
|
53
|
+
def cmake_build_type
|
54
|
+
(ENV["CMAKE_BUILD_TYPE"] || @cmake_build_type || "Release").dup
|
55
|
+
end
|
56
|
+
|
52
57
|
private
|
53
58
|
|
54
59
|
def generator_defaults
|
@@ -62,45 +67,21 @@ class MiniPortileCMake < MiniPortile
|
|
62
67
|
end
|
63
68
|
|
64
69
|
def cmake_compile_flags
|
65
|
-
|
70
|
+
# RbConfig::CONFIG['CC'] and RbConfig::CONFIG['CXX'] can contain additional flags, for example
|
71
|
+
# "clang++ -std=gnu++11" or "clang -fdeclspec". CMake is just looking for the command name.
|
72
|
+
cc_compiler = cc_cmd.split.first
|
73
|
+
cxx_compiler = cxx_cmd.split.first
|
66
74
|
|
67
75
|
# needed to ensure cross-compilation with CMake targets the right CPU and compilers
|
68
76
|
[
|
69
77
|
"-DCMAKE_SYSTEM_NAME=#{cmake_system_name}",
|
70
78
|
"-DCMAKE_SYSTEM_PROCESSOR=#{cpu_type}",
|
71
|
-
"-DCMAKE_C_COMPILER=#{
|
72
|
-
"-DCMAKE_CXX_COMPILER=#{cxx_compiler}"
|
79
|
+
"-DCMAKE_C_COMPILER=#{cc_compiler}",
|
80
|
+
"-DCMAKE_CXX_COMPILER=#{cxx_compiler}",
|
81
|
+
"-DCMAKE_BUILD_TYPE=#{cmake_build_type}",
|
73
82
|
]
|
74
83
|
end
|
75
84
|
|
76
|
-
def find_compiler(compilers)
|
77
|
-
compilers.find { |binary| which(binary) }
|
78
|
-
end
|
79
|
-
|
80
|
-
# configure automatically searches for the right compiler based on the
|
81
|
-
# `--host` parameter. However, CMake doesn't have an equivalent feature.
|
82
|
-
# Search for the right compiler for the target architecture using
|
83
|
-
# some basic heruistics.
|
84
|
-
def find_c_and_cxx_compilers(host)
|
85
|
-
c_compiler = ENV["CC"]
|
86
|
-
cxx_compiler = ENV["CXX"]
|
87
|
-
|
88
|
-
if MiniPortile.darwin?
|
89
|
-
c_compiler ||= 'clang'
|
90
|
-
cxx_compiler ||='clang++'
|
91
|
-
else
|
92
|
-
c_compiler ||= 'gcc'
|
93
|
-
cxx_compiler ||= 'g++'
|
94
|
-
end
|
95
|
-
|
96
|
-
c_platform_compiler = "#{host}-#{c_compiler}"
|
97
|
-
cxx_platform_compiler = "#{host}-#{cxx_compiler}"
|
98
|
-
c_compiler = find_compiler([c_platform_compiler, c_compiler])
|
99
|
-
cxx_compiler = find_compiler([cxx_platform_compiler, cxx_compiler])
|
100
|
-
|
101
|
-
[c_compiler, cxx_compiler]
|
102
|
-
end
|
103
|
-
|
104
85
|
# Full list: https://gitlab.kitware.com/cmake/cmake/-/blob/v3.26.4/Modules/CMakeDetermineSystem.cmake?ref_type=tags#L12-31
|
105
86
|
def cmake_system_name
|
106
87
|
return system_name if system_name
|
data/mini_portile2.gemspec
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "mini_portile2/version"
|
1
|
+
require_relative "lib/mini_portile2/version"
|
5
2
|
|
6
3
|
Gem::Specification.new do |spec|
|
7
4
|
spec.name = "mini_portile2"
|
@@ -10,8 +7,12 @@ Gem::Specification.new do |spec|
|
|
10
7
|
spec.authors = ["Luis Lavena", "Mike Dalessio", "Lars Kanis"]
|
11
8
|
spec.email = "mike.dalessio@gmail.com"
|
12
9
|
|
13
|
-
spec.summary = "
|
14
|
-
spec.description =
|
10
|
+
spec.summary = "Simple autoconf and cmake builder for developers"
|
11
|
+
spec.description = <<~TEXT
|
12
|
+
Simple autoconf and cmake builder for developers. It provides a standard way to compile against
|
13
|
+
dependency libraries without requiring system-wide installation. It also simplifies
|
14
|
+
vendoring and cross-compilation by providing a consistent build interface.
|
15
|
+
TEXT
|
15
16
|
|
16
17
|
spec.homepage = "https://github.com/flavorjones/mini_portile"
|
17
18
|
spec.licenses = ["MIT"]
|
@@ -0,0 +1,13 @@
|
|
1
|
+
prefix=/foo/libxml2/2.11.5
|
2
|
+
exec_prefix=${prefix}
|
3
|
+
libdir=/foo/libxml2/2.11.5/lib
|
4
|
+
includedir=${prefix}/include
|
5
|
+
modules=1
|
6
|
+
|
7
|
+
Name: libXML
|
8
|
+
Version: 2.11.5
|
9
|
+
Description: libXML library version2.
|
10
|
+
Requires:
|
11
|
+
Libs: -L${libdir} -lxml2
|
12
|
+
Libs.private: -L/foo/zlib/1.3/lib -lz -lm
|
13
|
+
Cflags: -I${includedir}/libxml2 -ggdb3
|
@@ -0,0 +1,13 @@
|
|
1
|
+
prefix=/foo/libxslt/1.1.38
|
2
|
+
exec_prefix=${prefix}
|
3
|
+
libdir=/foo/libxslt/1.1.38/lib
|
4
|
+
includedir=${prefix}/include
|
5
|
+
|
6
|
+
|
7
|
+
Name: libexslt
|
8
|
+
Version: 0.8.21
|
9
|
+
Description: EXSLT Extension library
|
10
|
+
Requires: libxml-2.0, libxslt
|
11
|
+
Cflags: -I${includedir}
|
12
|
+
Libs: -L${libdir} -lexslt
|
13
|
+
Libs.private: -lm
|
@@ -0,0 +1,13 @@
|
|
1
|
+
prefix=/foo/libxslt/1.1.38
|
2
|
+
exec_prefix=${prefix}
|
3
|
+
libdir=/foo/libxslt/1.1.38/lib
|
4
|
+
includedir=${prefix}/include
|
5
|
+
|
6
|
+
|
7
|
+
Name: libxslt
|
8
|
+
Version: 1.1.38
|
9
|
+
Description: XSLT library version 2.
|
10
|
+
Requires: libxml-2.0
|
11
|
+
Cflags: -I${includedir} -Wno-deprecated-enum-enum-conversion
|
12
|
+
Libs: -L${libdir} -lxslt
|
13
|
+
Libs.private: -lm
|
data/test/helper.rb
CHANGED
@@ -9,6 +9,12 @@ require 'archive/tar/minitar'
|
|
9
9
|
require 'fileutils'
|
10
10
|
require 'erb'
|
11
11
|
require 'mini_portile2'
|
12
|
+
require 'logger'
|
13
|
+
|
14
|
+
puts "#{__FILE__}:#{__LINE__}: relevant RbConfig::CONFIG values:"
|
15
|
+
%w[target_os target_cpu CC CXX].each do |key|
|
16
|
+
puts "- #{key}: #{RbConfig::CONFIG[key].inspect}"
|
17
|
+
end
|
12
18
|
|
13
19
|
class TestCase < Minitest::Test
|
14
20
|
include Minitest::Hooks
|
@@ -18,7 +24,12 @@ class TestCase < Minitest::Test
|
|
18
24
|
attr_accessor :webrick
|
19
25
|
|
20
26
|
def start_webrick(path)
|
21
|
-
@webrick = WEBrick::HTTPServer.new(
|
27
|
+
@webrick = WEBrick::HTTPServer.new(
|
28
|
+
:Port => HTTP_PORT,
|
29
|
+
:DocumentRoot => path,
|
30
|
+
:Logger => Logger.new(File::NULL),
|
31
|
+
:AccessLog => [],
|
32
|
+
).tap do |w|
|
22
33
|
Thread.new do
|
23
34
|
w.start
|
24
35
|
end
|