refactor(build): add static_library

This commit is contained in:
2025-09-12 01:43:26 +02:00
parent 25e259ae07
commit 56fa31d087
13 changed files with 349 additions and 152 deletions

View File

@@ -5,27 +5,42 @@ project(
default_options: ['c_std=c17','warning_level=3'],
)
src = files(
cc = meson.get_compiler('c')
# Sources without test files
lib_src = files(
'hashmap/myhashmap.c',
'queue/myqueue.c',
'string/mystring.c',
'vector/myvector.c',
'stack/mystack.c',
'socket/mysocket.c',
)
testlib = files(
# Test files
test_src = files(
'test/test.c',
'test/hashmap/hm1.c',
'test/queue/q1.c',
'test/queue/queue1.c',
'test/string/str1.c',
'test/string/str2.c',
'test/string/str3.c',
'test/vector/v1.c',
'test/stack/s1.c',
'test/vector/vec1.c',
'test/stack/stack1.c',
'test/socket/socket1.c',
)
sources = src + testlib
# Windows Socket lib
winsock_dep = cc.find_library('ws2_32', required: false)
inc_dir = include_directories('string', 'queue', 'hashmap', 'vector')
# Include directories
inc_dir = include_directories('string', 'queue', 'hashmap', 'vector', 'stack', 'socket')
executable('testlib', sources, include_directories: inc_dir)
# Static library
myclib_lib = static_library('myclib', lib_src, include_directories: inc_dir, dependencies: winsock_dep, install: true)
# Install headers
install_headers(['hashmap/myhashmap.h', 'queue/myqueue.h', 'string/mystring.h', 'vector/myvector.h', 'stack/mystack.h', 'socket/mysocket.h'], subdir: 'myclib')
# Test executable
executable('testlib', lib_src + test_src, include_directories: inc_dir, dependencies: winsock_dep)