Skip to content

Commit

Permalink
broken
Browse files Browse the repository at this point in the history
  • Loading branch information
sanko committed Mar 18, 2024
1 parent dc15d84 commit 46f66b2
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 88 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/bsd.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: BSD

on: [push]

on: [push, pull_request, workflow_dispatch]
jobs:
test:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ jobs:
build:
runs-on: "${{ matrix.os }}-latest"
strategy:
fail-fast: false
matrix:
os:
- ubuntu
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ jobs:
build:
runs-on: "${{ matrix.os }}-latest"
strategy:
fail-fast: false
matrix:
os:
- macos
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ jobs:
build:
runs-on: "${{ matrix.os }}-latest"
strategy:
fail-fast: false
matrix:
os:
- windows
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ test_cpp
share/share
share/bin
*.session
xmake.*
4 changes: 1 addition & 3 deletions Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ my %args = (
},

requires => {
'File::ShareDir' => '0',
'File::Which' => '0',
'Module::Build' => '0',
'Path::Tiny' => '0',
'perl' => '5.020000',
},

Expand Down
7 changes: 3 additions & 4 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand All @@ -60,9 +61,7 @@
},
"runtime" : {
"requires" : {
"File::ShareDir" : "0",
"File::Which" : "0",
"Module::Build" : "0",
"Path::Tiny" : "0",
"perl" : "5.020000"
}
},
Expand Down
55 changes: 28 additions & 27 deletions builder/xmake.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -73,6 +72,8 @@ package builder::xmake {
#~ }
sub gather_info {
my ( $s, $xmake, $xrepo ) = @_;
warn $xmake;

Check failure on line 75 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.36/strawberry

Use of uninitialized value $xmake in warn

Check failure on line 75 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.36/strawberry

Warning: something's wrong

Check failure on line 75 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.36/default

Use of uninitialized value $xmake in warn

Check failure on line 75 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.36/default

Warning: something's wrong

Check failure on line 75 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.38/strawberry

Use of uninitialized value $xmake in warn

Check failure on line 75 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.38/strawberry

Warning: something's wrong

Check failure on line 75 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.38/default

Use of uninitialized value $xmake in warn

Check failure on line 75 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.38/default

Warning: something's wrong
warn $xrepo;

Check failure on line 76 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.36/strawberry

Use of uninitialized value $xrepo in warn

Check failure on line 76 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.36/strawberry

Warning: something's wrong

Check failure on line 76 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.36/default

Use of uninitialized value $xrepo in warn

Check failure on line 76 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.36/default

Warning: something's wrong

Check failure on line 76 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.38/strawberry

Use of uninitialized value $xrepo in warn

Check failure on line 76 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.38/strawberry

Warning: something's wrong

Check failure on line 76 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.38/default

Use of uninitialized value $xrepo in warn

Check failure on line 76 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.38/default

Warning: something's wrong
$s->config_data( xmake_exe => $xmake );
$s->config_data( xrepo_exe => $xrepo );
$s->config_data( xmake_dir => File::Basename::dirname($xmake) );

Check failure on line 79 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.36/strawberry

fileparse(): need a valid pathname

Check failure on line 79 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.36/default

fileparse(): need a valid pathname

Check failure on line 79 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.38/strawberry

fileparse(): need a valid pathname

Check failure on line 79 in builder/xmake.pm

View workflow job for this annotation

GitHub Actions / windows/5.38/default

fileparse(): need a valid pathname
Expand All @@ -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 ) {
Expand All @@ -107,41 +99,49 @@ 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]);
my $dest = path( $s->base_dir )->child('share');
$dest->mkdir;
$s->log_info(qq[Running $installer /NOADMIN /S /D=$dest...\n]);
$s->do_system( $installer, '/NOADMIN', '/S', '/D=' . $dest );
$s->log_info(qq[Installed to $dest\n]);
push @PATH, $dest;
push @PATH, $dest->child('bin')->realpath;
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 );
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) {
$s->config_data( xmake_type => 'system' );
}
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 {
Expand Down Expand Up @@ -241,10 +241,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;
}

Expand Down Expand Up @@ -273,17 +274,17 @@ 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 ) {
$git = $_;
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';
Expand Down
5 changes: 2 additions & 3 deletions cpanfile
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down
62 changes: 17 additions & 45 deletions lib/Alien/xmake.pm
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion share/.hey

This file was deleted.

16 changes: 14 additions & 2 deletions t/00_compile.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 46f66b2

Please sign in to comment.