Skip to content

Commit 379cf22

Browse files
authored
🐛 Fix issue with PRQL build (#9)
Now, PRQL is not included in dev builds unless the prql tags is specified with make prql
1 parent 7f64e90 commit 379cf22

File tree

6 files changed

+40
-24
lines changed

6 files changed

+40
-24
lines changed

.goreleaser.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ builds:
1616
- fts5
1717
- sqlite_json
1818
- sqlite_math_functions
19+
- prql
1920

2021
ldflags:
2122
- -s -w
@@ -46,6 +47,7 @@ builds:
4647
- fts5
4748
- sqlite_json
4849
- sqlite_math_functions
50+
- prql
4951

5052
ldflags:
5153
- -s -w
@@ -70,6 +72,7 @@ builds:
7072
- fts5
7173
- sqlite_json
7274
- sqlite_math_functions
75+
- prql
7376
ldflags:
7477
- -s -w
7578
env:

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"go.buildTags": "vtable"
2+
"go.buildTags": "vtable fts5 sqlite_json sqlite_math_functions"
33
}

makefile

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ FILES:= main.go
33
ifdef CC
44
CC := $(CC)
55
else
6-
CC := "gcc -O3"
6+
CC := "gcc -O2"
77
endif
88

9-
TAGS := "vtable fts5 sqlite_json sqlite_math_functions"
10-
9+
TAGS := vtable fts5 sqlite_json sqlite_math_functions
10+
1111
BUILD_FLAGS := "-ldflags=-s -w"
1212

1313
all: $(FILES)
14-
go build -o main.out -tags $(TAGS) $(BUILD_FLAGS) $(FILES)
14+
go build -o main.out -tags "$(TAGS)" $(BUILD_FLAGS) $(FILES)
15+
16+
prql: $(FILES)
17+
go build -o main.out -tags "$(TAGS) prql" $(BUILD_FLAGS) $(FILES)
1518

1619
clean:
1720
rm -f main.out

other/prql/prql.go

+6-19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build prql
2+
13
package prql
24

35
// #cgo CFLAGS: -I.
@@ -26,21 +28,6 @@ import (
2628
"unsafe"
2729
)
2830

29-
type SourceLocationError struct {
30-
startLine int
31-
startColumn int
32-
endLine int
33-
endColumn int
34-
}
35-
36-
type CompileMessage struct {
37-
ErrorCode rune
38-
// Annoted code containing the error and the hints
39-
Display string
40-
// The location of the error
41-
LocationError SourceLocationError
42-
}
43-
4431
func ToSQL(prqlQuery string) (string, []CompileMessage) {
4532
res := C.to_sql(C.CString(prqlQuery))
4633
a := res.messages
@@ -59,10 +46,10 @@ func ToSQL(prqlQuery string) (string, []CompileMessage) {
5946
}
6047

6148
if message.location != nil {
62-
compileMessage.LocationError.startLine = int(message.location.start_line)
63-
compileMessage.LocationError.startColumn = int(message.location.start_col)
64-
compileMessage.LocationError.endLine = int(message.location.end_line)
65-
compileMessage.LocationError.endColumn = int(message.location.end_col)
49+
compileMessage.LocationError.StartLine = int(message.location.start_line)
50+
compileMessage.LocationError.StartColumn = int(message.location.start_col)
51+
compileMessage.LocationError.EndLine = int(message.location.end_line)
52+
compileMessage.LocationError.EndColumn = int(message.location.end_col)
6653
}
6754

6855
messages[i] = compileMessage

other/prql/prql_blank.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build !prql
2+
3+
package prql
4+
5+
func ToSQL(prqlQuery string) (string, []CompileMessage) {
6+
return prqlQuery, nil
7+
}

other/prql/types.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package prql
2+
3+
type SourceLocationError struct {
4+
StartLine int
5+
StartColumn int
6+
EndLine int
7+
EndColumn int
8+
}
9+
10+
type CompileMessage struct {
11+
ErrorCode rune
12+
// Annoted code containing the error and the hints
13+
Display string
14+
// The location of the error
15+
LocationError SourceLocationError
16+
}

0 commit comments

Comments
 (0)