Skip to content

Commit 41e176a

Browse files
SiegeLordExSiegeLord
authored andcommitted
Add documentatin and tooling to help maintain ABI compatibility.
1 parent 25c4b14 commit 41e176a

18 files changed

+50238
-14
lines changed

README_abi.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
ABI Compatibility Guidelines
2+
============================
3+
4+
# ABI description
5+
6+
Allegro is split into the core library (`liballegro`) and addons (e.g.
7+
`liballegro_image`). The public API starts with `al_` for functions and
8+
`ALLEGRO_` for types. The private API that is used by the addons starts with
9+
`_al` for functions and `_AL` for types. There are some exceptions where there
10+
are some `ALLEGRO_` types defined in `aintern_*.h` headers. Despite their names
11+
starting with `ALLEGRO_` those are private types.
12+
13+
Within a minor version (5.0, 5.2 etc) we maintain ABI backwards compatibility
14+
only for public API. This means that we can't remove functions (even if we turn
15+
them into compatibility functions), can't change their arguments. For types, we
16+
can't change their size. If the type is not opaque, this means we can't add or
17+
remove fields, change their types. These considerations do not apply to private
18+
APIs: Allegro addons and Allegro core are intended to match in their precise
19+
version when used together. Therefore private APIs have no backwards compatibility.
20+
21+
Similarly, the unstable public API (marked as such in the documentation) also
22+
does not come with backwards guarantees.
23+
24+
# Tooling
25+
26+
To help maintain ABI compatibility we provide two scripts. To use them you must
27+
be on Linux and have built the non-monolith version of the library with debug
28+
symbols (e.g. RelWithDebInfo). First, we have `misc/generate_abi.sh`:
29+
30+
```bash
31+
./misc/generate_abi.sh $BUILD_DIR
32+
```
33+
34+
This is used to generate "golden" ABI XML files which are checked in and
35+
updated every release. Then, there's `misc/compare_abi.sh`:
36+
37+
```bash
38+
./misc/compare_abi.sh $BUILD_DIR
39+
```
40+
41+
This is run before making a release to check for ABI compatibility regressions.
42+
Check over the outputs of this script to make sure the ABI compatibility is
43+
maintained. This process is manual due to the somewhat complex ABI guarantees,
44+
but we'll strive to make this more automatic in the future.

README_releasing.txt

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ How to Make a Release
44
This guide explains how to make an Allegro release. This all assumes that we're
55
on Linux.
66

7-
1. Starting with the master branch, pick a commit which you want to be the base of
7+
1. First, build the library with the addons, and run the
8+
`./misc/compare_abi.sh` to check if ABI compatibility has been maintaned
9+
(see README_abi.txt). Fix any regressions and along the way make sure that
10+
the newly added public APIs are correctly classified as unstable and are
11+
documented.
12+
13+
2. Starting with the master branch, pick a commit which you want to be the base of
814
the release branch. Typically this will be HEAD, but if there are some
915
underbaked commits there, you may want to use an earlier commit. Call this
1016
branch with the new release name (e.g. 5.2.2 in this case):
@@ -17,51 +23,55 @@ on Linux.
1723

1824
git cherry-pick -x badf00d
1925

20-
2. On the master branch, bump the version to the next release in
26+
3. On the master branch, bump the version to the next release in
2127
`include/allegro5/base.h` by using the `misc/fixver.sh` script. Commit this
2228
change. For example:
2329

2430
misc/fixver.sh 5 2 3 GIT
2531

26-
3. Write a changelog file. This is located in docs/src/changes-5.2.txt.
32+
4. Write a changelog file. This is located in docs/src/changes-5.2.txt.
2733

2834
Typically you will want to look through the commits made since the last
2935
release, e.g. using `git log <last_release>..<this_release>` (e.g. `git log
3036
5.2.1..5.2.2`). Follow the format of the previous changelogs. Commit this
3137
change.
3238

33-
4. We are now done with the master branch. Check out the release branch now.
39+
5. Generate the new ABI files using `./misc/generate_abi.sh`. Commit the
40+
changes.
41+
42+
6. We are now done with the master branch. Check out the release branch now.
3443

