commit 1fb6b4b77253ad1de121bd7b25addec53c87f092
parent b45f002c8d2b26f949208982aa6b683d117592b2
Author: Drew DeVault <sir@cmpwn.com>
Date: Fri, 2 Apr 2021 17:45:21 -0400
hare::module: clean up candidate selection
This might be a bit weird. We may want to change the rules a bit on the
empty basename so that it never conflicts.
+linux/
+x86_64/
These should both be included. But, so should both of these:
+linux+x86_64/
+x86_64/
This only applies to the empty name, though. For the named file:
foo+linux.ha
foo+x86_64.ha
This should be incompatible, raising an error, but for this:
foo+linux+x86_64.ha
foo+x86_64.ha
The former should win.
Diffstat:
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/hare/module/scan.ha b/hare/module/scan.ha
@@ -152,6 +152,8 @@ fn scan_directory(
// as the build input and the other two files are discarded.
//
// TODO: Improve the documentation which describes this algorithm
+ // TODO: Loosen requirements for empty basename, and make non-empty
+ // basename conflict on an equal number of tags
for (let i = 0z; i < len(dirs); i += 1) {
let name = dirs[i];
@@ -175,13 +177,18 @@ fn scan_directory(
if (inputs[j].1 != base) {
continue;
};
- if (len(inputs[j].2) < len(tags)) {
+ let theirs = inputs[j].2;
+ if (len(theirs) < len(tags)) {
free(inputs[j].1);
tags_free(inputs[j].2);
free(inputs[j].3);
inputs[j] = tuple;
superceeded = true;
break;
+ } else if (len(theirs) > len(tags)) {
+ // They are more specific
+ superceeded = true;
+ break;
};
};
if (!superceeded) {
@@ -214,7 +221,8 @@ fn scan_directory(
if (inputs[j].1 != base) {
continue;
};
- if (len(inputs[j].2) < len(tags)) {
+ let theirs = inputs[j].2;
+ if (len(theirs) < len(tags)) {
// We are more specific
free(inputs[j].1);
tags_free(inputs[j].2);
@@ -222,12 +230,10 @@ fn scan_directory(
inputs[j] = tuple;
superceeded = true;
break;
- } else if (len(inputs[j].2) > len(tags)) {
+ } else if (len(theirs) > len(tags)) {
// They are more specific
superceeded = true;
break;
- } else {
- abort(); // TODO
};
};
if (!superceeded) {