mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update bytecode output to cope with metadata-only compilability.
This commit is contained in:
parent
fcbb8ec51c
commit
19761a08fa
@ -10,15 +10,32 @@ report = open("report.txt", "wb")
|
||||
|
||||
for optimize in [False, True]:
|
||||
for f in sorted(glob.glob("*.sol")):
|
||||
args = [solc, '--combined-json', 'bin,metadata', f]
|
||||
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']
|
||||
if optimize:
|
||||
args += ['--optimize']
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(out, err) = proc.communicate()
|
||||
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(out, err) = proc.communicate(json.dumps(input))
|
||||
try:
|
||||
result = json.loads(out.strip())
|
||||
for contractName in sorted(result['contracts'].keys()):
|
||||
report.write(contractName + ' ' + result['contracts'][contractName]['bin'] + '\n')
|
||||
report.write(contractName + ' ' + result['contracts'][contractName]['metadata'] + '\n')
|
||||
except:
|
||||
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:
|
||||
report.write(f + ": ERROR\n")
|
||||
|
@ -88,8 +88,12 @@ for (var optimize of [false, true])
|
||||
{
|
||||
for (var contractName in result['contracts'][filename])
|
||||
{
|
||||
console.log(filename + ':' + contractName + ' ' + result['contracts'][filename][contractName].evm.bytecode.object)
|
||||
console.log(filename + ':' + contractName + ' ' + result['contracts'][filename][contractName].metadata)
|
||||
var contractData = result['contracts'][filename][contractName];
|
||||
if (contractData.evm !== undefined && contractData.evm.bytecode !== undefined)
|
||||
console.log(filename + ':' + contractName + ' ' + contractData.evm.bytecode.object)
|
||||
else
|
||||
console.log(filename + ':' + contractName + ' NO BYTECODE')
|
||||
console.log(filename + ':' + contractName + ' ' + contractData.metadata)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user