Skip to content

Commit

Permalink
support define output name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joinhack committed Nov 20, 2024
1 parent 27ca390 commit 4198e84
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tools/c2w/c2w.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
"path/filepath"
"time"

c2w "github.com/blocklessnetwork/bls-c2w"
blsc2w "github.com/blocklessnetwork/bls-c2w"
"github.com/containerd/containerd/archive"
"github.com/urfave/cli"
)

const defaultOutputFile = "bls-out.wasm"

var dockerfile = c2w.Dockerfile
var dockerfile = blsc2w.Dockerfile

func main() {
app := cli.NewApp()
Expand Down Expand Up @@ -57,6 +57,7 @@ func main() {

func action(clicontext *cli.Context) error {
arg1 := clicontext.Args().First()
outputPath := clicontext.Args().Get(1)
if arg1 == "" {
return fmt.Errorf("specify image name")
}
Expand All @@ -78,6 +79,16 @@ func action(clicontext *cli.Context) error {
if err := preparedImage(builderPath, srcImgName, srcImgPath, clicontext.String("target-arch")); err != nil {
return fmt.Errorf("failed to prepare image: %w", err)
}
if outputPath != "" {
d, f := filepath.Split(outputPath)
destDir, err = filepath.Abs(d)
if err != nil {
return err
}
if f != "" {
destFile = f
}
}
return build(builderPath, srcImgPath, destDir, destFile, clicontext)
}

Expand Down

0 comments on commit 4198e84

Please sign in to comment.