Skip to content

Commit 413e741

Browse files
authored
chore: move rs-cpp out of project (#1258)
1 parent 6f0bc68 commit 413e741

File tree

10 files changed

+41
-278
lines changed

10 files changed

+41
-278
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 rs-cpp ./rs-cpp/
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 rs-cpp/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 -Irs-cpp/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-
rs-cpp = {path = "./rs-cpp"}
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/Dependency.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "Builder/Compiler.hpp"
44
#include "VersionReq.hpp"
55

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

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

2123
GitDependency(std::string name, std::string url,

lib/Dependency.cc

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,22 @@ static const fs::path CACHE_DIR(getXdgCacheHome() / "cabin");
2525
static const fs::path GIT_DIR(CACHE_DIR / "git");
2626
static const fs::path GIT_SRC_DIR(GIT_DIR / "src");
2727

28-
rs::Result<CompilerOpts> GitDependency::install() const {
29-
fs::path installDir = GIT_SRC_DIR / name;
28+
fs::path GitDependency::installDir() const {
29+
fs::path dir = GIT_SRC_DIR / name;
3030
if (target.has_value()) {
31-
installDir += '-' + target.value();
31+
dir += '-' + target.value();
3232
}
33+
return dir;
34+
}
3335

34-
if (fs::exists(installDir) && !fs::is_empty(installDir)) {
36+
rs::Result<CompilerOpts> GitDependency::install() const {
37+
const fs::path targetDir = installDir();
38+
39+
if (fs::exists(targetDir) && !fs::is_empty(targetDir)) {
3540
spdlog::debug("{} is already installed", name);
3641
} else {
3742
git2::Repository repo;
38-
repo.clone(url, installDir.string());
43+
repo.clone(url, targetDir.string());
3944

4045
if (target.has_value()) {
4146
// Checkout to target.
@@ -49,14 +54,14 @@ rs::Result<CompilerOpts> GitDependency::install() const {
4954
target.has_value() ? target.value() : url);
5055
}
5156

52-
const fs::path includeDir = installDir / "include";
57+
const fs::path includeDir = targetDir / "include";
5358
fs::path include;
5459

5560
if (fs::exists(includeDir) && fs::is_directory(includeDir)
5661
&& !fs::is_empty(includeDir)) {
5762
include = includeDir;
5863
} else {
59-
include = installDir;
64+
include = targetDir;
6065
}
6166

6267
return rs::Ok(CompilerOpts(CFlags({}, { IncludeDir{ include } }, {}),

lib/Manifest.cc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,23 @@ installDependencies(const Manifest& manifest, const bool includeDevDeps,
210210
return std::visit(
211211
Overloaded{
212212
[&](const GitDependency& gitDep) -> rs::Result<void> {
213-
installed.emplace_back(rs_try(gitDep.install()));
213+
CompilerOpts depOpts = rs_try(gitDep.install());
214+
215+
const fs::path depManifestPath =
216+
gitDep.installDir() / Manifest::FILE_NAME;
217+
if (fs::exists(depManifestPath)) {
218+
const Manifest depManifest =
219+
rs_try(Manifest::tryParse(depManifestPath, false));
220+
221+
std::vector<CompilerOpts> nestedDeps;
222+
rs_try(installDependencies(depManifest, includeDevDeps,
223+
seenDeps, visited, nestedDeps));
224+
for (const CompilerOpts& opts : nestedDeps) {
225+
depOpts.merge(opts);
226+
}
227+
}
228+
229+
installed.emplace_back(std::move(depOpts));
214230
return rs::Ok();
215231
},
216232
[&](const SystemDependency& sysDep) -> rs::Result<void> {

rs-cpp/cabin.toml

Lines changed: 0 additions & 8 deletions
This file was deleted.

rs-cpp/include/rs.hpp

Lines changed: 0 additions & 7 deletions
This file was deleted.

rs-cpp/include/rs/result.hpp

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)