2022-05-26 09:02:32 -07:00
|
|
|
# Upstream utils
|
|
|
|
|
|
|
|
|
|
## Layout
|
|
|
|
|
|
|
|
|
|
Each thirdparty library has a Python script for updating it. They generally:
|
|
|
|
|
|
|
|
|
|
1. Check out a thirdparty Git repository to a specific commit or tag
|
|
|
|
|
2. Apply patch files to the thirdparty repo to fix things specific to our build
|
|
|
|
|
3. Copy a subset of the thirdparty files into our repo
|
|
|
|
|
4. Comment out any header includes that were invalidated, if needed
|
|
|
|
|
|
|
|
|
|
`upstream_utils.py` contains utilities common to these update scripts.
|
|
|
|
|
|
2023-05-16 09:41:46 -07:00
|
|
|
Patches are generated in the thirdparty repo with git's format-patch command so
|
|
|
|
|
they can be applied as individual commits and easily rebased onto newer
|
|
|
|
|
versions. Each library has its own patch directory (e.g., `lib_patches`).
|
2022-05-26 09:02:32 -07:00
|
|
|
|
|
|
|
|
## Updating thirdparty library version
|
|
|
|
|
|
|
|
|
|
The example below will update a hypothetical library called `lib` to the tag
|
|
|
|
|
`2.0`.
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
Start in the `upstream_utils` folder. Make sure a clone of the upstream repo exists.
|
2022-05-26 09:02:32 -07:00
|
|
|
```bash
|
2024-07-16 17:20:07 -07:00
|
|
|
./<lib>.py clone
|
2022-05-26 09:02:32 -07:00
|
|
|
```
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
Rebase the clone of the upstream repo.
|
2022-05-26 09:02:32 -07:00
|
|
|
```bash
|
2024-07-16 17:20:07 -07:00
|
|
|
./<lib>.py rebase 2.0
|
2022-05-26 09:02:32 -07:00
|
|
|
```
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
Update the `upstream_utils` patch files and the tag in the script.
|
2022-05-26 09:02:32 -07:00
|
|
|
```bash
|
2024-07-16 17:20:07 -07:00
|
|
|
./<lib>.py format-patch
|
2022-05-26 09:02:32 -07:00
|
|
|
```
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
Copy the updated upstream files into the thirdparty files within allwpilib.
|
2022-05-26 09:02:32 -07:00
|
|
|
```bash
|
2024-07-16 17:20:07 -07:00
|
|
|
./<lib>.py copy-upstream-to-thirdparty
|
2023-08-24 15:00:07 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Adding patch to thirdparty library
|
|
|
|
|
|
|
|
|
|
The example below will add a new patch file to a hypothetical library called
|
|
|
|
|
`lib` (Replace `<lib>` with `llvm`, `fmt`, `eigen`, ... in the following steps).
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
Start in the `upstream_utils` folder. Make sure a clone of the upstream repo exists.
|
|
|
|
|
```bash
|
|
|
|
|
./<lib>.py clone
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Update the clone of the upstream repo.
|
2023-08-24 15:00:07 -07:00
|
|
|
```bash
|
2024-07-16 17:20:07 -07:00
|
|
|
./<lib>.py reset
|
2023-08-24 15:00:07 -07:00
|
|
|
```
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
Navigate to the repo. If you can't find it, the directory of the clone is printed at the start of the `clone` command.
|
2023-08-24 15:00:07 -07:00
|
|
|
```bash
|
|
|
|
|
cd /tmp/<lib>
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Make a commit with the desired changes.
|
|
|
|
|
```bash
|
|
|
|
|
git add ...
|
|
|
|
|
git commit -m "..."
|
|
|
|
|
```
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
Navigate back to `upstream_utils`.
|
2023-08-24 15:00:07 -07:00
|
|
|
```bash
|
2024-07-16 17:20:07 -07:00
|
|
|
cd allwpilib/upstream_utils
|
2023-08-24 15:00:07 -07:00
|
|
|
```
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
Update the `upstream_utils` patch files.
|
2023-08-24 15:00:07 -07:00
|
|
|
```bash
|
2024-07-16 17:20:07 -07:00
|
|
|
./<lib>.py format-patch
|
2023-08-24 15:00:07 -07:00
|
|
|
```
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
Update the list of patch files in `<lib>.py`, then rerun `<lib>.py` to reimport the thirdparty files.
|
2023-08-24 15:00:07 -07:00
|
|
|
```bash
|
2024-07-16 17:20:07 -07:00
|
|
|
./<lib>.py copy-upstream-to-thirdparty
|
2022-05-26 09:02:32 -07:00
|
|
|
```
|