BACKUP DE DEBUG
This commit is contained in:
parent
2ca705be70
commit
1a3d07cb90
90
Bakefile
Normal file
90
Bakefile
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
# Définition des variables
|
||||||
|
PACKAGE = fr.monlouyan.bakefile
|
||||||
|
ENTRY = Main
|
||||||
|
BUILDDIR = ./build/
|
||||||
|
DOCDIR = ./doc/
|
||||||
|
CLASSP = ./build
|
||||||
|
MANIFESTPATH = Manifest.MF
|
||||||
|
SOURCEDIR = ./src/
|
||||||
|
TESTDIR = ./tests/
|
||||||
|
|
||||||
|
# Liste des fichiers source et leurs correspondances en .class
|
||||||
|
BAKECLI_CLASS = $(BUILDDIR)fr/monlouyan/bakefile/BakeCLI.class
|
||||||
|
TIMESTAMPMANAGER_CLASS = $(BUILDDIR)fr/monlouyan/bakefile/TimestampManager.class
|
||||||
|
BAKEFILEPARSER_CLASS = $(BUILDDIR)fr/monlouyan/bakefile/BakefileParser.class
|
||||||
|
DEPENDENCYRESOLVER_CLASS = $(BUILDDIR)fr/monlouyan/bakefile/DependencyResolver.class
|
||||||
|
COMMANDEXECUTOR_CLASS = $(BUILDDIR)fr/monlouyan/bakefile/CommandExecutor.class
|
||||||
|
BAKEENGINE_CLASS = $(BUILDDIR)fr/monlouyan/bakefile/BakeEngine.class
|
||||||
|
RULE_CLASS = $(BUILDDIR)fr/monlouyan/bakefile/Rule.class
|
||||||
|
MAIN_CLASS = $(BUILDDIR)fr/monlouyan/bakefile/Main.class
|
||||||
|
|
||||||
|
# Fichiers source
|
||||||
|
BAKECLI_SRC = $(SOURCEDIR)fr/monlouyan/bakefile/BakeCLI.java
|
||||||
|
TIMESTAMPMANAGER_SRC = $(SOURCEDIR)fr/monlouyan/bakefile/TimestampManager.java
|
||||||
|
BAKEFILEPARSER_SRC = $(SOURCEDIR)fr/monlouyan/bakefile/BakefileParser.java
|
||||||
|
DEPENDENCYRESOLVER_SRC = $(SOURCEDIR)fr/monlouyan/bakefile/DependencyResolver.java
|
||||||
|
COMMANDEXECUTOR_SRC = $(SOURCEDIR)fr/monlouyan/bakefile/CommandExecutor.java
|
||||||
|
BAKEENGINE_SRC = $(SOURCEDIR)fr/monlouyan/bakefile/BakeEngine.java
|
||||||
|
RULE_SRC = $(SOURCEDIR)fr/monlouyan/bakefile/Rule.java
|
||||||
|
MAIN_SRC = $(SOURCEDIR)fr/monlouyan/bakefile/Main.java
|
||||||
|
|
||||||
|
# Cible principale
|
||||||
|
all: init $(MAIN_CLASS)
|
||||||
|
|
||||||
|
# Initialiser les répertoires nécessaires
|
||||||
|
init:
|
||||||
|
@mkdir -p $(BUILDDIR)
|
||||||
|
@mkdir -p $(BUILDDIR)fr/monlouyan/bakefile/
|
||||||
|
|
||||||
|
$(MAIN_CLASS): $(MAIN_SRC) $(BAKECLI_CLASS) $(BAKEENGINE_CLASS)
|
||||||
|
@echo "Compilation de $(MAIN_SRC)..."
|
||||||
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $(MAIN_SRC) -Xlint:unchecked -Xlint:deprecation -sourcepath src
|
||||||
|
|
||||||
|
$(RULE_CLASS): $(RULE_SRC) $(BAKECLI_CLASS)
|
||||||
|
@echo "Compilation de $(RULE_SRC)..."
|
||||||
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $(RULE_SRC) -Xlint:unchecked -Xlint:deprecation -sourcepath src
|
||||||
|
|
||||||
|
$(TIMESTAMPMANAGER_CLASS): $(TIMESTAMPMANAGER_SRC)
|
||||||
|
@echo "Compilation de $(TIMESTAMPMANAGER_SRC)..."
|
||||||
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $(TIMESTAMPMANAGER_SRC) -Xlint:unchecked -Xlint:deprecation -sourcepath src
|
||||||
|
|
||||||
|
$(DEPENDENCYRESOLVER_CLASS): $(DEPENDENCYRESOLVER_SRC) $(RULE_CLASS)
|
||||||
|
@echo "Compilation de $(DEPENDENCYRESOLVER_SRC)..."
|
||||||
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $(DEPENDENCYRESOLVER_SRC) -Xlint:unchecked -Xlint:deprecation -sourcepath src
|
||||||
|
|
||||||
|
$(COMMANDEXECUTOR_CLASS): $(COMMANDEXECUTOR_SRC) $(RULE_CLASS) $(TIMESTAMPMANAGER_CLASS)
|
||||||
|
@echo "Compilation de $(COMMANDEXECUTOR_SRC)..."
|
||||||
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $(COMMANDEXECUTOR_SRC) -Xlint:unchecked -Xlint:deprecation -sourcepath src
|
||||||
|
|
||||||
|
$(BAKEFILEPARSER_CLASS): $(BAKEFILEPARSER_SRC) $(RULE_CLASS)
|
||||||
|
@echo "Compilation de $(BAKEFILEPARSER_SRC)..."
|
||||||
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $(BAKEFILEPARSER_SRC) -Xlint:unchecked -Xlint:deprecation -sourcepath src
|
||||||
|
|
||||||
|
$(BAKEENGINE_CLASS): $(BAKEENGINE_SRC) $(BAKEFILEPARSER_CLASS) $(DEPENDENCYRESOLVER_CLASS) $(COMMANDEXECUTOR_CLASS) $(RULE_CLASS) $(BAKECLI_CLASS)
|
||||||
|
@echo "Compilation de $(BAKEENGINE_SRC)..."
|
||||||
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $(BAKEENGINE_SRC) -Xlint:unchecked -Xlint:deprecation -sourcepath src
|
||||||
|
|
||||||
|
$(BAKECLI_CLASS): $(BAKECLI_SRC)
|
||||||
|
@echo "Compilation de $(BAKECLI_SRC)..."
|
||||||
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $(BAKECLI_SRC) -Xlint:unchecked -Xlint:deprecation -sourcepath src
|
||||||
|
|
||||||
|
|
||||||
|
# Génération de la documentation Javadoc
|
||||||
|
javadoc:
|
||||||
|
echo "Génération de la documentation Javadoc..."
|
||||||
|
javadoc -d $(DOCDIR) -sourcepath $(SOURCEDIR) -subpackages $(PACKAGE)
|
||||||
|
echo "Documentation Javadoc générée dans $(DOCDIR)"
|
||||||
|
|
||||||
|
see-javadoc: javadoc
|
||||||
|
echo "Ouverture de la documentation Javadoc sur Firefox..."
|
||||||
|
firefox $(DOCDIR)/index.html
|
||||||
|
|
||||||
|
# Nettoyage des fichiers générés
|
||||||
|
clean:
|
||||||
|
echo "Nettoyage des fichiers générés..."
|
||||||
|
rm -rf $(BUILDDIR)
|
||||||
|
rm -rf $(DOCDIR)
|
||||||
|
echo "Nettoyage terminé."
|
||||||
|
|
||||||
|
# Cibles spéciales
|
||||||
|
.PHONY: all init javadoc clean
|
@ -26,9 +26,10 @@ public class BakefileParser {
|
|||||||
/**
|
/**
|
||||||
* Regex pour détecter les targets et leurs dépendances.
|
* Regex pour détecter les targets et leurs dépendances.
|
||||||
* 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 assure que la ligne ne commence pas par une tabulation
|
||||||
|
* et vérifie que le premier caractère non-espace n'est pas un symbole de commentaire
|
||||||
*/
|
*/
|
||||||
private static final Pattern TARGET_PATTERN = Pattern.compile("^([^:#]+?)\\s*:\\s*([^#]*?)\\s*(?:#.*)?$");
|
private static final Pattern TARGET_PATTERN = Pattern.compile("^([^\\t:#][^:#]+?)\\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.
|
||||||
|
@ -79,6 +79,14 @@ public class DependencyResolver {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignorer les options de compilation qui pourraient avoir été mal interprétées comme des règles
|
||||||
|
if (ruleName.startsWith("-") || ruleName.contains(":")) {
|
||||||
|
if (debug) {
|
||||||
|
System.out.println("Debug: Skipping compiler option: " + ruleName);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Rule rule = ruleMap.get(ruleName);
|
Rule rule = ruleMap.get(ruleName);
|
||||||
if (rule != null) {
|
if (rule != null) {
|
||||||
rulesToBuild.add(rule);
|
rulesToBuild.add(rule);
|
||||||
@ -108,6 +116,12 @@ public class DependencyResolver {
|
|||||||
if (dep.startsWith("~")) {
|
if (dep.startsWith("~")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignorer les options de compilation qui pourraient avoir un ':' dedans
|
||||||
|
if (dep.startsWith("-") || dep.contains(":")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
topologicalSort(dep, processed, buildOrder);
|
topologicalSort(dep, processed, buildOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,6 +162,11 @@ public class DependencyResolver {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignorer les options de compilation qui pourraient avoir un ':' dedans
|
||||||
|
if (dependency.startsWith("-") || dependency.contains(":")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (ruleMap.containsKey(dependency)) {
|
if (ruleMap.containsKey(dependency)) {
|
||||||
detectCycle(dependency, visited, stack, ruleName);
|
detectCycle(dependency, visited, stack, ruleName);
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,12 @@ public class Rule {
|
|||||||
|
|
||||||
File depFile = new File(dependency);
|
File depFile = new File(dependency);
|
||||||
boolean hasRule = BakeEngine.hasRule(dependency);
|
boolean hasRule = BakeEngine.hasRule(dependency);
|
||||||
|
|
||||||
|
// Ignorer les options de compilation qui pourraient avoir un ':' dedans
|
||||||
|
if (dependency.startsWith("-") || dependency.contains(":")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!depFile.exists() && !dependency.isEmpty() && !hasRule) {
|
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(2);
|
System.exit(2);
|
||||||
@ -121,8 +127,8 @@ public class Rule {
|
|||||||
// Si la règle n'a pas de commandes, on vérifie seulement si une dépendance doit être mise à jour
|
// Si la règle n'a pas de commandes, on vérifie seulement si une dépendance doit être mise à jour
|
||||||
if (commands.isEmpty()) {
|
if (commands.isEmpty()) {
|
||||||
for (String dependency : dependencies) {
|
for (String dependency : dependencies) {
|
||||||
// Skip dependencies with tilde in path
|
// Skip dependencies with tilde in path or compiler options
|
||||||
if (dependency.startsWith("~")) {
|
if (dependency.startsWith("~") || dependency.startsWith("-") || dependency.contains(":")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,8 +157,8 @@ public class Rule {
|
|||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
|
|
||||||
for (String dependency : dependencies) {
|
for (String dependency : dependencies) {
|
||||||
// Skip dependencies with tilde in path
|
// Skip dependencies with tilde in path or compiler options
|
||||||
if (dependency.startsWith("~")) {
|
if (dependency.startsWith("~") || dependency.startsWith("-") || dependency.contains(":")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
tests/test-26-rule-in-rule/bake/Bakefile
Normal file
2
tests/test-26-rule-in-rule/bake/Bakefile
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Main.class: Main.java
|
||||||
|
javac Main.java -Xlint:unchecked
|
5
tests/test-26-rule-in-rule/bake/Main.java
Normal file
5
tests/test-26-rule-in-rule/bake/Main.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("Hello, World!");
|
||||||
|
}
|
||||||
|
}
|
5
tests/test-26-rule-in-rule/make/Main.java
Normal file
5
tests/test-26-rule-in-rule/make/Main.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("Hello, World!");
|
||||||
|
}
|
||||||
|
}
|
2
tests/test-26-rule-in-rule/make/Makefile
Normal file
2
tests/test-26-rule-in-rule/make/Makefile
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Main.class: Main.java
|
||||||
|
javac Main.java -Xlint:unchecked
|
Loading…
x
Reference in New Issue
Block a user