Skip to content

Commit 0522750

Browse files
rickrick
rick
authored and
rick
committed
tighten up meson config
1 parent 233f0c0 commit 0522750

File tree

14 files changed

+207
-68
lines changed

14 files changed

+207
-68
lines changed

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ TESTS_LIST_LOG_FILE = $(shell pwd)/.tests-list.log
1616
TESTS_SUITES_LOG_FILE=$(shell pwd)/.tests-suites.log
1717
TESTS_TESTS_LOG_FILE=$(shell pwd)/.tests-tests.log
1818
##############################################################
19-
TIDIED_FILES = deps*/*.c deps*/*.h term*/*.c term*/*.h ctable*/*.c ctable*/*.h *table*/*.c *table*/*.h gumbo-test/*.c gumbo-test/*.h cgif-test/*.c *-test/*.c *-test/*.h
19+
TIDIED_FILES = deps*/*.c deps*/*.h term*/*.c term*/*.h ctable*/*.c ctable*/*.h *table*/*.c *table*/*.h gumbo-test/*.c gumbo-test/*.h cgif-test/*.c *-test/*.c *-test/*.h chan-test/*.c chan-test/*.h
2020
TRIGGER_FILE=.trigger.c
2121
##############################################################
2222
do-setup:
@@ -32,7 +32,7 @@ fmt-scripts:
3232
uncrustify:
3333
@$(UNCRUSTIFY) -c etc/uncrustify.cfg --replace $(TIDIED_FILES)||true
3434
uncrustify-clean:
35-
@find . -type f -name "*unc-back*"|xargs -I % unlink %
35+
@find . -type f -maxdepth 2 -name "*unc-back*"|xargs -I % unlink %
3636

3737
clean:
3838
@rm -rf build .cache
@@ -66,6 +66,7 @@ do-nodemon:
6666
-w Makefile \
6767
-i '*/embeds/*' -i 'subprojects/*/' -i submodules -i 'build/*' \
6868
-w "term-tests" \
69+
-w "chan-test/*.c" -w "chan-test/*.h" \
6970
-w "term-tests-test" \
7071
-e Makefile,tpl,build,sh,c,h,Makefile \
7172
-x env -- bash -xc 'make'

chan-test/chan-test.c

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#include "ansicodes.h"
2+
#define L log_debug
3+
#define DISPATCHED_JOBS_QTY 100
4+
#define JOBS_BUFFER_QTY 10
5+
#define WORKER_SLEEP_MS 50
6+
#include "chan-test.h"
7+
#include <assert.h>
8+
#include <ctype.h>
9+
#include <pthread.h>
10+
#include <stdarg.h>
11+
#include <stdint.h>
12+
#include <stdint.h>
13+
#include <stdio.h>
14+
#include <stdio.h>
15+
#include <stdlib.h>
16+
#include <stdlib.h>
17+
#include <string.h>
18+
#include <sys/stat.h>
19+
#include <sys/time.h>
20+
#include <time.h>
21+
#include <unistd.h>
22+
23+
volatile int processed_jobs_qty = 0;
24+
volatile int processed_qtys[1024];
25+
chan_t *jobs;
26+
chan_t *done;
27+
28+
29+
void *worker(void *WID){
30+
void *job;
31+
int processed_qty = 0;
32+
size_t WORKER_ID = (size_t)WID;
33+
34+
L("%lu> Worker waing for jobs....", WORKER_ID);
35+
while (chan_recv(jobs, &job) == 0) {
36+
usleep(WORKER_SLEEP_MS * 1000 * WORKER_ID);
37+
processed_qtys[WORKER_ID]++;
38+
processed_qty++;
39+
L(AC_RESETALL AC_YELLOW "<%lu>" AC_RESETALL " #%lu OK. processed %d jobs <%d/%d> (%d jobs in queue)",
40+
WORKER_ID, (size_t)job,
41+
processed_qtys[WORKER_ID],
42+
processed_qty,
43+
DISPATCHED_JOBS_QTY,
44+
chan_size(jobs)
45+
);
46+
}
47+
48+
L(AC_RESETALL AC_GREEN_BLACK AC_ITALIC "%lu> received all jobs> " AC_RESETALL, WORKER_ID);
49+
chan_send(done, (void *)WORKER_ID);
50+
return(NULL);
51+
}
52+
53+
pthread_t th[10];
54+
55+
56+
TEST t_chan_jobs_worker(void){
57+
jobs = chan_init(JOBS_BUFFER_QTY);
58+
done = chan_init(0);
59+
60+
61+
processed_qtys[1] = 0;
62+
pthread_create(&th[0], NULL, worker, (void *)1);
63+
64+
processed_qtys[2] = 0;
65+
pthread_create(&th[1], NULL, worker, (void *)2);
66+
67+
processed_qtys[5] = 0;
68+
pthread_create(&th[2], NULL, worker, (void *)50);
69+
70+
for (int i = 1; i <= DISPATCHED_JOBS_QTY; i++) {
71+
chan_send_int(jobs, i);
72+
log_info(" sent job #%d/%d", i, DISPATCHED_JOBS_QTY);
73+
}
74+
75+
chan_close(jobs);
76+
L("sent all jobs.waiting for done signals......");
77+
78+
chan_recv(done, NULL);
79+
chan_recv(done, NULL);
80+
chan_recv(done, NULL);
81+
82+
log_error("done signals received.....waiting on threads to exit....");
83+
pthread_join(&th[0], NULL);
84+
pthread_join(&th[1], NULL);
85+
pthread_join(&th[2], NULL);
86+
87+
log_error("threads exited..disposing of channels......");
88+
chan_dispose(jobs);
89+
chan_dispose(done);
90+
L("cleaned up jobs channels");
91+
92+
PASS();
93+
}
94+
95+
96+
GREATEST_MAIN_DEFS();
97+
98+
99+
int main(int argc, char **argv) {
100+
(void)argc; (void)argv;
101+
GREATEST_MAIN_BEGIN();
102+
RUN_TEST(t_chan_jobs_worker);
103+
GREATEST_MAIN_END();
104+
return(0);
105+
}
106+

chan-test/chan-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/chan/src/chan.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+

chan-test/meson.build

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
chan_test_srcs = [
2+
'chan-test.c',
3+
]
4+
chan_test_inc = [
5+
inc,
6+
]
7+
chan_test_deps = [
8+
chan_dep,
9+
greatest_dep,
10+
ansicodes_dep,
11+
logh_dep,
12+
ms_dep,
13+
timestamp_dep,
14+
]
15+
16+
if get_option('enable-binaries')
17+
chan_test_exec = executable('chan-test',
18+
chan_test_srcs,
19+
dependencies: chan_test_deps,
20+
include_directories: chan_test_inc,
21+
)
22+
if get_option('enable-binary-tests')
23+
test('chan-test', chan_test_exec, args: [])
24+
endif
25+
endif

meson.build

+7-49
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,20 @@
1-
project('meson_deps', ['c'],
2-
default_options: [
3-
'warning_level=0',
4-
'c_std=gnu99',
5-
]
6-
)
7-
#############################################################
1+
project('meson_deps',['c'],default_options:['warning_level=0','c_std=gnu99'])
82
cc = meson.get_compiler('c')
9-
#//***********************************************************/
10-
deps = []
11-
bin_srcs = []
12-
submodule_srcs = []
13-
#############################################################
14-
fs = import('fs')
15-
pkg_config = import('pkgconfig')
3+
pwd = meson.current_source_dir()
4+
meson_deps_dir = meson.current_source_dir()
165
#############################################################
17-
config = configuration_data()
18-
version = run_command('git', 'describe', '--tags')
19-
config.set('version', version.stdout().strip())
20-
add_project_arguments('-D_GNU_SOURCE', language : 'c')
21-
add_project_arguments('-DDBG_H_DEF_ONCE', language : 'c')
22-
add_project_arguments('-DDBG_H_NO_WARNING', language : 'c')
23-
add_project_arguments('-DASSERTF_DEF_ONCE', language : 'c')
24-
add_project_arguments('-DLOG_USE_COLOR', language : 'c')
25-
add_project_arguments('-DLOG_LEVEL=TRACE', language : 'c')
26-
add_project_arguments('-Wno-pragma-once-outside-header', language : 'c')
27-
add_project_arguments('-Wno-incompatible-pointer-types', language : 'c')
28-
add_project_arguments('-Wno-pointer-sign', language : 'c')
29-
add_project_arguments('-Wno-unused-value', language : 'c')
30-
add_project_arguments('-Wno-gnu-alignof-expression', language : 'c')
31-
add_project_arguments('-Wno-varargs', language : 'c')
32-
add_project_arguments('-Wno-return-type', language : 'c')
33-
#############################################################################
34-
pwd_bin = find_program('pwd', required : true)
35-
pwd = run_command(pwd_bin, check: true).stdout().strip()
36-
meson_deps_dir = pwd
37-
#############################################################################
386
inc = [
397
include_directories('submodules/list/src'),
40-
include_directories('submodules/libspng/spng'),
41-
include_directories('submodules/debug_print_h'),
42-
include_directories('submodules/debug_print_h/src'),
43-
include_directories('submodules'),
44-
include_directories('submodules/c_fsio/include'),
45-
include_directories('submodules/c_string_buffer/include'),
46-
include_directories('submodules/c_stringfn/include'),
47-
include_directories('submodules/djbhash/src'),
48-
# include_directories('submodules/incbin'),
49-
include_directories('submodules/greatest'),
508
include_directories('submodules/debug_print_h/src'),
519
include_directories('submodules/debug_print_h/include'),
5210
include_directories('submodules/progressbar/include/progressbar'),
53-
include_directories('submodules/fs.c'),
54-
include_directories('submodules/slug.c/deps'),
55-
include_directories('submodules/which/src'),
56-
include_directories('submodules/str-ends-with'),
5711
include_directories('submodules/cgif/inc'),
5812
include_directories('submodules/SDL_DBGP'),
13+
include_directories('submodules'),
5914
include_directories('.'),
6015
]
16+
subdir('meson/args')
17+
subdir('meson/inc')
6118
###########################################
6219
subdir('meson')
6320
###########################################
@@ -75,3 +32,4 @@ subdir('cgif-test')
7532
###########################################
7633
subdir('dbgp-test')
7734
subdir('ee-test')
35+
subdir('chan-test')

