Skip to content

Commit

Permalink
werror
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Jul 20, 2024
1 parent 848a2f3 commit 3a94e3c
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 27 deletions.
69 changes: 69 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
AfterClass: true
AfterControlStatement: true
AfterEnum: false
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 4
NamespaceIndentation: Inner
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
42 changes: 18 additions & 24 deletions mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "maiken/module/init.hpp"
#include <cstdint>
#include <unordered_set>

#include "maiken/module/init.hpp"

namespace mkn {
namespace python3 {

class ModuleMaker : public maiken::Module {
private:
private:
#if defined(_WIN32)
const bool config_expected = 0;
#else
Expand All @@ -49,45 +50,40 @@ class ModuleMaker : public maiken::Module {
mkn::kul::Dir bin;
std::shared_ptr<kul::cli::EnvVar> path_var;

protected:
protected:
static void VALIDATE_NODE(YAML::Node const &node) {
using namespace mkn::kul::yaml;
Validator({NodeValidator("args")}).validate(node);
}

public:
void init(maiken::Application &a, YAML::Node const &node)
public:
void init(maiken::Application &a, YAML::Node const & /*node*/)
KTHROW(std::exception) override {
bool finally = 0;
if (!kul::env::WHICH(PY.c_str()))
PY = "python";
if (!kul::env::WHICH(PY.c_str())) PY = "python";
PYTHON = mkn::kul::env::GET("PYTHON");
if (!PYTHON.empty())
PY = PYTHON;
if (!PYTHON.empty()) PY = PYTHON;
#if defined(_WIN32)
if (PY.rfind(".exe") == std::string::npos)
PY += ".exe";
if (PY.rfind(".exe") == std::string::npos) PY += ".exe";
#endif
mkn::kul::Process p(PY);
mkn::kul::ProcessCapture pc(p);
HOME = mkn::kul::env::GET("PYTHON3_HOME");
if (!HOME.empty()) {
#if defined(_WIN32)
bin = mkn::kul::Dir(HOME);
if (!bin)
KEXCEPT(kul::Exception, "$PYTHON3_HOME does not exist");
if (!bin) KEXCEPT(kul::Exception, "$PYTHON3_HOME does not exist");
#else
bin = mkn::kul::Dir("bin", HOME);
if (!bin)
KEXCEPT(kul::Exception, "$PYTHON3_HOME/bin does not exist");
if (!bin) KEXCEPT(kul::Exception, "$PYTHON3_HOME/bin does not exist");
#endif
path_var = std::make_shared<kul::cli::EnvVar>(
"PATH", bin.real(), mkn::kul::cli::EnvVarMode::PREP);
mkn::kul::env::SET(path_var->name(), path_var->toString().c_str());
p.var(path_var->name(), path_var->toString());
};
#if defined(_WIN32)
pyconfig_found = false; // doesn't exist on windows (generally)
pyconfig_found = false; // doesn't exist on windows (generally)
#else
pyconfig_found = mkn::kul::env::WHICH(PY3_CONFIG.c_str());
#endif
Expand All @@ -111,18 +107,16 @@ class ModuleMaker : public maiken::Module {
} catch (...) {
KERR << "UNKNOWN ERROR CAUGHT";
}
if (finally)
exit(2);
if (finally) exit(2);
using namespace mkn::kul::cli;
auto &evs = a.envVars();

std::string extension;
if (pyconfig_found) {
mkn::kul::os::PushDir pushd(a.project().dir());
mkn::kul::Process p(PY3_CONFIG);
mkn::kul::ProcessCapture pc(p);
p << "--extension-suffix";
if (path_var)
p.var(path_var->name(), path_var->toString());
if (path_var) p.var(path_var->name(), path_var->toString());
p.start();
extension = pc.outs();
} else {
Expand All @@ -134,13 +128,13 @@ class ModuleMaker : public maiken::Module {
p.start();
extension = pc.outs();
}
a.m_cInfo.lib_ext = mkn::kul::String::LINES(extension)[0]; // drop EOL
a.m_cInfo.lib_ext = mkn::kul::String::LINES(extension)[0]; // drop EOL
a.m_cInfo.lib_prefix = "";
a.mode(maiken::compiler::Mode::SHAR);
}
};
} // namespace python3
} // namespace mkn
} // namespace python3
} // namespace mkn

extern "C" KUL_PUBLISH maiken::Module *maiken_module_construct() {
return new mkn::python3::ModuleMaker;
Expand Down
6 changes: 3 additions & 3 deletions test.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@


#include <maiken.hpp>

#include "mkn/kul/signal.hpp"
#include "mkn/kul/yaml.hpp"
#include <maiken.hpp>

const std::string yArgs = "";

Expand All @@ -18,8 +19,7 @@ int main(int argc, char *argv[]) {
loader->module()->link(*app, node);
loader->module()->pack(*app, node);
loader->unload();
for (const auto inc : app->includes())
KLOG(INF) << inc.first;
for (const auto inc : app->includes()) KLOG(INF) << inc.first;
} catch (const mkn::kul::Exception &e) {
KLOG(ERR) << e.what();
return 2;
Expand Down

0 comments on commit 3a94e3c

Please sign in to comment.