Skip to content

Commit 1e45f85

Browse files
committed
Add meson build system
1 parent 12a8e73 commit 1e45f85

File tree

14 files changed

+755
-3
lines changed

14 files changed

+755
-3
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Compiled source
2-
build/
2+
/*build*/
33
*.o
44
*.so
55
*.so.*
66
*.a
77

88
# IDE-related files
9+
.idea/
910

1011
# OS generated files
1112
.DS_Store*
1213
Thumbs.db
1314

1415
# Other
1516
*~
16-
.*
1717
*.swp
1818
core
1919
*.log

meson.build

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
project('libomemo-c', 'c', license: 'GPL-3.0', version: '0.5.1', meson_version: '>=1.1.0')
2+
3+
cc = meson.get_compiler('c')
4+
5+
6+
c_args = []
7+
if cc.has_function('SecureZeroMemory', prefix: '#include <Windows.h>')
8+
c_args += ['-DSECUREZEROMEMORY']
9+
endif
10+
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
11+
c_args += ['-fmessage-length=0', '-Wall', '-Wmissing-field-initializers', '-Wno-missing-braces', '-Wparentheses']
12+
endif
13+
if cc.get_id() == 'gcc'
14+
c_args += ['-Wsign-compare']
15+
if cc.has_argument('-Wsign-conversion')
16+
c_args += ['-Wsign-conversion']
17+
endif
18+
endif
19+
if cc.get_id() == 'clang'
20+
c_args += ['-Wswitch', '-Wunused-variable', '-Wunused-value', '-Wshadow', '-Wint-conversion', '-Wpointer-sign', '-Wprotocol', '-Wshorten-64-to-32']
21+
endif
22+
if cc.has_function('memset_s', prefix: '#include <string.h>')
23+
c_args += ['-DHAVE_MEMSET_S']
24+
endif
25+
26+
subdir('protobuf')
27+
subdir('src')
28+
if get_option('tests')
29+
subdir('tests')
30+
endif

meson_options.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
option('tests', type: 'boolean', value: true, description: 'Whether to compile unit tests')

protobuf/meson.build

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
protoc_c = find_program('protoc-c', required: false)
2+
if protoc_c.found()
3+
protoc_gen_c = find_program('protoc-gen-c', required: false)
4+
if protoc_gen_c.found()
5+
protoc = find_program('protoc', required: false)
6+
else
7+
protoc = disabler()
8+
endif
9+
else
10+
protoc_gen_c = find_program('protoc-gen-c')
11+
protoc = find_program('protoc')
12+
endif
13+
14+
protoc_depends = []
15+
if protoc.found() and protoc_gen_c.found()
16+
protoc_depends += custom_target(
17+
command: [protoc_gen_c],
18+
capture: true,
19+
output: ['protoc_gen_c.stamp']
20+
)
21+
protoc_command = [protoc, '--plugin=protoc-gen-c=' + protoc_gen_c.full_path(), '--proto_path=@CURRENT_SOURCE_DIR@', '--c_out=@OUTDIR@', '@INPUT@']
22+
else # protoc-c is available
23+
protoc_command = [protoc_c, '--proto_path=@CURRENT_SOURCE_DIR@', '--c_out=@OUTDIR@', '@INPUT@']
24+
endif
25+
26+
protobuf_proto_names = [
27+
'LocalStorageProtocol',
28+
'WhisperTextProtocol',
29+
'OMEMO',
30+
]
31+
32+
protobuf_proto_sources = []
33+
protobuf_c_sources = []
34+
protobuf_c_headers = []
35+
foreach name : protobuf_proto_names
36+
protobuf_proto_sources += files(name + '.proto')
37+
protobuf_c_sources += [name + '.pb-c.c']
38+
protobuf_c_headers += [name + '.pb-c.h']
39+
endforeach
40+
41+
protobuf_c_sources = custom_target(
42+
'protobuf_c_sources',
43+
command: protoc_command,
44+
input: protobuf_proto_sources,
45+
output: [protobuf_c_sources, protobuf_c_headers],
46+
depends: protoc_depends,
47+
)
48+
49+
libprotobuf_c_dep = dependency('libprotobuf-c')
50+
protobuf_dep = declare_dependency(dependencies: libprotobuf_c_dep, sources: protobuf_c_sources, include_directories: include_directories('.'))

