Compare commits
4 Commits
4002a222f5
...
9363c73bbd
| Author | SHA1 | Date | |
|---|---|---|---|
| 9363c73bbd | |||
| 63f0379df0 | |||
| 48d449a605 | |||
| ad276eae12 |
2
build.sh
2
build.sh
@ -35,7 +35,7 @@ $SRC
|
||||
if [ ! -f "kerep/bin/libkerep-$OS-$ARCH.a" ]; then
|
||||
echo "libkerep-$OS-$ARCH.a not found"
|
||||
cd kerep
|
||||
./build.sh
|
||||
./build.sh "$1"
|
||||
cd ..
|
||||
fi
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
uname_rezult="$(uname -m)"
|
||||
uname_result="$(uname -m)"
|
||||
|
||||
case "$uname_rezult" in
|
||||
case "$uname_result" in
|
||||
arm | arm32 | armhf | aarch32)
|
||||
ARCH=arm32
|
||||
;;
|
||||
@ -15,7 +15,7 @@ case "$uname_rezult" in
|
||||
ARCH=x64
|
||||
;;
|
||||
*)
|
||||
echo "unknown CPU architecture: $uname_rezult"
|
||||
echo "unknown CPU architecture: $uname_result"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
uname_rezult="$(uname -o)"
|
||||
uname_result="$(uname -o)"
|
||||
|
||||
case "$uname_rezult" in
|
||||
case "$uname_result" in
|
||||
Msys | Cygwin | "MS/Windows")
|
||||
OS=windows
|
||||
;;
|
||||
@ -18,7 +18,7 @@ case "$uname_rezult" in
|
||||
OS=macos
|
||||
;;
|
||||
*)
|
||||
echo "unknown operating system: $uname_rezult"
|
||||
echo "unknown operating system: $uname_result"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -6,17 +6,15 @@ gcc: {
|
||||
src_dirs: [ "src" ],
|
||||
};
|
||||
|
||||
configurations: {
|
||||
release: {
|
||||
preprocess_sources: {
|
||||
src_languages: [ "c", "c++" ],
|
||||
src_dirs: [ "src" ],
|
||||
},
|
||||
gcc: {
|
||||
pre_args: [ "-O2" ],
|
||||
post_args: [ "-Wl,--gc-sections" ],
|
||||
};
|
||||
};
|
||||
release: {
|
||||
preprocess_sources: {
|
||||
src_languages: [ "c", "c++" ],
|
||||
src_dirs: [ "src" ],
|
||||
},
|
||||
gcc: {
|
||||
pre_args: [ "-O2" ],
|
||||
post_args: [ "-Wl,--gc-sections" ],
|
||||
},
|
||||
};
|
||||
|
||||
tasks: {
|
||||
@ -24,7 +22,7 @@ tasks: {
|
||||
pre_tasks: [ ],
|
||||
tool_order: [ "preprocess_sources", "gcc", "g++", "g++-link" ],
|
||||
#g++: [ ... ],
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
languages: [
|
||||
@ -35,14 +33,20 @@ languages: [
|
||||
{
|
||||
aliases: [ "c-header" ],
|
||||
file_extensions: [ "h" ],
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
tools: [
|
||||
{
|
||||
aliases: [ "preprocess_sources" ],
|
||||
exe_file: "echo",
|
||||
supported_languages: [ "any" ],
|
||||
parallel: false,
|
||||
},
|
||||
{
|
||||
aliases: [ "gcc" ],
|
||||
exe_file: "gcc",
|
||||
supported_languages: [ "c" ]; # set to "any" to use with any lang
|
||||
parallel: false,
|
||||
}
|
||||
},
|
||||
];
|
||||
@ -2,8 +2,15 @@
|
||||
set -eo pipefail
|
||||
|
||||
CMP="gcc"
|
||||
WARN="-std=c11 -Wall -Wno-discarded-qualifiers -Wno-unused-parameter"
|
||||
ARGS="-O2"
|
||||
WARN="-std=c99 -Wall -Wextra -Wno-discarded-qualifiers -Wno-unused-parameter"
|
||||
ARGS_DEBUG="-O0 -g"
|
||||
ARGS_RELEASE="-O2 -flto=auto -fdata-sections -ffunction-sections -Wl,--gc-sections"
|
||||
if [[ "$1" = "debug" ]]; then
|
||||
ARGS=$ARGS_DEBUG
|
||||
else
|
||||
ARGS=$ARGS_RELEASE
|
||||
fi
|
||||
|
||||
SRC="$(find src -name '*.c')"
|
||||
|
||||
OS=$(../detect_os.sh)
|
||||
|
||||
@ -64,64 +64,64 @@ Maybe file_close(FileHandle file){
|
||||
}
|
||||
|
||||
#define ioWriteCheck() \
|
||||
if(rezult==EOF) \
|
||||
if(result==EOF) \
|
||||
safethrow(ERR_IO_EOF,;); \
|
||||
if(rezult!=0) \
|
||||
if(result!=0) \
|
||||
safethrow(ERR_IO,;);
|
||||
|
||||
Maybe file_writeChar(FileHandle file, char byte){
|
||||
i32 rezult=fputc(byte, file);
|
||||
i32 result=fputc(byte, file);
|
||||
ioWriteCheck();
|
||||
return MaybeNull;
|
||||
}
|
||||
|
||||
Maybe file_writeBuffer(FileHandle file, char* buffer, u64 length){
|
||||
i32 rezult=0;
|
||||
for(u64 i=0; i<length && !rezult; i++)
|
||||
rezult=fputc(buffer[i], file);
|
||||
i32 result=0;
|
||||
for(u64 i=0; i<length && !result; i++)
|
||||
result=fputc(buffer[i], file);
|
||||
ioWriteCheck();
|
||||
return MaybeNull;
|
||||
}
|
||||
|
||||
Maybe file_writeCptr(FileHandle file, char* cptr){
|
||||
i32 rezult=fputs(cptr, file);
|
||||
i32 result=fputs(cptr, file);
|
||||
ioWriteCheck();
|
||||
return MaybeNull;
|
||||
}
|
||||
|
||||
|
||||
Maybe file_readChar(FileHandle file){
|
||||
i32 rezult=fgetc(file);
|
||||
i32 result=fgetc(file);
|
||||
if(feof(file)) safethrow(ERR_IO_EOF,;);
|
||||
if(ferror(file)) safethrow(ERR_IO,;);
|
||||
return SUCCESS(UniUInt64(rezult));
|
||||
return SUCCESS(UniUInt64(result));
|
||||
}
|
||||
|
||||
Maybe file_readBuffer(FileHandle file, char* buffer, u64 length){
|
||||
i32 rezult=0;
|
||||
i32 result=0;
|
||||
u64 i=0;
|
||||
for(; i<length && rezult!=EOF; i++){
|
||||
rezult=fgetc(file);
|
||||
buffer[i]=(char)rezult;
|
||||
for(; i<length && result!=EOF; i++){
|
||||
result=fgetc(file);
|
||||
buffer[i]=(char)result;
|
||||
}
|
||||
if(ferror(file)) safethrow(ERR_IO,;);
|
||||
return SUCCESS(UniUInt64(i));
|
||||
}
|
||||
|
||||
Maybe file_readAll(FileHandle file, char** allBytes){
|
||||
i32 rezult=0;
|
||||
i32 result=0;
|
||||
char buffer[256];
|
||||
string bufStr={.ptr=buffer, .length=sizeof(buffer)};
|
||||
StringBuilder* sb=StringBuilder_create();
|
||||
u64 i=0;
|
||||
while(true){
|
||||
rezult=fgetc(file);
|
||||
if(rezult==EOF){
|
||||
result=fgetc(file);
|
||||
if(result==EOF){
|
||||
if(ferror(file))
|
||||
safethrow(ERR_IO, StringBuilder_free(sb));
|
||||
break;
|
||||
}
|
||||
buffer[i%sizeof(buffer)]=(char)rezult;
|
||||
buffer[i%sizeof(buffer)]=(char)result;
|
||||
i++;
|
||||
if(!(i%sizeof(buffer)))
|
||||
StringBuilder_append_string(sb,bufStr);
|
||||
|
||||
@ -22,7 +22,7 @@ char* __path_concat(u32 n, ...){
|
||||
const char* output=totality;
|
||||
totality[totalLength]=0;
|
||||
|
||||
// copying content of all strings to rezult
|
||||
// copying content of all strings to result
|
||||
u16 k=0;
|
||||
for(; k<n-1; k++){
|
||||
memcopy(parts[k], totality, lengths[k]);
|
||||
@ -74,11 +74,11 @@ char* path_parentDir(char* dir){
|
||||
|
||||
char* path_basename(char* path, bool with_extension){
|
||||
i32 nameIndex=cptr_lastIndexOfChar(path, path_sep)+1;
|
||||
string rezult=string_fromCptr(path+nameIndex);
|
||||
string result=string_fromCptr(path+nameIndex);
|
||||
if(!with_extension){
|
||||
i32 extIndex=cptr_lastIndexOfChar(rezult.ptr, '.');
|
||||
i32 extIndex=cptr_lastIndexOfChar(result.ptr, '.');
|
||||
if(extIndex!=0 && extIndex!=-1)
|
||||
rezult.length=extIndex;
|
||||
result.length=extIndex;
|
||||
}
|
||||
return string_extract(rezult);
|
||||
return string_extract(result);
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ void Hashtable_expand(Hashtable* ht){
|
||||
ht->rows=newrows;
|
||||
}
|
||||
|
||||
Autoarr(KVPair)* getrow(Hashtable* ht, char* key, bool can_expand){
|
||||
Autoarr(KVPair)* getrow(Hashtable* ht, const char* key, bool can_expand){
|
||||
u32 hash=hashs(hash_sdbm32, key);
|
||||
Autoarr(KVPair)* ar=ht->rows[hash%HT_HEIGHTS[ht->hein]];
|
||||
if(can_expand && Autoarr_length(ar)==Autoarr_max_length(ar))
|
||||
@ -69,7 +69,7 @@ Autoarr(KVPair)* getrow(Hashtable* ht, char* key, bool can_expand){
|
||||
|
||||
/// @param key must be heap allocated
|
||||
/// Hashtable_free will free this pointer
|
||||
void Hashtable_add(Hashtable* ht, char* key, Unitype u){
|
||||
void Hashtable_add(Hashtable* ht, const char* key, Unitype u){
|
||||
KVPair p={ .key=key, .value=u };
|
||||
Autoarr_add(getrow(ht,key,true),p);
|
||||
}
|
||||
@ -81,7 +81,7 @@ void Hashtable_addMany(Hashtable* ht, KVPair* pair_array, u32 count){
|
||||
}
|
||||
|
||||
// returns null or pointer to value in hashtable
|
||||
Unitype* Hashtable_getPtr(Hashtable* ht, char* key){
|
||||
Unitype* Hashtable_getPtr(Hashtable* ht, const char* key){
|
||||
Autoarr(KVPair)* ar=getrow(ht,key,false);
|
||||
u32 arlen=Autoarr_length(ar);
|
||||
for(u32 i=0;i<arlen;i++){
|
||||
@ -91,7 +91,7 @@ Unitype* Hashtable_getPtr(Hashtable* ht, char* key){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Unitype Hashtable_get(Hashtable* ht, char* key){
|
||||
Unitype Hashtable_get(Hashtable* ht, const char* key){
|
||||
Autoarr(KVPair)* ar=getrow(ht,key,false);
|
||||
u32 arlen=Autoarr_length(ar);
|
||||
for(u32 i=0;i<arlen;i++){
|
||||
@ -101,14 +101,14 @@ Unitype Hashtable_get(Hashtable* ht, char* key){
|
||||
return UniNull;
|
||||
}
|
||||
|
||||
bool Hashtable_tryGet(Hashtable* ht, char* key, Unitype* output){
|
||||
bool Hashtable_tryGet(Hashtable* ht, const char* key, Unitype* output){
|
||||
Unitype u=Hashtable_get(ht,key);
|
||||
*output=u;
|
||||
return !Unitype_isUniNull(u);
|
||||
}
|
||||
|
||||
|
||||
bool Hashtable_trySet(Hashtable* ht, char* key, Unitype u){
|
||||
bool Hashtable_trySet(Hashtable* ht, const char* key, Unitype u){
|
||||
Unitype* val=Hashtable_getPtr(ht,key);
|
||||
if(val==NULL)
|
||||
return false;
|
||||
@ -116,7 +116,7 @@ bool Hashtable_trySet(Hashtable* ht, char* key, Unitype u){
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Hashtable_tryAdd(Hashtable* ht, char* key, Unitype u){
|
||||
bool Hashtable_tryAdd(Hashtable* ht, const char* key, Unitype u){
|
||||
Unitype* val=Hashtable_getPtr(ht,key);
|
||||
if(val==NULL){
|
||||
Hashtable_add(ht, key, u);
|
||||
@ -125,7 +125,7 @@ bool Hashtable_tryAdd(Hashtable* ht, char* key, Unitype u){
|
||||
return false;
|
||||
}
|
||||
|
||||
void Hashtable_addOrSet(Hashtable* ht, char* key, Unitype u){
|
||||
void Hashtable_addOrSet(Hashtable* ht, const char* key, Unitype u){
|
||||
Unitype* val=Hashtable_getPtr(ht, key);
|
||||
if(val==NULL)
|
||||
Hashtable_add(ht, key, u); // add
|
||||
|
||||
@ -23,18 +23,18 @@ u16 Hashtable_height(Hashtable* ht);
|
||||
// don't add pairs with the same keys,
|
||||
// or something weird will happen
|
||||
// if not sure, use Hashtable_addOrSet()
|
||||
void Hashtable_add(Hashtable* ht, char* key, Unitype u);
|
||||
void Hashtable_add(Hashtable* ht, const char* key, Unitype u);
|
||||
|
||||
void Hashtable_addOrSet(Hashtable* ht, char* key, Unitype u);
|
||||
void Hashtable_addOrSet(Hashtable* ht, const char* key, Unitype u);
|
||||
void Hashtable_addMany(Hashtable* ht, KVPair* pair_array, u32 count);
|
||||
bool Hashtable_tryAdd(Hashtable* ht, char* key, Unitype u);
|
||||
bool Hashtable_trySet(Hashtable* ht, char* key, Unitype u);
|
||||
bool Hashtable_tryAdd(Hashtable* ht, const char* key, Unitype u);
|
||||
bool Hashtable_trySet(Hashtable* ht, const char* key, Unitype u);
|
||||
|
||||
// returns null or pointer to value in hashtable
|
||||
Unitype* Hashtable_getPtr(Hashtable* ht, char* key);
|
||||
Unitype* Hashtable_getPtr(Hashtable* ht, const char* key);
|
||||
|
||||
Unitype Hashtable_get(Hashtable* ht, char* key);
|
||||
bool Hashtable_tryGet(Hashtable* ht, char* key, Unitype* output);
|
||||
Unitype Hashtable_get(Hashtable* ht, const char* key);
|
||||
bool Hashtable_tryGet(Hashtable* ht, const char* key, Unitype* output);
|
||||
|
||||
#define Hashtable_foreach(HT, EL, codeblock...) { \
|
||||
u16 hmax=Hashtable_height(HT); \
|
||||
|
||||
@ -8,7 +8,7 @@ extern "C" {
|
||||
#include "../Autoarr/Autoarr.h"
|
||||
|
||||
STRUCT(KVPair,
|
||||
char* key;
|
||||
const char* key;
|
||||
Unitype value;
|
||||
)
|
||||
|
||||
|
||||
@ -160,7 +160,7 @@ char* __cptr_concat(u32 n, ...){
|
||||
char* output=totality;
|
||||
totality[totalLength]=0;
|
||||
|
||||
// copying content of all strings to rezult
|
||||
// copying content of all strings to result
|
||||
for(u16 k=0; k<n; k++){
|
||||
memcopy(strs[k], totality, lengths[k]);
|
||||
totality+=lengths[k];
|
||||
@ -212,6 +212,6 @@ char* cptr_replaceIn(const char* src, const char* str_old, const char* str_new,
|
||||
u32 src_remains_len=cptr_length(src);
|
||||
if(src_remains_len>0)
|
||||
StringBuilder_append_string(sb, (string){.ptr=(char*)src, .length=src_remains_len});
|
||||
string rezult=StringBuilder_build(sb);
|
||||
return rezult.ptr;
|
||||
string result=StringBuilder_build(sb);
|
||||
return result.ptr;
|
||||
}
|
||||
|
||||
@ -25,23 +25,23 @@ char* errname(ErrorId err){
|
||||
|
||||
char* __genErrMsg(const char* errmsg, const char* srcfile, i32 line, const char* funcname){
|
||||
size_t bufsize=ERRMSG_MAXLENGTH;
|
||||
char* rezult=malloc(bufsize);
|
||||
char* result=malloc(bufsize);
|
||||
IFMSC(
|
||||
sprintf_s(rezult,bufsize,"[%s:%d] %s() throwed error: %s",srcfile,line,funcname,errmsg),
|
||||
sprintf(rezult,"[%s:%d] %s() throwed error: %s",srcfile,line,funcname,errmsg)
|
||||
sprintf_s(result,bufsize,"[%s:%d] %s() throwed error: %s",srcfile,line,funcname,errmsg),
|
||||
sprintf(result,"[%s:%d] %s() throwed error: %s",srcfile,line,funcname,errmsg)
|
||||
);
|
||||
return rezult;
|
||||
return result;
|
||||
}
|
||||
|
||||
char* __extendErrMsg(const char* errmsg, const char* srcfile, i32 line, const char* funcname){
|
||||
size_t bufsize=cptr_length(errmsg)+ERRMSG_MAXLENGTH;
|
||||
char* rezult=malloc(bufsize);
|
||||
char* result=malloc(bufsize);
|
||||
IFMSC(
|
||||
sprintf_s(rezult,bufsize,"%s\n \\___[%s:%d] %s()",errmsg,srcfile,line,funcname),
|
||||
sprintf(rezult,"%s\n \\___[%s:%d] %s()",errmsg,srcfile,line,funcname)
|
||||
sprintf_s(result,bufsize,"%s\n \\___[%s:%d] %s()",errmsg,srcfile,line,funcname),
|
||||
sprintf(result,"%s\n \\___[%s:%d] %s()",errmsg,srcfile,line,funcname)
|
||||
);
|
||||
free(errmsg);
|
||||
return rezult;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Maybe_free(Maybe e){
|
||||
|
||||
@ -60,10 +60,10 @@ char* __unknownErr( );
|
||||
__RETURN_EXCEPTION(((char*)__genErrMsg(E, __FILE__,__LINE__,__func__))); \
|
||||
}
|
||||
|
||||
#define try_cpp(_funcCall, _rezult, freeMem) Maybe _rezult=_funcCall; if(_rezult.errmsg){ \
|
||||
#define try_cpp(_funcCall, _result, freeMem) Maybe _result=_funcCall; if(_result.errmsg){ \
|
||||
freeMem; \
|
||||
_rezult.errmsg=__extendErrMsg(_rezult.errmsg, __FILE__,__LINE__,__func__); \
|
||||
return _rezult; \
|
||||
_result.errmsg=__extendErrMsg(_result.errmsg, __FILE__,__LINE__,__func__); \
|
||||
return _result; \
|
||||
}
|
||||
|
||||
#else
|
||||
@ -73,16 +73,16 @@ char* __unknownErr( );
|
||||
__RETURN_EXCEPTION(((char*)__genErrMsg((__stringify_err(E)), __FILE__,__LINE__,__func__))); \
|
||||
}
|
||||
|
||||
#define try(_funcCall, _rezult, freeMem) Maybe _rezult=_funcCall; if(_rezult.errmsg){ \
|
||||
#define try(_funcCall, _result, freeMem) Maybe _result=_funcCall; if(_result.errmsg){ \
|
||||
freeMem; \
|
||||
_rezult.errmsg=__extendErrMsg(_rezult.errmsg, __FILE__,__LINE__,__func__); \
|
||||
return _rezult; \
|
||||
_result.errmsg=__extendErrMsg(_result.errmsg, __FILE__,__LINE__,__func__); \
|
||||
return _result; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define tryLast(_funcCall, _rezult, ON_EXIT) Maybe _rezult=_funcCall; if(_rezult.errmsg){ \
|
||||
_rezult.errmsg=__extendErrMsg(_rezult.errmsg, __FILE__,__LINE__,__func__); \
|
||||
__EXIT(_rezult.errmsg); \
|
||||
#define tryLast(_funcCall, _result, ON_EXIT) Maybe _result=_funcCall; if(_result.errmsg){ \
|
||||
_result.errmsg=__extendErrMsg(_result.errmsg, __FILE__,__LINE__,__func__); \
|
||||
__EXIT(_result.errmsg); \
|
||||
}
|
||||
|
||||
#if __cplusplus
|
||||
|
||||
@ -132,7 +132,7 @@ You can even embed it into macro in header (see kprint.h)
|
||||
PRAGMA_WARNING_POP
|
||||
|
||||
/// gcc throws warning on unused function return value
|
||||
#define WARN_UNUSED_REZULT __attribute__((warn_unused_result))
|
||||
#define WARN_UNUSED_RESULT __attribute__((WARN_UNUSED_RESULT))
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ typedef void (*freeMembers_t)(void*);
|
||||
typedef char* (*toString_t)(void* obj, u32 fmt);
|
||||
|
||||
STRUCT(ktDescriptor,
|
||||
char* name;
|
||||
const char* name;
|
||||
ktid id;
|
||||
u16 size;
|
||||
freeMembers_t freeMembers; // NULL or function which frees all struct members
|
||||
|
||||
@ -85,11 +85,11 @@ char *Unitype_toString(Unitype u, u32 fmt)
|
||||
valuestr = type->toString(u.VoidPtr, fmt);
|
||||
else
|
||||
valuestr = "ERR_NO_TOSTRING_FUNC";
|
||||
char *rezult = cptr_concat("{ type: ", type->name, ", allocated on heap: ", (u.allocatedInHeap ? "true" : "false"),
|
||||
char *result = cptr_concat("{ type: ", type->name, ", allocated on heap: ", (u.allocatedInHeap ? "true" : "false"),
|
||||
", value:", valuestr, " }");
|
||||
if (type->toString)
|
||||
free(valuestr);
|
||||
return rezult;
|
||||
return result;
|
||||
}
|
||||
|
||||
void printuni(Unitype v)
|
||||
|
||||
@ -53,8 +53,8 @@ Maybe __ksprint(u8 n, kp_fmt* formats, __kp_value_union* objects){
|
||||
StringBuilder_append_cptr(strb, mStr.value.VoidPtr);
|
||||
Unitype_free(mStr.value);
|
||||
}
|
||||
char* rezult=StringBuilder_build(strb).ptr;
|
||||
return SUCCESS(UniHeapPtr(char, rezult));
|
||||
char* result=StringBuilder_build(strb).ptr;
|
||||
return SUCCESS(UniHeapPtr(char, result));
|
||||
}
|
||||
|
||||
Maybe __kfprint(FILE* file, u8 n, kp_fmt* formats, __kp_value_union* objects){
|
||||
|
||||
@ -74,11 +74,14 @@ Maybe Tool_tryApplyOptions(Tool* t, Hashtable* dtsod){
|
||||
if(!UniCheckTypePtr(val, Autoarr(Unitype)))
|
||||
safethrow("src_languages value expected to be a string array", ;);
|
||||
Autoarr(Unitype)* ar = val.VoidPtr;
|
||||
|
||||
Unitype any_lang_uni;
|
||||
bool is_any_language = Hashtable_tryGet(t->supported_languages, "any", &any_lang_uni);
|
||||
Autoarr_foreach(ar, el,
|
||||
if(!UniCheckTypePtr(el, char))
|
||||
safethrow("src_languages array values expected to be string", ;);
|
||||
const char* l_name = el.VoidPtr;
|
||||
if(!Hashtable_tryGet(t->supported_languages, l_name, &val))
|
||||
if(!is_any_language && !Hashtable_tryGet(t->supported_languages, l_name, &val))
|
||||
safethrow(cptr_concat("language '", l_name, "' isn't supported by tool '", Autoarr_get(t->aliases, 0), "'"), ;);
|
||||
Hashtable_add(t->src_languages, l_name, val);
|
||||
)
|
||||
@ -127,11 +130,7 @@ Maybe CompilationScenario_tryApplyPlatformSpecificOptions(CompilationScenario* s
|
||||
try(CompilationScenario_tryApplyConditionalOptions(sc, dtsod, os_and_arch), _m2, ;);
|
||||
free(os_and_arch);
|
||||
|
||||
os_and_arch = cptr_concat(os, "_", arch);
|
||||
try(CompilationScenario_tryApplyConditionalOptions(sc, dtsod, os_and_arch), _m3, ;);
|
||||
free(os_and_arch);
|
||||
|
||||
return SUCCESS(UniBool(_m0.value.Bool || _m1.value.Bool || _m2.value.Bool || _m3.value.Bool));
|
||||
return SUCCESS(UniBool(_m0.value.Bool || _m1.value.Bool || _m2.value.Bool));
|
||||
}
|
||||
|
||||
Maybe CompilationScenario_applyConfigurationOptions(CompilationScenario* sc, Hashtable* dtsod, const char* configuration){
|
||||
@ -142,8 +141,13 @@ Maybe CompilationScenario_applyConfigurationOptions(CompilationScenario* sc, Has
|
||||
}
|
||||
|
||||
Maybe CompilationScenario_applyTaskOptions(CompilationScenario* sc, Hashtable* dtsod, const char* task){
|
||||
try(CompilationScenario_tryApplyConditionalOptions(sc, dtsod, task), _m0, ;);
|
||||
if(!_m0.value.Bool)
|
||||
Unitype tasks_uni;
|
||||
if(!Hashtable_tryGet(dtsod, "tasks", &tasks_uni))
|
||||
safethrow(cptr_concat("key 'tasks' not found"), ;);
|
||||
if(!UniCheckTypePtr(tasks_uni, Hashtable))
|
||||
safethrow(ERR_WRONGTYPE, ;);
|
||||
try(CompilationScenario_tryApplyConditionalOptions(sc, tasks_uni.VoidPtr, task), _m1, ;);
|
||||
if(!_m1.value.Bool)
|
||||
safethrow(cptr_concat("task '", task, "' not found"), ;);
|
||||
return MaybeNull;
|
||||
}
|
||||
@ -192,10 +196,18 @@ Maybe CompilationScenario_tryRegisterLanguages(CompilationScenario* sc, Hashtabl
|
||||
// registers each alias of the language
|
||||
Autoarr_foreach(aliases, l_name,
|
||||
if(!Hashtable_tryAdd(sc->languages, l_name, UniHeapPtr(Language, lang)))
|
||||
safethrow(cptr_concat("language '", l_name, "has been already registered"), ;);
|
||||
safethrow(cptr_concat("language '", l_name, "' has been already registered"), ;);
|
||||
)
|
||||
)
|
||||
|
||||
// "any" language
|
||||
Language* any_lang = malloc(sizeof(Language));
|
||||
Autoarr(Pointer)* any_aliases = Autoarr_create(Pointer, 1, 1);
|
||||
Autoarr_add(any_aliases, cptr_copy("any"));
|
||||
Language_construct(any_lang, any_aliases, Autoarr_create(Pointer, 0, 0));
|
||||
if(!Hashtable_tryAdd(sc->languages, "any", UniHeapPtr(Language, any_lang)))
|
||||
safethrow(cptr_concat("language '", "any", "has been already registered"), ;);
|
||||
|
||||
return SUCCESS(UniTrue);
|
||||
}
|
||||
|
||||
|
||||
@ -10,9 +10,9 @@ Maybe Process_start(Process* p, const char* file_path, const char** args, int ar
|
||||
memset(p, 0, sizeof(Process));
|
||||
if(search_in_PATH && !cptr_contains(file_path, "\\")){
|
||||
LPSTR lpFilePart;
|
||||
char search_rezult[MAX_PATH];
|
||||
safethrow_if_false(SearchPath( NULL, file_path, NULL, MAX_PATH, search_rezult, &lpFilePart))
|
||||
file_path = cptr_copy(search_rezult);
|
||||
char search_result[MAX_PATH];
|
||||
safethrow_if_false(SearchPath( NULL, file_path, NULL, MAX_PATH, search_result, &lpFilePart))
|
||||
file_path = cptr_copy(search_result);
|
||||
}
|
||||
|
||||
SECURITY_ATTRIBUTES saAttr;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user