Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# Enable platform-specific config
common --enable_platform_specific_config

# GCC/Clang warnings
build:unix --copt=-Wall --copt=-Wextra --copt=-Wpedantic --copt=-Werror
# MSVC warnings
build:msvc --copt=/W4 --copt=/WX

# Map configs to platforms/toolchains
build:macos --config=unix
build:linux --config=unix
build:windows --config=msvc
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.4.0
34 changes: 34 additions & 0 deletions .github/workflows/build-bazel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: build bazel

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- uses: bazel-contrib/setup-bazel@0.15.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
external-cache: true

- name: Checkout repository
uses: actions/checkout@v4

- name: Build (fastbuild)
run: bazel build //...

- name: Test (fastbuild)
run: bazel test //...
10 changes: 9 additions & 1 deletion .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ on:
pull_request:

jobs:
check-sqlite:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check SQLite versions
run: bash tools/check_sqlite_versions.sh

build:
needs: check-sqlite
strategy:
matrix:
build:
Expand Down Expand Up @@ -48,4 +57,3 @@ jobs:
- name: Run unit test
run: ctest --preset ${{ matrix.build.preset }}-release --parallel


2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ build*/

.DS_STORE
CMakeUserPresets.json

bazel-*
46 changes: 46 additions & 0 deletions BAZEL_SETUP_CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Bazel Setup Context for libsl3

## Project Status

Successfully added Bazel 8.4+ build system alongside existing CMake. All core functionality working.

## Current Status

- ✅ Library builds: `bazel build --config=release //:sl3`
- ✅ all tests pass
- ✅ Sample programs build successfully

## Key Commands

```bash
# Build library
bazel build ...
bazel build -c dbg ...
bazel build -c opt ...

bazel test ...
# apply configs as wanted

# Debug compile commands
bazel aquery --config=debug //tests/version:version_test --output=text
```

## Outstanding Issues

1. **Version test fails** - SQLite runtime vs compile-time version mismatch (3.43.2 vs 3.47.2)
2. **Need toolchain setup** - Add dedicated Xcode and GCC (brew) toolchains
3. **VS Code IntelliSense** - Add hedron_compile_commands for C++ language support

## Next Steps

Note that the order will defined, not as written here.

- Add hedron_compile_commands to MODULE.bazel for VS Code IntelliSense
- Add Xcode toolchain configuration
- Add GCC (brew) toolchain configuration
- Test builds with different toolchains

## Architecture

- Uses modern Bazel Bzlmod (MODULE.bazel) instead of deprecated WORKSPACE.bazel
- Parallel CMake/Bazel build support (no conflicts)
53 changes: 53 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//:config.bzl", "sl3_config")

package(default_visibility = ["//visibility:public"])

# Generate config header using cross-platform Starlark
sl3_config(
name = "generate_config",
output = "include/sl3/config.hpp",
template = "src/config.in",
version = module_version(),
)

cc_library(
name = "sl3",
srcs = [
"src/sl3/columns.cpp",
"src/sl3/command.cpp",
"src/sl3/config.cpp",
"src/sl3/database.cpp",
"src/sl3/dataset.cpp",
"src/sl3/dbvalue.cpp",
"src/sl3/dbvalues.cpp",
"src/sl3/error.cpp",
"src/sl3/rowcallback.cpp",
"src/sl3/types.cpp",
"src/sl3/value.cpp",
# Private headers
"src/sl3/connection.hpp",
"src/sl3/utils.hpp",
],
hdrs = [
"include/sl3.hpp",
"include/sl3/columns.hpp",
"include/sl3/command.hpp",
"include/sl3/container.hpp",
"include/sl3/database.hpp",
"include/sl3/dataset.hpp",
"include/sl3/dbvalue.hpp",
"include/sl3/dbvalues.hpp",
"include/sl3/error.hpp",
"include/sl3/rowcallback.hpp",
"include/sl3/types.hpp",
"include/sl3/value.hpp",
":generate_config",
],
includes = [
"include",
],
deps = [
"@sqlite//:sqlite3",
],
)
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ set(sl3_MINOR_VERSION 2)

# sqlite major is always 3, no need to use that here
# set(internal_SQLITE_MAJOR_V 3)
set(internal_SQLITE_MINOR_V 47)
set(internal_SQLITE_PATCH_V 2)
set(internal_SQLITE_MINOR_V 50)
set(internal_SQLITE_PATCH_V 4)

# sqlite uses (X*1000000 + Y*1000 + Z),
# but minor patch used since major is always 3
Expand Down
19 changes: 19 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""libsl3 - A C++ wrapper for SQLite3"""

# SQLite version configuration - single source of truth
SQLITE3_MINOR = 50
SQLITE3_PATCH = 4
SQLITE3_VERSION = "3.{}.{}".format(SQLITE3_MINOR, SQLITE3_PATCH)

module(
name = "libsl3",
version = "1.2.{}".format(SQLITE3_MINOR * 1000 + SQLITE3_PATCH),
)

# Core Bazel modules
bazel_dep(name = "rules_cc", version = "0.2.8")
bazel_dep(name = "platforms", version = "1.0.0")

# Library dependencies from the Bazel Central Registry
bazel_dep(name = "sqlite3", version = SQLITE3_VERSION, repo_name = "sqlite")
bazel_dep(name = "doctest", version = "2.4.12")
Loading
Loading