From 9103217c4a317e0976ca1efcaf45c421376d9ba9 Mon Sep 17 00:00:00 2001 From: Jason Steving Date: Tue, 9 Nov 2021 11:45:32 -0800 Subject: [PATCH 01/10] Initial pass at onboarding Claro to Riju. --- langs/claro.yaml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 langs/claro.yaml diff --git a/langs/claro.yaml b/langs/claro.yaml new file mode 100644 index 0000000..a74c5fe --- /dev/null +++ b/langs/claro.yaml @@ -0,0 +1,44 @@ +id: "claro" +name: "Claro" + +install: + aptKey: + - "https://bazel.build/bazel-release.pub.gpg" + aptRepo: + - "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" + apt: + - bazel + - default-jdk + manual: | + # Install Claro repo. + install -d "${pkg}/usr/local/bin" + touch "${pkg}/usr/local/bin/MYTEST" + wget "https://github.com/JasonSteving99/claro-lang/archive/refs/tags/v0.1.0.tar.gz" + tar -xf v0.1.0.tar.gz + pushd claro-lang-* + cp -R * "${pkg}/usr/local/bin" + popd + + +setup: | + echo "setting up!" + cp -R /usr/local/bin/* "${HOME}/src" + +main: "src/java/com/claro/claro_programs/conditions.claro" +template: | + # Fill this in later + print("Hello, Riju world!"); + +run: | + echo "Hello, world!" + echo $(bazel --version) + pwd + ls + # This --nojava_header_compilation flag is necessary because Lombok + # fails with error "Turbine is not currently supported by lombok." + # Followed the resolution here: https://githubmemory.com/repo/rzwitserloot/lombok/issues/2911 + # I don't know what any of this means.... but hey it works now *shrug* + bazel run --nojava_header_compilation //src/java/com/claro/claro_programs:conditions_compiled_claro_image + +skip: + - run From 7c29db6d0694da8351e9223bc8def4685e7a7124 Mon Sep 17 00:00:00 2001 From: Jason Steving Date: Fri, 3 Dec 2021 04:15:15 -0800 Subject: [PATCH 02/10] ClaroSupport working! This is a massive effort to hack together the Bazel generated jar files and runscript into something that can be deployed on Riju! This all still needs to be cleaned up, but I'm definitely not going to risk losing all this work so it's getting pushed up as is in the meantime. --- langs/claro.yaml | 87 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 14 deletions(-) diff --git a/langs/claro.yaml b/langs/claro.yaml index a74c5fe..8a68013 100644 --- a/langs/claro.yaml +++ b/langs/claro.yaml @@ -13,32 +13,91 @@ install: # Install Claro repo. install -d "${pkg}/usr/local/bin" touch "${pkg}/usr/local/bin/MYTEST" - wget "https://github.com/JasonSteving99/claro-lang/archive/refs/tags/v0.1.0.tar.gz" - tar -xf v0.1.0.tar.gz - pushd claro-lang-* - cp -R * "${pkg}/usr/local/bin" - popd + # Temporarily try to pull the tarball of the built Bazel repo instead of just the sources. + # wget "https://github.com/JasonSteving99/claro-lang/archive/refs/tags/v0.1.0.tar.gz" + # tar -xf v0.1.0.tar.gz + # pushd claro-lang-* + + # wget "https://github.com/JasonSteving99/claro-lang/releases/download/v0.1.0/claro-lang.tar.gz" + # tar -xzvf claro-lang.tar.gz + wget "https://github.com/JasonSteving99/claro-lang/releases/download/v0.1.0/claro-lang-bazel-bin.tar.gz" + tar -xzvf claro-lang-bazel-bin.tar.gz + + cp -R external "${pkg}/usr/local/bin" + cp -R src "${pkg}/usr/local/bin" + + # TODO(jsteving) I SHOULD NOW FOLLOW THIS GENERAL APPROACH TO CREATE A RUNSCRIPT: + # Create the shortest classpath we can, by making it relative if possible. + # RUNPATH="${JAVA_RUNFILES}/claro-lang/" + # RUNPATH="${RUNPATH#$PWD/}" + # CLASSPATH="${RUNPATH}src/java/com/claro/claro_programs/conditions_compiled_claro_image.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/guava/guava/28.1-jre/guava-28.1-jre.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/org/codehaus/mojo/animal-sniffer-annotations/1.18/animal-sniffer-annotations-1.18.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/org/checkerframework/checker-qual/2.8.1/checker-qual-2.8.1.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/errorprone/error_prone_annotations/2.3.2/error_prone_annotations-2.3.2.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/impls/builtins_impls/collections/libcollections_impls.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/impls/builtins_impls/libbuiltins_impls.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libtype.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libbase_type.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/impls/libclaro_type_implementation.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/impls/user_defined_impls/libuser_defined_impls.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libclaro_type_exception.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libconcrete_type.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libtypes.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libparameterized_type.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libtype_provider.jar:${RUNPATH}src/java/com/claro/compiler_backends/interpreted/libscoped_heap.jar:${RUNPATH}src/java/com/claro/libclaro_parser_exception.jar:${RUNPATH}src/java/com/claro/intermediate_representation/expressions/libexpr.jar:${RUNPATH}src/java/com/claro/intermediate_representation/libnode.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libconcrete_types.jar:${RUNPATH}src/java/com/claro/runtime_utilities/libruntime_utilities.jar" + # CLASSPATH+=":${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/org/projectlombok/lombok/1.18.20/lombok-1.18.20.jar" + # CLASSPATH+=":${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/com/google/auto/value/auto-value/1.5.3/auto-value-1.5.3.jar" + # echo $CLASSPATH + # javac -classpath $CLASSPATH Conditions.java + # mkdir com + # mkdir com/claro + # mv Conditions.class com/claro + # jar -uf "${RUNPATH}src/java/com/claro/claro_programs/conditions_compiled_claro_image.jar" com/claro/Conditions.class + # exec $JAVABIN -classpath $CLASSPATH "${ARGS[@]}" + + # popd + wget "https://github.com/JasonSteving99/claro-lang/releases/download/v0.1.0/claro_compiler_binary_deploy.jar" + cp claro_compiler_binary_deploy.jar "${pkg}/usr/local/bin" setup: | echo "setting up!" cp -R /usr/local/bin/* "${HOME}/src" + # touch src/java/com/claro/claro_programs/Riju.java + # bazel build --nojava_header_compilation //src/java/com/claro/claro_programs:riju -main: "src/java/com/claro/claro_programs/conditions.claro" +main: "src/java/com/claro/claro_programs/Conditions.claro" template: | - # Fill this in later - print("Hello, Riju world!"); + # Please allow a few minutes for your session to be ready to work with, then have fun! + print("Hello, world!"); run: | - echo "Hello, world!" - echo $(bazel --version) - pwd - ls + # Skip rebuilding the entire compiler all over again and instead just use the pre-built Claro compiler jar. + chmod +rw src/java/com/claro/claro_programs/Conditions.java + java -jar claro_compiler_binary_deploy.jar --java_source --silent --classname=Conditions --package=com.claro \ + < src/java/com/claro/claro_programs/Conditions.claro \ + > src/java/com/claro/claro_programs/Conditions.java + + # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + # We don't want to depend on Bazel at all for rebuilding, it's just one file changing. Rebuild it using + # the packaged jar files and then update the jar holding that recompiled file and run the Bazel gen'd + # run script which points at all the correct jar runfiles. + pushd src/java/com/claro/claro_programs/ > /dev/null + fancydelim=$(printf '\001') # https://stackoverflow.com/a/25821096/10027370 + + MY_SCRIPT=' CLASSPATH+=":\${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/org/projectlombok/lombok/1.18.20/lombok-1.18.20.jar"\n' + MY_SCRIPT+=' CLASSPATH+=":\${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/com/google/auto/value/auto-value/1.5.3/auto-value-1.5.3.jar"\n' + MY_SCRIPT+=' javac -classpath $CLASSPATH Conditions.java\n' + # There's an assumption that the dir ./com/claro/ was made before this. + MY_SCRIPT+=' mv Conditions*.class com/claro\n' + MY_SCRIPT+=' jar -uf "${RUNPATH}src/java/com/claro/claro_programs/conditions_compiled_claro_image.jar" com/claro/Conditions*.class\n' + MY_SCRIPT+=' java -classpath $CLASSPATH "${ARGS[@]}"\n' + # We insert our own exit here to short-circuit the call to JAVABIN which is invalid on this host machine. + MY_SCRIPT+=' exit $?\n' + + sed -n "H;\${x;s/\n//;s${fancydelim}create_and_run_classpath_jar\nelse\n${fancydelim}&${MY_SCRIPT}\n${fancydelim};p;}" conditions_compiled_claro_image > conditions_compiled_claro_image2 + + chmod 777 conditions_compiled_claro_image + cat conditions_compiled_claro_image2 > conditions_compiled_claro_image + + ./conditions_compiled_claro_image + + popd > /dev/null + # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + # This --nojava_header_compilation flag is necessary because Lombok # fails with error "Turbine is not currently supported by lombok." # Followed the resolution here: https://githubmemory.com/repo/rzwitserloot/lombok/issues/2911 # I don't know what any of this means.... but hey it works now *shrug* - bazel run --nojava_header_compilation //src/java/com/claro/claro_programs:conditions_compiled_claro_image + # bazel run --nojava_header_compilation --ui_event_filters=-info,-stdout,-stderr --noshow_progress //src/java/com/claro/claro_programs:riju + # bazel run --nojava_header_compilation --ui_event_filters=-info,-stdout,-stderr --noshow_progress //src/java/com/claro/claro_programs:conditions_compiled_claro_image skip: - - run + - run From 1104bfb3a5dbaabdcb437db24f7cc762ae0d10bc Mon Sep 17 00:00:00 2001 From: Jason Steving Date: Mon, 6 Dec 2021 01:54:33 -0800 Subject: [PATCH 03/10] ClaroSupport working efficiently! And NOW.....A REPL on RIJU! This is the final push towards implementing legitimate support for Claro in Riju! I've now figured out how to package up all of the Bazel generated build resources (jars) and the Bazel generated run script and have pieced everything together so that rebuilds and initial page loads are all as efficient as I can make them so far accounting for the intermediate step of compiling to Java. The general process is to package everything needed from Bazel in a tarball and then to dynamically insert a custom script to the Bazel generated run script in bazel-bin to rebuild and update the jar file for the latest modification to the file. This allows me to canibalize Bazel's logic for determining where all the proper "runfiles" a.k.a. jars are located in that tarball. With this approach I'm also able to trivially support the Claro REPL in Riju as well!!!!! This is the greatest unexpected surprise :D. --- langs/claro.yaml | 126 +++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 74 deletions(-) diff --git a/langs/claro.yaml b/langs/claro.yaml index 8a68013..c611fe2 100644 --- a/langs/claro.yaml +++ b/langs/claro.yaml @@ -2,102 +2,80 @@ id: "claro" name: "Claro" install: - aptKey: - - "https://bazel.build/bazel-release.pub.gpg" - aptRepo: - - "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" apt: - - bazel - default-jdk manual: | - # Install Claro repo. install -d "${pkg}/usr/local/bin" - touch "${pkg}/usr/local/bin/MYTEST" - # Temporarily try to pull the tarball of the built Bazel repo instead of just the sources. - # wget "https://github.com/JasonSteving99/claro-lang/archive/refs/tags/v0.1.0.tar.gz" - # tar -xf v0.1.0.tar.gz - # pushd claro-lang-* - # wget "https://github.com/JasonSteving99/claro-lang/releases/download/v0.1.0/claro-lang.tar.gz" - # tar -xzvf claro-lang.tar.gz - wget "https://github.com/JasonSteving99/claro-lang/releases/download/v0.1.0/claro-lang-bazel-bin.tar.gz" + # Pull resources from the latest Claro repo release. + ver="$(latest_release JasonSteving99/claro-lang)" + + # Pull the tarball of the built Bazel repo's bazel-bin instead of just the sources. + wget "https://github.com/JasonSteving99/claro-lang/releases/download/${ver}/claro-lang-bazel-bin.tar.gz" tar -xzvf claro-lang-bazel-bin.tar.gz - cp -R external "${pkg}/usr/local/bin" - cp -R src "${pkg}/usr/local/bin" + ##################################################################################################### + # We don't want to depend on Bazel at all for rebuilding, it's just one file changing. Rebuild it using + # the packaged jar files and then update the jar holding that recompiled file and run the Bazel gen'd + # run script which points at all the correct jar runfiles. First though, we need to slightly modify + # the Bazel gen'd runscript to rebuild using the packaged jars for us (without explicitly rerunning Bazel + # itself since this is super slow and involves starting up a new Bazel server...). + pushd claro_programs/ > /dev/null + fancydelim=$(printf '\001') # https://stackoverflow.com/a/25821096/10027370 - # TODO(jsteving) I SHOULD NOW FOLLOW THIS GENERAL APPROACH TO CREATE A RUNSCRIPT: - # Create the shortest classpath we can, by making it relative if possible. - # RUNPATH="${JAVA_RUNFILES}/claro-lang/" - # RUNPATH="${RUNPATH#$PWD/}" - # CLASSPATH="${RUNPATH}src/java/com/claro/claro_programs/conditions_compiled_claro_image.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/guava/guava/28.1-jre/guava-28.1-jre.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/org/codehaus/mojo/animal-sniffer-annotations/1.18/animal-sniffer-annotations-1.18.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/org/checkerframework/checker-qual/2.8.1/checker-qual-2.8.1.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:${RUNPATH}../maven/v1/https/jcenter.bintray.com/com/google/errorprone/error_prone_annotations/2.3.2/error_prone_annotations-2.3.2.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/impls/builtins_impls/collections/libcollections_impls.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/impls/builtins_impls/libbuiltins_impls.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libtype.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libbase_type.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/impls/libclaro_type_implementation.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/impls/user_defined_impls/libuser_defined_impls.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libclaro_type_exception.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libconcrete_type.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libtypes.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libparameterized_type.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libtype_provider.jar:${RUNPATH}src/java/com/claro/compiler_backends/interpreted/libscoped_heap.jar:${RUNPATH}src/java/com/claro/libclaro_parser_exception.jar:${RUNPATH}src/java/com/claro/intermediate_representation/expressions/libexpr.jar:${RUNPATH}src/java/com/claro/intermediate_representation/libnode.jar:${RUNPATH}src/java/com/claro/intermediate_representation/types/libconcrete_types.jar:${RUNPATH}src/java/com/claro/runtime_utilities/libruntime_utilities.jar" - # CLASSPATH+=":${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/org/projectlombok/lombok/1.18.20/lombok-1.18.20.jar" - # CLASSPATH+=":${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/com/google/auto/value/auto-value/1.5.3/auto-value-1.5.3.jar" - # echo $CLASSPATH - # javac -classpath $CLASSPATH Conditions.java - # mkdir com - # mkdir com/claro - # mv Conditions.class com/claro - # jar -uf "${RUNPATH}src/java/com/claro/claro_programs/conditions_compiled_claro_image.jar" com/claro/Conditions.class - # exec $JAVABIN -classpath $CLASSPATH "${ARGS[@]}" + # MY_SCRIPT=' CLASSPATH+=":\${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/org/projectlombok/lombok/1.18.20/lombok-1.18.20.jar"\n' + # MY_SCRIPT+=' CLASSPATH+=":\${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/com/google/auto/value/auto-value/1.5.3/auto-value-1.5.3.jar"\n' + # For the purpose of rebuilding, we need lombok and autovalue on the classpath. + MY_SCRIPT=' REBUILD_CLASSPATH="${CLASSPATH}"\n' + MY_SCRIPT+=' REBUILD_CLASSPATH+=":lombok-1.18.20.jar"\n' + MY_SCRIPT+=' REBUILD_CLASSPATH+=":auto-value-1.5.3.jar"\n' + MY_SCRIPT+=' javac -classpath $REBUILD_CLASSPATH Conditions.java\n' + # There's an assumption that the dir ./com/claro/ was made in the tarball before this. + MY_SCRIPT+=' mv Conditions*.class com/claro\n' + MY_SCRIPT+=' jar -uf "${RUNPATH}src/java/com/claro/claro_programs/conditions_compiled_claro_image.jar" com/claro/Conditions*.class\n' + MY_SCRIPT+=' java -classpath $CLASSPATH "${ARGS[@]}"\n' + # We insert our own exit here to short-circuit the Bazel run script's call to JAVABIN which is + # invalid on this host machine. + MY_SCRIPT+=' exit $?\n' + + # Insert MY_SCRIPT into the Bazel run script just before java gets executed. We're reusing Bazel's run + # script basically just to get a conveniently curated CLASSPATH variable generated to point to all the + # randomly scattered jar files that Bazel places throughout bazel-bin/. + sed -n "H;\${x;s/\n//;s${fancydelim}create_and_run_classpath_jar\nelse\n${fancydelim}&${MY_SCRIPT}\n${fancydelim};p;}" conditions_compiled_claro_image > conditions_compiled_claro_image2 + + # I'm not good enough with sed to figure out how to avoid this extra temporary stop in a second file. Oh well. + chmod 777 conditions_compiled_claro_image + cat conditions_compiled_claro_image2 > conditions_compiled_claro_image + + popd > /dev/null + ##################################################################################################### + + cp -R claro_programs "${pkg}/usr/local/bin" - # popd wget "https://github.com/JasonSteving99/claro-lang/releases/download/v0.1.0/claro_compiler_binary_deploy.jar" cp claro_compiler_binary_deploy.jar "${pkg}/usr/local/bin" - setup: | - echo "setting up!" cp -R /usr/local/bin/* "${HOME}/src" - # touch src/java/com/claro/claro_programs/Riju.java - # bazel build --nojava_header_compilation //src/java/com/claro/claro_programs:riju -main: "src/java/com/claro/claro_programs/Conditions.claro" +main: "claro_programs/Conditions.claro" template: | - # Please allow a few minutes for your session to be ready to work with, then have fun! + # Thanks for trying out Claro during its early development stages! + # To learn Claro by example, check out: + # https://clarolang.com/tree/main/src/java/com/claro/claro_programs + print("Hello, world!"); run: | # Skip rebuilding the entire compiler all over again and instead just use the pre-built Claro compiler jar. - chmod +rw src/java/com/claro/claro_programs/Conditions.java + chmod +rw claro_programs/Conditions.java java -jar claro_compiler_binary_deploy.jar --java_source --silent --classname=Conditions --package=com.claro \ - < src/java/com/claro/claro_programs/Conditions.claro \ - > src/java/com/claro/claro_programs/Conditions.java - - # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - # We don't want to depend on Bazel at all for rebuilding, it's just one file changing. Rebuild it using - # the packaged jar files and then update the jar holding that recompiled file and run the Bazel gen'd - # run script which points at all the correct jar runfiles. - pushd src/java/com/claro/claro_programs/ > /dev/null - fancydelim=$(printf '\001') # https://stackoverflow.com/a/25821096/10027370 - - MY_SCRIPT=' CLASSPATH+=":\${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/org/projectlombok/lombok/1.18.20/lombok-1.18.20.jar"\n' - MY_SCRIPT+=' CLASSPATH+=":\${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/com/google/auto/value/auto-value/1.5.3/auto-value-1.5.3.jar"\n' - MY_SCRIPT+=' javac -classpath $CLASSPATH Conditions.java\n' - # There's an assumption that the dir ./com/claro/ was made before this. - MY_SCRIPT+=' mv Conditions*.class com/claro\n' - MY_SCRIPT+=' jar -uf "${RUNPATH}src/java/com/claro/claro_programs/conditions_compiled_claro_image.jar" com/claro/Conditions*.class\n' - MY_SCRIPT+=' java -classpath $CLASSPATH "${ARGS[@]}"\n' - # We insert our own exit here to short-circuit the call to JAVABIN which is invalid on this host machine. - MY_SCRIPT+=' exit $?\n' - - sed -n "H;\${x;s/\n//;s${fancydelim}create_and_run_classpath_jar\nelse\n${fancydelim}&${MY_SCRIPT}\n${fancydelim};p;}" conditions_compiled_claro_image > conditions_compiled_claro_image2 - - chmod 777 conditions_compiled_claro_image - cat conditions_compiled_claro_image2 > conditions_compiled_claro_image + < claro_programs/Conditions.claro \ + > claro_programs/Conditions.java + pushd claro_programs/ > /dev/null ./conditions_compiled_claro_image - popd > /dev/null - # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - # This --nojava_header_compilation flag is necessary because Lombok - # fails with error "Turbine is not currently supported by lombok." - # Followed the resolution here: https://githubmemory.com/repo/rzwitserloot/lombok/issues/2911 - # I don't know what any of this means.... but hey it works now *shrug* - # bazel run --nojava_header_compilation --ui_event_filters=-info,-stdout,-stderr --noshow_progress //src/java/com/claro/claro_programs:riju - # bazel run --nojava_header_compilation --ui_event_filters=-info,-stdout,-stderr --noshow_progress //src/java/com/claro/claro_programs:conditions_compiled_claro_image - -skip: - - run +repl: | + java -jar claro_compiler_binary_deploy.jar --repl --silent \ No newline at end of file From 733ccee274d1a292d52edff87fd27d7b8b12b9f9 Mon Sep 17 00:00:00 2001 From: Jason Steving Date: Mon, 6 Dec 2021 01:57:02 -0800 Subject: [PATCH 04/10] ClaroSupport working efficiently! And NOW.....A REPL on RIJU! This is the final push towards implementing legitimate support for Claro in Riju! I've now figured out how to package up all of the Bazel generated build resources (jars) and the Bazel generated run script and have pieced everything together so that rebuilds and initial page loads are all as efficient as I can make them so far accounting for the intermediate step of compiling to Java. The general process is to package everything needed from Bazel in a tarball and then to dynamically insert a custom script to the Bazel generated run script in bazel-bin to rebuild and update the jar file for the latest modification to the file. This allows me to canibalize Bazel's logic for determining where all the proper "runfiles" a.k.a. jars are located in that tarball. With this approach I'm also able to trivially support the Claro REPL in Riju as well!!!!! This is the greatest unexpected surprise :D. --- langs/claro.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/langs/claro.yaml b/langs/claro.yaml index c611fe2..a4fb577 100644 --- a/langs/claro.yaml +++ b/langs/claro.yaml @@ -23,8 +23,6 @@ install: pushd claro_programs/ > /dev/null fancydelim=$(printf '\001') # https://stackoverflow.com/a/25821096/10027370 - # MY_SCRIPT=' CLASSPATH+=":\${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/org/projectlombok/lombok/1.18.20/lombok-1.18.20.jar"\n' - # MY_SCRIPT+=' CLASSPATH+=":\${RUNPATH}../../../../../../../external/maven/v1/https/jcenter.bintray.com/com/google/auto/value/auto-value/1.5.3/auto-value-1.5.3.jar"\n' # For the purpose of rebuilding, we need lombok and autovalue on the classpath. MY_SCRIPT=' REBUILD_CLASSPATH="${CLASSPATH}"\n' MY_SCRIPT+=' REBUILD_CLASSPATH+=":lombok-1.18.20.jar"\n' From 5e4d0bb18fe91f98970aa529c8e8b3f02960a0da Mon Sep 17 00:00:00 2001 From: Jason Steving Date: Mon, 6 Dec 2021 02:09:21 -0800 Subject: [PATCH 05/10] ClaroSupport working efficiently! And NOW.....A REPL on RIJU! This is the final push towards implementing legitimate support for Claro in Riju! I've now figured out how to package up all of the Bazel generated build resources (jars) and the Bazel generated run script and have pieced everything together so that rebuilds and initial page loads are all as efficient as I can make them so far accounting for the intermediate step of compiling to Java. The general process is to package everything needed from Bazel in a tarball and then to dynamically insert a custom script to the Bazel generated run script in bazel-bin to rebuild and update the jar file for the latest modification to the file. This allows me to canibalize Bazel's logic for determining where all the proper "runfiles" a.k.a. jars are located in that tarball. With this approach I'm also able to trivially support the Claro REPL in Riju as well!!!!! This is the greatest unexpected surprise :D. --- langs/claro.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/langs/claro.yaml b/langs/claro.yaml index a4fb577..aa4716f 100644 --- a/langs/claro.yaml +++ b/langs/claro.yaml @@ -44,6 +44,7 @@ install: # I'm not good enough with sed to figure out how to avoid this extra temporary stop in a second file. Oh well. chmod 777 conditions_compiled_claro_image cat conditions_compiled_claro_image2 > conditions_compiled_claro_image + rm conditions_compiled_claro_image2 popd > /dev/null ##################################################################################################### @@ -69,11 +70,13 @@ run: | chmod +rw claro_programs/Conditions.java java -jar claro_compiler_binary_deploy.jar --java_source --silent --classname=Conditions --package=com.claro \ < claro_programs/Conditions.claro \ - > claro_programs/Conditions.java - - pushd claro_programs/ > /dev/null - ./conditions_compiled_claro_image - popd > /dev/null + > claro_programs/Conditions.java \ + && \ + pushd claro_programs/ > /dev/null \ + && \ + ./conditions_compiled_claro_image \ + && \ + popd > /dev/null repl: | java -jar claro_compiler_binary_deploy.jar --repl --silent \ No newline at end of file From a024cdefa17b7ac4f9a603c174563fb4634b5d2e Mon Sep 17 00:00:00 2001 From: Jason Steving Date: Mon, 6 Dec 2021 02:22:25 -0800 Subject: [PATCH 06/10] ClaroSupport working efficiently! And NOW.....A REPL on RIJU! This is the final push towards implementing legitimate support for Claro in Riju! I've now figured out how to package up all of the Bazel generated build resources (jars) and the Bazel generated run script and have pieced everything together so that rebuilds and initial page loads are all as efficient as I can make them so far accounting for the intermediate step of compiling to Java. The general process is to package everything needed from Bazel in a tarball and then to dynamically insert a custom script to the Bazel generated run script in bazel-bin to rebuild and update the jar file for the latest modification to the file. This allows me to canibalize Bazel's logic for determining where all the proper "runfiles" a.k.a. jars are located in that tarball. With this approach I'm also able to trivially support the Claro REPL in Riju as well!!!!! This is the greatest unexpected surprise :D. --- langs/claro.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/langs/claro.yaml b/langs/claro.yaml index aa4716f..4aaeac3 100644 --- a/langs/claro.yaml +++ b/langs/claro.yaml @@ -1,6 +1,27 @@ id: "claro" name: "Claro" +info: + impl: "Claro" + version: "0.1.0" + year: 2021 + desc: "Optionally compiled or interpreted, high-level, toy programming language, with an eye towards providing standardized Software Engineering best practices out of the box" + ext: + - claro + web: + home: "https://clarolang.com/" + source: "https://github.com/JasonSteving99/claro-lang/" + category: recreational + mode: compiled or interpreted + platform: Bazel + syntax: + - java + typing: static + paradigm: + - functional + - imperative + usage: literally just Jason Steving + install: apt: - default-jdk From b950e503dbd24184c3f6566254eb50e3490e306e Mon Sep 17 00:00:00 2001 From: Jason Steving Date: Mon, 6 Dec 2021 02:32:25 -0800 Subject: [PATCH 07/10] ClaroSupport working efficiently! And NOW.....A REPL on RIJU! This is the final push towards implementing legitimate support for Claro in Riju! I've now figured out how to package up all of the Bazel generated build resources (jars) and the Bazel generated run script and have pieced everything together so that rebuilds and initial page loads are all as efficient as I can make them so far accounting for the intermediate step of compiling to Java. The general process is to package everything needed from Bazel in a tarball and then to dynamically insert a custom script to the Bazel generated run script in bazel-bin to rebuild and update the jar file for the latest modification to the file. This allows me to canibalize Bazel's logic for determining where all the proper "runfiles" a.k.a. jars are located in that tarball. With this approach I'm also able to trivially support the Claro REPL in Riju as well!!!!! This is the greatest unexpected surprise :D. --- langs/claro.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/langs/claro.yaml b/langs/claro.yaml index 4aaeac3..4d9c068 100644 --- a/langs/claro.yaml +++ b/langs/claro.yaml @@ -100,4 +100,10 @@ run: | popd > /dev/null repl: | - java -jar claro_compiler_binary_deploy.jar --repl --silent \ No newline at end of file + java -jar claro_compiler_binary_deploy.jar --repl --silent + +input: | + print(123 * 234); + +skip: + - runrepl From 76bc7825af0256859eb6124386fe7d8ea7e15402 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Wed, 22 Dec 2021 11:04:42 -0800 Subject: [PATCH 08/10] Various improvements --- langs/claro.yaml | 141 +++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 72 deletions(-) diff --git a/langs/claro.yaml b/langs/claro.yaml index 4d9c068..6a18a54 100644 --- a/langs/claro.yaml +++ b/langs/claro.yaml @@ -3,107 +3,104 @@ name: "Claro" info: impl: "Claro" - version: "0.1.0" year: 2021 - desc: "Optionally compiled or interpreted, high-level, toy programming language, with an eye towards providing standardized Software Engineering best practices out of the box" + desc: "High-level toy programming language providing standardized Software Engineering best practices out of the box" ext: - claro web: home: "https://clarolang.com/" - source: "https://github.com/JasonSteving99/claro-lang/" - category: recreational - mode: compiled or interpreted - platform: Bazel + source: "https://github.com/JasonSteving99/claro-lang" + category: general + mode: + - compiled + - interpreted + platform: [] syntax: - - java + - c typing: static paradigm: - functional - imperative - usage: literally just Jason Steving + usage: personal install: - apt: - - default-jdk - manual: | - install -d "${pkg}/usr/local/bin" + apt: + - default-jdk + manual: | + install -d "${pkg}/opt/claro/programs" + install -d "${pkg}/usr/local/bin" - # Pull resources from the latest Claro repo release. - ver="$(latest_release JasonSteving99/claro-lang)" + # Pull resources from the latest Claro repo release. + ver="$(latest_release JasonSteving99/claro-lang | sed 's/^v//')" - # Pull the tarball of the built Bazel repo's bazel-bin instead of just the sources. - wget "https://github.com/JasonSteving99/claro-lang/releases/download/${ver}/claro-lang-bazel-bin.tar.gz" - tar -xzvf claro-lang-bazel-bin.tar.gz + # Pull the tarball of the built Bazel repo's bazel-bin instead of just the sources. + wget "https://github.com/JasonSteving99/claro-lang/releases/download/v${ver}/claro-lang-bazel-bin.tar.gz" + tar -xf claro-lang-bazel-bin.tar.gz - ##################################################################################################### - # We don't want to depend on Bazel at all for rebuilding, it's just one file changing. Rebuild it using - # the packaged jar files and then update the jar holding that recompiled file and run the Bazel gen'd - # run script which points at all the correct jar runfiles. First though, we need to slightly modify - # the Bazel gen'd runscript to rebuild using the packaged jars for us (without explicitly rerunning Bazel - # itself since this is super slow and involves starting up a new Bazel server...). - pushd claro_programs/ > /dev/null - fancydelim=$(printf '\001') # https://stackoverflow.com/a/25821096/10027370 + ##################################################################################################### + # We don't want to depend on Bazel at all for rebuilding, it's just one file changing. Rebuild it using + # the packaged jar files and then update the jar holding that recompiled file and run the Bazel gen'd + # run script which points at all the correct jar runfiles. First though, we need to slightly modify + # the Bazel gen'd runscript to rebuild using the packaged jars for us (without explicitly rerunning Bazel + # itself since this is super slow and involves starting up a new Bazel server...). + pushd claro_programs + read -r -d '' MY_SCRIPT <<"EOF" ||: + REBUILD_CLASSPATH="${CLASSPATH}" # For the purpose of rebuilding, we need lombok and autovalue on the classpath. - MY_SCRIPT=' REBUILD_CLASSPATH="${CLASSPATH}"\n' - MY_SCRIPT+=' REBUILD_CLASSPATH+=":lombok-1.18.20.jar"\n' - MY_SCRIPT+=' REBUILD_CLASSPATH+=":auto-value-1.5.3.jar"\n' - MY_SCRIPT+=' javac -classpath $REBUILD_CLASSPATH Conditions.java\n' + REBUILD_CLASSPATH+=":lombok-1.18.20.jar" + REBUILD_CLASSPATH+=":auto-value-1.5.3.jar" + javac -classpath $REBUILD_CLASSPATH Conditions.java # There's an assumption that the dir ./com/claro/ was made in the tarball before this. - MY_SCRIPT+=' mv Conditions*.class com/claro\n' - MY_SCRIPT+=' jar -uf "${RUNPATH}src/java/com/claro/claro_programs/conditions_compiled_claro_image.jar" com/claro/Conditions*.class\n' - MY_SCRIPT+=' java -classpath $CLASSPATH "${ARGS[@]}"\n' - # We insert our own exit here to short-circuit the Bazel run script's call to JAVABIN which is - # invalid on this host machine. - MY_SCRIPT+=' exit $?\n' + mv Conditions*.class com/claro + jar -uf "${RUNPATH}src/java/com/claro/claro_programs/conditions_compiled_claro_image.jar" com/claro/Conditions*.class + java -classpath $CLASSPATH "${ARGS[@]}" + EOF - # Insert MY_SCRIPT into the Bazel run script just before java gets executed. We're reusing Bazel's run - # script basically just to get a conveniently curated CLASSPATH variable generated to point to all the - # randomly scattered jar files that Bazel places throughout bazel-bin/. - sed -n "H;\${x;s/\n//;s${fancydelim}create_and_run_classpath_jar\nelse\n${fancydelim}&${MY_SCRIPT}\n${fancydelim};p;}" conditions_compiled_claro_image > conditions_compiled_claro_image2 + # Insert MY_SCRIPT into the Bazel run script just before java gets executed. We're reusing Bazel's run + # script basically just to get a conveniently curated CLASSPATH variable generated to point to all the + # randomly scattered jar files that Bazel places throughout bazel-bin/. + sed -i "s|exec \$JAVABIN.*|${MY_SCRIPT//$'\n'/\\n}|" conditions_compiled_claro_image - # I'm not good enough with sed to figure out how to avoid this extra temporary stop in a second file. Oh well. - chmod 777 conditions_compiled_claro_image - cat conditions_compiled_claro_image2 > conditions_compiled_claro_image - rm conditions_compiled_claro_image2 + chmod -R u+rw * - popd > /dev/null - ##################################################################################################### + popd + ##################################################################################################### - cp -R claro_programs "${pkg}/usr/local/bin" + cp -R claro_programs/. "${pkg}/opt/claro/programs/" - wget "https://github.com/JasonSteving99/claro-lang/releases/download/v0.1.0/claro_compiler_binary_deploy.jar" - cp claro_compiler_binary_deploy.jar "${pkg}/usr/local/bin" + wget "https://github.com/JasonSteving99/claro-lang/releases/download/v${ver}/claro_compiler_binary_deploy.jar" + cp claro_compiler_binary_deploy.jar "${pkg}/opt/claro/" setup: | - cp -R /usr/local/bin/* "${HOME}/src" + cp -R /opt/claro/programs "./" -main: "claro_programs/Conditions.claro" +main: "programs/Conditions.claro" template: | - # Thanks for trying out Claro during its early development stages! - # To learn Claro by example, check out: - # https://clarolang.com/tree/main/src/java/com/claro/claro_programs + # Thanks for trying out Claro during its early development stages! + # To learn Claro by example, check out: + # https://clarolang.com/tree/main/src/java/com/claro/claro_programs - print("Hello, world!"); - -run: | - # Skip rebuilding the entire compiler all over again and instead just use the pre-built Claro compiler jar. - chmod +rw claro_programs/Conditions.java - java -jar claro_compiler_binary_deploy.jar --java_source --silent --classname=Conditions --package=com.claro \ - < claro_programs/Conditions.claro \ - > claro_programs/Conditions.java \ - && \ - pushd claro_programs/ > /dev/null \ - && \ - ./conditions_compiled_claro_image \ - && \ - popd > /dev/null + print("Hello, world!"); repl: | - java -jar claro_compiler_binary_deploy.jar --repl --silent + java -jar /opt/claro/claro_compiler_binary_deploy.jar --repl --silent + +# Skip rebuilding the entire compiler all over again and instead just +# use the pre-built Claro compiler jar. +compile: | + java -jar /opt/claro/claro_compiler_binary_deploy.jar \ + --java_source --silent \ + --classname=Conditions --package=com.claro \ + < programs/Conditions.claro \ + > programs/Conditions.java +run: | + set -e + + cd programs + ./conditions_compiled_claro_image ||: + + java -jar /opt/claro/claro_compiler_binary_deploy.jar --repl --silent input: | - print(123 * 234); - -skip: - - runrepl + print(123 * 234); From cb2c2da32cbd761172be6efab35a22effef4f6a4 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Wed, 22 Dec 2021 12:44:57 -0800 Subject: [PATCH 09/10] More --- langs/claro.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/langs/claro.yaml b/langs/claro.yaml index 6a18a54..0b88a3c 100644 --- a/langs/claro.yaml +++ b/langs/claro.yaml @@ -28,7 +28,6 @@ install: - default-jdk manual: | install -d "${pkg}/opt/claro/programs" - install -d "${pkg}/usr/local/bin" # Pull resources from the latest Claro repo release. ver="$(latest_release JasonSteving99/claro-lang | sed 's/^v//')" From 90d5ed70807e4ae65a1ec52757750f79e337eb6e Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Wed, 22 Dec 2021 12:48:22 -0800 Subject: [PATCH 10/10] Bump timeout --- langs/claro.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/langs/claro.yaml b/langs/claro.yaml index 0b88a3c..2f6aae4 100644 --- a/langs/claro.yaml +++ b/langs/claro.yaml @@ -103,3 +103,5 @@ run: | input: | print(123 * 234); + +timeoutFactor: 2