Skip to content

Commit d523c34

Browse files
cyanogilvieclaude
andcommitted
Add meson build support and GitHub release workflow
Add meson build alongside existing autotools, with teabase submodule providing shared infrastructure. Includes GitHub Actions workflow that builds, tests, cross-compiles for Windows (MinGW), and creates releases with source and binary artifacts. Templatize docs (parse_args.md.in), simplify pkgIndex.tcl.in to use single @PKG_LIB_FILE@ compatible with both build systems, and fix -Wunused-parameter for -Werror builds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0407dff commit d523c34

File tree

14 files changed

+211
-23
lines changed

14 files changed

+211
-23
lines changed

.github/workflows/release.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
13+
- name: Install dependencies
14+
run: |
15+
sudo apt-get update
16+
sudo apt-get install -y ninja-build pandoc mingw-w64 wine64 zip
17+
pip3 install --user meson
18+
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
23+
- name: Build and test (native, meson fallback)
24+
run: |
25+
meson setup build
26+
meson compile -C build
27+
meson test -C build --print-errorlogs
28+
29+
- name: Cross-compile for Windows
30+
run: |
31+
cat > /tmp/cross-mingw64.ini <<'EOF'
32+
[binaries]
33+
c = 'x86_64-w64-mingw32-gcc'
34+
cpp = 'x86_64-w64-mingw32-g++'
35+
ar = 'x86_64-w64-mingw32-ar'
36+
strip = 'x86_64-w64-mingw32-strip'
37+
windres = 'x86_64-w64-mingw32-windres'
38+
exe_wrapper = 'wine'
39+
pkg-config = 'pkg-config'
40+
41+
[built-in options]
42+
default_library = 'shared'
43+
44+
[properties]
45+
sys_root = '/usr/x86_64-w64-mingw32'
46+
pkg_config_libdir = '/nonexistent'
47+
48+
[host_machine]
49+
system = 'windows'
50+
cpu_family = 'x86_64'
51+
cpu = 'x86_64'
52+
endian = 'little'
53+
EOF
54+
meson setup buildwin --cross-file /tmp/cross-mingw64.ini --buildtype=release -Ddebug=true
55+
meson compile -C buildwin
56+
57+
- name: Test Windows build under wine
58+
run: meson test -C buildwin --print-errorlogs
59+
60+
- name: Extract version
61+
id: version
62+
run: |
63+
ver=$(meson introspect build --projectinfo | python3 -c 'import sys,json; print(json.load(sys.stdin)["version"])')
64+
echo "version=${ver}" >> "$GITHUB_OUTPUT"
65+
echo "project=parse_args-${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
66+
67+
- name: Create source tarball
68+
run: |
69+
project="${{ steps.version.outputs.project }}"
70+
# Generate README.md from docs
71+
meson compile -C build readme
72+
cp build/doc/README.md README.md
73+
# Copy workspace dereferencing symlinks, then strip build artifacts
74+
cp -aL . "/tmp/${project}"
75+
find "/tmp/${project}" -name '.git' -exec rm -rf {} +
76+
rm -rf "/tmp/${project}/.github"
77+
rm -rf "/tmp/${project}/build" "/tmp/${project}/buildwin"
78+
rm -rf "/tmp/${project}/subprojects/packagecache"
79+
rm -rf "/tmp/${project}/subprojects/tcl"
80+
rm -rf "/tmp/${project}/subprojects/libtommath-"*
81+
rm -rf "/tmp/${project}/subprojects/.wraplock"
82+
tar czf "/tmp/${project}.tar.gz" -C /tmp "${project}"
83+
cd /tmp && zip -rq "${project}-source.zip" "${project}"
84+
85+
- name: Package Windows binaries
86+
run: |
87+
pkg_dir="parse_args-${{ steps.version.outputs.version }}"
88+
mkdir -p "/tmp/win/${pkg_dir}"
89+
cp buildwin/teabase/libparse_args.dll "/tmp/win/${pkg_dir}/"
90+
cp buildwin/teabase/pkgIndex.tcl "/tmp/win/${pkg_dir}/"
91+
cp buildwin/doc/parse_args.html "/tmp/win/${pkg_dir}/parse_args.html"
92+
cd /tmp/win
93+
zip -r "/tmp/${{ steps.version.outputs.project }}-windows-x86_64.zip" "${pkg_dir}"
94+
95+
- name: Upload artifacts
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: release-artifacts
99+
path: |
100+
/tmp/${{ steps.version.outputs.project }}.tar.gz
101+
/tmp/${{ steps.version.outputs.project }}-source.zip
102+
/tmp/${{ steps.version.outputs.project }}-windows-x86_64.zip
103+
104+
- name: Create GitHub Release
105+
uses: softprops/action-gh-release@v1
106+
with:
107+
draft: false
108+
prerelease: false
109+
generate_release_notes: true
110+
files: |
111+
/tmp/${{ steps.version.outputs.project }}.tar.gz
112+
/tmp/${{ steps.version.outputs.project }}-source.zip
113+
/tmp/${{ steps.version.outputs.project }}-windows-x86_64.zip

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ tags
1717
*~
1818
*.gcda
1919
*.gcno
20+
/build
21+
/buildwin
22+
/subprojects/.wraplock
23+
/subprojects/packagecache
24+
/subprojects/tcl
25+
/subprojects/libtommath-*
26+
/doc/parse_args.md

README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
---
2-
author:
3-
- Cyan Ogilvie
4-
date: 0.5
5-
title: parse_args(3) 0.5 \| Advanced argument parsing for Tcl
6-
---
7-
81
# NAME
92

103
parse_args - Core-style argument parsing for scripts
114

125
# SYNOPSIS
136

