Alien-xmake

 view release on metacpan or  search on metacpan

builder/xmake.pm  view on Meta::CPAN

            my ($host) = @_;
            my $output = `ping -c 1 -W 1 $host 2>/dev/null`;
            $output =~ /time=([\d.]+)/ if $output;
            return $1 // 65535;
        }

        sub get_fast_host {
            my $gitee_speed  = get_host_speed("gitee.com");
            my $github_speed = get_host_speed("github.com");

            #~ CORE::say "gitee.com mirror took $gitee_speed ms";
            #~ CORE::say "github.com mirror took $github_speed ms";
            if ( $gitee_speed <= $github_speed ) {
                return 'gitee.com';
            }
            else {
                return 'github.com';
            }
        }
        my $cwd        = rel2abs('.');
        my $projectdir = tempdir( CLEANUP => 1 );
        my $workdir;

builder/xmake.pm  view on Meta::CPAN

            warn '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; }
            my $mirror = get_fast_host();
            CORE::say "Using $mirror mirror...";
            my ( $gitrepo, $gitrepo_raw );
            if ( $mirror eq 'github.com' ) {
                $gitrepo = 'https://github.com/xmake-io/xmake.git';

                #$gitrepo_raw='https://github.com/xmake-io/xmake/raw/master';
                $gitrepo_raw = 'https://fastly.jsdelivr.net/gh/xmake-io/xmake@master';
            }
            else {
                $gitrepo     = "https://gitee.com/tboox/xmake.git";
                $gitrepo_raw = "https://gitee.com/tboox/xmake/raw/master";



( run in 4.313 seconds using v1.01-cache-2.11-cpan-483215c6ad5 )