From d68dd37426065824976f47eff2e73554bc223da2 Mon Sep 17 00:00:00 2001 From: Robert Martin-Legene <robert@nic.ar> Date: Tue, 27 Apr 2021 16:37:02 +0000 Subject: [PATCH] Mejorando solc --- bin/solc | 70 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 13 deletions(-) diff --git a/bin/solc b/bin/solc index 95132df..12b4bde 100755 --- a/bin/solc +++ b/bin/solc @@ -4,24 +4,68 @@ # See if PATH is set up incorrectly (look for another install of this binary). -mypath=$( realpath $0 ) -myname=${mypath##*/} -for p in ${PATH//:/ } -do - checkfile=${p}/${myname} - if [ -x ${checkfile} ] +printf -v newline '\n' + +function find_evm_version() +{ + # Remember to set the evm version to be compatible with + # the blockchain. BFA is still at Byzantium (as per 2021). + # The current version is listed in lib/versions with + # keyword chain_evm_version + unset evmvers + local keyword + keyword=chain_evm_version + while read -r + do + if [[ "$REPLY" =~ ^${keyword}= ]] + then + evmvers=${REPLY#${keyword}=} + break + fi + done < "${BFAHOME:-/home/bfa/bfa}/lib/versions" + if [ -z "$evmvers" ] then - if [ $( realpath ${checkfile} ) = $mypath ] + printf -v errortxt '%s\n%s' "$errortxt" "Can not find the keyword ${keyword} in lib/versions" + errortxt=${errortxt#${newline}} + fi +} + +function find_first_solc +{ + local mypath myname p + mypath=$( realpath "$0" ) + myname=${mypath##*/} + unset first_solc + for p in ${PATH//:/ } + do + local checkfile=${p}/${myname} + if [ ! -x "${checkfile}" ] + then + continue + fi + if [ "$(realpath "${checkfile}")" = "$mypath" ] then continue fi # we found another one, yay! - evmvers=$( grep '^chain_evm_version=' ${BFAHOME:-/home/bfa/bfa}/lib/versions | head -1 ) - exec ${checkfile} ${evmvers/*=/--evm-version=} --combined-json abi,asm,ast,bin,bin-runtime,compact-format,devdoc,generated-sources,generated-sources-runtime,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,storage-layout,userdoc "$@" - exit 1 + first_solc=${checkfile} + break + done + if [ -z "$first_solc" ] + then + printf -v errortxt '%s\n%s' "$errortxt" "solc: command not found." + errortxt=${errortxt#${newline}} fi -done +} + +errortxt= +find_first_solc +find_evm_version +if [ -n "$errortxt" ] +then + echo "$errortxt" >&2 + exit 1 +fi -# not found -echo "solc: command not found." >&2 +exec "${first_solc}" --evm-version="$evmvers" --combined-json abi,asm,ast,bin,bin-runtime,compact-format,devdoc,generated-sources,generated-sources-runtime,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,storage-layout,userdoc "$@" exit 1 -- GitLab