File Coverage

alienfile
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1 1     1   294528 use alienfile;
  1         5  
  1         10  
2 1     1   233 use Path::Tiny qw( path );
  1         2  
  1         61  
3 1     1   9 use Config;
  1         2  
  1         919  
4              
5             # DuckDB's latest version
6             my $version = '1.3.0';
7              
8             # Determine platform-specific settings
9             my $os = $^O;
10             my $arch = $Config{archname} =~ /aarch64|arm64/ ? 'aarch64' : 'amd64';
11              
12             # Map OS to DuckDB's naming convention
13             my $os_name =
14             $os eq 'darwin' ? 'osx' :
15             $os eq 'MSWin32' ? 'windows' :
16             'linux';
17              
18             # Special case for macOS which uses universal binaries
19             my $pkg_name = $os eq 'darwin'
20             ? "libduckdb-osx-universal.zip"
21             : "libduckdb-$os_name-$arch.zip";
22              
23             probe sub {
24             my($build) = @_;
25            
26             # Check for libduckdb in common system paths
27             my @paths = qw( /usr/lib /usr/local/lib );
28             foreach my $path (@paths) {
29             if (-f "$path/libduckdb.so" || -f "$path/libduckdb.dylib" || -f "$path/duckdb.dll") {
30             return 'system';
31             }
32             }
33             return;
34             };
35              
36             share {
37             # Download the binary
38             start_url "https://github.com/duckdb/duckdb/releases/download/v${version}/${pkg_name}";
39             plugin Download => (
40             version => qr/([0-9\.]+)/,
41             );
42              
43             # Extract the binary
44             plugin Extract => 'zip';
45              
46             # No build required for pre-built binaries
47             build sub {
48             my($build) = @_;
49             my $prefix = $build->install_prop->{prefix};
50            
51             # Create necessary directories
52             path($prefix, 'lib')->mkpath;
53             path($prefix, 'include')->mkpath;
54            
55             # Move library files to the right place
56             if($os eq 'MSWin32') {
57             path('duckdb.dll')->copy(path($prefix, 'lib', 'duckdb.dll'));
58             } elsif($os eq 'darwin') {
59             path('libduckdb.dylib')->copy(path($prefix, 'lib', 'libduckdb.dylib'));
60             } else {
61             path('libduckdb.so')->copy(path($prefix, 'lib', 'libduckdb.so'));
62             }
63            
64             # Move header files
65             for my $header (path('.')->children(qr/\.h$/)) {
66             $header->copy(path($prefix, 'include', $header->basename));
67             }
68             };
69              
70             # Gather installed files
71             gather sub {
72             my($build) = @_;
73             $build->runtime_prop->{$_} = 1 for qw( shared_library );
74             };
75             };