This commit is contained in:
Kegsay 2018-03-06 11:50:12 +00:00 committed by GitHub
commit 9f1a7a604d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -33,9 +33,10 @@ var (
binFlag = flag.String("bin", "", "Path to the Ethereum contract bytecode (generate deploy method)") binFlag = flag.String("bin", "", "Path to the Ethereum contract bytecode (generate deploy method)")
typFlag = flag.String("type", "", "Struct name for the binding (default = package name)") typFlag = flag.String("type", "", "Struct name for the binding (default = package name)")
solFlag = flag.String("sol", "", "Path to the Ethereum contract Solidity source to build and bind") solFlag = flag.String("sol", "", "Path to the Ethereum contract Solidity source to build and bind")
solcFlag = flag.String("solc", "solc", "Solidity compiler to use if source builds are requested") solcFlag = flag.String("solc", "solc", "Solidity compiler to use if source builds are requested")
excFlag = flag.String("exc", "", "Comma separated types to exclude from binding") excFlag = flag.String("exc", "", "Comma separated types to exclude from binding")
solcArgsFlag = flag.String("flags", "", "Space separated extra flags to pass to solc")
pkgFlag = flag.String("pkg", "", "Package name to generate the binding into") pkgFlag = flag.String("pkg", "", "Package name to generate the binding into")
outFlag = flag.String("out", "", "Output file for the generated binding (default = stdout)") outFlag = flag.String("out", "", "Output file for the generated binding (default = stdout)")
@ -81,7 +82,11 @@ func main() {
for _, kind := range strings.Split(*excFlag, ",") { for _, kind := range strings.Split(*excFlag, ",") {
exclude[strings.ToLower(kind)] = true exclude[strings.ToLower(kind)] = true
} }
contracts, err := compiler.CompileSolidity(*solcFlag, *solFlag) var solcArgs []string
if *solcArgsFlag != "" {
solcArgs = strings.Split(*solcArgsFlag, " ")
}
contracts, err := compiler.CompileSolidity(*solcFlag, solcArgs, *solFlag)
if err != nil { if err != nil {
fmt.Printf("Failed to build Solidity contract: %v\n", err) fmt.Printf("Failed to build Solidity contract: %v\n", err)
os.Exit(-1) os.Exit(-1)

View file

@ -119,7 +119,7 @@ func CompileSolidityString(solc, source string) (map[string]*Contract, error) {
} }
// CompileSolidity compiles all given Solidity source files. // CompileSolidity compiles all given Solidity source files.
func CompileSolidity(solc string, sourcefiles ...string) (map[string]*Contract, error) { func CompileSolidity(solc string, extraArgs []string, sourcefiles ...string) (map[string]*Contract, error) {
if len(sourcefiles) == 0 { if len(sourcefiles) == 0 {
return nil, errors.New("solc: no source files") return nil, errors.New("solc: no source files")
} }
@ -131,7 +131,8 @@ func CompileSolidity(solc string, sourcefiles ...string) (map[string]*Contract,
if err != nil { if err != nil {
return nil, err return nil, err
} }
args := append(s.makeArgs(), "--") args := append(s.makeArgs(), extraArgs...)
args = append(args, "--")
cmd := exec.Command(s.Path, append(args, sourcefiles...)...) cmd := exec.Command(s.Path, append(args, sourcefiles...)...)
return s.run(cmd, source) return s.run(cmd, source)
} }