Skip to content

Commit

Permalink
Merge branch 'main' into yagiz/add-url-pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire authored Dec 26, 2024
2 parents 2730b70 + 3a302b5 commit ae17a77
Show file tree
Hide file tree
Showing 11 changed files with 381 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build
cmake-build-debug-coverage
cmake-build-debug
cmake-build-release
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build --cxxopt="-std=c++20"
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.0.0
54 changes: 54 additions & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Bazel

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- '**.md'
- 'docs/**'
push:
branches:
- main
paths-ignore:
- '**.md'
- 'docs/**'

permissions:
contents: read
actions: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: bazel-contrib/setup-bazel@bbf8fe8b219f642c7f8bc673215f28eb1d9dec51 # v0.10.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Build & Test
run: bazel test //...
ubuntu:
strategy:
fail-fast: false
matrix:
shared: [ON, OFF]
cxx: [g++-12, clang++-14]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: bazel-contrib/setup-bazel@bbf8fe8b219f642c7f8bc673215f28eb1d9dec51 # v0.10.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Build & Test
run: bazel test //...
env:
CC: ${{matrix.cxx}}
CXX: ${{matrix.cxx}}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ benchmarks/competitors/servo-url/target

#ignore VScode
.vscode/
.idea
.idea

# bazel output
bazel-*
20 changes: 20 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cc_library(
name = "ada",
srcs = [
"src/ada.cpp",
],
hdrs = glob([
"include/*.h",
"include/ada/*.h",
# todo: this can be included by every client of the library, but there is no better way
# since .cpp files are included into each other.
"src/*.cpp",
]),
# todo: once .cpp files are not included, rather then polluting -I flags, src/ should
# be dropped from hdrs and this replaced by `strip_include_prefix = "include"`
includes = [
"include",
"include/ada",
],
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel_dep(name = "googletest", version = "1.15.2")
280 changes: 280 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,13 @@ You can install Ada using `brew install ada-url`.
Ada uses cmake as a build system. It's recommended you to run the following commands to build it locally.
Without tests:
- **Build**: `cmake -B build && cmake --build build`
With tests (requires git):
- **Build**: `cmake -B build -DADA_TESTING=ON && cmake --build build`
- **Test**: `ctest --output-on-failure --test-dir build`
Windows users need additional flags to specify the build configuration, e.g. `--config Release`.
Expand Down
3 changes: 1 addition & 2 deletions include/ada/checkers-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ namespace ada::checkers {
constexpr bool has_hex_prefix_unsafe(std::string_view input) {
// This is actually efficient code, see has_hex_prefix for the assembly.
constexpr bool is_little_endian = std::endian::native == std::endian::little;
constexpr auto word0x =
std::bit_cast<uint16_t>(static_cast<uint16_t>(0x7830));
constexpr uint16_t word0x = 0x7830;
uint16_t two_first_bytes =
static_cast<uint16_t>(input[0]) |
static_cast<uint16_t>((static_cast<uint16_t>(input[1]) << 8));
Expand Down
9 changes: 9 additions & 0 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cc_test(
name = "url_search_params",
srcs = ["url_search_params.cpp"],
deps = [
"//:ada",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)

0 comments on commit ae17a77

Please sign in to comment.