Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ COPY .git .
COPY Makefile .
COPY include ./include/
COPY lib ./lib/
COPY rs-cpp ./rs-cpp/
COPY src ./src/
RUN make BUILD=release install

Expand Down
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ CUSTOM_CXXFLAGS := $(shell grep -m1 cxxflags cabin.toml | sed 's/cxxflags = \[//

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

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

# System dependency versions
PKGS := \
Expand All @@ -44,8 +44,9 @@ DEFINES := -DCABIN_CABIN_PKG_VERSION='"$(VERSION)"' \
-DCABIN_CABIN_COMMIT_HASH='"$(COMMIT_HASH)"' \
-DCABIN_CABIN_COMMIT_SHORT_HASH='"$(COMMIT_SHORT_HASH)"' \
-DCABIN_CABIN_COMMIT_DATE='"$(COMMIT_DATE)"'
INCLUDES := -Iinclude -Isrc -Irs-cpp/include -isystem $(O)/DEPS/toml11/include \
-isystem $(O)/DEPS/mitama-cpp-result/include
INCLUDES := -Iinclude -Isrc -isystem $(O)/DEPS/toml11/include \
-isystem $(O)/DEPS/mitama-cpp-result/include \
-isystem $(O)/DEPS/rs-cpp/include

CXXFLAGS := -std=c++$(EDITION) -fdiagnostics-color $(CUSTOM_CXXFLAGS) \
$(DEFINES) $(INCLUDES) $(PKG_CFLAGS) -MMD -MP
Expand Down Expand Up @@ -105,3 +106,7 @@ $(O)/DEPS/mitama-cpp-result:
@mkdir -p $(@D)
@$(GIT) clone https://github.com/loliGothicK/mitama-cpp-result.git $@
@$(GIT) -C $@ reset --hard $(RESULT_VER)

$(O)/DEPS/rs-cpp:
@mkdir -p $(@D)
@$(GIT) clone https://github.com/ken-matsui/rs-cpp.git $@
2 changes: 1 addition & 1 deletion cabin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ libcurl = {version = ">=7.79.1 && <9", system = true}
libgit2 = {version = ">=1.7 && <1.10", system = true}
nlohmann_json = {version = "3.10.5", system = true}
tbb = {version = ">=2021.5.0 && <2023.0.0", system = true}
rs-cpp = {path = "./rs-cpp"}
rs-cpp = {git = "https://github.com/ken-matsui/rs-cpp.git", branch = "main"}

[dev-dependencies]
boost-ut = {git = "https://github.com/boost-ext/ut.git", tag = "v2.3.1"}
Expand Down
2 changes: 2 additions & 0 deletions include/Dependency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Builder/Compiler.hpp"
#include "VersionReq.hpp"

#include <filesystem>
#include <optional>
#include <rs/result.hpp>
#include <string>
Expand All @@ -16,6 +17,7 @@ struct GitDependency {
const std::string url;
const std::optional<std::string> target;

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

GitDependency(std::string name, std::string url,
Expand Down
19 changes: 12 additions & 7 deletions lib/Dependency.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ static const fs::path CACHE_DIR(getXdgCacheHome() / "cabin");
static const fs::path GIT_DIR(CACHE_DIR / "git");
static const fs::path GIT_SRC_DIR(GIT_DIR / "src");

rs::Result<CompilerOpts> GitDependency::install() const {
fs::path installDir = GIT_SRC_DIR / name;
fs::path GitDependency::installDir() const {
fs::path dir = GIT_SRC_DIR / name;
if (target.has_value()) {
installDir += '-' + target.value();
dir += '-' + target.value();
}
return dir;
}

if (fs::exists(installDir) && !fs::is_empty(installDir)) {
rs::Result<CompilerOpts> GitDependency::install() const {
const fs::path targetDir = installDir();

if (fs::exists(targetDir) && !fs::is_empty(targetDir)) {
spdlog::debug("{} is already installed", name);
} else {
git2::Repository repo;
repo.clone(url, installDir.string());
repo.clone(url, targetDir.string());

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

const fs::path includeDir = installDir / "include";
const fs::path includeDir = targetDir / "include";
fs::path include;

if (fs::exists(includeDir) && fs::is_directory(includeDir)
&& !fs::is_empty(includeDir)) {
include = includeDir;
} else {
include = installDir;
include = targetDir;
}

return rs::Ok(CompilerOpts(CFlags({}, { IncludeDir{ include } }, {}),
Expand Down
18 changes: 17 additions & 1 deletion lib/Manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,23 @@ installDependencies(const Manifest& manifest, const bool includeDevDeps,
return std::visit(
Overloaded{
[&](const GitDependency& gitDep) -> rs::Result<void> {
installed.emplace_back(rs_try(gitDep.install()));
CompilerOpts depOpts = rs_try(gitDep.install());

const fs::path depManifestPath =
gitDep.installDir() / Manifest::FILE_NAME;
if (fs::exists(depManifestPath)) {
const Manifest depManifest =
rs_try(Manifest::tryParse(depManifestPath, false));

std::vector<CompilerOpts> nestedDeps;
rs_try(installDependencies(depManifest, includeDevDeps,
seenDeps, visited, nestedDeps));
for (const CompilerOpts& opts : nestedDeps) {
depOpts.merge(opts);
}
}

installed.emplace_back(std::move(depOpts));
return rs::Ok();
},
[&](const SystemDependency& sysDep) -> rs::Result<void> {
Expand Down
8 changes: 0 additions & 8 deletions rs-cpp/cabin.toml

This file was deleted.

7 changes: 0 additions & 7 deletions rs-cpp/include/rs.hpp

This file was deleted.

54 changes: 0 additions & 54 deletions rs-cpp/include/rs/result.hpp

This file was deleted.

Loading
Loading