2017-03-22 19:19:57 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import glob
|
|
|
|
import subprocess
|
|
|
|
import json
|
|
|
|
|
|
|
|
solc = sys.argv[1]
|
2017-06-20 12:31:09 +00:00
|
|
|
report = open("report.txt", "wb")
|
2017-03-22 19:19:57 +00:00
|
|
|
|
2017-03-22 19:56:44 +00:00
|
|
|
for optimize in [False, True]:
|
|
|
|
for f in sorted(glob.glob("*.sol")):
|
2019-03-04 15:19:34 +00:00
|
|
|
sources = {}
|
|
|
|
sources[f] = {'content': open(f, 'r').read()}
|
|
|
|
input = {
|
|
|
|
'language': 'Solidity',
|
|
|
|
'sources': sources,
|
|
|
|
'settings': {
|
|
|
|
'optimizer': {
|
|
|
|
'enabled': optimize
|
|
|
|
},
|
|
|
|
'outputSelection': { '*': { '*': ['evm.bytecode.object', 'metadata'] } }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
args = [solc, '--standard-json']
|
2017-03-22 19:56:44 +00:00
|
|
|
if optimize:
|
|
|
|
args += ['--optimize']
|
2019-03-04 15:19:34 +00:00
|
|
|
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
(out, err) = proc.communicate(json.dumps(input))
|
2017-03-22 19:56:44 +00:00
|
|
|
try:
|
|
|
|
result = json.loads(out.strip())
|
2019-03-04 15:19:34 +00:00
|
|
|
for filename in sorted(result['contracts'].keys()):
|
|
|
|
for contractName in sorted(result['contracts'][filename].keys()):
|
|
|
|
contractData = result['contracts'][filename][contractName]
|
|
|
|
if 'evm' in contractData and 'bytecode' in contractData['evm']:
|
|
|
|
report.write(filename + ':' + contractName + ' ' + contractData['evm']['bytecode']['object'] + '\n')
|
|
|
|
else:
|
|
|
|
report.write(filename + ':' + contractName + ' NO BYTECODE\n')
|
|
|
|
report.write(filename + ':' + contractName + ' ' + contractData['metadata'] + '\n')
|
|
|
|
except KeyError:
|
2017-03-22 19:56:44 +00:00
|
|
|
report.write(f + ": ERROR\n")
|