Merge pull request #1806 from ethersphere/solc2
new solc api - late fixes
This commit is contained in:
commit
55bdcfaeac
@ -35,8 +35,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
versionRegExp = regexp.MustCompile("[0-9]+\\.[0-9]+\\.[0-9]+")
|
versionRegexp = regexp.MustCompile("[0-9]+\\.[0-9]+\\.[0-9]+")
|
||||||
newAPIRegexp = regexp.MustCompile("0\\.1\\.[2-9][0-9]*")
|
legacyRegexp = regexp.MustCompile("0\\.(9\\..*|1\\.[01])")
|
||||||
paramsLegacy = []string{
|
paramsLegacy = []string{
|
||||||
"--binary", // Request to output the contract in binary (hexadecimal).
|
"--binary", // Request to output the contract in binary (hexadecimal).
|
||||||
"file", //
|
"file", //
|
||||||
@ -55,7 +55,7 @@ var (
|
|||||||
"--userdoc", // Request to output the contract's Natspec user documentation.
|
"--userdoc", // Request to output the contract's Natspec user documentation.
|
||||||
"--devdoc", // Request to output the contract's Natspec developer documentation.
|
"--devdoc", // Request to output the contract's Natspec developer documentation.
|
||||||
"--add-std", // include standard lib contracts
|
"--add-std", // include standard lib contracts
|
||||||
"--optimize=1", // code optimizer switched on
|
"--optimize", // code optimizer switched on
|
||||||
"-o", // output directory
|
"-o", // output directory
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -102,8 +102,8 @@ func New(solcPath string) (sol *Solidity, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fullVersion := out.String()
|
fullVersion := out.String()
|
||||||
version := versionRegExp.FindString(fullVersion)
|
version := versionRegexp.FindString(fullVersion)
|
||||||
legacy := !newAPIRegexp.MatchString(version)
|
legacy := legacyRegexp.MatchString(version)
|
||||||
|
|
||||||
sol = &Solidity{
|
sol = &Solidity{
|
||||||
solcPath: solcPath,
|
solcPath: solcPath,
|
||||||
|
@ -46,9 +46,9 @@ contract test {
|
|||||||
func TestCompiler(t *testing.T) {
|
func TestCompiler(t *testing.T) {
|
||||||
sol, err := New("")
|
sol, err := New("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Skip("solc not found: skip: %v", err)
|
t.Skipf("solc not found: %v", err)
|
||||||
} else if sol.Version() != solcVersion {
|
} else if sol.Version() != solcVersion {
|
||||||
t.Skip("WARNING: skipping due to a newer version of solc found (%v, expect %v)", sol.Version(), solcVersion)
|
t.Skipf("WARNING: a newer version of solc found (%v, expect %v)", sol.Version(), solcVersion)
|
||||||
}
|
}
|
||||||
contracts, err := sol.Compile(source)
|
contracts, err := sol.Compile(source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -83,7 +83,7 @@ func TestCompileError(t *testing.T) {
|
|||||||
func TestNoCompiler(t *testing.T) {
|
func TestNoCompiler(t *testing.T) {
|
||||||
_, err := New("/path/to/solc")
|
_, err := New("/path/to/solc")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Log("solidity quits with error: %v", err)
|
t.Logf("solidity quits with error: %v", err)
|
||||||
} else {
|
} else {
|
||||||
t.Errorf("no solc installed, but got no error")
|
t.Errorf("no solc installed, but got no error")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user