diff --git a/solidity_contracts/compile_tools/compile_solidity_contract.sh b/solidity_contracts/compile_tools/compile_solidity_contract.sh index 2ef8942..180f77d 100755 --- a/solidity_contracts/compile_tools/compile_solidity_contract.sh +++ b/solidity_contracts/compile_tools/compile_solidity_contract.sh @@ -31,7 +31,51 @@ set -o pipefail # 3 solcjs --starndard-json has some bugs (https://github.com/ethereum/solc-js/issues/460) so we can only use "content" as input. # 4 To copy the source code into the json file, we have to escape \\ \" \t \n. (Ignore \b \r \f as we shouldn't have them in sol file) tmpfile=$(mktemp) -cat "$SOLIDITY_SOURCE_FILE_PATH" \ +awk 'BEGIN { + found=0; + } + + { + spos=index($0,"/*"); + epos=index($0,"*/"); + + if(spos > 0 && epos ==0) + { + printf("%s\n",substr($0,1,spos-1)); + found=1; + } + else if(spos == 0 && epos >0) + { + found=0; + if(length($0) != epos+1) + { + printf("%s\n",substr($0,epos+2)); + } + } + else if(spos > 0 && epos > 0) + { + printf("%s %s\n",substr($0,1,spos-1),substr($0,epos+2)); + } + else if(found==0) + { + cpp_comment=index($0,"//"); + if(cpp_comment == 0) + { + print; + } + else + { + printf("%s\n",substr($0,1,cpp_comment-1)); + } + } + } + + END { + if(found==1) + { + print "there is unmatched comment" + } + }' "$SOLIDITY_SOURCE_FILE_PATH" \ | awk -v token="__CONTRACT_CONTENT" ' BEGIN { RS = "\0" # Set record separator to null to read the whole input