Commit 82e61b1c authored by Oscar Campos's avatar Oscar Campos Committed by Oscar Campos
Browse files

fix: fix generate pipeline stage

parent 7c85aa4e
......@@ -8,4 +8,8 @@ doc/
*.dynlib
*.dll
*_registrable.gen.go
gdnative/*.gen.*
.vscode/
plan/
......@@ -42,6 +42,8 @@ go_bindings_generation:
stage: generation
script:
- go get -u github.com/sqs/goreturns
- export PATH="$PATH:$GOPATH/bin"
- git submodule update --init
- go run build/mage.go generate
allow_failure: false
except:
......
// Copyright © 2019 - 2020 Oscar Campos <oscar.campos@thepimpam.com>
// Copyright © 2017 - William Edwards
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License
package main
import (
"github.com/alecthomas/kong"
)
var description = `Compiles gdnative-go packages with auto registration data into NativeScript boilerplate`
// main application entry point
func main() {
ctx := kong.Parse(&cli,
kong.Description(description),
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{Compact: true}),
)
err := ctx.Run(&context{Path: cli.Path, Verbose: cli.Verbose})
ctx.FatalIfErrorf(err)
}
// Copyright © 2019 - 2020 Oscar Campos <oscar.campos@thepimpam.com>
// Copyright © 2017 - William Edwards
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License
package main
import (
"fmt"
"os"
"path/filepath"
)
const unknown string = "unknown"
var (
version = unknown
commit = unknown
date = unknown
builtBy = unknown
)
type versionCmd struct{}
func (cmd *versionCmd) Run(ctx *context) error {
appName := filepath.Base(os.Args[0])
fmt.Printf(
"%s %s-%s\n\tbuilt on: %s\n\tbuilt by: %s\n",
appName, version, commit, date, builtBy,
)
return nil
}
......@@ -5,7 +5,6 @@ package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"runtime"
......@@ -42,7 +41,7 @@ func Generate() error {
// Clean cleans previous generations
func Clean() error {
log.Println("Cleaning previous generation...")
fmt.Println("Cleaning previous generation...")
path := filepath.Join(getCurrentFilePath(), "gdnative", "*.gen.*")
files, globErr := filepath.Glob(path)
if globErr != nil {
......@@ -64,19 +63,25 @@ func RetrieveGodotDocumentation() error {
_, found := os.Stat(docPath)
if found == nil {
_ = os.Chdir(docPath)
log.Println("Godot documentation found. Pulling latest changes...")
defer func() {
_ = os.Chdir(localPath)
}()
fmt.Println("Godot documentation found. Pulling latest changes...")
if err := sh.Run("git", "pull", "origin", "master"); err != nil {
return fmt.Errorf("could not pull latest Godot documentation from git: %w", err)
}
_ = os.Chdir(localPath)
return nil
}
log.Println("Godot documentation not found. Cloning the repository...")
fmt.Println("Godot documentation not found. Cloning the repository...")
if err := os.MkdirAll(docPath, 0766); err != nil {
return fmt.Errorf("could not create a new directory on the disk: %w", err)
}
_ = os.Chdir(docPath)
defer func() {
_ = os.Chdir(localPath)
}()
if err := sh.Run("git", "init"); err != nil {
return fmt.Errorf("could not execute git init: %w", err)
}
......@@ -113,7 +118,7 @@ func getCurrentFilePath() string {
_, filename, _, ok := runtime.Caller(0)
if !ok {
log.Fatal("could not get current file path")
panic(fmt.Errorf("could not get current file path"))
}
return filepath.Join(filepath.Dir(filename))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment