Skip to content

Commit 8327004

Browse files
committed
Install abseil and downgrade bazel to 7.1.2
Had to downgrade Bazel to 7.1.2 because it was crashing when building abseil. See issue: hedronvision/bazel-compile-commands-extractor#199
1 parent c27582b commit 8327004

8 files changed

+1960
-104
lines changed

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
7.2.1
1+
7.1.2
22
# important to prevent errors from version updates
33
# such as: https://github.com/hedronvision/bazel-compile-commands-extractor/issues/199

BUILD.bazel

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ load("@rules_cc//cc:defs.bzl", "cc_binary")
33
cc_binary(
44
name = "hello_main",
55
srcs = ["hello_main.cc"],
6-
deps = [":hello_world"]
6+
deps = [
7+
":hello_world",
8+
"@abseil-cpp//absl/flags:parse"
9+
]
710
)
811

912
cc_library(

MODULE.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module(
99
)
1010

1111
bazel_dep(name = "googletest", version = "1.15.2")
12+
bazel_dep(name = "abseil-cpp", version = "20240722.0")
1213

1314
# Hedron's Compile Commands Extractor for Bazel
1415
# https://github.com/hedronvision/bazel-compile-commands-extractor

MODULE.bazel.lock

+1,943-96
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hello_main.cc

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
#include "absl/flags/flag.h"
2+
#include "absl/flags/parse.h"
13
#include "hello_world.h"
24
#include <iostream>
35

4-
int main() {
5-
HelloWorld(std::cout);
6+
ABSL_FLAG(std::string, name, "World", "name to say hello to");
7+
8+
int main(int argc, char **argv) {
9+
absl::ParseCommandLine(argc, argv);
10+
HelloWorld(absl::GetFlag(FLAGS_name), std::cout);
611
return 0;
712
}

hello_world.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <ostream>
22

3-
void HelloWorld(std::ostream &ostream) {
4-
ostream << "Hello World!" << std::endl;
3+
void HelloWorld(const std::string &name, std::ostream &ostream) {
4+
ostream << "Hello " << name << "!" << std::endl;
55
}

hello_world.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
#include <ostream>
55

6-
void HelloWorld(std::ostream &ostream);
6+
void HelloWorld(const std::string &name, std::ostream &ostream);
77

88
#endif // !HELLO_WORLD_H

hello_world_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
TEST(HelloWorld, PrintsHelloWorld) {
66
std::ostringstream output_stream;
77

8-
HelloWorld(output_stream);
8+
HelloWorld("World", output_stream);
99

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

0 commit comments

Comments
 (0)