aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/bytecodecompare
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-03-23 03:56:44 +0800
committerchriseth <chris@ethereum.org>2017-03-23 16:56:18 +0800
commit5c3a80ab5bac2dd5faf19416a640990af3da0a31 (patch)
tree69c5699ba612cc3a28dfb1edae57b545814663ef /scripts/bytecodecompare
parentbbe3557a2fda2f4a09b63b1f3e501d4c8625bfe1 (diff)
downloaddexon-solidity-5c3a80ab5bac2dd5faf19416a640990af3da0a31.tar.gz
dexon-solidity-5c3a80ab5bac2dd5faf19416a640990af3da0a31.tar.zst
dexon-solidity-5c3a80ab5bac2dd5faf19416a640990af3da0a31.zip
Also generate optimized code.
Diffstat (limited to 'scripts/bytecodecompare')
-rwxr-xr-xscripts/bytecodecompare/prepare_report.py24
-rwxr-xr-xscripts/bytecodecompare/storebytecode.sh29
2 files changed, 30 insertions, 23 deletions
diff --git a/scripts/bytecodecompare/prepare_report.py b/scripts/bytecodecompare/prepare_report.py
index 68793927..5a770981 100755
--- a/scripts/bytecodecompare/prepare_report.py
+++ b/scripts/bytecodecompare/prepare_report.py
@@ -8,13 +8,17 @@ 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)
- (out, err) = proc.communicate()
- 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:
- report.write(f + ": ERROR\n")
+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())
+ 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")
diff --git a/scripts/bytecodecompare/storebytecode.sh b/scripts/bytecodecompare/storebytecode.sh
index 8a3953c3..cdf376a6 100755
--- a/scripts/bytecodecompare/storebytecode.sh
+++ b/scripts/bytecodecompare/storebytecode.sh
@@ -49,23 +49,26 @@ 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])
{
- if (filename !== undefined)
+ for (var filename of process.argv.slice(2))
{
- var inputs = {}
- inputs[filename] = fs.readFileSync(filename).toString()
- var result = compiler.compile({sources: inputs})
- if (!('contracts' in result) || Object.keys(result['contracts']).length === 0)
+ if (filename !== undefined)
{
- console.log(filename + ': ERROR')
- }
- else
- {
- for (var contractName in result['contracts'])
+ var inputs = {}
+ inputs[filename] = fs.readFileSync(filename).toString()
+ var result = compiler.compile({sources: inputs}, optimize)
+ if (!('contracts' in result) || Object.keys(result['contracts']).length === 0)
+ {
+ console.log(filename + ': ERROR')
+ }
+ else
{
- console.log(contractName + ' ' + result['contracts'][contractName].bytecode)
- console.log(contractName + ' ' + result['contracts'][contractName].metadata)
+ for (var contractName in result['contracts'])
+ {
+ console.log(contractName + ' ' + result['contracts'][contractName].bytecode)
+ console.log(contractName + ' ' + result['contracts'][contractName].metadata)
+ }
}
}
}