128 lines
5.9 KiB
Makefile
128 lines
5.9 KiB
Makefile
# Définition des variables
|
|
PACKAGE = fr.monlouyan.bakefile
|
|
ENTRY = Main
|
|
BUILDDIR = ./build/
|
|
DOCDIR = ./doc/
|
|
JARNAME = bakefile.jar
|
|
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 $(JARNAME) deploy-tests
|
|
|
|
# Initialiser les répertoires nécessaires
|
|
init:
|
|
@echo "Création des répertoires nécessaires..."
|
|
@mkdir -p $(BUILDDIR)
|
|
@mkdir -p $(BUILDDIR)fr/monlouyan/bakefile/
|
|
@echo "Répertoires créés."
|
|
|
|
# ---- Phase 1: Compilation des classes sans dépendances circulaires ----
|
|
phase1: init $(BAKECLI_CLASS) $(TIMESTAMPMANAGER_CLASS)
|
|
|
|
$(BAKECLI_CLASS): $(BAKECLI_SRC)
|
|
@echo "Compilation de BakeCLI.java..."
|
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $< -Xlint:unchecked -Xlint:deprecation
|
|
|
|
$(TIMESTAMPMANAGER_CLASS): $(TIMESTAMPMANAGER_SRC)
|
|
@echo "Compilation de TimestampManager.java..."
|
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $< -Xlint:unchecked -Xlint:deprecation
|
|
|
|
# ---- Phase 2: Création de stubs pour gérer les dépendances circulaires ----
|
|
STUBS_DIR = $(BUILDDIR)stubs/fr/monlouyan/bakefile/
|
|
RULE_STUB = $(STUBS_DIR)Rule.java
|
|
BAKEENGINE_STUB = $(STUBS_DIR)BakeEngine.java
|
|
|
|
stubs: phase1
|
|
@echo "Création des stubs pour les classes avec dépendances circulaires..."
|
|
@mkdir -p $(STUBS_DIR)
|
|
@echo "package fr.monlouyan.bakefile; public class Rule { private String name; private java.util.List<String> dependencies; private java.util.List<String> commands; private boolean isPhony; public Rule(String name, java.util.List<String> dependencies, java.util.List<String> commands, boolean isPhony) { this.name = name; this.dependencies = dependencies; this.commands = commands; this.isPhony = isPhony; } public String getName() { return name; } public java.util.List<String> getDependencies() { return dependencies; } public java.util.List<String> getCommands() { return commands; } public boolean isPhony() { return isPhony; } public boolean needsUpdate() { return false; } public boolean isEmpty() { return dependencies.isEmpty() && commands.isEmpty(); } }" > $(RULE_STUB)
|
|
@echo "package fr.monlouyan.bakefile; public class BakeEngine { public void run() {} public static boolean hasRule(String target) { return false; } public static Rule getRule(String target) { return null; } }" > $(BAKEENGINE_STUB)
|
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $(STUBS_DIR)*.java
|
|
@echo "Stubs créés."
|
|
|
|
# ---- Phase 3: Compilation des classes avec stubs pour résoudre les dépendances circulaires ----
|
|
phase3: stubs $(BAKEFILEPARSER_CLASS) $(DEPENDENCYRESOLVER_CLASS) $(COMMANDEXECUTOR_CLASS)
|
|
|
|
$(BAKEFILEPARSER_CLASS): $(BAKEFILEPARSER_SRC)
|
|
@echo "Compilation de BakefileParser.java avec stubs..."
|
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $< -Xlint:unchecked -Xlint:deprecation
|
|
|
|
$(DEPENDENCYRESOLVER_CLASS): $(DEPENDENCYRESOLVER_SRC)
|
|
@echo "Compilation de DependencyResolver.java avec stubs..."
|
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $< -Xlint:unchecked -Xlint:deprecation
|
|
|
|
$(COMMANDEXECUTOR_CLASS): $(COMMANDEXECUTOR_SRC)
|
|
@echo "Compilation de CommandExecutor.java avec stubs..."
|
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $< -Xlint:unchecked -Xlint:deprecation
|
|
|
|
# ---- Phase 4: Compilation finale des classes avec dépendances circulaires ----
|
|
phase4: phase3 $(BAKEENGINE_CLASS) $(RULE_CLASS) $(MAIN_CLASS)
|
|
|
|
$(BAKEENGINE_CLASS): $(BAKEENGINE_SRC)
|
|
@echo "Compilation finale de BakeEngine.java..."
|
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $< -Xlint:unchecked -Xlint:deprecation
|
|
|
|
$(RULE_CLASS): $(RULE_SRC)
|
|
@echo "Compilation finale de Rule.java..."
|
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $< -Xlint:unchecked -Xlint:deprecation
|
|
|
|
$(MAIN_CLASS): $(MAIN_SRC)
|
|
@echo "Compilation de Main.java..."
|
|
@javac -cp $(CLASSP) -d $(BUILDDIR) $< -Xlint:unchecked -Xlint:deprecation
|
|
|
|
# Création du fichier JAR (dépend de phase4 pour s'assurer que tout est compilé)
|
|
$(JARNAME): phase4
|
|
@echo "Création du fichier JAR..."
|
|
@jar cfm $(JARNAME) $(MANIFESTPATH) -C $(BUILDDIR) fr/monlouyan/bakefile
|
|
@echo "Fichier JAR créé : $(JARNAME)"
|
|
|
|
# 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
|
|
|
|
# Déploiement du JAR dans les répertoires de test
|
|
deploy-tests: $(JARNAME)
|
|
@echo "Déploiement du JAR dans les répertoires de test..."
|
|
@find $(TESTDIR) -type d -name 'bake' -exec cp $(JARNAME) {} \;
|
|
@echo "Déploiement terminé."
|
|
|
|
# Nettoyage des fichiers générés
|
|
clean:
|
|
@echo "Nettoyage des fichiers générés..."
|
|
@rm -rf $(BUILDDIR)
|
|
@rm -rf $(DOCDIR)
|
|
@rm -f $(JARNAME)
|
|
@find $(TESTDIR) -name "$(JARNAME)" -delete
|
|
@echo "Nettoyage terminé."
|
|
|
|
# Cibles spéciales
|
|
.PHONY: all init phase1 stubs phase3 phase4 javadoc deploy-tests clean |