Skip to content

Commit 4bb8dc9

Browse files
committed
merge: with main
2 parents cba81fd + 413e741 commit 4bb8dc9

Some content is hidden

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

49 files changed

+1550
-1781
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ COPY .git .
1818
COPY Makefile .
1919
COPY include ./include/
2020
COPY lib ./lib/
21-
COPY rustify ./rustify/
2221
COPY src ./src/
2322
RUN make BUILD=release install
2423

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ CUSTOM_CXXFLAGS := $(shell grep -m1 cxxflags cabin.toml | sed 's/cxxflags = \[//
2323

2424
# Git dependency versions
2525
TOML11_VER := $(shell grep -m1 toml11 cabin.toml | sed 's/.*tag = \(.*\)}/\1/' | tr -d '"')
26-
RESULT_VER := $(shell grep -m1 cpp-result rustify/cabin.toml | sed 's/.*tag = \(.*\)}/\1/' | tr -d '"')
26+
RESULT_VER := v11.0.0
2727

28-
GIT_DEPS := $(O)/DEPS/toml11 $(O)/DEPS/mitama-cpp-result
28+
GIT_DEPS := $(O)/DEPS/toml11 $(O)/DEPS/mitama-cpp-result $(O)/DEPS/rs-cpp
2929

3030
# System dependency versions
3131
PKGS := \
@@ -44,8 +44,9 @@ DEFINES := -DCABIN_CABIN_PKG_VERSION='"$(VERSION)"' \
4444
-DCABIN_CABIN_COMMIT_HASH='"$(COMMIT_HASH)"' \
4545
-DCABIN_CABIN_COMMIT_SHORT_HASH='"$(COMMIT_SHORT_HASH)"' \
4646
-DCABIN_CABIN_COMMIT_DATE='"$(COMMIT_DATE)"'
47-
INCLUDES := -Iinclude -Isrc -Irustify/include -isystem $(O)/DEPS/toml11/include \
48-
-isystem $(O)/DEPS/mitama-cpp-result/include
47+
INCLUDES := -Iinclude -Isrc -isystem $(O)/DEPS/toml11/include \
48+
-isystem $(O)/DEPS/mitama-cpp-result/include \
49+
-isystem $(O)/DEPS/rs-cpp/include
4950

5051
CXXFLAGS := -std=c++$(EDITION) -fdiagnostics-color $(CUSTOM_CXXFLAGS) \
5152
$(DEFINES) $(INCLUDES) $(PKG_CFLAGS) -MMD -MP
@@ -105,3 +106,7 @@ $(O)/DEPS/mitama-cpp-result:
105106
@mkdir -p $(@D)
106107
@$(GIT) clone https://github.com/loliGothicK/mitama-cpp-result.git $@
107108
@$(GIT) -C $@ reset --hard $(RESULT_VER)
109+
110+
$(O)/DEPS/rs-cpp:
111+
@mkdir -p $(@D)
112+
@$(GIT) clone https://github.com/ken-matsui/rs-cpp.git $@

cabin.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ libcurl = {version = ">=7.79.1 && <9", system = true}
1818
libgit2 = {version = ">=1.7 && <1.10", system = true}
1919
nlohmann_json = {version = "3.10.5", system = true}
2020
tbb = {version = ">=2021.5.0 && <2023.0.0", system = true}
21-
rustify = {path = "rustify"}
21+
rs-cpp = {git = "https://github.com/ken-matsui/rs-cpp.git", branch = "main"}
2222

2323
[dev-dependencies]
2424
boost-ut = {git = "https://github.com/boost-ext/ut.git", tag = "v2.3.1"}

include/Algos.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#pragma once
22

33
#include "Command.hpp"
4-
#include "Rustify/Result.hpp"
54

65
#include <algorithm>
76
#include <cstddef>
87
#include <optional>
8+
#include <rs/result.hpp>
99
#include <span>
1010
#include <string>
1111
#include <string_view>
@@ -17,9 +17,9 @@ std::string toMacroName(std::string_view name) noexcept;
1717
std::string replaceAll(std::string str, std::string_view from,
1818
std::string_view to) noexcept;
1919

20-
Result<ExitStatus> execCmd(const Command& cmd) noexcept;
21-
Result<std::string> getCmdOutput(const Command& cmd,
22-
std::size_t retry = 3) noexcept;
20+
rs::Result<ExitStatus> execCmd(const Command& cmd) noexcept;
21+
rs::Result<std::string> getCmdOutput(const Command& cmd,
22+
std::size_t retry = 3) noexcept;
2323
bool commandExists(std::string_view cmd) noexcept;
2424

2525
constexpr char toLower(char c) noexcept {

include/Builder/BuildGraph.hpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#include "Builder/SourceLayout.hpp"
88
#include "Command.hpp"
99
#include "Manifest.hpp"
10-
#include "Rustify/Result.hpp"
1110

1211
#include <cstdint>
1312
#include <filesystem>
1413
#include <optional>
14+
#include <rs/result.hpp>
1515
#include <string>
1616
#include <string_view>
1717
#include <tbb/spin_mutex.h>
@@ -34,8 +34,8 @@ class BuildGraph {
3434
TestKind kind = TestKind::Unit;
3535
};
3636

37-
static Result<BuildGraph> create(const Manifest& manifest,
38-
const BuildProfile& buildProfile);
37+
static rs::Result<BuildGraph> create(const Manifest& manifest,
38+
const BuildProfile& buildProfile);
3939

4040
const fs::path& outBasePath() const { return outBasePath_; }
4141
const Manifest& manifest() const { return project.manifest; }
@@ -46,16 +46,16 @@ class BuildGraph {
4646
const std::string& libraryName() const { return libName; }
4747
const std::vector<TestTarget>& testTargets() const { return testTargets_; }
4848

49-
Result<void> installDeps(bool includeDevDeps);
49+
rs::Result<void> installDeps(bool includeDevDeps);
5050
void enableCoverage();
51-
Result<void> plan(bool logAnalysis = true);
52-
Result<void> writeBuildFilesIfNeeded() const;
53-
Result<void> generateCompdb() const;
51+
rs::Result<void> plan(bool logAnalysis = true);
52+
rs::Result<void> writeBuildFilesIfNeeded() const;
53+
rs::Result<void> generateCompdb() const;
5454

55-
Result<bool> needsBuild(const std::vector<std::string>& targets) const;
55+
rs::Result<bool> needsBuild(const std::vector<std::string>& targets) const;
5656
Command ninjaCommand(bool dryRun = false) const;
57-
Result<ExitStatus> buildTargets(const std::vector<std::string>& targets,
58-
std::string_view displayName) const;
57+
rs::Result<ExitStatus> buildTargets(const std::vector<std::string>& targets,
58+
std::string_view displayName) const;
5959

6060
private:
6161
struct CompileUnit {
@@ -84,22 +84,22 @@ class BuildGraph {
8484
const std::unordered_set<std::string>& dependencies,
8585
bool isTest);
8686

87-
Result<std::string> runMM(const std::string& sourceFile,
88-
bool isTest = false) const;
89-
Result<bool> containsTestCode(const std::string& sourceFile) const;
87+
rs::Result<std::string> runMM(const std::string& sourceFile,
88+
bool isTest = false) const;
89+
rs::Result<bool> containsTestCode(const std::string& sourceFile) const;
9090

91-
Result<void> processSrc(const fs::path& sourceFilePath,
92-
const SourceRoot& root,
93-
std::unordered_set<std::string>& buildObjTargets,
94-
tbb::spin_mutex* mtx = nullptr);
95-
Result<std::unordered_set<std::string>>
91+
rs::Result<void> processSrc(const fs::path& sourceFilePath,
92+
const SourceRoot& root,
93+
std::unordered_set<std::string>& buildObjTargets,
94+
tbb::spin_mutex* mtx = nullptr);
95+
rs::Result<std::unordered_set<std::string>>
9696
processSources(const std::vector<fs::path>& sourceFilePaths,
9797
const SourceRoot& root);
9898

99-
Result<std::optional<TestTarget>>
99+
rs::Result<std::optional<TestTarget>>
100100
processUnittestSrc(const fs::path& sourceFilePath,
101101
tbb::spin_mutex* mtx = nullptr);
102-
Result<std::optional<TestTarget>>
102+
rs::Result<std::optional<TestTarget>>
103103
processIntegrationTestSrc(const fs::path& sourceFilePath,
104104
tbb::spin_mutex* mtx = nullptr);
105105

@@ -108,7 +108,7 @@ class BuildGraph {
108108
const std::unordered_set<std::string>& objTargetDeps,
109109
const std::unordered_set<std::string>& buildObjTargets) const;
110110

111-
Result<void> configure();
111+
rs::Result<void> configure();
112112
void writeBuildFiles() const;
113113

114114
fs::path outBasePath_;

include/Builder/Compiler.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#pragma once
22

33
#include "Command.hpp"
4-
#include "Rustify/Result.hpp"
54
#include "VersionReq.hpp"
65

76
#include <filesystem>
87
#include <fmt/format.h>
98
#include <fmt/std.h>
9+
#include <rs/result.hpp>
1010
#include <string>
1111
#include <string_view>
1212
#include <utility>
@@ -44,7 +44,8 @@ struct CFlags {
4444
: macros(std::move(macros)), includeDirs(std::move(includeDirs)),
4545
others(std::move(others)) {}
4646

47-
static Result<CFlags> parsePkgConfig(std::string_view pkgConfigVer) noexcept;
47+
static rs::Result<CFlags>
48+
parsePkgConfig(std::string_view pkgConfigVer) noexcept;
4849

4950
void merge(const CFlags& other) noexcept;
5051
};
@@ -71,7 +72,8 @@ struct LdFlags {
7172
LdFlags(std::vector<LibDir> libDirs, std::vector<Lib> libs,
7273
std::vector<std::string> others) noexcept;
7374

74-
static Result<LdFlags> parsePkgConfig(std::string_view pkgConfigVer) noexcept;
75+
static rs::Result<LdFlags>
76+
parsePkgConfig(std::string_view pkgConfigVer) noexcept;
7577

7678
void merge(const LdFlags& other) noexcept;
7779
};
@@ -84,8 +86,9 @@ struct CompilerOpts {
8486
CompilerOpts(CFlags cFlags, LdFlags ldFlags) noexcept
8587
: cFlags(std::move(cFlags)), ldFlags(std::move(ldFlags)) {}
8688

87-
static Result<CompilerOpts> parsePkgConfig(const VersionReq& pkgVerReq,
88-
std::string_view pkgName) noexcept;
89+
static rs::Result<CompilerOpts>
90+
parsePkgConfig(const VersionReq& pkgVerReq,
91+
std::string_view pkgName) noexcept;
8992

9093
void merge(const CompilerOpts& other) noexcept;
9194
};
@@ -95,7 +98,7 @@ class Compiler {
9598
const std::string cxx;
9699

97100
static Compiler init(std::string cxx) noexcept;
98-
static Result<Compiler> init() noexcept;
101+
static rs::Result<Compiler> init() noexcept;
99102

100103
Command makeCompileCmd(const CompilerOpts& opts,
101104
const std::string& sourceFile,

include/Builder/DepGraph.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#include "Builder/BuildGraph.hpp"
44
#include "Builder/BuildProfile.hpp"
55
#include "Manifest.hpp"
6-
#include "Rustify/Result.hpp"
76

87
#include <filesystem>
98
#include <optional>
9+
#include <rs/result.hpp>
1010
#include <utility>
1111

1212
namespace cabin {
@@ -17,8 +17,9 @@ class DepGraph {
1717
public:
1818
explicit DepGraph(fs::path rootPath) : rootPath(std::move(rootPath)) {}
1919

20-
Result<void> resolve();
21-
Result<BuildGraph> computeBuildGraph(const BuildProfile& buildProfile) const;
20+
rs::Result<void> resolve();
21+
rs::Result<BuildGraph>
22+
computeBuildGraph(const BuildProfile& buildProfile) const;
2223

2324
private:
2425
fs::path rootPath;

include/Command.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#pragma once
22

3-
#include "Rustify/Result.hpp"
4-
53
#include <cstdint>
64
#include <cstdlib>
75
#include <filesystem>
86
#include <fmt/format.h>
7+
#include <rs/result.hpp>
98
#include <span>
109
#include <string>
1110
#include <string_view>
@@ -53,8 +52,8 @@ class Child {
5352
friend struct Command;
5453

5554
public:
56-
Result<ExitStatus> wait() const noexcept;
57-
Result<CommandOutput> waitWithOutput() const noexcept;
55+
rs::Result<ExitStatus> wait() const noexcept;
56+
rs::Result<CommandOutput> waitWithOutput() const noexcept;
5857
};
5958

6059
struct Command {
@@ -111,8 +110,8 @@ struct Command {
111110

112111
std::string toString() const;
113112

114-
Result<Child> spawn() const noexcept;
115-
Result<CommandOutput> output() const noexcept;
113+
rs::Result<Child> spawn() const noexcept;
114+
rs::Result<CommandOutput> output() const noexcept;
116115
};
117116

118117
} // namespace cabin

include/Dependency.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#pragma once
22

33
#include "Builder/Compiler.hpp"
4-
#include "Rustify/Result.hpp"
54
#include "VersionReq.hpp"
65

6+
#include <filesystem>
77
#include <optional>
8+
#include <rs/result.hpp>
89
#include <string>
910
#include <utility>
1011
#include <variant>
@@ -16,7 +17,8 @@ struct GitDependency {
1617
const std::string url;
1718
const std::optional<std::string> target;
1819

19-
Result<CompilerOpts> install() const;
20+
[[nodiscard]] std::filesystem::path installDir() const;
21+
rs::Result<CompilerOpts> install() const;
2022

2123
GitDependency(std::string name, std::string url,
2224
std::optional<std::string> target)
@@ -27,7 +29,7 @@ struct PathDependency {
2729
const std::string name;
2830
const std::string path;
2931

30-
Result<CompilerOpts> install() const;
32+
rs::Result<CompilerOpts> install() const;
3133

3234
PathDependency(std::string name, std::string path)
3335
: name(std::move(name)), path(std::move(path)) {}
@@ -37,7 +39,7 @@ struct SystemDependency {
3739
const std::string name;
3840
const VersionReq versionReq;
3941

40-
Result<CompilerOpts> install() const;
42+
rs::Result<CompilerOpts> install() const;
4143

4244
SystemDependency(std::string name, VersionReq versionReq)
4345
: name(std::move(name)), versionReq(std::move(versionReq)) {}

0 commit comments

Comments
 (0)