Skip to content

Commit 5313d08

Browse files
cyanogilvieclaude
andcommitted
Use meson dist for release tarballs, add build instructions
- Replace manual cp/tar with meson dist + dist_fixup.sh script - Dist script bakes README.md, manpage, and autoconf configure - Removes JSONTestSuite (167MB) and .github from release tarballs - Replaces symlinks with copies for Windows compatibility - Add BUILDING section to documentation with meson/autotools/Docker examples Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f859afc commit 5313d08

5 files changed

Lines changed: 190 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,15 @@ jobs:
101101
- name: Create source tarball
102102
run: |
103103
project="${{ steps.version.outputs.project }}"
104-
meson compile -C build readme
105-
cp build/doc/README.md README.md
106-
cp -aL . "/tmp/${project}"
107-
find "/tmp/${project}" -name '.git' -exec rm -rf {} +
108-
rm -rf "/tmp/${project}/.github"
109-
rm -rf "/tmp/${project}/build" "/tmp/${project}/builddir" "/tmp/${project}/buildwin"
110-
rm -rf "/tmp/${project}/subprojects/packagecache"
111-
rm -rf "/tmp/${project}/subprojects/tcl"
112-
rm -rf "/tmp/${project}/subprojects/libtommath-"*
113-
rm -rf "/tmp/${project}/subprojects/.wraplock"
104+
# Build docs so the dist script can bake README.md and manpage
105+
meson compile -C build doc
106+
# meson dist creates a clean tarball from git-tracked files,
107+
# then runs tools/dist_fixup.sh to copy README, remove .github,
108+
# and replace symlinks with copies (for Windows users)
109+
meson dist -C build --no-tests --allow-dirty --formats xztar
110+
# Repack as .tar.gz and create a zip for the release
111+
tar xf build/meson-dist/rl_json-*.tar.xz -C /tmp
112+
mv "/tmp/rl_json-${{ steps.version.outputs.version }}" "/tmp/${project}"
114113
tar czf "/tmp/${project}.tar.gz" -C /tmp "${project}"
115114
cd /tmp && zip -rq "${project}-source.zip" "${project}"
116115

README.md

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
---
2-
author:
3-
- Cyan Ogilvie
4-
title: json(n) 0.16 \| rl_json Tcl JSON Package
5-
---
6-
71
# NAME
82

93
json - Parse, manipulate and produce JSON documents
@@ -732,6 +726,73 @@ Replacements are:
732726
- `?size` - use **json length** *json_val* ?*key …*?
733727
- `?keys` - use **json keys** *json_val* ?*key …*?
734728

