Skip to content

Commit

Permalink
fix(binaries): adapt arch specific unpacking
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen committed Jun 18, 2023
1 parent 62806c8 commit 1b25ab4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion binaries/bindata/bindata.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import (
func init() {
unpack.Unpack(data, "%s", "%s")
}
`, name, constraints, pkg, name, binaries.EngineVersion)
`, platform, constraints, pkg, name, binaries.EngineVersion)
return err
}

Expand Down
5 changes: 4 additions & 1 deletion binaries/unpack/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path"
"strings"
"time"

"github.com/steebchen/prisma-client-go/binaries"
Expand All @@ -17,6 +18,8 @@ import (
func Unpack(data []byte, name string, version string) {
start := time.Now()

name = strings.ReplaceAll(name, "_", "-")

filename := fmt.Sprintf("prisma-query-engine-%s", name)

// TODO check if dev env/dev binary in ~/.prisma
Expand All @@ -31,7 +34,7 @@ func Unpack(data []byte, name string, version string) {
}

if _, err := os.Stat(file); err == nil {
logger.Debug.Printf("query engine exists, not unpacking. %s", time.Since(start))
logger.Debug.Printf("query engine exists, not unpacking. %s. at %s", time.Since(start), file)
return
}

Expand Down
12 changes: 7 additions & 5 deletions generator/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strings"
"text/template"

Expand Down Expand Up @@ -172,17 +173,18 @@ func generateBinaries(input *Root) error {

func generateQueryEngineFiles(binaryTargets []string, pkg, outputDir string) error {
for _, name := range binaryTargets {
pt := name
if strings.Contains(name, "debian") || strings.Contains(name, "rhel") {
pt = "linux"
}

if name == "native" {
name = platform.BinaryPlatformName()
pt = runtime.GOOS
}

enginePath := binaries.GetEnginePath(binaries.GlobalCacheDir(), "query-engine", name)

pt := name
if strings.Contains(name, "debian") || strings.Contains(name, "rhel") {
pt = "linux"
}

filename := fmt.Sprintf("query-engine-%s_gen.go", name)
to := path.Join(outputDir, filename)

Expand Down

0 comments on commit 1b25ab4

Please sign in to comment.