Moved from pkg-config
This commit is contained in:
parent
ef4a6dec24
commit
06d5a33495
17
README.md
17
README.md
@ -2,25 +2,26 @@
|
||||
|
||||
C.A. stands for Collarbone Annihilation.
|
||||
|
||||
# About
|
||||
|
||||
Сделан на летней практике 5-ю первокурсниками из ИУ9-21Б.
|
||||
|
||||
# Dependencies
|
||||
|
||||
iu9-ca-web-chat использует
|
||||
- C++
|
||||
- GCC
|
||||
- [regexis024-build-system](
|
||||
https://peppermintgingerbread.zip/collarbone-annihilation/regexis024-build-system
|
||||
https://gitlab.yyyi.ru/collarbone-annihilation/regexis024-build-system
|
||||
)
|
||||
- [libregexis024](
|
||||
https://peppermintgingerbread.zip/kme-devline/libregexis024
|
||||
https://gitlab.yyyi.ru/kme-devline/libregexis024
|
||||
)
|
||||
- [libjsonincpp](
|
||||
https://peppermintgingerbread.zip/collarbone-annihilation/libjsonincpp
|
||||
https://gitlab.yyyi.ru/collarbone-annihilation/libjsonincpp
|
||||
)
|
||||
- [sqlite3](
|
||||
https://www.sqlite.org
|
||||
)
|
||||
- pkg-config и pkg-config файлики для всех этих зависимостей
|
||||
|
||||
Сервис так же использует библиотеки engine_engine_number_9 и new_york_transit_line,
|
||||
размещённые прямо в репозитории.
|
||||
@ -30,7 +31,7 @@ iu9-ca-web-chat использует
|
||||
# Compilation
|
||||
|
||||
```sh
|
||||
./building/build_build_sytem.sh
|
||||
regexis024_build_system.sh
|
||||
./building/main bi ./ "absolute/path/to/installation/root"
|
||||
```
|
||||
# Usage
|
||||
@ -69,8 +70,8 @@ iu9-ca-web-chat использует
|
||||
Зачем писать комментарии в коде, если можно их вынести в отдельные пдф-ки?
|
||||
|
||||
- [API сервиса](
|
||||
https://peppermintgingerbread.zip/collarbone-annihilation/iu9-ca-chat-api)
|
||||
https://gitlab.yyyi.ru/collarbone-annihilation/iu9-ca-chat-api)
|
||||
- [Доки New York Transit Line](
|
||||
https://peppermintgingerbread.zip/collarbone-annihilation/new_york_transit_line_documentation_rus)
|
||||
https://gitlab.yyyi.ru/collarbone-annihilation/new_york_transit_line_documentation_rus)
|
||||
|
||||
О том как работает всё остальное можно только догадываться.
|
||||
|
@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
BUILDING_DIR="./building"
|
||||
[ -d "$BUILDING_DIR" ] || exit 1
|
||||
MAIN_FILE="$BUILDING_DIR/main.cpp"
|
||||
[ -f "$MAIN_FILE" ] || exit 1
|
||||
|
||||
COOL_FLAGS="$(pkg-config --cflags regexis024-build-system)"
|
||||
|
||||
g++ $COOL_FLAGS -o "$BUILDING_DIR/main" "$MAIN_FILE" || exit 1
|
@ -1,30 +1,21 @@
|
||||
#include "regexis024_build_system.h"
|
||||
#include <utility>
|
||||
|
||||
#include "regexis024_build_system.h"
|
||||
|
||||
std::vector<std::string> getFromPkgConfig(const std::string& req, const std::string& name){
|
||||
std::string pc_stdout, pc_stderr;
|
||||
CommandReturnCode rc = executeCommand_and_save_output({"pkg-config", "--" + req, name}, pc_stdout, pc_stderr);
|
||||
ASSERT(rc.isOk(), "failed to use pkg-config beacause of:\n" + pc_stderr);
|
||||
// todo: learn how pkg-config actually stores these options
|
||||
std::vector<std::string> result;
|
||||
for (char ch: pc_stdout) {
|
||||
if (result.empty())
|
||||
result.emplace_back();
|
||||
if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') {
|
||||
if (!result.back().empty())
|
||||
result.emplace_back();
|
||||
} else {
|
||||
result.back() += ch;
|
||||
std::string make_uppercase(const std::string &source) {
|
||||
std::string result(source);
|
||||
for (size_t i = 0; i < source.size(); i++) {
|
||||
char ch = source[i];
|
||||
if ('a' <= ch && ch <= 'z')
|
||||
result[i] = (char)(ch - 'a' + 'A');
|
||||
}
|
||||
}
|
||||
if (!result.empty() && result.back().empty())
|
||||
result.pop_back();
|
||||
return result;
|
||||
}
|
||||
|
||||
ExternalLibraryTarget formExternalLibraryTargetWithNativeName(const std::string& name) {
|
||||
return {name, {getFromPkgConfig("cflags", name), getFromPkgConfig("libs", name)}};
|
||||
ExternalLibraryTarget formExternalLibraryTargetWithNonNativeName(const std::string& name) {
|
||||
std::string ev_name = "BSCRIPT_DEP_" + make_uppercase(name);
|
||||
const char* ev = getenv(ev_name.c_str());
|
||||
ASSERT(ev, "No environmaent variable " + ev_name);
|
||||
return {name, parse_passed_forward_str(ev)};
|
||||
}
|
||||
|
||||
struct CAWebChat {
|
||||
@ -64,9 +55,9 @@ struct CAWebChat {
|
||||
ASSERT(build_type == "release" || build_type == "debug", "Unknown build type");
|
||||
|
||||
std::vector<ExternalLibraryTarget> ext_targets = {
|
||||
formExternalLibraryTargetWithNativeName("libjsonincpp"),
|
||||
formExternalLibraryTargetWithNativeName("sqlite3"),
|
||||
formExternalLibraryTargetWithNativeName("libregexis024"),
|
||||
formExternalLibraryTargetWithNonNativeName("libjsonincpp"),
|
||||
formExternalLibraryTargetWithNonNativeName("sqlite3"),
|
||||
formExternalLibraryTargetWithNonNativeName("libregexis024"),
|
||||
};
|
||||
|
||||
std::vector<CTarget> my_targets;
|
||||
|
@ -5,20 +5,38 @@
|
||||
#include <engine_engine_number_9/os_utils.h>
|
||||
#include <find_db.h>
|
||||
|
||||
void sqlite_single_statement(sqlite3* db_hand_ptr, const std::string& req_statement) {
|
||||
sqlite3_stmt* stmt_obj_ptr = NULL;
|
||||
int ret = sqlite3_prepare16_v2(db_hand_ptr, req_statement.c_str(), -1, &stmt_obj_ptr, NULL);
|
||||
void sqlite_single_statement(sqlite3* db_hand, const std::string& req_statement) {
|
||||
sqlite3_stmt* stmt_obj = NULL;
|
||||
int ret = sqlite3_prepare16_v2(db_hand, req_statement.c_str(), -1, &stmt_obj, NULL);
|
||||
een9_ASSERT(ret == 0, "Can't compile request expression");
|
||||
struct Guard1{sqlite3_stmt*& r; ~Guard1(){if (sqlite3_finalize(r) != 0) {abort();}}} guard1{stmt_obj_ptr};
|
||||
struct Guard1{sqlite3_stmt*& r; ~Guard1(){if (sqlite3_finalize(r) != 0) {abort();}}} guard1{stmt_obj};
|
||||
while (true) {
|
||||
ret = sqlite3_step(stmt_obj_ptr);
|
||||
ret = sqlite3_step(stmt_obj);
|
||||
if (ret == SQLITE_DONE)
|
||||
break;
|
||||
if (ret != SQLITE_ROW) {
|
||||
printf("sqlite_row error!!!\n");
|
||||
printf("%s\n", sqlite3_errmsg(db_hand));
|
||||
break;
|
||||
}
|
||||
|
||||
int cc = sqlite3_column_count(stmt_obj);
|
||||
std::vector<int> types(cc);
|
||||
for (int i = 0; i < cc; i++) {
|
||||
types[i] = sqlite3_column_type(stmt_obj, i);
|
||||
}
|
||||
printf("Column: |");
|
||||
for (int i = 0; i < cc; i++) {
|
||||
switch (types[i]) {
|
||||
#define ccase(tname) case SQLITE_ ## tname: printf(" " #tname " |"); break;
|
||||
ccase(INTEGER)
|
||||
ccase(FLOAT)
|
||||
ccase(BLOB)
|
||||
ccase(NULL)
|
||||
case SQLITE3_TEXT:
|
||||
printf(" TEXT |"); break;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("Request steps are done\n");
|
||||
}
|
||||
@ -32,9 +50,10 @@ void initialize_website(const json::JSON& config, const std::string& root_pw) {
|
||||
een9_ASSERT(ret == 0, "Invalid settings[\"database\"] field");
|
||||
een9_ASSERT(!een9::isRegularFile(db_path), "Database file exists prior to initialization. "
|
||||
"Can't preceed withut harming existing data");
|
||||
sqlite3* db_hand_ptr = NULL;
|
||||
ret = sqlite3_open(db_path.c_str(), &db_hand_ptr);
|
||||
een9_ASSERT(ret == 0, "Can't open database");
|
||||
struct Guard1{sqlite3*& dhp; ~Guard1(){if (sqlite3_close(dhp) != 0) {abort();}}} guard1{db_hand_ptr};
|
||||
sqlite_single_statement(db_hand_ptr, "CREATE TABLE tb(a INT, b INT);");
|
||||
// sqlite3* db_hand = NULL;
|
||||
// ret = sqlite3_open(db_path.c_str(), &db_hand);
|
||||
// een9_ASSERT(ret == 0, "Can't open database");
|
||||
// struct Guard1{sqlite3*& dhp; ~Guard1(){if (sqlite3_close(dhp) != 0) {abort();}}} guard1{db_hand};
|
||||
// sqlite_single_statement(db_hand, "CREATE TABLE tb(a INT, b INT);");
|
||||
// todo: actually write something
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
#include <stdexcept>
|
||||
|
||||
void usage(char** argv) {
|
||||
printf("Usage: %s <file with settings>\n", argv[0]);
|
||||
printf("Usage: %s <file with settings> <run|initialize>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user