729+
## BUILDING
730+
731+
The primary build system is `meson`. Use the `PKG_CONFIG_PATH`
732+
environment variable to point meson to Tcl if it is installed in a
733+
nonstandard location. The legacy autotools build system is also
734+
maintained.
735+
736+
Tcl 8.6 and Tcl 9.0 are both supported.
737+
738+
### From a Release Tarball
739+
740+
Download and extract [the
741+
release](https://github.com/RubyLane/rl_json/releases), then build:
742+
743+
``` sh
744+
# meson (recommended)
745+
meson setup builddir --buildtype=release
746+
meson test -C builddir
747+
meson install -C builddir
748+
749+
# autotools
750+
./configure
751+
make
752+
make test
753+
sudo make install
754+
```
755+
756+
### From the Git Sources
757+
758+
Fetch [the code](https://github.com/RubyLane/rl_json) and submodules
759+
recursively, then build:
760+
761+
``` sh
762+
git clone --recurse-submodules https://github.com/RubyLane/rl_json
763+
cd rl_json
764+
765+
# meson (recommended)
766+
meson setup builddir --buildtype=release
767+
meson test -C builddir
768+
meson install -C builddir
769+
770+
# autotools
771+
autoconf
772+
./configure
773+
make
774+
make test
775+
sudo make install
776+
```
777+
778+
### In a Docker Build
779+
780+
Build from a specified release version, minimising image size:
781+
782+
``` dockerfile
783+
WORKDIR /tmp/rl_json
784+
RUN wget https://github.com/RubyLane/rl_json/releases/download/v0.16/rl_json-v0.16.tar.gz -O - | tar xz --strip-components=1 && \
785+
meson setup builddir --buildtype=release && \
786+
meson install -C builddir && \
787+
strip /usr/local/lib/lib*rl_json*.so && \
788+
cd .. && rm -rf rl_json
789+
```
790+
791+
For any of the build methods you may need to set
792+
`PKG_CONFIG_PATH=/path/to/tcl/lib/pkgconfig` (meson) or pass
793+
`--with-tcl /path/to/tcl/lib` to `configure` (autotools) if your Tcl
794+
install is somewhere nonstandard.
795+
735796
## KEYWORDS
736797

737798
json, parsing, formatting

doc/json.md.in

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,71 @@ Version 0.10.0 deprecates various subcommands and features, which will be remove
734734
- `?size` - use **json length** *json_val* ?*key ...*?
735735
- `?keys` - use **json keys** *json_val* ?*key ...*?
736736

737+
## BUILDING
738+
739+
The primary build system is `meson`. Use the `PKG_CONFIG_PATH` environment
740+
variable to point meson to Tcl if it is installed in a nonstandard location.
741+
The legacy autotools build system is also maintained.
742+
743+
Tcl 8.6 and Tcl 9.0 are both supported.
744+
745+
### From a Release Tarball
746+
747+
Download and extract [the release](https://github.com/RubyLane/@PACKAGE_NAME@/releases), then build:
748+
749+
```sh
750+
# meson (recommended)
751+
meson setup builddir --buildtype=release
752+
meson test -C builddir
753+
meson install -C builddir
754+
755+
# autotools
756+
./configure
757+
make
758+
make test
759+
sudo make install
760+
```
761+
762+
### From the Git Sources
763+
764+
Fetch [the code](https://github.com/RubyLane/@PACKAGE_NAME@) and submodules
765+
recursively, then build:
766+
767+
```sh
768+
git clone --recurse-submodules https://github.com/RubyLane/@PACKAGE_NAME@
769+
cd @PACKAGE_NAME@
770+
771+
# meson (recommended)
772+
meson setup builddir --buildtype=release
773+
meson test -C builddir
774+
meson install -C builddir
775+
776+
# autotools
777+
autoconf
778+
./configure
779+
make
780+
make test
781+
sudo make install
782+
```
783+
784+
### In a Docker Build
785+
786+
Build from a specified release version, minimising image size:
787+
788+
```dockerfile
789+
WORKDIR /tmp/@PACKAGE_NAME@
790+
RUN wget https://github.com/RubyLane/@PACKAGE_NAME@/releases/download/v@PACKAGE_VERSION@/@PACKAGE_NAME@-v@PACKAGE_VERSION@.tar.gz -O - | tar xz --strip-components=1 && \
791+
meson setup builddir --buildtype=release && \
792+
meson install -C builddir && \
793+
strip /usr/local/lib/lib*@PACKAGE_NAME@*.so && \
794+
cd .. && rm -rf @PACKAGE_NAME@
795+
```
796+
797+
For any of the build methods you may need to set
798+
`PKG_CONFIG_PATH=/path/to/tcl/lib/pkgconfig` (meson) or pass
799+
`--with-tcl /path/to/tcl/lib` to `configure` (autotools) if your Tcl
800+
install is somewhere nonstandard.
801+
737802
## KEYWORDS
738803

739804
json, parsing, formatting

meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,6 @@ configure_file(
142142

143143
subdir('doc')
144144

145+
meson.add_dist_script('tools/dist_fixup.sh')
146+
145147
# vim: foldmethod=marker foldmarker=<<<,>>> shiftwidth=2 expandtab

tools/dist_fixup.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
# Called by meson.add_dist_script() during "meson dist".
3+
# MESON_DIST_ROOT — the dist staging directory
4+
# MESON_BUILD_ROOT — the build directory (has generated files)
5+
# MESON_SOURCE_ROOT — the source directory
6+
7+
set -e
8+
9+
dist="$MESON_DIST_ROOT"
10+
build="$MESON_BUILD_ROOT"
11+
12+
# Copy generated README.md from the build tree (built by pandoc)
13+
if [ -f "$build/doc/README.md" ]; then
14+
cp "$build/doc/README.md" "$dist/README.md"
15+
fi
16+
17+
# Bake generated manpage for users who don't have pandoc
18+
if [ -f "$build/doc/rl_json.n" ]; then
19+
cp "$build/doc/rl_json.n" "$dist/doc/json.n"
20+
fi
21+
22+
# Bake autotools configure script so users don't need autoconf
23+
if [ -f "$MESON_SOURCE_ROOT/configure" ]; then
24+
cp "$MESON_SOURCE_ROOT/configure" "$dist/configure"
25+
elif command -v autoconf >/dev/null 2>&1; then
26+
(cd "$dist" && autoconf)
27+
fi
28+
29+
# Remove .github — not useful in release tarballs
30+
rm -rf "$dist/.github"
31+
32+
# Remove JSONTestSuite submodule — 167 MB of test corpus not needed by users
33+
rm -rf "$dist/tests/JSONTestSuite"
34+
35+
# Replace symlinks with copies of their targets so the tarball works
36+
# on Windows (which doesn't support symlinks without special permissions)
37+
find "$dist" -type l | while read -r link; do
38+
target=$(readlink -f "$link")
39+
if [ -e "$target" ]; then
40+
rm "$link"
41+
if [ -d "$target" ]; then
42+
cp -a "$target" "$link"
43+
else
44+
cp "$target" "$link"
45+
fi
46+
fi
47+
done

0 commit comments

Comments
 (0)