Skip to content

Commit 7637ae7

Browse files
committed
simply configs, use share dir for patches, add downloading cosmocc
1 parent d759d22 commit 7637ae7

File tree

4 files changed

+101
-74
lines changed

4 files changed

+101
-74
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
uses: shogo82148/actions-setup-perl@v1
1919
with:
2020
perl-version: '5.36'
21+
install-modules-with: cpanm
22+
install-modules: File::ShareDir::Install
2123
- name: Test in-tree
2224
run: |
2325
cd Perl-Dist-APPerl
@@ -81,6 +83,7 @@ jobs:
8183
CF_EMAIL: ${{ secrets.CF_EMAIL }}
8284
run: |
8385
ls -la
86+
wget https://cpan.metacpan.org/authors/id/R/RE/REHSACK/File-ShareDir-1.118.tar.gz
8487
apperlm install-build-deps -p perl5 -c cosmopolitan
8588
apperlm init --name ${{ matrix.config }}
8689
apperlm list

Makefile.PL

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ for my $parameter ( keys %min_eumm_version ) {
7575
WriteMakefile(%WriteMakefileArgs);
7676

7777
sub MY::postamble {
78-
return "authortest: test\n\tAUTHOR_TESTING=1 "
78+
return File::ShareDir::Install::postamble(@_) . "\n"
79+
."authortest: test\n\tAUTHOR_TESTING=1 "
7980
. $_[0]->test_via_harness( '$(FULLPERLRUN)', 'xt/author/*.t' );
8081
}
81-
82-
{
83-
package
84-
MY;
85-
use File::ShareDir::Install qw(postamble);
86-
}

lib/Perl/Dist/APPerl.pm

Lines changed: 89 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ use constant {
3535
use constant {
3636
SITE_CONFIG_FILE => (SITE_CONFIG_DIR."/site.json"),
3737
};
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+
};
3851

3952
sub _load_apperl_configs {
4053

@@ -659,76 +672,72 @@ my %defconfig = (
659672
zip_extra_files => {},
660673
nobuild_perl_bin => ['src/perl.com', $^X],
661674
},
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',
664677
perl_id => 'b22da6b83c37604132694ead0bdcf61690f74a53',
665-
cosmo_id => '52f1db7220935cfcf2c8e583678f5ccc4b5bbacd',
678+
cosmo_id => '9c5a7795add7add5a214afce27d896084e0861c5',
666679
cosmo_mode => '',
667680
cosmo_ape_loader => 'ape-no-modify-self.o',
681+
dest => 'perl-vista.com',
668682
perl_flags => ['-Dprefix=/zip', '-Uversiononly', '-Dmyhostname=cosmo', '-Dmydomain=invalid'],
669683
perl_extra_flags => ['-Doptimize=-Os', '-de'],
670-
dest => 'perl.com',
671684
MANIFEST => ['lib', 'bin'],
672685
'include_Perl-Dist-APPerl' => 1,
673686
perl_repo_files => {},
674687
zip_extra_files => {},
675688
},
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',
685692
perl_onlyextensions => [qw(Cwd Fcntl File/Glob Hash/Util IO List/Util POSIX Socket attributes re)],
686-
perl_extra_flags => ['-Doptimize=-Os', '-de'],
687693
MANIFEST => \@smallmanifest,
688694
'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',
695695
dest => 'perl-small-vista.com',
696696
},
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']},
698697
'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']},
700698
'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+
},
701722
# 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']},
703724
dontuse_threads => {
704725
desc => "not recommended, threaded build is buggy",
705726
base => 'full',
706727
perl_extra_flags => ['-Doptimize=-Os', '-Dusethreads', '-de'],
707728
perl_id => 'cosmo-apperl'
708729
},
709730
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 => {
716731
desc => "For developing cosmo platform perl without apperl additions",
717732
base => 'full',
718733
perl_id => 'v5.36.3',
719734
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'],
727736
},
728737
perl_apperl_dev => {
729738
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'],
732741
}
733742
}
734743
);
@@ -798,7 +807,7 @@ sub NewConfig {
798807
}
799808

