]> Sergey Matveev's repositories - tofuproxy.git/commitdiff
Refactor C-code building, use pkgconf
authorSergey Matveev <stargrave@stargrave.org>
Mon, 1 Nov 2021 09:45:12 +0000 (12:45 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 1 Nov 2021 09:45:12 +0000 (12:45 +0300)
23 files changed:
all.do
cmd/.gitignore [deleted file]
cmd/enzstd/.gitignore [deleted file]
cmd/enzstd/README [deleted file]
cmd/enzstd/compile_flags.txt.do [deleted symlink]
cmd/enzstd/enzstd.do [deleted file]
cmd/unzstd/.gitignore [deleted file]
cmd/unzstd/compile_flags.txt.do [deleted file]
cmd/unzstd/unzstd.do [deleted file]
cmd/zstd/.gitignore [new file with mode: 0644]
cmd/zstd/README [new file with mode: 0644]
cmd/zstd/all.do [new file with mode: 0644]
cmd/zstd/compile_flags.txt.do [new file with mode: 0644]
cmd/zstd/conf/.gitignore [new file with mode: 0644]
cmd/zstd/conf/pkgconf.rc.do [new file with mode: 0644]
cmd/zstd/conf/zstd.cflags.rc.do [new file with mode: 0644]
cmd/zstd/conf/zstd.libs.rc.do [new file with mode: 0644]
cmd/zstd/default.do [new file with mode: 0644]
cmd/zstd/enzstd.c [moved from cmd/enzstd/enzstd.c with 100% similarity]
cmd/zstd/unzstd.c [moved from cmd/unzstd/unzstd.c with 100% similarity]
default.cmd.do
doc/warcs.texi
warc/open.go

diff --git a/all.do b/all.do
index c4a5702e8af42b1d5da19131f4fa9cd35e52692f..4f7b66f8f9761b972a05317876e4b6a8c55b498b 100644 (file)
--- a/all.do
+++ b/all.do
@@ -1,2 +1,2 @@
-redo-ifchange cert.pem tofuproxy.cmd fifos/ensure cmd/unzstd/unzstd
+redo-ifchange cert.pem tofuproxy.cmd fifos/ensure cmd/zstd/unzstd
 mkdir -p certs ccerts
diff --git a/cmd/.gitignore b/cmd/.gitignore
deleted file mode 100644 (file)
index 895dab3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-compile_flags.txt
diff --git a/cmd/enzstd/.gitignore b/cmd/enzstd/.gitignore
deleted file mode 100644 (file)
index 6fcec77..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/enzstd
diff --git a/cmd/enzstd/README b/cmd/enzstd/README
deleted file mode 100644 (file)
index ca20ab6..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-enzstd creates Zstandard compressed stream of frames, where each frame
-holds exactly single WARC record. It also explicitly adds checksum.
-Utility takes records from stdin, where each record has 64-bit
-big-endian length prefix.
diff --git a/cmd/enzstd/compile_flags.txt.do b/cmd/enzstd/compile_flags.txt.do
deleted file mode 120000 (symlink)
index 0f4f6ff..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../unzstd/compile_flags.txt.do
\ No newline at end of file
diff --git a/cmd/enzstd/enzstd.do b/cmd/enzstd/enzstd.do
deleted file mode 100644 (file)
index c381e4e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-src=enzstd.c
-redo-ifchange $src
-${CC:-cc} ${CFLAGS} -o $3 $src $LDFLAGS -lzstd
diff --git a/cmd/unzstd/.gitignore b/cmd/unzstd/.gitignore
deleted file mode 100644 (file)
index f2358dc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/unzstd
diff --git a/cmd/unzstd/compile_flags.txt.do b/cmd/unzstd/compile_flags.txt.do
deleted file mode 100644 (file)
index 13b13f1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-printf "%s" "$CFLAGS $LDFLAGS" | tr " " "\n" | grep -v "^$" | sort | uniq
diff --git a/cmd/unzstd/unzstd.do b/cmd/unzstd/unzstd.do
deleted file mode 100644 (file)
index 8b50f9f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-src=unzstd.c
-redo-ifchange $src
-${CC:-cc} ${CFLAGS} -o $3 $src $LDFLAGS -lzstd
diff --git a/cmd/zstd/.gitignore b/cmd/zstd/.gitignore
new file mode 100644 (file)
index 0000000..06ed646
--- /dev/null
@@ -0,0 +1,3 @@
+/compile_flags.txt
+/enzstd
+/unzstd
diff --git a/cmd/zstd/README b/cmd/zstd/README
new file mode 100644 (file)
index 0000000..7a1612c
--- /dev/null
@@ -0,0 +1,11 @@
+enzstd creates Zstandard compressed stream of frames, where each frame
+holds exactly single WARC record. It also explicitly adds checksum.
+Utility takes records from stdin, where each record has 64-bit
+big-endian length prefix.
+
+unzstd decompressed Zstandard frames stream from stdin to stdout. If
+stream starts with the dictionary (either compressed, or uncompressed)
+it is loaded first. If 3rd file descriptor is opened, then each frame's
+offset (its size) with decompressed data size is printed in
+tab-separated format. If the stream contains dictionary, then first
+frame's data size equals to zero.
diff --git a/cmd/zstd/all.do b/cmd/zstd/all.do
new file mode 100644 (file)
index 0000000..aac1e34
--- /dev/null
@@ -0,0 +1 @@
+redo-ifchange enzstd unzstd
diff --git a/cmd/zstd/compile_flags.txt.do b/cmd/zstd/compile_flags.txt.do
new file mode 100644 (file)
index 0000000..d07460a
--- /dev/null
@@ -0,0 +1,5 @@
+redo-ifchange $src conf/zstd.cflags.rc conf/zstd.libs.rc
+read ZSTD_CFLAGS < conf/zstd.cflags.rc
+read ZSTD_LIBS < conf/zstd.libs.rc
+printf "%s" "$CFLAGS $ZSTD_CFLAGS $LDFLAGS $ZSTD_LIBS" |
+    tr " " "\n" | grep -v "^$" | sort | uniq
diff --git a/cmd/zstd/conf/.gitignore b/cmd/zstd/conf/.gitignore
new file mode 100644 (file)
index 0000000..27f2869
--- /dev/null
@@ -0,0 +1 @@
+/*.rc
diff --git a/cmd/zstd/conf/pkgconf.rc.do b/cmd/zstd/conf/pkgconf.rc.do
new file mode 100644 (file)
index 0000000..5b57e6e
--- /dev/null
@@ -0,0 +1 @@
+echo ${PKGCONF:-`command -v pkgconf || command -v pkg-config`}
diff --git a/cmd/zstd/conf/zstd.cflags.rc.do b/cmd/zstd/conf/zstd.cflags.rc.do
new file mode 100644 (file)
index 0000000..2dcf2b2
--- /dev/null
@@ -0,0 +1,3 @@
+redo-ifchange pkgconf.rc
+read PKGCONF < pkgconf.rc
+$PKGCONF --cflags libzstd
diff --git a/cmd/zstd/conf/zstd.libs.rc.do b/cmd/zstd/conf/zstd.libs.rc.do
new file mode 100644 (file)
index 0000000..d9b1fb7
--- /dev/null
@@ -0,0 +1,3 @@
+redo-ifchange pkgconf.rc
+read PKGCONF < pkgconf.rc
+$PKGCONF --libs libzstd
diff --git a/cmd/zstd/default.do b/cmd/zstd/default.do
new file mode 100644 (file)
index 0000000..387fbb5
--- /dev/null
@@ -0,0 +1,5 @@
+src=$1.c
+redo-ifchange $src conf/zstd.cflags.rc conf/zstd.libs.rc
+read ZSTD_CFLAGS < conf/zstd.cflags.rc
+read ZSTD_LIBS < conf/zstd.libs.rc
+${CC:-cc} $CFLAGS $ZSTD_CFLAGS -o $3 $src $ZSTD_LIBS
similarity index 100%
rename from cmd/enzstd/enzstd.c
rename to cmd/zstd/enzstd.c
similarity index 100%
rename from cmd/unzstd/unzstd.c
rename to cmd/zstd/unzstd.c
index c2ee005ce30fcfdda95e6e7893f1b6f2a44e242a..97e15022ed195b01a0d75ea62779523472ffaa1b 100644 (file)
@@ -6,5 +6,7 @@ redo-ifchange \
     rounds/*.go \
     tls/*.go \
     warc/*.go
-GO_LDFLAGS="${GO_LDFLAGS:--ldflags=-s}"
-${GO:-go} build -o $3 $GO_LDFLAGS ./cmd/${1%.cmd}
+UNZSTD_PATH="`pwd`/cmd/zstd/unzstd"
+GO_LDFLAGS="${GO_LDFLAGS:--s}"
+GO_LDFLAGS="$GO_LDFLAGS -X go.stargrave.org/tofuproxy/warc.UnZSTDPath=$UNZSTD_PATH"
+${GO:-go} build -o $3 -ldflags="$GO_LDFLAGS" ./cmd/${1%.cmd}
index b20b120e301679292c05fd1bcf991f827ee3675c..a88cde4e9e135d111f1e0740d6f13545af30380f 100644 (file)
@@ -24,13 +24,11 @@ Zstandard compressed WARC, as in
 Multi-frame format is properly indexed. Dictionary at the beginning
 is also supported.
 
-It is processed with with @command{unzstd} (@file{cmd/unzstd/unzstd})
+It is processed with with @command{unzstd} (@file{cmd/zstd/unzstd})
 utility. It eats compressed stream from @code{stdin}, outputs
 decompressed data to @code{stdout}, and prints each frame size with
 corresponding decompressed data size to 3rd file descriptor (if it is
-opened). You can adjust path to it with
-@code{-X go.stargrave.org/tofuproxy/warc.UnZSTDPath} command line option
-during building.
+opened).
 
 @end table
 
index e742f9e6792dd0e8592d51398d87987f483848bb..ade3079c89686adc0a269f61ae272ebfe6b73aba 100644 (file)
@@ -24,7 +24,7 @@ import (
        "path"
 )
 
-var UnZSTDPath = "/home/stargrave/work/tofuproxy/cmd/unzstd/unzstd"
+var UnZSTDPath = "/home/stargrave/work/tofuproxy/cmd/zstd/unzstd"
 
 type Offset struct {
        Z int64 // Compressed frame size