Skip to content

Commit

Permalink
Merge pull request #101 from build-cpp/minor-cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
mrexodia authored Mar 25, 2023
2 parents ee7fe38 + 7a7ddf2 commit 240fafc
Show file tree
Hide file tree
Showing 27 changed files with 109 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-2019, macos-10.15, ubuntu-20.04]
os: [windows-2022, macos-11, ubuntu-20.04]
env:
BUILD_TYPE: Release
BUILD_TYPE: 'Release'
CMAKE_GENERATOR: 'Ninja'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@6263846cf3c17009dfc81604efabae16044fc074 # master

- name: Visual Studio Development Environment
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1

- name: Tag cmkr.cmake
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: cmake -P "cmake/replace_tag.cmake"
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: lint

on: [push]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: clang-format
id: clang-format
uses: DoozyX/clang-format-lint-action@c3b2c943e924028b93a707a5b1b017976ab8d50c # v0.15
with:
exclude: './third_party'
extensions: 'c,h,cpp,hpp'
clangFormatVersion: 15
style: file

- name: clang-format instructions
if: ${{ failure() && steps.clang-format.outcome == 'failure' }}
run: |
# Instructions for fixing the formatting errors
echo -e "\n\033[0;31mTo fix the formatting, run:\nclang-format -style=file -i \$(git ls-files \"*.c\" \"*.h\" \"*.cpp\" \"*.hpp\")\033[0m\n"
exit 1
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ build*/
.idea/
cmake-build*/
CMakeLists.txt.user
.vscode/
.vscode/
.DS_Store
2 changes: 0 additions & 2 deletions CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions include/build.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,3 @@ int install();

} // namespace build
} // namespace cmkr

int cmkr_build_run(int argc, char **argv);

int cmkr_build_clean();

int cmkr_build_install();
27 changes: 0 additions & 27 deletions include/error.hpp

This file was deleted.

4 changes: 1 addition & 3 deletions include/fs.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once

#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || \
(defined(__cplusplus) && __cplusplus >= 201703L)) && \
defined(__has_include)
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include)
#if __has_include(<filesystem>) && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
#define GHC_USE_STD_FS
#include <filesystem>
Expand Down
4 changes: 0 additions & 4 deletions include/help.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@ const char *message() noexcept;

} // namespace help
} // namespace cmkr

const char *cmkr_help_version(void);

const char *cmkr_help_message(void);
9 changes: 7 additions & 2 deletions include/project_parser.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#pragma once

#include <mpark/variant.hpp>
#include <vector>
#include <string>

#include <mpark/variant.hpp>
#include <tsl/ordered_map.h>
#include <tsl/ordered_set.h>
#include <vector>

namespace cmkr {
namespace parser {
Expand Down Expand Up @@ -47,6 +48,10 @@ struct Vcpkg {
};

std::vector<Package> packages;

bool enabled() const {
return !packages.empty();
}
};

enum TargetType {
Expand Down
4 changes: 1 addition & 3 deletions src/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
#include "build.hpp"
#include "cmake_generator.hpp"
#include "help.hpp"

#include "fs.hpp"
#include <exception>
#include <iostream>

#include <stdexcept>
#include <string>
#include <vector>
Expand Down
42 changes: 4 additions & 38 deletions src/build.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#include "build.hpp"
#include "cmake_generator.hpp"
#include "error.hpp"
#include "project_parser.hpp"

#include "fs.hpp"
#include <cstddef>
#include <cstdlib>
#include <sstream>
#include <stdexcept>
#include <system_error>

namespace cmkr {
namespace build {
Expand All @@ -17,7 +13,7 @@ int run(int argc, char **argv) {
parser::Project project(nullptr, ".", true);
if (argc > 2) {
for (int i = 2; i < argc; ++i) {
project.build_args.push_back(argv[i]);
project.build_args.emplace_back(argv[i]);
}
}
std::stringstream ss;
Expand Down Expand Up @@ -48,13 +44,13 @@ int run(int argc, char **argv) {
}

int clean() {
bool ret = false;
bool success = false;
parser::Project project(nullptr, ".", true);
if (fs::exists(project.build_dir)) {
ret = fs::remove_all(project.build_dir);
success = fs::remove_all(project.build_dir);
fs::create_directory(project.build_dir);
}
return !ret;
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}

int install() {
Expand All @@ -64,33 +60,3 @@ int install() {
}
} // namespace build
} // namespace cmkr

int cmkr_build_run(int argc, char **argv) {
try {
return cmkr::build::run(argc, argv);
} catch (const std::system_error &e) {
return e.code().value();
} catch (...) {
return cmkr::error::Status(cmkr::error::Status::Code::BuildError);
}
}

int cmkr_build_clean(void) {
try {
return cmkr::build::clean();
} catch (const std::system_error &e) {
return e.code().value();
} catch (...) {
return cmkr::error::Status(cmkr::error::Status::Code::CleanError);
}
}

int cmkr_build_install(void) {
try {
return cmkr::build::install();
} catch (const std::system_error &e) {
return e.code().value();
} catch (...) {
return cmkr::error::Status(cmkr::error::Status::Code::InstallError);
}
}
Loading

0 comments on commit 240fafc

Please sign in to comment.