summaryrefslogtreecommitdiff
path: root/docs/markdown
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2024-03-02 00:59:32 +0200
committerGitHub <noreply@github.com>2024-03-02 00:59:32 +0200
commit54996132af6d0feaef6afd943c94ff25911ca67b (patch)
tree7981fd0fedd247c91a40adf9e9a7716e1ffba892 /docs/markdown
parentcc4cfbcad92945a1629c80664e1eb755c68905dd (diff)
parent524a66116b38a65210b7516781d26ed6efb690b9 (diff)
downloadmeson-54996132af6d0feaef6afd943c94ff25911ca67b.tar.gz
Merge pull request #12804 from joukewitteveen/dist-rewriter
Support `meson dist` when getting project versions from VCS
Diffstat (limited to 'docs/markdown')
-rw-r--r--docs/markdown/Creating-releases.md27
-rw-r--r--docs/markdown/Reference-tables.md1
2 files changed, 28 insertions, 0 deletions
diff --git a/docs/markdown/Creating-releases.md b/docs/markdown/Creating-releases.md
index 638125c87..e0c80af5b 100644
--- a/docs/markdown/Creating-releases.md
+++ b/docs/markdown/Creating-releases.md
@@ -86,3 +86,30 @@ meson setup builddir
meson dist -C builddir
```
This produces `builddir/meson-dist/mysubproject-1.0.tar.xz` tarball.
+
+## Cement a version obtained from VCS
+
+*Since 1.4.0* the `meson dist` command enables rewriting the build
+configuration of the distribution tarball. This is needed when the
+configuration depends on metadata from revision control such as in the
+following example.
+
+`meson.build`:
+```meson
+project('tig', 'c',
+ version : run_command('version.sh', 'get-vcs').stdout.strip())
+
+meson.add_dist_script('version.sh', 'set-dist', meson.project_version())
+```
+`version.sh`:
+```sh
+#!/bin/sh
+
+if [ "$1" = "get-vcs" ]; then
+ git -C "$MESON_SOURCE_ROOT" describe --always --dirty
+elif [ "$1" = "set-dist" ]; then
+ $MESONREWRITE --sourcedir="$MESON_PROJECT_DIST_ROOT" kwargs set project / version "$2"
+else
+ exit 1
+fi
+```
diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md
index af6a9b9f0..02ac083e5 100644
--- a/docs/markdown/Reference-tables.md
+++ b/docs/markdown/Reference-tables.md
@@ -85,6 +85,7 @@ For languages that don't have separate dynamic linkers such as C# and Java, the
| Value | Comment |
| ----- | ------- |
| MESONINTROSPECT | Command to run to run the introspection command, may be of the form `python /path/to/meson introspect`, user is responsible for splitting the path if necessary. |
+| MESONREWRITE | Command to run to run the rewriting command, only set when running `dist` scripts |
| MESON_BUILD_ROOT | Absolute path to the build dir |
| MESON_DIST_ROOT | Points to the root of the staging directory, only set when running `dist` scripts |
| MESON_SOURCE_ROOT | Absolute path to the source dir |