Skip to content

Commit febf6e1

Browse files
committed
Small compile_flags helper script
Increase toolchain test cases to cover non-rules_swiftnav rules Extend test suite
1 parent 753d7ef commit febf6e1

File tree

12 files changed

+240
-20
lines changed

12 files changed

+240
-20
lines changed

cc/toolchains/llvm/unix_cc_toolchain_config.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ def _impl(ctx):
12911291
flag_set(
12921292
actions = all_link_actions,
12931293
flag_groups = [flag_group(
1294-
flags = ["-Wl,-fatal-warnings"] if is_linux else [""], # fails on Mac & clang14: ["-Wl,-fatal_warnings"],
1294+
flags = ["-Wl,-fatal-warnings"] if is_linux else ["-Wl,-fatal_warnings"],
12951295
)],
12961296
),
12971297
],
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
1+
load("@rules_swiftnav//cc:defs.bzl", "swift_cc_test", "swift_cc_library")
12
load("@rules_swiftnav//cc:defs2.bzl", "UNIT", "swift_add_cc_test", "swift_add_prod_cc_library")
23

4+
swift_cc_library(
5+
name = "add",
6+
srcs = ["add.cc"],
7+
hdrs = ["add.hpp"],
8+
visibility = ["//visibility:public"],
9+
standard = 20,
10+
)
11+
12+
swift_cc_test(
13+
name = "add_test",
14+
srcs = ["add_test.cc"],
15+
type = UNIT,
16+
deps = [
17+
":add",
18+
"@googletest//:gtest_main",
19+
],
20+
)
21+
322
swift_add_prod_cc_library(
4-
name = "base_math",
5-
srcs = ["base_math.cc"],
6-
hdrs = ["base_math.hpp"],
23+
name = "sign",
24+
srcs = ["sign.cc"],
25+
hdrs = ["sign.hpp"],
726
visibility = ["//visibility:public"],
27+
standard = 20,
828
)
929

1030
swift_add_cc_test(
11-
name = "base_math_test",
12-
srcs = ["base_math_test.cc"],
31+
name = "sign_test",
32+
srcs = ["sign_test.cc"],
1333
type = UNIT,
1434
deps = [
15-
":base_math",
35+
":sign",
1636
"@googletest//:gtest_main",
1737
],
1838
)

examples/small_world/src/base_math/base_math.cc renamed to examples/small_world/src/base_math/add.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "base_math.hpp"
1+
#include "add.hpp"
22

33
int add(int x, int y) {
44
return x + y;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef ADD_HPP
2+
#define ADD_HPP
3+
4+
int add(int x, int y);
5+
6+
#endif
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
#include "base_math.hpp"
1+
#include "add.hpp"
22
#include "gtest/gtest.h"
33

44
TEST(BaseMathTest, Add) {
55
EXPECT_EQ(add(1, 2), 3);
66
EXPECT_EQ(add(-1, 1), 0);
77
EXPECT_EQ(add(-1, -1), -2);
88
}
9-
10-
TEST(BaseMathTest, SignPlus) {
11-
EXPECT_EQ(Math::sign(10), 1);
12-
//EXPECT_EQ(Math::sign(-10), -1);
13-
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "sign.hpp"
2+
3+
int add(int x, int y) {
4+
return x + y;
5+
}

examples/small_world/src/base_math/base_math.hpp renamed to examples/small_world/src/base_math/sign.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef BASE_MATH_HPP
2-
#define BASE_MATH_HPP
1+
#ifndef SIGN_HPP
2+
#define SIGN_HPP
33

44
int add(int x, int y);
55

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "sign.hpp"
2+
#include "gtest/gtest.h"
3+
4+
TEST(BaseMathTest, SignPlus) {
5+
EXPECT_EQ(Math::sign(10), 1);
6+
//EXPECT_EQ(Math::sign(-10), -1);
7+
}

examples/small_world/src/fibonacci/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ swift_add_safe_cc_library(
55
srcs = ["fibonacci.cc"],
66
hdrs = ["fibonacci.hpp"],
77
visibility = ["//visibility:public"],
8-
deps = ["//src/base_math"],
8+
deps = ["//src/base_math:add"],
99
)
1010

1111
swift_add_cc_test(

examples/small_world/src/fibonacci/fibonacci.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "fibonacci.hpp"
2-
#include "src/base_math/base_math.hpp"
2+
#include "src/base_math/add.hpp"
33

44
int fibonacci(int n) {
55
if (n <= 1) {

0 commit comments

Comments
 (0)