800809
sub InstallBuildDeps {
801-
my ($perlrepo, $cosmorepo) = @_;
810+
my ($perlrepo, $cosmorepo, $cosmocc) = @_;
802811
my $SiteConfig = _load_json(SITE_CONFIG_FILE);
803812
# if a repo is not set, set one up by default
804813
if((!$SiteConfig || !exists $SiteConfig->{perl_repo}) && (!$perlrepo)) {
@@ -811,13 +820,25 @@ sub InstallBuildDeps {
811820
_setup_repo( $cosmorepo, _load_apperl_configs()->{cosmo_remotes});
812821
print "apperlm install-build-deps: setup cosmo repo\n";
813822
}
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+
}
814833

815834
# (re)write site config
816835
$perlrepo //= $SiteConfig->{perl_repo};
817836
$cosmorepo //= $SiteConfig->{cosmo_repo};
837+
$cosmocc //= $SiteConfig->{cosmocc};
818838
my %siteconfig = (
819839
perl_repo => abs_path($perlrepo),
820-
cosmo_repo => abs_path($cosmorepo)
840+
cosmo_repo => abs_path($cosmorepo),
841+
cosmocc => abs_path($cosmocc),
821842
);
822843
$SiteConfig = \%siteconfig;
823844
make_path(SITE_CONFIG_DIR);
@@ -857,7 +878,7 @@ sub Status {
857878
}
858879
my @stable = grep( /v\d+\.\d+\.\d+(\-vista)?$/, @configlist);
859880
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');
861882
my @categories = (
862883
['PROJECT', \@projectitems],
863884
['STABLE', \@stable],
@@ -903,6 +924,8 @@ sub Set {
903924
print "cd ".$SiteConfig->{cosmo_repo}."\n";
904925
chdir($SiteConfig->{cosmo_repo}) or die "Failed to enter cosmo repo";
905926
_command_or_die('git', 'checkout', $itemconfig->{cosmo_id});
927+
} else {
928+
-d $SiteConfig->{cosmocc} or die $SiteConfig->{cosmocc} . ' is not a directory';
906929
}
907930

908931
if (! $itemconfig->{perl_url}) {
@@ -934,7 +957,8 @@ sub Set {
934957
chdir($SiteConfig->{perl_repo}) or die "Failed to enter perl repo";
935958
}
936959
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);
938962
}
939963

940964
print "cd ".START_WD."\n";
@@ -990,12 +1014,15 @@ sub Configure {
9901014
);
9911015
$ENV{COSMO_MODE} = $itemconfig->{cosmo_mode};
9921016
$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};
9931021
}
9941022

