diff --git a/src/fr/monlouyan/bakefile/BakeEngine.java b/src/fr/monlouyan/bakefile/BakeEngine.java index e0bc724..be1f436 100644 --- a/src/fr/monlouyan/bakefile/BakeEngine.java +++ b/src/fr/monlouyan/bakefile/BakeEngine.java @@ -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()); diff --git a/src/fr/monlouyan/bakefile/BakefileParser.java b/src/fr/monlouyan/bakefile/BakefileParser.java index 61bf21d..1757752 100644 --- a/src/fr/monlouyan/bakefile/BakefileParser.java +++ b/src/fr/monlouyan/bakefile/BakefileParser.java @@ -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)); diff --git a/src/fr/monlouyan/bakefile/Rule.java b/src/fr/monlouyan/bakefile/Rule.java index a3218c2..84ebae2 100644 --- a/src/fr/monlouyan/bakefile/Rule.java +++ b/src/fr/monlouyan/bakefile/Rule.java @@ -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); }