From: Thomas Walker Lynch Date: Thu, 12 Sep 2024 02:18:43 +0000 (+0000) Subject: build of tools bash scripts replaced by gradle build file X-Git-Url: https://git.reasoningtechnology.com/style/static/gitweb.css?a=commitdiff_plain;h=1bbc9776dbdf19417c05814300541b4dda0c603b;p=GQL-to-Cypher build of tools bash scripts replaced by gradle build file --- diff --git a/.gitignore b/.gitignore index 762861f..02b640c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ #*# *~ a.out - +.gradle/ diff --git a/Erebus/.gitignore b/Erebus/.gitignore new file mode 100644 index 0000000..120f485 --- /dev/null +++ b/Erebus/.gitignore @@ -0,0 +1,2 @@ +* +!/.gitignore diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..ec3a5bb --- /dev/null +++ b/build.gradle @@ -0,0 +1,145 @@ + +defaultTasks 'installTools' + +/*-------------------------------------------------------------------------------- + + Configuration variables + +*/ + +// project structure +def repoHome = rootDir +def toolDir = "${repoHome}/tool" +def upstreamDir = "${toolDir}/upstream" +def executorDir = "${toolDir}/executor" +def erebusDir = file("${rootDir}/Erebus") + +// tool versions +def antlrVersion = '4.11.1' +def jdkVersion = '22.0.1' +def jdkBuild = '8' + +// The urls for upstream files +def antlrUrl = "https://www.antlr.org/download/antlr-${antlrVersion}-complete.jar" +def jdkUrl = "https://github.com/adoptium/temurin22-binaries/releases/download/jdk-${jdkVersion}%2B${jdkBuild}/OpenJDK22U-jdk_x64_linux_hotspot_${jdkVersion}_${jdkBuild}.tar.gz" + +task installAntlr { + doLast { + def antlrJar = file("${upstreamDir}/antlr-${antlrVersion}-complete.jar") + def antlrExecutorJar = file("${executorDir}/antlr-${antlrVersion}-complete.jar") + + mkdir(upstreamDir) + mkdir(executorDir) + + if (!antlrJar.exists()) { + println "Downloading ANTLR..." + new URL(antlrUrl).withInputStream { i -> antlrJar.withOutputStream { it << i } } + } + + if (!antlrExecutorJar.exists()) { + copy { + from antlrJar + into executorDir + } + println "ANTLR installed in executor." + } else { + println "ANTLR already installed." + } + } +} + +task installJava { + doLast { + def jdkTar = file("${upstreamDir}/jdk-${jdkVersion}.tar.gz") + def jdkDir = file("${toolDir}/jdk-${jdkVersion}+${jdkBuild}") + + mkdir(upstreamDir) + mkdir(toolDir) + + if (!jdkTar.exists()) { + println "Downloading JDK..." + new URL(jdkUrl).withInputStream { i -> jdkTar.withOutputStream { it << i } } + } + + if (!jdkDir.exists()) { + println "Extracting JDK..." + copy { + from tarTree(resources.gzip(jdkTar)) + into toolDir + } + println "JDK installed." + } else { + println "JDK already installed." + } + + // Set JAVA_HOME and test Java installation + def javaHome = file("${jdkDir}") + if (!javaHome.exists()) { + throw new GradleException("JDK extraction failed.") + } + + // variables saved for use in subproject build scripts + project.ext.javaHome = jdkDir + + println "Java installation complete." + } +} + +// Add a task to install both tools +task installTools { + dependsOn installAntlr, installJava +} + +// Ensure all subprojects depend on the tool installation +subprojects { + afterEvaluate { project -> + project.tasks.each { task -> + task.dependsOn ':installTools' + } + } +} + +task cleanTool { + description = 'Cleans the installed tools (but not upstream files)' + doLast { + // Define the directories or files to clean + def toolDirs = [ + file("${rootDir}/tool/bin"), + file("${rootDir}/tool/executor"), + file("${rootDir}/tool/jdk-22.0.1+8") + ] + + // Delete the tool directories + toolDirs.each { dir -> + if (dir.exists()) { + println "Deleting ${dir}..." + delete dir + } + } + + println " ./tool cleaned." + } +} + +task cleanErebus { + description = "Cleans the project level temporary directory 'Erebus'" + + doLast { + if (erebusDir.exists()) { + erebusDir.eachFile { file -> + if (file.name != '.gitignore') { + if (file.isDirectory()) { + file.deleteDir() + } else { + file.delete() + } + } + } + println "Erebus directory cleaned, except for .gitignore." + } else { + println "Erebus directory does not exist." + } + } +} + + diff --git a/developer/.gitignore b/developer/.gitignore deleted file mode 100644 index fd21199..0000000 --- a/developer/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ - -/jvm/ -/javac/ANTLR/ -/temporary/ - diff --git a/developer/Erebus/.gitignore b/developer/Erebus/.gitignore new file mode 100644 index 0000000..2db43ed --- /dev/null +++ b/developer/Erebus/.gitignore @@ -0,0 +1,4 @@ + +* +!/.gitignore + diff --git a/developer/Lethe/.githolder b/developer/Lethe/.githolder new file mode 100644 index 0000000..e69de29 diff --git a/developer/Lethe/Hibou_build.gradle b/developer/Lethe/Hibou_build.gradle new file mode 100644 index 0000000..ca38ddd --- /dev/null +++ b/developer/Lethe/Hibou_build.gradle @@ -0,0 +1,106 @@ +task setup { + doLast { + def dirs = [ + "$(ANTLR_IN_PRIMARY_DIR)", + "$(JAVA_COMP_IN_DIR)", + "$(JAVA_COMP_IN_PRIMARY_DIR)", + "$(JAVA_COMP_IN_ANTLR_DIR)", + "$(JAVA_COMP_IN_SYN_DIR)", + "$(JVM_IN_DIR)", + "$(EXECUTOR_IN_DIR)", + "test", + "deprecated", + "experiment", + "ologist", + "temporary" + ] + dirs.each { dir -> + if (!file(dir).exists()) { + mkdir dir + } + } + } +} + +def compileJava(source, target) { + tasks.create(name: "compile${source}", type: Exec) { + commandLine '$(JAVA_COMP)', '-d', '$(JAVA_COMP_OUT_DIR)', '-sourcepath', '$(JAVA_COMP_IN_DL)', source + doLast { + println "Compiled ${source} to ${target}" + } + } +} + +def createJar(source, target) { + tasks.create(name: "jar${source}", type: Exec) { + commandLine '$(JAVA_ARCHIVE)', 'cf', target, '-C', '$(JAVA_COMP_OUT_DIR)', source + doLast { + println "Created ${target}" + } + } +} + +def createWrapper(source, target) { + tasks.create(name: "wrapper${source}", type: Exec) { + doLast { + def script = new File(target) + script.text = "#!/usr/bin/env bash\n$(JAVA_INTERP) -cp ${CLASSPATH}:${JVM_IN_DP}:${JVM_IN_DP}/${source}.jar ${source} \$@" + script.setExecutable(true) + println "Created program ${target}" + } + } +} + +task ANTLR_OUT_FL { + dependsOn setup + doLast { + println "Building ANTLR_OUT_FL..." + // Add specific build steps for ANTLR_OUT_FL here + } +} + +task all { + dependsOn ANTLR_OUT_FL + doLast { + println "Building all targets..." + } +} + +task clean { + doLast { + println "Use the command `clean