From: Thomas Walker Lynch Date: Tue, 15 Oct 2024 15:17:54 +0000 (+0000) Subject: rearranging for block testing X-Git-Url: https://git.reasoningtechnology.com/style/static/gitweb.js?a=commitdiff_plain;h=92580145b23e70ecc6e563bd4460e52a26e98813;p=Ariadne rearranging for block testing --- diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index e177f6f..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,152 +0,0 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that -entity. For the purposes of this definition, "control" means (i) the power, -direct or indirect, to cause the direction or management of such entity, whether -by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of -the outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of this -License, each Contributor hereby grants to You a perpetual, worldwide, -non-exclusive, no-charge, royalty-free, irrevocable copyright license to -reproduce, prepare Derivative Works of, publicly display, publicly perform, -sublicense, and distribute the Work and such Derivative Works in Source or -Object form. - -3. Grant of Patent License. Subject to the terms and conditions of this License, -each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) patent -license to make, have made, use, offer to sell, sell, import, and otherwise -transfer the Work, where such license applies only to those patent claims -licensable by such Contributor that are necessarily infringed by their -Contribution(s) alone or by combination of their Contribution(s) with the Work -to which such Contribution(s) was submitted. If You institute patent litigation -against any entity (including a cross-claim or counterclaim in a lawsuit) -alleging that the Work or a Contribution incorporated within the Work -constitutes direct or contributory patent infringement, then any patent licenses -granted to You under this License for that Work shall terminate as of the date -such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the Work or -Derivative Works thereof in any medium, with or without modifications, and in -Source or Object form, provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and You must cause any modified files to carry prominent notices -stating that You changed the files; and You must retain, in the Source form of -any Derivative Works that You distribute, all copyright, patent, trademark, and -attribution notices from the Source form of the Work, excluding those notices -that do not pertain to any part of the Derivative Works; and If the Work -includes a "NOTICE" text file as part of its distribution, then any Derivative -Works that You distribute must include a readable copy of the attribution -notices contained within such NOTICE file, excluding those notices that do not -pertain to any part of the Derivative Works, in at least one of the following -places: within a NOTICE text file distributed as part of the Derivative Works; -within the Source form or documentation, if provided along with the Derivative -Works; or, within a display generated by the Derivative Works, if and wherever -such third-party notices normally appear. The contents of the NOTICE file are -for informational purposes only and do not modify the License. You may add Your -own attribution notices within Derivative Works that You distribute, alongside -or as an addendum to the NOTICE text from the Work, provided that such -additional attribution notices cannot be construed as modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, any -Contribution intentionally submitted for inclusion in the Work by You to the -Licensor shall be under the terms and conditions of this License, without any -additional terms or conditions. Notwithstanding the above, nothing herein shall -supersede or modify the terms of any separate license agreement you may have -executed with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade names, -trademarks, service marks, or product names of the Licensor, except as required -for reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed to in -writing, Licensor provides the Work (and each Contributor provides its -Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied, including, without limitation, any warranties -or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A -PARTICULAR PURPOSE. You are solely responsible for determining the -appropriateness of using or redistributing the Work and assume any risks -associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, whether in -tort (including negligence), contract, or otherwise, unless required by -applicable law (such as deliberate and grossly negligent acts) or agreed to in -writing, shall any Contributor be liable to You for damages, including any -direct, indirect, special, incidental, or consequential damages of any character -arising as a result of this License or out of the use or inability to use the -Work (including but not limited to damages for loss of goodwill, work stoppage, -computer failure or malfunction, or any and all other commercial damages or -losses), even if such Contributor has been advised of the possibility of such -damages. - -9. Accepting Warranty or Additional Liability. While redistributing the Work or -Derivative Works thereof, You may choose to offer, and charge a fee for, -acceptance of support, warranty, indemnity, or other liability obligations -and/or rights consistent with this License. However, in accepting such -obligations, You may act only on Your own behalf and on Your sole -responsibility, not on behalf of any other Contributor, and only if You agree to -indemnify, defend, and hold each Contributor harmless for any liability incurred -by, or claims asserted against, such Contributor by reason of your accepting any -such warranty or additional liability. - -END OF TERMS AND CONDITIONS diff --git a/LICENSE.txt b/LICENSE.txt new file mode 120000 index 0000000..98f0753 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1 @@ +document/license.txt \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 991e4ee..0000000 --- a/README.md +++ /dev/null @@ -1,19 +0,0 @@ -Ariadne feared for the life of Theseus, who she had fallen in love with, because -he was to enter the maze designed by Daedalus. She saved him by giving him -a ball of string. - -Building experimental code for GQL_to_Cypher has proven to be as complex as -navigating Daedalus's maze. As it turns out, `make` does not -backward-chain pattern rules. Gradle/Groovy tends to build projects in -layers. - -To use the Ariadne build tool, a developer writes their dependency graph in -Groovy, utilizing a map and a set of regular expression matching -functions. Then, to build or clean up the project, the developer invokes -Ariadne. - -Ariadne was originally written in Groovy because it evolved incrementally as -part of a Gradle script. - - - diff --git a/README.txt b/README.txt new file mode 120000 index 0000000..06fa5f4 --- /dev/null +++ b/README.txt @@ -0,0 +1 @@ +document/readme.txt \ No newline at end of file diff --git a/developer/javac/Build.java b/developer/javac/Build.java deleted file mode 100644 index b0cdab3..0000000 --- a/developer/javac/Build.java +++ /dev/null @@ -1,76 +0,0 @@ -import java.util.List; - -public class Build { - - // Function to load the graph class dynamically - public static Class includeAClass(String aClassFp) { - ClassLoader classLoader = Build.class.getClassLoader(); - String className = aClassFp.replace('/', '.').replace(".class", ""); - try { - return classLoader.loadClass(className); - } catch (Exception e) { - System.out.println("Error loading class '" + className + "': " + e.getMessage()); - return null; - } - } - - // Build function - public static void build(String graphDefinitionFp, List rootNodeLabels) { - // Print summary of what we are doing - System.out.println("build:: Building targets for graph '" + graphDefinitionFp + ".class'"); - if (rootNodeLabels.isEmpty()) { - System.out.println("No build targets specified. Please provide root node labels to build."); - System.exit(0); - } - System.out.println("Building targets: " + String.join(", ", rootNodeLabels)); - - // Load the dependency graph class from arg[1] - Class graphDefinitionClass = includeAClass(graphDefinitionFp); - if (graphDefinitionClass != null) { - System.out.println("build:: loaded " + graphDefinitionFp + ".class"); - } else { - System.out.println("build:: failed to load " + graphDefinitionFp + ".class"); - System.exit(1); - } - - // Get the node_map and node_f_list from the graph class - // Assuming these methods are static and return the appropriate types - // Replace with actual method calls if they are different - Object nodeMap = null; - Object nodeFList = null; - try { - nodeMap = graphDefinitionClass.getMethod("getNodeMap").invoke(null); - nodeFList = graphDefinitionClass.getMethod("getNodeFList").invoke(null); - } catch (Exception e) { - System.out.println("Error invoking methods on graphDefinitionClass: " + e.getMessage()); - System.exit(1); - } - System.out.println("node_map: " + nodeMap); - System.out.println("node_f_list: " + nodeFList); - - // Create an instance of AriadneGraph, and run the build scripts - // Assuming AriadneGraph has a constructor that takes nodeMap and nodeFList - // Replace with actual constructor call if it is different - try { - Class ariadneGraphClass = Class.forName("AriadneGraph"); - Object graph = ariadneGraphClass.getConstructor(nodeMap.getClass(), nodeFList.getClass()).newInstance(nodeMap, nodeFList); - ariadneGraphClass.getMethod("runBuildScriptsF", List.class).invoke(graph, rootNodeLabels); - } catch (Exception e) { - System.out.println("Error creating or invoking AriadneGraph: " + e.getMessage()); - System.exit(1); - } - } - - // Entry point when run as a script - public static void main(String[] args) { - if (args.length == 0) { - System.out.println("Usage: ./build [root_node_labels...]"); - System.exit(1); - } - - // Get graph definition file and root node labels - String graphDefinitionFp = args[0]; - List rootNodeLabels = args.length > 1 ? List.of(args).subList(1, args.length) : List.of(); - build(graphDefinitionFp, rootNodeLabels); - } -} diff --git a/developer/javac/Build.javax b/developer/javac/Build.javax new file mode 100644 index 0000000..b0cdab3 --- /dev/null +++ b/developer/javac/Build.javax @@ -0,0 +1,76 @@ +import java.util.List; + +public class Build { + + // Function to load the graph class dynamically + public static Class includeAClass(String aClassFp) { + ClassLoader classLoader = Build.class.getClassLoader(); + String className = aClassFp.replace('/', '.').replace(".class", ""); + try { + return classLoader.loadClass(className); + } catch (Exception e) { + System.out.println("Error loading class '" + className + "': " + e.getMessage()); + return null; + } + } + + // Build function + public static void build(String graphDefinitionFp, List rootNodeLabels) { + // Print summary of what we are doing + System.out.println("build:: Building targets for graph '" + graphDefinitionFp + ".class'"); + if (rootNodeLabels.isEmpty()) { + System.out.println("No build targets specified. Please provide root node labels to build."); + System.exit(0); + } + System.out.println("Building targets: " + String.join(", ", rootNodeLabels)); + + // Load the dependency graph class from arg[1] + Class graphDefinitionClass = includeAClass(graphDefinitionFp); + if (graphDefinitionClass != null) { + System.out.println("build:: loaded " + graphDefinitionFp + ".class"); + } else { + System.out.println("build:: failed to load " + graphDefinitionFp + ".class"); + System.exit(1); + } + + // Get the node_map and node_f_list from the graph class + // Assuming these methods are static and return the appropriate types + // Replace with actual method calls if they are different + Object nodeMap = null; + Object nodeFList = null; + try { + nodeMap = graphDefinitionClass.getMethod("getNodeMap").invoke(null); + nodeFList = graphDefinitionClass.getMethod("getNodeFList").invoke(null); + } catch (Exception e) { + System.out.println("Error invoking methods on graphDefinitionClass: " + e.getMessage()); + System.exit(1); + } + System.out.println("node_map: " + nodeMap); + System.out.println("node_f_list: " + nodeFList); + + // Create an instance of AriadneGraph, and run the build scripts + // Assuming AriadneGraph has a constructor that takes nodeMap and nodeFList + // Replace with actual constructor call if it is different + try { + Class ariadneGraphClass = Class.forName("AriadneGraph"); + Object graph = ariadneGraphClass.getConstructor(nodeMap.getClass(), nodeFList.getClass()).newInstance(nodeMap, nodeFList); + ariadneGraphClass.getMethod("runBuildScriptsF", List.class).invoke(graph, rootNodeLabels); + } catch (Exception e) { + System.out.println("Error creating or invoking AriadneGraph: " + e.getMessage()); + System.exit(1); + } + } + + // Entry point when run as a script + public static void main(String[] args) { + if (args.length == 0) { + System.out.println("Usage: ./build [root_node_labels...]"); + System.exit(1); + } + + // Get graph definition file and root node labels + String graphDefinitionFp = args[0]; + List rootNodeLabels = args.length > 1 ? List.of(args).subList(1, args.length) : List.of(); + build(graphDefinitionFp, rootNodeLabels); + } +} diff --git a/developer/javac/File.java b/developer/javac/File.java index d3cd0b4..b101ea8 100644 --- a/developer/javac/File.java +++ b/developer/javac/File.java @@ -1,4 +1,4 @@ -package Ariadne; +package com.ReasoningTechnology.Ariadne; import java.io.*; import java.nio.file.*; diff --git a/developer/shell/build b/developer/shell/build new file mode 100755 index 0000000..f4d3bbc --- /dev/null +++ b/developer/shell/build @@ -0,0 +1,2 @@ +#!/bin/bash +java com/ReasoningTechnology/Ariadne/build diff --git a/developer/tool/clean_build_directories b/developer/tool/clean_build_directories new file mode 100755 index 0000000..ed9e807 --- /dev/null +++ b/developer/tool/clean_build_directories @@ -0,0 +1,24 @@ +#!/bin/bash + +# Removes all files found in the build directories. It asks no questions as to +# how or why the files got there. Be especially careful with the 'shell' directory +# if you added scripts to it for release with the project they will be deleted. +# consider adding a `shell-leaf` directory instead of adding scripts to `shell`. + +# 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 + +# remove files + set -x + cd "$REPO_HOME"/developer + rm -r scratch_pad/* + rm jvm/* + rm shell/* + set +x + +echo "$(script_fn) done." + diff --git a/developer/tool/clean_javac b/developer/tool/clean_javac deleted file mode 100755 index 58109d4..0000000 --- a/developer/tool/clean_javac +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# remove all files created by make's call to `javac` - -script_name=$(basename ${BASH_SOURCE[0]}) -if [ -z "$REPO_HOME" ]; then - echo "$script_name:: REPO_HOME is not set." - exit 1 -fi -if [ -z "$ENV_DEVELOPER_LOCAL" ]; then - echo "release:: ENV_DEV_BUILD is not set." - exit 1 -fi - -set -x -cd "$REPO_HOME"/developer -rm -rf scratch_pad/* -set +x - -echo "$script_name done." diff --git a/developer/tool/clean_javac_output b/developer/tool/clean_javac_output new file mode 100755 index 0000000..57e64c1 --- /dev/null +++ b/developer/tool/clean_javac_output @@ -0,0 +1,17 @@ +#!/bin/bash +# remove all files created by make's call to `javac` + +# 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 + +# remove files + set -x + cd "$REPO_HOME"/developer + rm -r scratch_pad/com/ReasoningTechnology/Ariadne + set +x + +echo "$(script_fn) done." diff --git a/developer/tool/clean_make b/developer/tool/clean_make index fbdec11..3d8bceb 100755 --- a/developer/tool/clean_make +++ b/developer/tool/clean_make @@ -1,27 +1,25 @@ #!/bin/bash # remove all files made by `make` -script_name=$(basename ${BASH_SOURCE[0]}) -error=false -if [ -z "$REPO_HOME" ]; then - echo "$script_name:: REPO_HOME is not set." - error=true -fi -if [ -z "$ENV_DEVELOPER_LOCAL" ]; then - echo "$script_name:: ENV_DEV_BUILD is not set." - error=true -fi -if [ error ]; then - exit 1 -fi +# input guards -wrapper=build + 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 -set -x -cd "$REPO_HOME"/developer -rm -rf scratch_pad/* -rm -f jvm/Ariadne.jar -rm -f shell/{$wrapper} -set +x +# wrappers to clean (this list space separated list will grow) -echo "$script_name done." + wrapper=build + +# remove files + + set -x + cd "$REPO_HOME"/developer + rm -r scratch_pad/com/ReasoningTechnology/Ariadne + rm jvm/Ariadne.jar + rm shell/{$wrapper} + set +x + +echo "$(script_fn) done." diff --git a/developer/tool/clean_release b/developer/tool/clean_release index c358078..f5b59c7 100755 --- a/developer/tool/clean_release +++ b/developer/tool/clean_release @@ -1,31 +1,28 @@ #!/bin/bash -# remove file made by `make` and by `release` +# remove files made by `make` and by `release` -script_name=$(basename ${BASH_SOURCE[0]}) -error=false -if [ -z "$REPO_HOME" ]; then - echo "$script_name:: REPO_HOME is not set." - error=true -fi -if [ -z "$ENV_DEVELOPER_LOCAL" ]; then - echo "$script_name:: ENV_DEV_BUILD is not set." - error=true -fi -if [ error ]; then - exit 1 -fi +# input guards -# Define release directory -release_dir="$REPO_HOME"/release_candidate -wrapper=build + 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 -set -x -cd "$REPO_HOME"/developer -rm -rf scratch_pad/* -rm -f jvm/Ariadne.jar -rm -f shell/"$wrapper" -rm -f "$release_dir"/Ariadne.jar -rm -f "$release_dir"/{$wrapper} -set +x +# things to clean + + release_dir="$REPO_HOME"/release + wrapper=build + +# remove files + set -x + cd "$REPO_HOME"/developer + rm -r scratch_pad/com/ReasoningTechnology/Ariadne + rm jvm/Ariadne.jar + rm shell/{$wrapper} + rm -f "$release_dir"/Ariadne.jar + rm -f "$release_dir"/{$wrapper} + set +x + +echo "$(script_fn) done." -echo "$script_name done." diff --git a/developer/tool/env b/developer/tool/env index 3b03a8f..3321c60 100644 --- a/developer/tool/env +++ b/developer/tool/env @@ -1,32 +1,27 @@ #!/usr/bin/env bash -## input guards +# input guards -# instead of bailing, we will go fetch what we need -env_should_be="tool_shared/bespoke/env" -if [ "$ENV" != "$env_should_be" ]; then - source "$REPO_HOME"/"$env_should_be" -fi + env_must_be="tool_shared/bespoke/env" + if [ "$ENV" != "$env_must_be" ]; then + echo "$(script_fp):: error: must be run in the $env_must_be environment" + exit 1 + fi -if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then - echo "$script_name:: This script must be sourced, not executed." - exit 1 -fi + if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then + echo "$script_name:: This script must be sourced, not executed." + exit 1 + fi -## so we can do the build - -cd "$REPO_HOME"/developer/ - -export ENV=$(script_fp) -export PROJECT="$PROJECT"_developer +# so we can do the build export PATH=\ "$REPO_HOME"/developer/tool/\ :"$REPO_HOME"/tool_shared/bespoke/\ -"$JAVA_HOME"/bin\ +:"$JAVA_HOME"/bin\ :"$PATH" -## so we can run locally the stuff we built, +# so we can run the stuff we built locally. export CLASSPATH=\ "$REPO_HOME"/developer/jvm\ @@ -38,13 +33,17 @@ export PATH=\ "$REPO_HOME"/developer/shell\ :"$PATH" -## misc +# misc -# make .githolder and .gitignore visible -alias ls="ls -a" + # make .githolder and .gitignore visible + alias ls="ls -a" -echo "$ENV complete." +# some feedback to show all went well + export PROJECT="$PROJECT"_developer + export ENV=$(script_fp) + echo ENV "$ENV" + cd "$REPO_HOME"/developer/ diff --git a/developer/tool/make b/developer/tool/make index a345dd9..a8a9022 100755 --- a/developer/tool/make +++ b/developer/tool/make @@ -1,48 +1,49 @@ #!/bin/env bash -script_name=$(basename ${BASH_SOURCE[0]}) -if [ -z "$ENV_DEVELOPER_LOCAL" ]; then - echo "$script_name:: script can only be run from the developer environment" - return 1 -fi +# input guards -# work from the developer directory -cd "$REPO_HOME"/developer + 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 -echo "Compiling files..." -javac -d scratch_pad javac/*.java + cd "$REPO_HOME"/developer -if [ $? -ne 0 ]; then - echo "Compilation failed." - exit 1 -fi +echo "Compiling files..." + set -x + javac -d scratch_pad javac/*.java + set +x + if [ $? -ne 0 ]; then + echo "Compilation failed." + exit 1 + fi echo "Creating JAR file..." -jar_file=jvm/Ariadne.jar -mkdir -p jvm -jar cf $jar_file -C scratch_pad . - -if [ $? -eq 0 ]; then - echo "JAR file created successfully: $jar_file" -else - echo "Failed to create JAR file." - exit 1 -fi - -# for these to run, the jar file must be in the CLASSPATH -echo "Creating shell wrappers..." -mkdir -p shell + set -x + jar_file=jvm/Ariadne.jar + mkdir -p jvm + jar cf $jar_file -C scratch_pad . + set +x + if [ $? -eq 0 ]; then + echo "JAR file created successfully: $jar_file" + else + echo "Failed to create JAR file." + exit 1 + fi -wrapper=build -for file in $wrapper;do +echo "Creating shell wrappers..." + mkdir -p shell + wrapper=build + for file in $wrapper;do -cat > shell/$file << EOL + cat > shell/$file << EOL #!/bin/bash java com/ReasoningTechnology/Ariadne/$file EOL -chmod +x shell/$file + chmod +x shell/$file done -echo "$script_name done." +echo "$(script_fp) done." diff --git a/developer/tool/release b/developer/tool/release index 2675ba9..b6b9dbd 100755 --- a/developer/tool/release +++ b/developer/tool/release @@ -1,56 +1,61 @@ #!/bin/bash -script_name=$(basename ${BASH_SOURCE[0]}) -if [ -z "$REPO_HOME" ]; then - echo "$script_name:: REPO_HOME is not set." - exit 1 -fi - -if [ -z "$ENV_LOCAL_DEVELOPER" ]; then - echo "$script_name:: ENV_DEV_BUILD is not set." - exit 1 -fi - -release_dir="$REPO_HOME/release" -shell_dir="$REPO_HOME/developer/shell" -Ariadne_jar_fp="$REPO_HOME/developer/jvm/Ariadne.jar" -wrapper=build - - - -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 +# input guards + + if [ -z "$REPO_HOME" ]; then + echo "$(script_fp):: REPO_HOME is not set." + exit 1 fi - if ! install -m "$perms" "$source_fp" "$target_file"; then - echo "Error: Failed to install $(basename "$source_fp") to $target_dp" + 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 - else - echo "Installed $(basename "$source_fp") to $target_dp with permissions $perms" fi -} + +# script local environment + + release_dir="$REPO_HOME/release" + shell_dir="$REPO_HOME/developer/shell" + Ariadne_jar_fp="$REPO_HOME/developer/jvm/Ariadne.jar" + wrapper=build + + + 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 + } -echo "Starting release process..." +# do the release + + echo "Starting release process..." -# Install the JAR file -install_file "$Ariadne_jar_fp" "$release_dir" "ug+r" + # Install the JAR file + install_file "$Ariadne_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 + # Install shell wrappers + for wrapper in $wrapper; do + install_file "$shell_dir/$wrapper" "$release_dir" "ug+r+x" + done -echo "$script_name done." +echo "$(script_fp) done." diff --git a/document/license.txt b/document/license.txt new file mode 100644 index 0000000..e177f6f --- /dev/null +++ b/document/license.txt @@ -0,0 +1,152 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that +entity. For the purposes of this definition, "control" means (i) the power, +direct or indirect, to cause the direction or management of such entity, whether +by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of +the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this +License, each Contributor hereby grants to You a perpetual, worldwide, +non-exclusive, no-charge, royalty-free, irrevocable copyright license to +reproduce, prepare Derivative Works of, publicly display, publicly perform, +sublicense, and distribute the Work and such Derivative Works in Source or +Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, +each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) patent +license to make, have made, use, offer to sell, sell, import, and otherwise +transfer the Work, where such license applies only to those patent claims +licensable by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) with the Work +to which such Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Work or a Contribution incorporated within the Work +constitutes direct or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate as of the date +such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or +Derivative Works thereof in any medium, with or without modifications, and in +Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and You must cause any modified files to carry prominent notices +stating that You changed the files; and You must retain, in the Source form of +any Derivative Works that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, excluding those notices +that do not pertain to any part of the Derivative Works; and If the Work +includes a "NOTICE" text file as part of its distribution, then any Derivative +Works that You distribute must include a readable copy of the attribution +notices contained within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one of the following +places: within a NOTICE text file distributed as part of the Derivative Works; +within the Source form or documentation, if provided along with the Derivative +Works; or, within a display generated by the Derivative Works, if and wherever +such third-party notices normally appear. The contents of the NOTICE file are +for informational purposes only and do not modify the License. You may add Your +own attribution notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided that such +additional attribution notices cannot be construed as modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any +Contribution intentionally submitted for inclusion in the Work by You to the +Licensor shall be under the terms and conditions of this License, without any +additional terms or conditions. Notwithstanding the above, nothing herein shall +supersede or modify the terms of any separate license agreement you may have +executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, +trademarks, service marks, or product names of the Licensor, except as required +for reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in +writing, Licensor provides the Work (and each Contributor provides its +Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied, including, without limitation, any warranties +or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any risks +associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in +tort (including negligence), contract, or otherwise, unless required by +applicable law (such as deliberate and grossly negligent acts) or agreed to in +writing, shall any Contributor be liable to You for damages, including any +direct, indirect, special, incidental, or consequential damages of any character +arising as a result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, work stoppage, +computer failure or malfunction, or any and all other commercial damages or +losses), even if such Contributor has been advised of the possibility of such +damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or +Derivative Works thereof, You may choose to offer, and charge a fee for, +acceptance of support, warranty, indemnity, or other liability obligations +and/or rights consistent with this License. However, in accepting such +obligations, You may act only on Your own behalf and on Your sole +responsibility, not on behalf of any other Contributor, and only if You agree to +indemnify, defend, and hold each Contributor harmless for any liability incurred +by, or claims asserted against, such Contributor by reason of your accepting any +such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/document/readme.txt b/document/readme.txt new file mode 100644 index 0000000..9a7500e --- /dev/null +++ b/document/readme.txt @@ -0,0 +1,19 @@ + +Building a project can be like finding your way out of Daedalus's impossible to +solve maze. Ariadne hands you a ball of string. + +Ariadne is a graph based build tool. + +Each graph node represents either a build target or symbolic objective. + +Nodes have properties, and among these properties is a block of code that +presumably either builds the target or accomplishes the symbolic objective. + +Edges that link the nodes represent dependencies. + +The build tool is given a graph. It traverses down to leaf dependencies then +follows the string it laid out during the traversal, and works its way back up +to achieve the root objectives. + +The build tool recognizes and skips over cycles and build failures. + diff --git a/document/todo.txt b/document/todo.txt new file mode 100644 index 0000000..429086e --- /dev/null +++ b/document/todo.txt @@ -0,0 +1,3 @@ + +1. extract TestBench as its own project. Perhaps it can replace paintit as the +project skeleton. diff --git a/env_administrator b/env_administrator new file mode 100644 index 0000000..744a861 --- /dev/null +++ b/env_administrator @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +source tool/env + diff --git a/env_developer b/env_developer new file mode 100644 index 0000000..4236627 --- /dev/null +++ b/env_developer @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +source tool_shared/bespoke/env +source developer/tool/env + diff --git a/env_tester b/env_tester new file mode 100644 index 0000000..969a5d1 --- /dev/null +++ b/env_tester @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +source tool_shared/bespoke/env +source tester/tool/env + diff --git a/release/Ariadne.jar b/release/Ariadne.jar new file mode 100644 index 0000000..74faa32 Binary files /dev/null and b/release/Ariadne.jar differ diff --git a/release/black b/release/black deleted file mode 100755 index d94d9cb..0000000 --- a/release/black +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -java com/ReasoningTechnology/PaintIt/Black diff --git a/release/blue b/release/blue deleted file mode 100755 index 387f82a..0000000 --- a/release/blue +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -java com/ReasoningTechnology/PaintIt/Blue diff --git a/release/build b/release/build new file mode 100755 index 0000000..f4d3bbc --- /dev/null +++ b/release/build @@ -0,0 +1,2 @@ +#!/bin/bash +java com/ReasoningTechnology/Ariadne/build diff --git a/release/green b/release/green deleted file mode 100755 index 9611a51..0000000 --- a/release/green +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -java com/ReasoningTechnology/PaintIt/Green diff --git a/tester/.githolder b/tester/.githolder deleted file mode 100644 index e69de29..0000000 diff --git a/tester/deprecated/.githolder b/tester/deprecated/.githolder new file mode 100644 index 0000000..e69de29 diff --git a/tester/document/about_TestBench.txt b/tester/document/about_TestBench.txt new file mode 100644 index 0000000..de27572 --- /dev/null +++ b/tester/document/about_TestBench.txt @@ -0,0 +1,10 @@ + +javac/TestBench does not belong here. It should have its own project. + +Currently it must be made first using `make_TestBench`. It will be made again, +redundantly as part of `make` because it is in the javac directory. This does +not hurt anything. + +Later we will use an earlier version of the build tool to build the build tool, +and cases and `make_TestBench` can be handled more gracefully if it is still +here. diff --git a/tester/document/what_the_tests_do.txt b/tester/document/what_the_tests_do.txt index 792ac31..3f107d9 100644 --- a/tester/document/what_the_tests_do.txt +++ b/tester/document/what_the_tests_do.txt @@ -1,17 +1,8 @@ -Normally I would test individual subroutines/methods, then -combinations. However, this code was copied over from a Gradle script. So -instead, the tests are graded in complexity. +test0 - see if the tool will compile when given an empty graph. -test0 - tests that the code will compile. The test itself consists -of an empty graph. This was also the first test to make use of the -directory structure and work flow. +test1 - see what happens with a single symbolic node -test1 - The test graph has a single symbolic node. The question is if -the build code will run. The build code prints a message, said to -be the title of the graph. - -test2 - The test graph consists of a single node abstraction function -that builds nodes on the fly given a recognized target input. +Remaining tests are compiled into javac/TestBenchAriande diff --git a/tester/javac/TestBench.java b/tester/javac/TestBench.java index 0a9de3d..bd08267 100644 --- a/tester/javac/TestBench.java +++ b/tester/javac/TestBench.java @@ -1,8 +1,19 @@ +package com.reasoningtechnology.TestBench; import java.util.Map; public class TestBench { - public static void runTest_Map(Map test_map){ + // typically used to gather results before a return + public static boolean all(boolean[] conditions){ + for( boolean condition : conditions ){ + if( !condition ){ + return false; + } + } + return true; + } + + public static void run(Map test_map){ int totalTest_Map = test_map.size(); int passedTest_Map = 0; int failedTest_Map = 0; diff --git a/tester/javac/TestBenchAriadne.java b/tester/javac/TestBenchAriadne.java new file mode 100644 index 0000000..88a6bd2 --- /dev/null +++ b/tester/javac/TestBenchAriadne.java @@ -0,0 +1,53 @@ +package com.ReasoningTechnology.Ariadne.TestBench; +import com.reasoningtechnology.Ariadna.*; +import com.reasoningtechnology.TestBench.*; +import java.util.Map; +import java.util.HashMap; + +public class TestBenchAriadne extends TestBench{ + + public static boolean test_File_unpack_file_path_0(){ + boolean[] conditions = new boolean[5]; + int i = 0; + + // Test input + String test_fp = "/home/user/test.txt"; + + // Expected output + String expected_dp = "/home/user/"; + String expected_fn = "test.txt"; + String expected_fn_base = "test"; + String expected_fn_ext = "txt"; + + // Actual output + Map result = File.unpack_file_path( test_fp ); + + conditions[i++] = result.get("dp").equals( expected_dp ); + conditions[i++] = result.get("fn").equals( expected_fn ); + conditions[i++] = result.get("fn_base").equals( expected_fn_base ); + conditions[i++] = result.get("fn_ext").equals( expected_fn_ext ); + conditions[i++] = result.size() == 4; + + // Return true if all conditions are met + return all( conditions ); + } + + // Method to run all tests + public static void test_Ariadne(){ + Map test_map = new HashMap<>(); + + // Adding tests to the map + test_map.put( "File_unpack_file_path_0", test_File_unpack_file_path_0() ); + + // Run the tests using TestBench + TestBench.run( test_map ); + } + + // Main function to provide a shell interface for running tests + public static void main(String[] args){ + System.out.println("Running Ariadne tests..."); + test_Ariadne(); // Calls the method to run all tests + } + +} + diff --git a/tester/jvm/.githolder b/tester/jvm/.githolder new file mode 100644 index 0000000..e69de29 diff --git a/tester/jvm/AriadnaTestBench.jar b/tester/jvm/AriadnaTestBench.jar new file mode 100644 index 0000000..0c16d79 Binary files /dev/null and b/tester/jvm/AriadnaTestBench.jar differ diff --git a/tester/jvm/TestBench.jar b/tester/jvm/TestBench.jar new file mode 100644 index 0000000..40f1e0f Binary files /dev/null and b/tester/jvm/TestBench.jar differ diff --git a/tester/scratch_pad/.gitignore b/tester/scratch_pad/.gitignore new file mode 100644 index 0000000..120f485 --- /dev/null +++ b/tester/scratch_pad/.gitignore @@ -0,0 +1,2 @@ +* +!/.gitignore diff --git a/tester/test2/HelloWorld.java b/tester/test2/HelloWorld.java deleted file mode 100644 index 74d76d1..0000000 --- a/tester/test2/HelloWorld.java +++ /dev/null @@ -1,5 +0,0 @@ -public class HelloWorld{ - public static void main( String[] args ){ - System.out.println( "Hello, world!" ); - } -} diff --git a/tester/test2/TestGraph$_get_node_f_list_closure2.class b/tester/test2/TestGraph$_get_node_f_list_closure2.class deleted file mode 100644 index 12489c0..0000000 Binary files a/tester/test2/TestGraph$_get_node_f_list_closure2.class and /dev/null differ diff --git a/tester/test2/TestGraph$_get_node_f_list_closure3.class b/tester/test2/TestGraph$_get_node_f_list_closure3.class deleted file mode 100644 index 88475e8..0000000 Binary files a/tester/test2/TestGraph$_get_node_f_list_closure3.class and /dev/null differ diff --git a/tester/test2/TestGraph$_java_to_class_closure1.class b/tester/test2/TestGraph$_java_to_class_closure1.class deleted file mode 100644 index 8deb4f0..0000000 Binary files a/tester/test2/TestGraph$_java_to_class_closure1.class and /dev/null differ diff --git a/tester/test2/TestGraph$_java_to_class_f_closure1.class b/tester/test2/TestGraph$_java_to_class_f_closure1.class deleted file mode 100644 index ba07c8a..0000000 Binary files a/tester/test2/TestGraph$_java_to_class_f_closure1.class and /dev/null differ diff --git a/tester/test2/TestGraph.class b/tester/test2/TestGraph.class deleted file mode 100644 index 623d6f3..0000000 Binary files a/tester/test2/TestGraph.class and /dev/null differ diff --git a/tester/test2/TestGraph.groovy b/tester/test2/TestGraph.groovy deleted file mode 100644 index f1f3913..0000000 --- a/tester/test2/TestGraph.groovy +++ /dev/null @@ -1,150 +0,0 @@ -import AriadneGraph - -class TestGraph { - - static def get_node_map(){ - return [:] - } - - // given label .class returns node to build .class from .java - static java_to_class( node_label ){ - println("java_to_class::") - - def target=AriadneGraph.unpack_file_path(node_label) - println("java_to_class_f:: given target: ${target}") - - // this function recognizes .class files: - if( !target.fn || target.fn_ext != 'class' ) return [status: 'no_match'] - println("java_to_class_f:: node_label ${node_label} matched") - - def class_fp = node_label - def java_fp = target.dp + target.fn_base + '.java' - - return [ - status: 'matched' - ,label: class_fp - ,type: 'path' - ,neighbor: [java_fp] // The corresponding .java file - ,build: { - def process="javac ${java_fp}".execute() - process.waitFor() - if( process.exitValue() == 0 ){ - return [status: 'success' ,output: class_fp] - } else { - return [status: 'failure' ,error: process.err.text] - } - } - ] - } - /* - import java.util.HashMap; - import java.util.Map; - import java.io.IOException; - - public class AriadneGraph { - - public static Map java_to_class(String node_label) { - System.out.println("java_to_class::"); - - Map target = AriadneGraph.unpack_file_path(node_label); - System.out.println("java_to_class_f:: given target: " + target); - - // This function recognizes .class files - if (target.get("fn") == null || !target.get("fn_ext").equals("class")) { - Map noMatch = new HashMap<>(); - noMatch.put("status", "no_match"); - return noMatch; - } - - System.out.println("java_to_class_f:: node_label " + node_label + " matched"); - - String class_fp = node_label; - String java_fp = target.get("dp") + target.get("fn_base") + ".java"; - - // Create the node to return - Map matchedNode = new HashMap<>(); - matchedNode.put("status", "matched"); - matchedNode.put("label", class_fp); - matchedNode.put("type", "path"); - - // List of neighbors - matchedNode.put("neighbor", List.of(java_fp)); // The corresponding .java file - - // Define the build function as a lambda - matchedNode.put("build", (Runnable) () -> { - try { - Process process = Runtime.getRuntime().exec("javac " + java_fp); - process.waitFor(); - - if (process.exitValue() == 0) { - Map result = new HashMap<>(); - result.put("status", "success"); - result.put("output", class_fp); - return result; - } else { - Map result = new HashMap<>(); - result.put("status", "failure"); - result.put("error", new String(process.getErrorStream().readAllBytes())); - return result; - } - } catch (IOException | InterruptedException e) { - Map result = new HashMap<>(); - result.put("status", "failure"); - result.put("error", e.getMessage()); - return result; - } - }); - - return matchedNode; - } - - public static Map unpack_file_path(String node_label) { - // Stub implementation to mimic the unpack_file_path method - // This should return a Map containing keys like "fn", "fn_ext", "dp", and "fn_base" - Map filePathMap = new HashMap<>(); - filePathMap.put("fn", "ExampleFile"); - filePathMap.put("fn_ext", "class"); - filePathMap.put("dp", "/path/to/"); - filePathMap.put("fn_base", "ExampleFileBase"); - - return filePathMap; - } - - public static void main(String[] args) { - // Example usage - Map node = java_to_class("ExampleFile.class"); - System.out.println(node); - } -} -*/ - static java_leaf( node_label ){ - println("java_to_leaf::") - - def target = AriadneGraph.unpack_file_path( node_label ) - println("java_to_class_f:: given target: ${target}") - - // This function recognizes .java files: - if( !target.fn || target.fn_ext != 'java' ) return [status: 'no_match'] - println("java_to_class_f:: node_label ${node_label} matched") - - def java_fp = node_label - - return [ - status: 'matched' - ,label: java_fp - ,type: 'leaf' - ,neighbor: [] // Leaf nodes have no dependencies - ] - } - - // Static method to define the function list - static def get_node_f_list(){ - return ( - [ - { node_label -> java_to_class(node_label) } - ,{ node_label -> java_leaf(node_label) } - ] - ) - } - -} diff --git a/tester/test2/env_test b/tester/test2/env_test deleted file mode 100644 index 78c20df..0000000 --- a/tester/test2/env_test +++ /dev/null @@ -1,11 +0,0 @@ - -if [ -z "$ENV_TESTER" ]; then - echo "env_test0:: script can only be run in the tester environment" - env_error=true -fi - -export CLASSPATH=\ -"$REPO_HOME"/release_candidate\ -:"$REPO_HOME"/tester/test2\ -:$CLASSPATH - diff --git a/tester/test2/test.sh b/tester/test2/test.sh deleted file mode 100755 index 6cd9b04..0000000 --- a/tester/test2/test.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/env bash - -# smoke test, and yes, there was a lot of smoke -set -x - -source env_test -echo $CLASSPATH -build TestGraph HelloWorld.class - -echo "test complete" - diff --git a/tester/tool/clean b/tester/tool/clean new file mode 100755 index 0000000..ff8ac50 --- /dev/null +++ b/tester/tool/clean @@ -0,0 +1,21 @@ +# input guards + + env_must_be="tester/tool/env" + if [ "$ENV" != "$env_must_be" ]; then + echo "$(script_fp):: error: must be run in the $env_must_be environment" + exit 1 + fi + +# Paths +BUILD_DIR="$REPO_HOME/tester/scratch_pad" +JAR_OUTPUT_DIR="$REPO_HOME/tester/jvm" + +# Clean the scratch_pad directory +echo "Cleaning up scratch_pad directory..." +rm -rf "$BUILD_DIR"/* + +# Optionally clean the jar output as well +echo "Cleaning up jvm directory..." +rm -f "$JAR_OUTPUT_DIR"/*.jar + +echo "$script_name done." diff --git a/tester/tool/env b/tester/tool/env index a630a47..f6b871a 100644 --- a/tester/tool/env +++ b/tester/tool/env @@ -1,32 +1,41 @@ #!/usr/bin/env bash -## input guards +# input guards -# instead of bailing, we will go fetch what we need -env_should_be="tool_shared/bespoke/env" -if [ "$ENV" != "$env_should_be" ]; then - source "$REPO_HOME"/"$env_should_be" -fi + env_must_be="tool_shared/bespoke/env" + if [ "$ENV" != "$env_must_be" ]; then + echo "$(script_fp):: error: must be run in the $env_must_be environment" + exit 1 + fi -if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then - echo "$script_name:: This script must be sourced, not executed." - exit 1 -fi + if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then + echo "$script_name:: This script must be sourced, not executed." + exit 1 + fi -cd "$REPO_HOME"/tester/ - -export ENV=$(script_fp) -export PROJECT="$PROJECT"_tester +# so we can do testing export PATH=\ "$REPO_HOME"/tester/tool/\ :"$REPO_HOME"/tool_shared/bespoke/\ -"$JAVA_HOME"/bin\ +:"$JAVA_HOME"/bin\ :"$PATH" export CLASSPATH=\ -:"$REPO_HOME"/developer/release/Ariadne.jar\ -:"$JAVA_HOME"/lib\ +"$JAVA_HOME"/lib\ +:"$REPO_HOME"/release/Ariadne.jar\ +:"$REPO_HOME"/tester/jvm/TestBench.jar\ +:"$REPO_HOME"/tester/jvm/AriadneTestBench.jar\ :"$CLASSPATH" -echo "$ENV complete." +# misc + + # make .githolder and .gitignore visible + alias ls="ls -a" + +# some feedback to show all went well + + export PROJECT="$PROJECT"_tester + export ENV=$(script_fp) + echo ENV "$ENV" + cd "$REPO_HOME"/tester/ diff --git a/tester/tool/make b/tester/tool/make index c9aca35..cdcd57d 100755 --- a/tester/tool/make +++ b/tester/tool/make @@ -1,12 +1,21 @@ #!/bin/env bash -script_name=$(basename ${BASH_SOURCE[0]}) -if [ -z "$ENV_TESTER_LOCAL" ]; then - echo "make.sh:: script can only be run in the tester environment" - env_error=true -fi +# input guards + env_must_be="tester/tool/env" + if [ "$ENV" != "$env_must_be" ]; then + echo "$(script_fp):: error: must be run in the $env_must_be environment" + exit 1 + fi +# the build +set -x + cd $REPO_HOME/tester -echo "$script_name done." + javac -d scratch_pad javac/*.java + jar cf jvm/AriadnaTestBench.jar -C scratch_pad . + +set +x + +echo "$(script_fp) done." diff --git a/tester/tool/make_TestBench b/tester/tool/make_TestBench new file mode 100755 index 0000000..dd5daa9 --- /dev/null +++ b/tester/tool/make_TestBench @@ -0,0 +1,21 @@ +#!/bin/env bash + +# input guards + + env_must_be="tester/tool/env" + if [ "$ENV" != "$env_must_be" ]; then + echo "$(script_fp):: error: must be run in the $env_must_be environment" + exit 1 + fi + +# the build +set -x + + cd $REPO_HOME/tester + + javac -d scratch_pad javac/TestBench.java + jar cf jvm/TestBench.jar -C scratch_pad . + +set +x + +echo "$(script_fp) done." diff --git a/tool_shared/bespoke/env b/tool_shared/bespoke/env index 1939b29..d38b1bc 100644 --- a/tool_shared/bespoke/env +++ b/tool_shared/bespoke/env @@ -1,46 +1,61 @@ #!/usr/bin/env bash # environment shared by entire project -# Path to this script -script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" +# number one task, establish REPO_HOME +# this is specific to this script being in the .../tools_shared/env directory + script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" + export REPO_HOME="${script_path%/*/*}/" + export PROJECT=$(basename "$REPO_HOME") + ## set the shell prompt to show the project + PPS1="\n[$PROJECT]\n\u@\h§$(pwd)§\n> " + PPS2=">> " -# Path to the repo is two directories up -export REPO_HOME="${script_path%/*/*}/" +# some useful functions for environment scripts -# script name and path relative to the top of the project -script_fn(){ - echo "$(basename ${BASH_SOURCE[0]})" -} -script_fp(){ - echo "$(realpath --relative-to="$REPO_HOME" "$script_path")/$(script_fn)" -} -export -f script_fn script_fp + ## path to script file + script_fp() { + eval " + local script_dp=\$(dirname \$(realpath \${BASH_SOURCE[1]})) + echo \$(realpath --relative-to=\"$REPO_HOME\" \"\$script_dp\")/\$(script_fn) + " + } -# REPO_HOME relative file path to this script -# Calling the function correctly without braces -export ENV=$(script_fp) + ## path to script directory + script_dp() { + eval " + local script_dp=\$(dirname \$(realpath \${BASH_SOURCE[1]})) + echo \$(realpath --relative-to=\"$REPO_HOME\" \"\$script_dp\") + " + } -# this script must be sourced, sort of like Python activate -if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then - echo "$ENV must be sourced, not executed. Exiting." - exit 1 -fi + ## an env script will be in workspace/tool/env, so + workspace(){ + eval "echo \$(dirname \$(script_dp))" + } -export PROJECT=$(basename "$REPO_HOME") + ## script's filename + script_fn() { + eval "echo \$(basename \${BASH_SOURCE[1]})" + } + + export -f script_fp script_dp script_fn workspace + +# note to the programs which environment they are running. + + export ENV=$(script_fp) + +# The project administrator setup these tools and environment settings for all +# on the project to use: -# Third party tool(s) that the project admin kindly installed. -# The developer and tester should use these links to find them. export JAVA_HOME="$REPO_HOME/tool_shared/third_party/jdk-11" -# set the shell prompt to show the project -PPS1="\n[$PROJECT]\n\u@\h§$(pwd)§\n> " -PPS2=">> " +# some feedback to show all went well echo ENV "$ENV" echo REPO_HOME "$REPO_HOME" echo PROJECT "$PROJECT" -echo "$ENV completed." + diff --git a/tool_shared/bespoke/temp b/tool_shared/bespoke/temp deleted file mode 100644 index 0a80f78..0000000 --- a/tool_shared/bespoke/temp +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# Path to this script -script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" - -# Path to the repo is two directories up -export REPO_HOME="${script_path%/*/*}/" - -# script name and path relative to the top of the project -script_fn(){ - echo "$(basename ${BASH_SOURCE[0]})" -} -script_fp(){ - echo "$(realpath --relative-to="$REPO_HOME" "$script_path")/$(script_fn)" -} - -# REPO_HOME relative file path to this script -# Calling the function correctly without braces -export ENV=$(script_fp) - -# Output the values -echo "Script path: $script_path" -echo "Repo home: $REPO_HOME" -echo "ENV: $ENV" diff --git a/tool_shared/bespoke/vl b/tool_shared/bespoke/vl new file mode 100755 index 0000000..94fe14d --- /dev/null +++ b/tool_shared/bespoke/vl @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# vl 'vertical list' + +# Check if the command is provided +if [ -z "$1" ]; then + echo "Usage: vl [args...]" + exit 1 +fi + +# Capture the command and its arguments +cmd=$1 +shift + +# Run the command with the remaining arguments and replace colons or spaces with newlines +"$cmd" "$@" | tr ' :' '\n' + +exit 0 diff --git a/tool_shared/bespoke/wipe_release b/tool_shared/bespoke/wipe_release new file mode 100755 index 0000000..4b92b4b --- /dev/null +++ b/tool_shared/bespoke/wipe_release @@ -0,0 +1,17 @@ +#!/bin/bash +# remove all files in the release directory +set -e + +script_name=$(basename ${BASH_SOURCE[0]}) +if [ -z "$REPO_HOME" ]; then + echo "$script_name:: REPO_HOME is not set." + exit 1 +fi + +set -x +cd "$REPO_HOME" +rm -rf release/* +set +x + +echo "$script_name done." + diff --git a/tool_shared/bespoke/wipe_replease b/tool_shared/bespoke/wipe_replease deleted file mode 100755 index 4b92b4b..0000000 --- a/tool_shared/bespoke/wipe_replease +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# remove all files in the release directory -set -e - -script_name=$(basename ${BASH_SOURCE[0]}) -if [ -z "$REPO_HOME" ]; then - echo "$script_name:: REPO_HOME is not set." - exit 1 -fi - -set -x -cd "$REPO_HOME" -rm -rf release/* -set +x - -echo "$script_name done." -