Skip to content

Instantly share code, notes, and snippets.

@zengargoyle
Created November 14, 2015 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zengargoyle/a46a59f140d3c90b2cb7 to your computer and use it in GitHub Desktop.
Save zengargoyle/a46a59f140d3c90b2cb7 to your computer and use it in GitHub Desktop.
library searching
use LibraryMake;
use LibraryCheck;
sub find-library( Str:D $library, :$version ) {
my $so = get-vars('')<SO>;
return $library if $so eq '.dll'; # Windows?
return $library ~ $so if library-exists( $library ~ $so );
if $version.defined {
return $library ~ $so ~ ".$version"
if library-exists( $library ~ $so ~ ".$version");
}
fail "Could not find library for $library";
}
sub library { find-library('libfoo', '1') }
# ... is native(&library) ...
#
sub MAIN('test', $library, $version = Str) {
say find-library($library, :$version);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment