2024-12-30 14:10:05 +00:00
|
|
|
#| Utilities for interacting with idris and associated tooling
|
2024-12-30 13:43:26 +00:00
|
|
|
unit module IUtils;
|
|
|
|
|
|
|
|
need IUtils::IDEMode;
|
2024-12-30 14:38:52 +00:00
|
|
|
|
2024-12-31 15:49:13 +00:00
|
|
|
use paths;
|
|
|
|
|
|
|
|
#| Structure representing the root of what idris considers a package directory,
|
|
|
|
#| with the associated ipkg and source files. These can and will overlap within
|
|
|
|
#| the same directory.
|
|
|
|
class PackageInfo {
|
|
|
|
has IO::Path:D $.ipkg is required;
|
|
|
|
has IO::Path:D $.root is required;
|
|
|
|
has IO::Path:D @.sources is required;
|
|
|
|
}
|
|
|
|
|
|
|
|
#| Scan a particular ipkg for its associated sources
|
|
|
|
sub scan-ipkg(IO::Path:D $ipkg --> PackageInfo:D) {
|
|
|
|
my $contents = $ipkg.slurp;
|
|
|
|
my $src-dir =
|
|
|
|
($contents ~~
|
|
|
|
/ 'sourcedir' \h* '=' \h*
|
|
|
|
'"' $<value>=[<-["]>*] '"' /)<value>
|
|
|
|
// "src";
|
|
|
|
|
|
|
|
my IO::Path:D @sources =
|
|
|
|
paths($ipkg.parent.add($src-dir), :file(*.ends-with(".idr"))).map(*.IO);
|
|
|
|
PackageInfo.new(ipkg => $ipkg, root => $ipkg.parent, sources => @sources)
|
|
|
|
}
|
|
|
|
|
2024-12-31 16:25:05 +00:00
|
|
|
# TODO: Add some parsing of pack.toml to locate test packages and associate them
|
|
|
|
# with their source ipkg
|
|
|
|
|
2024-12-31 15:49:13 +00:00
|
|
|
#| Scan $*CWD to locate ipkgs and their associated sources
|
|
|
|
sub scan-packages(--> Array[PackageInfo:D]) is export {
|
|
|
|
my PackageInfo:D @ipkgs =
|
|
|
|
paths(:file(*.ends-with(".ipkg"))).map(*.IO.&scan-ipkg);
|
|
|
|
return @ipkgs;
|
|
|
|
}
|