@@ -35,6 +35,19 @@ use constant {
35
35
use constant {
36
36
SITE_CONFIG_FILE => (SITE_CONFIG_DIR." /site.json" ),
37
37
};
38
+ use constant {
39
+ SHARE_DIR => sub {
40
+ my $thispath = abs_path(__FILE__ );
41
+ defined ($thispath ) or die (__FILE__ .' issues?' );
42
+ my $sharedir = dirname($thispath )." /../../../share" ;
43
+ if (! -d $sharedir ) {
44
+ require ' File::ShareDir' ;
45
+ $sharedir = File::ShareDir::dist_dir(' Perl-Dist-APPerl' );
46
+ }
47
+ $sharedir = abs_path($sharedir ) // die " Failed to load sharedir" ;
48
+ return $sharedir ;
49
+ }-> ()
50
+ };
38
51
39
52
sub _load_apperl_configs {
40
53
@@ -659,76 +672,72 @@ my %defconfig = (
659
672
zip_extra_files => {},
660
673
nobuild_perl_bin => [' src/perl.com' , $^X],
661
674
},
662
- ' v5.36.0-full-v0.1.0' => {
663
- desc => ' Full perl v5.36.0 built with Cosmopolitan Libc 2.2 ' ,
675
+ ' v5.36.0-full-v0.1.0-vista ' => {
676
+ desc => ' Full perl v5.36.0, but with non-standard Cosmopolitan Libc that still supports vista ' ,
664
677
perl_id => ' b22da6b83c37604132694ead0bdcf61690f74a53' ,
665
- cosmo_id => ' 52f1db7220935cfcf2c8e583678f5ccc4b5bbacd ' ,
678
+ cosmo_id => ' 9c5a7795add7add5a214afce27d896084e0861c5 ' ,
666
679
cosmo_mode => ' ' ,
667
680
cosmo_ape_loader => ' ape-no-modify-self.o' ,
681
+ dest => ' perl-vista.com' ,
668
682
perl_flags => [' -Dprefix=/zip' , ' -Uversiononly' , ' -Dmyhostname=cosmo' , ' -Dmydomain=invalid' ],
669
683
perl_extra_flags => [' -Doptimize=-Os' , ' -de' ],
670
- dest => ' perl.com' ,
671
684
MANIFEST => [' lib' , ' bin' ],
672
685
' include_Perl-Dist-APPerl' => 1,
673
686
perl_repo_files => {},
674
687
zip_extra_files => {},
675
688
},
676
- ' v5.36.0-full-v0.1.0-vista' => {
677
- desc => ' Full perl v5.36.0, but with non-standard Cosmopolitan Libc that still supports vista' ,
678
- base => ' v5.36.0-full-v0.1.0' ,
679
- cosmo_id => ' 9c5a7795add7add5a214afce27d896084e0861c5' ,
680
- dest => ' perl-vista.com' ,
681
- },
682
- ' v5.36.0-small-v0.1.0' => {
683
- desc => ' small perl v5.36.0 built with Cosmopolitan Libc 2.2' ,
684
- base => ' v5.36.0-full-v0.1.0' ,
689
+ ' v5.36.0-small-v0.1.0-vista' => {
690
+ desc => ' small perl v5.36.0, but with non-standard Cosmopolitan Libc that still supports vista' ,
691
+ base => ' v5.36.0-full-v0.1.0-vista' ,
685
692
perl_onlyextensions => [qw( Cwd Fcntl File/Glob Hash/Util IO List/Util POSIX Socket attributes re) ],
686
- perl_extra_flags => [' -Doptimize=-Os' , ' -de' ],
687
693
MANIFEST => \@smallmanifest ,
688
694
' include_Perl-Dist-APPerl' => 0,
689
- dest => ' perl-small.com' ,
690
- },
691
- ' v5.36.0-small-v0.1.0-vista' => {
692
- desc => ' small perl v5.36.0, but with non-standard Cosmopolitan Libc that still supports vista' ,
693
- base => ' v5.36.0-small-v0.1.0' ,
694
- cosmo_id => ' 9c5a7795add7add5a214afce27d896084e0861c5' ,
695
695
dest => ' perl-small-vista.com' ,
696
696
},
697
- ' full' => { desc => ' moving target: full' , base => ' v5.36.0-full-v0.1.0' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ], cosmo3 => 1, perl_url => ' https://github.com/Perl/perl5/archive/refs/tags/v5.36.3.tar.gz' , patches => [' ../Perl-Dist-APPerl/5.36-cosmo.patch' , ' ../Perl-Dist-APPerl/5.36-cosmo-apperl.patch' ]},
698
697
' full-vista' => { desc => ' moving target: full for vista' , base => ' v5.36.0-full-v0.1.0-vista' , perl_id => ' 239a05bbef291b8de3309c95852d41fc027cacab' , cosmo_id => ' fea68b142e59b5861fe09375eb5bcb256b69b70e' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ]},
699
- ' small' => { desc => ' moving target: small' , base => ' v5.36.0-small-v0.1.0' , perl_id => ' 239a05bbef291b8de3309c95852d41fc027cacab' , cosmo_id => ' eb69a42863ef602a951249b801ceed5f74cbb11c' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ]},
700
698
' small-vista' => { desc => ' moving target: small for vista' , base => ' v5.36.0-small-v0.1.0-vista' , perl_id => ' 239a05bbef291b8de3309c95852d41fc027cacab' , cosmo_id => ' fea68b142e59b5861fe09375eb5bcb256b69b70e' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ]},
699
+ ' full' => {
700
+ desc => ' moving target: full' ,
701
+ perl_flags => [' -Dprefix=/zip' , ' -Uversiononly' , ' -Dmyhostname=cosmo' , ' -Dmydomain=invalid' ],
702
+ perl_extra_flags => [' -Doptimize=-Os' , ' -de' , ' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ],
703
+ MANIFEST => [' lib' , ' bin' ],
704
+ ' include_Perl-Dist-APPerl' => 1,
705
+ perl_repo_files => {},
706
+ zip_extra_files => {},
707
+ cosmo3 => 1,
708
+ dest => ' perl.com' ,
709
+ perl_url => ' https://github.com/Perl/perl5/archive/refs/tags/v5.36.3.tar.gz' ,
710
+ patches => [' __sharedir__/5.36-cosmo3.patch' , ' __sharedir__/5.36-cosmo-apperl.patch' ],
711
+ install_modules => [' File-ShareDir-1.118.tar.gz' ],
712
+ },
713
+ ' small' => {
714
+ desc => ' moving target: small' ,
715
+ base => ' full' ,
716
+ perl_onlyextensions => [qw( Cwd Fcntl File/Glob Hash/Util IO List/Util POSIX Socket attributes re) ],
717
+ MANIFEST => \@smallmanifest ,
718
+ ' include_Perl-Dist-APPerl' => 0,
719
+ dest => ' perl-small.com' ,
720
+ install_modules => [],
721
+ },
701
722
# development configs
702
- ' dbg' => { base => ' full' , perl_extra_flags => [' -Doptimize=-g3 -gdwarf-4' , ' -de' ], cosmo_mode => ' dbg ' , cosmo_id => ' 52f1db7220935cfcf2c8e583678f5ccc4b5bbacd ' },
723
+ ' dbg' => { base => ' full' , perl_extra_flags => [' -Doptimize=-g3 -gdwarf-4' , ' -de' ]},
703
724
dontuse_threads => {
704
725
desc => " not recommended, threaded build is buggy" ,
705
726
base => ' full' ,
706
727
perl_extra_flags => [' -Doptimize=-Os' , ' -Dusethreads' , ' -de' ],
707
728
perl_id => ' cosmo-apperl'
708
729
},
709
730
perl_cosmo_dev => {
710
- desc => " For developing cosmo platform perl without apperl additions" ,
711
- base => ' full' ,
712
- perl_id => ' cosmo' ,
713
- patches => [' ../Perl-Dist-APPerl/share/5.36-cosmo.patch' ]
714
- },
715
- perl_cosmo3_dev => {
716
731
desc => " For developing cosmo platform perl without apperl additions" ,
717
732
base => ' full' ,
718
733
perl_id => ' v5.36.3' ,
719
734
perl_url => undef ,
720
- patches => [' ../Perl-Dist-APPerl/share/5.36-cosmo3.patch' ],
721
- install_modules => [' File-ShareDir-1.118.tar.gz' ]
722
- },
723
- perl_cosmo_dev_on_vista => {
724
- desc => " For developing cosmo platform perl without apperl additions on vista" ,
725
- base => " perl_cosmo_dev" ,
726
- cosmo_id => ' 0740e68ea0e801168a5e354be5ad237a4795549a' ,
735
+ patches => [' __sharedir__/5.36-cosmo3.patch' ],
727
736
},
728
737
perl_apperl_dev => {
729
738
desc => " For developing apperl" ,
730
- base => ' full ' ,
731
- perl_id => ' cosmo-apperl'
739
+ base => ' perl_cosmo3_dev ' ,
740
+ ' +patches ' => [ ' __sharedir__/5.36- cosmo-apperl.patch ' ],
732
741
}
733
742
}
734
743
);
@@ -798,7 +807,7 @@ sub NewConfig {
798
807
}
799
808
800
809
sub InstallBuildDeps {
801
- my ($perlrepo , $cosmorepo ) = @_ ;
810
+ my ($perlrepo , $cosmorepo , $cosmocc ) = @_ ;
802
811
my $SiteConfig = _load_json(SITE_CONFIG_FILE);
803
812
# if a repo is not set, set one up by default
804
813
if ((!$SiteConfig || !exists $SiteConfig -> {perl_repo }) && (!$perlrepo )) {
@@ -811,13 +820,25 @@ sub InstallBuildDeps {
811
820
_setup_repo( $cosmorepo , _load_apperl_configs()-> {cosmo_remotes });
812
821
print " apperlm install-build-deps: setup cosmo repo\n " ;
813
822
}
823
+ if ((!$SiteConfig || !exists $SiteConfig -> {cosmocc }) && (!$cosmocc )) {
824
+ $cosmocc = SITE_REPO_DIR." /cosmocc" ;
825
+ print " mkdir -p $cosmocc \n " ;
826
+ make_path($cosmocc );
827
+ print " cd $cosmocc \n " ;
828
+ chdir ($cosmocc ) or die " Failed to chdir $cosmocc " ;
829
+ _command_or_die(' wget' , ' https://cosmo.zip/pub/cosmocc/cosmocc.zip' );
830
+ _command_or_die(' unzip' , ' cosmocc.zip' );
831
+ print " apperlm install-build-deps: setup cosmocc\n " ;
832
+ }
814
833
815
834
# (re)write site config
816
835
$perlrepo //= $SiteConfig -> {perl_repo };
817
836
$cosmorepo //= $SiteConfig -> {cosmo_repo };
837
+ $cosmocc //= $SiteConfig -> {cosmocc };
818
838
my %siteconfig = (
819
839
perl_repo => abs_path($perlrepo ),
820
- cosmo_repo => abs_path($cosmorepo )
840
+ cosmo_repo => abs_path($cosmorepo ),
841
+ cosmocc => abs_path($cosmocc ),
821
842
);
822
843
$SiteConfig = \%siteconfig ;
823
844
make_path(SITE_CONFIG_DIR);
@@ -857,7 +878,7 @@ sub Status {
857
878
}
858
879
my @stable = grep ( / v\d +\.\d +\.\d +(\- vista)?$ / , @configlist );
859
880
my @rolling = (' full' , ' full-vista' , ' small' , ' small-vista' );
860
- my @internal = (' dontuse_threads' , ' perl_cosmo_dev' , ' perl_cosmo_dev_on_vista ' , ' perl_apperl_dev ' );
881
+ my @internal = (' dontuse_threads' , ' perl_cosmo_dev' , ' perl_apperl_dev ' , ' dbg ' );
861
882
my @categories = (
862
883
[' PROJECT' , \@projectitems ],
863
884
[' STABLE' , \@stable ],
@@ -903,6 +924,8 @@ sub Set {
903
924
print " cd " .$SiteConfig -> {cosmo_repo }." \n " ;
904
925
chdir ($SiteConfig -> {cosmo_repo }) or die " Failed to enter cosmo repo" ;
905
926
_command_or_die(' git' , ' checkout' , $itemconfig -> {cosmo_id });
927
+ } else {
928
+ -d $SiteConfig -> {cosmocc } or die $SiteConfig -> {cosmocc } . ' is not a directory' ;
906
929
}
907
930
908
931
if (! $itemconfig -> {perl_url }) {
@@ -934,7 +957,8 @@ sub Set {
934
957
chdir ($SiteConfig -> {perl_repo }) or die " Failed to enter perl repo" ;
935
958
}
936
959
foreach my $patch (@{$itemconfig -> {patches }}) {
937
- _command_or_die(' git' , ' apply' , $patch );
960
+ my $realpatch = _fix_bases($patch , {__sharedir__ => SHARE_DIR});
961
+ _command_or_die(' git' , ' apply' , $realpatch );
938
962
}
939
963
940
964
print " cd " .START_WD." \n " ;
@@ -990,12 +1014,15 @@ sub Configure {
990
1014
);
991
1015
$ENV {COSMO_MODE } = $itemconfig -> {cosmo_mode };
992
1016
$ENV {COSMO_APE_LOADER } = $itemconfig -> {cosmo_ape_loader };
1017
+ $ENV {COSMO_REPO } = $SiteConfig -> {cosmo_repo };
1018
+ } else {
1019
+ -d $SiteConfig -> {cosmocc } or die $SiteConfig -> {cosmocc } . ' is not a directory' ;
1020
+ $ENV {COSMOCC } = $SiteConfig -> {cosmocc };
993
1021
}
994
1022
995
1023
# Finally Configure perl
996
1024
print " cd " .$SiteConfig -> {perl_repo }." \n " ;
997
1025
chdir ($SiteConfig -> {perl_repo }) or die " Failed to enter perl repo" ;
998
- $ENV {COSMO_REPO } = $SiteConfig -> {cosmo_repo };
999
1026
my @onlyextensions = ();
1000
1027
push @onlyextensions , (" -Donlyextensions= " .join (' ' , sort @{$itemconfig -> {perl_onlyextensions }}).' ' ) if (exists $itemconfig -> {perl_onlyextensions });
1001
1028
_command_or_die(' sh' , ' Configure' , @{$itemconfig -> {perl_flags }}, @onlyextensions , @{$itemconfig -> {perl_extra_flags }}, @_ );
@@ -1038,7 +1065,11 @@ sub Build {
1038
1065
# build cosmo perl if this isn't a nobuild config
1039
1066
if (! exists $UserProjectConfig -> {nobuild_perl_bin }){
1040
1067
my $SiteConfig = _load_json(SITE_CONFIG_FILE) or die " cannot build without build deps (run apperlm install-build-deps)" ;
1041
- -d $SiteConfig -> {cosmo_repo } or die $SiteConfig -> {cosmo_repo } .' is not directory' ;
1068
+ if (! $itemconfig -> {cosmo3 }) {
1069
+ -d $SiteConfig -> {cosmo_repo } or die $SiteConfig -> {cosmo_repo } .' is not directory' ;
1070
+ } else {
1071
+ -d $SiteConfig -> {cosmocc } or die $SiteConfig -> {cosmocc } .' is not directory' ;
1072
+ }
1042
1073
-d $SiteConfig -> {perl_repo } or die $SiteConfig -> {perl_repo } .' is not directory' ;
1043
1074
_install_perl_repo_files($itemconfig , $SiteConfig );
1044
1075
print " cd " .$SiteConfig -> {perl_repo }." \n " ;
@@ -1346,22 +1377,25 @@ END_USAGE
1346
1377
apperlm install-build-deps [-h|--help] [-c|--cosmo <path>] [-p|--perl <path>]
1347
1378
-c|--cosmo <path> set path to cosmopolitan repo (skips git initialization)
1348
1379
-p|--perl <path> set path to perl repo (skips git initialization)
1380
+ -C|--cosmocc <path> set path to cosmocc
1349
1381
-h|--help Show this message
1350
1382
Install build dependencies for APPerl, use -c or -p to skip initializing
1351
1383
those repos by providing a path to it.
1352
1384
END_USAGE
1353
1385
my $cosmo ;
1354
1386
my $perl ;
1387
+ my $cosmocc ;
1355
1388
my $help ;
1356
1389
GetOptionsFromArray(\@_ , " cosmo|c=s" => \$cosmo ,
1357
1390
" perl|p=s" => \$perl ,
1391
+ " cosmocc|C=s" => \$cosmocc ,
1358
1392
" help|h" => \$help ,
1359
1393
) or die ($usage );
1360
1394
if ($help ) {
1361
1395
print $usage ;
1362
1396
exit 0;
1363
1397
}
1364
- Perl::Dist::APPerl::InstallBuildDeps($perl , $cosmo );
1398
+ Perl::Dist::APPerl::InstallBuildDeps($perl , $cosmo , $cosmocc );
1365
1399
}
1366
1400
elsif ($command eq ' new-config' ) {
1367
1401
my $usage = <<'END_USAGE' ;
@@ -1413,14 +1447,14 @@ sub _setup_repo {
1413
1447
my ($repopath , $remotes ) = @_ ;
1414
1448
print " mkdir -p $repopath \n " ;
1415
1449
make_path($repopath );
1416
- print " cd $repopath \n " ;
1417
- chdir ($repopath ) or die " Failed to chdir $repopath " ;
1418
- _command_or_die(' git' , ' init' );
1419
- _command_or_die(' git' , ' checkout' , ' -b' , ' placeholder_dont_use' );
1420
- foreach my $remote (keys %{$remotes }) {
1421
- _command_or_die(' git' , ' remote' , ' add' , $remote , $remotes -> {$remote });
1422
- _command_or_die(' git' , ' fetch' , $remote );
1423
- }
1450
+ # print "cd $repopath\n";
1451
+ # chdir($repopath) or die "Failed to chdir $repopath";
1452
+ # _command_or_die('git', 'init');
1453
+ # _command_or_die('git', 'checkout', '-b', 'placeholder_dont_use');
1454
+ # foreach my $remote (keys %{$remotes}) {
1455
+ # _command_or_die('git', 'remote', 'add', $remote, $remotes->{$remote});
1456
+ # _command_or_die('git', 'fetch', $remote);
1457
+ # }
1424
1458
}
1425
1459
1426
1460
sub _write_json {
@@ -1507,22 +1541,18 @@ sub _load_apperl_config {
1507
1541
defined ($thispath ) or die (__FILE__ .' issues?' );
1508
1542
push @{$itemconfig {zip_extra_files }{" __perllib__/Perl/Dist" }}, $thispath ;
1509
1543
my $apperlm = $0 ;
1510
- my $patchdir ;
1511
1544
if (basename($0 ) ne ' apperlm' ) {
1512
1545
$apperlm = dirname($thispath )." /../../../script/apperlm" ;
1513
1546
}
1514
- $patchdir = dirname($thispath )." /../../../share" ;
1515
1547
$apperlm = abs_path($apperlm );
1516
1548
defined ($apperlm ) or die " error getting path to apperlm" ;
1517
1549
my @additionalfiles = ($apperlm );
1518
1550
-e $_ or die (" $_ $! " ) foreach @additionalfiles ;
1519
1551
push @{$itemconfig {zip_extra_files }{bin }}, @additionalfiles ;
1520
- $patchdir = abs_path($patchdir );
1521
- defined ($patchdir ) or die " error getting path to patchdir" ;
1522
- opendir (my $dh , $patchdir ) or die " error opening patch dir" ;
1552
+ opendir (my $dh , SHARE_DIR) or die " error opening patch dir" ;
1523
1553
while (my $file = readdir $dh ) {
1524
1554
next if (($file eq ' .' ) || ($file eq ' ..' ));
1525
- push @{$itemconfig {zip_extra_files }{" __perllib__/auto/share/dist/Perl-Dist-APPerl" }}, " $patchdir /$file " ;
1555
+ push @{$itemconfig {zip_extra_files }{" __perllib__/auto/share/dist/Perl-Dist-APPerl" }}, SHARE_DIR. " /$file " ;
1526
1556
}
1527
1557
}
1528
1558
0 commit comments