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
9 changes: 1 addition & 8 deletions .clangd
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
CompileFlags:
CompilationDatabase: "build/Debug"

Index:
Background: Skip # Disables background indexing if it crashes during idle time

Diagnostics:
ClangTidy:
Remove: ["*"] # Disables Clang-Tidy checks if a specific rule causes the crash
CompilationDatabase: "build/Debug"
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
SHELL := /bin/zsh

.PHONY: build
.PHONY: test

config:
@cmake -S . -B build/Debug -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=23 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wconversion -Wshadow -fno-exceptions" -DCMAKE_TOOLCHAIN_FILE=deps/build/Debug/generators/conan_toolchain.cmake -DBUILD_TESTING=ON
@cmake -S . -B build/Debug -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=23 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wconversion -Wshadow -fno-exceptions $(CPPFLAGS)" -DCMAKE_EXE_LINKER_FLAGS="$(LDFLAGS)" -DCMAKE_TOOLCHAIN_FILE=deps/build/Debug/generators/conan_toolchain.cmake -DBUILD_TESTING=ON

config-rel:
@cmake -S . -B build/Release -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=23 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wconversion -Wshadow -fno-exceptions" -DCMAKE_TOOLCHAIN_FILE=deps/build/Release/generators/conan_toolchain.cmake -DBUILD_TESTING=ON
@cmake -S . -B build/Release -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=23 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wconversion -Wshadow -fno-exceptions $(CPPFLAGS)" -DCMAKE_EXE_LINKER_FLAGS="$(LDFLAGS)" -DCMAKE_TOOLCHAIN_FILE=deps/build/Release/generators/conan_toolchain.cmake -DBUILD_TESTING=ON

build:
@cmake --build build/Debug --parallel
Expand Down
22 changes: 21 additions & 1 deletion src/conan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ std::optional<std::string> install(const config::GojoConfig& cfg,
}
}

std::println(MAGENTA("Installing conan dependencies...\n"));
std::fflush(stdout);

