Skip to content

Commit

Permalink
chore: build deps using Bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
ADD-SP committed Mar 2, 2024
1 parent ff4be1e commit 75aa7c4
Show file tree
Hide file tree
Showing 15 changed files with 196 additions and 419 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Enable Bzlmod for every Bazel command
common --enable_bzlmod
common --verbose_failures
common --registry=https://bcr.bazel.build
common --registry=https://raw.githubusercontent.com/ADD-SP/ngx_waf_deps/main

build --compilation_mode=dbg
build --copt="-g3"
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ jobs:
- name: Configure ${{ matrix.install-type }}
run: |
make parser
bazel build --config release //:dependencies --verbose_failures
bazel build --config release //:deps --verbose_failures
pushd bazel-bin
tar -zxf ngx_waf_deps.tar.gz
export LIB_INJECTION=$(realpath ngx_waf_deps)/libinjection
export LIB_SODIUM=$(realpath ngx_waf_deps)/libsodium
export LIB_UTHASH=$(realpath ngx_waf_deps)/uthash
tar -zxf deps.tar.gz
export LIB_INJECTION=$(realpath deps/libinjection)
export LIB_SODIUM=$(realpath deps/libsodium)
export LIB_UTHASH=$(realpath deps/uthash)
popd
cd nginx-src
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
docker:
runs-on: ubuntu-latest
if: ${{ false && github.event_name != 'schedule' }}
if: false
strategy:
matrix:
version: ['stable', 'mainline']
Expand Down
60 changes: 40 additions & 20 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,33 +1,53 @@

genrule(
name = "dependencies",
name = "deps",
srcs = [
"@libinjection",
"@libinjection//:src/libinjection.h",
"@libinjection//:src/libinjection_sqli.h",
"@libinjection//:src/libinjection_sqli_data.h",
"@libinjection//:src/libinjection_xss.h",
"@libinjection//:src/libinjection_html5.h",
"@uthash//:include/utarray.h",
"@uthash//:include/uthash.h",
"@uthash//:include/utlist.h",
"@uthash//:include/utringbuffer.h",
"@uthash//:include/utstack.h",
"@uthash//:include/utstring.h",
"@libsodium",
"@uthash",
],
outs = [
"ngx_waf_deps.tar.gz"
"deps.tar.gz"
],
cmd = """
mkdir -p ngx_waf_deps/libinjection/include
mkdir -p ngx_waf_deps/libinjection/lib
mkdir -p ngx_waf_deps/libsodium/include
mkdir -p ngx_waf_deps/libsodium/lib
mkdir -p ngx_waf_deps/uthash/include
mkdir -p deps/libinjection/include
mkdir -p deps/libinjection/lib
mkdir -p deps/libsodium/include
mkdir -p deps/libsodium/lib
mkdir -p deps/uthash/include
libinjection_dir=$$(dirname $$(echo '$(locations @libinjection)' | awk '{print $$1}'))
cp -L -r $$libinjection_dir/include/* ngx_waf_deps/libinjection/include
cp -L -r $$libinjection_dir/lib/* ngx_waf_deps/libinjection/lib
for f in $(locations @libinjection); do
cp -Lr $$f deps/libinjection/lib
done
libsodium_dir=$$(dirname $$(echo '$(locations @libsodium)' | awk '{print $$1}'))
cp -L -r $$libsodium_dir/include/* ngx_waf_deps/libsodium/include
cp -L -r $$libsodium_dir/lib/* ngx_waf_deps/libsodium/lib
cp -Lr $(location @libinjection//:src/libinjection.h) deps/libinjection/include
cp -Lr $(location @libinjection//:src/libinjection_sqli.h) deps/libinjection/include
cp -Lr $(location @libinjection//:src/libinjection_sqli_data.h) deps/libinjection/include
cp -Lr $(location @libinjection//:src/libinjection_xss.h) deps/libinjection/include
cp -Lr $(location @libinjection//:src/libinjection_html5.h) deps/libinjection/include
uthash_dir=$$(dirname $$(dirname $$(echo '$(locations @uthash)' | awk '{print $$1}')))
cp -L -r $$uthash_dir/include/* ngx_waf_deps/uthash/include
cp -Lr $(location @uthash//:include/utarray.h) deps/uthash/include
cp -Lr $(location @uthash//:include/uthash.h) deps/uthash/include
cp -Lr $(location @uthash//:include/utlist.h) deps/uthash/include
cp -Lr $(location @uthash//:include/utringbuffer.h) deps/uthash/include
cp -Lr $(location @uthash//:include/utstack.h) deps/uthash/include
cp -Lr $(location @uthash//:include/utstring.h) deps/uthash/include
libsodium_base=$$(dirname $$(echo '$(locations @libsodium)' | awk '{print $$1}'))
cp -Lr $$libsodium_base/include/* deps/libsodium/include
cp -Lr $$libsodium_base/lib/* deps/libsodium/lib
tar -zcvf $(RULEDIR)/ngx_waf_deps.tar.gz ngx_waf_deps
rm -rf ngx_waf_deps
rm -f $(RULEDIR)/deps.tar.gz
tar -zcvf $(RULEDIR)/deps.tar.gz deps
rm -rf deps
""",
)
)
27 changes: 3 additions & 24 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,6 @@ module(
)

bazel_dep(name = "rules_foreign_cc", version = "0.10.1")

use_repo(
use_extension(
"//bazel/libinjection:extensions.bzl",
"libinjection",
),
"libinjection",
)

use_repo(
use_extension(
"//bazel/libsodium:extensions.bzl",
"libsodium",
),
"libsodium",
)

use_repo(
use_extension(
"//bazel/uthash:extensions.bzl",
"uthash",
),
"uthash",
)
bazel_dep(name = "uthash", version = "2.3.0")
bazel_dep(name = "libinjection", version = "3.10.0")
bazel_dep(name = "libsodium", version = "1.0.19")
Loading

0 comments on commit 75aa7c4

Please sign in to comment.