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] solc = sys.argv[1]
report = open("report.txt", "w") report = open("report.txt", "w")
for optimize in [False, True]:
for f in sorted(glob.glob("*.sol")): for f in sorted(glob.glob("*.sol")):
proc = subprocess.Popen([solc, '--combined-json', 'bin,metadata', f], stdout=subprocess.PIPE, stderr=subprocess.PIPE) 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() (out, err) = proc.communicate()
try: try:
result = json.loads(out.strip()) result = json.loads(out.strip())

View File

@ -49,13 +49,15 @@ var fs = require('fs')
var compiler = require('solc/wrapper.js')(require('./soljson.js')) var compiler = require('solc/wrapper.js')(require('./soljson.js'))
for (var optimize of [false, true])
{
for (var filename of process.argv.slice(2)) for (var filename of process.argv.slice(2))
{ {
if (filename !== undefined) if (filename !== undefined)
{ {
var inputs = {} var inputs = {}
inputs[filename] = fs.readFileSync(filename).toString() 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) if (!('contracts' in result) || Object.keys(result['contracts']).length === 0)
{ {
console.log(filename + ': ERROR') console.log(filename + ': ERROR')
@ -70,6 +72,7 @@ for (var filename of process.argv.slice(2))
} }
} }
} }
}
EOF EOF
chmod +x solc chmod +x solc
./solc *.sol > report.txt ./solc *.sol > report.txt