Skip to content

Commit 233f0c0

Browse files
rickrick
rick
authored and
rick
committed
refactor deps
1 parent fa4e974 commit 233f0c0

22 files changed

+311
-13
lines changed

.envrc

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
#paleta < ~/.palettes/frontend-galaxy-dark
22
export PATH="$(pwd)/scripts:$PATH"
33
kfc -s base16-bright
4+
5+
if [[ -e "$ALACRITTY_SOCKET" ]]; then
6+
pycritty -f DaddyTimeMono_Nerd_Font_Mono
7+
fi

.gitmodules

+12
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,15 @@
346346
[submodule "submodules/SDL_DBGP"]
347347
path = submodules/SDL_DBGP
348348
url = https://github.com/superzazu/SDL_DBGP
349+
[submodule "submodules/libgit2"]
350+
path = submodules/libgit2
351+
url = https://github.com/libgit2/libgit2
352+
[submodule "submodules/isalloc"]
353+
path = submodules/isalloc
354+
url = https://github.com/struct/isoalloc
355+
[submodule "submodules/list"]
356+
path = submodules/list
357+
url = https://github.com/clibs/list
358+
[submodule "submodules/gumbo-get-element-by-id.c"]
359+
path = submodules/gumbo-get-element-by-id.c
360+
url = https://github.com/stephenmathieson/gumbo-get-element-by-id.c

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ uncrustify-clean:
3535
@find . -type f -name "*unc-back*"|xargs -I % unlink %
3636

3737
clean:
38-
@rm -rf vendor build meson .cache subprojects
38+
@rm -rf build .cache
3939

4040
fix-dbg:
4141
@$(SED) 's|, % s);|, %s);|g' -i $(TIDIED_FILES)

ee-test/ee-test.c

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#include "ee-test.h"
2+
#include <assert.h>
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include <sys/stat.h>
6+
int ee_main(void);
7+
int ee_main_once(void);
8+
int ee_main_loop(void);
9+
void on_added_new_listener(void *arg);
10+
11+
ee_t *EE;
12+
#define LOOP_LIM 10
13+
#define L log_info
14+
15+
void on_hello(void *arg);
16+
void on_hi(void *arg);
17+
18+
19+
TEST test_logh(void){
20+
log_info("logging an info message");
21+
log_warn("logging a warn message");
22+
log_debug("logging a debug message");
23+
log_error("logging an error %d", 123);
24+
L("xxxxxxxxxxxx %s", "2222222222");
25+
PASS();
26+
}
27+
28+
29+
TEST test_ee_loop(void){
30+
ee_main_loop();
31+
PASS();
32+
}
33+
34+
35+
TEST test_ee_once(void){
36+
ee_main_once();
37+
PASS();
38+
}
39+
40+
41+
TEST test_ee(void){
42+
ee_main();
43+
PASS();
44+
}
45+
46+
SUITE(suite_ee_once) {
47+
test_ee_once();
48+
PASS();
49+
}
50+
SUITE(suite_logh) {
51+
test_logh();
52+
PASS();
53+
}
54+
SUITE(suite_ee_loop) {
55+
test_ee_loop();
56+
PASS();
57+
}
58+
SUITE(suite_ee) {
59+
test_ee();
60+
PASS();
61+
}
62+
63+
GREATEST_MAIN_DEFS();
64+
65+
66+
int main(int argc, char **argv) {
67+
GREATEST_MAIN_BEGIN();
68+
(void)argc; (void)argv;
69+
RUN_SUITE(suite_logh);
70+
RUN_SUITE(suite_ee);
71+
RUN_SUITE(suite_ee_once);
72+
RUN_SUITE(suite_ee_loop);
73+
74+
GREATEST_MAIN_END();
75+
return(0);
76+
}
77+
78+
79+
void on_added_new_listener(void *arg) {
80+
ee_new_listener_t *listener;
81+
82+
listener = (ee_new_listener_t *)arg;
83+
L("New listener added for event '%s'.", listener->name);
84+
}
85+
86+
87+
int ee_main_once(void) {
88+
const char *event_hello = "hello";
89+
const char *event_hi = "hi";
90+
91+
EE = ee_new();
92+
ee_once(EE, event_hi, on_hi);
93+
assert(1 == ee_listener_count(EE, event_hi));
94+
ee_emit(EE, event_hi, "world");
95+
assert(0 == ee_listener_count(EE, event_hi));
96+
ee_emit(EE, event_hi, "world"); /* => nothing happens */
97+
return(0);
98+
}
99+
100+
101+
int ee_main_loop(void) {
102+
const char *event_hello = "hello";
103+
const char *event_hi = "hi";
104+
105+
EE = ee_new();
106+
ee_on(EE, EE_NEW_LISTENER, on_added_new_listener);
107+
ee_on(EE, event_hello, on_hello);
108+
ee_once(EE, event_hi, on_hi);
109+
for (int i = 0; i < LOOP_LIM; i++) {
110+
ee_emit(EE, event_hello, "world");
111+
ee_emit(EE, event_hi, "world");
112+
}
113+
}
114+
115+
116+
void on_hello(void *arg) {
117+
char *s = (char *)arg;
118+
119+
L("Invoked `on_hello` with '%s'", s);
120+
}
121+
122+
123+
void on_hi(void *arg) {
124+
char *s = (char *)arg;
125+
126+
L("Invoked `on_hi` with '%s'", s);
127+
}
128+
129+
130+
int ee_main(void) {
131+
const char *event_hello = "hello";
132+
const char *event_hi = "hi";
133+
134+
EE = ee_new();
135+
136+
ee_on(EE, EE_NEW_LISTENER, on_added_new_listener);
137+
138+
assert(0 == ee_listener_count(EE, event_hello));
139+
140+
/* subscribe "hello" indefinitely, "hi" only once */
141+
ee_on(EE, event_hello, on_hello);
142+
ee_once(EE, event_hi, on_hi);
143+
144+
L("ee_listener_count,event_hello->%d", ee_listener_count(EE, event_hello));
145+
assert(1 == ee_listener_count(EE, event_hello));
146+
assert(1 == ee_listener_count(EE, event_hi));
147+
148+
ee_emit(EE, event_hello, "world");
149+
ee_emit(EE, event_hi, "world");
150+
151+
assert(1 == ee_listener_count(EE, event_hello));
152+
assert(0 == ee_listener_count(EE, event_hi));
153+
154+
ee_emit(EE, event_hello, "world");
155+
ee_emit(EE, event_hi, "world"); /* => nothing happens */
156+
157+
ee_remove_listener(EE, event_hello, on_hello);
158+
assert(0 == ee_listener_count(EE, event_hello));
159+
160+
ee_emit(EE, event_hello, "world"); /* => nothing happens */
161+
162+
return(0);
163+
}

