Alien-Bit

 view release on metacpan or  search on metacpan

alienfile  view on Meta::CPAN

use alienfile;
use strict;
use warnings;

# Define metadata and build requirements
configure {
    requires 'Path::Tiny';
    requires 'File::Copy::Recursive';
    requires 'HTTP::Tiny';
    requires 'Carp';
};

# Always use the share approach (build from source)
# since there's no reliable system package detection
probe sub { 'share' };

share {
    # Import necessary modules
    use Path::Tiny            qw( path );
    use File::Copy::Recursive qw( dircopy fcopy );
    use Carp                  qw( croak );

    # Set source repository information
    my $repo_url =
      'https://github.com/chrisarg/Bit/archive/refs/heads/master.zip';

    # Configure download
    start_url $repo_url;
    plugin 'Download';
    plugin 'Extract' => 'zip';

    # Build configuration
    plugin 'Build::Make';

    build [
        # Standard build process
        ['%{make}'],

        # This builds the test program too
        ['%{make} test'],

        # This builds the benchmark programs
        ['%{make} bench']
    ];

    # Post-build file handling - copy files to staging directory
    after 'build' => sub {
        my ($build) = @_;

        # Determine destination directory
        my $stage_dir  = path( $build->install_prop->{stage} );
        my $source_dir = path( $build->install_prop->{extract} );

        # Create lib and include directories
        my $lib_dir     = $stage_dir->child('lib');
        my $include_dir = $stage_dir->child('include');
        $lib_dir->mkpath;
        $include_dir->mkpath;

        # Copy shared library to lib directory
        my $build_dir = $source_dir->child('build');
        my @libs;

        # Handle different platform library extensions
        if ( $^O eq 'MSWin32' ) {
            @libs = $build_dir->children(qr/\.(dll|lib)$/);
        }
        elsif ( $^O eq 'darwin' ) {
            @libs = $build_dir->children(qr/\.(dylib|a)$/);
        }
        else {
            @libs = $build_dir->children(qr/\.(so|a)$/);
        }

        # Copy each library file
        foreach my $lib (@libs) {
            my $dest = $lib_dir->child( $lib->basename );
            $lib->copy($dest) or croak "Failed to copy $lib to $dest: $!";
            print "Copied library: ", $lib->basename, "\n";
        }

        # Copy test and benchmark executables
        my @executables;
        if ( $^O eq 'MSWin32' ) {
            @executables = $build_dir->children(qr/\.(exe)$/);
        }
        else {
            @executables = grep {
                     -x $_
                  && !-d $_
                  && $_->basename !~ /\.(so|dylib|dll|o|a)$/
            } $build_dir->children;
        }

        foreach my $exe (@executables) {
            my $dest = $lib_dir->child( $exe->basename );



( run in 1.444 second using v1.01-cache-2.11-cpan-df04353d9ac )