Skip to content
Permalink
Browse files

Initial bazel stuff

  • Loading branch information
DarkDimius committed Oct 3, 2017
0 parents commit 9189734a6c061071c3d3cd4398a5d7874a8c0c49
Showing with 77 additions and 0 deletions.
  1. +7 −0 WORKSPACE
  2. +14 −0 gtest.Build
  3. +15 −0 main/BUILD
  4. +6 −0 main/hello-greet.cc
  5. +8 −0 main/hello-greet.h
  6. +12 −0 main/hello-world.cc
  7. +9 −0 test/BUILD
  8. +6 −0 test/hello-test.cc
@@ -0,0 +1,7 @@
new_http_archive(
name = "gtest",
url = "https://github.com/google/googletest/archive/release-1.8.0.zip",
sha256 = "f3ed3b58511efd272eb074a3a6d6fb79d7c2e6a0e374323d1e6bcbcc1ef141bf",
build_file = "gtest.BUILD",
strip_prefix = "googletest-release-1.8.0",
)
@@ -0,0 +1,14 @@
cc_library(
name = "main",
srcs = glob(
["src/*.cc"],
exclude = ["src/gtest-all.cc"]
),
hdrs = glob([
"include/**/*.h",
"src/*.h"
]),
copts = ["-Iexternal/gtest/include"],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
)
@@ -0,0 +1,15 @@
cc_library(
name = "hello-greet",
srcs = ["hello-greet.cc"],
hdrs = ["hello-greet.h"],
visibility = ["//visibility:public"],
)

cc_binary(
name = "hello-world",
srcs = ["hello-world.cc"],
deps = [
":hello-greet",
# "//lib:hello-time",
],
)
@@ -0,0 +1,6 @@
#include "main/hello-greet.h"
#include <string>

std::string get_greet(const std::string& who) {
return "Hello " + who;
}
@@ -0,0 +1,8 @@
#ifndef LIB_HELLO_GREET_H_
#define LIB_HELLO_GREET_H_

#include <string>

std::string get_greet(const std::string &thing);

#endif
@@ -0,0 +1,12 @@
#include "main/hello-greet.h"
#include <iostream>
#include <string>

int main(int argc, char** argv) {
std::string who = "world";
if (argc > 1) {
who = argv[1];
}
std::cout << get_greet(who) << std::endl;
return 0;
}
@@ -0,0 +1,9 @@
cc_test(
name = "hello-test",
srcs = ["hello-test.cc"],
copts = ["-Iexternal/gtest/include"],
deps = [
"@gtest//:main",
"//main:hello-greet",
],
)
@@ -0,0 +1,6 @@
#include "gtest/gtest.h"
#include "lib/hello-greet.h"

TEST(HelloTest, GetGreet) {
EXPECT_EQ(get_greet("Bazel"), "Hello Bazel");
}

0 comments on commit 9189734

Please sign in to comment.
You can’t perform that action at this time.