From 83f48da44cd1df77b6f477c26ed508004d94a2d8 Mon Sep 17 00:00:00 2001 From: Sanko Robinson Date: Mon, 18 Mar 2024 18:11:11 -0400 Subject: [PATCH] broken --- .github/workflows/bsd.yml | 4 +-- .github/workflows/linux.yml | 1 + .github/workflows/macos.yml | 1 + .github/workflows/windows.yml | 1 + .gitignore | 1 + Build.PL | 4 +-- META.json | 7 ++-- builder/xmake.pm | 67 ++++++++++++++++++----------------- cpanfile | 5 ++- lib/Alien/xmake.pm | 62 +++++++++----------------------- share/.hey | 1 - t/00_compile.t | 16 +++++++-- 12 files changed, 77 insertions(+), 93 deletions(-) delete mode 100644 share/.hey diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index a8e9119..05bd699 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -1,7 +1,5 @@ name: BSD - -on: [push] - +on: [push, pull_request, workflow_dispatch] jobs: test: runs-on: ubuntu-latest diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index ba82d2a..af26713 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -4,6 +4,7 @@ jobs: build: runs-on: "${{ matrix.os }}-latest" strategy: + fail-fast: false matrix: os: - ubuntu diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 018335f..d95b66d 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -4,6 +4,7 @@ jobs: build: runs-on: "${{ matrix.os }}-latest" strategy: + fail-fast: false matrix: os: - macos diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 56f17db..a67a105 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -4,6 +4,7 @@ jobs: build: runs-on: "${{ matrix.os }}-latest" strategy: + fail-fast: false matrix: os: - windows diff --git a/.gitignore b/.gitignore index 3097026..0e83579 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ test_cpp share/share share/bin *.session +xmake.* diff --git a/Build.PL b/Build.PL index 0e6991b..f00b71e 100644 --- a/Build.PL +++ b/Build.PL @@ -23,9 +23,7 @@ my %args = ( }, requires => { - 'File::ShareDir' => '0', - 'File::Which' => '0', - 'Module::Build' => '0', + 'Path::Tiny' => '0', 'perl' => '5.020000', }, diff --git a/META.json b/META.json index 6400655..b7f7944 100644 --- a/META.json +++ b/META.json @@ -36,7 +36,8 @@ "File::Temp" : "0", "File::Which" : "0", "HTTP::Tiny" : "0", - "Module::Build" : "0.4005" + "Module::Build" : "0.4005", + "Path::Tiny" : "0" } }, "develop" : { @@ -60,9 +61,7 @@ }, "runtime" : { "requires" : { - "File::ShareDir" : "0", - "File::Which" : "0", - "Module::Build" : "0", + "Path::Tiny" : "0", "perl" : "5.020000" } }, diff --git a/builder/xmake.pm b/builder/xmake.pm index a5d5fee..8535db7 100644 --- a/builder/xmake.pm +++ b/builder/xmake.pm @@ -10,10 +10,9 @@ package builder::xmake { use File::Spec::Functions qw[rel2abs]; use File::Which qw[which]; use Archive::Tar qw[]; - - #~ use File::ShareDir qw[]; + use Path::Tiny qw[path]; # - my $version = '2.8.8'; # Target install version + my $version = '2.8.8'; # Target install version # If false, a complete archive is downloaded (quickly) via http #~ my $installer_sh = 'https://xmake.io/shget.text'; @@ -73,6 +72,8 @@ package builder::xmake { #~ } sub gather_info { my ( $s, $xmake, $xrepo ) = @_; + warn $xmake; + warn $xrepo; $s->config_data( xmake_exe => $xmake ); $s->config_data( xrepo_exe => $xrepo ); $s->config_data( xmake_dir => File::Basename::dirname($xmake) ); @@ -82,21 +83,12 @@ package builder::xmake { $s->config_data( xmake_installed => 1 ); } - sub slurp { - my ( $s, $file ) = @_; - open my $fh, '<', $file or die; - local $/ = undef; - my $cont = <$fh>; - close $fh; - return $cont; - } - # Module::Build subclass sub ACTION_xmake_install { my ($s) = @_; #~ ddx $s->config_data; - return 1 if $s->config_data('xmake_install'); + return $s->config_data('xmake_type') if $s->config_data('xmake_type'); # my $os = $s->os_type; # based on Perl::OSType if ( !defined $os ) { @@ -107,25 +99,30 @@ package builder::xmake { } elsif ( $os eq 'Windows' ) { $s->config_data( xmake_type => 'share' ); + $s->log_info(qq[Downloading $installer_exe...\n]); my $installer = $s->download( $installer_exe, 'xmake_installer.exe' ); - my $dest = File::Spec->rel2abs( - File::Spec->catdir( $s->base_dir, @{ $s->share_dir->{dist} } ) ); - $s->log_info(qq[Running installer [$installer]...\n]); - $s->do_system( $installer, '/NOADMIN', '/S', '/D=' . $dest ); + my $dest = path( $s->base_dir )->child('share'); + $dest->mkdir; + my $cmd = join ' ', $installer, '/NOADMIN', '/S', '/D=share'; + $s->log_info(qq[Running $cmd\n]); + $s->do_system( $cmd ); $s->log_info(qq[Installed to $dest\n]); - push @PATH, $dest; - my $xmake = $s->locate_exe('xmake'); - my $xrepo = $s->locate_exe('xrepo'); + push @PATH, $dest->realpath; + path('.')->visit( sub {print "$_\n"}, {recurse => 1}); + system 'dir', $dest; + #~ my $xmake = $s->locate_exe('xmake'); + #~ my $xrepo = $s->locate_exe('xrepo'); $s->config_data( xmake_type => 'share' ); - $s->gather_info( $xmake, $xrepo ); - $s->config_data( xmake_install => $dest ); + #~ $s->gather_info( $xmake, $xrepo ); + #~ $s->config_data( xmake_install => $dest ); + return 'share' # D:\a\_temp\1aa1c77c-ff7b-41bc-8899-98e4cd421618.exe /NOADMIN /S /D=C:\Users\RUNNER~1\AppData\Local\Temp\xmake-15e5f277191e8a088998d0f797dd1f44b5491e17 #~ $s->warn_info('Windows is on the todo list'); #~ exit 1; } else { - unshift @PATH, 'share/bin'; + #~ unshift @PATH, 'share/bin'; my $xmake = $s->locate_exe('xmake'); my $xrepo = $s->locate_exe('xrepo'); if ($xmake) { @@ -133,15 +130,20 @@ package builder::xmake { } else { $s->build_from_source(); - $xmake = $s->locate_exe('xmake'); - $xrepo = $s->locate_exe('xrepo'); + unshift @PATH, 'share'; # $s->config_data( xmake_type => 'share' ); + return 'share'; } - $s->config_data( xmake_install => $xmake ); + $xmake = $s->locate_exe('xmake'); + $xrepo = $s->locate_exe('xrepo'); $s->gather_info( $xmake, $xrepo ); - return File::Spec->rel2abs($xmake); + + #~ $s->config_data( xmake_install => $xmake ); + #~ return File::Spec->rel2abs($xmake); + return; } + return $s->config_data('xmake_type'); } sub ACTION_code { @@ -241,10 +243,11 @@ package builder::xmake { #brew => 'brew --version', # MacOS #dnf => 'dnf --help', # Fedora, RHEL, OpenSUSE, CentOS ); - warn 'You should probably try running ' . $options{$installer} + $s->log_info( 'You should probably try running ' . $options{$installer} . "\n" ) if defined $options{$installer}; my $prebuilt = install_prebuilt(); - warn 'You could also install a prebuilt version of xmake with ' . $prebuilt + $s->log_info( + 'You could also install a prebuilt version of xmake with ' . $prebuilt . "\n" ) if defined $prebuilt; } @@ -273,7 +276,7 @@ package builder::xmake { my $workdir; my $archive = $s->download( $installer_tar, 'xmake.tar.gz' ); if ( !$archive ) { - warn 'Failed to download source snapshot... Looking for git...'; + $s->log_info('Failed to download source snapshot... Looking for git...'); my $git; for (qw[git]) { if ( system( $_, '--version' ) == 0 ) { @@ -281,9 +284,9 @@ package builder::xmake { last; } } - if ( !$git ) { warn 'Cannot locate git. Giving up'; exit 1; } + if ( !$git ) { $s->log_info('Cannot locate git. Giving up'); exit 1; } my $mirror = get_fast_host(); - CORE::say "Using $mirror mirror..."; + $s->log_info("Using $mirror mirror..."); my ( $gitrepo, $gitrepo_raw ); if ( $mirror eq 'github.com' ) { $gitrepo = 'https://github.com/xmake-io/xmake.git'; diff --git a/cpanfile b/cpanfile index 49c473f..8dc4b15 100644 --- a/cpanfile +++ b/cpanfile @@ -1,7 +1,5 @@ requires 'perl', '5.020000'; -requires 'File::ShareDir'; -requires 'File::Which'; -requires 'Module::Build'; +requires 'Path::Tiny'; on 'test' => sub { requires 'Test2::V0'; requires 'File::Temp'; @@ -15,6 +13,7 @@ on 'configure' => sub { requires 'File::Basename'; requires 'File::Which'; requires 'File::Temp'; + requires 'Path::Tiny'; }; on 'develop' => sub { requires 'CPAN::Uploader'; diff --git a/lib/Alien/xmake.pm b/lib/Alien/xmake.pm index 19036f1..19ff158 100644 --- a/lib/Alien/xmake.pm +++ b/lib/Alien/xmake.pm @@ -1,9 +1,12 @@ package Alien::xmake 0.05 { use strict; use warnings; - use File::Which qw[which]; - use File::ShareDir; - use File::Spec::Functions qw[rel2abs catdir catfile]; + use Path::Tiny qw[path]; + # + my ($dir) = grep {defined} map { + my $path = path($_)->child(qw[auto share dist Alien xmake bin]); + $path->is_dir ? $path : () + } @INC; # sub config { CORE::state $config //= sub { @@ -13,7 +16,7 @@ package Alien::xmake 0.05 { } # TODO: die if running xmake fails... we obviously don't have it installed - { xmake_type => 'system' }; + { xmake_type => 'shared' }; } ->(); $config; @@ -25,57 +28,26 @@ package Alien::xmake 0.05 { sub dynamic_libs { } # Valuable - sub install_type { - CORE::state $type - //= eval { -d rel2abs( catdir( File::ShareDir::dist_dir('Affix-xmake'), 'bin' ) ) } - ? 'share' : - 'system'; - - #config()->{xmake_type} - return $type; - } - - sub bin_dir { - CORE::state $dir - //= eval { rel2abs( catdir( File::ShareDir::dist_dir('Affix-xmake'), 'bin' ) ) }; - return $dir // config()->{xmake_dir}; - } + sub install_type { config()->{xmake_type} } + sub bin_dir { $dir // return; $dir->child('bin'); } sub exe { - CORE::state $exe //= eval { - rel2abs( - catfile( - File::ShareDir::dist_dir('Affix-xmake'), 'bin', - 'xmake' . ( $^O eq 'MSWin32' ? '.exe' : '' ) - ) - ); - }; - return $exe // config()->{xmake_exe}; + $dir // return; + $dir->child( 'bin', 'xmake' . ( $^O eq 'MSWin32' ? '.exe' : '' ) ); } sub xrepo { - CORE::state $exe //= eval { - rel2abs( - catfile( - File::ShareDir::dist_dir('Affix-xmake'), 'bin', - 'xmake' . ( $^O eq 'MSWin32' ? '.exe' : '' ) - ) - ); - }; - return $exe // config()->{xrepo_exe}; + $dir // return; + $dir->child( 'bin', 'xrepo' . ( $^O eq 'MSWin32' ? '.exe' : '' ) ); } sub version { + $dir // return; CORE::state $ver; if ( !defined $ver ) { - if ( config->{xmake_type} eq 'system' ) { - my $xmake = exe(); - my $run = `$xmake --version`; - ($ver) = $run =~ m[xmake (v.+?), A cross-platform build utility based on Lua]; - } - else { - $ver = config()->{xmake_ver}; - } + my $xmake = exe(); + my $run = `$xmake --version`; + ($ver) = $run =~ m[xmake (v.+?), A cross-platform build utility based on Lua]; } $ver; } diff --git a/share/.hey b/share/.hey deleted file mode 100644 index 18832d3..0000000 --- a/share/.hey +++ /dev/null @@ -1 +0,0 @@ -Hello. diff --git a/t/00_compile.t b/t/00_compile.t index b8dfddc..eec802d 100644 --- a/t/00_compile.t +++ b/t/00_compile.t @@ -2,12 +2,24 @@ use strict; use warnings; use lib 'lib', '../blib/lib', '../lib'; use Test2::V0; -use Env qw[@PATH]; + +#~ use Env qw[@PATH]; # use Alien::xmake; + +#~ diag File::ShareDir::dist_dir('Affix-xmake'); +#~ use Data::Dump; +#~ ddx \@INC; +#~ my ($dir) = grep {defined} map {my $path = path($_)->child(qw[auto share dist Alien-xmake]); $path->is_dir ? $path : ()} @INC; +#~ ddx $dir; +#~ ...; +#~ use Path::Tiny qw[path]; +#~ my $path = path $INC{'Alien/xmake.pm'}; +#~ diag $path->parent; # diag 'Install type: ' . Alien::xmake->install_type; -unshift @PATH, Alien::xmake->bin_dir; + +#~ unshift @PATH, Alien::xmake->bin_dir; # subtest xmake => sub { my $exe = Alien::xmake->exe;