compile.sh 847 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. # Configure to exit script as soon as a command fails.
  3. set -o errexit
  4. SOLC_05_DIR=solc-0.5
  5. # Delete any previous build artifacts
  6. rm -rf build/
  7. # Create a subproject where 0.5.x compilation will take place
  8. mkdir -p "$SOLC_05_DIR"
  9. cd "$SOLC_05_DIR"
  10. echo '{ "private": true }' > package.json
  11. npm install --save-dev truffle@5.0.0
  12. rm -rf contracts
  13. ln --symbolic ../contracts contracts
  14. # Delete any previous build artifacts
  15. rm -rf build/
  16. # Compile
  17. echo "
  18. module.exports = {
  19. compilers: {
  20. solc: {
  21. version: \"0.5.0\",
  22. },
  23. },
  24. };
  25. " > truffle-config.js
  26. npx truffle compile
  27. # Modify the paths in the artifacts to make it look as if they were built in the root
  28. sed --in-place --expression "s/\/$SOLC_05_DIR//g" build/contracts/*.json
  29. # Copy them back into the root
  30. cd ..
  31. cp --recursive "$SOLC_05_DIR"/build build