Correction bug test 16
This commit is contained in:
parent
c2ff5983e5
commit
297ceba632
@ -28,7 +28,7 @@ public class BakefileParser {
|
|||||||
* Format : "nom1 nom2 nom3 : dépendance1 dépendance2"
|
* Format : "nom1 nom2 nom3 : dépendance1 dépendance2"
|
||||||
* La nouvelle regex gère plusieurs cibles séparées par des espaces
|
* La nouvelle regex gère plusieurs cibles séparées par des espaces
|
||||||
*/
|
*/
|
||||||
private static final Pattern TARGET_PATTERN = Pattern.compile("^([A-Za-z0-9_.\\-]+(?:\\s+[A-Za-z0-9_.\\-]+)*)\\s*:\\s*([^#]*?)\\s*(?:#.*)?$");
|
private static final Pattern TARGET_PATTERN = Pattern.compile("^([A-Za-z0-9_.\\-\\$\\(\\)\\{\\}]+(?:\\s+[A-Za-z0-9_.\\-\\$\\(\\)\\{\\}]+)*)\\s*:\\s*([^#]*?)\\s*(?:#.*)?$");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regex pour détecter les lignes de commande associées à une target.
|
* Regex pour détecter les lignes de commande associées à une target.
|
||||||
@ -244,20 +244,28 @@ public class BakefileParser {
|
|||||||
List<String> commands = new ArrayList<>();
|
List<String> commands = new ArrayList<>();
|
||||||
List<List<String>> displayCommands = new ArrayList<>();
|
List<List<String>> displayCommands = new ArrayList<>();
|
||||||
|
|
||||||
|
// Variable pour suivre si la ligne précédente était une continuation
|
||||||
|
boolean previousLineContinues = false;
|
||||||
|
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
String line = lines.get(i).replace("\r", "");
|
String line = lines.get(i).replace("\r", "");
|
||||||
|
|
||||||
// Ignorer les lignes vides
|
// Ignorer les lignes vides
|
||||||
if (line.trim().isEmpty()) {
|
if (line.trim().isEmpty()) {
|
||||||
|
previousLineContinues = false; // Réinitialiser le flag de continuation
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gérer les erreurs de format (espaces au lieu de tabulations)
|
// Gérer les erreurs de format (espaces au lieu de tabulations)
|
||||||
if (line.matches("^ +.*$")) {
|
// Mais uniquement si ce n'est pas une continuation de variable
|
||||||
|
if (line.matches("^ +.*$") && !previousLineContinues) {
|
||||||
System.err.println(filename + ":" + (i+1) + ": *** missing separator. Stop.");
|
System.err.println(filename + ":" + (i+1) + ": *** missing separator. Stop.");
|
||||||
System.exit(2);
|
System.exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Vérifier si cette ligne se termine par un backslash (continuation)
|
||||||
|
previousLineContinues = line.trim().endsWith("\\");
|
||||||
|
|
||||||
// Matcher pour les déclarations .PHONY
|
// Matcher pour les déclarations .PHONY
|
||||||
Matcher phonyMatcher = PHONY_PATTERN.matcher(line);
|
Matcher phonyMatcher = PHONY_PATTERN.matcher(line);
|
||||||
if (phonyMatcher.matches()) {
|
if (phonyMatcher.matches()) {
|
||||||
@ -271,9 +279,35 @@ public class BakefileParser {
|
|||||||
if (varMatcher.matches()) {
|
if (varMatcher.matches()) {
|
||||||
String varName = varMatcher.group(1);
|
String varName = varMatcher.group(1);
|
||||||
String varValue = varMatcher.group(2).trim();
|
String varValue = varMatcher.group(2).trim();
|
||||||
|
|
||||||
|
// Vérifier si la ligne se termine par un backslash (continuation)
|
||||||
|
if (varValue.endsWith("\\")) {
|
||||||
|
StringBuilder fullValue = new StringBuilder(varValue.substring(0, varValue.length() - 1).trim());
|
||||||
|
int j = i + 1;
|
||||||
|
|
||||||
|
while (j < lines.size()) {
|
||||||
|
String nextLine = lines.get(j).trim();
|
||||||
|
|
||||||
|
if (nextLine.endsWith("\\")) {
|
||||||
|
fullValue.append(" ").append(nextLine.substring(0, nextLine.length() - 1).trim());
|
||||||
|
j++;
|
||||||
|
} else {
|
||||||
|
fullValue.append(" ").append(nextLine);
|
||||||
|
i = j; // Mettre à jour l'indice principal pour sauter les lignes traitées
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
varValue = fullValue.toString();
|
||||||
|
}
|
||||||
|
|
||||||
// Évaluer les variables référencées dans la valeur
|
// Évaluer les variables référencées dans la valeur
|
||||||
varValue = replaceVariables(varValue);
|
varValue = replaceVariables(varValue);
|
||||||
variables.put(varName, varValue);
|
variables.put(varName, varValue);
|
||||||
|
|
||||||
|
if (BakeCLI.isDebug()) {
|
||||||
|
System.out.println("Debug: Variable defined: " + varName + " = " + varValue);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,8 +335,15 @@ public class BakefileParser {
|
|||||||
|
|
||||||
// Configuration pour les nouvelles cibles
|
// Configuration pour les nouvelles cibles
|
||||||
String targetStr = targetMatcher.group(1);
|
String targetStr = targetMatcher.group(1);
|
||||||
|
if (BakeCLI.isDebug()) {
|
||||||
|
System.out.println("Debug: Raw target(s): " + targetStr);
|
||||||
|
}
|
||||||
currentTargets = splitTargets(targetStr);
|
currentTargets = splitTargets(targetStr);
|
||||||
|
|
||||||
|
if (BakeCLI.isDebug()) {
|
||||||
|
System.out.println("Debug: Resolved targets: " + currentTargets);
|
||||||
|
}
|
||||||
|
|
||||||
String depStr = targetMatcher.group(2);
|
String depStr = targetMatcher.group(2);
|
||||||
dependencies = splitDependencies(depStr);
|
dependencies = splitDependencies(depStr);
|
||||||
commands = new ArrayList<>();
|
commands = new ArrayList<>();
|
||||||
@ -377,6 +418,7 @@ public class BakefileParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (BakeCLI.isDebug()) {
|
if (BakeCLI.isDebug()) {
|
||||||
|
System.out.println("Debug: First target is: " + firstTarget);
|
||||||
System.out.println("Debug: Parsed " + rules.size() + " rules.");
|
System.out.println("Debug: Parsed " + rules.size() + " rules.");
|
||||||
for (Rule rule : rules) {
|
for (Rule rule : rules) {
|
||||||
System.out.println("Debug: Rule: " + rule.getName());
|
System.out.println("Debug: Rule: " + rule.getName());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user