diff options
author | Ayke van Laethem <[email protected]> | 2023-10-13 21:56:22 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-10-14 11:35:26 +0200 |
commit | 72b715fa99780e33e2d69615db43bc56834c9a5b (patch) | |
tree | da113d0829171e3d99b5f646131cbb869aca2ac7 /goenv | |
parent | d801d0cd539447322228e9f1daa860774584b4d3 (diff) | |
download | tinygo-72b715fa99780e33e2d69615db43bc56834c9a5b.tar.gz tinygo-72b715fa99780e33e2d69615db43bc56834c9a5b.zip |
all: add Nix flake file
This adds a flake.nix file that makes it possible to quickly create a
development environment.
You can download Nix here, for use on your Linux or macOS system:
https://nixos.org/download.html
After you have installed Nix, you can enter the development environment
as follows:
nix develop
This drops you into a bash shell, where you can install TinyGo simply
using the following command:
go install
That's all! Assuming you've set up your $PATH correctly, you can now use
the tinygo command as usual:
tinygo version
You can also do many other things from this environment. Building and
flashing should work as you're used to: it's not a VM or container so
there are no access restrictions.
Diffstat (limited to 'goenv')
-rw-r--r-- | goenv/goenv.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/goenv/goenv.go b/goenv/goenv.go index 5e2a3753b..4715b8769 100644 --- a/goenv/goenv.go +++ b/goenv/goenv.go @@ -43,6 +43,12 @@ var hasBuiltinTools = false // directory. var TINYGOROOT string +// If a particular Clang resource dir must always be used and TinyGo can't +// figure out the directory using heuristics, this global can be set using a +// linker flag. +// This is needed for Nix. +var clangResourceDir string + // Variables read from a `go env` command invocation. var goEnvVars struct { GOPATH string @@ -298,6 +304,15 @@ func isSourceDir(root string) bool { // In that case, the resource dir is always returned (even when linking // dynamically against LLVM) because libclang always needs this directory. func ClangResourceDir(libclang bool) string { + if clangResourceDir != "" { + // The resource dir is forced to a particular value at build time. + // This is needed on Nix for example, where Clang and libclang don't + // know their own resource dir. + // Also see: + // https://discourse.nixos.org/t/why-is-the-clang-resource-dir-split-in-a-separate-package/34114 + return clangResourceDir + } + if !hasBuiltinTools && !libclang { // Using external tools, so the resource dir doesn't need to be // specified. Clang knows where to find it. |