src/curve25519/meson.build

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
curve25519_c_args = c_args
2+
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
3+
curve25519_c_args += ['-Wno-unused-variable', '-Wno-unused-function', '-Wno-shadow']
4+
endif
5+
if cc.get_id() == 'gcc'
6+
curve25519_c_args += ['-Wno-sign-compare']
7+
if cc.has_argument('-Wno-sign-conversion')
8+
curve25519_c_args += ['-Wno-sign-conversion']
9+
endif
10+
endif
11+
if cc.get_id() == 'clang'
12+
curve25519_c_args += ['-Wno-shorten-64-to-32']
13+
endif
14+
if cc.has_function('memset_s', prefix: '#include <string.h>')
15+
curve25519_c_args += ['-DHAVE_MEMSET_S']
16+
endif
17+
18+
curve25519_sources = files([
19+
'curve25519-donna.c'
20+
])
21+
22+
ed25519_include_directories = [
23+
'ed25519/nacl_includes',
24+
'ed25519/additions',
25+
'ed25519/additions/generalized',
26+
'ed25519/tests',
27+
'ed25519',
28+
]
29+
30+
ed25519_sources = files([
31+
'ed25519/fe_0.c',
32+
'ed25519/fe_1.c',
33+
'ed25519/fe_add.c',
34+
'ed25519/fe_cmov.c',
35+
'ed25519/fe_copy.c',
36+
'ed25519/fe_frombytes.c',
37+
'ed25519/fe_invert.c',
38+
'ed25519/fe_isnegative.c',
39+
'ed25519/fe_isnonzero.c',
40+
'ed25519/fe_mul.c',
41+
'ed25519/fe_neg.c',
42+
'ed25519/fe_pow22523.c',
43+
'ed25519/fe_sq.c',
44+
'ed25519/fe_sq2.c',
45+
'ed25519/fe_sub.c',
46+
'ed25519/fe_tobytes.c',
47+
'ed25519/ge_add.c',
48+
'ed25519/ge_double_scalarmult.c',
49+
'ed25519/ge_frombytes.c',
50+
'ed25519/ge_madd.c',
51+
'ed25519/ge_msub.c',
52+
'ed25519/ge_p1p1_to_p2.c',
53+
'ed25519/ge_p1p1_to_p3.c',
54+
'ed25519/ge_p2_0.c',
55+
'ed25519/ge_p2_dbl.c',
56+
'ed25519/ge_p3_0.c',
57+
'ed25519/ge_p3_dbl.c',
58+
'ed25519/ge_p3_to_cached.c',
59+
'ed25519/ge_p3_to_p2.c',
60+
'ed25519/ge_p3_tobytes.c',
61+
'ed25519/ge_precomp_0.c',
62+
'ed25519/ge_scalarmult_base.c',
63+
'ed25519/ge_sub.c',
64+
'ed25519/ge_tobytes.c',
65+
'ed25519/open.c',
66+
'ed25519/sc_muladd.c',
67+
'ed25519/sc_reduce.c',
68+
'ed25519/sign.c',
69+
'ed25519/additions/compare.c',
70+
'ed25519/additions/curve_sigs.c',
71+
'ed25519/additions/ed_sigs.c',
72+
'ed25519/additions/elligator.c',
73+
'ed25519/additions/fe_edy_to_montx.c',
74+
'ed25519/additions/fe_isequal.c',
75+
'ed25519/additions/fe_isreduced.c',
76+
'ed25519/additions/fe_mont_rhs.c',
77+
'ed25519/additions/fe_montx_to_edy.c',
78+
'ed25519/additions/fe_sqrt.c',
79+
'ed25519/additions/ge_isneutral.c',
80+
'ed25519/additions/ge_montx_to_p3.c',
81+
'ed25519/additions/ge_neg.c',
82+
'ed25519/additions/ge_p3_to_montx.c',
83+
'ed25519/additions/ge_scalarmult.c',
84+
'ed25519/additions/ge_scalarmult_cofactor.c',
85+
'ed25519/additions/keygen.c',
86+
'ed25519/additions/open_modified.c',
87+
'ed25519/additions/sc_clamp.c',
88+
'ed25519/additions/sc_cmov.c',
89+
'ed25519/additions/sc_neg.c',
90+
'ed25519/additions/sign_modified.c',
91+
'ed25519/additions/utility.c',
92+
'ed25519/additions/generalized/ge_p3_add.c',
93+
'ed25519/additions/generalized/gen_eddsa.c',
94+
'ed25519/additions/generalized/gen_labelset.c',
95+
'ed25519/additions/generalized/gen_veddsa.c',
96+
'ed25519/additions/generalized/gen_x.c',
97+
'ed25519/additions/generalized/point_isreduced.c',
98+
'ed25519/additions/generalized/sc_isreduced.c',
99+
'ed25519/additions/xeddsa.c',
100+
'ed25519/additions/zeroize.c',
101+
'ed25519/nacl_sha512/blocks.c',
102+
'ed25519/nacl_sha512/hash.c',
103+
'ed25519/tests/internal_fast_tests.c',
104+
])
105+
106+
curve25519_lib = library('curve25519', curve25519_sources, ed25519_sources, c_args: curve25519_c_args, include_directories: ed25519_include_directories, install: false)
107+
curve25519_dep = declare_dependency(objects: curve25519_lib.extract_all_objects(recursive: false), include_directories: ed25519_include_directories)

0 commit comments

Comments
 (0)