Skip to content

Commit 175c985

Browse files
committed
Add more libs
Create new folder structure
1 parent 14e6292 commit 175c985

File tree

7 files changed

+106
-5
lines changed

7 files changed

+106
-5
lines changed

test/small_world/.bazelrc

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ common --@rules_swiftnav//cc:enable_bzlmod=true
88
build:coverage_x86_64_linux --platforms=@rules_swiftnav//platforms:x86_64_linux_llvm20
99

1010
build:coverage_aarch64_darwin --platforms=@rules_swiftnav//platforms:aarch64_darwin_llvm20
11+
build:coverage_aarch64_darwin --action_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=0
12+
13+
1114

1215
# # Overrides our custom toolchain and uses the system
1316
# build:system --noincompatible_enable_cc_toolchain_resolution
@@ -43,18 +46,47 @@ build:coverage_aarch64_darwin --platforms=@rules_swiftnav//platforms:aarch64_dar
4346
# test --spawn_strategy=local
4447
# test --strategy=TestRunner=local
4548

46-
#
49+
# coverage --spawn_strategy=local
50+
# coverage --strategy=TestRunner=local
51+
# coverage --action_env=COVERAGE_GCOV_PATH="/opt/homebrew/opt/llvm/bin/llvm-profdata" # not needed, part of clang20 toolchain!
52+
53+
# next line does not seem to change anything
54+
# coverage --action_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=1
4755

56+
# same, same
57+
# coverage --action_env=GCOV_PREFIX_STRIP=10
4858

59+
# next 4 lines are not possible with clang20!
60+
# coverage --cxxopt=-mllvm
61+
# coverage --copt=-mllvm
62+
# coverage --cxxopt=-system-headers-coverage
63+
# coverage --copt=-system-headers-coverage
4964

5065

51-
# bazel coverage --config=coverage_aarch64_darwin //src/base_math:base_math_test --subcommands
66+
# Mac:
67+
# https://github.com/bazelbuild/bazel/blob/1879fc9dbf9d1989c2f1a1e6d2ec61097fe62233/src/test/shell/bazel/bazel_coverage_cc_test_llvm.sh#L67 ?
68+
# bazel coverage --config=coverage_aarch64_darwin //src/base_math:base_math_test --subcommands --experimental_generate_llvm_lcov --combined_report=lcov
5269

70+
#common --action_env=BAZEL_LLVM_COV="external/rules_swiftnav+/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov"
71+
#common --action_env=BAZEL_LLVM_PROFDATA="external/rules_swiftnav+/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata"
72+
#common --action_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=1
73+
#common --repo_env=CC=${clang}
74+
#common --repo_env=GCOV=${llvm_profdata}
75+
#common --experimental_generate_llvm_lcov
5376

54-
# on ubuntu! you do not need those options above (might be only for Mac)
77+
78+
# on ubuntu!
5579
# 1.
5680
# bazel coverage --config=coverage_x86_64_linux //src/base_math:base_math_test --subcommands --experimental_generate_llvm_lcov --combined_report=lcov
5781
# 2.
58-
# /home/jenkins/.cache/bazel/_bazel_jenkins/5a7b992760bae9ecbea2fa12e457bcb7/execroot/_main/bazel-out/_coverage/_coverage_report.dat
82+
# cp "$(bazel info output_path)/_coverage/_coverage_report.dat" cov.dat
5983
# copy
6084
# 3. genhtml --output html cov.dat
85+
86+
87+
88+
# bazel coverage --config=coverage_x86_64_linux //src/old_folder_structure:old_folder_structure_test --subcommands --experimental_generate_llvm_lcov --combined_report=lcov
89+
# cp "$(bazel info output_path)/_coverage/_coverage_report.dat" cov.dat
90+
# genhtml --output html cov.dat
91+
92+
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1-
#pragma once
1+
#ifndef BASE_MATH_HPP
2+
#define BASE_MATH_HPP
23

34
int add(int x, int y);
5+
6+
struct Math {
7+
static int sign(int x) {
8+
if (x >= 0) {
9+
return 1;
10+
} else {
11+
return -1;
12+
}
13+
}
14+
};
15+
16+
#endif

test/small_world/src/base_math/base_math_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ TEST(BaseMathTest, Add) {
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+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
load("@rules_swiftnav//cc:defs.bzl", "UNIT", "swift_cc_library", "swift_cc_test")
2+
3+
swift_cc_library(
4+
name = "old_folder_structure",
5+
srcs = ["src/old_folder_structure.cc"],
6+
hdrs = ["include/old_folder_structure/old_folder_structure.hpp"],
7+
includes = ["include"],
8+
visibility = ["//visibility:public"],
9+
)
10+
11+
swift_cc_test(
12+
name = "old_folder_structure_test",
13+
srcs = ["test/old_folder_structure_test.cc"],
14+
type = UNIT,
15+
deps = [
16+
":old_folder_structure",
17+
"@googletest//:gtest_main",
18+
],
19+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef OLD_FOLDER_STRUCTURE_HPP
2+
#define OLD_FOLDER_STRUCTURE_HPP
3+
4+
int minus(int x, int y);
5+
6+
struct Math {
7+
static int inv_sign(int x) {
8+
if (x >= 0) {
9+
return -1;
10+
} else {
11+
return 1;
12+
}
13+
}
14+
};
15+
16+
#endif
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "old_folder_structure/old_folder_structure.hpp"
2+
3+
int minus(int x, int y) {
4+
return x - y;
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "old_folder_structure/old_folder_structure.hpp"
2+
#include "gtest/gtest.h"
3+
4+
TEST(old_folder_structure, Minus) {
5+
EXPECT_EQ(minus(1, 2), -1);
6+
EXPECT_EQ(minus(-1, 1), -2);
7+
EXPECT_EQ(minus(-1, -1), 0);
8+
}
9+
10+
TEST(old_folder_structure, InvSignPlus) {
11+
EXPECT_EQ(Math::inv_sign(10), -1);
12+
}

0 commit comments

Comments
 (0)