Résolution de bug - TEST JAVA -> 01

This commit is contained in:
Yanis HAMOUDI 2025-02-06 20:49:12 +01:00
parent 2a6599c5ae
commit 53ea20ea69
3 changed files with 19 additions and 3 deletions

@ -1,19 +1,33 @@
package fr.monlouyan.bakefile;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class BakeEngine {
private BakefileParser parser;
private DependencyResolver resolver;
private CommandExecutor executor;
private static Map<String, Rule> ruleMap;
public BakeEngine() {
this.parser = new BakefileParser("Bakefile");
this.resolver = new DependencyResolver(BakeCLI.isDebug());
ruleMap = new HashMap<>();
}
public static boolean hasRule(String target) {
// Vérifie si une règle existe pour créer cette cible
return ruleMap.containsKey(target);
}
public void run() {
List<Rule> rules = parser.parse();
for (Rule rule : rules) {
ruleMap.put(rule.getName(), rule);
}
List<Rule> rulesToBuild = resolver.resolve(rules, BakeCLI.getTargets());
this.executor = new CommandExecutor(BakeCLI.isDebug(), resolver.isCircular());

@ -54,7 +54,7 @@ public class BakefileParser {
if (!Files.exists(Paths.get(filename))) {
System.out.println("*** No targets specified and no makefile found. Stop.");
System.exit(1);
}
}
try {
List<String> lines = Files.readAllLines(Paths.get(filename));

@ -113,8 +113,10 @@ public class Rule {
if (BakeCLI.isDebug()) {
System.out.println("Debug : Dependency '" + dependency + "' last modified at " + TimestampManager.formatTimestamp(depTimestamp));
}
if (!depFile.exists() && !dependency.isEmpty()) {
boolean hasRule = BakeEngine.hasRule(dependency);
if (!depFile.exists() && !dependency.isEmpty() && !hasRule) {
System.out.println("bake: *** No rule to make target '" + dependency + "', needed by '" + name + "'. Stop.");
System.exit(1);
}