1
1
package Perl::Dist::APPerl ;
2
2
# Copyright (c) 2022 Gavin Hayes, see LICENSE in the root of the project
3
- use version; our $VERSION = version-> declare(" v0.0.2 " );
3
+ use version; our $VERSION = version-> declare(" v0.0.3 " );
4
4
use strict;
5
5
use warnings;
6
6
use JSON::PP qw( decode_json) ;
@@ -1218,25 +1218,38 @@ sub _load_apperl_config {
1218
1218
@configlist = reverse @configlist ;
1219
1219
1220
1220
# build the config from oldest to newest
1221
- # keys that start with '+' are actually appended to the non-plus variant instead of replacing
1221
+ # keys that start with '+' are appended to the non-plus variant instead of replacing
1222
+ # keys that start with '-' are removed from the non-plus variant instead of replacing
1223
+ # Removing a key added the same stage or vice versa is undefined
1222
1224
my %itemconfig ;
1223
1225
foreach my $config (@configlist ) {
1224
1226
foreach my $key (keys %$config ) {
1225
- if ($key =~ / ^\+ (.+)/ ) {
1226
- my $realkey = $1 ;
1227
+ if ($key =~ / ^(\+ |\- )(.+)/ ) {
1228
+ my $append = $1 eq ' +' ;
1229
+ my $realkey = $2 ;
1227
1230
exists $itemconfig {$realkey } or die (" cannot append without existing key" );
1228
1231
my $rtype = ref ($itemconfig {$realkey });
1229
1232
$rtype or die (" not ref" );
1230
- if ($rtype eq ' ARRAY' ) {
1231
- $itemconfig {$realkey } = [@{$itemconfig {$realkey }}, @{$config -> {$key }}];
1232
- }
1233
- elsif ($rtype eq ' HASH' ) {
1234
- foreach my $dest (keys %{$config -> {$key }}) {
1235
- push @{$itemconfig {$realkey }{$dest }}, @{$config -> {$key }{$dest }};
1233
+ if ($append ) {
1234
+ if ($rtype eq ' ARRAY' ) {
1235
+ $itemconfig {$realkey } = [@{$itemconfig {$realkey }}, @{$config -> {$key }}];
1236
+ }
1237
+ elsif ($rtype eq ' HASH' ) {
1238
+ foreach my $dest (keys %{$config -> {$key }}) {
1239
+ push @{$itemconfig {$realkey }{$dest }}, @{$config -> {$key }{$dest }};
1240
+ }
1241
+ }
1242
+ else {
1243
+ die ($rtype );
1236
1244
}
1237
1245
}
1238
1246
else {
1239
- die ($rtype );
1247
+ if ($rtype eq ' ARRAY' ) {
1248
+ _remove_arr_items_from_arr($itemconfig {$realkey }, $config -> {$key });
1249
+ }
1250
+ else {
1251
+ die ($rtype );
1252
+ }
1240
1253
}
1241
1254
}
1242
1255
else {
@@ -1250,7 +1263,6 @@ sub _load_apperl_config {
1250
1263
foreach my $path (@{$itemconfig {zip_extra_files }{$destdir }}) {
1251
1264
$path = abs_path($path );
1252
1265
$path or die ;
1253
- print $path ;
1254
1266
-e $path or die (" missing file $path " );
1255
1267
}
1256
1268
}
@@ -1620,9 +1632,10 @@ Now let's create a very basic C extension.
1620
1632
' CODE:' \
1621
1633
' printf("Hello, World!\n");' > MyCExtension/MyCExtension.xs
1622
1634
1623
- Add it to my_src_build_config in apperl-project.json . Some keys that
1624
- begin with '+' will be merged with the non-plus variant of a base
1625
- config.
1635
+ Add it to my_src_build_config in apperl-project.json . Keys that begin
1636
+ with '+' will be merged with the non-plus variant of the parent config.
1637
+ Keys the begin with '-' will be removed from the non-minus variant of
1638
+ the parent config.
1626
1639
1627
1640
"perl_repo_files" : { "ext" : [
1628
1641
"MyCExtension"
0 commit comments