0001-If-the-GOMOBILE_TMPDIR-env-variable-is-defined-use-t.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From 188307b6acd5003e82cb68872da9463f5f707515 Mon Sep 17 00:00:00 2001
  2. From: Nicolas Vigier <boklm@torproject.org>
  3. Date: Thu, 27 Jun 2019 12:46:38 +0200
  4. Subject: [PATCH] If the GOMOBILE_TMPDIR env variable is defined, use that as
  5. tmpdir
  6. Having the option to select a fixed tmpdir makes it possible to have
  7. reproducible builds, as the build directory is embedded in the generated
  8. executables.
  9. ---
  10. cmd/gomobile/env.go | 11 ++++++++---
  11. 1 file changed, 8 insertions(+), 3 deletions(-)
  12. diff --git a/cmd/gomobile/env.go b/cmd/gomobile/env.go
  13. index 471b009..b97141b 100644
  14. --- a/cmd/gomobile/env.go
  15. +++ b/cmd/gomobile/env.go
  16. @@ -61,9 +61,14 @@ func buildEnvInit() (cleanup func(), err error) {
  17. tmpdir = "$WORK"
  18. cleanupFn = func() {}
  19. } else {
  20. - tmpdir, err = ioutil.TempDir("", "gomobile-work-")
  21. - if err != nil {
  22. - return nil, err
  23. + gomobile_tmpdir := os.Getenv("GOMOBILE_TMPDIR")
  24. + if gomobile_tmpdir != "" {
  25. + tmpdir = gomobile_tmpdir
  26. + } else {
  27. + tmpdir, err = ioutil.TempDir("", "gomobile-work-")
  28. + if err != nil {
  29. + return nil, err
  30. + }
  31. }
  32. }
  33. if buildX {