parent
0766a2aacb
commit
2fa68351fc
@ -0,0 +1,27 @@ |
||||
all: build |
||||
|
||||
reset: |
||||
powershell -executionpolicy bypass .\scripts\reset_build.ps1
|
||||
|
||||
build: |
||||
meson compile -j 4 -C builddir
|
||||
|
||||
release_build: |
||||
meson --wipe builddir -Db_ndebug=true --buildtype release
|
||||
meson compile -j 4 -C builddir
|
||||
|
||||
debug_build: |
||||
meson setup --wipe builddir -Db_ndebug=true --buildtype debugoptimized
|
||||
meson compile -j 4 -C builddir
|
||||
|
||||
run: build |
||||
./builddir/sfmldemo.exe
|
||||
|
||||
debug: build |
||||
gdb --nx -x .gdbinit --ex run --args builddir/runtests.exe
|
||||
|
||||
debug_run: build |
||||
gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args builddir/sfmldemo.exe
|
||||
|
||||
clean: |
||||
meson compile --clean -C builddir
|
@ -0,0 +1,47 @@ |
||||
#include "dbc.hpp" |
||||
#include <iostream> |
||||
|
||||
void dbc::log(const string &message, const std::source_location location) { |
||||
std::cout << '[' << location.file_name() << ':' |
||||
<< location.line() << "|" |
||||
<< location.function_name() << "] " |
||||
<< message << std::endl; |
||||
} |
||||
|
||||
void dbc::sentinel(const string &message, const std::source_location location) { |
||||
string err = fmt::format("[SENTINEL!] {}", message); |
||||
dbc::log(err, location); |
||||
throw dbc::SentinelError{err}; |
||||
} |
||||
|
||||
void dbc::pre(const string &message, bool test, const std::source_location location) { |
||||
if(!test) { |
||||
string err = fmt::format("[PRE!] {}", message); |
||||
dbc::log(err, location); |
||||
throw dbc::PreCondError{err}; |
||||
} |
||||
} |
||||
|
||||
void dbc::pre(const string &message, std::function<bool()> tester, const std::source_location location) { |
||||
dbc::pre(message, tester(), location); |
||||
} |
||||
|
||||
void dbc::post(const string &message, bool test, const std::source_location location) { |
||||
if(!test) { |
||||
string err = fmt::format("[POST!] {}", message); |
||||
dbc::log(err, location); |
||||
throw dbc::PostCondError{err}; |
||||
} |
||||
} |
||||
|
||||
void dbc::post(const string &message, std::function<bool()> tester, const std::source_location location) { |
||||
dbc::post(message, tester(), location); |
||||
} |
||||
|
||||
void dbc::check(bool test, const string &message, const std::source_location location) { |
||||
if(!test) { |
||||
string err = fmt::format("[CHECK!] {}\n", message); |
||||
dbc::log(err, location); |
||||
throw dbc::CheckError{err}; |
||||
} |
||||
} |
@ -0,0 +1,50 @@ |
||||
#pragma once |
||||
|
||||
#include <string> |
||||
#include <fmt/core.h> |
||||
#include <functional> |
||||
#include <source_location> |
||||
|
||||
using std::string; |
||||
|
||||
namespace dbc { |
||||
class Error { |
||||
public: |
||||
const string message; |
||||
Error(string m) : message{m} {} |
||||
Error(const char *m) : message{m} {} |
||||
}; |
||||
|
||||
class CheckError : public Error {}; |
||||
class SentinelError : public Error {}; |
||||
class PreCondError : public Error {}; |
||||
class PostCondError : public Error {}; |
||||
|
||||
void log(const string &message, |
||||
const std::source_location location = |
||||
std::source_location::current()); |
||||
|
||||
[[noreturn]] void sentinel(const string &message, |
||||
const std::source_location location = |
||||
std::source_location::current()); |
||||
|
||||
void pre(const string &message, bool test, |
||||
const std::source_location location = |
||||
std::source_location::current()); |
||||
|
||||
void pre(const string &message, std::function<bool()> tester, |
||||
const std::source_location location = |
||||
std::source_location::current()); |
||||
|
||||
void post(const string &message, bool test, |
||||
const std::source_location location = |
||||
std::source_location::current()); |
||||
|
||||
void post(const string &message, std::function<bool()> tester, |
||||
const std::source_location location = |
||||
std::source_location::current()); |
||||
|
||||
void check(bool test, const string &message, |
||||
const std::source_location location = |
||||
std::source_location::current()); |
||||
} |
@ -1,10 +1,10 @@ |
||||
#!/usr/bin/env bash |
||||
set -ex |
||||
|
||||
mv ./subprojects/packagecache . |
||||
rm -rf ./subprojects ./builddir |
||||
mv -f ./subprojects/packagecache . |
||||
rm -rf subprojects builddir |
||||
mkdir subprojects |
||||
mv ./packagecache ./subprojects |
||||
mv -f packagecache ./subprojects/ && true |
||||
mkdir builddir |
||||
cp wraps/*.wrap subprojects/ |
||||
meson setup builddir |
||||
# on OSX you can't do this with static |
||||
meson setup --default-library=static --prefer-static builddir |
||||
|
Loading…
Reference in new issue