constexpr std::string_view cmd_str {
"conan install . "
"--deployer=full_deploy "
Expand All @@ -240,6 +243,23 @@ std::optional<std::string> install(const config::GojoConfig& cfg,
"-s build_type={}"
};

std::string build_type {};
std::stringstream ss { cfg.dep_build_types };
while (std::getline(ss, build_type, ',')) {
const std::string cmd {
std::format(cmd_str, cfg.project_name, build_type)
};

std::filesystem::current_path(cfg.project_root);
auto result { utils::execute_command(cmd, !verbose) };
if (!result.success) {
return std::make_optional(
std::format("{}\nfailed to install conan dependencies",
result.output)
);
}
}
/*
// In order to download the packages in debug and release mode, we have
// to install two times, one for each build type.
// Kinda sucks...
Expand Down Expand Up @@ -269,7 +289,7 @@ std::optional<std::string> install(const config::GojoConfig& cfg,
rel_result.output)
);
}

*/
std::fflush(stdout);
std::println(
GREEN("\nDependencies installed successfully\n")
Expand Down
26 changes: 26 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ constexpr std::string_view GENERATOR { "generator" };
constexpr std::string_view MULTI_CONFIG { "multi-config generator" };
constexpr std::string_view BUILD_TYPE { "build type" };
constexpr std::string_view PKG_MAN { "package manager" };
constexpr std::string_view PKG_BUILD_TYPE { "dependency build types" };
constexpr std::string_view SRC_EXT { "source file extension" };
constexpr std::string_view HDR_EXT { "header file extension" };
constexpr std::string_view FMT_STYLE { "clang-format style" };
Expand Down Expand Up @@ -170,6 +171,10 @@ R"(---
# Options: none, conan, vcpkg
{}={}

# Options: Debug, Release, RelWithDebInfo, MinSizeRel
# Note: any of the above options can be combined in a comma separated list
{}={}

# Options (C): c
# Options (C++): cpp, cc, cxx, c++
{}={}
Expand Down Expand Up @@ -391,6 +396,25 @@ read_from_file(const std::filesystem::path& cfg_file) {
std::getline(ss, cfg.pkg_manager);
result = validate_config_values(label, cfg.pkg_manager, PKG_MANAGERS);
}
else if (label == PKG_BUILD_TYPE) {
if (cfg.pkg_manager == "none") {
cfg.dep_build_types = "";
continue;
}

std::getline(ss, cfg.dep_build_types);
if (cfg.dep_build_types.empty()) {
cfg.dep_build_types = "Debug,Release";
result.success = true;
}
else {
std::stringstream ss2 { cfg.dep_build_types };
std::string build_type {};
while (std::getline(ss2, build_type, ',')) {
result = validate_config_values(PKG_BUILD_TYPE, build_type, BUILD_TYPES);
}
}
}
else if (label == SRC_EXT) {
std::getline(ss, cfg.src_ext);
if (cfg.project_lang == "C++") {
Expand Down Expand Up @@ -514,6 +538,7 @@ std::optional<std::string> write_to_file(const GojoConfig& cfg,
MULTI_CONFIG, cfg.multi_config ? "true" : "false",
BUILD_TYPE, cfg.build_type,
PKG_MAN, cfg.pkg_manager,
PKG_BUILD_TYPE, cfg.dep_build_types,
SRC_EXT, cfg.src_ext,
HDR_EXT, cfg.hdr_ext,
FMT_STYLE, cfg.fmt_style,
Expand Down Expand Up @@ -566,6 +591,7 @@ create_template(const std::filesystem::path& project_root) {
MULTI_CONFIG, "",
BUILD_TYPE, "",
PKG_MAN, "",
PKG_BUILD_TYPE, "",
SRC_EXT, "",
HDR_EXT, "",
FMT_STYLE, "",
Expand Down
2 changes: 2 additions & 0 deletions src/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct GojoConfig {
std::string generator;
std::string build_type;
std::string pkg_manager;
std::string dep_build_types;
std::string src_ext;
std::string hdr_ext;
std::string fmt_style;
Expand Down Expand Up @@ -60,6 +61,7 @@ const GojoConfig DEFAULT = {
.generator = "system default",
.build_type = "Debug",
.pkg_manager = "none",
.dep_build_types = "",
.src_ext = "cpp",
.hdr_ext = "hpp",
.fmt_style = "google",
Expand Down
19 changes: 19 additions & 0 deletions src/gojo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "src/utils.hpp"


// TODO: Create system to modify files in place
constexpr std::string_view VERSION_STRING { "gojo version 1.0.0-beta" };

int main(const int argc, const char* argv[]) {
Expand Down Expand Up @@ -64,7 +65,25 @@ int main(const int argc, const char* argv[]) {
else if (command == "refresh") {
result = commands::refresh(args, std::nullopt);
}
else if (command == "dep") {
// TODO: Implement
// gojo dep search <pkg>
// gojo dep install <pkg> [version]
// gojo dep add <pkg> [version]
// gojo dep remove <pkg>
// gojo dep uninstall <pkg>
}
else if (command == "set") {
// TODO: Implement
// gojo set <config file field>
}
else if (command == "publish") {
// TODO: Implement
// gojo publish
}
else if (command == "install") {
// TODO: refactor
// gojo install . [--replace|-r]
result = commands::install(args);
}
else if (command == "profile") {
Expand Down
11 changes: 11 additions & 0 deletions src/literals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,17 @@ open source toolchains. Below is an explanation of each field:
package manager is used, this value is set to '{3}none{0}'. The command
{1}gojo{0} {4}install{0} has no effect if no package manager is used.

- {2}dependency build types{0}
This field determines the build type(s) that your dependendencies should
build with. If this field is left empty, and a package manager is being
used, the default value is '{3}Debug,Release{0}'. The value for this field
must be a comma separated list of one or more build types, the selection
being the same as the {2}build type{0} field. This is used to make
switching between build types easier - the dependencies are built with the
defined build_type(s) at installation time rather than when the project
switches its build type. Each dependency should be built with the same
build type as your project.

- {2}source file extension{0}
This field determines the file extension for C++ source code files. This
field is not used for C projects. This field is only used during project
Expand Down
Loading