| 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 | # The corvus-json-schema C library (src-rs/corvus-json-schema-capi), version 0.1.7 or later in the 0.1 series. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # An installed library that pkg-config finds as corvus-json-schema is used as it is (the "system" install, linked | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # dynamically). Otherwise the release package for this platform is downloaded from the C library's GitHub release, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # checked against the SHA-256 digest recorded here, and installed into this distribution's share directory (the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # "share" install). There the static library is linked, so JSON::Schema::Corvus::XS has nothing to find at run time, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # except on Windows, where the C library is a DLL that Alien::CorvusJsonSchema->dynamic_libs names. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | my $version = '0.1.7'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | my %digest = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 'aarch64-pc-windows-msvc' => 'e74eb3822fa0730654045c2cf455a899bef90f90b6f183e60ee6a36416555a94', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 'aarch64-unknown-linux-gnu' => '00ad0bce8b1ae0d2c7657de191ea942293ab606bdc5f98f331b018e03b5dff10', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 'aarch64-unknown-linux-musl' => '92b6d6ba48fcfcbbedbf2d0bbb337d60e075d6289efd4a86ee7097e939d637ce', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 'universal2-apple-darwin' => '136d538b5ebe117fa6233c224c58cf6ff939149ec041c0c9317bcf4194c1d3aa', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 'x86_64-pc-windows-msvc' => 'b7c1e00459dc0018b6986f4bb38e2d4ad70b22d2cde2b6c84b06a8e57fdc70be', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 'x86_64-unknown-linux-gnu' => '290ada3bfedaf466b975f6992ff525629e7402669f1d1efbf4c1dd9c164d6a24', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 'x86_64-unknown-linux-musl' => '0830191606e99b1ee8bf3e9dd013c9e44bce19598dfbe45a235a054474e0cd45', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # The release package's target for this Perl, or undef when the release has none. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | sub target { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
target: called CC=10 SCAR=34.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | my $arch = $Config{archname}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | my $cpu = $arch =~ /^(?:x86_64|amd64|x64)/i || $arch =~ /-x64-/i ? 'x86_64' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
$arch =~ /^(?:x86_64|amd64|x64)/i or $arch =~ /-x64-/i
$arch =~ /^(?:aarch64|arm64)/i or $arch =~ /-arm64-/i
MC/DC0%0/2
$arch =~ /^(?:x86_64|amd64|x64)/i or $arch =~ /-x64-/i
$arch =~ /^(?:x86_64|amd64|x64)/i
$arch =~ /-x64-/i
MC/DC0%0/2
$arch =~ /^(?:aarch64|arm64)/i or $arch =~ /-arm64-/i
$arch =~ /^(?:aarch64|arm64)/i
$arch =~ /-arm64-/i
Truth table33%1/3
A or B
A= $arch =~ /^(?:x86_64|amd64|x64)/iB= $arch =~ /-x64-/i
Truth table0%0/3
A or B
A= $arch =~ /^(?:aarch64|arm64)/iB= $arch =~ /-arm64-/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | : $arch =~ /^(?:aarch64|arm64)/i || $arch =~ /-arm64-/i ? 'aarch64' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | return 'universal2-apple-darwin' if $^O eq 'darwin'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | return undef unless defined $cpu; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | return "$cpu-unknown-linux-" . ($Config{gnulibc_version} ? 'gnu' : 'musl') if $^O eq 'linux'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | return "$cpu-pc-windows-msvc" if $^O eq 'MSWin32'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | configure { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | requires 'Alien::Build::Plugin::Digest::SHA' => 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | plugin 'PkgConfig' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | pkg_name => 'corvus-json-schema', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | minimum_version => $version, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | share { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=27.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | my $target = target(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | ▶ | unless (defined $target) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | die "There is no release package of the corvus-json-schema C library for $^O ($Config{archname}). Build it from " | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | . "src-rs/corvus-json-schema-capi (https://github.com/corvus-dotnet/Corvus.JsonSchema), install it where " | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | . "pkg-config finds corvus-json-schema.pc, and install this distribution again.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | if ($^O eq 'MSWin32' && $Config{cc} !~ /gcc/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$^O eq "MSWin32" and not $Alien::Build::Auto::X0::Alienfile::Config{"cc"} =~ /gcc/i
MC/DC0%0/2
$^O eq "MSWin32" and not $Alien::Build::Auto::X0::Alienfile::Config{"cc"} =~ /gcc/i
$^O eq "MSWin32"
not $Alien::Build::Auto::X0::Alienfile::Config{"cc"} =~ /gcc/i
Truth table33%1/3
A and not(B)
A= $^O eq "MSWin32"B= not $Alien::Build::Auto::X0::Alienfile::Config{"cc"} =~ /gcc/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | die "On Windows this distribution needs a Perl built with gcc (Strawberry Perl), which links the C library's DLL. " | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | . "Install the C library where pkg-config finds it instead.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | my $extension = $^O eq 'MSWin32' ? 'zip' : 'tar.gz'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | my $name = "corvus-json-schema-$version-$target"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | start_url "https://github.com/corvus-dotnet/Corvus.JsonSchema/releases/download/capi-v$version/$name.$extension"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | plugin 'Download'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | plugin 'Digest' => [ SHA256 => $digest{$target} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | plugin 'Extract' => $extension; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # The package is prebuilt: installing it is copying it. Only the static library is kept on Linux and macOS, so that | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # -lcorvus_json_schema links it rather than the shared one. On Windows the DLL is kept, with an import library | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # under the name gcc's linker looks for. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | build sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my ($build) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | require File::Copy; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | require File::Path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $prefix = $build->install_prop->{stage}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | File::Path::mkpath([ "$prefix/include", "$prefix/lib" ]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | for my $file (qw(corvus_json_schema.h corvus_json_schema.hpp)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | File::Copy::copy("include/$file", "$prefix/include/$file") or die "copy include/$file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | for my $file (qw(LICENSE THIRD-PARTY-NOTICES.txt)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | File::Copy::copy($file, "$prefix/$file") or die "copy $file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($^O eq 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | File::Path::mkpath(["$prefix/bin"]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | File::Copy::copy('bin/corvus_json_schema.dll', "$prefix/bin/corvus_json_schema.dll") or die "copy the DLL: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | File::Copy::copy('lib/corvus_json_schema.dll.lib', "$prefix/lib/libcorvus_json_schema.dll.a") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | or die "copy the import library: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | File::Copy::copy('lib/libcorvus_json_schema.a', "$prefix/lib/libcorvus_json_schema.a") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | or die "copy the static library: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # The PkgConfig plugin registers a gather hook for share installs too, which would read a .pc file from the staged | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # package. This package has none (the release's names the shared library, and the share install links the static | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # one), so the share install's properties are set here instead, and that hook is not run. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | meta->around_hook(gather_share => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my (undef, $build) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $prefix = $build->runtime_prop->{prefix}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $private = $^O eq 'linux' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ? ($target =~ /musl$/ ? '-lgcc_s -lc' : '-lgcc_s -lutil -lrt -lpthread -lm -ldl -lc') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | : $^O eq 'darwin' ? '-lSystem -lc -lm' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $build->runtime_prop->{version} = $version; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $build->runtime_prop->{cflags} = "-I$prefix/include"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $build->runtime_prop->{cflags_static} = "-I$prefix/include"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $build->runtime_prop->{libs} = "-L$prefix/lib -lcorvus_json_schema $private"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $build->runtime_prop->{libs_static} = "-L$prefix/lib -lcorvus_json_schema $private"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $build->runtime_prop->{capi_target} = $target; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||