ee-test/ee-test.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
#include "cargs/include/cargs.h"
3+
#include "submodules/ee.c/src/ee.h"
4+
#include "submodules/greatest/greatest.h"
5+
#include "submodules/log.h/log.h"
6+
#include <ctype.h>
7+
#include <stdarg.h>
8+
#include <stdbool.h>
9+
#include <stdbool.h>
10+
#include <stdint.h>
11+
#include <stdint.h>
12+
#include <stdio.h>
13+
#include <stdio.h>
14+
#include <stdlib.h>
15+
#include <stdlib.h>
16+
#include <string.h>
17+
#include <string.h>
18+
#include <sys/time.h>
19+

ee-test/meson.build

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ee_test_srcs = [
2+
'ee-test.c',
3+
]
4+
ee_test_inc = [
5+
inc,
6+
]
7+
ee_test_deps = [
8+
ee_dep,
9+
list_dep,
10+
greatest_dep,
11+
ansicodes_dep,
12+
logh_dep,
13+
]
14+
15+
if get_option('enable-binaries')
16+
ee_test_exec = executable('ee-test',
17+
ee_test_srcs,
18+
dependencies: ee_test_deps,
19+
include_directories: ee_test_inc,
20+
)
21+
if get_option('enable-binary-tests')
22+
test('ee-test', ee_test_exec, args: [])
23+
endif
24+
endif

etc/uncrustify.cfg

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ indent_columns = 2
44
indent_with_tabs = 0
55
indent_class = true
66
indent_member = 2
7-
indent_bool_paren = true
87
indent_first_bool_expr = true
98
sp_arith = force
109
sp_assign = force

gumbo-test/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ if get_option('enable-binaries')
1515
include_directories: gumbo_test_inc,
1616
)
1717
if get_option('enable-binary-tests')
18-
test('gumbo-test', gumbo_test_exec, args: ['--test'])
18+
test('gumbo-test', gumbo_test_exec, args: ['../submodules/gumbo-parser/benchmarks/wikipedia.html'])
1919
endif
2020
endif

meson.build

