forked from go-gl/glfw
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make build cache a function of the glfw C sources
This is a workaround for the issue described in go-gl#269. Go unfortunately doesn't consider the C source files as part of its build cache calculation. Therefore, invalidate it by writing a hash which is computed across the full C source directory. This hash is only updated when `go generate` is called, but this will at least help the majority of users, when glfw is updated. This is encoded in grab-upstream.sh which is used for updating the sources. This hash is intended to be protected from divergance by CI, too. Resolves go-gl#269.
- Loading branch information
Showing
3 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
|
||
# This script computes the hash of the directory called "glfw", relative to $PWD | ||
# at time of invocation, and writes it into the upstreamTreeSHA constant in | ||
# glfw_tree_rebuild.go. Invoke this in a directory containing | ||
# glfw_tree_rebuild.go. | ||
|
||
export GIT_INDEX_FILE=$(mktemp) | ||
rm $GIT_INDEX_FILE | ||
git update-index | ||
git add glfw | ||
HASH=$(git write-tree) | ||
rm $GIT_INDEX_FILE | ||
|
||
sed -Ei 's/const upstreamTreeSHA = "[0-9a-f]+"/const upstreamTreeSHA = "'${HASH}'"/' glfw_tree_rebuild.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package glfw | ||
|
||
//go:generate ../../scripts/glfw_tree_rebuild.sh | ||
|
||
// This is a recursive hash of the full contents of the upstream glfw, as | ||
// generated by git (doesn't need to be committed) when you run `go generate` on | ||
// this package. This exists to invalidate the build cache (see [0]), which is | ||
// unaffected by C source inputs. | ||
// [0] https://github.com/go-gl/glfw/issues/269 | ||
const upstreamTreeSHA = "02493b10419e99f1293bfbb4fd805aadd527607e" |