Skip to content

Commit

Permalink
Aliases: removed (#1117)
Browse files Browse the repository at this point in the history
resolves #1027, resolves #1047
  • Loading branch information
ken-matsui authored Jan 22, 2025
1 parent d30eab6 commit 7d31d74
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 69 deletions.
2 changes: 1 addition & 1 deletion src/Algos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ findSimilarStr(

#ifdef CABIN_TEST

# include "Rustify/Aliases.hpp"
# include "Rustify/Tests.hpp"

# include <array>
Expand All @@ -202,6 +201,7 @@ findSimilarStr(
namespace tests {

using namespace cabin; // NOLINT(build/namespaces,google-build-using-namespace)
using std::string_view_literals::operator""sv;

static void
testLevDistance() {
Expand Down
6 changes: 4 additions & 2 deletions src/BuildConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ BuildConfig::mapHeaderToObj(
const fs::path& headerPath, const fs::path& buildOutPath
) const {
fs::path objBaseDir = fs::relative(
headerPath.parent_path(), manifest.path.parent_path() / "src"_path
headerPath.parent_path(), manifest.path.parent_path() / "src"
);
if (objBaseDir != ".") {
objBaseDir = buildOutPath / objBaseDir;
Expand Down Expand Up @@ -778,7 +778,7 @@ BuildConfig::processUnittestSrc(
parseMMOutput(Try(runMM(sourceFilePath, /*isTest=*/true)), objTarget);

const fs::path targetBaseDir = fs::relative(
sourceFilePath.parent_path(), manifest.path.parent_path() / "src"_path
sourceFilePath.parent_path(), manifest.path.parent_path() / "src"
);
fs::path testTargetBaseDir = unittestOutPath;
if (targetBaseDir != ".") {
Expand Down Expand Up @@ -1083,6 +1083,8 @@ getMakeCommand() {

#ifdef CABIN_TEST

# include "Rustify/Tests.hpp"

namespace tests {

using namespace cabin; // NOLINT(build/namespaces,google-build-using-namespace)
Expand Down
1 change: 0 additions & 1 deletion src/BuildConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "Command.hpp"
#include "Manifest.hpp"
#include "Rustify.hpp"

#include <cstdint>
#include <optional>
Expand Down
3 changes: 2 additions & 1 deletion src/Cli.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include "Logger.hpp"
#include "Rustify/Aliases.hpp"
#include "Rustify/Result.hpp"
#include "TermColor.hpp"

Expand Down Expand Up @@ -226,6 +225,8 @@ class Cli : public CliBase<Cli> {
std::forward_iterator auto& itr, const std::forward_iterator auto end,
std::string_view subcmd = ""
) {
using std::string_view_literals::operator""sv;

if (*itr == "-h"sv || *itr == "--help"sv) {
if (!subcmd.empty()) {
// {{ }} is a workaround for std::span until C++26.
Expand Down
16 changes: 8 additions & 8 deletions src/Cmd/New.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,25 @@ createTemplateFiles(const bool isBin, const std::string_view projectName) {
std::ofstream ofs;

if (isBin) {
fs::create_directories(projectName / "src"_path);
fs::create_directories(projectName / fs::path("src"));
Try(writeToFile(
ofs, projectName / "cabin.toml"_path, createCabinToml(projectName)
ofs, projectName / fs::path("cabin.toml"), createCabinToml(projectName)
));
Try(writeToFile(ofs, projectName / ".gitignore"_path, "/cabin-out"));
Try(writeToFile(ofs, projectName / "src"_path / "main.cc", MAIN_CC));
Try(writeToFile(ofs, projectName / fs::path(".gitignore"), "/cabin-out"));
Try(writeToFile(ofs, projectName / fs::path("src") / "main.cc", MAIN_CC));

logger::info("Created", "binary (application) `{}` package", projectName);
} else {
fs::create_directories(projectName / "include"_path / projectName);
fs::create_directories(projectName / fs::path("include") / projectName);
Try(writeToFile(
ofs, projectName / "cabin.toml"_path, createCabinToml(projectName)
ofs, projectName / fs::path("cabin.toml"), createCabinToml(projectName)
));
Try(writeToFile(
ofs, projectName / ".gitignore"_path, "/cabin-out\ncabin.lock"
ofs, projectName / fs::path(".gitignore"), "/cabin-out\ncabin.lock"
));
Try(writeToFile(
ofs,
(projectName / "include"_path / projectName / projectName).string()
(projectName / fs::path("include") / projectName / projectName).string()
+ ".hpp",
getHeader(projectName)
));
Expand Down
3 changes: 1 addition & 2 deletions src/Command.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "Command.hpp"

#include "Rustify/Aliases.hpp"
#include "Rustify/Result.hpp"

#include <algorithm>
Expand Down Expand Up @@ -206,7 +205,7 @@ Command::spawn() const noexcept {
_exit(1);
}

unreachable();
__builtin_unreachable();
} else {
// Parent process

Expand Down
3 changes: 1 addition & 2 deletions src/Git2/Exception.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include "../Rustify.hpp"

#include <exception>
#include <git2/errors.h>
#include <git2/version.h>
Expand Down Expand Up @@ -71,4 +69,5 @@ struct Exception final : public std::exception {
};

int git2Throw(int ret);

} // namespace git2
4 changes: 3 additions & 1 deletion src/Manifest.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include "Rustify/Aliases.hpp"
#include "Rustify/Result.hpp"
#include "Semver.hpp"
#include "VersionReq.hpp"
Expand All @@ -20,6 +19,9 @@

namespace cabin {

namespace fs = std::filesystem;
using std::string_view_literals::operator""sv;

struct Edition {
enum class Year : uint16_t {
Cpp98 = 1998,
Expand Down
5 changes: 0 additions & 5 deletions src/Rustify.hpp

This file was deleted.

43 changes: 0 additions & 43 deletions src/Rustify/Aliases.hpp

This file was deleted.

7 changes: 4 additions & 3 deletions src/VersionReq.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "VersionReq.hpp"

#include "Rustify/Aliases.hpp"
#include "Rustify/Result.hpp"

#include <cctype>
Expand Down Expand Up @@ -31,7 +30,7 @@ toString(const Comparator::Op op) noexcept {
case Comparator::Lte:
return "<=";
}
unreachable();
__builtin_unreachable();
}

struct ComparatorToken {
Expand Down Expand Up @@ -385,7 +384,7 @@ Comparator::satisfiedBy(const Version& ver) const noexcept {
case Op::Lte:
return matchesExact(*this, ver) || matchesLess(*this, ver);
}
unreachable();
__builtin_unreachable();
}

Comparator
Expand Down Expand Up @@ -895,6 +894,8 @@ operator<<(std::ostream& os, const VersionReq& req) {

namespace tests {

using std::string_literals::operator""s;

// Thanks to:
// https://github.com/dtolnay/semver/blob/b6171889ac7e8f47ec6f12003571bdcc7f737b10/tests/test_version_req.rs

Expand Down

0 comments on commit 7d31d74

Please sign in to comment.