rcc: use a relative path in the go:embed line

This commit is contained in:
mappu 2025-02-06 19:18:03 +13:00
parent 0da95c13f8
commit d8cb5494a0

View File

@ -9,6 +9,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"strings" "strings"
) )
@ -41,12 +42,19 @@ func RccExec() error {
*outputRcc = strings.TrimSuffix(*outputGo, `.go`) + `.rcc` *outputRcc = strings.TrimSuffix(*outputGo, `.go`) + `.rcc`
} }
// The rcc output path must be relative to the output go file path
embedPath, err := filepath.Rel(filepath.Dir(*outputGo), *outputRcc)
if err != nil {
return err
}
// Compile qrc to binary resource file // Compile qrc to binary resource file
rccCmd := exec.Command(*rccBinary, `--binary`, `-o`, *outputRcc, *input) rccCmd := exec.Command(*rccBinary, `--binary`, `-o`, *outputRcc, *input)
rccCmd.Stderr = os.Stderr rccCmd.Stderr = os.Stderr
rccCmd.Stdout = os.Stdout rccCmd.Stdout = os.Stdout
err := rccCmd.Run() err = rccCmd.Run()
if err != nil { if err != nil {
return err return err
} }
@ -69,7 +77,7 @@ import (
` + miqtImport + ` ` + miqtImport + `
) )
//go:embed ` + *outputRcc + ` //go:embed ` + embedPath + `
var ` + *variableName + ` []byte var ` + *variableName + ` []byte
func init() { func init() {