Skip to content

Commit

Permalink
New version v0.6.9 (dont you dare laugh)
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntRanch committed Aug 20, 2024
1 parent 0492b1c commit 854b760
Show file tree
Hide file tree
Showing 33 changed files with 3,434 additions and 2,724 deletions.
113 changes: 59 additions & 54 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,65 +1,70 @@
---
Language: Cpp
BasedOnStyle: LLVM
# Based on Source SDK 2013 style conventions
BasedOnStyle: Google

AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
# Align assignments and similar statements
AlignConsecutiveAssignments: true
AlignEscapedNewlines: Right
AlignOperands: false
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
ColumnLimit: 180
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
IncludeBlocks: Preserve
IndentCaseLabels: true
AlignConsecutiveDeclarations: true

# Align the * in declarations
DerivePointerAlignment: false
PointerAlignment: Left

# Column limit for wrapping code
ColumnLimit: 120

# Indentation settings
IndentWidth: 4
PointerAlignment: Right
ReflowComments: false
ReferenceAlignment: Left
SortIncludes: true
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
TabWidth: 4
UseTab: Never

# Bracing styles
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false

# Control spaces around various constructs
#SpacesInParens: Custom
#SpacesInParensOptions:
# InCStyleCasts: false
# InEmptyParentheses: false
# InConditionalStatements: true
# Other: false

SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Never

AllowShortEnumsOnASingleLine: false
# Control formatting of C++11 features
Cpp11BracedListStyle: false

BraceWrapping:
AfterEnum: false
# Namespace indentation
NamespaceIndentation: None

# Format comments
ReflowComments: true

# Additional settings to match Source SDK 2013 style
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
BreakBeforeBraces: Allman
IndentCaseLabels: true

AlignConsecutiveDeclarations: AcrossEmptyLines
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCaseColons: false

NamespaceIndentation: All
AllowShortCaseLabelsOnASingleLine: true
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ else
CXXFLAGS := -O2 $(CXXFLAGS)
endif

