From 8c2c57c545f7d8422a9f7069ff8cac6afa3bfd31 Mon Sep 17 00:00:00 2001 From: Thomas Walker Lynch Date: Mon, 5 Aug 2024 14:49:00 +0000 Subject: [PATCH] copmiled PrintBuildNameList --- developer/{ => deprecated}/build.gradle | 0 developer/deprecated/makefil_clean | 105 ++++++++++++++++++++++++ developer/executor/PrintRuleNameList | 2 + developer/executor/make | 2 +- developer/makefile | 27 ++++-- 5 files changed, 129 insertions(+), 7 deletions(-) rename developer/{ => deprecated}/build.gradle (100%) create mode 100644 developer/deprecated/makefil_clean create mode 100755 developer/executor/PrintRuleNameList diff --git a/developer/build.gradle b/developer/deprecated/build.gradle similarity index 100% rename from developer/build.gradle rename to developer/deprecated/build.gradle diff --git a/developer/deprecated/makefil_clean b/developer/deprecated/makefil_clean new file mode 100644 index 0000000..7cc647e --- /dev/null +++ b/developer/deprecated/makefil_clean @@ -0,0 +1,105 @@ +# 1. clean:temporary - removes files from ./temporary +# 2. General clean targets: +# clean:all - removes all things make built, and thus can be replaced by running make again. +# clean:all- (minus after the all) same as clean:all except for the program files (and their .jar if any) +# clean:program - all program files, i.e. ./exector/ and ./jvm/ for all programs. +# clean:class - class files +# clean:grammar - all generated grammar files + +# 2. +# clean:program: +# similear to clean:program, but only for the named program + +# clean:program+: +# bascially clean:all but only for the named program + +# clean:program-: +# baiscally clean:all- but only for the named program + +# 3. clean:grammar: +# siimilar to clean:grammar, but only for the named grammar + +# Function to clean a list of files +# Accepts a list of files as an argument and deletes the files in the list +# without complaining if a file is not found +define clean_files + echo "Cleaning files: $1";\ + for file in $1; do \ + if [ -e "$$file" ]; then \ + echo rm -f "$$file"; \ + rm -f "$$file"; \ + fi; \ + done +endef + + +# Function to clean the contents of a directory +# Accepts a directory as an argument, checks that the argument is not empty, +# ensures the directory exists, and then deletes the contents of the directory +# (excluding a file called .githolder) +define clean_directory + if [ -z "$1" ]; then \ + echo "Error: Directory argument is empty"; \ + elif [ ! -d "$1" ]; then \ + echo "Error: Directory $1 does not exist"; \ + else \ + : echo "Cleaning directory: $1"; \ + find "$1" -mindepth 1 -maxdepth 1 ! -name '.githolder' -exec rm -rf {} +; \ + touch "$1/.githolder"; \ + fi +endef + +# Function to handle individual cleaning +# Accepts a single option and removes the appropriate files +define do_clean + echo "Cleaning files for option: $1";\ + if [ "$1" = "" ]; then \ + echo "Usage: make clean:< all[-] | program[+/-][:] | grammar[:] | class | temp[orary] >"; \ + elif [ "$1" = "temporary" -o "$1" = "temp" ]; then \ + $(call clean_directory,$(TEMP_DIR)); \ + elif [ "$1" = "all" ]; then \ + $(call clean_directory,$(TEMP_DIR)); \ + $(call clean_files,$(ANTLR_OUT_FPL)); \ + $(call clean_files,$(JAVA_COMP_OUT_FPL)); \ + $(call clean_files,$(PROGRAM_FPL)); \ + elif [ "$1" = "all-" ]; then \ + $(call clean_directory,$(TEMP_DIR)); \ + $(call clean_files,$(ANTLR_OUT_FPL)); \ + $(call clean_files,$(JAVA_COMP_OUT_PRIMARY_FPL)); \ + elif [ "$1" = "program" ]; then \ + $(call clean_files,$(PROGRAM_FPL)); \ + elif [ "$1" = "class" ]; then \ + $(call clean_files,$(JAVA_COMP_OUT_FPL)); \ + elif [ "$1" = "grammar" ]; then \ + $(call clean_files,$(ANTLR_OUT_FPL)); \ + elif [ "$1" = "program:"* ]; then \ + program_name=$${1#program:}; \ + $(call clean_files,$(JAVA_COMP_OUT_DIR)/$${program_name}.jar executor/$${program_name}); \ + elif [ "$1" = "program+:"* ]; then \ + program_name=$${1#program+:}; \ + $(call clean_files,$(JAVA_COMP_OUT_DIR)/$${program_name}.jar executor/$${program_name}); \ + $(call clean_directory,$(TEMP_DIR)); \ + $(call clean_files,$(ANTLR_OUT_FPL)); \ + elif [ "$1" = "program-:"* ]; then \ + program_name=$${1#program-:}; \ + $(call clean_files,$(JAVA_COMP_OUT_DIR)/$${program_name}.jar executor/$${program_name}); \ + $(call clean_directory,$(TEMP_DIR)); \ + $(call clean_files,$(JAVA_COMP_OUT_PRIMARY_FPL)); \ + elif [ "$1" = "grammar:"* ]; then \ + grammar_name=$${1#grammar:}; \ + $(call clean_files,$(ANTLR_OUT_DIR)/$${grammar_name}*); \ + else \ + echo "Unknown clean option: $1"; \ + fi +endef + +# Default clean target +.PHONY: clean +clean: + @echo "Usage: make clean:< all[-] | program[+/-][:] | grammar[:] | class | temp[orary] >" + +# Clean specific program or option +# Calls the do_clean function with the pattern as an argument +.PHONY: clean\:% +clean\:%: + @$(call do_clean,$*) diff --git a/developer/executor/PrintRuleNameList b/developer/executor/PrintRuleNameList new file mode 100755 index 0000000..9114f23 --- /dev/null +++ b/developer/executor/PrintRuleNameList @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/java -cp jvm/PrintRuleNameList.jar PrintRuleNameList diff --git a/developer/executor/make b/developer/executor/make index 2902fcf..34112ba 100755 --- a/developer/executor/make +++ b/developer/executor/make @@ -2,5 +2,5 @@ cd "$REPO_HOME"/developer || { echo "Failed to change directory to" "$REPO_HOME"/developer; exit 1; } -/usr/bin/make -k $@ +/usr/bin/make --no-builtin-rules --keep-going $@ diff --git a/developer/makefile b/developer/makefile index 8b2ccb2..a7c70f9 100644 --- a/developer/makefile +++ b/developer/makefile @@ -119,9 +119,9 @@ all: setup $(PROGRAM_FPL) grammar: setup $(ANTLR_OUT_FPL) # specific programs or program versions: -PrintRuleNameList: $(PrintRuleNameList) -SyntaxTree_Test: $(ANTLR_OUT_SyntaxTree_Test_FPL) $(SyntaxTree_Test) -SyntaxTree_20240412: $(ANTLR_OUT_SyntaxTree_20240412_FPL) $(SyntaxTree_20240412) +PrintRuleNameList: $(PROGRAM_PrintRuleNameList) +SyntaxTree_Test: $(ANTLR_OUT_SyntaxTree_Test_FPL) $(PROGRAM_SyntaxTree_Test) +SyntaxTree_20240412: $(ANTLR_OUT_SyntaxTree_20240412_FPL) $(PROGRAM_SyntaxTree_20240412) # Specific grammar targets. Run them like this: # > make @@ -213,7 +213,7 @@ setup: # Accepts a list of files as an argument and deletes the files in the list # without complaining if a file is not found define clean_files - @echo "Cleaning files: $1";\ + echo "Cleaning files: $1";\ for file in $1; do \ if [ -e "$$file" ]; then \ echo rm -f "$$file"; \ @@ -311,16 +311,31 @@ $(ANTLR_OUT_DIR)/%Visitor.java: $(ANTLR_IN_DIR)/%.g4 @echo "making grammar from:" $< $(JAVA_INTERP) -jar $(ANTLR_JAR) -Dlanguage=Java -visitor -o $(ANTLR_OUT_DIR_PARENT) $< -# Generic recipe for building .jar files and placing scripts in the executor directory $(JAVA_COMP_OUT_DIR)/%.jar: $(JAVA_COMP_IN_PRIMARY_DIR)/%.java @echo "Building $*..." $(JAVA_COMP) -d $(JAVA_COMP_OUT_DIR) -sourcepath $(JAVA_COMP_IN_DL) $< $(JAVA_ARCHIVE) cf $@ -C $(JVM_IN_DIR) $*.class + @echo "Created $@" +.PRECIOUS: $(JAVA_COMP_OUT_DIR)/%.jar executor/%: $(JAVA_COMP_OUT_DIR)/%.jar @echo "Creating script for $*..." - echo "#!/usr/bin/env bash\n$(JAVA_INTERP) -cp $@ $*" > executor/$* + @echo "#!/usr/bin/env bash" > executor/$* + @echo "$(JAVA_INTERP) -cp $< $*" >> executor/$* chmod +x executor/$* + @echo "Created script executor/$*" + +# # Generic recipe for building .jar files and placing scripts in the executor directory +# $(JAVA_COMP_OUT_DIR)/%.jar: $(JAVA_COMP_IN_PRIMARY_DIR)/%.java +# @echo "Building $*..." +# $(JAVA_COMP) -d $(JAVA_COMP_OUT_DIR) -sourcepath $(JAVA_COMP_IN_DL) $< +# $(JAVA_ARCHIVE) cf $@ -C $(JVM_IN_DIR) $*.class + +# executor/%: $(JAVA_COMP_OUT_DIR)/%.jar +# @echo "Creating script for $*..." +# @echo "#!/usr/bin/env bash" > executor/$* +# @echo "$(JAVA_INTERP) -cp $< $*" >> executor/$* +# chmod +x executor/$* # LocalWords: makefile -- 2.20.1