Skip to content

Commit e2eb8c4

Browse files
carlossanlopjkoritzinskyjkotas
authored
Instructions for adding a native external library dependency (#105045)
* Instructions for adding a native external library dependency. * Apply suggestions from code review Co-authored-by: Jeremy Koritzinsky <[email protected]> * Address suggestions * Link to vendored libraries doc * Update src/native/external/README.md Co-authored-by: Jan Kotas <[email protected]> --------- Co-authored-by: Jeremy Koritzinsky <[email protected]> Co-authored-by: Jan Kotas <[email protected]>
1 parent 09b99bf commit e2eb8c4

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

src/native/external/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Native external libraries
2+
3+
This folder contains the source code of vendored third party native libraries that are used as dependencies for dotnet/runtime.
4+
5+
Vendored libraries are copies of third-party dependencies that are included in the project repository. These copies are built alongside the rest of the repository. The document describing our approach for vendored libraries can be found here: https://github.com/dotnet/arcade/blob/main/Documentation/UnifiedBuild/VMR-Strategy-For-External-Source.md
6+
7+
### Folder structure
8+
9+
Each native library is roughly structured the following way:
10+
11+
```
12+
library-folder/
13+
library-source-code-files
14+
library.cmake
15+
library-version.txt
16+
cgmanifest.json
17+
```
18+
19+
- `library-folder/` is where the native source code lives.
20+
- `library.cmake` is the main cmake file we add to build this library from anywhere in this repo.
21+
- `library-version.txt` contains all the detailed release information for this library, as well as information about any local patches applied to the library.
22+
- `cgmanifest.json` is the official file that describes the source code provenance for each one of the external libraries we consume.
23+
24+
### How to add or update a vendored library
25+
26+
1. Consult with the .NET Security experts to make sure we meet all of Microsoft's Open Source guidance, especially regarding security updates and timeline expectations. This step can only be performed by the .NET team.
27+
28+
2. Download a copy of the source code from an official public release and extract it inside the library folder under `src/native/external/<library-name>`.
29+
30+
- If the source code comes from a public github repo, you would download it from an url like: `https://github.com/org/repo/releases`.
31+
- Make a note of the commit used to snap that release.
32+
- From the root folder of the repo, make a note of the license file.
33+
34+
3. Open the `cgmanifest.json` file. Add or modify the entry for this library to indicate the commit hash from which the copy of this release was obtained. The entry looks like this:
35+
36+
```json
37+
"Registrations": [
38+
{
39+
"Component": {
40+
"Type": "git",
41+
"Git": {
42+
"RepositoryUrl": "https://github.com/org/repo",
43+
"CommitHash": "<commit from which the source code was obtained>"
44+
}
45+
}
46+
}
47+
]
48+
```
49+
50+
4. Open the [THIRD-PARTY-NOTICES.txt](https://github.com/dotnet/runtime/blob/main/THIRD-PARTY-NOTICES.TXT) file in the root folder of the runtime repo. Add or update the copy of the license of this library, making sure the license copy has a header like this:
51+
52+
```
53+
License notice for <library name>
54+
-----------------------
55+
56+
<link to GitHub commit from which the license was obtained>
57+
58+
```
59+
60+
4. Add or edit the `<library>-version.txt` file under `src/native/external`. This file should contain:
61+
- The release version of the downloaded release
62+
- The hash commit of the downloaded release
63+
- The URL to the tag of the downloaded release in the format `https://github.com/org/repo/releases/tag/<version_number>`
64+
- An optional section describing any additional information like:
65+
- Manual modifications we need to make after copying the source code. For example, deleting unnecessary files or trimming unnecessary code.
66+
- Important notes about the release, like security fixes.
67+
68+
5. Make any cmake changes to properly consume the source code, if needed. The information about these changes should be included in `<library>-version.txt` file. The same changes should be proposed for the library upstream so that they are not necessary during the next library update.
69+
70+
6. Submit a PR tagging the area owners as well as the @dotnet/runtime-infrastructure team.
71+
72+
7. Find ways to get notified about new releases for the external dependency. For example, if the source code comes from a GitHub repo, you can subscribe to new releases:
73+
- Go to the main org/repo page
74+
- Click on Watch
75+
- Click on Custom
76+
- Select the "Releases" and "Security alerts" checkboxes
77+
- Click on "Apply"
78+
79+
8. Validate that CG detects the dependency correctly. This step can only be performed by the .NET team.

0 commit comments

Comments
 (0)