build.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. libsodium_CASES="aead_aes256gcm2 aead_aes256gcm aead_chacha20poly13052 aead_chacha20poly1305 \
  5. aead_xchacha20poly1305 auth2 auth3 auth5 auth6 auth7 auth box2 box7 box8 \
  6. box_easy2 box_easy box_seal box_seed box chacha20 codecs core1 core2 core3 \
  7. core4 core5 core6 core_ed25519 core_ristretto255 ed25519_convert generichash2 \
  8. generichash3 generichash hash3 hash kdf keygen kx metamorphic misuse \
  9. onetimeauth2 onetimeauth7 onetimeauth pwhash_argon2id pwhash_argon2i \
  10. pwhash_scrypt_ll pwhash_scrypt randombytes scalarmult2 scalarmult5 \
  11. scalarmult6 scalarmult7 scalarmult8 scalarmult_ed25519 scalarmult_ristretto255 \
  12. scalarmult secretbox2 secretbox7 secretbox8 secretbox_easy2 secretbox_easy \
  13. secretbox secretstream_xchacha20poly1305 shorthash sign siphashx24 sodium_core \
  14. sodium_utils2 sodium_utils3 sodium_utils sodium_version stream2 stream3 stream4 \
  15. stream verify1 xchacha20"
  16. PLATFORM=$(uname -s | tr A-Z a-z)
  17. readonly WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc
  18. readonly OUT_DIR=$PWD/libsodium/zig-out/bin
  19. if [ ! -d libsodium ]; then
  20. git clone https://github.com/jedisct1/libsodium.git
  21. cd libsodium
  22. git checkout 1.0.19
  23. cd ..
  24. fi
  25. cd libsodium
  26. echo "Build libsodium native"
  27. zig build -Doptimize=ReleaseFast -Denable_benchmarks=true
  28. echo "Build libsodium wasm32-wasi"
  29. zig build -Doptimize=ReleaseFast -Denable_benchmarks=true -Dtarget=wasm32-wasi
  30. for case in ${libsodium_CASES}
  31. do
  32. ${WAMRC_CMD} -o ${OUT_DIR}/${case}.aot ${OUT_DIR}/${case}.wasm
  33. if [ "$?" != 0 ]; then
  34. echo -e "Error while compiling ${case}.wasm to ${case}.aot"
  35. exit
  36. fi
  37. if [[ ${PLATFORM} == "linux" ]]; then
  38. ${WAMRC_CMD} --enable-segue -o ${OUT_DIR}/${case}_segue.aot ${OUT_DIR}/${case}.wasm
  39. if [ "$?" != 0 ]; then
  40. echo -e "Error while compiling ${case}.wasm to ${case}_segue.aot"
  41. exit
  42. fi
  43. fi
  44. done