+2-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ project('meson_deps', ['c'],
77
#############################################################
88
cc = meson.get_compiler('c')
99
#//***********************************************************/
10-
osx_ldflags = []
1110
deps = []
1211
bin_srcs = []
1312
submodule_srcs = []
@@ -32,15 +31,12 @@ add_project_arguments('-Wno-gnu-alignof-expression', language : 'c')
3231
add_project_arguments('-Wno-varargs', language : 'c')
3332
add_project_arguments('-Wno-return-type', language : 'c')
3433
#############################################################################
35-
#osx_ldflags += ['-Wl,-framework,CoreFoundation']
36-
#osx_ldflags += '-Wl,-framework,Carbon'
37-
#osx_ldflags += ['-Wl,-framework,Foundation', '-Wl,-framework,AppKit']
38-
#add_project_link_arguments(osx_ldflags, language : ['objc', 'c'])
3934
pwd_bin = find_program('pwd', required : true)
4035
pwd = run_command(pwd_bin, check: true).stdout().strip()
4136
meson_deps_dir = pwd
4237
#############################################################################
4338
inc = [
39+
include_directories('submodules/list/src'),
4440
include_directories('submodules/libspng/spng'),
4541
include_directories('submodules/debug_print_h'),
4642
include_directories('submodules/debug_print_h/src'),
@@ -63,10 +59,6 @@ inc = [
6359
include_directories('.'),
6460
]
6561
###########################################
66-
subdir('meson/deps/sdl2')
67-
subdir('meson/deps/gumbo')
68-
subdir('meson/deps/cgif')
69-
subdir('meson/deps/dbgp')
7062
subdir('meson')
7163
###########################################
7264
subdir('deps')
@@ -82,3 +74,4 @@ subdir('gumbo-test')
8274
subdir('cgif-test')
8375
###########################################
8476
subdir('dbgp-test')
77+
subdir('ee-test')

meson/args/meson.build

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
add_project_arguments('-D_GNU_SOURCE', language : 'c')
2+
add_project_arguments('-DDBG_H_DEF_ONCE', language : 'c')
3+
add_project_arguments('-DDBG_H_NO_WARNING', language : 'c')
4+
add_project_arguments('-DASSERTF_DEF_ONCE', language : 'c')
5+
add_project_arguments('-DLOG_USE_COLOR', language : 'c')
6+
add_project_arguments('-DLOG_LEVEL=TRACE', language : 'c')
7+
add_project_arguments('-Wno-pragma-once-outside-header', language : 'c')
8+
add_project_arguments('-Wno-incompatible-pointer-types', language : 'c')
9+
add_project_arguments('-Wno-pointer-sign', language : 'c')
10+
add_project_arguments('-Wno-unused-value', language : 'c')
11+
add_project_arguments('-Wno-gnu-alignof-expression', language : 'c')
12+
add_project_arguments('-Wno-varargs', language : 'c')
13+
add_project_arguments('-Wno-return-type', language : 'c')

meson/deps/ansicodes/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ansicodes_lib = static_library('ansicodes',
2-
pwd+'/submodules/c_ansi/ansi-codes/ansi-codes.c',
2+
meson_deps_dir+'/submodules/c_ansi/ansi-codes/ansi-codes.c',
33
install: false,
44
dependencies: [
55
],

meson/deps/curl/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
curl_dep = cc.find_library('curl', required : true)

meson/deps/ee/meson.build

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ee_lib = static_library('ee',
2+
pwd + '/submodules/ee.c/src/ee.c',
3+
install: false,
4+
dependencies: [
5+
list_dep
6+
],
7+
include_directories: [
8+
inc,
9+
]
10+
)
11+
ee_dep = declare_dependency(include_directories: [inc], link_with: ee_lib)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
gumbo_id_lib = static_library('gumbo-id',
2+
pwd + '/submodules/gumbo-get-element-by-id.c/src/get-element-by-id.c',
3+
install: false,
4+
dependencies: [
5+
],
6+
include_directories: [
7+
inc,
8+
]
9+
)
10+
gumbo_id_dep = declare_dependency(include_directories: [inc], link_with: gumbo_id_lib)

meson/deps/list/meson.build

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
list_lib = static_library('list',
2+
pwd + '/submodules/list/src/list.c',
3+
pwd + '/submodules/list/src/list_iterator.c',
4+
pwd + '/submodules/list/src/list_node.c',
5+
install: false,
6+
dependencies: [
7+
],
8+
include_directories: [
9+
inc,
10+
]
11+
)
12+
list_dep = declare_dependency(include_directories: [inc], link_with: list_lib)

meson/deps/log.h/meson.build

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
logh_lib = library('logh',
2+
install: false,
3+
dependencies: [
4+
ansicodes_dep
5+
],
6+
include_directories: [
7+
inc,
8+
]
9+
)
10+
logh_dep = declare_dependency(include_directories: [inc], link_with: logh_lib)

meson/inc/meson.build

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
inc_dirs = include_directories(
3+
'../../',
4+
'../../submodules',
5+
'../../submodules/c_fsio/include',
6+
'../../submodules/slug.c/src',
7+
'../../submodules/slug.c/deps',
8+
'../../submodules/slug.c',
9+
'../../submodules/djbhash/src',
10+
'../../submodules/djbhash',
11+
'../../submodules/c_string_buffer/include',
12+
'../../submodules/c_stringfn/include',
13+
'../../submodules/greatest',
14+
'../../submodules/uuid4',
15+
)
16+
inc += inc_dirs

meson/meson.build

+7
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,11 @@ subdir('deps/generic_print')
4444
subdir('deps/libspinner')
4545
subdir('deps/ctable')
4646
subdir('deps/libuv')
47+
subdir('deps/sdl2')
48+
subdir('deps/list')
49+
subdir('deps/gumbo')
50+
subdir('deps/cgif')
51+
subdir('deps/dbgp')
52+
subdir('deps/log.h')
53+
subdir('deps/ee')
4754
####################################

0 commit comments

Comments
 (0)