Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Initial development. Incomplete, but ready for a merge into main.
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottBailey committed Jan 26, 2023
1 parent 1c272ef commit 9523e74
Show file tree
Hide file tree
Showing 78 changed files with 6,923 additions and 235 deletions.
137 changes: 137 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
Language: Cpp
# BasedOnStyle: Mozilla
AccessModifierOffset: -3
AlignAfterOpenBracket: Align
AlignArrayOfStructures: Left
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeComma
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 3
ContinuationIndentWidth: 3
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 3
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 3
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 3
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 3
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[Bb]uild*/*
CMakeLists.txt.user
CMakeLists.txt.user
*.md.backup
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.11)

project("Antelope Project Management System")

# Add dependent libraries.
# Make sure this happens BEFORE we include our common settings,
# otherwise we'll be compiling outside libraries with -Wall,
# -Wextra, -Werror
add_subdirectory( depends )

# Add some common stuff.
include( ./common.cmake REQUIRED )


add_subdirectory( common )
add_subdirectory( project )
add_subdirectory( aproj )
#add_subdirectory( aproj-qt )


option(BUILD_TESTS "Build and run the tests." On)
if(BUILD_TESTS)
enable_testing()
add_subdirectory( test )
endif()
21 changes: 21 additions & 0 deletions aproj/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

#
# These files are generally built in a common way, so here are some functions to simplify the process.
#

function(add_aproj target_name files)
add_executable(${target_name} ${files})
set_property(TARGET ${target_name} PROPERTY CXX_STANDARD 20)
target_link_libraries(${target_name} PUBLIC antler-project)
target_include_directories(${target_name} PRIVATE . )
install(FILES $<TARGET_FILE:${target_name}> COMPONENT Runtime DESTINATION .)
endfunction()


file(GLOB src_cpp ./*.cpp)

foreach(file_name IN ITEMS ${src_cpp})
cmake_path(GET file_name FILENAME fn)
string(REPLACE ".cpp" "" name ${fn})
add_aproj("${name}" "${fn}")
endforeach()
143 changes: 143 additions & 0 deletions aproj/aproj-add-app.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// aproj-add-app.cpp and aproj-add-lib.cpp are nearly identical while aproj-add-test.cpp has a few differences. If you change any
// of the three, make sure to keep the others similarly updated.

#include <iostream>
#include <filesystem>
#include <ctype.h>
#include <sstream>
#include <vector>

#include <antler/project/project.h>

#include <aproj-common.h>



std::string exe_name;
std::string indirect;

int usage(std::string_view err) {

std::ostream& os = (err.empty() ? std::cout : std::cerr);

os << exe_name << ": PATH [APP_NAME [APP_LANG [APP_OPTIONS]]]\n"
<< "\n"
<< " --help Print this help and exit.\n"
<< "\n"
<< " PATH is either path to `project.yaml` or the path containing it.\n"
<< " APP_NAME is the the name of the app to add.\n"
<< " APP_LANG is the language of the additional app.\n"
<< " APP_OPTIONS is the string of options to pass to the compiler.\n"
<< "\n"
<< " `project.yaml` is updated to add a new app.\n"
<< "\n"
<< " If either APP_NAME or APP_LANG is absent, the user is prompted.\n"
<< "\n"
;

if(err.empty())
return 0;
os << "Error: " << err << "\n";
return -1;
}


int main(int argc, char** argv) {

COMMON_INIT("Add an application entry to the project.");

// Test arg count is valid.
if(argc < 2)
return usage("path is required.");
if(argc > 5)
return usage("too many options.");


// Get the path to the project.
std::filesystem::path path=argv[1];
if(!antler::project::project::update_path(path))
return usage("path either did not exist or no `project.yaml` file could be found.");

// Load the project.
auto optional_proj = antler::project::project::parse(path);
if( !optional_proj )
return usage("Failed to load project file.");
auto proj = optional_proj.value();


std::string name;
antler::project::language lang=antler::project::language::none;
std::string opts;

if(argc >= 3) {
name = argv[2];
if(proj.object_exists(name, antler::project::object::type_t::app))
return usage("APP_NAME already exists in project.");
}

if(argc == 5)
opts = argv[3];

if(argc >= 4)
lang = antler::project::to_language(argv[3]);
else {
for(;;) {
if(!name.empty() && lang != antler::project::language::none) {

std::cout
<< "\n"
<< "app name: " << name << "\n"
<< "language: " << lang << "\n"
<< "options: " << opts << "\n"
<< "\n"
;

if(proj.object_exists(name, antler::project::object::type_t::app)) {
std::cerr << "Application " << name << " already exists in project. Can't add.\n\n";
}
else {
if(proj.object_exists(name))
std::cerr << "WARNING: " << name << " already exists in project as lib and/or test.\n\n";

if(is_this_correct())
break;
}
}

get_name("application name", name);

for(;;) {
std::cout << "Enter project language: [" << lang << "]" << std::flush;
std::string temp;
std::getline(std::cin,temp);
if(temp.empty() && lang != antler::project::language::none)
break;
antler::project::language l2 = antler::project::to_language(temp);
if(l2 != antler::project::language::none) {
lang = l2;
break;
}
}

{
std::cout << "Enter application options (space to clear): [" << opts << "]" << std::flush;
std::string temp;
std::getline(std::cin,temp);
if(temp == " ")
opts.clear();
else if(!temp.empty())
opts = temp;
}

}
}


if(lang == antler::project::language::none)
return usage("invalid language.");
auto obj = antler::project::object(antler::project::object::app, name, lang, opts);
proj.upsert_app(std::move(obj));
proj.sync();

return 0;
}
Loading

0 comments on commit 9523e74

Please sign in to comment.