From 1031d6676ed4478b95c4711c7d08f68149b97f01 Mon Sep 17 00:00:00 2001 From: CD Clark III Date: Thu, 20 Feb 2025 19:01:50 -0600 Subject: [PATCH 1/6] feat: added --root option to the install command. --root can be used to specify the install root. --- include/cppship/cmd/install.h | 4 +++- lib/cmd/install.cpp | 4 ++-- src/main.cpp | 10 ++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/cppship/cmd/install.h b/include/cppship/cmd/install.h index 0faaf10..ce37d5f 100644 --- a/include/cppship/cmd/install.h +++ b/include/cppship/cmd/install.h @@ -1,13 +1,15 @@ #pragma once #include "cppship/core/profile.h" +#include namespace cppship::cmd { struct InstallOptions { Profile profile = Profile::debug; + std::string root; }; int run_install(const InstallOptions& options); -} \ No newline at end of file +} diff --git a/lib/cmd/install.cpp b/lib/cmd/install.cpp index 975298f..17e1f29 100644 --- a/lib/cmd/install.cpp +++ b/lib/cmd/install.cpp @@ -32,9 +32,9 @@ int cmd::run_install([[maybe_unused]] const InstallOptions& options) return EXIT_SUCCESS; } - const auto dst = fmt::format("/usr/local/bin/{}", manifest.name()); + const auto dst = fmt::format("{}/bin/{}", options.root, manifest.name()); status("install", "{} to {}", bin_file.string(), dst); fs::copy_file(bin_file, dst, fs::copy_options::overwrite_existing); return EXIT_SUCCESS; #endif -} \ No newline at end of file +} diff --git a/src/main.cpp b/src/main.cpp index c6d83cd..e94369e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,9 +159,7 @@ std::list build_commands(const ArgumentParser& common) // install auto& install = commands.emplace_back("install", common, [](const ArgumentParser& cmd) { - return cmd::run_install({ - .profile = parse_profile(cmd.get("--profile")), - }); + return cmd::run_install({ .profile = parse_profile(cmd.get("--profile")), .root = cmd.get("--root") }); }); install.parser.add_description("install binary if exists"); @@ -169,6 +167,10 @@ std::list build_commands(const ArgumentParser& common) .help("build with specific profile") .metavar("profile") .default_value(std::string { kProfileRelease }); + install.parser.add_argument("--root") + .help("specify the installation root") + .metavar("root") + .default_value(std::string { "/usr/local" }); // run auto& run = commands.emplace_back("run", common, [](const ArgumentParser& cmd) { @@ -322,4 +324,4 @@ try { } catch (const std::exception& e) { error("unknown error {}", e.what()); return EXIT_FAILURE; -} \ No newline at end of file +} From fa44969b4cf0b782463d463918765d266d5ee1be Mon Sep 17 00:00:00 2001 From: CD Clark III Date: Sun, 23 Mar 2025 12:28:04 -0500 Subject: [PATCH 2/6] feat(install): create parent directories for exec install path The create_if_not_exist(...) function will now create parent directories if they do not exists. Added call to create_if_not_exists(...) when installing executable. --- include/cppship/util/fs.h | 9 +-------- lib/cmd/install.cpp | 7 +++++-- lib/util/fs.cpp | 14 ++++++++++++++ tests/util/fs.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 lib/util/fs.cpp diff --git a/include/cppship/util/fs.h b/include/cppship/util/fs.h index 8ee1f64..70a4cb5 100644 --- a/include/cppship/util/fs.h +++ b/include/cppship/util/fs.h @@ -27,13 +27,6 @@ class ScopedCurrentDir { fs::path mPrevCwd; }; -inline void create_if_not_exist(const fs::path& path) -{ - if (fs::exists(path)) { - return; - } +void create_if_not_exist(const fs::path& path); - fs::create_directory(path); } - -} \ No newline at end of file diff --git a/lib/cmd/install.cpp b/lib/cmd/install.cpp index 17e1f29..a09c9c2 100644 --- a/lib/cmd/install.cpp +++ b/lib/cmd/install.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -32,8 +33,10 @@ int cmd::run_install([[maybe_unused]] const InstallOptions& options) return EXIT_SUCCESS; } - const auto dst = fmt::format("{}/bin/{}", options.root, manifest.name()); - status("install", "{} to {}", bin_file.string(), dst); + const auto root = fs::path(options.root); + const auto dst = root / "bin" / manifest.name(); + cppship::create_if_not_exist(dst.parent_path()); + status("install", "{} to {}", bin_file.string(), dst.string()); fs::copy_file(bin_file, dst, fs::copy_options::overwrite_existing); return EXIT_SUCCESS; #endif diff --git a/lib/util/fs.cpp b/lib/util/fs.cpp new file mode 100644 index 0000000..2b3b895 --- /dev/null +++ b/lib/util/fs.cpp @@ -0,0 +1,14 @@ +#include "cppship/util/fs.h" + +void cppship::create_if_not_exist(const fs::path& path) +{ + if (fs::exists(path)) { + return; + } + + if (path.has_parent_path()) { + create_if_not_exist(path.parent_path()); + } + + fs::create_directory(path); +} diff --git a/tests/util/fs.cpp b/tests/util/fs.cpp index 11b4d24..309f55c 100644 --- a/tests/util/fs.cpp +++ b/tests/util/fs.cpp @@ -1,4 +1,6 @@ +#include #include +#include #include "cppship/util/fs.h" @@ -16,4 +18,39 @@ TEST(fs, ScopedCurrentDir) } EXPECT_EQ(fs::current_path(), cwd); -} \ No newline at end of file +} + +TEST(fs, CreateIfNotExist) +{ + const auto tmpdir = fs::temp_directory_path(); + const auto testdir = fs::path("cppship-unitests"); + + ScopedCurrentDir guard(tmpdir); + + if (fs::exists(testdir)) { + fs::remove_all(testdir); + } + fs::create_directory(testdir); + + { + ScopedCurrentDir guard2(testdir); + const auto newdir = fs::path("subdir1"); + EXPECT_FALSE(fs::exists(newdir)); + cppship::create_if_not_exist(newdir); + EXPECT_TRUE(fs::exists(newdir)); + } + { + ScopedCurrentDir guard2(testdir); + const auto newdir = fs::path("./subdir2/subsubdir1"); + EXPECT_FALSE(fs::exists(newdir)); + cppship::create_if_not_exist(newdir); + EXPECT_TRUE(fs::exists(newdir)); + } + { + ScopedCurrentDir guard2(testdir); + const auto newdir = fs::path("subdir3/subsubdir1/subsubsubdir1"); + EXPECT_FALSE(fs::exists(newdir)); + cppship::create_if_not_exist(newdir); + EXPECT_TRUE(fs::exists(newdir)); + } +} From 9e3a61752814c4b48e593547fd76098bda3caa3d Mon Sep 17 00:00:00 2001 From: CD Clark III Date: Sun, 23 Mar 2025 12:53:16 -0500 Subject: [PATCH 3/6] feat(install): default installs to .cppship dir to squash --- include/cppship/util/fs.h | 3 +++ lib/util/fs.cpp | 3 +++ src/main.cpp | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/cppship/util/fs.h b/include/cppship/util/fs.h index 70a4cb5..c6822b8 100644 --- a/include/cppship/util/fs.h +++ b/include/cppship/util/fs.h @@ -29,4 +29,7 @@ class ScopedCurrentDir { void create_if_not_exist(const fs::path& path); +inline constexpr std::string_view kCppShipDirName = ".cppship"; +fs::path get_cppship_dir(); + } diff --git a/lib/util/fs.cpp b/lib/util/fs.cpp index 2b3b895..fb1c4c2 100644 --- a/lib/util/fs.cpp +++ b/lib/util/fs.cpp @@ -1,4 +1,5 @@ #include "cppship/util/fs.h" +#include void cppship::create_if_not_exist(const fs::path& path) { @@ -12,3 +13,5 @@ void cppship::create_if_not_exist(const fs::path& path) fs::create_directory(path); } + +fs::path cppship::get_cppship_dir() { return fs::path(std::getenv("HOME")) / kCppShipDirName; } diff --git a/src/main.cpp b/src/main.cpp index e94369e..c1f60bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,7 @@ #include "cppship/cppship.h" #include "cppship/exception.h" +#include "cppship/util/fs.h" #include "cppship/util/log.h" #ifndef CPPSHIP_VERSION @@ -170,7 +171,7 @@ std::list build_commands(const ArgumentParser& common) install.parser.add_argument("--root") .help("specify the installation root") .metavar("root") - .default_value(std::string { "/usr/local" }); + .default_value(get_cppship_dir().string()); // run auto& run = commands.emplace_back("run", common, [](const ArgumentParser& cmd) { From 2fd4a0c53670c8cad8442fac2a9489d127553173 Mon Sep 17 00:00:00 2001 From: CD Clark III Date: Sat, 29 Mar 2025 10:29:06 -0400 Subject: [PATCH 4/6] remove unused include --- include/cppship/cmd/install.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/cppship/cmd/install.h b/include/cppship/cmd/install.h index ce37d5f..ba1ea57 100644 --- a/include/cppship/cmd/install.h +++ b/include/cppship/cmd/install.h @@ -1,7 +1,6 @@ #pragma once #include "cppship/core/profile.h" -#include namespace cppship::cmd { From a541de5b956ff5f4b094721b7be7e80b47cc414f Mon Sep 17 00:00:00 2001 From: CD Clark III Date: Sat, 29 Mar 2025 21:52:58 -0400 Subject: [PATCH 5/6] fixes for PR review --- lib/cmd/install.cpp | 5 +---- lib/util/fs.cpp | 8 ++------ src/main.cpp | 5 ++++- tests/util/fs.cpp | 2 -- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/cmd/install.cpp b/lib/cmd/install.cpp index a09c9c2..78b839f 100644 --- a/lib/cmd/install.cpp +++ b/lib/cmd/install.cpp @@ -1,6 +1,4 @@ #include -#include -#include #include #include @@ -10,7 +8,6 @@ #include "cppship/core/manifest.h" #include "cppship/util/fs.h" #include "cppship/util/log.h" -#include "cppship/util/repo.h" using namespace cppship; @@ -35,7 +32,7 @@ int cmd::run_install([[maybe_unused]] const InstallOptions& options) const auto root = fs::path(options.root); const auto dst = root / "bin" / manifest.name(); - cppship::create_if_not_exist(dst.parent_path()); + create_if_not_exist(dst.parent_path()); status("install", "{} to {}", bin_file.string(), dst.string()); fs::copy_file(bin_file, dst, fs::copy_options::overwrite_existing); return EXIT_SUCCESS; diff --git a/lib/util/fs.cpp b/lib/util/fs.cpp index fb1c4c2..58e50bd 100644 --- a/lib/util/fs.cpp +++ b/lib/util/fs.cpp @@ -1,17 +1,13 @@ #include "cppship/util/fs.h" #include +#include void cppship::create_if_not_exist(const fs::path& path) { if (fs::exists(path)) { return; } - - if (path.has_parent_path()) { - create_if_not_exist(path.parent_path()); - } - - fs::create_directory(path); + fs::create_directories(path); } fs::path cppship::get_cppship_dir() { return fs::path(std::getenv("HOME")) / kCppShipDirName; } diff --git a/src/main.cpp b/src/main.cpp index c1f60bf..a84f17d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -160,7 +160,10 @@ std::list build_commands(const ArgumentParser& common) // install auto& install = commands.emplace_back("install", common, [](const ArgumentParser& cmd) { - return cmd::run_install({ .profile = parse_profile(cmd.get("--profile")), .root = cmd.get("--root") }); + return cmd::run_install({ + .profile = parse_profile(cmd.get("--profile")), + .root = cmd.get("--root"), + }); }); install.parser.add_description("install binary if exists"); diff --git a/tests/util/fs.cpp b/tests/util/fs.cpp index 309f55c..f991229 100644 --- a/tests/util/fs.cpp +++ b/tests/util/fs.cpp @@ -1,6 +1,4 @@ -#include #include -#include #include "cppship/util/fs.h" From 4f940a40aedebdc91a37e945a773acc903be686a Mon Sep 17 00:00:00 2001 From: CD Clark III Date: Fri, 18 Apr 2025 19:33:06 -0500 Subject: [PATCH 6/6] style: ran cppship fmt with llvm 19.1.7 --- include/cppship/cmake/bin.h | 2 +- include/cppship/cmake/dep.h | 6 +-- include/cppship/cmake/dependency_injector.h | 2 +- include/cppship/cmake/generator.h | 2 +- include/cppship/cmake/lib.h | 2 +- include/cppship/cmake/msvc.h | 2 +- include/cppship/cmake/package_configurer.h | 6 +-- include/cppship/cmd/build.h | 2 +- include/cppship/cmd/cmake.h | 2 +- include/cppship/cmd/init.h | 2 +- include/cppship/core/dependency.h | 2 +- include/cppship/core/manifest.h | 2 +- include/cppship/core/profile.h | 2 +- include/cppship/core/resolver.h | 11 ++--- include/cppship/util/assert.h | 2 +- include/cppship/util/io.h | 2 +- lib/cmake/generator.cpp | 19 ++++----- lib/cmake/msvc.cpp | 5 ++- lib/cmake/package_configurer.cpp | 13 +++--- lib/cmd/bench.cpp | 5 ++- lib/cmd/build.cpp | 45 ++++++++++++--------- lib/cmd/cmake.cpp | 8 ++-- lib/cmd/fmt.cpp | 2 +- lib/cmd/install.cpp | 3 +- lib/cmd/lint.cpp | 2 +- lib/cmd/run.cpp | 5 ++- lib/cmd/test.cpp | 5 ++- lib/core/compiler.cpp | 5 ++- lib/core/dependency.cpp | 7 ++-- lib/core/resolver.cpp | 11 ++--- lib/util/fs.cpp | 1 + tests/cmake/package_configurer.cpp | 20 +++++---- tests/util/fs.cpp | 4 +- 33 files changed, 119 insertions(+), 90 deletions(-) diff --git a/include/cppship/cmake/bin.h b/include/cppship/cmake/bin.h index f78ffff..c3dad68 100644 --- a/include/cppship/cmake/bin.h +++ b/include/cppship/cmake/bin.h @@ -30,4 +30,4 @@ class CmakeBin { BinDesc mDesc; }; -} \ No newline at end of file +} diff --git a/include/cppship/cmake/dep.h b/include/cppship/cmake/dep.h index 190a3d7..789f65c 100644 --- a/include/cppship/cmake/dep.h +++ b/include/cppship/cmake/dep.h @@ -1,10 +1,10 @@ #pragma once -#include "cppship/core/dependency.h" - #include #include +#include "cppship/core/dependency.h" + namespace cppship::cmake { struct Dep { @@ -16,4 +16,4 @@ struct Dep { std::vector resolve_deps( const std::vector& declared_deps, const ResolvedDependencies& resolved); -} \ No newline at end of file +} diff --git a/include/cppship/cmake/dependency_injector.h b/include/cppship/cmake/dependency_injector.h index b46b0d4..83d8ea4 100644 --- a/include/cppship/cmake/dependency_injector.h +++ b/include/cppship/cmake/dependency_injector.h @@ -39,4 +39,4 @@ class CmakeDependencyInjector : public DependencyInjector { ResolvedDependencies mAllDeps; }; -} \ No newline at end of file +} diff --git a/include/cppship/cmake/generator.h b/include/cppship/cmake/generator.h index ff04665..a7aae79 100644 --- a/include/cppship/cmake/generator.h +++ b/include/cppship/cmake/generator.h @@ -71,4 +71,4 @@ class CmakeGenerator { std::set mTestTargets; }; -} \ No newline at end of file +} diff --git a/include/cppship/cmake/lib.h b/include/cppship/cmake/lib.h index 2e9205d..7d10bdc 100644 --- a/include/cppship/cmake/lib.h +++ b/include/cppship/cmake/lib.h @@ -38,4 +38,4 @@ class CmakeLib { std::vector mDefinitions; }; -} \ No newline at end of file +} diff --git a/include/cppship/cmake/msvc.h b/include/cppship/cmake/msvc.h index fcf34f8..a3c1c3c 100644 --- a/include/cppship/cmake/msvc.h +++ b/include/cppship/cmake/msvc.h @@ -9,4 +9,4 @@ namespace cppship::msvc { // msvc generator has different binary path, fix it fs::path fix_bin_path(const cppship::cmd::BuildContext& ctx, std::string_view bin); -} \ No newline at end of file +} diff --git a/include/cppship/cmake/package_configurer.h b/include/cppship/cmake/package_configurer.h index 211abb1..b0b0081 100644 --- a/include/cppship/cmake/package_configurer.h +++ b/include/cppship/cmake/package_configurer.h @@ -1,9 +1,9 @@ #pragma once -#include "cppship/core/dependency.h" - #include +#include "cppship/core/dependency.h" + namespace cppship::cmake { struct ConfigOptions { @@ -17,4 +17,4 @@ struct ConfigOptions { void config_packages( const ResolvedDependencies& cppship_deps, const ResolvedDependencies& all_deps, const ConfigOptions& options); -} \ No newline at end of file +} diff --git a/include/cppship/cmd/build.h b/include/cppship/cmd/build.h index 9f47947..3b980a4 100644 --- a/include/cppship/cmd/build.h +++ b/include/cppship/cmd/build.h @@ -72,4 +72,4 @@ void cmake_setup(const BuildContext& ctx); int cmake_build(const BuildContext& ctx, const BuildOptions& options); -} \ No newline at end of file +} diff --git a/include/cppship/cmd/cmake.h b/include/cppship/cmd/cmake.h index fb44b46..85da0ed 100644 --- a/include/cppship/cmd/cmake.h +++ b/include/cppship/cmd/cmake.h @@ -6,4 +6,4 @@ struct CmakeOptions { }; int run_cmake(const CmakeOptions& options); -} \ No newline at end of file +} diff --git a/include/cppship/cmd/init.h b/include/cppship/cmd/init.h index 65410c8..fa557b8 100644 --- a/include/cppship/cmd/init.h +++ b/include/cppship/cmd/init.h @@ -18,4 +18,4 @@ struct InitOptions { int run_init(const InitOptions& options); -} \ No newline at end of file +} diff --git a/include/cppship/core/dependency.h b/include/cppship/core/dependency.h index f493e2d..60d39d2 100644 --- a/include/cppship/core/dependency.h +++ b/include/cppship/core/dependency.h @@ -4,13 +4,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include "cppship/util/assert.h" #include "cppship/util/fs.h" diff --git a/include/cppship/core/manifest.h b/include/cppship/core/manifest.h index 9c658c7..8d9fa22 100644 --- a/include/cppship/core/manifest.h +++ b/include/cppship/core/manifest.h @@ -63,4 +63,4 @@ class Manifest { void generate_manifest(std::string_view name, CxxStd std, const fs::path& dir); -} \ No newline at end of file +} diff --git a/include/cppship/core/profile.h b/include/cppship/core/profile.h index 9458b4e..768b0f1 100644 --- a/include/cppship/core/profile.h +++ b/include/cppship/core/profile.h @@ -72,4 +72,4 @@ struct ProfileOptions { std::vector conditional_configs; }; -} \ No newline at end of file +} diff --git a/include/cppship/core/resolver.h b/include/cppship/core/resolver.h index 696b03f..92a8804 100644 --- a/include/cppship/core/resolver.h +++ b/include/cppship/core/resolver.h @@ -1,14 +1,15 @@ #pragma once -#include "cppship/core/dependency.h" -#include "cppship/core/manifest.h" - #include -#include #include #include #include +#include + +#include "cppship/core/dependency.h" +#include "cppship/core/manifest.h" + namespace cppship { struct ResolveResult { @@ -45,4 +46,4 @@ class Resolver { std::set mPackageSeen; }; -} \ No newline at end of file +} diff --git a/include/cppship/util/assert.h b/include/cppship/util/assert.h index d4ca947..80f778f 100644 --- a/include/cppship/util/assert.h +++ b/include/cppship/util/assert.h @@ -15,4 +15,4 @@ inline void enforce(bool expr, std::string_view msg) } } -} \ No newline at end of file +} diff --git a/include/cppship/util/io.h b/include/cppship/util/io.h index fb105b1..cda2028 100644 --- a/include/cppship/util/io.h +++ b/include/cppship/util/io.h @@ -12,4 +12,4 @@ std::string read_as_string(const fs::path& file); std::string read_as_string(std::istream& iss); -} \ No newline at end of file +} diff --git a/lib/cmake/generator.cpp b/lib/cmake/generator.cpp index 1f4aed5..ec20409 100644 --- a/lib/cmake/generator.cpp +++ b/lib/cmake/generator.cpp @@ -1,12 +1,4 @@ #include "cppship/cmake/generator.h" -#include "cppship/cmake/bin.h" -#include "cppship/cmake/cfg_predicate.h" -#include "cppship/cmake/dep.h" -#include "cppship/cmake/group.h" -#include "cppship/cmake/lib.h" -#include "cppship/cmake/naming.h" -#include "cppship/core/manifest.h" -#include "cppship/exception.h" #include #include @@ -19,6 +11,15 @@ #include #include +#include "cppship/cmake/bin.h" +#include "cppship/cmake/cfg_predicate.h" +#include "cppship/cmake/dep.h" +#include "cppship/cmake/group.h" +#include "cppship/cmake/lib.h" +#include "cppship/cmake/naming.h" +#include "cppship/core/manifest.h" +#include "cppship/exception.h" + using namespace ranges::views; using namespace cppship; @@ -460,4 +461,4 @@ void CmakeGenerator::fill_profile_(Profile profile) appender.output(profile_str, config, "\t"); mOut << "endif()\n\n"; } -} \ No newline at end of file +} diff --git a/lib/cmake/msvc.cpp b/lib/cmake/msvc.cpp index 41917e2..2f8ef75 100644 --- a/lib/cmake/msvc.cpp +++ b/lib/cmake/msvc.cpp @@ -1,8 +1,9 @@ #include "cppship/cmake/msvc.h" -#include "cppship/util/io.h" #include +#include "cppship/util/io.h" + using namespace cppship; fs::path msvc::fix_bin_path(const cppship::cmd::BuildContext& ctx, std::string_view bin) @@ -13,4 +14,4 @@ fs::path msvc::fix_bin_path(const cppship::cmd::BuildContext& ctx, std::string_v } return bin; -} \ No newline at end of file +} diff --git a/lib/cmake/package_configurer.cpp b/lib/cmake/package_configurer.cpp index 9d40a95..dbe4df4 100644 --- a/lib/cmake/package_configurer.cpp +++ b/lib/cmake/package_configurer.cpp @@ -1,13 +1,14 @@ #include "cppship/cmake/package_configurer.h" + +#include +#include + #include "cppship/cmake/lib.h" #include "cppship/core/layout.h" #include "cppship/core/manifest.h" #include "cppship/util/io.h" #include "cppship/util/repo.h" -#include -#include - using namespace cppship; using namespace fmt::literals; @@ -27,7 +28,9 @@ void cmake::config_packages( add_library({target} INTERFACE IMPORTED) target_include_directories({target} INTERFACE {cmake_deps_dir}/{package}/include) )", - "target"_a = cmake_target, "package"_a = dep.package, "cmake_deps_dir"_a = options.cmake_deps_dir)); + "target"_a = cmake_target, + "package"_a = dep.package, + "cmake_deps_dir"_a = options.cmake_deps_dir)); continue; } @@ -56,4 +59,4 @@ target_include_directories({target} INTERFACE {cmake_deps_dir}/{package}/include write(package_cmake_config_file, content); } -} \ No newline at end of file +} diff --git a/lib/cmd/bench.cpp b/lib/cmd/bench.cpp index 3ba0843..092bab8 100644 --- a/lib/cmd/bench.cpp +++ b/lib/cmd/bench.cpp @@ -1,3 +1,5 @@ +#include "cppship/cmd/bench.h" + #include #include @@ -8,7 +10,6 @@ #include "cppship/cmake/msvc.h" #include "cppship/cmake/naming.h" -#include "cppship/cmd/bench.h" #include "cppship/cmd/build.h" #include "cppship/core/manifest.h" #include "cppship/util/fs.h" @@ -64,4 +65,4 @@ int cmd::run_bench(const BenchOptions& options) } return result; -} \ No newline at end of file +} diff --git a/lib/cmd/build.cpp b/lib/cmd/build.cpp index 0c22776..af28f47 100644 --- a/lib/cmd/build.cpp +++ b/lib/cmd/build.cpp @@ -1,16 +1,4 @@ #include "cppship/cmd/build.h" -#include "cppship/cmake/generator.h" -#include "cppship/cmake/group.h" -#include "cppship/cmake/package_configurer.h" -#include "cppship/core/compiler.h" -#include "cppship/core/dependency.h" -#include "cppship/core/resolver.h" -#include "cppship/exception.h" -#include "cppship/util/cmd.h" -#include "cppship/util/fs.h" -#include "cppship/util/git.h" -#include "cppship/util/io.h" -#include "cppship/util/log.h" #include #include @@ -29,6 +17,19 @@ #include #include +#include "cppship/cmake/generator.h" +#include "cppship/cmake/group.h" +#include "cppship/cmake/package_configurer.h" +#include "cppship/core/compiler.h" +#include "cppship/core/dependency.h" +#include "cppship/core/resolver.h" +#include "cppship/exception.h" +#include "cppship/util/cmd.h" +#include "cppship/util/fs.h" +#include "cppship/util/git.h" +#include "cppship/util/io.h" +#include "cppship/util/log.h" + using namespace cppship; using namespace boost::process; using namespace fmt::literals; @@ -181,8 +182,10 @@ void cmd::conan_install(const BuildContext& ctx) return; } - const auto cmd = fmt::format("conan install {} -of {}/conan -pr {} --build=missing", ctx.build_dir.string(), - ctx.profile_dir.string(), ctx.conan_profile_path.string()); + const auto cmd = fmt::format("conan install {} -of {}/conan -pr {} --build=missing", + ctx.build_dir.string(), + ctx.profile_dir.string(), + ctx.conan_profile_path.string()); status("dependency", "install dependencies: {}", cmd); int res = run_cmd(cmd); @@ -233,7 +236,8 @@ void cmd::cmake_setup(const BuildContext& ctx) const auto result = std::move(resolver).resolve(); ResolvedDependencies deps = toml::get(toml::parse(ctx.dependency_file)); - CmakeGenerator gen(&ctx.layout, ctx.manifest, + CmakeGenerator gen(&ctx.layout, + ctx.manifest, GeneratorOptions { .deps = cmake::resolve_deps(result.dependencies, deps), .dev_deps = cmake::resolve_deps(result.dev_dependencies, deps), @@ -242,7 +246,10 @@ void cmd::cmake_setup(const BuildContext& ctx) const std::string cmd = fmt::format("cmake -B {} -S build -DCMAKE_BUILD_TYPE={} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON " "-DCONAN_GENERATORS_FOLDER={} -DCPPSHIP_DEPS_DIR={}", - ctx.profile_dir.string(), ctx.profile, (ctx.profile_dir / "conan").string(), ctx.deps_dir.string()); + ctx.profile_dir.string(), + ctx.profile, + (ctx.profile_dir / "conan").string(), + ctx.deps_dir.string()); status("config", "config cmake: {}", cmd); const int res = run_cmd(cmd); @@ -291,7 +298,9 @@ std::string_view to_cmake_group(cmd::BuildGroup group, const std::string_view li int cmd::cmake_build(const BuildContext& ctx, const BuildOptions& options) { - auto cmd = fmt::format("cmake --build {} -j {} --config {}", ctx.profile_dir.string(), options.max_concurrency, + auto cmd = fmt::format("cmake --build {} -j {} --config {}", + ctx.profile_dir.string(), + options.max_concurrency, to_string(options.profile)); if (options.target) { cmd += fmt::format(" --target {}", *options.target); @@ -305,4 +314,4 @@ int cmd::cmake_build(const BuildContext& ctx, const BuildOptions& options) status("build", "{}", cmd); return run_cmd(cmd); -} \ No newline at end of file +} diff --git a/lib/cmd/cmake.cpp b/lib/cmd/cmake.cpp index 620673a..7c7cf98 100644 --- a/lib/cmd/cmake.cpp +++ b/lib/cmd/cmake.cpp @@ -1,3 +1,5 @@ +#include "cppship/cmd/cmake.h" + #include #include @@ -6,7 +8,6 @@ #include "cppship/cmake/generator.h" #include "cppship/cmd/build.h" -#include "cppship/cmd/cmake.h" #include "cppship/core/resolver.h" #include "cppship/util/io.h" #include "cppship/util/log.h" @@ -30,7 +31,8 @@ int cmd::run_cmake(const CmakeOptions&) ResolvedDependencies deps = toml::get(toml::parse(ctx.dependency_file)); const auto declared_deps = concat(result.dependencies, result.dev_dependencies) | ranges::to(); - CmakeGenerator gen(&ctx.layout, ctx.manifest, + CmakeGenerator gen(&ctx.layout, + ctx.manifest, GeneratorOptions { .deps = cmake::resolve_deps(result.dependencies, deps), .dev_deps = cmake::resolve_deps(result.dev_dependencies, deps), @@ -45,4 +47,4 @@ int cmd::run_cmake(const CmakeOptions&) fs::copy_file(ctx.conan_file, ctx.root / "conanfile.txt", fs::copy_options::overwrite_existing); return 0; -} \ No newline at end of file +} diff --git a/lib/cmd/fmt.cpp b/lib/cmd/fmt.cpp index 557ce2c..d6e0d5b 100644 --- a/lib/cmd/fmt.cpp +++ b/lib/cmd/fmt.cpp @@ -41,4 +41,4 @@ int cmd::run_fmt(const FmtOptions& options) } return exit_code; -} \ No newline at end of file +} diff --git a/lib/cmd/install.cpp b/lib/cmd/install.cpp index 78b839f..af002af 100644 --- a/lib/cmd/install.cpp +++ b/lib/cmd/install.cpp @@ -1,10 +1,11 @@ +#include "cppship/cmd/install.h" + #include #include #include #include "cppship/cmd/build.h" -#include "cppship/cmd/install.h" #include "cppship/core/manifest.h" #include "cppship/util/fs.h" #include "cppship/util/log.h" diff --git a/lib/cmd/lint.cpp b/lib/cmd/lint.cpp index e78bbc0..5bd84ed 100644 --- a/lib/cmd/lint.cpp +++ b/lib/cmd/lint.cpp @@ -50,4 +50,4 @@ int cmd::run_lint(const LintOptions& options) pool.wait_for_tasks(); return ranges::any_of(tasks, [](auto& fut) { return fut.get() != 0; }) ? EXIT_FAILURE : EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/lib/cmd/run.cpp b/lib/cmd/run.cpp index bae6dd6..36e5221 100644 --- a/lib/cmd/run.cpp +++ b/lib/cmd/run.cpp @@ -1,3 +1,5 @@ +#include "cppship/cmd/run.h" + #include #include @@ -7,7 +9,6 @@ #include "cppship/cmake/msvc.h" #include "cppship/cmake/naming.h" #include "cppship/cmd/build.h" -#include "cppship/cmd/run.h" #include "cppship/core/manifest.h" #include "cppship/util/cmd.h" #include "cppship/util/fs.h" @@ -79,4 +80,4 @@ int cmd::run_run(const RunOptions& options) const auto cmd = fmt::format("{} {}", bin_file.string(), options.args); status("run", "{}", cmd); return boost::process::system(cmd); -} \ No newline at end of file +} diff --git a/lib/cmd/test.cpp b/lib/cmd/test.cpp index e5732da..76f195a 100644 --- a/lib/cmd/test.cpp +++ b/lib/cmd/test.cpp @@ -1,3 +1,5 @@ +#include "cppship/cmd/test.h" + #include #include @@ -6,7 +8,6 @@ #include "cppship/cmake/naming.h" #include "cppship/cmd/build.h" -#include "cppship/cmd/test.h" #include "cppship/util/fs.h" #include "cppship/util/log.h" @@ -45,4 +46,4 @@ int cmd::run_test(const TestOptions& options) status("test", "{}", cmd); return boost::process::system(cmd, boost::process::shell); -} \ No newline at end of file +} diff --git a/lib/core/compiler.cpp b/lib/core/compiler.cpp index 29b6730..d85338f 100644 --- a/lib/core/compiler.cpp +++ b/lib/core/compiler.cpp @@ -1,5 +1,4 @@ #include "cppship/core/compiler.h" -#include "cppship/util/cmd.h" #include #include @@ -8,6 +7,8 @@ #include +#include "cppship/util/cmd.h" + using namespace std::literals; using namespace cppship; using namespace cppship::compiler; @@ -113,4 +114,4 @@ CompilerInfo::CompilerInfo() mId = get_compiler_id(out); mLibCxx = get_libcxx(mId); -} \ No newline at end of file +} diff --git a/lib/core/dependency.cpp b/lib/core/dependency.cpp index 20ef669..e42eaa1 100644 --- a/lib/core/dependency.cpp +++ b/lib/core/dependency.cpp @@ -1,9 +1,10 @@ #include "cppship/core/dependency.h" -#include "cppship/exception.h" -#include "cppship/util/string.h" #include +#include "cppship/exception.h" +#include "cppship/util/string.h" + using namespace cppship; namespace { @@ -95,4 +96,4 @@ ResolvedDependencies cppship::collect_conan_deps(const fs::path& conan_dep_dir, } return deps; -} \ No newline at end of file +} diff --git a/lib/core/resolver.cpp b/lib/core/resolver.cpp index 485a1ca..8244b37 100644 --- a/lib/core/resolver.cpp +++ b/lib/core/resolver.cpp @@ -1,13 +1,14 @@ #include "cppship/core/resolver.h" -#include "cppship/core/manifest.h" -#include "cppship/util/io.h" -#include "cppship/util/log.h" -#include "cppship/util/repo.h" #include #include #include +#include "cppship/core/manifest.h" +#include "cppship/util/io.h" +#include "cppship/util/log.h" +#include "cppship/util/repo.h" + using namespace cppship; using namespace fmt::literals; @@ -138,4 +139,4 @@ void Resolver::resolve_package_(std::string_view package, const fs::path& packag mUnresolved.push(sub_dep); } -} \ No newline at end of file +} diff --git a/lib/util/fs.cpp b/lib/util/fs.cpp index 58e50bd..07ff415 100644 --- a/lib/util/fs.cpp +++ b/lib/util/fs.cpp @@ -1,4 +1,5 @@ #include "cppship/util/fs.h" + #include #include diff --git a/tests/cmake/package_configurer.cpp b/tests/cmake/package_configurer.cpp index cac96d7..4045961 100644 --- a/tests/cmake/package_configurer.cpp +++ b/tests/cmake/package_configurer.cpp @@ -1,8 +1,4 @@ #include "cppship/cmake/package_configurer.h" -#include "cppship/core/dependency.h" -#include "cppship/util/fs.h" -#include "cppship/util/io.h" -#include "cppship/util/repo.h" #include @@ -10,6 +6,11 @@ #include #include +#include "cppship/core/dependency.h" +#include "cppship/util/fs.h" +#include "cppship/util/io.h" +#include "cppship/util/repo.h" + using namespace cppship; using namespace std::string_literals; @@ -33,7 +34,8 @@ TEST(package_configurer, HeaderOnly) }, } }; - cmake::config_packages(deps, deps, + cmake::config_packages(deps, + deps, { .deps_dir = deps_dir, .post_process @@ -81,7 +83,8 @@ fmt = "9.1.0" .cmake_target = "fmt::fmt", }); - cmake::config_packages(deps, all_deps, + cmake::config_packages(deps, + all_deps, { .deps_dir = deps_dir, .post_process @@ -142,7 +145,8 @@ fmt = "9.1.0" .cmake_target = "fmt::fmt", }); - cmake::config_packages(deps, all_deps, + cmake::config_packages(deps, + all_deps, { .deps_dir = deps_dir, .post_process @@ -163,4 +167,4 @@ target_link_libraries(test_pack_lib PUBLIC fmt::fmt) add_library(cppship::test_pack ALIAS test_pack_lib) )"); -} \ No newline at end of file +} diff --git a/tests/util/fs.cpp b/tests/util/fs.cpp index f991229..3cc3f87 100644 --- a/tests/util/fs.cpp +++ b/tests/util/fs.cpp @@ -1,7 +1,7 @@ -#include - #include "cppship/util/fs.h" +#include + using namespace cppship; TEST(fs, ScopedCurrentDir)