Résolution de bug - TEST JAVA -> 01
This commit is contained in:
parent
2a6599c5ae
commit
53ea20ea69
src/fr/monlouyan/bakefile
@ -1,19 +1,33 @@
|
|||||||
package fr.monlouyan.bakefile;
|
package fr.monlouyan.bakefile;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class BakeEngine {
|
public class BakeEngine {
|
||||||
private BakefileParser parser;
|
private BakefileParser parser;
|
||||||
private DependencyResolver resolver;
|
private DependencyResolver resolver;
|
||||||
private CommandExecutor executor;
|
private CommandExecutor executor;
|
||||||
|
private static Map<String, Rule> ruleMap;
|
||||||
|
|
||||||
public BakeEngine() {
|
public BakeEngine() {
|
||||||
this.parser = new BakefileParser("Bakefile");
|
this.parser = new BakefileParser("Bakefile");
|
||||||
this.resolver = new DependencyResolver(BakeCLI.isDebug());
|
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() {
|
public void run() {
|
||||||
List<Rule> rules = parser.parse();
|
List<Rule> rules = parser.parse();
|
||||||
|
|
||||||
|
for (Rule rule : rules) {
|
||||||
|
ruleMap.put(rule.getName(), rule);
|
||||||
|
}
|
||||||
|
|
||||||
List<Rule> rulesToBuild = resolver.resolve(rules, BakeCLI.getTargets());
|
List<Rule> rulesToBuild = resolver.resolve(rules, BakeCLI.getTargets());
|
||||||
this.executor = new CommandExecutor(BakeCLI.isDebug(), resolver.isCircular());
|
this.executor = new CommandExecutor(BakeCLI.isDebug(), resolver.isCircular());
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class BakefileParser {
|
|||||||
if (!Files.exists(Paths.get(filename))) {
|
if (!Files.exists(Paths.get(filename))) {
|
||||||
System.out.println("*** No targets specified and no makefile found. Stop.");
|
System.out.println("*** No targets specified and no makefile found. Stop.");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<String> lines = Files.readAllLines(Paths.get(filename));
|
List<String> lines = Files.readAllLines(Paths.get(filename));
|
||||||
|
@ -113,8 +113,10 @@ public class Rule {
|
|||||||
if (BakeCLI.isDebug()) {
|
if (BakeCLI.isDebug()) {
|
||||||
System.out.println("Debug : Dependency '" + dependency + "' last modified at " + TimestampManager.formatTimestamp(depTimestamp));
|
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.out.println("bake: *** No rule to make target '" + dependency + "', needed by '" + name + "'. Stop.");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user