Skip to content

Commit

Permalink
Bazel support (#12)
Browse files Browse the repository at this point in the history
* build rust

* go builds

* tests pass

* release runs too

* gazelle formatting

* add CI

* check in cargo.lock based on this https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html

* add linker opts

* does renaming help?

* builds

* upgrade to 0.14.1

* update release files
  • Loading branch information
daulet authored Nov 9, 2023
1 parent 457ba48 commit 5e367fe
Show file tree
Hide file tree
Showing 20 changed files with 6,659 additions and 33 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push: {}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Mount bazel cache
uses: actions/cache@v1
with:
path: "/home/runner/.cache/bazel"
key: bazel

- name: Install bazelisk
run: |
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.18.0/bazelisk-linux-amd64"
mkdir -p "${GITHUB_WORKSPACE}/bin/"
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
- name: Test
run: |
"${GITHUB_WORKSPACE}/bin/bazel" test //...
- name: Build
run: |
"${GITHUB_WORKSPACE}/bin/bazel" build //...
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
libtokenizers.a
/artifacts

# Rust
target

# Bazel
/bazel-*
58 changes: 58 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@crate_index//:defs.bzl", "aliases", "all_crate_deps")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@rules_rust//rust:defs.bzl", "rust_static_library")

# gazelle:prefix github.com/daulet/tokenizers
gazelle(
name = "gazelle",
)

gazelle(
name = "gazelle-update-repos",
args = [
"-from_file=go.mod",
"-to_macro=deps.bzl%go_dependencies",
"-prune",
],
command = "update-repos",
)

rust_static_library(
name = "tokenizers",
srcs = glob([
"src/**/*.rs",
]),
aliases = aliases(),
proc_macro_deps = all_crate_deps(
proc_macro = True,
),
visibility = ["//visibility:public"],
deps = all_crate_deps(),
)

go_test(
name = "tokenizers_test",
srcs = ["tokenizer_test.go"],
data = ["//test:data"],
embedsrcs = ["//test:embeddata"],
deps = [
":tokenizers_go",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
],
)

go_library(
name = "tokenizers_go",
srcs = [
"tokenizer.go",
"tokenizers.h",
],
cdeps = [
":tokenizers",
],
cgo = True,
importpath = "github.com/daulet/tokenizers",
visibility = ["//visibility:public"],
)
Loading

0 comments on commit 5e367fe

Please sign in to comment.