mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Extract the script embedded in storebytecode.sh into a separate file
This commit is contained in:
parent
f03245d473
commit
42786c2d29
49
scripts/bytecodecompare/prepare_report.js
Executable file
49
scripts/bytecodecompare/prepare_report.js
Executable file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env node
|
||||
var process = require('process')
|
||||
var fs = require('fs')
|
||||
|
||||
var compiler = require('./solc-js/wrapper.js')(require('./solc-js/soljson.js'))
|
||||
|
||||
for (var optimize of [false, true])
|
||||
{
|
||||
for (var filename of process.argv.slice(2))
|
||||
{
|
||||
if (filename !== undefined)
|
||||
{
|
||||
var inputs = {}
|
||||
inputs[filename] = { content: fs.readFileSync(filename).toString() }
|
||||
var input = {
|
||||
language: 'Solidity',
|
||||
sources: inputs,
|
||||
settings: {
|
||||
optimizer: { enabled: optimize },
|
||||
outputSelection: { '*': { '*': ['evm.bytecode.object', 'metadata'] } },
|
||||
"modelChecker": { "engine": "none" }
|
||||
}
|
||||
}
|
||||
var result = JSON.parse(compiler.compile(JSON.stringify(input)))
|
||||
if (
|
||||
!('contracts' in result) ||
|
||||
Object.keys(result['contracts']).length === 0 ||
|
||||
!result['contracts'][filename] ||
|
||||
Object.keys(result['contracts'][filename]).length === 0
|
||||
)
|
||||
{
|
||||
// NOTE: do not exit here because this may be run on source which cannot be compiled
|
||||
console.log(filename + ': ERROR')
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var contractName in result['contracts'][filename])
|
||||
{
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -46,60 +46,9 @@ TMPDIR=$(mktemp -d)
|
||||
git clone --depth 1 https://github.com/ethereum/solc-js.git solc-js
|
||||
( cd solc-js; npm install )
|
||||
cp "$REPO_ROOT/emscripten_build/libsolc/soljson.js" solc-js/
|
||||
cat > solc <<EOF
|
||||
#!/usr/bin/env node
|
||||
var process = require('process')
|
||||
var fs = require('fs')
|
||||
|
||||
var compiler = require('./solc-js/wrapper.js')(require('./solc-js/soljson.js'))
|
||||
|
||||
for (var optimize of [false, true])
|
||||
{
|
||||
for (var filename of process.argv.slice(2))
|
||||
{
|
||||
if (filename !== undefined)
|
||||
{
|
||||
var inputs = {}
|
||||
inputs[filename] = { content: fs.readFileSync(filename).toString() }
|
||||
var input = {
|
||||
language: 'Solidity',
|
||||
sources: inputs,
|
||||
settings: {
|
||||
optimizer: { enabled: optimize },
|
||||
outputSelection: { '*': { '*': ['evm.bytecode.object', 'metadata'] } },
|
||||
"modelChecker": { "engine": "none" }
|
||||
}
|
||||
}
|
||||
var result = JSON.parse(compiler.compile(JSON.stringify(input)))
|
||||
if (
|
||||
!('contracts' in result) ||
|
||||
Object.keys(result['contracts']).length === 0 ||
|
||||
!result['contracts'][filename] ||
|
||||
Object.keys(result['contracts'][filename]).length === 0
|
||||
)
|
||||
{
|
||||
// NOTE: do not exit here because this may be run on source which cannot be compiled
|
||||
console.log(filename + ': ERROR')
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var contractName in result['contracts'][filename])
|
||||
{
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
cp ""$REPO_ROOT"/scripts/bytecodecompare/prepare_report.js" .
|
||||
echo "Running the compiler..."
|
||||
chmod +x solc
|
||||
./solc *.sol > report.txt
|
||||
./prepare_report.js *.sol > report.txt
|
||||
echo "Finished running the compiler."
|
||||
else
|
||||
"$REPO_ROOT/scripts/bytecodecompare/prepare_report.py" "$BUILD_DIR/solc/solc"
|
||||
|
Loading…
Reference in New Issue
Block a user