14-
**package require parse_args** ?0.5?
7+
**package require parse_args** ?0.6?
158

169
**parse_args::parse_args** *args* *argspec* ?*varname*?
1710

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dnl to configure the system for the local environment.
1919
# so that we create the export library with the dll.
2020
#-----------------------------------------------------------------------
2121

22-
AC_INIT([parse_args], [0.5.2])
22+
AC_INIT([parse_args], [0.6])
2323

2424
#--------------------------------------------------------------------
2525
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
@@ -181,7 +181,7 @@ TEA_MAKE_LIB
181181
TEA_PROG_TCLSH
182182
#TEA_PROG_WISH
183183

184-
AC_CONFIG_FILES([Makefile pkgIndex.tcl])
184+
AC_CONFIG_FILES([Makefile pkgIndex.tcl doc/parse_args.md])
185185
#AC_CONFIG_FILES([sampleConfig.sh])
186186
AC_CONFIG_HEADERS([config.h])
187187

doc/meson.build

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
pandoc = find_program('pandoc', native: true, required: false)
2+
3+
if pandoc.found()
4+
doc_md = configure_file(
5+
input: 'parse_args.md.in',
6+
output: '@BASENAME@',
7+
configuration: teaconf,
8+
)
9+
10+
doc_targets = []
11+
12+
doc_targets += custom_target('htmldoc',
13+
input: doc_md,
14+
output: 'parse_args.html',
15+
command: [pandoc, '--standalone', '--metadata', 'title=parse_args',
16+
'--from', 'markdown', '--to', 'html',
17+
'@INPUT@', '--output', '@OUTPUT@'],
18+
install: true,
19+
install_dir: get_option('datadir') / 'doc',
20+
build_by_default: true,
21+
)
22+
doc_targets += custom_target('manpage',
23+
input: doc_md,
24+
output: 'parse_args.n',
25+
command: [pandoc, '--standalone', '--from', 'markdown', '--to', 'man',
26+
'@INPUT@', '--output', '@OUTPUT@'],
27+
install: true,
28+
install_dir: get_option('mandir'),
29+
build_by_default: true,
30+
)
31+
32+
doc_targets += custom_target('readme',
33+
input: doc_md,
34+
output: 'README.md',
35+
command: [pandoc, '--from', 'markdown', '--to', 'gfm',
36+
'@INPUT@', '--output', '@OUTPUT@'],
37+
install_dir: meson.project_source_root(),
38+
install_tag: 'source',
39+
build_by_default: false,
40+
)
41+
42+
alias_target('doc', doc_targets)
43+
endif
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
% parse_args(3) 0.5 | Advanced argument parsing for Tcl
1+
% parse_args(3) @PACKAGE_VERSION@ | Advanced argument parsing for Tcl
22
% Cyan Ogilvie
3-
% 0.5
3+
% @PACKAGE_VERSION@
44

55

66
# NAME
@@ -10,7 +10,7 @@ parse\_args - Core-style argument parsing for scripts
1010

1111
# SYNOPSIS
1212

13-
**package require parse_args** ?0.5?
13+
**package require parse_args** ?@PACKAGE_VERSION@?
1414

1515
**parse_args::parse_args** *args* *argspec* ?*varname*?
1616

generic/parse_args.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,8 @@ static void free_interp_cx(ClientData cdata, Tcl_Interp* interp) //{{{
10871087
struct interp_cx* l = (struct interp_cx*)cdata;
10881088
int i;
10891089

1090+
(void)interp;
1091+
10901092
if (l) {
10911093
for (i=0; i<L_end; i++)
10921094
replace_tclobj(&l->obj[i], NULL);

meson.build

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
project('parse_args', 'c',
2+
version: '0.6',
3+
default_options: ['c_std=c11', 'warning_level=3', 'werror=true'],
4+
meson_version: '>=1.3.0',
5+
)
6+
7+
cc = meson.get_compiler('c')
8+
fs = import('fs')
9+
add_project_arguments('-D_DEFAULT_SOURCE', language: 'c')
10+
11+
if get_option('debug')
12+
add_project_arguments(cc.get_supported_arguments(['-ggdb3']), language: 'c')
13+
endif
14+
15+
add_project_arguments('-Wno-missing-field-initializers', language: 'c')
16+
17+
conf = configuration_data()
18+
19+
tea_want_shims = ['tip445']
20+
21+
add_project_arguments('-DHAVE_CONFIG_H', language: 'c')
22+
23+
deps = []
24+
inc = [include_directories('generic')]
25+
26+
pkg_sources = files(
27+
'generic/parse_args.c',
28+
)
29+
30+
subdir('teabase')
31+
subdir('doc')

pkgIndex.tcl.in

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
# -*- tcl -*-
2-
# Tcl package index file, version 1.1
31
#
4-
if {[package vsatisfies [package provide Tcl] 9.0-]} {
5-
package ifneeded @PACKAGE_NAME@ @PACKAGE_VERSION@ \
6-
[list load [file join $dir @PKG_LIB_FILE9@] [string totitle @PACKAGE_NAME@]]
7-
} else {
8-
package ifneeded @PACKAGE_NAME@ @PACKAGE_VERSION@ \
9-
[list load [file join $dir @PKG_LIB_FILE8@] [string totitle @PACKAGE_NAME@]]
10-
}
2+
# Tcl package index file
3+
#
4+
package ifneeded @PACKAGE_NAME@ @PACKAGE_VERSION@ \
5+
[list load [file join $dir @PKG_LIB_FILE@] [string totitle @PACKAGE_NAME@]]

subprojects/libtommath.wrap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../teabase/subprojects/libtommath.wrap

0 commit comments

Comments
 (0)