mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Enable to go-generate under non-GOPATH directories
This commit is contained in:
parent
88e488a5a6
commit
b9265d5120
@ -32,7 +32,6 @@ import (
|
|||||||
"golang.org/x/image/font"
|
"golang.org/x/image/font"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
"github.com/hajimehoshi/ebiten/internal"
|
|
||||||
"github.com/hajimehoshi/ebiten/text"
|
"github.com/hajimehoshi/ebiten/text"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -261,6 +260,21 @@ func outputKeyboardImage() (map[ebiten.Key]image.Rectangle, error) {
|
|||||||
return keyMap, nil
|
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}}
|
const keyRectTmpl = `{{.License}}
|
||||||
|
|
||||||
// Code generated by gen.go using 'go generate'. DO NOT EDIT.
|
// 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 {
|
func outputKeyRectsGo(k map[ebiten.Key]image.Rectangle) error {
|
||||||
license, err := internal.LicenseComment()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
path := "keyrects.go"
|
path := "keyrects.go"
|
||||||
|
|
||||||
f, err := os.Create(path)
|
f, err := os.Create(path)
|
||||||
|
22
genkeys.go
22
genkeys.go
@ -28,8 +28,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -348,12 +346,22 @@ func (k KeyNames) Swap(i, j int) {
|
|||||||
k[i], k[j] = k[j], k[i]
|
k[i], k[j] = k[j], k[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
const license = `// Copyright 2013 The Ebiten Authors
|
||||||
license, err := internal.LicenseComment()
|
//
|
||||||
if err != nil {
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
log.Fatal(err)
|
// 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).
|
// Follow the standard comment rule (https://golang.org/s/generatedcode).
|
||||||
doNotEdit := "// Code generated by genkeys.go using 'go generate'. DO NOT EDIT."
|
doNotEdit := "// Code generated by genkeys.go using 'go generate'. DO NOT EDIT."
|
||||||
|
|
||||||
|
@ -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
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user