VERSION = 0.6.8
VERSION = 0.6.9
BRANCH = main
SRC = $(sort $(wildcard src/*.cpp))
OBJ = $(SRC:.cpp=.o)
CURL_LIBS ?= -lcurl -lnghttp3 -lnghttp2 -lidn2 -lssh2 -lssl -lcrypto -lpsl -lgssapi_krb5 -lzstd -lbrotlidec -lz # pkg-config --static --libs libcurl (but fixed)
LDFLAGS += -L./$(BUILDDIR)/fmt -L./$(BUILDDIR)/cpr -lcpr -lalpm -lfmt $(CURL_LIBS)
CXXFLAGS ?= -mtune=generic -march=native
CXXFLAGS += -funroll-all-loops -isystem include -std=c++20 $(VARS) -DVERSION=\"$(VERSION)\" -DBRANCH=\"$(BRANCH)\" -DLOCALEDIR=\"$(LOCALEDIR)\"
CXXFLAGS += -funroll-all-loops -isystem include -std=c++23 $(VARS) -DVERSION=\"$(VERSION)\" -DBRANCH=\"$(BRANCH)\" -DLOCALEDIR=\"$(LOCALEDIR)\"

is_cpr_installed = $(shell ldconfig -p | grep libcpr > /dev/null || test -d $(BUILDDIR)/cpr && echo -n yes)

Expand Down
12 changes: 6 additions & 6 deletions compile_commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"include",
"-std=c++20",
"-DENABLE_NLS=1",
"-DVERSION=\"0.6.7\"",
"-DVERSION=\"0.6.9\"",
"-DBRANCH=\"main\"",
"-DLOCALEDIR=\"/usr/share/locale\"",
"-c",
Expand All @@ -33,7 +33,7 @@
"include",
"-std=c++20",
"-DENABLE_NLS=1",
"-DVERSION=\"0.6.7\"",
"-DVERSION=\"0.6.9\"",
"-DBRANCH=\"main\"",
"-DLOCALEDIR=\"/usr/share/locale\"",
"-c",
Expand All @@ -56,7 +56,7 @@
"include",
"-std=c++20",
"-DENABLE_NLS=1",
"-DVERSION=\"0.6.7\"",
"-DVERSION=\"0.6.9\"",
"-DBRANCH=\"main\"",
"-DLOCALEDIR=\"/usr/share/locale\"",
"-c",
Expand All @@ -79,7 +79,7 @@
"include",
"-std=c++20",
"-DENABLE_NLS=1",
"-DVERSION=\"0.6.7\"",
"-DVERSION=\"0.6.9\"",
"-DBRANCH=\"main\"",
"-DLOCALEDIR=\"/usr/share/locale\"",
"-c",
Expand All @@ -102,7 +102,7 @@
"include",
"-std=c++20",
"-DENABLE_NLS=1",
"-DVERSION=\"0.6.7\"",
"-DVERSION=\"0.6.9\"",
"-DBRANCH=\"main\"",
"-DLOCALEDIR=\"/usr/share/locale\"",
"-c",
Expand All @@ -125,7 +125,7 @@
"include",
"-std=c++20",
"-DENABLE_NLS=1",
"-DVERSION=\"0.6.7\"",
"-DVERSION=\"0.6.9\"",
"-DBRANCH=\"main\"",
"-DLOCALEDIR=\"/usr/share/locale\"",
"-c",
Expand Down
2 changes: 1 addition & 1 deletion compile_flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
-Wall
-std=c++20
-DENABLE_NLS=1
-DVERSION="0.6.7"
-DVERSION="0.6.9"
-DBRANCH="main"
-DLOCALEDIR="/usr/share/locale"
2 changes: 1 addition & 1 deletion cpr
Submodule cpr updated 120 files
14 changes: 9 additions & 5 deletions include/args.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@
#ifndef ARGS_HPP
#define ARGS_HPP

#include "util.hpp"
#include <alpm.h>
#include <getopt.h>

enum {
#include "util.hpp"

enum
{
OP_MAIN = 1,
OP_SYNC,
OP_REM,
OP_QUERY,
OP_UPGRADE,
OP_PACMAN, // when it's different from -S,R,Q we gonna use pacman
OP_PACMAN, // when it's different from -S,R,Q we gonna use pacman
};

enum {
enum
{
OP_ASK = 1000,
OP_CACHEDIR,
OP_AURONLY,
Expand All @@ -55,7 +58,8 @@ enum {
OP_NOSAVE,
};

struct Operation_t {
struct Operation_t
{
u_short op;
u_short op_s_sync;
u_short op_s_upgrade;
Expand Down
73 changes: 37 additions & 36 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@
#define TOML_ENABLE_FORMATTERS 0

#include <alpm.h>

#include <filesystem>
#include <map>
#include <string>
#include <string_view>
#include <type_traits>
#include <filesystem>

#include "fmt/color.h"
#include "toml++/toml.hpp"

using std::string;
using std::vector;
using std::string_view;
using std::filesystem::path;

// so we don't need to include util.hpp for getConfigValue()
string expandVar(string& str);
std::string expandVar(std::string& str);

struct _color_t {
struct _color_t
{
fmt::rgb red;
fmt::rgb green;
fmt::rgb blue;
Expand All @@ -45,59 +44,61 @@ struct _color_t {
fmt::rgb index;
};

class Config {
public:
alpm_handle_t *handle = nullptr;
alpm_list_t *repos = nullptr;
string makepkgBin;
vector<string> editor;
path cacheDir;
string pmConfig;
string sudo;
string git;
string makepkgConf;
bool aurOnly;
bool useGit;
bool colors;
bool secretRecipe;
bool debug;
bool quiet;
bool noconfirm;
class Config
{
public:
alpm_handle_t* handle = nullptr;
alpm_list_t* repos = nullptr;
std::string makepkgBin;
std::vector<std::string> editor;
path cacheDir;
std::string pmConfig;
std::string sudo;
std::string git;
std::string makepkgConf;
bool aurOnly;
bool useGit;
bool colors;
bool secretRecipe;
bool debug;
bool quiet;
bool noconfirm;
// alpm transaction flags
int flags;
int flags;

Config(string_view configFile, string_view themeFile, string_view configDir);
Config(std::string_view configFile, std::string_view themeFile, std::string_view configDir);
~Config();

void initVars();
void initColors();

void loadConfigFile(string_view filename);
void loadPacmanConfigFile(string filename);
void loadThemeFile(string_view filename);
void loadConfigFile(std::string_view filename);
void loadPacmanConfigFile(std::string filename);
void loadThemeFile(std::string_view filename);

// stupid c++ that wants template functions in header
template <typename T>
T getConfigValue(const string& value, T fallback) {
T getConfigValue(const std::string& value, T fallback)
{
std::optional<T> ret = this->tbl.at_path(value).value<T>();
if constexpr (toml::is_string<T>) // if we want to get a value that's a string
if constexpr (toml::is_string<T>) // if we want to get a value that's a std::string
return ret ? expandVar(ret.value()) : expandVar(fallback);
else
return ret.value_or(fallback);
}

fmt::rgb getThemeValue(const string& value, const string& fallback);
string getThemeHexValue(const string& value, const string& fallback);
fmt::rgb getThemeValue(const std::string& value, const std::string& fallback);
std::string getThemeHexValue(const std::string& value, const std::string& fallback);

private:
private:
toml::table tbl, theme_tbl;
};

extern std::unique_ptr<Config> config;
inline struct _color_t color;

// we comment the default config values, just like /etc/pacman.conf
inline const constexpr string_view AUTOCONFIG = R"#([general]
inline constexpr std::string_view AUTOCONFIG = R"#([general]
# All options are commented out with their default values listed.
# If you wish to use different options values, uncomment and update those.
# It's safe to remove any options you want, just remember their default value
Expand Down Expand Up @@ -142,7 +143,7 @@ inline const constexpr string_view AUTOCONFIG = R"#([general]
#MakepkgConf = "/etc/makepkg.conf"
)#";

inline const constexpr string_view AUTOTHEME = R"#([theme]
inline constexpr std::string_view AUTOTHEME = R"#([theme]
red = "#ff2000"
green = "#00ff00"
blue = "#00aaff"
Expand Down
Loading

0 comments on commit 854b760

Please sign in to comment.