-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: example of Nginx buildsystem integration
- Loading branch information
1 parent
4e6520f
commit f7dc512
Showing
8 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
ngx_addon_name=ngx_rust_examples | ||
ngx_cargo_profile=ngx-module | ||
|
||
if [ $HTTP = YES ]; then | ||
ngx_module_type=HTTP | ||
|
||
if :; then | ||
ngx_module_name=ngx_http_async_module | ||
ngx_module_lib=async | ||
|
||
ngx_module_lib=$NGX_OBJS/$ngx_addon_name/$ngx_cargo_profile/examples/lib$ngx_module_lib.a | ||
ngx_module_deps=$ngx_module_lib | ||
ngx_module_libs="$ngx_module_lib -lm" | ||
|
||
# Module deps are usually added to the object file targets, but we don't have any | ||
LINK_DEPS="$LINK_DEPS $ngx_module_lib" | ||
|
||
. auto/module | ||
fi | ||
|
||
if :; then | ||
ngx_module_name=ngx_http_awssigv4_module | ||
ngx_module_lib=awssig | ||
|
||
ngx_module_lib=$NGX_OBJS/$ngx_addon_name/$ngx_cargo_profile/examples/lib$ngx_module_lib.a | ||
ngx_module_deps=$ngx_module_lib | ||
ngx_module_libs=$ngx_module_lib | ||
|
||
# Module deps are usually added to the object file targets, but we don't have any | ||
LINK_DEPS="$LINK_DEPS $ngx_module_lib" | ||
|
||
. auto/module | ||
fi | ||
|
||
if :; then | ||
ngx_module_name=ngx_http_curl_module | ||
ngx_module_lib=curl | ||
|
||
ngx_module_lib=$NGX_OBJS/$ngx_addon_name/$ngx_cargo_profile/examples/lib$ngx_module_lib.a | ||
ngx_module_deps=$ngx_module_lib | ||
ngx_module_libs=$ngx_module_lib | ||
|
||
# Module deps are usually added to the object file targets, but we don't have any | ||
LINK_DEPS="$LINK_DEPS $ngx_module_lib" | ||
|
||
. auto/module | ||
fi | ||
|
||
case "$NGX_PLATFORM" in | ||
Linux:*) | ||
ngx_module_name=ngx_http_orig_dst_module | ||
ngx_module_lib=httporigdst | ||
|
||
ngx_module_lib=$NGX_OBJS/$ngx_addon_name/$ngx_cargo_profile/examples/lib$ngx_module_lib.a | ||
ngx_module_deps=$ngx_module_lib | ||
ngx_module_libs=$ngx_module_lib | ||
|
||
# Module deps are usually added to the object file targets, but we don't have any | ||
LINK_DEPS="$LINK_DEPS $ngx_module_lib" | ||
|
||
. auto/module | ||
;; | ||
esac | ||
|
||
if :; then | ||
ngx_module_name=ngx_http_upstream_custom_module | ||
ngx_module_lib=upstream | ||
|
||
ngx_module_lib=$NGX_OBJS/$ngx_addon_name/$ngx_cargo_profile/examples/lib$ngx_module_lib.a | ||
ngx_module_deps=$ngx_module_lib | ||
ngx_module_libs=$ngx_module_lib | ||
|
||
# Module deps are usually added to the object file targets, but we don't have any | ||
LINK_DEPS="$LINK_DEPS $ngx_module_lib" | ||
|
||
. auto/module | ||
fi | ||
fi | ||
|
||
# Write a cargo config with the $ngx_cargo_profile definition (optional) | ||
|
||
if [ "$NGX_DEBUG" = YES ]; then | ||
NGX_CARGO_PROFILE_BASE=dev | ||
else | ||
NGX_CARGO_PROFILE_BASE=release | ||
fi | ||
|
||
mkdir -p "$NGX_OBJS/.cargo" | ||
cat > "$NGX_OBJS/.cargo/config.toml" << END | ||
|
||
[profile.$ngx_cargo_profile] | ||
inherits = "$NGX_CARGO_PROFILE_BASE" | ||
|
||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
ngx_addon_name=ngx_rust_examples | ||
ngx_cargo_profile=ngx-module | ||
ngx_cargo_manifest=$(realpath $ngx_addon_dir/Cargo.toml) | ||
ngx_cargo_features= | ||
ngx_rust_examples="async awssig curl upstream" | ||
|
||
case "$NGX_PLATFORM" in | ||
Linux:*) | ||
ngx_cargo_features="$ngx_cargo_features linux" | ||
ngx_rust_examples="$ngx_rust_examples httporigdst" | ||
;; | ||
esac | ||
|
||
for ngx_rust_example in $ngx_rust_examples | ||
do | ||
|
||
cat << END >> $NGX_MAKEFILE | ||
|
||
# Always call cargo instead of tracking the source modifications | ||
.PHONY: $NGX_OBJS/$ngx_addon_name/$ngx_cargo_profile/examples/lib$ngx_rust_example.a | ||
|
||
$NGX_OBJS/$ngx_addon_name/$ngx_cargo_profile/examples/lib$ngx_rust_example.a: | ||
cd $NGX_OBJS && \\ | ||
NGX_OBJS="\$\$PWD" cargo rustc \\ | ||
--crate-type staticlib \\ | ||
--example "$ngx_rust_example" \\ | ||
--no-default-features \\ | ||
--features "$ngx_cargo_features" \\ | ||
--profile $ngx_cargo_profile \\ | ||
--target-dir $ngx_addon_name \\ | ||
--manifest-path $ngx_cargo_manifest | ||
|
||
END | ||
|
||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters