Skip to content

Commit 39d2707

Browse files
committed
better prebuilts
1 parent f90f978 commit 39d2707

File tree

11 files changed

+100
-40
lines changed

11 files changed

+100
-40
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ For usage examples, see `examples` directory.
7272
Building
7373
------------------------------------------------------------------------------
7474

75-
The library uses a pre-built embedded build of sqinn for Linux/amd64 and
76-
Windows/amd64.
75+
The library includes a prebuilt embedded build of sqinn for linux_amd64 and
76+
windows_amd64.
7777

78-
If you do not want to use a pre-built sqinn binary, you can compile sqinn
78+
If you do not want to use a prebuilt sqinn binary, you can compile sqinn
7979
yourself. See <https://github.com/cvilsmeier/sqinn> for instructions.
8080
You must then specify the path to sqinn like so:
8181

@@ -181,6 +181,11 @@ might occur. The PRAGMA busy_timeout might help to avoid SQLITE_BUSY errors.
181181
Changelog
182182
------------------------------------------------------------------------------
183183

184+
### v2.1.0-dev
185+
186+
- better prebuilts (gzip and use bulid constraints)
187+
188+
184189
### v2.0.1
185190

186191
- ValXy const is now byte (was untyped)

prebuilt/howto.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
HOWTO MAKE PREBUILT
2+
--------------------------------------
3+
4+
Sqinn-go embeds prebuilt sqinn binaries for convenience.
5+
Currently it embeds linux_amd64 and windows_amd64.
6+
7+
To update them, do this:
8+
9+
- Download latest sqinn builds from https://github.com/cvilsmeier/sqinn/releases
10+
11+
- Extract dist-*.zip archives (e.g. in Downloads folder)
12+
13+
cd prebuilt
14+
cat ~/Downloads/dist-linux-amd64/sqinn | gzip > linux-amd64.gz
15+
cat ~/Downloads/dist-windows-amd64/sqinn.exe | gzip > windows-amd64.gz
16+
17+
That's it.

prebuilt/linux-amd64.gz

984 KB
Binary file not shown.

prebuilt/linux/sqinn

-2 MB
Binary file not shown.

prebuilt/prebuilt.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package prebuilt
2+
3+
import (
4+
"bytes"
5+
"compress/gzip"
6+
"fmt"
7+
"io"
8+
"os"
9+
"path/filepath"
10+
"runtime"
11+
)
12+
13+
func Extract() (_dirname string, _filename string, _err error) {
14+
if len(gzipData) == 0 {
15+
platform := runtime.GOOS + "_" + runtime.GOARCH
16+
return "", "", fmt.Errorf("no embedded prebuilt sqinn binary found for %s, please build your own, see https://github.com/cvilsmeier/sqinn for build instructions", platform)
17+
}
18+
tempdir, err := os.MkdirTemp("", "")
19+
if err != nil {
20+
return "", "", err
21+
}
22+
tempname := filepath.Join(tempdir, "sqinn")
23+
gr, err := gzip.NewReader(bytes.NewReader(gzipData))
24+
if err != nil {
25+
os.RemoveAll(tempdir)
26+
return "", "", err
27+
}
28+
f, err := os.OpenFile(tempname, os.O_RDWR|os.O_CREATE, 0755)
29+
if err != nil {
30+
os.RemoveAll(tempdir)
31+
return "", "", err
32+
}
33+
defer f.Close()
34+
_, err = io.Copy(f, gr)
35+
if err != nil {
36+
os.RemoveAll(tempdir)
37+
return "", "", err
38+
}
39+
return tempdir, tempname, nil
40+
}

prebuilt/prebuilt_linux_amd64.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package prebuilt
2+
3+
import (
4+
_ "embed"
5+
)
6+
7+
//go:embed "linux-amd64.gz"
8+
var gzipData []byte

prebuilt/prebuilt_other.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//go:build !((linux || windows) && amd64)
2+
3+
package prebuilt
4+
5+
var gzipData []byte = nil

prebuilt/prebuilt_windows_amd64.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package prebuilt
2+
3+
import (
4+
_ "embed"
5+
)
6+
7+
//go:embed "windows-amd64.gz"
8+
var gzipData []byte

prebuilt/windows-amd64.gz

562 KB
Binary file not shown.

prebuilt/windows/sqinn.exe

-1.42 MB
Binary file not shown.

0 commit comments

Comments
 (0)