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.
|
C.A. stands for Collarbone Annihilation.
|
||||||
|
|
||||||
|
# About
|
||||||
|
|
||||||
Сделан на летней практике 5-ю первокурсниками из ИУ9-21Б.
|
Сделан на летней практике 5-ю первокурсниками из ИУ9-21Б.
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
iu9-ca-web-chat использует
|
iu9-ca-web-chat использует
|
||||||
- C++
|
- GCC
|
||||||
- [regexis024-build-system](
|
- [regexis024-build-system](
|
||||||
https://peppermintgingerbread.zip/collarbone-annihilation/regexis024-build-system
|
https://gitlab.yyyi.ru/collarbone-annihilation/regexis024-build-system
|
||||||
)
|
)
|
||||||
- [libregexis024](
|
- [libregexis024](
|
||||||
https://peppermintgingerbread.zip/kme-devline/libregexis024
|
https://gitlab.yyyi.ru/kme-devline/libregexis024
|
||||||
)
|
)
|
||||||
- [libjsonincpp](
|
- [libjsonincpp](
|
||||||
https://peppermintgingerbread.zip/collarbone-annihilation/libjsonincpp
|
https://gitlab.yyyi.ru/collarbone-annihilation/libjsonincpp
|
||||||
)
|
)
|
||||||
- [sqlite3](
|
- [sqlite3](
|
||||||
https://www.sqlite.org
|
https://www.sqlite.org
|
||||||
)
|
)
|
||||||
- pkg-config и pkg-config файлики для всех этих зависимостей
|
|
||||||
|
|
||||||
Сервис так же использует библиотеки engine_engine_number_9 и new_york_transit_line,
|
Сервис так же использует библиотеки engine_engine_number_9 и new_york_transit_line,
|
||||||
размещённые прямо в репозитории.
|
размещённые прямо в репозитории.
|
||||||
@ -30,7 +31,7 @@ iu9-ca-web-chat использует
|
|||||||
# Compilation
|
# Compilation
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./building/build_build_sytem.sh
|
regexis024_build_system.sh
|
||||||
./building/main bi ./ "absolute/path/to/installation/root"
|
./building/main bi ./ "absolute/path/to/installation/root"
|
||||||
```
|
```
|
||||||
# Usage
|
# Usage
|
||||||
@ -69,8 +70,8 @@ iu9-ca-web-chat использует
|
|||||||
Зачем писать комментарии в коде, если можно их вынести в отдельные пдф-ки?
|
Зачем писать комментарии в коде, если можно их вынести в отдельные пдф-ки?
|
||||||
|
|
||||||
- [API сервиса](
|
- [API сервиса](
|
||||||
https://peppermintgingerbread.zip/collarbone-annihilation/iu9-ca-chat-api)
|
https://gitlab.yyyi.ru/collarbone-annihilation/iu9-ca-chat-api)
|
||||||
- [Доки New York Transit Line](
|
- [Доки 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 <utility>
|
||||||
|
|
||||||
#include "regexis024_build_system.h"
|
std::string make_uppercase(const std::string &source) {
|
||||||
|
std::string result(source);
|
||||||
std::vector<std::string> getFromPkgConfig(const std::string& req, const std::string& name){
|
for (size_t i = 0; i < source.size(); i++) {
|
||||||
std::string pc_stdout, pc_stderr;
|
char ch = source[i];
|
||||||
CommandReturnCode rc = executeCommand_and_save_output({"pkg-config", "--" + req, name}, pc_stdout, pc_stderr);
|
if ('a' <= ch && ch <= 'z')
|
||||||
ASSERT(rc.isOk(), "failed to use pkg-config beacause of:\n" + pc_stderr);
|
result[i] = (char)(ch - 'a' + 'A');
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!result.empty() && result.back().empty())
|
|
||||||
result.pop_back();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalLibraryTarget formExternalLibraryTargetWithNativeName(const std::string& name) {
|
ExternalLibraryTarget formExternalLibraryTargetWithNonNativeName(const std::string& name) {
|
||||||
return {name, {getFromPkgConfig("cflags", name), getFromPkgConfig("libs", 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 {
|
struct CAWebChat {
|
||||||
@ -64,9 +55,9 @@ struct CAWebChat {
|
|||||||
ASSERT(build_type == "release" || build_type == "debug", "Unknown build type");
|
ASSERT(build_type == "release" || build_type == "debug", "Unknown build type");
|
||||||
|
|
||||||
std::vector<ExternalLibraryTarget> ext_targets = {
|
std::vector<ExternalLibraryTarget> ext_targets = {
|
||||||
formExternalLibraryTargetWithNativeName("libjsonincpp"),
|
formExternalLibraryTargetWithNonNativeName("libjsonincpp"),
|
||||||
formExternalLibraryTargetWithNativeName("sqlite3"),
|
formExternalLibraryTargetWithNonNativeName("sqlite3"),
|
||||||
formExternalLibraryTargetWithNativeName("libregexis024"),
|
formExternalLibraryTargetWithNonNativeName("libregexis024"),
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<CTarget> my_targets;
|
std::vector<CTarget> my_targets;
|
||||||
|
@ -5,20 +5,38 @@
|
|||||||
#include <engine_engine_number_9/os_utils.h>
|
#include <engine_engine_number_9/os_utils.h>
|
||||||
#include <find_db.h>
|
#include <find_db.h>
|
||||||
|
|
||||||
void sqlite_single_statement(sqlite3* db_hand_ptr, const std::string& req_statement) {
|
void sqlite_single_statement(sqlite3* db_hand, const std::string& req_statement) {
|
||||||
sqlite3_stmt* stmt_obj_ptr = NULL;
|
sqlite3_stmt* stmt_obj = NULL;
|
||||||
int ret = sqlite3_prepare16_v2(db_hand_ptr, req_statement.c_str(), -1, &stmt_obj_ptr, 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");
|
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) {
|
while (true) {
|
||||||
ret = sqlite3_step(stmt_obj_ptr);
|
ret = sqlite3_step(stmt_obj);
|
||||||
if (ret == SQLITE_DONE)
|
if (ret == SQLITE_DONE)
|
||||||
break;
|
break;
|
||||||
if (ret != SQLITE_ROW) {
|
if (ret != SQLITE_ROW) {
|
||||||
printf("sqlite_row error!!!\n");
|
printf("sqlite_row error!!!\n");
|
||||||
|
printf("%s\n", sqlite3_errmsg(db_hand));
|
||||||
break;
|
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");
|
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(ret == 0, "Invalid settings[\"database\"] field");
|
||||||
een9_ASSERT(!een9::isRegularFile(db_path), "Database file exists prior to initialization. "
|
een9_ASSERT(!een9::isRegularFile(db_path), "Database file exists prior to initialization. "
|
||||||
"Can't preceed withut harming existing data");
|
"Can't preceed withut harming existing data");
|
||||||
sqlite3* db_hand_ptr = NULL;
|
// sqlite3* db_hand = NULL;
|
||||||
ret = sqlite3_open(db_path.c_str(), &db_hand_ptr);
|
// ret = sqlite3_open(db_path.c_str(), &db_hand);
|
||||||
een9_ASSERT(ret == 0, "Can't open database");
|
// een9_ASSERT(ret == 0, "Can't open database");
|
||||||
struct Guard1{sqlite3*& dhp; ~Guard1(){if (sqlite3_close(dhp) != 0) {abort();}}} guard1{db_hand_ptr};
|
// struct Guard1{sqlite3*& dhp; ~Guard1(){if (sqlite3_close(dhp) != 0) {abort();}}} guard1{db_hand};
|
||||||
sqlite_single_statement(db_hand_ptr, "CREATE TABLE tb(a INT, b INT);");
|
// sqlite_single_statement(db_hand, "CREATE TABLE tb(a INT, b INT);");
|
||||||
|
// todo: actually write something
|
||||||
}
|
}
|
@ -6,7 +6,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
void usage(char** argv) {
|
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);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user