From 94a50a8e9abf35c607f128c1fc124cbe279f8fe3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ivar=20H=C3=A4rnqvist?= <ivaha717@student.liu.se>
Date: Tue, 25 Feb 2020 12:29:58 +0100
Subject: [PATCH] add clang-format, add basic ctest files, fix README

---
 .clang-format       | 151 ++++++++++++++++++++++++++++++++++++++++++++
 CMakeLists.txt      |   8 ++-
 README.md           |   4 +-
 test/CMakeLists.txt |   9 +++
 test/test_main.cpp  |   5 ++
 5 files changed, 173 insertions(+), 4 deletions(-)
 create mode 100644 .clang-format
 create mode 100644 test/CMakeLists.txt
 create mode 100644 test/test_main.cpp

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..7548f76b
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,151 @@
+AccessModifierOffset: -4
+
+AlignAfterOpenBracket: DontAlign
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignConsecutiveMacros: true
+AlignEscapedNewlines: DontAlign
+AlignOperands: false
+AlignTrailingComments: true
+
+AllowAllArgumentsOnNextLine: true
+AllowAllConstructorInitializersOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: Empty
+AllowShortCaseLabelsOnASingleLine: true
+AllowShortFunctionsOnASingleLine: Empty
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLambdasOnASingleLine: Inline
+AllowShortLoopsOnASingleLine: false
+
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: true
+AlwaysBreakTemplateDeclarations: Yes
+
+BinPackArguments: false
+BinPackParameters: true
+
+BreakBeforeBraces: Custom
+BraceWrapping:
+  AfterCaseLabel: false
+  AfterClass: false
+  AfterControlStatement: false
+  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
+BreakBeforeTernaryOperators: false
+BreakConstructorInitializers: BeforeComma
+BreakInheritanceList: BeforeComma
+BreakStringLiterals: true
+
+ColumnLimit: 140
+
+CommentPragmas: ''
+
+CompactNamespaces: false
+
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+ConstructorInitializerIndentWidth: 4
+
+ContinuationIndentWidth: 4
+
+Cpp11BracedListStyle: true
+
+DerivePointerAlignment: false
+
+DisableFormat: false
+
+FixNamespaceComments: true
+
+ForEachMacros:
+  - Q_FOREACH
+  - BOOST_FOREACH
+  - FOREACH
+  - FOR_EACH
+
+IncludeBlocks: Regroup
+IncludeCategories:
+  - Regex: '^<'
+    Priority: 2
+  - Regex: '.*'
+    Priority: 1
+IncludeIsMainRegex: '(_test)?$'
+
+IndentCaseLabels: true
+IndentGotoLabels: false
+IndentPPDirectives: None
+IndentWidth: 4
+IndentWrappedFunctionNames: false
+
+KeepEmptyLinesAtTheStartOfBlocks: false
+
+Language: Cpp
+
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+
+MaxEmptyLinesToKeep: 1
+
+NamespaceIndentation: None
+NamespaceMacros:
+  - NAMESPACE
+
+PenaltyBreakAssignment: 100
+PenaltyBreakBeforeFirstCallParameter: 10
+PenaltyBreakComment: 10
+PenaltyBreakFirstLessLess: 100
+PenaltyBreakString: 10
+PenaltyBreakTemplateDeclaration: 10000
+PenaltyExcessCharacter: 999999
+PenaltyReturnTypeOnItsOwnLine: 10000
+
+PointerAlignment: Left
+
+ReflowComments: false
+
+SortIncludes: true
+SortUsingDeclarations: true
+
+SpaceAfterCStyleCast: false
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyBlock: false
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInCStyleCastParentheses: false
+SpacesInContainerLiterals: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+
+Standard: Cpp11
+
+StatementMacros:
+  - Q_UNUSED
+
+TabWidth: 4
+
+TypenameMacros:
+  - STACK_OF
+  - LIST
+  - LIST_ENTRY
+
+UseTab: ForContinuationAndIndentation
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 433d2746..ab4d1bf5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,10 +75,14 @@ add_custom_target(
 	copy_python_dir ALL
 	COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_LIST_DIR}/${LIBRARY_NAME}" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIBRARY_NAME}"
 	COMMENT "Copying python files to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIBRARY_NAME}"
-	DEPENDS remove_old_python_dir
+	DEPENDS "${TARGET_NAME}" remove_old_python_dir
 )
 add_custom_target(
 	copy_misc_files ALL
 	COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_LIST_DIR}/README.md" "${CMAKE_CURRENT_LIST_DIR}/LICENSE" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
 	COMMENT "Copying misc. files to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
-)
\ No newline at end of file
+	DEPENDS "${TARGET_NAME}"
+)
+
+enable_testing()
+add_subdirectory(test)
\ No newline at end of file
diff --git a/README.md b/README.md
index bcd09857..54440d52 100644
--- a/README.md
+++ b/README.md
@@ -62,13 +62,13 @@ python3 setup.py sdist
 The output gets written to `B-ASIC/dist/b-asic-<version>.tar.gz`.
 
 #### Installation (Binary distribution)
-In `B-ASIC`:
+In `B-ASIC/dist`:
 ```
 python3 -m pip install b_asic-<version>-<python_tag>-<abi_tag>-<platform_tag>.whl
 ```
 
 #### Installation (Source distribution)
-In `B-ASIC`:
+In `B-ASIC/dist`:
 ```
 python3 -m pip install b-asic-<version>.tar.gz
 ```
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 00000000..c9fd7f20
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.13)
+
+project("B-ASIC-test")
+
+add_executable(
+	test-main
+	"${CMAKE_CURRENT_SOURCE_DIR}/test_main.cpp"
+)
+add_test(NAME test-main COMMAND test-main)
\ No newline at end of file
diff --git a/test/test_main.cpp b/test/test_main.cpp
new file mode 100644
index 00000000..30ea92f7
--- /dev/null
+++ b/test/test_main.cpp
@@ -0,0 +1,5 @@
+// TODO: Tests
+
+int main() {
+	return 0;
+}
\ No newline at end of file
-- 
GitLab