From 1570d33046e8e869f735417ee1293033b2f06809 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Thu, 29 Aug 2024 13:42:34 -0400 Subject: [PATCH] Fix install of circom Signed-off-by: Andrew Richardson --- domains/zeto/.gitignore | 1 + domains/zeto/build.gradle | 31 +++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/domains/zeto/.gitignore b/domains/zeto/.gitignore index d16d1b987..415a0d732 100644 --- a/domains/zeto/.gitignore +++ b/domains/zeto/.gitignore @@ -1,2 +1,3 @@ internal/zeto/abis/ zkp/ +tools/ diff --git a/domains/zeto/build.gradle b/domains/zeto/build.gradle index cb0a6beb5..2b6242f1c 100644 --- a/domains/zeto/build.gradle +++ b/domains/zeto/build.gradle @@ -13,12 +13,15 @@ * SPDX-License-Identifier: Apache-2.0 */ +import org.apache.tools.ant.taskdefs.condition.Os + ext { goFiles = fileTree(".") { include "internal/**/*.go" } jsCircuits = "${rootDir}/zeto/zkp/circuits" zkpOut = "${projectDir}/zkp" + toolsOut = "${projectDir}/tools" } configurations { @@ -71,9 +74,28 @@ task circuitsInstall(type: Exec) { outputs.dir("node_modules") } -task installCircom(type: Download) { - src "https://github.com/iden3/circom/releases/download/v2.1.9/circom-linux-amd64" - dest new File(buildDir, "circom") +task installCircom { + def filename + def outname + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + filename = "circom-windows-amd64.exe" + outname = "circom.exe" + } else if (Os.isFamily(Os.FAMILY_MAC)) { + filename = "circom-macos-amd64" + outname = "circom" + } else { + filename = "circom-linux-amd64" + outname = "circom" + } + + def url = "https://github.com/iden3/circom/releases/download/v2.1.9/${filename}" + def f = new File(toolsOut, outname) + doFirst { + mkdir(f.parent) + new URL(url).withInputStream{ i -> f.withOutputStream{ it << i }} + f.setExecutable(true) + } + outputs.file(f) } task circuitsGen(type: Exec, dependsOn: [circuitsInstall, installCircom]) { @@ -82,7 +104,7 @@ task circuitsGen(type: Exec, dependsOn: [circuitsInstall, installCircom]) { args '--', '-c', 'anon' workingDir "${rootDir}/zeto/zkp/circuits" - environment 'PATH', "${environment.PATH}:${buildDir}/circom" + environment 'PATH', "${toolsOut}${File.pathSeparator}${environment.PATH}" environment "CIRCUITS_ROOT", zkpOut environment "PROVING_KEYS_ROOT", zkpOut environment "PTAU_DOWNLOAD_PATH", zkpOut @@ -122,4 +144,5 @@ task clean(type: Delete) { delete 'coverage' delete 'internal/zeto/abis' delete zkpOut + delete toolsOut }