Skip to content

Commit

Permalink
Feature/bazel modules update (#3)
Browse files Browse the repository at this point in the history
- copts now handled by select to enable C++20
- Cleaner CI
  • Loading branch information
0-Sacha authored Jun 1, 2024
1 parent f67fbae commit 762f593
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 67 deletions.
8 changes: 0 additions & 8 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ common --show_timestamps
common --verbose_failures
test --test_output=errors

# Opts
common:linux --config=default_compiler_opts
common:msvc --config=microsoft_compiler_opts

common:default_compiler_opts --copt -std=c++20
common:microsoft_compiler_opts --copt /std:c++20

# BuildBuddy
common:linux --workspace_status_command=$(pwd)/.buildbuddy/workspace_status.sh
common:windows --workspace_status_command=.buildbuddy/workspace_status.bat
Expand All @@ -23,7 +16,6 @@ common:buildbuddy --bes_backend=grpcs://sacha.buildbuddy.io
common:buildbuddy --remote_cache=grpcs://sacha.buildbuddy.io
common:buildbuddy --remote_executor=grpcs://sacha.buildbuddy.io
common:buildbuddy --experimental_remote_cache_compression
common:buildbuddy --jobs=50
common:buildbuddy --nolegacy_important_outputs
common:buildbuddy --platforms=@buildbuddy_test//:buildbuddy_linux_x86_64
common:buildbuddy --extra_execution_platforms=@buildbuddy_test//:buildbuddy_linux_x86_64
Expand Down
8 changes: 4 additions & 4 deletions .buildkite/linux_amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ agents:
steps:
- label: ":bazel: Build and Test on gcc"
commands:
- CC=gcc bazelisk build --config=default_compiler_opts //:LittleECSTests
- CC=gcc bazelisk test --config=default_compiler_opts //:LittleECSTests
- CC=gcc bazelisk build //:LittleECSTests
- CC=gcc bazelisk test //:LittleECSTests

- label: ":bazel: Build and Test on Clang"
commands:
- CC=clang bazelisk build --config=default_compiler_opts //:LittleECSTests
- CC=clang bazelisk test --config=default_compiler_opts //:LittleECSTests
- CC=clang bazelisk build //:LittleECSTests
- CC=clang bazelisk test //:LittleECSTests
4 changes: 2 additions & 2 deletions .buildkite/windows_amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ agents:
steps:
- label: ":bazel: Build"
commands:
- bazelisk build --config=microsoft_compiler_opts //:LittleECSTests
- bazelisk test --config=microsoft_compiler_opts //:LittleECSTests
- bazelisk build //:LittleECSTests
- bazelisk test //:LittleECSTests
12 changes: 6 additions & 6 deletions .github/workflows/LittleECS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
path: "~/.cache/bazel"
key: bazel
- name: Building...
run: bazelisk build --config=microsoft_compiler_opts //:LittleECSTests
run: bazelisk build //:LittleECSTests
- name: Testing...
run: bazelisk test --config=microsoft_compiler_opts //:LittleECSTests
run: bazelisk test //:LittleECSTests

ubuntu-latest-gcc:
runs-on: ubuntu-latest
Expand All @@ -37,9 +37,9 @@ jobs:
- name: Version
run: gcc --version
- name: Building...
run: CC=gcc bazelisk build --config=default_compiler_opts //:LittleECSTests
run: CC=gcc bazelisk build //:LittleECSTests
- name: Testing...
run: CC=gcc bazelisk test --config=default_compiler_opts //:LittleECSTests
run: CC=gcc bazelisk test //:LittleECSTests

ubuntu-latest-clang:
runs-on: ubuntu-latest
Expand All @@ -59,6 +59,6 @@ jobs:
- name: Version
run: clang --version
- name: Building...
run: CC=clang++-17 bazelisk build --config=default_compiler_opts //:LittleECSTests
run: CC=clang++-17 bazelisk build //:LittleECSTests
- name: Testing...
run: CC=clang++-17 bazelisk test --config=default_compiler_opts //:LittleECSTests
run: CC=clang++-17 bazelisk test //:LittleECSTests
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

# bazel
# Bazel
MODULE.bazel.lock
bazel-bin
bazel-out
Expand All @@ -16,11 +15,12 @@ bazel-testlogs
*.vcxproj.filters
*.vcxproj.user

# Make
# VSCode
.vscode

# Premake
Makefile
*.make

# bin
bin
bin-int

Expand Down
16 changes: 14 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ cc_library(
srcs = glob([ "src/**/*.h" ]),
hdrs = glob([ "src/**/*.h" ]),
includes = [ "src/" ],
copts = select({
"@rules_cc//cc/compiler:msvc-cl": ["/std:c++20"],
"//conditions:default": ["-std=c++20"],
}),
strip_include_prefix = "src",
include_prefix = "LittleECS",
linkstatic = True,
Expand All @@ -15,18 +19,26 @@ cc_library(

cc_test(
name = "LittleECSTests",
includes = [ "src/" ],
srcs = glob([ "Tests/**/*.h", "Tests/**/*.cpp" ], exclude=["Tests/Perf/**"]),
includes = [ "src/" ],
defines = [ "LECS_USE_PROJECTCORE" ],
copts = select({
"@rules_cc//cc/compiler:msvc-cl": ["/std:c++20"],
"//conditions:default": ["-std=c++20"],
}),
deps = [ "@ProjectCore//:ProjectCore", ":LittleECS" ],
visibility = ["//visibility:public"],
)

cc_test(
name = "LittleECSTestsPerf",
includes = [ "src/" ],
srcs = glob([ "Tests/**/*.h", "Tests/**/*.cpp" ]),
includes = [ "src/" ],
defines = [ "LECS_USE_PROJECTCORE" ],
copts = select({
"@rules_cc//cc/compiler:msvc-cl": ["/std:c++20"],
"//conditions:default": ["-std=c++20"],
}),
deps = [ "@ProjectCore//:ProjectCore", ":LittleECS" ],
visibility = ["//visibility:public"],
)
7 changes: 1 addition & 6 deletions Docs/Workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
This doc is tigtelly related to the [Workflow example](../Examples/Workflow/main.cpp)

To launch it, you can set your working directory to Examples/ and run:
- On Windows, using msvc:
```
bazelisk run --config=msvc //Workflow:Workflow
```
- On Linux: (This `--config=linux` is not mandatory)
```
bazelisk run --config=linux //Workflow:Workflow
bazelisk run //Workflow:Workflow
```

7 changes: 0 additions & 7 deletions Examples/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@ common --incompatible_strict_action_env
common --show_timestamps
common --verbose_failures
test --test_output=errors

# Opts
common:linux --config=default_compiler_opts
common:msvc --config=microsoft_compiler_opts

common:default_compiler_opts --copt -std=c++20
common:microsoft_compiler_opts --copt /std:c++20
22 changes: 6 additions & 16 deletions Examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@

##### Build and Run examples one by one (Recommended)
Example with `//Workflow:Workflow` (see below for the list of example)
- On Windows, using msvc:
```
bazelisk run --config=msvc //Workflow:Workflow
```
- On Linux: (This `--config=linux` is not mandatory)
```
bazelisk run --config=linux //Workflow:Workflow
```
```
bazelisk run //Workflow:Workflow
```

##### Compile all examples, then run binaries
To compile every example:
- On Windows, using msvc:
```
bazelisk build --config=msvc //...
```
- On Linux: (This `--config=linux` is not mandatory)
```
bazelisk build --config=linux //...
```
```
bazelisk build //...
```

Then you can run a program with (example with `//Workflow:Workflow`, see below for the list of example)
```
Expand Down
4 changes: 4 additions & 0 deletions Examples/Workflow/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ cc_binary(
name = "Workflow",
srcs = glob([ "*.h", "*.cpp" ]),
defines = [ "LECS_USE_PROJECTCORE" ],
copts = select({
"@rules_cc//cc/compiler:msvc-cl": ["/std:c++20"],
"//conditions:default": ["-std=c++20"],
}),
deps = [ "@ProjectCore//:ProjectCore", "@littleecs//:LittleECS" ],
visibility = ["//visibility:public"],
)
5 changes: 3 additions & 2 deletions Examples/Workflow/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ int main()
registry.Add<Name>(alice, "Alice");
registry.Add<Name>(bob, "Bob");


/****** Get Components ******/
std::cout << std::endl;
Logger.Info("Alice's int: {}", registry.Get<int>(alice));
Expand All @@ -53,8 +54,8 @@ int main()
std::cout << std::endl;
/**
* To ForEach on a specific Component, use ForEachUniqueComponent.
* It takes an lambda which can contains optionally an `LECS::EntityId` as first parameter, in that case the entityId will be send to the lambda
* The component you want to loop over is take as an template argument, and the lambda can take the component as:
* It takes an lambda which can contains optionally an `LECS::EntityId` as first parameter, in that case the entityId will be sent to the lambda
* The component you want to loop over is took as an template argument, and the lambda can take the component as:
* - value <int>
* - const value <const int>
* - const reference <const int&>
Expand Down
3 changes: 2 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "ht
http_archive(
name = "ProjectCore",
urls = [ "https://github.com/0-Sacha/ProjectCore/archive/refs/heads/dev.zip" ],
strip_prefix = "ProjectCore-dev"
strip_prefix = "ProjectCore-dev",
integrity = "sha256-28v/wuBCDSekQV03i9/2Tn+AR9hllqPdCOMYOvHBwmI=",
)
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,4 @@ It can be used using [Bazel](https://bazel.build/).
A `cc_library` rule has been created: `@LittleECS//:LittleECS`.
You need to add the module `littleecs` to your dependencies.

You will need at least to give an c++ standard to use (at least c++20) since no one have been forced. You can check the [bazelrc](.bazelrc) to see how you can add one.

Not Recommended: There is also a [Premake](https://premake.github.io/docs/using-premake) configuration, thought it is deprecated (and run on a wrapper of mine: [PremakeUtilities](https://github.com/0-Sacha/PremakeUtilities)). I keep it for my Game Engine [Blackbird](https://github.com/0-Sacha/Blackbird) which is using `Premake` as Build system.
12 changes: 6 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_utilities",
strip_prefix = "bazel_utilities-d748d078d0bdd4e5fe9020e8011a46edb484525e",
urls = [ "https://github.com/0-Sacha/bazel_utilities/archive/d748d078d0bdd4e5fe9020e8011a46edb484525e.zip" ],
integrity = "sha256-qakyhHoLPrGK/3zD+dWIL7wGSjLwMX69TiSGA05Wu2c=",
strip_prefix = "bazel_utilities-efe15a48c3b063436d6deecaa14b811083035993",
urls = [ "https://github.com/0-Sacha/bazel_utilities/archive/efe15a48c3b063436d6deecaa14b811083035993.zip" ],
integrity = "sha256-g1BUGaQFSLywkzTqixQdQTdrJ25TlcqG6PZXoCK7Jrw=",
)

http_archive(
name = "bazel_buildbuddy",
strip_prefix = "bazel_buildbuddy-89937f1942a9271348c0963ef89fb67c240c3afd",
urls = [ "https://github.com/0-Sacha/bazel_buildbuddy/archive/89937f1942a9271348c0963ef89fb67c240c3afd.zip" ],
integrity = "sha256-M8sEkfNBjSivQhIRYRzCXIq7ix3w23UckP0z9T/L3II=",
strip_prefix = "bazel_buildbuddy-b0840cf378c4aef5750b5e8bc87aa2ad1aeb874f",
urls = [ "https://github.com/0-Sacha/bazel_buildbuddy/archive/b0840cf378c4aef5750b5e8bc87aa2ad1aeb874f.zip" ],
integrity = "sha256-Wvbu4LB7F3d42Xj/dQyaGjVEntf4U3DO+aku3zEZD4I=",
)

load("@bazel_buildbuddy//:rules.bzl", "buildbuddy_toolchain")
Expand Down

0 comments on commit 762f593

Please sign in to comment.