mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/glfw: Refactoring
This commit is contained in:
parent
81ef20ddd0
commit
61c0908b13
@ -17,11 +17,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -111,10 +110,14 @@ func run() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
in, err := ioutil.ReadFile(dll)
|
dllf, err := os.Open(dll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer dllf.Close()
|
||||||
|
|
||||||
|
hash := sha256.New()
|
||||||
|
in := io.TeeReader(dllf, hash)
|
||||||
|
|
||||||
out, err := os.Create(fmt.Sprintf("glfwdll_windows_%s.go", arch))
|
out, err := os.Create(fmt.Sprintf("glfwdll_windows_%s.go", arch))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -123,7 +126,7 @@ func run() error {
|
|||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
// As the file name already specified the build environment, buildtags are not requried.
|
// As the file name already specified the build environment, buildtags are not requried.
|
||||||
if err := file2byteslice.Write(out, bytes.NewReader(in), true, "", "glfw", "glfwDLLCompressed"); err != nil {
|
if err := file2byteslice.Write(out, in, true, "", "glfw", "glfwDLLCompressed"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,13 +136,14 @@ func run() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer hashout.Close()
|
defer hashout.Close()
|
||||||
hash := sha256.Sum256(in)
|
|
||||||
|
hashsum := hash.Sum(nil)
|
||||||
if _, err := fmt.Fprintf(hashout, `// Code generated by gen.go. DO NOT EDIT.
|
if _, err := fmt.Fprintf(hashout, `// Code generated by gen.go. DO NOT EDIT.
|
||||||
|
|
||||||
package glfw
|
package glfw
|
||||||
|
|
||||||
const glfwDLLHash = "%s"
|
const glfwDLLHash = "%s"
|
||||||
`, hex.EncodeToString(hash[:])); err != nil {
|
`, hex.EncodeToString(hashsum[:])); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user