mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Also generate optimized code.
This commit is contained in:
parent
bbe3557a2f
commit
5c3a80ab5b
@ -8,13 +8,17 @@ import json
|
|||||||
solc = sys.argv[1]
|
solc = sys.argv[1]
|
||||||
report = open("report.txt", "w")
|
report = open("report.txt", "w")
|
||||||
|
|
||||||
for f in sorted(glob.glob("*.sol")):
|
for optimize in [False, True]:
|
||||||
proc = subprocess.Popen([solc, '--combined-json', 'bin,metadata', f], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
for f in sorted(glob.glob("*.sol")):
|
||||||
(out, err) = proc.communicate()
|
args = [solc, '--combined-json', 'bin,metadata', f]
|
||||||
try:
|
if optimize:
|
||||||
result = json.loads(out.strip())
|
args += ['--optimize']
|
||||||
for contractName in sorted(result['contracts'].keys()):
|
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
report.write(contractName + ' ' + result['contracts'][contractName]['bin'] + '\n')
|
(out, err) = proc.communicate()
|
||||||
report.write(contractName + ' ' + result['contracts'][contractName]['metadata'] + '\n')
|
try:
|
||||||
except:
|
result = json.loads(out.strip())
|
||||||
report.write(f + ": ERROR\n")
|
for contractName in sorted(result['contracts'].keys()):
|
||||||
|
report.write(contractName + ' ' + result['contracts'][contractName]['bin'] + '\n')
|
||||||
|
report.write(contractName + ' ' + result['contracts'][contractName]['metadata'] + '\n')
|
||||||
|
except:
|
||||||
|
report.write(f + ": ERROR\n")
|
||||||
|
@ -49,23 +49,26 @@ var fs = require('fs')
|
|||||||
|
|
||||||
var compiler = require('solc/wrapper.js')(require('./soljson.js'))
|
var compiler = require('solc/wrapper.js')(require('./soljson.js'))
|
||||||
|
|
||||||
for (var filename of process.argv.slice(2))
|
for (var optimize of [false, true])
|
||||||
{
|
{
|
||||||
if (filename !== undefined)
|
for (var filename of process.argv.slice(2))
|
||||||
{
|
{
|
||||||
var inputs = {}
|
if (filename !== undefined)
|
||||||
inputs[filename] = fs.readFileSync(filename).toString()
|
|
||||||
var result = compiler.compile({sources: inputs})
|
|
||||||
if (!('contracts' in result) || Object.keys(result['contracts']).length === 0)
|
|
||||||
{
|
{
|
||||||
console.log(filename + ': ERROR')
|
var inputs = {}
|
||||||
}
|
inputs[filename] = fs.readFileSync(filename).toString()
|
||||||
else
|
var result = compiler.compile({sources: inputs}, optimize)
|
||||||
{
|
if (!('contracts' in result) || Object.keys(result['contracts']).length === 0)
|
||||||
for (var contractName in result['contracts'])
|
|
||||||
{
|
{
|
||||||
console.log(contractName + ' ' + result['contracts'][contractName].bytecode)
|
console.log(filename + ': ERROR')
|
||||||
console.log(contractName + ' ' + result['contracts'][contractName].metadata)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (var contractName in result['contracts'])
|
||||||
|
{
|
||||||
|
console.log(contractName + ' ' + result['contracts'][contractName].bytecode)
|
||||||
|
console.log(contractName + ' ' + result['contracts'][contractName].metadata)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user