mirror of
https://github.com/gosticks/gml.git
synced 2025-10-16 12:05:33 +00:00
Merge pull request #5 from desertbit/qtmodules
add support for dynamic qt modules
This commit is contained in:
commit
41bb83f6f6
@ -49,6 +49,7 @@ func init() {
|
||||
f.String("b", "build-dir", "./build", "build directorty")
|
||||
f.String("d", "dest-dir", "./", "destination directorty")
|
||||
f.String("t", "tags", "", "go build tags")
|
||||
f.String("m", "qt-modules", "", "comma separated list of qt modules added to the project")
|
||||
},
|
||||
Run: runBuild,
|
||||
}
|
||||
@ -70,6 +71,7 @@ func runBuild(c *grumble.Context) error {
|
||||
c.Flags.String("source-dir"),
|
||||
c.Flags.String("build-dir"),
|
||||
c.Flags.String("dest-dir"),
|
||||
c.Flags.String("qt-modules"),
|
||||
c.Flags.Bool("clean"),
|
||||
c.Flags.Bool("no-strip"),
|
||||
c.Flags.Bool("debug"),
|
||||
@ -90,6 +92,7 @@ func runBuildDocker(c *grumble.Context) error {
|
||||
c.Flags.String("source-dir"),
|
||||
c.Flags.String("build-dir"),
|
||||
c.Flags.String("dest-dir"),
|
||||
c.Flags.String("qt-modules"),
|
||||
c.Flags.Bool("clean"),
|
||||
c.Flags.Bool("no-strip"),
|
||||
c.Flags.Bool("debug"),
|
||||
|
||||
@ -40,13 +40,16 @@ const (
|
||||
PostHookName = "GML_BUILD_POST_HOOKS"
|
||||
)
|
||||
|
||||
func Build(sourceDir, buildDir, destDir string, clean, noStrip, debugBuild, race bool, tags string) (err error) {
|
||||
func Build(sourceDir, buildDir, destDir, qtModules string, clean, noStrip, debugBuild, race bool, tags string) (err error) {
|
||||
// Force no strip if this is a debug build.
|
||||
if debugBuild {
|
||||
noStrip = true
|
||||
}
|
||||
|
||||
ctx, err := newContext(sourceDir, buildDir, destDir, clean, debugBuild)
|
||||
// Convert the comma separated qt modules list to a whitespace separated one.
|
||||
qtModules = strings.Join(strings.Split(qtModules, ","), " ")
|
||||
|
||||
ctx, err := newContext(sourceDir, buildDir, destDir, qtModules, clean, debugBuild)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -52,6 +52,8 @@ type Context struct {
|
||||
BuildDir string
|
||||
DestDir string
|
||||
|
||||
QTModules string
|
||||
|
||||
GmlBindingDir string
|
||||
GmlBindingHeadersDir string
|
||||
GmlBindingSourcesDir string
|
||||
@ -71,7 +73,7 @@ type Context struct {
|
||||
DebugBuild bool
|
||||
}
|
||||
|
||||
func newContext(sourceDir, buildDir, destDir string, clean bool, debugBuild bool) (ctx *Context, err error) {
|
||||
func newContext(sourceDir, buildDir, destDir, qtModules string, clean bool, debugBuild bool) (ctx *Context, err error) {
|
||||
// Get absolute paths.
|
||||
sourceDir, err = filepath.Abs(sourceDir)
|
||||
if err != nil {
|
||||
@ -92,6 +94,7 @@ func newContext(sourceDir, buildDir, destDir string, clean bool, debugBuild bool
|
||||
SourceDir: sourceDir,
|
||||
BuildDir: buildDir,
|
||||
DestDir: destDir,
|
||||
QTModules: qtModules,
|
||||
QMLDir: filepath.Join(sourceDir, qmlDir),
|
||||
QMLResDir: filepath.Join(sourceDir, qmlResDir),
|
||||
QMLResFile: filepath.Join(sourceDir, qmlResFile),
|
||||
@ -121,7 +124,6 @@ func newContext(sourceDir, buildDir, destDir string, clean bool, debugBuild bool
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
err = ctx.cleanupDirs()
|
||||
|
||||
@ -51,7 +51,7 @@ func prepareQtProject(ctx *Context) (err error) {
|
||||
}
|
||||
|
||||
const qtProData = `
|
||||
QT += core qml quick
|
||||
QT += core qml quick {{ .QTModules }}
|
||||
|
||||
TEMPLATE = lib
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ func Containers() []string {
|
||||
|
||||
func Build(
|
||||
container string,
|
||||
sourceDir, buildDir, destDir string,
|
||||
sourceDir, buildDir, destDir, qtModules string,
|
||||
clean, noStrip, debugBuild, race, customContainer bool,
|
||||
tags string,
|
||||
) (err error) {
|
||||
@ -90,7 +90,7 @@ func Build(
|
||||
|
||||
utils.PrintColorln("> docker build: " + container)
|
||||
|
||||
user, err := user.Current()
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -103,8 +103,8 @@ func Build(
|
||||
|
||||
args := []string{
|
||||
"run", "--rm", "-i" + ttyArg,
|
||||
"-e", "UID=" + user.Uid,
|
||||
"-e", "GID=" + user.Gid,
|
||||
"-e", "UID=" + usr.Uid,
|
||||
"-e", "GID=" + usr.Gid,
|
||||
"-e", "GOBIN=/work/bin",
|
||||
"-e", "GOPATH=/work/go",
|
||||
"-e", "GOCACHE=/work/build/go-cache",
|
||||
@ -124,7 +124,8 @@ func Build(
|
||||
args = append(args, "build",
|
||||
"--source-dir", "/work/"+ctx.BinName,
|
||||
"--build-dir", "/work/build/gml-build",
|
||||
"--dest-dir", "/work/bin")
|
||||
"--dest-dir", "/work/bin",
|
||||
"--qt-modules", qtModules)
|
||||
|
||||
if clean {
|
||||
args = append(args, "--clean")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user