summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorNick White <git@njw.name>2021-06-21 18:04:33 +0100
committerNick White <git@njw.name>2021-06-21 18:11:35 +0100
commite1cbbad8b536e3fac4b236d81fa43b9ff3d6ccff (patch)
tree4b616e8ae2ee49f649c7a815ae7cd153c4a85d62 /cmd
parentee9c0f92067e3d203bd86958e9537cb1e5a0d80d (diff)
rescribe: Set up so only Tesseract needed for the build platform is embedded
Diffstat (limited to 'cmd')
-rw-r--r--cmd/rescribe/embed_darwin.go10
-rw-r--r--cmd/rescribe/embed_linux.go10
-rw-r--r--cmd/rescribe/embed_other.go13
-rw-r--r--cmd/rescribe/embed_windows.go10
-rw-r--r--cmd/rescribe/main.go11
5 files changed, 46 insertions, 8 deletions
diff --git a/cmd/rescribe/embed_darwin.go b/cmd/rescribe/embed_darwin.go
new file mode 100644
index 0000000..cad8a29
--- /dev/null
+++ b/cmd/rescribe/embed_darwin.go
@@ -0,0 +1,10 @@
+// Copyright 2021 Nick White.
+// Use of this source code is governed by the GPLv3
+// license that can be found in the LICENSE file.
+
+package main
+
+import _ "embed"
+
+// TODO: add go:embed here
+var tesszip []byte
diff --git a/cmd/rescribe/embed_linux.go b/cmd/rescribe/embed_linux.go
new file mode 100644
index 0000000..cad8a29
--- /dev/null
+++ b/cmd/rescribe/embed_linux.go
@@ -0,0 +1,10 @@
+// Copyright 2021 Nick White.
+// Use of this source code is governed by the GPLv3
+// license that can be found in the LICENSE file.
+
+package main
+
+import _ "embed"
+
+// TODO: add go:embed here
+var tesszip []byte
diff --git a/cmd/rescribe/embed_other.go b/cmd/rescribe/embed_other.go
new file mode 100644
index 0000000..fe51fd0
--- /dev/null
+++ b/cmd/rescribe/embed_other.go
@@ -0,0 +1,13 @@
+// Copyright 2021 Nick White.
+// Use of this source code is governed by the GPLv3
+// license that can be found in the LICENSE file.
+
+// +build !darwin
+// +build !linux
+// +build !windows
+
+package main
+
+// if not one of the above platforms, we won't embed anything, so
+// just create an empty byte slice
+var tesszip []byte
diff --git a/cmd/rescribe/embed_windows.go b/cmd/rescribe/embed_windows.go
new file mode 100644
index 0000000..c447624
--- /dev/null
+++ b/cmd/rescribe/embed_windows.go
@@ -0,0 +1,10 @@
+// Copyright 2021 Nick White.
+// Use of this source code is governed by the GPLv3
+// license that can be found in the LICENSE file.
+
+package main
+
+import _ "embed"
+
+//go:embed tesseract-w32-v5.0.0-alpha.20210506.zip
+var tesszip []byte
diff --git a/cmd/rescribe/main.go b/cmd/rescribe/main.go
index c47de00..51a33b2 100644
--- a/cmd/rescribe/main.go
+++ b/cmd/rescribe/main.go
@@ -1,4 +1,4 @@
-// Copyright 2019 Nick White.
+// Copyright 2021 Nick White.
// Use of this source code is governed by the GPLv3
// license that can be found in the LICENSE file.
@@ -43,9 +43,6 @@ Note that embedded Tesseract includes these training files:
- rescribev8_fast.traineddata (Latin historic printing)
`
-//go:embed tesseract-w32-v5.0.0-alpha.20210506.zip
-var w32zip []byte
-
const QueueTimeoutSecs = 2 * 60
const PauseBetweenChecks = 1 * time.Second
const LogSaveTime = 1 * time.Minute
@@ -184,15 +181,13 @@ func main() {
}
switch runtime.GOOS {
case "windows":
- err = unpackZip(w32zip, tessdir)
+ err = unpackZip(tesszip, tessdir)
if err != nil {
- log.Fatalln("Error unpacking embedded w32 zip:", err)
+ log.Fatalln("Error unpacking embedded Tesseract zip:", err)
}
tessCommand = filepath.Join(tessdir, "tesseract.exe")
// TODO: add linux and osx
}
-
- trainingPath = filepath.Join(tessdir, "tessdata", strings.Replace(trainingPath, "trainings/", "", 1))
}
f, err := os.Open(trainingPath)