Change build system to meson
This commit is contained in:
82
.clang-format
Normal file
82
.clang-format
Normal file
@@ -0,0 +1,82 @@
|
||||
# Google C/C++ Code Style settings
|
||||
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||
|
||||
Language: Cpp
|
||||
BasedOnStyle: Google
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignOperands: Align
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Inline
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterStruct: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
ColumnLimit: 80
|
||||
CompactNamespaces: false
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
FixNamespaceComments: true
|
||||
IncludeBlocks: Preserve
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 2
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PointerAlignment: Left
|
||||
ReflowComments: false
|
||||
SeparateDefinitionBlocks: Always
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: c++17
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
2
.clang-format-include
Normal file
2
.clang-format-include
Normal file
@@ -0,0 +1,2 @@
|
||||
inc/*
|
||||
src/*
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
build/
|
||||
builddir/
|
||||
.cache/
|
||||
.vscode/*
|
||||
!.vscode/c_cpp_properties.json
|
||||
|
13
.vscode/c_cpp_properties.json
vendored
13
.vscode/c_cpp_properties.json
vendored
@@ -1 +1,12 @@
|
||||
{}
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"compileCommands": "/builddir/compile_commands.json"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -2,5 +2,7 @@
|
||||
"clangd.arguments": [ "-log=verbose",
|
||||
"-pretty",
|
||||
"--background-index",
|
||||
"--compile-commands-dir=${workspaceFolder}/build"]
|
||||
"--compile-commands-dir=${workspaceFolder}/builddir",
|
||||
"-std=c++17"
|
||||
]
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(ptprnt LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "Set C++ Compiler Flags" FORCE)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
|
||||
set(SOURCES
|
||||
src/P700Printer.cpp
|
||||
src/P700Driver.cpp
|
||||
src/main.cpp
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
${PROJECT_SOURCE_DIR}/inc
|
||||
)
|
@@ -8,4 +8,4 @@ struct Bitmap {
|
||||
std::vector<std::vector<int>> map;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ptprnt::bitmap
|
@@ -9,4 +9,4 @@ struct info {
|
||||
std::string version{""};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ptprnt::driver
|
@@ -5,10 +5,9 @@
|
||||
|
||||
namespace ptprnt::driver {
|
||||
|
||||
class IDriver
|
||||
{
|
||||
public:
|
||||
virtual ~IDriver() {};
|
||||
class IDriver {
|
||||
public:
|
||||
virtual ~IDriver(){};
|
||||
|
||||
/**
|
||||
* @brief Get Information struct about this driver
|
||||
@@ -25,7 +24,6 @@ public:
|
||||
*/
|
||||
virtual bool open() = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @brief close the device
|
||||
*
|
||||
@@ -41,7 +39,6 @@ public:
|
||||
* @return false error sending command
|
||||
*/
|
||||
virtual bool command() = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ptprnt::driver
|
@@ -9,10 +9,9 @@
|
||||
|
||||
namespace ptprnt::printer {
|
||||
|
||||
class IPrinter
|
||||
{
|
||||
public:
|
||||
virtual ~IPrinter() {};
|
||||
class IPrinter {
|
||||
public:
|
||||
virtual ~IPrinter(){};
|
||||
|
||||
/**
|
||||
* @brief Get Information struct about the printer
|
||||
@@ -41,4 +40,4 @@ public:
|
||||
virtual bool printBitmap(std::shared_ptr<bitmap::Bitmap> bm) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ptprnt::printer
|
@@ -1,14 +1,15 @@
|
||||
|
||||
#include "IDriver.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ptprnt::driver {
|
||||
|
||||
class P700Driver : public IDriver
|
||||
{
|
||||
public:
|
||||
class P700Driver : public IDriver {
|
||||
public:
|
||||
P700Driver(uint16_t UsbDevVendor = 0x04f9, uint16_t UsbDevId = 0x2061);
|
||||
~P700Driver() override;
|
||||
|
||||
@@ -18,4 +19,4 @@ public:
|
||||
bool command() override;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ptprnt::driver
|
@@ -8,9 +8,8 @@
|
||||
|
||||
namespace ptprnt::printer {
|
||||
|
||||
class P700Printer : public IPrinter
|
||||
{
|
||||
public:
|
||||
class P700Printer : public IPrinter {
|
||||
public:
|
||||
P700Printer(std::unique_ptr<driver::P700Driver> driver);
|
||||
~P700Printer() override;
|
||||
|
||||
@@ -18,9 +17,9 @@ public:
|
||||
bool printText(std::string_view text, uint32_t fontSize) override;
|
||||
bool printBitmap(std::shared_ptr<bitmap::Bitmap> bm) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
static info mPrinterInfo;
|
||||
std::unique_ptr<driver::P700Driver> mDriver;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ptprnt::printer
|
@@ -18,4 +18,4 @@ struct info {
|
||||
bool cutter = {false};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ptprnt::printer
|
21
meson.build
Normal file
21
meson.build
Normal file
@@ -0,0 +1,21 @@
|
||||
project('ptprnt', 'cpp',
|
||||
version: '0.1.0',
|
||||
license: 'GPLv3',
|
||||
default_options : ['c_std=c11', 'cpp_std=c++17']
|
||||
)
|
||||
|
||||
usbdep = dependency('libusb-1.0')
|
||||
|
||||
incdir = include_directories('inc')
|
||||
|
||||
srcs = [
|
||||
'src/main.cpp',
|
||||
'src/P700Driver.cpp',
|
||||
'src/P700Printer.cpp'
|
||||
]
|
||||
|
||||
executable(
|
||||
'ptprnt', srcs,
|
||||
include_directories : incdir,
|
||||
dependencies : usbdep
|
||||
)
|
@@ -1,17 +1,13 @@
|
||||
#include "P700Driver.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ptprnt::driver {
|
||||
|
||||
P700Driver::P700Driver(uint16_t UsbDevVendor, uint16_t UsbDevId) {
|
||||
P700Driver::P700Driver(uint16_t UsbDevVendor, uint16_t UsbDevId) {}
|
||||
|
||||
}
|
||||
|
||||
P700Driver::~P700Driver() {
|
||||
|
||||
}
|
||||
P700Driver::~P700Driver() {}
|
||||
|
||||
driver::info P700Driver::getInfo() {
|
||||
return driver::info{};
|
||||
@@ -29,4 +25,4 @@ bool P700Driver::command() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ptprnt::driver
|
@@ -1,18 +1,18 @@
|
||||
#include "P700Printer.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ptprnt::printer {
|
||||
|
||||
P700Printer::P700Printer(std::unique_ptr<driver::P700Driver> driver) {
|
||||
if(!driver->open()) {
|
||||
if (!driver->open()) {
|
||||
throw std::invalid_argument("Could not open driver!");
|
||||
}
|
||||
}
|
||||
|
||||
P700Printer::~P700Printer() {
|
||||
if(!mDriver->close()) {
|
||||
if (!mDriver->close()) {
|
||||
std::cerr << "Could not close driver properly!" << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ P700Printer::~P700Printer() {
|
||||
printer::info P700Printer::getInfo() {
|
||||
return printer::info{};
|
||||
}
|
||||
|
||||
bool P700Printer::printText(std::string_view text, uint32_t fontSize) {
|
||||
return false;
|
||||
}
|
||||
@@ -28,4 +29,4 @@ bool P700Printer::printBitmap(std::shared_ptr<bitmap::Bitmap> bm) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ptprnt::printer
|
@@ -4,16 +4,16 @@
|
||||
#include "IPrinter.hpp"
|
||||
#include "P700Printer.hpp"
|
||||
|
||||
#include <libusb-1.0/libusb.h>
|
||||
using namespace ptprnt;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
std::cout << "Hello ptprnt!" << std::endl;
|
||||
|
||||
libusb_init(NULL);
|
||||
auto driver = std::make_unique<driver::P700Driver>();
|
||||
auto printer = std::make_unique<printer::P700Printer>(std::move(driver));
|
||||
printer::info info = printer->getInfo();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user