Skip to content

Commit 515b3fd

Browse files
authored
all: wrap by cabin namespace (#1086)
1 parent 682213b commit 515b3fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+187
-5
lines changed

.github/workflows/cpp.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,15 @@ jobs:
5050
- name: Build Cabin
5151
run: make RELEASE=1
5252

53+
- uses: actions/setup-python@v5
54+
with:
55+
python-version: '3.*'
56+
5357
- name: Install cpplint
54-
run: sudo apt-get install -y cpplint
58+
run: pip install cpplint
59+
60+
- name: Show cpplint version
61+
run: cpplint --version
5562

5663
- name: cabin lint
5764
run: ./build/cabin lint --verbose

src/Algos.cc

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <utility>
1616
#include <vector>
1717

18+
namespace cabin {
19+
1820
std::string
1921
toUpper(const std::string_view str) noexcept {
2022
std::string res;
@@ -178,6 +180,8 @@ findSimilarStr(
178180
}
179181
}
180182

183+
} // namespace cabin
184+
181185
#ifdef CABIN_TEST
182186

183187
# include "Rustify/Aliases.hpp"
@@ -188,6 +192,8 @@ findSimilarStr(
188192

189193
namespace tests {
190194

195+
using namespace cabin; // NOLINT(build/namespaces,google-build-using-namespace)
196+
191197
static void
192198
testLevDistance() {
193199
// Test bytelength agnosticity

src/Algos.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <string>
99
#include <string_view>
1010

11+
namespace cabin {
12+
1113
std::string toUpper(std::string_view str) noexcept;
1214
std::string toMacroName(std::string_view name) noexcept;
1315
std::string
@@ -29,3 +31,5 @@ bool commandExists(std::string_view cmd) noexcept;
2931
std::optional<std::string_view> findSimilarStr(
3032
std::string_view lhs, std::span<const std::string_view> candidates
3133
);
34+
35+
} // namespace cabin

src/BuildConfig.cc

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include <utility>
3535
#include <vector>
3636

37+
namespace cabin {
38+
3739
std::ostream&
3840
operator<<(std::ostream& os, VarType type) {
3941
switch (type) {
@@ -1023,10 +1025,14 @@ getMakeCommand() {
10231025
return makeCommand;
10241026
}
10251027

1028+
} // namespace cabin
1029+
10261030
#ifdef CABIN_TEST
10271031

10281032
namespace tests {
10291033

1034+
using namespace cabin; // NOLINT(build/namespaces,google-build-using-namespace)
1035+
10301036
// NOTE: These tests are commented out, BuildConfig won't be used in the
10311037
// future. We can remove these tests then.
10321038
//

src/BuildConfig.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <unordered_set>
1616
#include <vector>
1717

18+
namespace cabin {
19+
1820
// clang-format off
1921
inline const std::unordered_set<std::string> SOURCE_FILE_EXTS{
2022
".c", ".c++", ".cc", ".cpp", ".cxx"
@@ -197,3 +199,5 @@ emitCompdb(const Manifest& manifest, bool isDebug, bool includeDevDeps);
197199
std::string_view modeToString(bool isDebug);
198200
std::string_view modeToProfile(bool isDebug);
199201
Command getMakeCommand();
202+
203+
} // namespace cabin

src/Cli.cc

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <utility>
1616
#include <vector>
1717

18+
namespace cabin {
19+
1820
static constinit const std::string_view PADDING = " ";
1921

2022
static void
@@ -540,3 +542,5 @@ Cli::printHelp(const std::span<const std::string_view> args) const noexcept {
540542
printCmdHelp();
541543
return EXIT_SUCCESS;
542544
}
545+
546+
} // namespace cabin

src/Cli.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <unordered_map>
1515
#include <vector>
1616

17+
namespace cabin {
18+
1719
class Opt;
1820
class Arg;
1921
class Subcmd;
@@ -257,3 +259,5 @@ class Cli : public CliBase<Cli> {
257259
/// Print help message for cabin itself.
258260
void printCmdHelp() const noexcept;
259261
};
262+
263+
} // namespace cabin

src/Cmd/Add.cc

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <unordered_map>
1717
#include <unordered_set>
1818

19+
namespace cabin {
20+
1921
static int addMain(std::span<const std::string_view> args);
2022

2123
const Subcmd ADD_CMD =
@@ -244,3 +246,5 @@ addMain(const std::span<const std::string_view> args) {
244246
newDeps, isSystemDependency, version, tag, rev, branch
245247
);
246248
}
249+
250+
} // namespace cabin

src/Cmd/Add.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
#include "../Cli.hpp"
44

5+
namespace cabin {
6+
57
extern const Subcmd ADD_CMD;
8+
9+
} // namespace cabin

src/Cmd/Build.cc

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <system_error>
2222
#include <vector>
2323

24+
namespace cabin {
25+
2426
static int buildMain(std::span<const std::string_view> args);
2527

2628
const Subcmd BUILD_CMD =
@@ -152,3 +154,5 @@ buildMain(const std::span<const std::string_view> args) {
152154
logger::info("Generated", "{}/compile_commands.json", outDir);
153155
return EXIT_SUCCESS;
154156
}
157+
158+
} // namespace cabin

src/Cmd/Build.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55

66
#include <string>
77

8+
namespace cabin {
9+
810
extern const Subcmd BUILD_CMD;
911
int buildImpl(const Manifest& manifest, std::string& outDir, bool isDebug);
12+
13+
} // namespace cabin

src/Cmd/Clean.cc

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <string>
1111
#include <string_view>
1212

13+
namespace cabin {
14+
1315
static int cleanMain(std::span<const std::string_view> args) noexcept;
1416

1517
const Subcmd CLEAN_CMD = //
@@ -57,3 +59,5 @@ cleanMain(const std::span<const std::string_view> args) noexcept {
5759
}
5860
return EXIT_SUCCESS;
5961
}
62+
63+
} // namespace cabin

src/Cmd/Clean.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
#include "../Cli.hpp"
44

5+
namespace cabin {
6+
57
extern const Subcmd CLEAN_CMD;
8+
9+
} // namespace cabin

src/Cmd/Common.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "../Cli.hpp"
44
#include "../Parallelism.hpp"
55

6+
namespace cabin {
7+
68
inline constinit const Opt OPT_DEBUG = Opt{ "--debug" }.setShort("-d").setDesc(
79
"Build with debug information [default]"
810
);
@@ -21,3 +23,5 @@ inline const Opt OPT_JOBS =
2123
.setDesc("Set the number of jobs to run in parallel")
2224
.setPlaceholder("<NUM>")
2325
.setDefault(NUM_DEFAULT_THREADS);
26+
27+
} // namespace cabin

src/Cmd/Fmt.cc

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <utility>
1919
#include <vector>
2020

21+
namespace cabin {
22+
2123
static int fmtMain(std::span<const std::string_view> args);
2224

2325
const Subcmd FMT_CMD =
@@ -155,3 +157,5 @@ fmtMain(const std::span<const std::string_view> args) {
155157

156158
return execCmd(clangFormat);
157159
}
160+
161+
} // namespace cabin

src/Cmd/Fmt.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
#include "../Cli.hpp"
44

5+
namespace cabin {
6+
57
extern const Subcmd FMT_CMD;
8+
9+
} // namespace cabin

src/Cmd/Help.cc

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <span>
66
#include <string_view>
77

8+
namespace cabin {
9+
810
static int helpMain(std::span<const std::string_view> args) noexcept;
911

1012
const Subcmd HELP_CMD = //
@@ -17,3 +19,5 @@ static int
1719
helpMain(const std::span<const std::string_view> args) noexcept {
1820
return getCli().printHelp(args);
1921
}
22+
23+
} // namespace cabin

src/Cmd/Help.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
#include "../Cli.hpp"
44

5+
namespace cabin {
6+
57
extern const Subcmd HELP_CMD;
8+
9+
} // namespace cabin

src/Cmd/Init.cc

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <string>
1313
#include <string_view>
1414

15+
namespace cabin {
16+
1517
static int initMain(std::span<const std::string_view> args);
1618

1719
const Subcmd INIT_CMD =
@@ -61,3 +63,5 @@ initMain(const std::span<const std::string_view> args) {
6163
);
6264
return EXIT_SUCCESS;
6365
}
66+
67+
} // namespace cabin

src/Cmd/Init.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
#include "../Cli.hpp"
44

5+
namespace cabin {
6+
57
extern const Subcmd INIT_CMD;
8+
9+
} // namespace cabin

src/Cmd/Lint.cc

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <string_view>
1616
#include <vector>
1717

18+
namespace cabin {
19+
1820
static int lintMain(std::span<const std::string_view> args);
1921

2022
const Subcmd LINT_CMD = Subcmd{ "lint" }
@@ -120,3 +122,5 @@ lintMain(const std::span<const std::string_view> args) {
120122
return lint(manifest.package.name, cpplintArgs);
121123
}
122124
}
125+
126+
} // namespace cabin

src/Cmd/Lint.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
#include "../Cli.hpp"
44

5+
namespace cabin {
6+
57
extern const Subcmd LINT_CMD;
8+
9+
} // namespace cabin

src/Cmd/New.cc

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <string>
1616
#include <string_view>
1717

18+
namespace cabin {
19+
1820
static int newMain(std::span<const std::string_view> args);
1921

2022
const Subcmd NEW_CMD = //
@@ -159,3 +161,5 @@ newMain(const std::span<const std::string_view> args) {
159161
git2::Repository().init(packageName);
160162
return EXIT_SUCCESS;
161163
}
164+
165+
} // namespace cabin

src/Cmd/New.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
#include <string>
66
#include <string_view>
77

8+
namespace cabin {
9+
810
extern const Subcmd NEW_CMD;
911
std::string createCabinToml(std::string_view projectName) noexcept;
12+
13+
} // namespace cabin

src/Cmd/Run.cc

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <system_error>
1919
#include <vector>
2020

21+
namespace cabin {
22+
2123
static int runMain(std::span<const std::string_view> args);
2224

2325
const Subcmd RUN_CMD =
@@ -83,3 +85,5 @@ runMain(const std::span<const std::string_view> args) {
8385
const Command command(outDir + "/" + manifest.package.name, runArgs);
8486
return execCmd(command);
8587
}
88+
89+
} // namespace cabin

src/Cmd/Run.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
#include "../Cli.hpp"
44

5+
namespace cabin {
6+
57
extern const Subcmd RUN_CMD;
8+
9+
} // namespace cabin

src/Cmd/Search.cc

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <string>
1414
#include <string_view>
1515

16+
namespace cabin {
17+
1618
static int searchMain(std::span<const std::string_view> args);
1719

1820
const Subcmd SEARCH_CMD =
@@ -140,3 +142,5 @@ searchMain(const std::span<const std::string_view> args) {
140142
printTable(packages);
141143
return EXIT_SUCCESS;
142144
}
145+
146+
} // namespace cabin

src/Cmd/Search.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
#include "../Cli.hpp"
44

5+
namespace cabin {
6+
57
extern const Subcmd SEARCH_CMD;
8+
9+
} // namespace cabin

src/Cmd/Test.cc

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <system_error>
2222
#include <vector>
2323

24+
namespace cabin {
25+
2426
static int testMain(std::span<const std::string_view> args);
2527

2628
const Subcmd TEST_CMD = //
@@ -162,3 +164,5 @@ testMain(const std::span<const std::string_view> args) {
162164
}
163165
return exitCode;
164166
}
167+
168+
} // namespace cabin

0 commit comments

Comments
 (0)