From: Thomas Walker Lynch Date: Thu, 8 Aug 2024 15:46:21 +0000 (+0000) Subject: moved build environment and script targets from makefile into the shell environment X-Git-Url: https://git.reasoningtechnology.com/usr/lib/python2.7/UserDict.py?a=commitdiff_plain;h=d00ba950a6931b4f3e8ae57776b27b7d836a2d50;p=GQL-to-Cypher moved build environment and script targets from makefile into the shell environment --- diff --git a/developer/executor/clean b/developer/executor/clean new file mode 100755 index 0000000..7561e09 --- /dev/null +++ b/developer/executor/clean @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +# Clean targets: +# +# 1. > clean temp[orary] - removes files from ./temporary except for .githolder +# +# 2. General clean targets: +# +# > clean all # removes all things make built, and thus can be replaced by running make again. +# > clean all- # same as clean:all except not the program files (and their .jar if any) +# > clean program # remove all built ./executor/ and ./jvm/ files +# > clean class # removes the class files +# > clean grammar # removes the generated java grammar files +# +# 3. Specific clean targets: +# +# > clean program # similar to clean:program, but only for the named program +# - clean all # basically clean:all but only for the named program +# - clean all- # basically clean:all- but only for the named program +# - clean grammar - similar to clean:grammar, but only for the named grammar + +# Function to display usage message +display_usage() { + echo "Usage: clean ] | program | grammar | class | temp[orary]>" +} + +# Command parser +clean_command_parser() { + local token_list=($1) + local token_count=${#token_list[@]} + local command=${token_list[0]} + local arg=${token_list[1]} + + if [ "$token_count" -eq 0 ]; then + display_usage + elif [ "$token_count" -eq 1 ]; then + case "$command" in + "temporary" | "temp") + clean_directory "$TEMP_DIR" + ;; + "all") + clean_directory "$TEMP_DIR" + clean_grammar + clean_files "JAVA_COMP_OUT_FPL" + clean_files "PROGRAM_FPL" + ;; + "all-") + clean_directory "$TEMP_DIR" + clean_grammar + clean_files "JAVA_COMP_OUT_PRIMARY_FPL" + ;; + "program") + clean_files "PROGRAM_FPL" + ;; + "class") + clean_files "JAVA_COMP_OUT_FPL" + ;; + "grammar") + clean_grammar + ;; + *) + echo "Unknown clean option: $command" + ;; + esac + elif [ "$token_count" -eq 2 ]; then + case "$command" in + "program") + clean_files "$JAVA_COMP_OUT_DIR/$arg.jar executor/$arg" + ;; + "all") + clean_files "$JAVA_COMP_OUT_DIR/$arg.jar executor/$arg" + clean_directory "$TEMP_DIR" + clean_grammar "$arg" + ;; + "all-") + clean_files "$JAVA_COMP_OUT_DIR/$arg.class $JAVA_COMP_OUT_DIR/$arg.BaseVisitor.class $JAVA_COMP_OUT_DIR/$arg.Visitor.class $JAVA_COMP_OUT_DIR/$arg.Parser.class $JAVA_COMP_OUT_DIR/$arg.Lexer.class" + clean_directory "$TEMP_DIR" + ;; + "grammar") + clean_grammar "$arg" + ;; + *) + echo "Unknown clean command: $command" + ;; + esac + else + echo "Clean commands are at most two tokens, but we found: $token_count" + fi +} + +# Main script logic +if [ $# -eq 0 ]; then + display_usage +else + clean_command_parser "$*" +fi diff --git a/developer/executor/clean_directory b/developer/executor/clean_directory new file mode 100755 index 0000000..ab6abfe --- /dev/null +++ b/developer/executor/clean_directory @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +source /path/to/env.sh + +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 diff --git a/developer/executor/clean_file_list b/developer/executor/clean_file_list new file mode 100755 index 0000000..ec88243 --- /dev/null +++ b/developer/executor/clean_file_list @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +source /path/to/env.sh + +if [ -z "$1" ]; then + echo "Error: File list name is not provided." + exit 1 +fi + +file_list=$(eval echo \$$1) + +if [ -z "$file_list" ]; then + echo "Error: File list $1 is empty or not set." + exit 1 +fi + +echo "Cleaning files: $file_list" +for file in $file_list; do + if [ -e "$file" ]; then + echo rm -f "$file" + rm -f "$file" + fi +done diff --git a/developer/executor/clean_grammar b/developer/executor/clean_grammar new file mode 100755 index 0000000..e343704 --- /dev/null +++ b/developer/executor/clean_grammar @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Check if required variables are set +if [ -z "$ANTLR_GRAMMAR_LIST" ] || [ -z "$ANTLR_OUT_DIR" ]; then + echo "Error: Required environment variables ANTLR_GRAMMAR_LIST or ANTLR_OUT_DIR are not set." + exit 1 +fi + +# Function to delete a specific grammar +delete_grammar() { + local grammar=$1 + if [ -z "$grammar" ]; then + echo "Error: Grammar name is empty" + elif echo "$ANTLR_GRAMMAR_LIST" | grep -qw "$grammar"; then + rm -f "$ANTLR_OUT_DIR/$grammar"* + echo "Deleted files starting with $grammar in $ANTLR_OUT_DIR" + else + echo "Invalid grammar name: $grammar" + fi +} + +# If no argument is given, delete all grammars +if [ -z "$1" ]; then + for grammar in $ANTLR_GRAMMAR_LIST; do + delete_grammar "$grammar" + done +else + delete_grammar "$1" +fi diff --git a/developer/executor/env_build b/developer/executor/env_build new file mode 100755 index 0000000..621fb6b --- /dev/null +++ b/developer/executor/env_build @@ -0,0 +1,108 @@ +#!/usr/bin/env bash + +# Ensure the script is sourced +if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then + echo "This script must be sourced, not executed. Exiting." + return 1 +fi + + +# Note these suffixes: +# _FL = File List +# _FPL = File Path List +# _DL = Directory List + +# _PRIMARY = stuff not built +# _IN things input to some program +# _OUT things output by some program + +#-------------------------------------------------------------------------------- +# tools +# +# set by project manager: JAVA_HOME, ANTLR_JAR, DEVELOPER_HOME +# +export JAVA_COMP="${JAVA_HOME}/bin/javac" +export JAVA_INTERP="${JAVA_HOME}/bin/java" +export JAVA_ARCHIVE="${JAVA_HOME}/bin/jar" +export CLASSPATH="$ANTLR_JAR" + +#-------------------------------------------------------------------------------- +# to be built +# +export PROGRAM_PrintRuleNameList="executor/PrintRuleNameList" +export PROGRAM_SyntaxTree_Test="executor/SyntaxTree_Test" +export PROGRAM_SyntaxTree_20240412="executor/SyntaxTree_20240412" + +# an all programs list +export PROGRAM_FPL="${PROGRAM_PrintRuleNameList} ${PROGRAM_SyntaxTree_Test} ${PROGRAM_SyntaxTree_20240412}" + +#-------------------------------------------------------------------------------- +# misc +# +export TEMP_DIR="$DEVELOPER_HOME"/temporary + +#-------------------------------------------------------------------------------- +# ANTLR environment +# + +# ANTLR directories +export ANTLR_PRIMARY_DIR="ANTLR" +export ANTLR_IN_DIR="${ANTLR_PRIMARY_DIR}" +export ANTLR_OUT_DIR="javac/ANTLR" +export ANTLR_OUT_DIR_PARENT="javac" + +# ANTLR input files +ANTLR_IN_FPL=$(ls ${ANTLR_IN_DIR}/*.g4 2>/dev/null) +export ANTLR_GRAMMAR_LIST=$(basename -s .g4 ${ANTLR_IN_FPL}) +if [ -z "${ANTLR_IN_FPL}" ]; then + echo "No ANTLR input grammar files found" +fi + +# ANTLR will produce these output files. +# +# This function accepts a grammar name, or a grammar name with an extension; +# and sets a variable of the form ANTLR_OUT__FPL to a list of +# files that ANTLR would produce for . +set_ANTLR_out_fpl_var() { + local grammar=$1 + export ANTLR_OUT_${grammar}_FPL="${ANTLR_OUT_DIR}/${grammar}Lexer.java ${ANTLR_OUT_DIR}/${grammar}Parser.java ${ANTLR_OUT_DIR}/${grammar}BaseVisitor.java ${ANTLR_OUT_DIR}/${grammar}Visitor.java" +} + +# Generate ANTLR_OUT__FPL for each grammar +for grammar in ${ANTLR_GRAMMAR_LIST}; do + set_ANTLR_out_fpl_var ${grammar} +done + +# Combine all individual file lists into ANTLR_OUT_FPL +ANTLR_OUT_FPL="" +for grammar in ${ANTLR_GRAMMAR_LIST}; do + ANTLR_OUT_FPL="${ANTLR_OUT_FPL} $(eval echo \$ANTLR_OUT_${grammar}_FPL)" +done +export ANTLR_OUT_FPL + +#-------------------------------------------------------------------------------- +# Java environment +# + +# JAVA directories +export JAVA_COMP_IN_PRIMARY_DIR="javac" +export JAVA_COMP_IN_ANTLR_DIR="${ANTLR_OUT_DIR}" +export JAVA_COMP_IN_DL="${JAVA_COMP_IN_PRIMARY_DIR}:${JAVA_COMP_IN_ANTLR_DIR}" +export JAVA_COMP_OUT_DIR="jvm" + +# JAVA input files +JAVA_COMP_IN_PRIMARY_FPL=$(ls ${JAVA_COMP_IN_PRIMARY_DIR}/*.java 2>/dev/null) +JAVA_COMP_IN_ANTLR_FPL=${ANTLR_OUT_FPL} +export JAVA_COMP_IN_FPL="${JAVA_COMP_IN_PRIMARY_FPL} ${JAVA_COMP_IN_ANTLR_FPL}" + +# JAVA will produce these output files +JAVA_COMP_OUT_PRIMARY_FPL=$(echo ${JAVA_COMP_IN_PRIMARY_FPL} | sed "s|${JAVA_COMP_IN_PRIMARY_DIR}/|${JAVA_COMP_OUT_DIR}/|g" | sed "s|.java|.class|g") +JAVA_COMP_OUT_ANTLR_FPL=$(echo ${JAVA_COMP_IN_ANTLR_FPL} | sed "s|${JAVA_COMP_IN_ANTLR_DIR}/|${JAVA_COMP_OUT_DIR}/|g" | sed "s|.java|.class|g") +export JAVA_COMP_OUT_FPL="${JAVA_COMP_OUT_PRIMARY_FPL} ${JAVA_COMP_OUT_ANTLR_FPL}" + +#-------------------------------------------------------------------------------- +# JVM environment +# +export JVM_IN_DIR="${JAVA_COMP_OUT_DIR}" +export CLASSPATH="${CLASSPATH}:${JVM_IN_DIR}" + diff --git a/developer/executor/make b/developer/executor/make index 34112ba..94e85a0 100755 --- a/developer/executor/make +++ b/developer/executor/make @@ -1,6 +1,6 @@ #!/usr/bin/env bash -cd "$REPO_HOME"/developer || { echo "Failed to change directory to" "$REPO_HOME"/developer; exit 1; } +cd "$DEVELOPER_HOME" || { echo "Failed to change directory to" "$DEVELOPER_HOME"; exit 1; } /usr/bin/make --no-builtin-rules --keep-going $@ diff --git a/developer/makefile b/developer/makefile index 0b6e080..d3258ba 100644 --- a/developer/makefile +++ b/developer/makefile @@ -1,127 +1,18 @@ -# GQL_to_Cypher makefile - -#================================================================================ -# Setup the environment -# -# Use `make variable` to print the value assigned to each variable in this section - -#---------------------------------------- -# some notes about setting variables. Save yourself some grief by reading this. -# - -# Note these suffixes: -# _FL = File List -# _FPL = File Path List -# _DL = Directory List - -# _PRIMARY means these are primary inputs, this makefile does not build them -# _IN program inputs -# _OUT expected program outputs - -# The following is an example of setting a variable. Use `make variable` -# to prints its value, and note the embedded and trailing spaces. -ISLAND := land island - -#-------------------------------------- -# Variables from the evv_dev environment: JAVA_HOME, ANTLR_JAR - -#---------------------------------------- -# programs used by this makefile -# -JAVA_COMP := $(JAVA_HOME)/bin/javac -JAVA_INTERP := $(JAVA_HOME)/bin/java -JAVA_ARCHIVE := $(JAVA_HOME)/bin/jar - -#---------------------------------------- -# programs being built by this makefile: -# -PROGRAM_PrintRuleNameList := executor/PrintRuleNameList -PROGRAM_SyntaxTree_Test := executor/SyntaxTree_Test -PROGRAM_SyntaxTree_20240412 := executor/SyntaxTree_20240412 - -PROGRAM_FPL := $(PROGRAM_PrintRuleNameList) $(PROGRAM_SyntaxTree_Test) $(PROGRAM_SyntaxTree_20240412) - -#---------------------------------------- -# misc -# -TEMP_DIR := temporary - -#---------------------------------------- -# ANTLR environment -# Add a `.g4` file into the ANTLR_IN_DIR - -# ANTLR directories -ANTLR_PRIMARY_DIR := ANTLR -ANTLR_IN_DIR := $(ANTLR_PRIMARY_DIR) -ANTLR_OUT_DIR := javac/ANTLR -ANTLR_OUT_DIR_PARENT := javac - - -# ANTLR input files -ANTLR_IN_FPL := $(wildcard $(ANTLR_IN_DIR)/*.g4) -ANTLR_GRAMMAR_LIST := $(basename $(notdir $(ANTLR_IN_FPL))) -ifeq ($(strip $(ANTLR_IN_FPL)),) - $(info No ANTLR input grammar files found) -endif - -# ANTLR will produce these output files. - -# This function accepts a grammar name, or a grammar name with an extension; -# and sets a variable of the form ANTLR_OUT__FPL to a list of -# files that ANTLR would produce for . -define set_ANTLR_out_fpl_var - ANTLR_OUT_$(basename $1)_FPL := \ - $(ANTLR_OUT_DIR)/$(basename $1)Lexer.java \ - $(ANTLR_OUT_DIR)/$(basename $1)Parser.java \ - $(ANTLR_OUT_DIR)/$(basename $1)BaseVisitor.java \ - $(ANTLR_OUT_DIR)/$(basename $1)Visitor.java -endef - -# Generate ANTLR_OUT__FPL for each grammar -$(foreach file,$(ANTLR_GRAMMAR_LIST),$(eval $(call set_ANTLR_out_fpl_var,$(file)))) - -# Combine all individual file lists into ANTLR_OUT_FPL -ANTLR_OUT_FPL := $(foreach file,$(ANTLR_GRAMMAR_LIST),$(value ANTLR_OUT_$(file)_FPL)) - -#---------------------------------------- -# Java environment - -# JAVA directories -JAVA_COMP_IN_PRIMARY_DIR := javac -JAVA_COMP_IN_ANTLR_DIR := $(ANTLR_OUT_DIR) -JAVA_COMP_IN_DL := $(JAVA_COMP_IN_PRIMARY_DIR):$(JAVA_COMP_IN_ANTLR_DIR) -JAVA_COMP_OUT_DIR := jvm - -# JAVA input files -JAVA_COMP_IN_PRIMARY_FPL := $(wildcard $(JAVA_COMP_IN_PRIMARY_DIR)/*.java) -JAVA_COMP_IN_ANTLR_FPL := $(ANTLR_OUT_FPL) -JAVA_COMP_IN_FPL := $(JAVA_COMP_IN_PRIMARY_FPL) $(JAVA_COMP_IN_ANTLR_FPL) - -# JAVA will produce these output files -JAVA_COMP_OUT_PRIMARY_FPL := $(patsubst $(JAVA_COMP_IN_PRIMARY_DIR)/%.java,$(JAVA_COMP_OUT_DIR)/%.class,$(JAVA_COMP_IN_PRIMARY_FPL)) -JAVA_COMP_OUT_ANTLR_FPL := $(patsubst $(JAVA_COMP_IN_ANTLR_DIR)/%.java,$(JAVA_COMP_OUT_DIR)/%.class,$(JAVA_COMP_IN_ANTLR_FPL)) -JAVA_COMP_OUT_FPL := $(JAVA_COMP_OUT_PRIMARY_FPL) $(JAVA_COMP_OUT_ANTLR_FPL) - -#---------------------------------------- -# JVM environment - -JVM_IN_DIR := $(JAVA_COMP_OUT_DIR) -CLASSPATH := $(CLASSPATH):$(JVM_IN_DIR) -export CLASSPATH - - #================================================================================ # Make targets # -# The general make everything targets: all: setup $(PROGRAM_FPL) + grammar: setup $(ANTLR_OUT_FPL) -# specific programs or program versions: +SyntaxTree_Test: $(ANTLR_OUT_GQL_Test_FPL) + make $(PROGRAM_SyntaxTree_Test) + +SyntaxTree_20240412: $(ANTLR_OUT_GQL_20240412_FPL) + make $(PROGRAM_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 @@ -131,48 +22,6 @@ $(foreach grammar,$(ANTLR_GRAMMAR_LIST),$(eval $(grammar): $(value ANTLR_OUT_$(g # Compile all the .java files. java: setup $(JAVA_COMP_OUT_FPL) -# prints out each variable within quotes so that spaces can be seen -.PHONY: variable -variable: - $(info ISLAND is '$(ISLAND)') - - $(info PROGRAM_PrintRuleNameList is '$(PROGRAM_PrintRuleNameList)') - $(info PROGRAM_SyntaxTree_Test is '$(PROGRAM_SyntaxTree_Test)') - $(info PROGRAM_SyntaxTree_20240412 is '$(PROGRAM_SyntaxTree_20240412)') - $(info PROGRAM_FPL is '$(PROGRAM_FPL)') - - $(info JAVA_COMP is '$(JAVA_COMP)') - $(info JAVA_INTERP is '$(JAVA_INTERP)') - $(info JAVA_ARCHIVE is '$(JAVA_ARCHIVE)') - - $(info TEMP_DIR is '$(TEMP_DIR)') - - $(info ANTLR_PRIMARY_DIR is '$(ANTLR_PRIMARY_DIR)') - $(info ANTLR_IN_DIR is '$(ANTLR_IN_DIR)') - $(info ANTLR_OUT_DIR is '$(ANTLR_OUT_DIR)') - $(info ANTLR_OUT_DIR_PARENT is '$(ANTLR_OUT_DIR_PARENT)') - $(info ANTLR_IN_FPL is '$(ANTLR_IN_FPL)') - $(info ANTLR_GRAMMAR_LIST is '$(ANTLR_GRAMMAR_LIST)') - $(foreach file,$(ANTLR_GRAMMAR_LIST),$(info ANTLR_OUT_$(file)_FPL is '$(value ANTLR_OUT_$(file)_FPL)')) - $(info ANTLR_OUT_FPL is '$(ANTLR_OUT_FPL)') - - $(info JAVA_COMP_IN_PRIMARY_DIR is '$(JAVA_COMP_IN_PRIMARY_DIR)') - $(info JAVA_COMP_IN_ANTLR_DIR is '$(JAVA_COMP_IN_ANTLR_DIR)') - $(info JAVA_COMP_IN_DL is '$(JAVA_COMP_IN_DL)') - $(info JAVA_COMP_OUT_DIR is '$(JAVA_COMP_OUT_DIR)') - - $(info JAVA_COMP_IN_PRIMARY_FPL is '$(JAVA_COMP_IN_PRIMARY_FPL)') - $(info JAVA_COMP_IN_ANTLR_FPL is '$(JAVA_COMP_IN_ANTLR_FPL)') - $(info JAVA_COMP_IN_FPL is '$(JAVA_COMP_IN_FPL)') - - $(info JAVA_COMP_OUT_PRIMARY_FPL is '$(JAVA_COMP_OUT_PRIMARY_FPL)') - $(info JAVA_COMP_OUT_ANTLR_FPL is '$(JAVA_COMP_OUT_ANTLR_FPL)') - $(info JAVA_COMP_OUT_FPL is '$(JAVA_COMP_OUT_FPL)') - - $(info JVM_IN_DIR is '$(JVM_IN_DIR)') - $(info CLASSPATH is '$(CLASSPATH)') - @: - .PHONY: version version: $(info ANTLR_JAR is '$(notdir $(ANTLR_JAR))') @@ -187,148 +36,22 @@ setup: mkdir -p $(ANTLR_IN_DIR) $(JAVA_COMP_IN_PRIMARY_DIR) $(JVM_IN_DIR) mkdir -p executor test deprecated experiment documentation temporary - -# 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 not 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: -# similar 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 - -define clean_command_parser_1 - if [ "$(token)" = "temporary" ]; then \ - $(call clean_directory,$(TEMP_DIR)); \ - elif [ "$(token)" = "temp" ]; then \ - $(call clean_directory,$(TEMP_DIR)); \ - elif [ "$(token)" = "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 [ "$(token)" = "all-" ]; then \ - $(call clean_directory,$(TEMP_DIR)); \ - $(call clean_files,$(ANTLR_OUT_FPL)); \ - $(call clean_files,$(JAVA_COMP_OUT_PRIMARY_FPL)); \ - elif [ "$(token)" = "program" ]; then \ - $(call clean_files,$(PROGRAM_FPL)); \ - elif [ "$(token)" = "class" ]; then \ - $(call clean_files,$(JAVA_COMP_OUT_FPL)); \ - elif [ "$(token)" = "grammar" ]; then \ - $(call clean_files,$(ANTLR_OUT_FPL)); \ - else \ - echo "Unknown clean option: $(token)"; \ - fi -endef - -define clean_command_parser_2 - if [ "$(token)" = "program" ]; then \ - $(call clean_files,$(JAVA_COMP_OUT_DIR)/$(arg).jar executor/$(arg)); \ - elif [ "$(token)" = "program+" ]; then \ - $(call clean_files,$(JAVA_COMP_OUT_DIR)/$(arg).jar executor/$(arg)); \ - $(call clean_directory,$(TEMP_DIR)); \ - $(call clean_files,$(ANTLR_OUT_FPL)); \ - elif [ "$(token)" = "program-" ]; then \ - $(call clean_files,$(JAVA_COMP_OUT_DIR)/$(arg).jar executor/$(arg)); \ - $(call clean_directory,$(TEMP_DIR)); \ - $(call clean_files,$(JAVA_COMP_OUT_PRIMARY_FPL)); \ - elif [ "$(token)" = "grammar" ]; then \ - $(call clean_files,$(ANTLR_OUT_DIR)/$(arg)*); \ - else \ - echo "Unknown clean option: $(token)"; \ - fi -endef - -define clean_command_parser - $(eval token_list := $1) - $(eval token_count := $(words $(token_list))) - $(eval token := $(firstword $(token_list))) - $(eval arg := $(word 2, $(token_list))) - if [ "$(token_count)" -eq 0 ]; then \ - echo "Usage: make clean:< all[-] | program[+/-] | grammar | class | temp[orary] >"; \ - elif [ "$(token_count)" -eq 1 ]; then \ - $(call clean_command_parser_1); \ - elif [ "$(token_count)" -eq 2 ]; then \ - $(call clean_command_parser_2); \ - else \ - echo "Invalid number of tokens: $(token_count)"; \ - fi -endef - -# Clean specific program or option -# Calls the clean_command_parser function with the pattern as an argument -.PHONY: clean\:% -clean\:%: - $(eval token_list := $(subst :, ,$*)) - @$(call clean_command_parser,$(token_list)) - - -# Clean specific program or option -# Calls the clean_command_parser function with the pattern as an argument .PHONY: clean\:% clean\:%: - @$(call clean_command_parser,$(subst :, ,$*)) + clean $(subst :, ,$*)) # Default clean target .PHONY: clean clean: - @echo "Usage: make clean:< all[-] | program[+/-][:] | grammar[:] | class | temp[orary] >" - - + clean #useful for distinguishing initial make error messages and message generated by rules firing nothing: @: - #================================================================================ # recipes - -# ANTLR a run of any of these will make all the files $(ANTLR_OUT_DIR)/%Lexer.java \ $(ANTLR_OUT_DIR)/%Parser.java \ $(ANTLR_OUT_DIR)/%BaseVisitor.java \ @@ -350,17 +73,4 @@ executor/%: $(JAVA_COMP_OUT_DIR)/%.jar 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 diff --git a/executor/env_dev b/executor/env_dev index dddb026..6b1e0fb 100644 --- a/executor/env_dev +++ b/executor/env_dev @@ -12,13 +12,12 @@ if [ -z "$REPO_HOME" ]; then source "${script_path}/env_base" fi -export ANTLR_JAR="$REPO_HOME/tool/executor/antlr-4.11.1-complete.jar" export JAVA_HOME="$REPO_HOME/tool/jdk-22.0.1+8" -export CLASSPATH="$ANTLR_JAR" - -export PATH="$REPO_HOME"/developer/executor:"$REPO_HOME"/tool/executor:"$JAVA_HOME"/bin:"$PATH" +export ANTLR_JAR="$REPO_HOME/tool/executor/antlr-4.11.1-complete.jar" +export DEVELOPER_HOME="$REPO_HOME/developer" -alias ls="ls -a" -cd "$REPO_HOME/developer" +export PATH="$DEVELOPER_HOME"/executor:"$REPO_HOME"/tool/executor:"$JAVA_HOME"/bin:"$PATH" +cd "$DEVELOPER_HOME" +source "$DEVELOPER_HOME"/executor/env_build echo "${BASH_SOURCE[0]}" "complete" diff --git a/executor/env_pm b/executor/env_pm index 332aa8d..d784e3e 100644 --- a/executor/env_pm +++ b/executor/env_pm @@ -15,4 +15,6 @@ fi PATH="$REPO_HOME/executor:$PATH" PROJECT="$PROJECT"_PM +alias ls="ls -a" + echo "${BASH_SOURCE[0]}" "complete"