From: Thomas Walker Lynch Date: Tue, 29 Oct 2024 12:02:06 +0000 (+0000) Subject: replaces bespoke/env with more robust "where is this script" functions X-Git-Url: https://git.reasoningtechnology.com/style/static/git-logo.png?a=commitdiff_plain;h=688dacea5c4f6e22d399da9f4d6a4c77d27c3749;p=Mosaic replaces bespoke/env with more robust "where is this script" functions --- diff --git a/developer/javac/Mosaic.java b/developer/javac/Mosaic.java index adc43c4..d20baae 100644 --- a/developer/javac/Mosaic.java +++ b/developer/javac/Mosaic.java @@ -1,4 +1,4 @@ -package com.ReasoningTechnology.Mosaic.Test; +package com.ReasoningTechnology.Mosaic; import com.ReasoningTechnology.Mosaic.Util; /* diff --git a/developer/javac/Util.java b/developer/javac/Util.java index 9e15eee..45f2a53 100644 --- a/developer/javac/Util.java +++ b/developer/javac/Util.java @@ -12,20 +12,19 @@ import java.time.format.DateTimeFormatter; public class Util{ - // typically used to gather results before a return + // Typically used to gather conditions before returning a test result. + // As this is used for testing, and an empty conditions list is unusual, + // returns false for an empty conditions list. public static boolean all(boolean[] conditions){ - for( boolean condition : conditions ){ - if( !condition ){ - return false; - } - } + if( conditions.length == 0 ) return false; + for(boolean condition : conditions) if(!condition) return false; return true; } public static void all_set_false(boolean[] conditions){ - for( boolean condition : conditions ) condition = false; + for(boolean condition : conditions) condition = false; } public static void all_set_true(boolean[] conditions){ - for( boolean condition : conditions ) condition = true; + for(boolean condition : conditions) condition = true; } public static String iso_utc_time(){ diff --git a/developer/scratch_pad/.gitignore b/developer/scratch_pad/.gitignore deleted file mode 100644 index 120f485..0000000 --- a/developer/scratch_pad/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!/.gitignore diff --git a/developer/scratchpad/.gitignore b/developer/scratchpad/.gitignore new file mode 100644 index 0000000..120f485 --- /dev/null +++ b/developer/scratchpad/.gitignore @@ -0,0 +1,2 @@ +* +!/.gitignore diff --git a/developer/shell/Mosaic b/developer/shell/Mosaic deleted file mode 100755 index ba5b241..0000000 --- a/developer/shell/Mosaic +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -java com.ReasoningTechnology."Mosaic".Mosaic diff --git a/developer/tool/#release# b/developer/tool/#release# deleted file mode 100755 index 9ca9125..0000000 --- a/developer/tool/#release# +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash - -# input guards - - if [ -z "$REPO_HOME" ]; then - echo "$(script_fp):: REPO_HOME is not set." - exit 1 - fi - - env_must_be="developer/tool/env" - if [ "$ENV" != "$env_must_be" ]; then - echo "$(script_fp):: error: must be run in the $env_must_be environment" - exit 1 - fi - -# script local environment - - release_dir="$REPO_HOME/release" - shell_dir="$REPO_HOME/developer/shell" - project_jar_fp="$REPO_HOME/developer/jvm/"$PROJECT".jar" - wrapper=$(shell_wrapper_list) - - - if [ ! -d "$release_dir" ]; then - mkdir -p "$release_dir" - fi - - # Function to copy and set permissions - install_file() { - source_fp="$1" - target_dp="$2" - perms="$3" - - target_file="$target_dp/$(basename "$source_fp")" - - if [ ! -f "$source_fp" ]; then - echo "install_file:: Source file '$source_fp' does not exist." - return 1 - fi - - if ! install -m "$perms" "$source_fp" "$target_file"; then - echo "Error: Failed to install $(basename "$source_fp") to $target_dp" - exit 1 - else - echo "Installed $(basename "$source_fp") to $target_dp with permissions $perms" - fi - } - -# do the release - - echo "Starting release process..." - - # Install the JAR file - install_file "$project_jar_fp" "$release_dir" "ug+r" - - # Install shell wrappers - for wrapper in $wrapper; do - install_file "$shell_dir/$wrapper" "$release_dir" "ug+r+x" - done - -echo "$(script_fp) done." diff --git a/developer/tool/clean_build_directories b/developer/tool/clean_build_directories index 5165c3a..8990e26 100755 --- a/developer/tool/clean_build_directories +++ b/developer/tool/clean_build_directories @@ -15,7 +15,7 @@ # remove files set -x cd "$REPO_HOME"/developer - rm -r scratch_pad/* + rm -r scratchpad/* rm jvm/* rm shell/* set +x diff --git a/developer/tool/clean_javac_output b/developer/tool/clean_javac_output index 88d8f3d..1f94c43 100755 --- a/developer/tool/clean_javac_output +++ b/developer/tool/clean_javac_output @@ -11,7 +11,7 @@ # remove files set -x cd "$REPO_HOME"/developer - rm -r scratch_pad/com/ReasoningTechnology/"$PROJECT" + rm -r scratchpad/com/ReasoningTechnology/"$PROJECT" set +x echo "$(script_fn) done." diff --git a/developer/tool/clean_make_output b/developer/tool/clean_make_output index 2a3acd5..af7c00a 100755 --- a/developer/tool/clean_make_output +++ b/developer/tool/clean_make_output @@ -17,7 +17,7 @@ set -x cd "$REPO_HOME"/developer - rm -r scratch_pad/com/ReasoningTechnology/"$PROJECT" + rm -r scratchpad/com/ReasoningTechnology/"$PROJECT" rm jvm/"$PROJECT".jar rm shell/{$wrapper} set +x diff --git a/developer/tool/clean_release b/developer/tool/clean_release index fc31cde..ec10d91 100755 --- a/developer/tool/clean_release +++ b/developer/tool/clean_release @@ -17,7 +17,7 @@ # remove files set -x cd "$REPO_HOME"/developer - rm -r scratch_pad/com/ReasoningTechnology/"$PROJECT" + rm -r scratchpad/com/ReasoningTechnology/"$PROJECT" rm jvm/"$PROJECT".jar rm shell/{$wrapper} rm -f "$release_dir"/"$PROJECT".jar diff --git a/developer/tool/distribute_source b/developer/tool/distribute_source new file mode 100755 index 0000000..003dd3d --- /dev/null +++ b/developer/tool/distribute_source @@ -0,0 +1,31 @@ +#!/bin/env bash + +# This script links the sources into the directory tree in parallel to the package. + +# Input guards + + env_must_be="developer/tool/env" + if [ "$ENV" != "$env_must_be" ]; then + echo "$(script_fp):: error: must be run in the $env_must_be environment" + exit 1 + fi + + cd "$REPO_HOME"/developer + +# Link sources into the package tree + + package_tree="scratchpad/com/ReasoningTechnology/$PROJECT" + mkdir -p "$package_tree" + echo "Package: $package_tree" + + echo -n "Linking:" + for source_file in javac/*.java; do + echo -n " $(basename "$source_file")" + link_target="$package_tree/$(basename "$source_file")" + if [ ! -L "$link_target" ]; then + ln -s "$(realpath --relative-to="$package_tree" "$source_file")" "$link_target" + fi + done + echo "." + +echo "$(script_fp) done." diff --git a/developer/tool/make b/developer/tool/make index 92e3ba2..16b477b 100755 --- a/developer/tool/make +++ b/developer/tool/make @@ -12,7 +12,7 @@ echo "Compiling files..." set -x - javac -d scratch_pad javac/*.java + javac -g -d scratchpad javac/*.java set +x if [ $? -ne 0 ]; then echo "Compilation failed." @@ -23,7 +23,7 @@ echo "Creating JAR file..." set -x jar_file=jvm/"$PROJECT".jar mkdir -p jvm - jar cf $jar_file -C scratch_pad . + jar cf $jar_file -C scratchpad . set +x if [ $? -eq 0 ]; then echo "JAR file created successfully: $jar_file" diff --git a/developer/tool/release b/developer/tool/release index 8129f15..9ca9125 100755 --- a/developer/tool/release +++ b/developer/tool/release @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # input guards diff --git a/document/directory_naming.html b/document/directory_naming.html index 64ab608..f5ee0a0 100644 --- a/document/directory_naming.html +++ b/document/directory_naming.html @@ -92,13 +92,13 @@
  • document/ Documentation on developing and building the project.
  • javac/ Java source files for compilation.
  • jvm/ Compiled Java bytecode files for the project, typically a jar for a Java project.
  • -
  • scratch_pad/ Temporary storage typically for intermediate files created during build.
  • +
  • scratchpad/ Temporary storage typically for intermediate files created during build.
  • shell/ Shell scripts intended to be part of the project release. (These are not tools.)
  • tool/ Tools created by the developer, used for development tasks.
  • document/ General documentation about the project.
  • release/ Release candidate for testing. Becomes the release on the release branch.
  • -
  • scratch_pad/ Temporary storage for project administration tasks.
  • +
  • scratchpad/ Temporary storage for project administration tasks.
  • tester/ Workspace for the tester. Has the test bench, tests, and test scripts.