-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Bazel support Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build custom branch Signed-off-by: Uilian Ries <uilianries@gmail.com> * Fix C++ flag Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add export file Signed-off-by: Uilian Ries <uilianries@gmail.com> * Fix bazel execution in CI Signed-off-by: Uilian Ries <uilianries@gmail.com> * print dir Signed-off-by: Uilian Ries <uilianries@gmail.com> * Revert "print dir" This reverts commit 511b828. * Fix cache path Signed-off-by: Uilian Ries <uilianries@gmail.com> * inject export Signed-off-by: Uilian Ries <uilianries@gmail.com> * inject export Signed-off-by: Uilian Ries <uilianries@gmail.com> * Do not inject definitions Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update export.h Signed-off-by: Uilian Ries <uilianries@gmail.com> * Split bazel build Signed-off-by: Uilian Ries <uilianries@gmail.com> * Remove define from bazel Signed-off-by: Uilian Ries <uilianries@gmail.com> * Remove export.h Signed-off-by: Uilian Ries <uilianries@gmail.com> * Generate export.h by bazel Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update contribution guide Signed-off-by: Uilian Ries <uilianries@gmail.com> --------- Signed-off-by: Uilian Ries <uilianries@gmail.com> Co-authored-by: Michał Cieślar <michalovskyyy@gmail.com>
- Loading branch information
1 parent
213ce21
commit 6102421
Showing
9 changed files
with
173 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: bazel | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
paths-ignore: | ||
- 'docs/**' | ||
- '**/*.md' | ||
- 'LICENSE' | ||
workflow_dispatch: | ||
pull_request: | ||
paths-ignore: | ||
- 'docs/**' | ||
- '**/*.md' | ||
- 'LICENSE' | ||
|
||
jobs: | ||
bazel: | ||
name: ci-ubuntu-24.04-gcc-bazel | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install ccache | ||
uses: hendrikmuhs/ccache-action@v1.2 | ||
|
||
- name: Cache Bazel | ||
id: cache-bazel | ||
uses: actions/cache@v4.0.2 | ||
env: | ||
cache-name: cache-bazel-data | ||
with: | ||
path: /home/runner/.cache/bazel/_bazel_runner | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('MODULE.bazel') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Build faker-cxx library | ||
run: bazel build //:faker-cxx | ||
|
||
- name: Build faker-cxx examples and run | ||
run: | | ||
bazel build //examples:faker-cxx-basic-example | ||
bazel build //examples:faker-cxx-person-example | ||
bazel-bin/examples/faker-cxx-person-example | ||
bazel-bin/examples/faker-cxx-basic-example | ||
- name: Build faker-cxx tests and validate | ||
run: | | ||
bazel build //tests:faker-cxx-ut | ||
bazel-bin/tests/faker-cxx-ut |
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 |
---|---|---|
|
@@ -63,3 +63,7 @@ build-linux-clang | |
#kdevelop temp files | ||
*.kdev4 | ||
.kdev4 | ||
|
||
bazel-* | ||
MODULE.bazel.lock | ||
install/ |
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,28 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_library") | ||
|
||
genrule( | ||
name = "generate_export_header", | ||
srcs = [], | ||
outs = ["include/faker-cxx/Export.h"], | ||
cmd = """ | ||
echo "#pragma once" > $@ | ||
echo "#define FAKER_CXX_EXPORT" >> $@ | ||
""", | ||
) | ||
|
||
cc_library( | ||
name = "faker-cxx", | ||
srcs = glob(["src/**/*.cpp"]), | ||
hdrs = glob(["src/**/*.h", "include/**/*.h"]) + [":generate_export_header"], | ||
includes = ["include", "src"], | ||
visibility = ["//visibility:public"], | ||
deps = ["@fmt//:fmt"], | ||
copts = select({ | ||
"//conditions:default": [ | ||
"-std=c++20" | ||
], | ||
"@platforms//os:windows": [ | ||
"/std:c++20", | ||
], | ||
}), | ||
) |
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,4 @@ | ||
|
||
bazel_dep(name = "rules_foreign_cc", version = "0.10.1") | ||
bazel_dep(name = "fmt", version = "10.2.1") | ||
bazel_dep(name = "googletest", version = "1.14.0") |
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 @@ | ||
workspace(name = "faker-cxx") |
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,29 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_binary") | ||
|
||
cc_binary( | ||
name = "faker-cxx-basic-example", | ||
srcs = ["basic/main.cpp",], | ||
deps = ["//:faker-cxx",], | ||
copts = select({ | ||
"//conditions:default": [ | ||
"-std=c++20" | ||
], | ||
"@platforms//os:windows": [ | ||
"/std:c++20", | ||
], | ||
}), | ||
) | ||
|
||
cc_binary( | ||
name = "faker-cxx-person-example", | ||
srcs = ["person/main.cpp",], | ||
deps = ["//:faker-cxx",], | ||
copts = select({ | ||
"//conditions:default": [ | ||
"-std=c++20" | ||
], | ||
"@platforms//os:windows": [ | ||
"/std:c++20", | ||
], | ||
}), | ||
) |
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,16 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_binary") | ||
|
||
cc_test( | ||
name = "faker-cxx-ut", | ||
srcs = glob(["**/*.cpp"]), | ||
deps = ["//:faker-cxx", "@googletest//:gtest_main"], | ||
includes = ["../src/common", "../src/modules"], | ||
copts = select({ | ||
"//conditions:default": [ | ||
"-std=c++20" | ||
], | ||
"@platforms//os:windows": [ | ||
"/std:c++20", | ||
], | ||
}), | ||
) |