build_dll

This commit is contained in:
Timerix22 2022-03-21 23:20:24 +03:00
parent 20ce758528
commit 5bc866cf3e
7 changed files with 84 additions and 24 deletions

21
.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
# Build results
[Bb]in/
.bin/
[Dd]ebug/
[Rr]elease/
[Rr]eleases/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# IDE files
.vs/
.vscode/
.vshistory/
.idea/
.editorconfig
*.user
#backups
.old*/

View File

@ -1,5 +1,5 @@
#if __cplusplus #if __cplusplus
extern "c" { extern "C" {
#endif #endif
#pragma once #pragma once
@ -8,14 +8,19 @@ extern "c" {
//parses text to binary values //parses text to binary values
Hashtable* DtsodV24_deserialize(char* text); Hashtable* DtsodV24_deserialize(char* text);
//creates text representation of dtsod //creates text representation of dtsod
char* DtsodV24_serialize(Hashtable* dtsod); char* DtsodV24_serialize(Hashtable* dtsod);
//returns value or UniNull if key not found //returns value or UniNull if key not found
Unitype DtsodV24_get(Hashtable* dtsod, char* key); Unitype DtsodV24_get(Hashtable* dtsod, char* key);
//adds or sets value //adds or sets value
void DtsodV24_addOrSet(Hashtable* dtsod, char* key, Unitype value); void DtsodV24_addOrSet(Hashtable* dtsod, char* key, Unitype value);
//checks for dtsod contains value or dont //checks for dtsod contains value or dont
bool DtsodV24_contains(Hashtable* dtsod, char* key); bool DtsodV24_contains(Hashtable* dtsod, char* key);
//replaces value with UniNull if key exists in dtsod //replaces value with UniNull if key exists in dtsod
bool DtsodV24_remove(Hashtable* dtsod, char* key); bool DtsodV24_remove(Hashtable* dtsod, char* key);

View File

@ -1,33 +1,45 @@
SRC=$(wildcard [^tests]**/*.c) SRC=$(wildcard [^tests]**/*.c)
TESTS=$(wildcard tests/*c) $(wildcard tests/**/*.c) TESTS=$(wildcard tests/*c) $(wildcard tests/**/*.c)
OUTDIR=.bin OUTDIR=.bin
OUTFILE=$(OUTDIR)/kerep_test.com
CMP=gcc CMP=gcc
all: clear_c build test
all: clear_c clear_bin build_test build_dll
clear_c: clear_c:
clear clear
clear_bin: clear_bin:
@echo -e '\e[96m--------------[clear_bin]--------------\e[0m' @echo -e '\e[96m--------------[clear_bin]--------------\e[0m'
touch $(OUTDIR)/_.com rm -rf $(OUTDIR)
rm $(OUTDIR)/*.com mkdir $(OUTDIR)
clang: CMP=clang clang: CMP=clang
clang: all clang: all
CMPARGS= -Wall -Wno-discarded-qualifiers $(SRC) $(TESTS) -o $(OUTFILE) TEST_FILE=$(OUTDIR)/kerep_test.com
build: TEST_ARGS= -Wall -Wno-discarded-qualifiers $(SRC) $(TESTS) -o $(TEST_FILE)
@echo -e '\n\e[96m----------------[build]----------------\e[0m' OPT_ARGS= -O1 -flto
@mkdir -p $(OUTDIR) build_test:
$(CMP) -O1 -flto $(CMPARGS) @echo -e '\n\e[96m----------------[build_test]----------------\e[0m'
build_dbg: $(CMP) $(OPT_ARGS) $(TEST_ARGS)
@echo -e '\n\e[96m--------------[build_dbg]--------------\e[0m'
@mkdir -p $(OUTDIR) build_test_dbg:
$(CMP) -O0 -g $(CMPARGS).dbg @echo -e '\n\e[96m--------------[build_test_dbg]--------------\e[0m'
$(CMP) -O0 -g $(TEST_ARGS).dbg
test: test:
@echo -e '\n\e[96m----------------[test]-----------------\e[0m' @echo -e '\n\e[96m----------------[test]-----------------\e[0m'
$(OUTFILE) $(TEST_FILE)
valgrind: clear_c build_dbg
valgrind: clear_c build_test_dbg
@echo -e '\n\e[96m--------------[valgrind]---------------\e[0m' @echo -e '\n\e[96m--------------[valgrind]---------------\e[0m'
valgrind -s --read-var-info=yes --track-origins=yes --fullpath-after=kerep/ \ valgrind -s --read-var-info=yes --track-origins=yes --fullpath-after=kerep/ \
--leak-check=full --show-leak-kinds=all $(OUTFILE).dbg --leak-check=full --show-leak-kinds=all $(TEST_FILE).dbg
DLL_FILE=$(OUTDIR)/kerep.dll
DLL_ARGS= -Wall -Wno-discarded-qualifiers \
-fPIC -shared -Wl,-soname,kerep.dll \
$(SRC) $(TESTS) -o $(DLL_FILE)
build_dll:
@echo -e '\n\e[96m-------------[build_dll]---------------\e[0m'
$(CMP) $(OPT_ARGS) $(DLL_ARGS)

View File

@ -29,7 +29,6 @@ int8 typesize(my_type type);
// can store any base type // can store any base type
typedef struct Unitype{ typedef struct Unitype{
my_type type;
union { union {
int64 Int64; int64 Int64;
uint64 UInt64; uint64 UInt64;
@ -38,11 +37,12 @@ typedef struct Unitype{
bool Bool; bool Bool;
void* VoidPtr; void* VoidPtr;
}; };
my_type type;
} Unitype; } Unitype;
static const Unitype UniNull={Null,.VoidPtr=NULL}; static const Unitype UniNull={.VoidPtr=NULL,.type=Null};
static const Unitype UniTrue={Bool,.Bool=true}; static const Unitype UniTrue={.Bool=true,.type=Bool};
static const Unitype UniFalse={Bool,.Bool=false}; static const Unitype UniFalse={.Bool=false,.type=Bool};
#define Uni(TYPE,VAL) (Unitype){.type=TYPE,.TYPE=VAL} #define Uni(TYPE,VAL) (Unitype){.type=TYPE,.TYPE=VAL}
#define UniPtr(TYPE,VAL) (Unitype){.type=TYPE,.VoidPtr=VAL} #define UniPtr(TYPE,VAL) (Unitype){.type=TYPE,.VoidPtr=VAL}

View File

@ -1,11 +1,20 @@
#include "../base/base.h" #include "../base/base.h"
#include "tests.h" #include "tests.h"
#include "../Hashtable/KeyValuePair.h"
KeyValuePair test_marshalling(char* text){
//printf("<%s>\n", text);
Unitype u={.VoidPtr=text,.type=CharPtr};
KeyValuePair msg={"message",u};
return msg;
}
void test_all(){ void test_all(){
/* test_searchtree(); test_searchtree();
test_autoarr(); test_autoarr();
test_hashtable(); test_hashtable();
test_string(); */ test_string();
test_dtsod(); test_dtsod();
printf("\e[96m---------------------------------------\e[0m\n"); printf("\e[96m---------------------------------------\e[0m\n");
} }

13
tests/test_marshalling.h Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#if __cplusplus
extern "C" {
#endif
#include "../Hashtable/KeyValuePair.h"
KeyValuePair test_marshalling(char* text);
#if __cplusplus
}
#endif

View File

@ -8,4 +8,4 @@ void test_searchtree();
void test_autoarr(); void test_autoarr();
void test_hashtable(); void test_hashtable();
void test_string(); void test_string();
void test_dtsod(); void test_dtsod();