-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat: modify cache & NGINX dir #72
Conversation
Let's add this to the
|
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.
This is a solid PR! Thank you.
Could you please add the new .cache directory to the .gitignore file?
Also, please reply to the comment about using the cargo triple instead of the os-arch pattern. I do not have a strong opinion, so I would love to know what you think.
Once again, thank you for the contribution.
README.md
Outdated
@@ -38,9 +38,15 @@ cargo build --package=examples --examples --features=linux --release | |||
After compilation, the modules can be found in the path `target/release/examples/` ( with the `.so` file extension for | |||
Linux or `.dylib` for MacOS). | |||
|
|||
Additionally, the folder `.cache/nginx/{NGX_VERSION}/{OS}/` will contain the compiled version of NGINX used to build | |||
Additionally, the folder `.cache/nginx/{NGX_VERSION}/{OS}-{Arch}/` will contain the compiled version of NGINX used to build |
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.
If we are going to encode architecture here, we may want to consider over to using the full cargo triple string because os and architecture are not enough information to tell you if you can actually run the binary on a system. For example, a library may be build for musl
, and will not work on other glibc variants.
It looks like <arch><sub>-<vendor>-<sys>-<abi>
.
What do you think of doing that instead?
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.
Cargo triple strings contain enough information to replace {OS}-{Arch}
since we currently only support linux and macos (if not, there are more variants listed here and here), so I agree to use the triple.
What I suspect is whether the triple is enough. Does Nginx binary vary depending on Linux distributions? For example, do we have to distinguish two same version Nginxs, one of which is compiled on Debian and the other is on CentOS?
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.
Does Nginx binary vary depending on Linux distributions
It does only for the version created by the distros for their packaging systems. Many of those contain patches. Those binaries are considered "unsupported" / "unsupportable" from the perspective of NGINX. However, that doesn't really matter for ngx-rust, because we are building the binaries from scratch without any such patches, so I believe we do not need to encode any distro specific information. In short, we don't need to care about this for ngx-rust.
Let's change the PR to support the triple string, and I'll click the merge button.
Thank you for your rapid review.
We don't have to add this, because
|
Oh, that's my oversight. Thank you for clarifying. |
I changed the src dir name in the same manner to the Nginx dir: |
README.md
Outdated
@@ -38,9 +38,15 @@ cargo build --package=examples --examples --features=linux --release | |||
After compilation, the modules can be found in the path `target/release/examples/` ( with the `.so` file extension for | |||
Linux or `.dylib` for MacOS). | |||
|
|||
Additionally, the folder `.cache/nginx/{NGX_VERSION}/{OS}/` will contain the compiled version of NGINX used to build | |||
Additionally, the folder `.cache/nginx/{NGX_VERSION}/{OS}-{Arch}/` will contain the compiled version of NGINX used to build |
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.
.cache/nginx/{NGX_VERSION}/{OS}-{Arch}/
One last thing, let's update the string in the readme to reflect the triple format.
README.md
Outdated
|
||
* `CACHE_DIR` (default `[nginx-sys's root directory]/.cache`) - the directory containing cache files, means PGP keys, tarballs, PGP signatures, and unpacked source codes. It also contains compiled NGINX in default configuration. | ||
* `NGINX_INSTALL_ROOT_DIR` (default `{CACHE_DIR}/nginx`) - the directory containing the series of compiled NGINX in its subdirectories | ||
* `NGINX_INSTALL_DIR` (default `{NGINX_INSTALL_BASE_DIR}/{NGX_VERSION}/{OS}-{Arch}`) - the directory containing the NGINX compiled in the build |
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.
Same here.
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.
Looks great. Let's get the readme updated and I will merge.
Once again, thank you for the stellar contribution!
Updated |
Proposed changes
This PR add some environment variable options useful to develop modules using the SDK.
CACHE_DIR
Default:
[nginx-sys's root]/.cache
Specify cache directory. With relative -> absolute path converting option provided in
.cargo/config.toml
like below, we are able to generate a project-owned cache dir:This option makes it easier to save and restore the cache, which speeds up CI/CD.
Sidenote
Originally the default location of the cache dir is in the parent dir of the manifest dir (= root dir) of
nginx-sys
: this is equivalent to set the default ofCACHE_DIR
as[nginx-sys's root]/../.cache
. This setting resulted the cache dir to be generated in the root dir ofngx-rust
as long asngx-rust
is treated as the main project (this is likely the originally intended behavior).However, once
nginx-sys
is whether directly or indirectly used as a dependency of other projects, the repository was copied in$CARGO_HOME/registry/cache/index.crates.io-***/nginx-sys-***/
or$CARGO_HOME/git/checkouts/ngx-rust-***/***/
, causing the cache dir to be generated in the same depth with the copies of crates. This was apparently undesirable.So the default value of
CACHE_DIR
is changed to[nginx-sys's root]/.cache
to prevent the "pollution" described above. Instead,ngx-rust
also useCACHE_DIR
to move the cache dir to the original location.NGINX_INSTALL_ROOT_DIR
Default:
{CACHE_DIR}/nginx
Specify the directory where the NGINX compiled in the series of build will be installed. By default, each of Nginx is installed in the sub-subdirectory labeled by the version, OS and Architecture. This option is useful at developing stage to try multiple versions with your own conf files (for the latter aim only,
NGINX_INSTALL_DIR
is more suited).NGINX_INSTALL_DIR
Default:
{NGINX_INSTALL_ROOT_DIR}/{NGX_VERSION}/{OS}-{Arch}
Specify the directory where the NGINX compiled in this build will be installed. This option is mainly intended to facilitate the test automation in CI/CD.
Checklist
Before creating a PR, run through this checklist and mark each as complete.