9951023
# Finally Configure perl
9961024
print "cd ".$SiteConfig->{perl_repo}."\n";
9971025
chdir($SiteConfig->{perl_repo}) or die "Failed to enter perl repo";
998-
$ENV{COSMO_REPO} = $SiteConfig->{cosmo_repo};
9991026
my @onlyextensions = ();
10001027
push @onlyextensions, ("-Donlyextensions= ".join(' ', sort @{$itemconfig->{perl_onlyextensions}}).' ') if(exists $itemconfig->{perl_onlyextensions});
10011028
_command_or_die('sh', 'Configure', @{$itemconfig->{perl_flags}}, @onlyextensions, @{$itemconfig->{perl_extra_flags}}, @_);
@@ -1038,7 +1065,11 @@ sub Build {
10381065
# build cosmo perl if this isn't a nobuild config
10391066
if(! exists $UserProjectConfig->{nobuild_perl_bin}){
10401067
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+
}
10421073
-d $SiteConfig->{perl_repo} or die $SiteConfig->{perl_repo} .' is not directory';
10431074
_install_perl_repo_files($itemconfig, $SiteConfig);
10441075
print "cd ".$SiteConfig->{perl_repo}."\n";
@@ -1346,22 +1377,25 @@ END_USAGE
13461377
apperlm install-build-deps [-h|--help] [-c|--cosmo <path>] [-p|--perl <path>]
13471378
-c|--cosmo <path> set path to cosmopolitan repo (skips git initialization)
13481379
-p|--perl <path> set path to perl repo (skips git initialization)
1380+
-C|--cosmocc <path> set path to cosmocc
13491381
-h|--help Show this message
13501382
Install build dependencies for APPerl, use -c or -p to skip initializing
13511383
those repos by providing a path to it.
13521384
END_USAGE
13531385
my $cosmo;
13541386
my $perl;
1387+
my $cosmocc;
13551388
my $help;
13561389
GetOptionsFromArray(\@_, "cosmo|c=s" => \$cosmo,
13571390
"perl|p=s" => \$perl,
1391+
"cosmocc|C=s" => \$cosmocc,
13581392
"help|h" => \$help,
13591393
) or die($usage);
13601394
if($help) {
13611395
print $usage;
13621396
exit 0;
13631397
}
1364-
Perl::Dist::APPerl::InstallBuildDeps($perl, $cosmo);
1398+
Perl::Dist::APPerl::InstallBuildDeps($perl, $cosmo, $cosmocc);
13651399
}
13661400
elsif($command eq 'new-config') {
13671401
my $usage = <<'END_USAGE';
@@ -1413,14 +1447,14 @@ sub _setup_repo {
14131447
my ($repopath, $remotes) = @_;
14141448
print "mkdir -p $repopath\n";
14151449
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+
#}
14241458
}
14251459

14261460
sub _write_json {
@@ -1507,22 +1541,18 @@ sub _load_apperl_config {
15071541
defined($thispath) or die(__FILE__.'issues?');
15081542
push @{$itemconfig{zip_extra_files}{"__perllib__/Perl/Dist"}}, $thispath;
15091543
my $apperlm = $0;
1510-
my $patchdir;
15111544
if(basename($0) ne 'apperlm') {
15121545
$apperlm = dirname($thispath)."/../../../script/apperlm";
15131546
}
1514-
$patchdir = dirname($thispath)."/../../../share";
15151547
$apperlm = abs_path($apperlm);
15161548
defined($apperlm) or die "error getting path to apperlm";
15171549
my @additionalfiles = ($apperlm);
15181550
-e $_ or die("$_ $!") foreach @additionalfiles;
15191551
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";
15231553
while(my $file = readdir $dh) {
15241554
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";
15261556
}
15271557
}
15281558

share/5.36-cosmo3.patch

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ index 8f25e9d835..8fcde9e4e2 100644
2323
Gene Sullivan <[email protected]>
2424
Geoffrey F. Green <[email protected]>
2525
diff --git a/Configure b/Configure
26-
index 67e990217d..cd8ce30511 100755
26+
index 67e990217d..bedad1da43 100755
2727
--- a/Configure
2828
+++ b/Configure
2929
@@ -2744,7 +2744,7 @@ int main(int argc, char *argv[]) {
@@ -48,7 +48,7 @@ index 67e990217d..cd8ce30511 100755
4848
fi
4949
fi
5050

51-
+ if [ $COSMO_REPO ]; then
51+
+ if [ $COSMOCC ]; then
5252
+ osname='cosmo'
5353
+ osvers=''
5454
+ fi
@@ -809,15 +809,15 @@ index 024c66a147..2741c895ed 100644
809809

810810
diff --git a/hints/cosmo.sh b/hints/cosmo.sh
811811
new file mode 100644
812-
index 0000000000..e74369d214
812+
index 0000000000..3d7118a4f9
813813
--- /dev/null
814814
+++ b/hints/cosmo.sh
815-
@@ -0,0 +1,22 @@
815+
@@ -0,0 +1,21 @@
816816
+#! /bin/sh
817817
+# cosmo.sh - hints for building perl using the Cosmopolitan Libc
818818
+#
819819
+
820-
+test -d "$COSMO_REPO" || exit 1;
820+
+test -d "$COSMOCC" || exit 1;
821821
+
822822
+usedl='undef'
823823
+usenm='false'
@@ -829,12 +829,11 @@ index 0000000000..e74369d214
829829
+locincpth=''
830830
+loclibpth=''
831831
+glibpth=''
832-
+#cc="/home/sample/repos/cosmocc/bin/x86_64-unknown-cosmo-cc"
833-
+cc="/home/sample/repos/cosmopolitan/cosmocc/bin/x86_64-unknown-cosmo-cc"
832+
+cc="$COSMOCC/bin/x86_64-unknown-cosmo-cc"
834833
+ccflags="-fno-stack-protector -D_COSMO_SOURCE"
835834
+ldflags="-fno-stack-protector"
836835
+libs=''
837-
+unset COSMO_REPO
836+
+unset COSMOCC
838837
diff --git a/lib/.gitignore b/lib/.gitignore
839838
index cb6a26cfcc..8d99235088 100644
840839
--- a/lib/.gitignore

0 commit comments

Comments
 (0)