meson/deps/chan/meson.build

+20-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
chan_lib = library('chan',
1+
chan_c_args = [
2+
'-Wno-macro-redefined',
3+
]
4+
chan_lib = static_library('chan',
25
'../../../submodules/chan/src/chan.c',
36
'../../../submodules/chan/src/queue.c',
4-
install: false, dependencies: [],
7+
install: false,
8+
dependencies: [
9+
timestamp_dep,
10+
ansicodes_dep,
11+
threads_dep,
12+
logh_dep,
13+
ms_dep,
14+
],
515
include_directories: [
16+
inc,
617
'../../../submodules/chan/src',
7-
]
18+
],
19+
c_args: chan_c_args,
820
)
9-
10-
chan_dep = declare_dependency(include_directories: [
11-
'../../../submodules/chan/src',
12-
], link_with: chan_lib
21+
chan_dep = declare_dependency(
22+
include_directories: [
23+
inc,
24+
],
25+
link_with: chan_lib,
1326
)
14-
15-
#deps += djbhash_dep

meson/deps/gd/meson.build

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

meson/deps/libmutotp/meson.build

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
libmutotp_c_args = [
2+
'-Wno-format-security',
3+
]
4+
15
libmutotp_lib = static_library('libmutotp',
26
pwd + '/submodules/libmutotp/totp.c',
37
pwd + '/submodules/libmutotp/sha1.c',
@@ -7,6 +11,7 @@ libmutotp_lib = static_library('libmutotp',
711
dependencies: [],
812
include_directories: [
913
inc,
10-
]
14+
],
15+
c_args: libmutotp_c_args,
1116
)
1217
libmutotp_dep = declare_dependency(include_directories: [inc], link_with: libmutotp_lib)

meson/deps/progress/meson.build

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
progress_cargs = [
22
'-Wno-macro-redefined',
3-
]
3+
]
44
progress_lib = library('process',
5-
pwd + '/submodules/progress.c/progress.c',
6-
install: false, dependencies: [
5+
pwd + '/submodules/progress.c/progress.c',
6+
install: false,
7+
dependencies: [
78
],
89
include_directories: [
910
],
1011
c_args: progress_cargs,
1112
)
12-
progress_dep = declare_dependency(include_directories: [
13-
], link_with: progress_lib,
13+
14+
progress_dep = declare_dependency(
15+
include_directories: [
16+
],
17+
link_with: progress_lib,
1418
)

meson/deps/sqlite3/meson.build

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ sqlite = [
33
]
44

55
sqlite_cflags = [
6+
'-Wno-pointer-to-int-cast',
7+
'-Wno-int-to-void-pointer-cast',
68
'-DSQLITE_OMIT_LOAD_EXTENSION',
79
'-DSQLITE_THREADSAFE=0',
810
'-DSQLITE_DEFAULT_AUTOVACUUM=1',

meson/deps/threads/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
threads_dep = dependency('threads', required : true)

meson/meson.build

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
####################################
2+
subdir('deps/ansicodes')
3+
subdir('deps/log.h')
24
subdir('deps/libspng')
35
subdir('deps/asprintf')
46
subdir('deps/debug_print_h')
57
subdir('deps/assertf')
68
subdir('deps/parson')
79
subdir('deps/cargs')
10+
subdir('deps/threads')
811
#subdir('sudeps/c_timer')
912
subdir('deps/c_string_buffer')
1013
subdir('deps/c_fsio')
@@ -21,7 +24,6 @@ subdir('deps/timestamp')
2124
subdir('deps/termpaint')
2225
subdir('deps/tempdir')
2326
subdir('deps/http-get')
24-
subdir('deps/ansicodes')
2527
subdir('deps/spin')
2628
subdir('deps/libmutotp')
2729
subdir('deps/curses')
@@ -49,6 +51,5 @@ subdir('deps/list')
4951
subdir('deps/gumbo')
5052
subdir('deps/cgif')
5153
subdir('deps/dbgp')
52-
subdir('deps/log.h')
5354
subdir('deps/ee')
5455
####################################

meson/osx/meson.build

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
osx_ldflags = ['-Wl,-framework,CoreFoundation']
2+
osx_ldflags += '-Wl,-framework,Carbon'
3+
osx_ldflags += ['-Wl,-framework,Foundation', '-Wl,-framework,AppKit']
4+
add_project_link_arguments(osx_ldflags, language : ['objc', 'c'])

submodules/c_eventemitter

Submodule c_eventemitter added at f14ed1b

0 commit comments

Comments
 (0)