adrg/sysfont

Build failure using TinyGo

tdewolff opened this issue · 6 comments

See tdewolff/canvas#83 (comment)

It appears that this library cannot be built using TinyGo, is this something you'd like to support?

# github.com/adrg/xdg
github.com/adrg/xdg@v0.3.3/paths_unix.go:18:87: Getuid not declared by package os
github.com/adrg/xdg@v0.3.3/utils.go:59:16: MkdirAll not declared by package os
github.com/adrg/xdg@v0.3.3/utils.go:59:33: ModeDir not declared by package os
adrg commented

Hi @tdewolff. It would be great if TinyGo was supported by xdg (and implicitly by sysfont). However, I think it might be better to raise the issues on the TinyGo repository. It would certainly avoid a lot of workarounds on my part in order to make it work.

From what I can tell, two of the three issues you mentioned are already in work there:

ModeDir not declared by package os: there's already an issue for this (tinygo-org/tinyfs#4) and a PR (tinygo-org/tinygo#1903) which has been merged already.

Getuid not declared by package os: there's already an issue for this one as well (tinygo-org/tinygo#1886) and a PR (tinygo-org/tinygo#1892) which will hopefully be merged soon.

So there's only MkdirAll not declared by package os left. Maybe @gedw99 can open an issue there regarding this because it's not specific to the xdg library.

Are these issues on Go 1.16 only or does this reproduce with Go 1.15 as well?

Hey Adrian, thanks for the quick and in-depth response. I agree this would be better to take up with TinyGo!

hey @tdewolff @adrg

"So there's only MkdirAll not declared by package os left ..."

Some ideas on this:

  1. Virtualise the OS file system using indexdb as the base store.

https://github.com/JohnStarich/go-wasm/blob/master/internal/js/fs/mkdir.go

Johns project wraps the golang file OS with a indexdb based implementation, allowing golang wasm to work.
He uses file embeded at compile time to put the golang src code into the system it seems.
This is not what we want though i think. As what you want is to be able to see if the fonts are on the real OS the browser is running on right ?

Yep its crazy but thats the golang src files, sitting there in indexdb.
Screenshot 2021-06-04 at 14 49 43

  1. this supports Mkdir: tinygo-org/tinyfs#5

Not sure if this is a viable option for the sysfont project though.

BTW added "no-debug" flag sometimes helps things work

For example:
tinygo build -o wasm.wasm -target=wasm -no-debug -tags=example ./examples/2048/

tinygo now supports os.MkdirAll().

The next problem blocking "tinygo test" from working in sysfont seems to be unsupported uses of reflect in testify and go-spew, see
tinygo-org/tinygo#2650
tinygo-org/tinygo#2649