Skip to content

Commit 103d5de

Browse files
committed
README: document adding new dependencies
Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
1 parent 565e8b6 commit 103d5de

File tree

1 file changed

+65
-1
lines changed

1 file changed

+65
-1
lines changed

README.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The macOS SDK must be installed.
2727

2828
./bintool bdist
2929

30-
## Substitute Sources
30+
## Substitute sources
3131

3232
To override the source tree used to build a project, create a top-level
3333
directory named `override` and place the substitute source tree in a
@@ -70,3 +70,67 @@ Report the version number that will be used in archive file names.
7070
#### `projects`
7171

7272
Report the IDs and display names of all component projects.
73+
74+
## Adding a new dependency
75+
76+
openslide-bin produces binaries which do not link with shared libraries from
77+
the build environment, except for specific platform libraries on each
78+
supported OS. To add a library dependency to openslide-bin, you must
79+
configure openslide-bin to build that library itself.
80+
81+
All dependencies must be built with [Meson][], even those that don't natively
82+
support Meson. For many common libraries, a Meson port is available from
83+
Meson's [wrapdb][]. Otherwise, you'll need to port the library's build
84+
system to Meson and submit the port to wrapdb (or to the upstream project if
85+
its maintainers are interested).
86+
87+
To add a dependency to openslide-bin:
88+
89+
1. Use `meson wrap install` to add the dependency's wrap file from wrapdb
90+
to the `subprojects` directory.
91+
2. Add the dependency to `_PROJECTS` in `common/software.py`.
92+
- Test the `update_url` and `update_regex` by running `./bintool updates`.
93+
A successful run will not produce an output line for the new dependency.
94+
3. Modify `deps/meson.build` to invoke the build, in the correct order
95+
relative to the other dependencies. Include any necessary build options,
96+
e.g. disable building command-line tools to reduce build time.
97+
98+
### Common problems
99+
100+
New dependencies sometimes have build bugs that need to be fixed in wrapdb
101+
or upstream. Common problems include:
102+
103+
1. Libraries dllexporting their public symbols when built as a Windows static
104+
library. `dllexport` should only be used when building a dynamic library.
105+
2. Libraries taking an unintended dependency on pthreads. Many libraries
106+
use Windows threading primitives on Windows but unconditionally depend on
107+
`dependency('threads')` in their `meson.build`, thus adding a dependency
108+
on the pthreads library. openslide-bin intentionally does not ship a
109+
pthreads implementation.
110+
111+
Either issue will cause the build or smoke test to fail. The subproject can
112+
be patched by adding a patch file to the `subprojects/packagefiles`
113+
directory and adding a `diff_files` directive to the subproject's wrap file.
114+
115+
### Submitting a PR
116+
117+
When adding a new dependency to OpenSlide, the corresponding openslide-bin PR
118+
should be be submitted early in the development process, since OpenSlide's CI
119+
will not pass on Windows until the dependency is available in openslide-bin.
120+
The `subproject()` call in `deps/meson.build` should initially be gated
121+
behind `if dev_deps`, causing the new subproject to be omitted from
122+
openslide-bin releases until the feature lands in an OpenSlide release.
123+
124+
All openslide-bin subprojects must use wraps from wrapdb, so new Meson ports
125+
should be submitted there first. (wrapdb does not expect ports to include
126+
all functionality from the upstream build system. For example, obscure
127+
options and CPU architectures can be omitted.) As an exception, wraps for
128+
newly-developed libraries can point directly to an upstream Git commit while
129+
the library is being integrated into OpenSlide. However, the wrap must be
130+
added to wrapdb before the first OpenSlide release that uses the library.
131+
132+
Similarly, all `diff_files` directives in wrap files must have a comment
133+
linking to a wrapdb PR or upstream PR for the patch.
134+
135+
[Meson]: https://mesonbuild.com/
136+
[wrapdb]: https://github.com/mesonbuild/wrapdb

0 commit comments

Comments
 (0)