Skip to content

Commit

Permalink
build command now builds the ./cmd/ponzu package instead of a list of…
Browse files Browse the repository at this point in the history
… files
  • Loading branch information
martint17r committed May 16, 2017
1 parent 4ad3513 commit fa6a490
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions cmd/ponzu/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/spf13/cobra"
)

func buildPonzuServer() error {
pwd, err := os.Getwd()
if err != nil {
return err
}

// copy all ./content files to internal vendor directory
src := "content"
dst := filepath.Join("cmd", "ponzu", "vendor", "github.com", "ponzu-cms", "ponzu", "content")
err = emptyDir(dst)
err := emptyDir(dst)
if err != nil {
return err
}
Expand All @@ -36,18 +32,9 @@ func buildPonzuServer() error {
}

// execute go build -o ponzu-cms cmd/ponzu/*.go
buildOptions := []string{"build", "-o", buildOutputName()}
cmdBuildFiles := []string{
"main.go", "options.go", "generate.go",
"usage.go", "paths.go", "add.go",
}
var cmdBuildFilePaths []string
for _, file := range cmdBuildFiles {
p := filepath.Join(pwd, "cmd", "ponzu", file)
cmdBuildFilePaths = append(cmdBuildFilePaths, p)
}

build := exec.Command(gocmd, append(buildOptions, cmdBuildFilePaths...)...)
cmdPackageName := strings.Join([]string{".", "cmd", "ponzu"}, "/")

This comment has been minimized.

Copy link
@nilslice

nilslice May 16, 2017

Contributor

I don't think is windows compatible now - look at filepath.Separator (I think its in that package)

This comment has been minimized.

Copy link
@martint17r

martint17r May 16, 2017

Author Contributor

That is a package name, not a file name. Are you sure that Go package names follow the same conventions as the plattform. I do not have access to a windows system, so I can't be sure.

This comment has been minimized.

Copy link
@nilslice

nilslice May 16, 2017

Contributor

By joining paths with the "/", the command becomes unsupported on windows, which is why the filepath.Separator value exists:
https://golang.org/pkg/path/filepath/#pkg-constants

This is used internally by ponzu in a number of places already to ensure cross-platform compatibility, which we need to keep.

See some examples here: https://github.com/ponzu-cms/ponzu/search?utf8=%E2%9C%93&q=filepath.Separator&type=

This comment has been minimized.

Copy link
@nilslice

nilslice May 16, 2017

Contributor

I see what you're saying -- that command is sent to the go command, not as a shell command.. this would be a question for @sirikon... I am not sure if it performs as you suggested. The "." is also something I'm unsure of for cross-platform compatibility.

This comment has been minimized.

Copy link
@sirikon

sirikon May 16, 2017

@nilslice AFAIK... That's just a package name, and separators in package names are the same, and the go tool should take care of that.

Anyway, if you tell me the commands that I need to perform, I can check it later downloading this PR source code.

buildOptions := []string{"build", "-o", buildOutputName(), cmdPackageName}
build := exec.Command(gocmd, buildOptions...)
build.Stderr = os.Stderr
build.Stdout = os.Stdout

Expand Down

0 comments on commit fa6a490

Please sign in to comment.