| 1 | 1 | ▶ | use alienfile; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use Config; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | # Use a system pugixml when one is installed and recent enough; otherwise build | ||||||||||
| 5 | # from source. 1.8 is the floor XML::PugiXML needs (it references the output | ||||||||||
| 6 | # flag format_no_empty_element_tags, added in pugixml 1.8). Older or missing | ||||||||||
| 7 | # system libraries fall through to the source build below, which installs the | ||||||||||
| 8 | # current release. | ||||||||||
| 9 | 1 | plugin 'PkgConfig' => ( | |||||||||
| 10 | pkg_name => 'pugixml', | ||||||||||
| 11 | atleast_version => '1.8', | ||||||||||
| 12 | ); | ||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | share { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=5.3
| |||||||||||
| 15 | 1 | requires 'ExtUtils::CBuilder' => '0.280226'; | |||||||||
| 16 | |||||||||||
| 17 | 1 | plugin 'Download' => ( | |||||||||
| 18 | url => 'https://github.com/zeux/pugixml/releases/download/v1.16/pugixml-1.16.tar.gz', | ||||||||||
| 19 | version => qr/pugixml-([0-9.]+)\.tar\.gz$/, | ||||||||||
| 20 | ); | ||||||||||
| 21 | |||||||||||
| 22 | 1 | plugin 'Extract' => 'tar.gz'; | |||||||||
| 23 | |||||||||||
| 24 | 0 | ▶ | build sub { | ||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||
| 25 | 0 | my ($build) = @_; | |||||||||
| 26 | 0 | require ExtUtils::CBuilder; | |||||||||
| 27 | 0 | require Path::Tiny; | |||||||||
| 28 | |||||||||||
| 29 | # The -std pugixml.cpp is compiled with decides which overloads the library | ||||||||||
| 30 | # has (C++11 move, C++17 string_view), so take the newest that works. | ||||||||||
| 31 | 0 | my $cb = ExtUtils::CBuilder->new; | |||||||||
| 32 | 0 | my $obj; | |||||||||
| 33 | 0 | for my $std ('-std=c++17', '-std=c++11', '') { | |||||||||
| 34 | 0 | ▶ | $obj = eval { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | $cb->compile( | |||||||||
| 36 | 'C++' => 1, | ||||||||||
| 37 | source => 'src/pugixml.cpp', | ||||||||||
| 38 | extra_compiler_flags => $std, | ||||||||||
| 39 | ); | ||||||||||
| 40 | } and last; | ||||||||||
| 41 | } | ||||||||||
| 42 | 0 | ▶ | die "failed to compile src/pugixml.cpp\n" unless $obj; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | |||||||||||
| 44 | 0 | my $lib = "libpugixml$Config{_a}"; | |||||||||
| 45 | 0 | ▶ | $build->system((split ' ', $Config{ar}), 'crs', $lib, $obj) == 0 | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | or die "failed to create $lib\n"; | ||||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | my ($v) = Path::Tiny->new('src/pugixml.hpp')->slurp | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | =~ /^\s*#\s*define\s+PUGIXML_VERSION\s+(\d+)/m | ||||||||||
| 50 | or die "PUGIXML_VERSION not found in src/pugixml.hpp\n"; | ||||||||||
| 51 | 0 | my $version = sprintf '%d.%d', $v / 1000, $v % 1000 / 10; | |||||||||
| 52 | 0 | ▶ | $version .= '.' . $v % 10 if $v % 10; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | |||||||||||
| 54 | 0 | my $stage = Path::Tiny->new($build->install_prop->{prefix}); | |||||||||
| 55 | 0 | my $include = $stage->child('include'); | |||||||||
| 56 | 0 | my $libdir = $stage->child('lib'); | |||||||||
| 57 | 0 | $_->mkpath for $include, $libdir->child('pkgconfig'); | |||||||||
| 58 | Path::Tiny->new("src/$_")->copy($include->child($_)) | ||||||||||
| 59 | 0 | for qw( pugixml.hpp pugiconfig.hpp ); | |||||||||
| 60 | 0 | Path::Tiny->new($lib)->copy($libdir->child($lib)); | |||||||||
| 61 | |||||||||||
| 62 | 0 | my $prefix = $build->runtime_prop->{prefix}; | |||||||||
| 63 | 0 | $libdir->child('pkgconfig', 'pugixml.pc')->spew(<<"PC"); | |||||||||
| 64 | prefix=$prefix | ||||||||||
| 65 | includedir=\${prefix}/include | ||||||||||
| 66 | libdir=\${prefix}/lib | ||||||||||
| 67 | |||||||||||
| 68 | Name: pugixml | ||||||||||
| 69 | Description: Light-weight, simple and fast XML parser for C++ with XPath support. | ||||||||||
| 70 | URL: https://pugixml.org/ | ||||||||||
| 71 | Version: $version | ||||||||||
| 72 | Cflags: -I\${includedir} | ||||||||||
| 73 | Libs: -L\${libdir} -lpugixml | ||||||||||
| 74 | PC | ||||||||||
| 75 | 1 | }; | |||||||||
| 76 | 1 | }; | |||||||||