From b9265d5120de6b53382f4b539d9616488950cfb9 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 28 Jul 2018 19:21:19 +0900 Subject: [PATCH] Enable to go-generate under non-GOPATH directories --- examples/keyboard/keyboard/gen.go | 20 +++++++++++---- genkeys.go | 22 ++++++++++------ internal/license.go | 42 ------------------------------- 3 files changed, 30 insertions(+), 54 deletions(-) delete mode 100644 internal/license.go diff --git a/examples/keyboard/keyboard/gen.go b/examples/keyboard/keyboard/gen.go index 08330d9ed..4a9db6d8e 100644 --- a/examples/keyboard/keyboard/gen.go +++ b/examples/keyboard/keyboard/gen.go @@ -32,7 +32,6 @@ import ( "golang.org/x/image/font" "github.com/hajimehoshi/ebiten" - "github.com/hajimehoshi/ebiten/internal" "github.com/hajimehoshi/ebiten/text" ) @@ -261,6 +260,21 @@ func outputKeyboardImage() (map[ebiten.Key]image.Rectangle, error) { return keyMap, nil } +const license = `// Copyright 2013 The Ebiten Authors +// +// 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. +` + const keyRectTmpl = `{{.License}} // Code generated by gen.go using 'go generate'. DO NOT EDIT. @@ -285,10 +299,6 @@ func KeyRect(key ebiten.Key) (image.Rectangle, bool) { }` func outputKeyRectsGo(k map[ebiten.Key]image.Rectangle) error { - license, err := internal.LicenseComment() - if err != nil { - return err - } path := "keyrects.go" f, err := os.Create(path) diff --git a/genkeys.go b/genkeys.go index 88cf7c6ea..129c6a631 100644 --- a/genkeys.go +++ b/genkeys.go @@ -28,8 +28,6 @@ import ( "strconv" "strings" "text/template" - - "github.com/hajimehoshi/ebiten/internal" ) var ( @@ -348,12 +346,22 @@ func (k KeyNames) Swap(i, j int) { k[i], k[j] = k[j], k[i] } -func main() { - license, err := internal.LicenseComment() - if err != nil { - log.Fatal(err) - } +const license = `// Copyright 2013 The Ebiten Authors +// +// 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. +` +func main() { // Follow the standard comment rule (https://golang.org/s/generatedcode). doNotEdit := "// Code generated by genkeys.go using 'go generate'. DO NOT EDIT." diff --git a/internal/license.go b/internal/license.go deleted file mode 100644 index 171b3c83f..000000000 --- a/internal/license.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 Hajime Hoshi -// -// 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 internal - -import ( - "regexp" - "strconv" - "strings" -) - -const license = `Copyright 2013 The Ebiten Authors - -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. -` - -// LicenseComment returns the license string in Go comment style. -func LicenseComment() (string, error) { - lines := strings.Split(license, "\n") - return "// " + strings.Join(lines[:len(lines)-1], "\n// "), nil -}