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