Skip to content

Commit

Permalink
Install abseil and downgrade bazel to 7.1.2
Browse files Browse the repository at this point in the history
Had to downgrade Bazel to 7.1.2 because it was crashing when building
abseil.
See issue: hedronvision/bazel-compile-commands-extractor#199
  • Loading branch information
andrenbrandao committed Aug 3, 2024
1 parent c27582b commit 8327004
Show file tree
Hide file tree
Showing 8 changed files with 1,960 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
7.2.1
7.1.2
# important to prevent errors from version updates
# such as: https://github.com/hedronvision/bazel-compile-commands-extractor/issues/199
5 changes: 4 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ load("@rules_cc//cc:defs.bzl", "cc_binary")
cc_binary(
name = "hello_main",
srcs = ["hello_main.cc"],
deps = [":hello_world"]
deps = [
":hello_world",
"@abseil-cpp//absl/flags:parse"
]
)

cc_library(
Expand Down
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module(
)

bazel_dep(name = "googletest", version = "1.15.2")
bazel_dep(name = "abseil-cpp", version = "20240722.0")

# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
Expand Down
2,039 changes: 1,943 additions & 96 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions hello_main.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "hello_world.h"
#include <iostream>

int main() {
HelloWorld(std::cout);
ABSL_FLAG(std::string, name, "World", "name to say hello to");

int main(int argc, char **argv) {
absl::ParseCommandLine(argc, argv);
HelloWorld(absl::GetFlag(FLAGS_name), std::cout);
return 0;
}
4 changes: 2 additions & 2 deletions hello_world.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <ostream>

void HelloWorld(std::ostream &ostream) {
ostream << "Hello World!" << std::endl;
void HelloWorld(const std::string &name, std::ostream &ostream) {
ostream << "Hello " << name << "!" << std::endl;
}
2 changes: 1 addition & 1 deletion hello_world.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

#include <ostream>

void HelloWorld(std::ostream &ostream);
void HelloWorld(const std::string &name, std::ostream &ostream);

#endif // !HELLO_WORLD_H
2 changes: 1 addition & 1 deletion hello_world_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
TEST(HelloWorld, PrintsHelloWorld) {
std::ostringstream output_stream;

HelloWorld(output_stream);
HelloWorld("World", output_stream);

EXPECT_EQ(output_stream.str(), "Hello World!\n");
}

0 comments on commit 8327004

Please sign in to comment.