-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: split some policies by the implicated method #14211
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,36 @@ | ||||||
# Build and Package | ||||||
|
||||||
This document gathers all the relevant information regarding the general lines to follow while writing either the `build()` or the `package()` methods. | ||||||
Both methods often use build helpers to build binaries and install them into the `package_folder`. | ||||||
|
||||||
<!-- toc --> | ||||||
## Contents | ||||||
|
||||||
* [Build Method](#build-method) | ||||||
* [Package](#package)<!-- endToc --> | ||||||
|
||||||
## Build Method | ||||||
|
||||||
* `build()` method should focus on build only, not installation. During the build, nothing should be written in `package` folder. Installation step should only occur in `package()` method. | ||||||
|
||||||
* The build itself should only rely on local files. Nothing should be downloaded from the internet during this step. If external files are required, they should come from `requirements` or `build_requirements` in addition to source files downloaded in `source()` or coming from the recipe itself. | ||||||
|
||||||
* Except for CMake and a working build toolchain (compiler, linker, archiver, etc.), the recipe should not assume that any other build tool is installed on the user-build machine (like Meson, autotools, or pkg-config). On Windows, the recipe should not assume that a shell is available (like MSYS2). Therefore, if the build method requires additional tools, they should be added to `build_requirements()`. | ||||||
|
||||||
* It is forbidden to run other conan client commands during build. In other words, if upstream build files call conan under the hood (through `cmake-conan` for example or any other logic), this logic must be removed. | ||||||
|
||||||
* Settings from profile should be honored (`build_type`, `compiler.libcxx`, `compiler.cppstd`, `compiler.runtime` etc). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was intended to call out problematic settings not all of them 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure which are more problematic 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same, it deserves an example. for newcomers, it's kinda unclear, how to to it exactly. it would be nice if you illustrate with a small code block, e.g. for CMake. |
||||||
|
||||||
* These env vars from profile should be honored and properly propagated to underlying build system during the build: `CC`, `CXX`, `CFLAGS`, `CXXFLAGS`, `LDFLAGS`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it deserves an example. for newcomers, it's kinda unclear. can you illustrate how to honor these variables, e.g. for CMake? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes the docs are bad - I am not trying to fix them in this PR 😄 I got many more too come! |
||||||
|
||||||
## Package | ||||||
|
||||||
* CMake config files must be removed (they will be generated for consumers by `cmake_find_package`, `cmake_find_package_multi`, or `CMakeDeps` generators). Use `rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))` or `rm(self, "*.cmake", os.path.join(self.package_folder, "lib"))`. | ||||||
|
||||||
* pkg-config files must be removed (they will be generated for consumers by `pkg_config` or `PkgConfigDeps` generators). Use `rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))` or `rm(self, "*.pc", os.path.join(self.package_folder, "lib"))`. | ||||||
|
||||||
* On *nix systems, executables and shared libraries should have empty `RPATH`/`RUNPATH`/`LC_RPATH`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how do I achieve that? how do I ensure that? examples are needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we also need to put some links to the relevant documentation for:
maybe with some brief examples on how to inspect them (commands like |
||||||
|
||||||
* On macOS, install name in `LC_ID_DYLIB` section of shared libs must be `@rpath/<libfilename>`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how do I achieve that? how do I ensure that? examples are needed. |
||||||
|
||||||
* Installed files must not contain absolute paths specific to build machine. Relative paths to other packages is also forbidden since relative paths of dependencies during build may not be the same for consumers. Hardcoded relative paths pointing to a location in the package itself are allowed. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how do I check for that? how do I prevent/fix that? examples are needed. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Dependencies | ||
|
||
This section outlines all the practices and guidelines for the `requirements()` and `build_requirements()` methods. This includes everything from "vendored" dependencies to | ||
when and how the versions could be changed. | ||
|
||
<!-- toc --> | ||
## Contents | ||
|
||
* [Rules](#rules)<!-- endToc --> | ||
|
||
## Rules | ||
|
||
* [Version range](https://docs.conan.io/en/latest/versioning/version_ranges.html) is not allowed. | ||
* Specify explicit [RREV](https://docs.conan.io/en/latest/versioning/revisions.html) (recipe revision) of dependencies is not allowed. | ||
* Vendoring in library source code should be removed (best effort) to avoid potential ODR violations. If upstream takes care to rename | ||
symbols, it may be acceptable. | ||
* Only ConanCenter recipes are allowed in `requires`/`requirements()` and `build_requires`/`build_requirements()`. | ||
* If a requirement is conditional, this condition must not depend on [build context](https://docs.conan.io/en/1.35/devtools/build_requires.html#build-and-host-contexts). Build requirements don't have this constraint. | ||
* Forcing options of dependencies inside a recipe should be avoided, except if it is mandatory for the library - in which case it must | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. example would be nice |
||
be enforced through the `validate()` methods. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,33 @@ | ||||||
# Sources and Patches | ||||||
|
||||||
This documents contains everything related to the `source()`. This includes picking sources, where they should come from and goes into when and how to modify sources. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
in another section, we already stated sources are immutable |
||||||
These are a very important aspects and it helps us to establish the quality of the packages offered by ConanCenter. | ||||||
|
||||||
<!-- toc --> | ||||||
## Contents | ||||||
|
||||||
* [Sources](#sources)<!-- endToc --> | ||||||
|
||||||
## Sources | ||||||
|
||||||
**Origin of sources:** | ||||||
|
||||||
* Library sources should come from an official origin like the library source code repository or the official | ||||||
release/download webpage. | ||||||
|
||||||
* If an official source archive is available, it should be preferred over an auto-generated archive. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we should explain it a little bit more, on how to distinguish these two. |
||||||
|
||||||
**Source immutability:** Downloaded source code stored under `source` folder should not be modified. Any patch or `replace_in_file` statement should be applied to the copy of this source code when a build is executed (basically in `build()` method). | ||||||
|
||||||
**Building from sources:** Recipes should always build packages from library sources. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have some known exceptions to this rule (MSYS2, Android NDK, etc.) |
||||||
|
||||||
**Sources not accessible:** | ||||||
|
||||||
* Library sources that are not publicly available will not be allowed in this repository even if the license allows their redistribution. | ||||||
|
||||||
* If library sources cannot be downloaded from their official origin or cannot be consumed directly due to their | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we had some special cases for that, e.g. for |
||||||
format, the recommendation is to contact the publisher and ask them to provide the sources in a way/format that can be consumed | ||||||
programmatically. | ||||||
|
||||||
* In case of needing those binaries to use them as a "build require" for some library, we will consider following the approach of adding it | ||||||
as a system recipe (`<build_require>/system`) and making those binaries available in the CI machines (if the license allows it). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do I check for that?