35-
5. Cherry-pick the commit with the changelog onto this branch.
44+
7. Cherry-pick the commit with the changelog and the ABI changes onto this
45+
branch.
3646

37-
6. Remove the "GIT" suffix and increase the version by 1. This can be done via
47+
8. Remove the "GIT" suffix and increase the version by 1. This can be done via
3848
`misc/fixver.sh` script. Commit this change. For example:
3949

4050
misc/fixver.sh 5 2 2 0
4151

42-
7. Tag the previous commit with the same version number and the release number
52+
9. Tag the previous commit with the same version number and the release number
4353
(e.g. "5.2.2.0" if you're releasing 5.2.2. An example command would be:
4454

4555
git tag -a -m "Tag 5.2.2.0" 5.2.2.0
4656

47-
8. Create the source archives by running `misc/create_release_archives.sh` and
57+
10. Create the source archives by running `misc/create_release_archives.sh` and
4858
passing in the release version. This will create 3 source archives (.tar.gz,
4959
.7z and .zip) in the current directory. And example invocation would be:
5060

5161
misc/create_release_archives.sh 5.2.2.0
5262

53-
10. At this point you could do some additional checks (like making binaries).
63+
11. At this point you could do some additional checks (like making binaries).
5464

55-
11. If all checks are good, push the master and release branches to github
65+
12. If all checks are good, push the master and release branches to github
5666
(with the --tags option).
5767

58-
12. Upload the source archives to github. Go to the releases tab, and make a
68+
13. Upload the source archives to github. Go to the releases tab, and make a
5969
new release with the tag you just created.
6070

61-
13. Build the docs, including the pdf. Add these to the website via the
71+
14. Build the docs, including the pdf. Add these to the website via the
6272
liballeg.github.io repository.
6373

64-
14. Make an announcement on the website. This involves making a news item,
74+
15. Make an announcement on the website. This involves making a news item,
6575
changing the download area and copy-pasting the change list.
6676

67-
15. Make an announcement on Discord. You're done!
77+
16. Make an announcement on Discord. You're done!

misc/compare_abi.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
#set -e
3+
4+
build_dir="${1}"
5+
6+
if [[ -z "${build_dir}" ]]
7+
then
8+
echo "Usage: $0 <build-dir>"
9+
exit 1
10+
fi
11+
12+
if ! $(which abidw > /dev/null 2>&1)
13+
then
14+
echo "abidw not found"
15+
exit 1
16+
fi
17+
18+
library_paths=("${build_dir}"/lib/*.so)
19+
abidiff_args=(
20+
--suppressions misc/suppressions.abignore
21+
--leaf-changes-only
22+
)
23+
24+
for library_path in "${library_paths[@]}";
25+
do
26+
library_filename=$(basename "${library_path}")
27+
library="${library_filename%.*}"
28+
abi_path="misc/${library}_abi.xml"
29+
echo Comparing ${library}
30+
header=$(cat <<HEADER
31+
================================
32+
Comparing ${library}
33+
================================
34+
35+
HEADER
36+
)
37+
report=$(abidiff "${abidiff_args[@]}" "${abi_path}" "${library_path}")
38+
39+
printf "%s\n%s" "${header}" "${report}" | less
40+
done

misc/generate_abi.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
set -e
3+
4+
build_dir="${1}"
5+
6+
if [[ -z "${build_dir}" ]]
7+
then
8+
echo "Usage: $0 <build-dir>"
9+
exit 1
10+
fi
11+
12+
if ! $(which abidw > /dev/null 2>&1)
13+
then
14+
echo "abidw not found"
15+
exit 1
16+
fi
17+
18+
library_paths=("${build_dir}"/lib/*.so)
19+
abidw_args=(
20+
--suppressions misc/suppressions.abignore
21+
--exported-interfaces-only
22+
)
23+
24+
for library_path in "${library_paths[@]}";
25+
do
26+
library_filename=$(basename "${library_path}")
27+
library="${library_filename%.*}"
28+
out_path="misc/${library}_abi.xml"
29+
echo Generating $out_path
30+
abidw "${abidw_args[@]}" "${library_path}" --out-file "${out_path}"
31+
sed -i "s@$(pwd)/@@g" "${out_path}"
32+
done

0 commit comments

Comments
 (0)