maddyblue / sqlfmt

SQL formatter with width-aware output
https://sqlfum.pt
Apache License 2.0
418 stars 23 forks source link

Undefined errors from CockroachDB when trying to build #41

Open dalanmiller opened 6 years ago

dalanmiller commented 6 years ago

I've definitely ran make in the $GOPATH/src/github.com/cockroachdb/cockroach dir, but still seem to be getting this undefined errors.

āžœ  sqlfmt git:(master) bash build.sh
+ IMG=gcr.io/hots-cockroach/sqlfmt:latest
+ go build -o sqlfmt
# github.com/cockroachdb/cockroach/pkg/sql/lex
../../cockroachdb/cockroach/pkg/sql/lex/keywords.go:10:32: undefined: ABORT
../../cockroachdb/cockroach/pkg/sql/lex/keywords.go:11:32: undefined: ACTION
../../cockroachdb/cockroach/pkg/sql/lex/keywords.go:12:32: undefined: ADD
../../cockroachdb/cockroach/pkg/sql/lex/keywords.go:13:32: undefined: ADMIN
../../cockroachdb/cockroach/pkg/sql/lex/keywords.go:14:32: undefined: AGGREGATE
../../cockroachdb/cockroach/pkg/sql/lex/keywords.go:15:32: undefined: ALL
../../cockroachdb/cockroach/pkg/sql/lex/keywords.go:16:32: undefined: ALTER
../../cockroachdb/cockroach/pkg/sql/lex/keywords.go:17:32: undefined: ANALYSE
../../cockroachdb/cockroach/pkg/sql/lex/keywords.go:18:32: undefined: ANALYZE
../../cockroachdb/cockroach/pkg/sql/lex/keywords.go:19:32: undefined: AND
../../cockroachdb/cockroach/pkg/sql/lex/keywords.go:19:32: too many errors
maddyblue commented 6 years ago

See the last line of the readme:

Requires having the master branch of https://github.com/cockroachdb/cockroach checked out at $GOPATH/src/github.com/cockroachdb/cockroach, and running make in that directory.

dalanmiller commented 6 years ago

Apologies @mjibson, as a post-posting edit, I mentioned that I had done that! šŸ™‡

maddyblue commented 6 years ago

Those identifiers should appear in a file called tokens.go. I'm not convinced make ran successfully because it would exist otherwise. Other option is to checkout https://github.com/cockroachdb/cockroach-gen at github.com/cockroachdb/cockroach which already has all of the files pregenerated.

dalanmiller commented 6 years ago

That was it! I was getting really variable output when running make and assumed nothing went wrong. Blew everything away and then properly ensured I had cmake installed made everything go away.

Now I'm getting different undefined errors in a couple files when attempting to target WASM:

$ GOOS=js GOARCH=wasm go build -o main.wasm
# github.com/cockroachdb/cockroach/pkg/util/sysutil
../../cockroachdb/cockroach/pkg/util/sysutil/sysutil.go:51:23: undefined: syscall.SIGHUP
../../cockroachdb/cockroach/pkg/util/sysutil/sysutil_unix.go:32:3: undefined: unix.Getuid
../../cockroachdb/cockroach/pkg/util/sysutil/sysutil_unix.go:32:18: undefined: unix.Geteuid
../../cockroachdb/cockroach/pkg/util/sysutil/sysutil_unix.go:32:34: undefined: unix.Getgid
../../cockroachdb/cockroach/pkg/util/sysutil/sysutil_unix.go:32:49: undefined: unix.Getegid
../../cockroachdb/cockroach/pkg/util/sysutil/sysutil_unix.go:38:9: undefined: unix.Statfs_t
../../cockroachdb/cockroach/pkg/util/sysutil/sysutil_unix.go:39:12: undefined: unix.Statfs
# github.com/cockroachdb/cockroach/vendor/github.com/lib/pq
../../cockroachdb/cockroach/vendor/github.com/lib/pq/conn.go:321:13: undefined: userCurrent
maddyblue commented 6 years ago

Ah yeah. WASM isn't going to work because cockroach uses some unix-only stuff that's only been added for windows. I think I fixed all of them once and the output was still like a 50MB wasm file which is way too huge for any browser or serverless platform to accept.