Also generate optimized code.

This commit is contained in:
chriseth 2017-03-22 20:56:44 +01:00
parent bbe3557a2f
commit 5c3a80ab5b
2 changed files with 30 additions and 23 deletions

View File

@ -8,8 +8,12 @@ import json
solc = sys.argv[1]
report = open("report.txt", "w")
for f in sorted(glob.glob("*.sol")):
proc = subprocess.Popen([solc, '--combined-json', 'bin,metadata', f], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for optimize in [False, True]:
for f in sorted(glob.glob("*.sol")):
args = [solc, '--combined-json', 'bin,metadata', f]
if optimize:
args += ['--optimize']
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = proc.communicate()
try:
result = json.loads(out.strip())

View File

@ -49,13 +49,15 @@ var fs = require('fs')
var compiler = require('solc/wrapper.js')(require('./soljson.js'))
for (var filename of process.argv.slice(2))
for (var optimize of [false, true])
{
for (var filename of process.argv.slice(2))
{
if (filename !== undefined)
{
var inputs = {}
inputs[filename] = fs.readFileSync(filename).toString()
var result = compiler.compile({sources: inputs})
var result = compiler.compile({sources: inputs}, optimize)
if (!('contracts' in result) || Object.keys(result['contracts']).length === 0)
{
console.log(filename + ': ERROR')
@ -69,6 +71,7 @@ for (var filename of process.argv.slice(2))
}
}
}
}
}
EOF
chmod +x solc