Create binaries with libsnark disabled on new tags (#319)
* add appveyor, travis, remove libsnark as default, add push to gh * fix appveyor * change appveyor to nightly * use cargo for build job * change to build everywhere * update token, reduce targets * add more targets * add on liner script * remove rustc dep * add need_cmd * add check cmd * simple brackets * use check_cmd for curl * copy stdlib to OUT_DIR * ship stdlib in archive * install stdlib, give PATH hints after build script * clean * comment * scripts: ensure one-liner install script works with FreeBSD * remove appveyor for now * clean, remove windows, remove appveyor, remove travis test * put back cross install * fix stdlib test generation * disable tests in travis * restore test script to prevent tests to run.. * change scripts to keep same behaviour now that libsnark is disabled by default * update docs with installer * change docker to dockerhub * change repo
This commit is contained in:
parent
0014fdee48
commit
b93bf6f1ef
16 changed files with 555 additions and 21 deletions
BIN
.cargo/bin/zokrates
Executable file
BIN
.cargo/bin/zokrates
Executable file
Binary file not shown.
71
.travis.yml
Normal file
71
.travis.yml
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
# Based on the "trust" template v0.1.2
|
||||||
|
# https://github.com/japaric/trust/tree/v0.1.2
|
||||||
|
|
||||||
|
dist: trusty
|
||||||
|
language: rust
|
||||||
|
rust:
|
||||||
|
- nightly
|
||||||
|
services: docker
|
||||||
|
sudo: required
|
||||||
|
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- CRATE_NAME=zokrates
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
# Linux
|
||||||
|
- env: TARGET=aarch64-unknown-linux-gnu
|
||||||
|
- env: TARGET=arm-unknown-linux-gnueabi
|
||||||
|
- env: TARGET=i686-unknown-linux-gnu
|
||||||
|
- env: TARGET=x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
|
# OSX
|
||||||
|
- env: TARGET=i686-apple-darwin
|
||||||
|
os: osx
|
||||||
|
- env: TARGET=x86_64-apple-darwin
|
||||||
|
os: osx
|
||||||
|
|
||||||
|
# *BSD
|
||||||
|
- env: TARGET=x86_64-unknown-freebsd
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- set -e
|
||||||
|
- rustup self update
|
||||||
|
|
||||||
|
install:
|
||||||
|
- sh ci/install.sh
|
||||||
|
- source ~/.cargo/env || true
|
||||||
|
|
||||||
|
script:
|
||||||
|
- bash ci/script.sh
|
||||||
|
|
||||||
|
after_script: set +e
|
||||||
|
|
||||||
|
before_deploy:
|
||||||
|
- sh ci/before_deploy.sh
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
api_key:
|
||||||
|
secure: bJV3yFnt19nv2mc+0ekX6y6qfrq1mPCo+RZaPfY+KaUNJCposqIlvwZ0+TZIzKNNqrvC+oUyt8/jWU2A/hy1oFTkZmdtdcGkKYkm1C9v62ntOK6xv88qsZ4lz0Q6qKGoa7Ao3MZ9zomDl9WV+IESnPlnE5mCqw0sW1YF+pabZIojHPJyjspsKmcRADpPCSm9Qbotq521Q8+vGcfCLSlVOpGTMfG4MwB2K8FRV9m/wVaFjbKHg97rVMj1RKwtCDt0UNYTUhtfQ0jKqFGnQBxMKGhuvcoWQfjjcAcBGcBPfhXMXhOHEdbxrsdgpj/AJ4UTZlU15iTZ9wZlkSvBx4ttN2I0QEGt8UbzcXyG2JWkNBdKMAecQQU2g+UoAzLWFahzVgxrTfxiTQ8l9ax2hnY4xy+Qh4sMMWg1on1n0iHfIc4co5T0hNeCwXm8tcFIUtbE3FC92r5l23jom8EpQkDR3KnNt22wOqYOXH5yre2ZCi29phK3JkoXBfJfs1A8PQKXw/CiIfpPTQWYR2A6C2eQ27zia2sowzA4RUbplP1CAnCZrhjcNhU2R2DlgklDUkqwmaSetCQ1ZaWzXI6mUs/VJLpMbWKcX5kRT1C+ZhC0ZBbGrxrIPKWEdZHseE5uHNXFWxxvh5QrdpmULpeFL5wnXyWnrDOMpnkZx60w6VUHfbM=
|
||||||
|
file_glob: true
|
||||||
|
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
|
||||||
|
on:
|
||||||
|
tags: true
|
||||||
|
provider: releases
|
||||||
|
skip_cleanup: true
|
||||||
|
|
||||||
|
cache: cargo
|
||||||
|
before_cache:
|
||||||
|
# Travis can't cache files that are not readable by "others"
|
||||||
|
- chmod -R a+r $HOME/.cargo
|
||||||
|
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
# release tags
|
||||||
|
- /^\d+\.\d+\.\d+.*$/
|
||||||
|
- master
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
email:
|
||||||
|
on_success: never
|
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -396,6 +396,11 @@ dependencies = [
|
||||||
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fs_extra"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fuchsia-cprng"
|
name = "fuchsia-cprng"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
|
@ -1278,6 +1283,7 @@ dependencies = [
|
||||||
name = "zokrates_stdlib"
|
name = "zokrates_stdlib"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1333,6 +1339,7 @@ dependencies = [
|
||||||
"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02"
|
"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02"
|
||||||
"checksum ff 0.5.0 (git+https://github.com/matterinc/ff?tag=0.5)" = "<none>"
|
"checksum ff 0.5.0 (git+https://github.com/matterinc/ff?tag=0.5)" = "<none>"
|
||||||
"checksum ff_derive 0.4.0 (git+https://github.com/matterinc/ff?tag=0.5)" = "<none>"
|
"checksum ff_derive 0.4.0 (git+https://github.com/matterinc/ff?tag=0.5)" = "<none>"
|
||||||
|
"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
|
||||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||||
"checksum futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "62941eff9507c8177d448bd83a44d9b9760856e184081d8cd79ba9f03dd24981"
|
"checksum futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "62941eff9507c8177d448bd83a44d9b9760856e184081d8cd79ba9f03dd24981"
|
||||||
"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4"
|
"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4"
|
||||||
|
|
|
@ -13,6 +13,10 @@ _This is a proof-of-concept implementation. It has not been tested for productio
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -LSfs get.zokrat.es | sh
|
||||||
|
```
|
||||||
|
|
||||||
Have a look at the [documentation](https://zokrates.github.io/) for more information about using ZoKrates.
|
Have a look at the [documentation](https://zokrates.github.io/) for more information about using ZoKrates.
|
||||||
A getting started tutorial can be found [here](https://zokrates.github.io/sha256example.html).
|
A getting started tutorial can be found [here](https://zokrates.github.io/sha256example.html).
|
||||||
|
|
||||||
|
|
4
build.sh
4
build.sh
|
@ -4,7 +4,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -n "$WITH_LIBSNARK" ]; then
|
if [ -n "$WITH_LIBSNARK" ]; then
|
||||||
cargo build
|
cargo -Z package-features build --package zokrates_cli --features="libsnark"
|
||||||
else
|
else
|
||||||
cargo -Z package-features build --no-default-features
|
cargo build
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -n "$WITH_LIBSNARK" ]; then
|
if [ -n "$WITH_LIBSNARK" ]; then
|
||||||
cargo build --release
|
cargo -Z package-features build --release --package zokrates_cli --features="libsnark"
|
||||||
else
|
else
|
||||||
cargo -Z package-features build --release --no-default-features
|
cargo build --release
|
||||||
fi
|
fi
|
||||||
|
|
35
ci/before_deploy.sh
Executable file
35
ci/before_deploy.sh
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
# This script takes care of building your crate and packaging it for release
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local src=$(pwd) \
|
||||||
|
stage=
|
||||||
|
|
||||||
|
case $TRAVIS_OS_NAME in
|
||||||
|
linux)
|
||||||
|
stage=$(mktemp -d)
|
||||||
|
;;
|
||||||
|
osx)
|
||||||
|
stage=$(mktemp -d -t tmp)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
test -f Cargo.lock || cargo generate-lockfile
|
||||||
|
|
||||||
|
cross build --bin zokrates --target $TARGET --release
|
||||||
|
|
||||||
|
# Package artifacts
|
||||||
|
# Binary
|
||||||
|
cp target/$TARGET/release/zokrates $stage/
|
||||||
|
# Standard library
|
||||||
|
cp -r zokrates_stdlib/stdlib $stage
|
||||||
|
|
||||||
|
cd $stage
|
||||||
|
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
|
||||||
|
cd $src
|
||||||
|
|
||||||
|
rm -rf $stage
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
47
ci/install.sh
Executable file
47
ci/install.sh
Executable file
|
@ -0,0 +1,47 @@
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local target=
|
||||||
|
if [ $TRAVIS_OS_NAME = linux ]; then
|
||||||
|
target=x86_64-unknown-linux-musl
|
||||||
|
sort=sort
|
||||||
|
else
|
||||||
|
target=x86_64-apple-darwin
|
||||||
|
sort=gsort # for `sort --sort-version`, from brew's coreutils.
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Builds for iOS are done on OSX, but require the specific target to be
|
||||||
|
# installed.
|
||||||
|
case $TARGET in
|
||||||
|
aarch64-apple-ios)
|
||||||
|
rustup target install aarch64-apple-ios
|
||||||
|
;;
|
||||||
|
armv7-apple-ios)
|
||||||
|
rustup target install armv7-apple-ios
|
||||||
|
;;
|
||||||
|
armv7s-apple-ios)
|
||||||
|
rustup target install armv7s-apple-ios
|
||||||
|
;;
|
||||||
|
i386-apple-ios)
|
||||||
|
rustup target install i386-apple-ios
|
||||||
|
;;
|
||||||
|
x86_64-apple-ios)
|
||||||
|
rustup target install x86_64-apple-ios
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# This fetches latest stable release
|
||||||
|
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
|
||||||
|
| cut -d/ -f3 \
|
||||||
|
| grep -E '^v[0.1.0-9.]+$' \
|
||||||
|
| $sort --version-sort \
|
||||||
|
| tail -n1)
|
||||||
|
curl -LSfs https://japaric.github.io/trust/install.sh | \
|
||||||
|
sh -s -- \
|
||||||
|
--force \
|
||||||
|
--git japaric/cross \
|
||||||
|
--tag $tag \
|
||||||
|
--target $target
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
11
ci/script.sh
Normal file
11
ci/script.sh
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# This script takes care of testing your crate
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
# This is the test phase. We will only build as tests happened before.
|
||||||
|
main() {
|
||||||
|
cross build --target $TARGET
|
||||||
|
cross build --target $TARGET --release
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
|
@ -4,7 +4,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -n "$WITH_LIBSNARK" ]; then
|
if [ -n "$WITH_LIBSNARK" ]; then
|
||||||
cargo test --release -- --ignored
|
cargo -Z package-features test --release --package zokrates_cli --features="libsnark" -- --ignored
|
||||||
else
|
else
|
||||||
cargo -Z package-features test --release --no-default-features -- --ignored
|
cargo test --release -- --ignored
|
||||||
fi
|
fi
|
337
scripts/one_liner.sh
Executable file
337
scripts/one_liner.sh
Executable file
|
@ -0,0 +1,337 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
help() {
|
||||||
|
cat <<'EOF'
|
||||||
|
Install ZoKrates
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
one_liner.sh [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-f, --force Force overwriting an existing installation
|
||||||
|
--to LOCATION Where to install (default ~/.zokrates)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
check_cmd() {
|
||||||
|
command -v "$1" > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
need_cmd() {
|
||||||
|
if ! check_cmd "$1"; then
|
||||||
|
err "need '$1' (command not found)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_bitness() {
|
||||||
|
need_cmd head
|
||||||
|
# Architecture detection without dependencies beyond coreutils.
|
||||||
|
# ELF files start out "\x7fELF", and the following byte is
|
||||||
|
# 0x01 for 32-bit and
|
||||||
|
# 0x02 for 64-bit.
|
||||||
|
# The printf builtin on some shells like dash only supports octal
|
||||||
|
# escape sequences, so we use those.
|
||||||
|
local _current_exe_head
|
||||||
|
_current_exe_head=$(head -c 5 /proc/self/exe )
|
||||||
|
if [ "$_current_exe_head" = "$(printf '\177ELF\001')" ]; then
|
||||||
|
echo 32
|
||||||
|
elif [ "$_current_exe_head" = "$(printf '\177ELF\002')" ]; then
|
||||||
|
echo 64
|
||||||
|
else
|
||||||
|
err "unknown platform bitness"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_endianness() {
|
||||||
|
local cputype=$1
|
||||||
|
local suffix_eb=$2
|
||||||
|
local suffix_el=$3
|
||||||
|
|
||||||
|
# detect endianness without od/hexdump, like get_bitness() does.
|
||||||
|
need_cmd head
|
||||||
|
need_cmd tail
|
||||||
|
|
||||||
|
local _current_exe_endianness
|
||||||
|
_current_exe_endianness="$(head -c 6 /proc/self/exe | tail -c 1)"
|
||||||
|
if [ "$_current_exe_endianness" = "$(printf '\001')" ]; then
|
||||||
|
echo "${cputype}${suffix_el}"
|
||||||
|
elif [ "$_current_exe_endianness" = "$(printf '\002')" ]; then
|
||||||
|
echo "${cputype}${suffix_eb}"
|
||||||
|
else
|
||||||
|
err "unknown platform endianness"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_architecture() {
|
||||||
|
local _ostype _cputype _bitness _arch
|
||||||
|
_ostype="$(uname -s)"
|
||||||
|
_cputype="$(uname -m)"
|
||||||
|
|
||||||
|
if [ "$_ostype" = Linux ]; then
|
||||||
|
if [ "$(uname -o)" = Android ]; then
|
||||||
|
_ostype=Android
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then
|
||||||
|
# Darwin `uname -m` lies
|
||||||
|
if sysctl hw.optional.x86_64 | grep -q ': 1'; then
|
||||||
|
_cputype=x86_64
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$_ostype" in
|
||||||
|
|
||||||
|
Android)
|
||||||
|
_ostype=linux-android
|
||||||
|
;;
|
||||||
|
|
||||||
|
Linux)
|
||||||
|
_ostype=unknown-linux-gnu
|
||||||
|
_bitness=$(get_bitness)
|
||||||
|
;;
|
||||||
|
|
||||||
|
FreeBSD)
|
||||||
|
_ostype=unknown-freebsd
|
||||||
|
;;
|
||||||
|
|
||||||
|
NetBSD)
|
||||||
|
_ostype=unknown-netbsd
|
||||||
|
;;
|
||||||
|
|
||||||
|
DragonFly)
|
||||||
|
_ostype=unknown-dragonfly
|
||||||
|
;;
|
||||||
|
|
||||||
|
Darwin)
|
||||||
|
_ostype=apple-darwin
|
||||||
|
;;
|
||||||
|
|
||||||
|
MINGW* | MSYS* | CYGWIN*)
|
||||||
|
_ostype=pc-windows-gnu
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
err "unrecognized OS type: $_ostype"
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$_cputype" in
|
||||||
|
|
||||||
|
i386 | i486 | i686 | i786 | x86)
|
||||||
|
_cputype=i686
|
||||||
|
;;
|
||||||
|
|
||||||
|
xscale | arm)
|
||||||
|
_cputype=arm
|
||||||
|
if [ "$_ostype" = "linux-android" ]; then
|
||||||
|
_ostype=linux-androideabi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
armv6l)
|
||||||
|
_cputype=arm
|
||||||
|
if [ "$_ostype" = "linux-android" ]; then
|
||||||
|
_ostype=linux-androideabi
|
||||||
|
else
|
||||||
|
_ostype="${_ostype}eabihf"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
armv7l | armv8l)
|
||||||
|
_cputype=armv7
|
||||||
|
if [ "$_ostype" = "linux-android" ]; then
|
||||||
|
_ostype=linux-androideabi
|
||||||
|
else
|
||||||
|
_ostype="${_ostype}eabihf"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
aarch64)
|
||||||
|
_cputype=aarch64
|
||||||
|
;;
|
||||||
|
|
||||||
|
x86_64 | x86-64 | x64 | amd64)
|
||||||
|
_cputype=x86_64
|
||||||
|
;;
|
||||||
|
|
||||||
|
mips)
|
||||||
|
_cputype=$(get_endianness mips '' el)
|
||||||
|
;;
|
||||||
|
|
||||||
|
mips64)
|
||||||
|
if [ "$_bitness" -eq 64 ]; then
|
||||||
|
# only n64 ABI is supported for now
|
||||||
|
_ostype="${_ostype}abi64"
|
||||||
|
_cputype=$(get_endianness mips64 '' el)
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
ppc)
|
||||||
|
_cputype=powerpc
|
||||||
|
;;
|
||||||
|
|
||||||
|
ppc64)
|
||||||
|
_cputype=powerpc64
|
||||||
|
;;
|
||||||
|
|
||||||
|
ppc64le)
|
||||||
|
_cputype=powerpc64le
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
err "unknown CPU type: $_cputype"
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Detect 64-bit linux with 32-bit userland
|
||||||
|
if [ "${_ostype}" = unknown-linux-gnu ] && [ "${_bitness}" -eq 32 ]; then
|
||||||
|
case $_cputype in
|
||||||
|
x86_64)
|
||||||
|
_cputype=i686
|
||||||
|
;;
|
||||||
|
mips64)
|
||||||
|
_cputype=$(get_endianness mips '' el)
|
||||||
|
;;
|
||||||
|
powerpc64)
|
||||||
|
_cputype=powerpc
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Detect armv7 but without the CPU features Rust needs in that build,
|
||||||
|
# and fall back to arm.
|
||||||
|
# See https://github.com/rust-lang/rustup.rs/issues/587.
|
||||||
|
if [ "$_ostype" = "unknown-linux-gnueabihf" ] && [ "$_cputype" = armv7 ]; then
|
||||||
|
if ensure grep '^Features' /proc/cpuinfo | grep -q -v neon; then
|
||||||
|
# At least one processor does not have NEON.
|
||||||
|
_cputype=arm
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
_arch="${_cputype}-${_ostype}"
|
||||||
|
|
||||||
|
RETVAL="$_arch"
|
||||||
|
}
|
||||||
|
|
||||||
|
say() {
|
||||||
|
echo "ZoKrates: $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
say_err() {
|
||||||
|
say "$1" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
err() {
|
||||||
|
if [ ! -z $td ]; then
|
||||||
|
rm -rf $td
|
||||||
|
fi
|
||||||
|
|
||||||
|
say_err "ERROR $1"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
need() {
|
||||||
|
if ! command -v $1 > /dev/null 2>&1; then
|
||||||
|
err "need $1 (command not found)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
need_cmd curl
|
||||||
|
|
||||||
|
force=false
|
||||||
|
while test $# -gt 0; do
|
||||||
|
case $1 in
|
||||||
|
--force | -f)
|
||||||
|
force=true
|
||||||
|
;;
|
||||||
|
--to)
|
||||||
|
dest=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
need basename
|
||||||
|
need curl
|
||||||
|
need install
|
||||||
|
need mkdir
|
||||||
|
need mktemp
|
||||||
|
need tar
|
||||||
|
|
||||||
|
git="schaeff/zokrates"
|
||||||
|
|
||||||
|
url="https://github.com/$git"
|
||||||
|
|
||||||
|
url="$url/releases"
|
||||||
|
|
||||||
|
tag=$(curl -s "$url/latest" | cut -d'"' -f2 | rev | cut -d'/' -f1 | rev)
|
||||||
|
say_err "Tag: latest ($tag)"
|
||||||
|
|
||||||
|
# detect host architecture
|
||||||
|
get_architecture || return 1
|
||||||
|
arch="$RETVAL"
|
||||||
|
|
||||||
|
# find file extension. For now always tar.gz
|
||||||
|
ext="tar.gz"
|
||||||
|
|
||||||
|
say_err "Detected architecture: $arch"
|
||||||
|
|
||||||
|
# Set target directory
|
||||||
|
if [ -z $dest ]; then
|
||||||
|
dest="$HOME/.zokrates"
|
||||||
|
fi
|
||||||
|
|
||||||
|
say_err "Installing to: $dest"
|
||||||
|
|
||||||
|
# Fetch archive
|
||||||
|
url="$url/download/$tag/zokrates-$tag-$arch.$ext"
|
||||||
|
|
||||||
|
say_err "Fetching: $url"
|
||||||
|
|
||||||
|
td=$(mktemp -d || mktemp -d -t tmp)
|
||||||
|
curl -sLf --show-error $url | tar -C $td -xzf -
|
||||||
|
|
||||||
|
# install ZoKrates
|
||||||
|
for f in $(ls $td); do
|
||||||
|
# put folders into $dest
|
||||||
|
if [ -d $td/$f ]; then
|
||||||
|
if [ -e "$dest/$f" ] && [ $force = false ]; then
|
||||||
|
err "$f already exists in $dest, use --force to overwrite"
|
||||||
|
else
|
||||||
|
mkdir -p $dest
|
||||||
|
cp -rf $td/$f $dest
|
||||||
|
rm -rf $td/$f
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# put executables into $dest/bin
|
||||||
|
if [ -x $td/$f ]; then
|
||||||
|
if [ -e "$dest/$f" ] && [ $force = false ]; then
|
||||||
|
err "$f already exists in $dest, use --force to overwrite"
|
||||||
|
else
|
||||||
|
mkdir -p $dest/bin
|
||||||
|
install -m 755 $td/$f $dest/bin
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf $td
|
||||||
|
|
||||||
|
cat <<'EOF'
|
||||||
|
|
||||||
|
ZoKrates was installed succesfully!
|
||||||
|
If this is the first time you're installing ZoKrates run the following:
|
||||||
|
export PATH=$PATH:$HOME/.zokrates/bin
|
||||||
|
export ZOKRATES_HOME=$HOME/.zokrates/stdlib
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
4
test.sh
4
test.sh
|
@ -4,7 +4,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -n "$WITH_LIBSNARK" ]; then
|
if [ -n "$WITH_LIBSNARK" ]; then
|
||||||
cargo test
|
cargo -Z package-features test --release --package zokrates_cli --features="libsnark"
|
||||||
else
|
else
|
||||||
cargo -Z package-features test --no-default-features
|
cargo test --release
|
||||||
fi
|
fi
|
|
@ -2,9 +2,17 @@
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
### One-line install
|
||||||
|
|
||||||
|
We provide a one-line install for Linux, MacOS and FreeBSD:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -LSfs get.zokrat.es | sh
|
||||||
|
```
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
|
|
||||||
Using Docker is currently the recommended way to get started with ZoKrates.
|
ZoKrates is available on Dockerhub.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -ti zokrates/zokrates /bin/bash
|
docker run -ti zokrates/zokrates /bin/bash
|
||||||
|
@ -14,13 +22,12 @@ From there on, you can use the `zokrates` CLI.
|
||||||
|
|
||||||
### From source
|
### From source
|
||||||
|
|
||||||
You can build the container yourself from [source](https://github.com/JacobEberhardt/ZoKrates/) with the following commands:
|
You can build the container yourself from [source](https://github.com/ZoKrates/ZoKrates/) with the following commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/JacobEberhardt/ZoKrates
|
git clone https://github.com/ZoKrates/ZoKrates
|
||||||
cd ZoKrates
|
cd ZoKrates
|
||||||
docker build -t zokrates .
|
cargo build --release
|
||||||
docker run -ti zokrates /bin/bash
|
|
||||||
cd ZoKrates/target/release
|
cd ZoKrates/target/release
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ repository = "https://github.com/JacobEberhardt/ZoKrates.git"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["libsnark"]
|
default = []
|
||||||
libsnark = ["zokrates_core/libsnark"]
|
libsnark = ["zokrates_core/libsnark"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -4,10 +4,6 @@ version = "0.1.0"
|
||||||
authors = ["Stefan Deml <stefandeml@gmail.com>", "schaeff <thibaut@schaeff.fr>"]
|
authors = ["Stefan Deml <stefandeml@gmail.com>", "schaeff <thibaut@schaeff.fr>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["libsnark"]
|
|
||||||
libsnark = ["zokrates_core/libsnark"]
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
zokrates_field = { version = "0.3", path = "../zokrates_field" }
|
zokrates_field = { version = "0.3", path = "../zokrates_field" }
|
||||||
zokrates_core = { version = "0.3", path = "../zokrates_core" }
|
zokrates_core = { version = "0.3", path = "../zokrates_core" }
|
||||||
|
@ -18,3 +14,4 @@ serde_json = "1.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
glob = "0.3.0"
|
glob = "0.3.0"
|
||||||
|
fs_extra = "1.1.0"
|
||||||
|
|
|
@ -1,10 +1,28 @@
|
||||||
use glob::glob;
|
use fs_extra::copy_items;
|
||||||
|
use fs_extra::dir::CopyOptions;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// export stdlib folder to OUT_DIR
|
||||||
|
export_stdlib();
|
||||||
|
|
||||||
|
// generate tests
|
||||||
|
write_tests();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn export_stdlib() {
|
||||||
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
|
let mut options = CopyOptions::new();
|
||||||
|
options.overwrite = true;
|
||||||
|
copy_items(&vec!["stdlib"], out_dir, &options).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_tests() {
|
||||||
|
use glob::glob;
|
||||||
|
|
||||||
let out_dir = env::var("OUT_DIR").unwrap();
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
let destination = Path::new(&out_dir).join("tests.rs");
|
let destination = Path::new(&out_dir).join("tests.rs");
|
||||||
let mut test_file = File::create(&destination).unwrap();
|
let mut test_file = File::create(&destination).unwrap();
|
||||||
|
|
Loading…
Reference in a new issue