summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2017-12-02 10:33:41 -0500
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-04-29 11:33:26 -0400
commit2a35813311dde9bbb40964afb6f3ca36f1e559da (patch)
tree43494317323ca2bbb46442051af03eb38ec6058e
parent926a6a62c985043325ab954ad19e3a92a051eef6 (diff)
downloadtor-2a35813311dde9bbb40964afb6f3ca36f1e559da.tar.xz
tor-2a35813311dde9bbb40964afb6f3ca36f1e559da.zip
Add meson.builds, micro-revision.i.in
-rw-r--r--.gitignore2
-rw-r--r--meson.build208
-rw-r--r--meson_options.txt2
-rw-r--r--micro-revision.i.in1
-rw-r--r--src/common/meson.build72
-rw-r--r--src/ext/ed25519/donna/meson.build1
-rw-r--r--src/ext/ed25519/ref10/meson.build45
-rw-r--r--src/ext/keccak-tiny/meson.build1
-rw-r--r--src/ext/meson.build3
-rw-r--r--src/meson.build15
-rw-r--r--src/or/meson.build106
-rw-r--r--src/rust/meson.build1
-rwxr-xr-xsrc/rust/tor_rust/build.sh22
-rw-r--r--src/rust/tor_rust/meson.build9
-rw-r--r--src/trunnel/meson.build13
15 files changed, 500 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index c00fbe97e..1dc5aff2c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,7 +55,7 @@ uptime-*.json
/config.guess
/config.sub
/conftest*
-/micro-revision.*
+/micro-revision.i
/patch-stamp
/stamp-h
/stamp-h.in
diff --git a/meson.build b/meson.build
new file mode 100644
index 000000000..4adab0994
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,208 @@
+project('tor', 'c')
+
+add_project_arguments('-D_GNU_SOURCE', language: 'c')
+add_project_arguments('-D_REENTRANT', language: 'c')
+
+cc = meson.get_compiler('c')
+
+orconf = configuration_data()
+
+orconf.set('USE_CURVE25519_DONNA', true)
+orconf.set('LOGFACILITY', 'LOG_DAEMON')
+orconf.set_quoted('LOCALSTATEDIR', get_option('localstatedir'))
+orconf.set_quoted('CONFDIR', get_option('sysconfdir') + '/tor')
+orconf.set_quoted('VERSION', '0.3.3.0-alpha-dev')
+orconf.set_quoted('SHARE_DATADIR', get_option('datadir'))
+
+libm = cc.find_library('m', required: false)
+libdl = cc.find_library('dl', required: false)
+# https://github.com/mesonbuild/meson/issues/553
+if host_machine.system() != 'windows'
+ threads = dependency('threads', required: false)
+ orconf.set('HAVE_PTHREAD', threads.found())
+endif
+libevent = dependency('libevent', version: '>= 2.0.10')
+zlib = dependency('zlib')
+openssl = dependency('openssl')
+lzma = dependency('liblzma', required: false)
+if lzma.found()
+ orconf.set('HAVE_LZMA', true)
+endif
+zstd = dependency('libzstd', version: '>= 1.1', required: false)
+if zstd.found()
+ orconf.set('HAVE_ZSTD', true)
+endif
+systemd = dependency('libsystemd', required: false)
+if systemd.found()
+ orconf.set('HAVE_SYSTEMD', true)
+endif
+
+check_headers = [
+ 'arpa/inet.h',
+ 'crt_externs.h',
+ 'execinfo.h',
+ 'fcntl.h',
+ 'grp.h',
+ 'ifaddrs.h',
+ 'linux/if.h',
+ 'linux/types.h',
+ 'machine/limits.h',
+ 'net/if.h',
+ 'netdb.h',
+ 'netinet/in.h',
+ 'pwd.h',
+ 'readpassphrase.h',
+ 'signal.h',
+ 'sys/capability.h',
+ 'sys/eventfd.h',
+ 'sys/fcntl.h',
+ 'sys/file.h',
+ 'sys/ioctl.h',
+ 'sys/limits.h',
+ 'sys/mman.h',
+ 'sys/param.h',
+ 'sys/prctl.h',
+ 'sys/random.h',
+ 'sys/resource.h',
+ 'sys/select.h',
+ 'sys/socket.h',
+ 'sys/stat.h',
+ 'sys/statvfs.h',
+ 'sys/syscall.h',
+ 'sys/sysctl.h',
+ 'sys/syslimits.h',
+ 'sys/time.h',
+ 'sys/types.h',
+ 'sys/types.h',
+ 'sys/un.h',
+ 'sys/utime.h',
+ 'sys/wait.h',
+ 'syslog.h',
+ 'unistd.h',
+ 'utime.h',
+]
+
+foreach h : check_headers
+ orconf.set('HAVE_' + h.to_upper().underscorify(), cc.has_header(h))
+endforeach
+
+foreach t : ['struct in6_addr', 'struct sockaddr_in6', 'sa_family_t']
+ orconf.set('HAVE_' + t.to_upper().underscorify(), cc.has_type(t, prefix: '
+#include <netinet/in.h>
+#ifdef _WIN32
+#define _WIN32_WINNT 0x0501
+#define WIN32_LEAN_AND_MEAN
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif
+'))
+endforeach
+
+check_funcs = [
+ '_NSGetEnviron',
+ 'RtlSecureZeroMemory',
+ 'SecureZeroMemory',
+ 'accept4',
+ 'backtrace',
+ 'backtrace_symbols_fd',
+ 'clock_gettime',
+ 'eventfd',
+ 'explicit_bzero',
+ 'timingsafe_memcmp',
+ 'flock',
+ 'ftime',
+ 'get_current_dir_name',
+ 'getaddrinfo',
+ 'getifaddrs',
+ 'getpass',
+ 'getrlimit',
+ 'gettimeofday',
+ 'gmtime_r',
+ 'gnu_get_libc_version',
+ 'htonll',
+ 'inet_aton',
+ 'ioctl',
+ 'issetugid',
+ 'llround',
+ 'localtime_r',
+ 'lround',
+ 'memmem',
+ 'memset_s',
+ 'pipe',
+ 'pipe2',
+ 'prctl',
+ 'readpassphrase',
+ 'rint',
+ 'sigaction',
+ 'socketpair',
+ 'statvfs',
+ 'strlcat',
+ 'strlcpy',
+ 'strnlen',
+ 'strptime',
+ 'strtok_r',
+ 'strtoull',
+ 'sysconf',
+ 'sysctl',
+ 'truncate',
+ 'uname',
+ 'usleep',
+ 'vasprintf',
+ '_vscprintf',
+]
+
+foreach f : check_funcs
+ orconf.set('HAVE_' + f.to_upper().underscorify(), cc.has_function(f))
+endforeach
+
+check_openssl_funcs = [
+ 'SSL_SESSION_get_master_key',
+ 'SSL_get_server_random',
+ 'SSL_get_client_ciphers',
+ 'SSL_get_client_random',
+ 'SSL_CIPHER_find',
+ 'TLS_method',
+ 'EVP_PBE_scrypt'
+]
+
+foreach f : check_openssl_funcs
+ orconf.set('HAVE_' + f.to_upper().underscorify(), cc.has_function(f, prefix: '#include <openssl/ssl.h>', dependencies: openssl))
+endforeach
+
+orconf.set('HAVE_SOCKLEN_T', cc.has_type('socklen_t', prefix: '#include <sys/socket.h>'))
+
+orconf.set('SIZEOF_INT', cc.sizeof('int'))
+orconf.set('SIZEOF_VOID_P', cc.sizeof('void *'))
+orconf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix: '#include <unistd.h>'))
+orconf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix: '#include <time.h>'))
+
+orconf.set('HAVE_STRUCT_TIMEVAL_TV_SEC', cc.has_member('struct timeval', 'tv_sec', prefix: '#include <sys/time.h>'))
+
+if get_option('use_rust')
+ cargo = get_option('cargo')
+ cargo_run = run_command(cargo)
+ if cargo_run.returncode() == 0
+ orconf.set('HAVE_RUST', true)
+ use_rust = true
+ else
+ error('Rust requested but cargo doesn\'t work.')
+ endif
+else
+ use_rust = false
+endif
+
+if cc.has_member('struct tcp_info', 'tcpi_unacked', prefix: '#include <netinet/tcp.h>') and cc.has_member('struct tcp_info', 'tcpi_snd_mss', prefix: '#include <netinet/tcp.h>') and cc.has_header_symbol('linux/sockios.h', 'SIOCOUTQNSD')
+ orconf.set('HAVE_KIST_SUPPORT', true)
+endif
+
+configure_file(output: 'orconfig.h', configuration: orconf)
+add_project_arguments('-I.', language: 'c')
+foreach d : ['ext/trunnel', 'trunnel', 'ext', 'common', 'or']
+ add_project_arguments('-I' + meson.source_root() + '/src/' + d, language: 'c')
+endforeach
+
+micro_revision = vcs_tag(command: ['git', 'rev-parse', '--short=16', 'HEAD'], fallback: '', input: 'micro-revision.i.in', output: 'micro-revision.i')
+
+subdir('src')
+#subdir('doc')
+#subdir('contrib')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 000000000..8956ee595
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,2 @@
+option('use_rust', type: 'boolean', value: false, description: 'Use rust')
+option('cargo', type: 'string', value: 'cargo', description: 'Path to cargo executable')
diff --git a/micro-revision.i.in b/micro-revision.i.in
new file mode 100644
index 000000000..c0bd958cb
--- /dev/null
+++ b/micro-revision.i.in
@@ -0,0 +1 @@
+"@VCS_TAG@"
diff --git a/src/common/meson.build b/src/common/meson.build
new file mode 100644
index 000000000..7a32020ac
--- /dev/null
+++ b/src/common/meson.build
@@ -0,0 +1,72 @@
+libdonna = [libed25519_ref10, libed25519_donna]
+
+libcurve25519_donna_src = [
+ '../ext/curve25519_donna/curve25519-donna-c64.c'
+]
+libcurve25519_donna = static_library('curve25519-donna', libcurve25519_donna_src)
+libdonna += libcurve25519_donna
+
+threads_impl_source = 'compat_pthreads.c'
+
+libor_src = [
+ 'address.c',
+ 'address_set.c',
+ 'backtrace.c',
+ 'buffers.c',
+ 'compat.c',
+ 'compat_threads.c',
+ 'compat_time.c',
+ 'confline.c',
+ 'container.c',
+ 'log.c',
+ 'memarea.c',
+ 'pubsub.c',
+ 'util.c',
+ 'util_bug.c',
+ 'util_format.c',
+ 'util_process.c',
+ 'sandbox.c',
+ 'storagedir.c',
+ 'workqueue.c',
+ '../ext/readpassphrase.c',
+ micro_revision,
+ threads_impl_source,
+]
+
+libor = static_library('or', libor_src)
+
+libor_ctime_src = [
+ '../ext/csiphash.c',
+ 'di_ops.c',
+]
+
+libor_ctime = static_library('or-ctime', libor_ctime_src)
+
+libor_crypto_src = [
+ 'aes.c',
+ 'buffers_tls.c',
+ 'compress.c',
+ 'compress_lzma.c',
+ 'compress_none.c',
+ 'compress_zlib.c',
+ 'compress_zstd.c',
+ 'crypto.c',
+ 'crypto_format.c',
+ 'crypto_openssl_mgt.c',
+ 'crypto_pwbox.c',
+ 'crypto_rsa.c',
+ 'crypto_s2k.c',
+ 'tortls.c',
+ 'crypto_curve25519.c',
+ 'crypto_ed25519.c',
+]
+
+libor_crypto = static_library('or-crypto', libor_crypto_src)
+
+libor_event_src = [
+ 'compat_libevent.c',
+ 'procmon.c',
+ 'timers.c',
+]
+
+libor_event = static_library('or-event', libor_event_src)
diff --git a/src/ext/ed25519/donna/meson.build b/src/ext/ed25519/donna/meson.build
new file mode 100644
index 000000000..59ce0402a
--- /dev/null
+++ b/src/ext/ed25519/donna/meson.build
@@ -0,0 +1 @@
+libed25519_donna = static_library('ed25519_donna', 'ed25519_tor.c', c_args: ['-DED25519_CUSTOMRANDOM', '-DED25519_CUSTOMHASH', '-DED25519_SUFFIX=_donna'])
diff --git a/src/ext/ed25519/ref10/meson.build b/src/ext/ed25519/ref10/meson.build
new file mode 100644
index 000000000..24630d2c1
--- /dev/null
+++ b/src/ext/ed25519/ref10/meson.build
@@ -0,0 +1,45 @@
+sources = [
+ 'fe_0.c',
+ 'fe_1.c',
+ 'fe_add.c',
+ 'fe_cmov.c',
+ 'fe_copy.c',
+ 'fe_frombytes.c',
+ 'fe_invert.c',
+ 'fe_isnegative.c',
+ 'fe_isnonzero.c',
+ 'fe_mul.c',
+ 'fe_neg.c',
+ 'fe_pow22523.c',
+ 'fe_sq.c',
+ 'fe_sq2.c',
+ 'fe_sub.c',
+ 'fe_tobytes.c',
+ 'ge_add.c',
+ 'ge_double_scalarmult.c',
+ 'ge_frombytes.c',
+ 'ge_madd.c',
+ 'ge_msub.c',
+ 'ge_p1p1_to_p2.c',
+ 'ge_p1p1_to_p3.c',
+ 'ge_p2_0.c',
+ 'ge_p2_dbl.c',
+ 'ge_p3_0.c',
+ 'ge_p3_dbl.c',
+ 'ge_p3_to_cached.c',
+ 'ge_p3_to_p2.c',
+ 'ge_p3_tobytes.c',
+ 'ge_precomp_0.c',
+ 'ge_scalarmult_base.c',
+ 'ge_sub.c',
+ 'ge_tobytes.c',
+ 'keypair.c',
+ 'open.c',
+ 'sc_muladd.c',
+ 'sc_reduce.c',
+ 'sign.c',
+ 'keyconv.c',
+ 'blinding.c'
+]
+
+libed25519_ref10 = static_library('ed25519_ref10', sources)
diff --git a/src/ext/keccak-tiny/meson.build b/src/ext/keccak-tiny/meson.build
new file mode 100644
index 000000000..5a6c2664c
--- /dev/null
+++ b/src/ext/keccak-tiny/meson.build
@@ -0,0 +1 @@
+libkeccak_tiny = static_library('keccak-tiny', 'keccak-tiny-unrolled.c')
diff --git a/src/ext/meson.build b/src/ext/meson.build
new file mode 100644
index 000000000..86d348c41
--- /dev/null
+++ b/src/ext/meson.build
@@ -0,0 +1,3 @@
+subdir('ed25519/ref10')
+subdir('ed25519/donna')
+subdir('keccak-tiny')
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 000000000..9a9730351
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,15 @@
+libevent = dependency('libevent')
+
+subdir('ext')
+subdir('common')
+subdir('trunnel')
+if use_rust
+ subdir('rust')
+endif
+subdir('or')
+#subdir('test')
+#subdir('tools')
+#subdir('win32')
+#subdir('config')
+#subdir('test/fuzz')
+#subdir('trace')
diff --git a/src/or/meson.build b/src/or/meson.build
new file mode 100644
index 000000000..2f4f4bee2
--- /dev/null
+++ b/src/or/meson.build
@@ -0,0 +1,106 @@
+libtor_sources = [
+ 'addressmap.c',
+ 'bridges.c',
+ 'channel.c',
+ 'channelpadding.c',
+ 'channeltls.c',
+ 'circpathbias.c',
+ 'circuitbuild.c',
+ 'circuitlist.c',
+ 'circuitmux.c',
+ 'circuitmux_ewma.c',
+ 'circuitstats.c',
+ 'circuituse.c',
+ 'command.c',
+ 'config.c',
+ 'confparse.c',
+ 'connection.c',
+ 'connection_edge.c',
+ 'connection_or.c',
+ 'conscache.c',
+ 'consdiff.c',
+ 'consdiffmgr.c',
+ 'control.c',
+ 'cpuworker.c',
+ 'dircollate.c',
+ 'directory.c',
+ 'dirserv.c',
+ 'dirvote.c',
+ 'dos.c',
+ 'dns.c',
+ 'dnsserv.c',
+ 'fp_pair.c',
+ 'geoip.c',
+ 'git_revision.c',
+ 'entrynodes.c',
+ 'ext_orport.c',
+ 'hibernate.c',
+ 'hs_cache.c',
+ 'hs_cell.c',
+ 'hs_circuit.c',
+ 'hs_circuitmap.c',
+ 'hs_client.c',
+ 'hs_common.c',
+ 'hs_config.c',
+ 'hs_control.c',
+ 'hs_descriptor.c',
+ 'hs_ident.c',
+ 'hs_intropoint.c',
+ 'hs_ntor.c',
+ 'hs_service.c',
+ 'hs_stats.c',
+ 'keypin.c',
+ 'main.c',
+ 'microdesc.c',
+ 'networkstatus.c',
+ 'nodelist.c',
+ 'onion.c',
+ 'onion_fast.c',
+ 'onion_tap.c',
+ 'shared_random.c',
+ 'shared_random_state.c',
+ 'transports.c',
+ 'parsecommon.c',
+ 'periodic.c',
+ 'protover.c',
+ 'protover_rust.c',
+ 'proto_cell.c',
+ 'proto_control0.c',
+ 'proto_ext_or.c',
+ 'proto_http.c',
+ 'proto_socks.c',
+ 'policies.c',
+ 'reasons.c',
+ 'relay.c',
+ 'rendcache.c',
+ 'rendclient.c',
+ 'rendcommon.c',
+ 'rendmid.c',
+ 'rendservice.c',
+ 'rephist.c',
+ 'replaycache.c',
+ 'router.c',
+ 'routerkeys.c',
+ 'routerlist.c',
+ 'routerparse.c',
+ 'routerset.c',
+ 'scheduler.c',
+ 'scheduler_kist.c',
+ 'scheduler_vanilla.c',
+ 'statefile.c',
+ 'status.c',
+ 'torcert.c',
+ 'tor_api.c',
+ 'onion_ntor.c',
+ micro_revision
+]
+
+libtor = static_library('tor', libtor_sources)
+
+tor_deps = [threads, zlib, openssl, libevent, systemd, lzma, zstd, libm, libdl]
+if use_rust
+ tor_deps += tor_rust
+endif
+tor_ldadd = [libtor, libor, libor_ctime, libor_crypto, libkeccak_tiny, libdonna, libor_event, libor_trunnel]
+
+executable('tor', 'tor_main.c', dependencies: tor_deps, link_with: tor_ldadd)
diff --git a/src/rust/meson.build b/src/rust/meson.build
new file mode 100644
index 000000000..123d799c8
--- /dev/null
+++ b/src/rust/meson.build
@@ -0,0 +1 @@
+subdir('tor_rust')
diff --git a/src/rust/tor_rust/build.sh b/src/rust/tor_rust/build.sh
new file mode 100755
index 000000000..c013153d0
--- /dev/null
+++ b/src/rust/tor_rust/build.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ "$1" = "release" ]; then
+ cargo_build_type=release
+ cargo_args=--release
+else
+ cargo_build_type=debug
+ cargo_args=
+fi
+source_dir="$2"
+output_dir="$(realpath -s "$3")"
+output_lib="$(realpath -s "$4")"
+shift 4
+
+cd "$source_dir"
+
+set -x
+
+CARGO_TARGET_DIR="$output_dir/target.dir" \
+ cargo build $cargo_args "$@"
+
+cp -p "$output_dir/target.dir/$cargo_build_type/libtor_rust.a" "$output_lib"
diff --git a/src/rust/tor_rust/meson.build b/src/rust/tor_rust/meson.build
new file mode 100644
index 000000000..094af9ffa
--- /dev/null
+++ b/src/rust/tor_rust/meson.build
@@ -0,0 +1,9 @@
+build_cmd = [files('build.sh'), get_option('buildtype'), '@INPUT@', '@OUTDIR@', '@OUTPUT@']
+
+# input and output are relative to source dir and output dir
+libtor_rust = custom_target('libtor_rust',
+ build_always: true,
+ command: build_cmd,
+ input: '.',
+ output: 'libtor_rust.a')
+tor_rust = declare_dependency(sources: libtor_rust)
diff --git a/src/trunnel/meson.build b/src/trunnel/meson.build
new file mode 100644
index 000000000..fde178b48
--- /dev/null
+++ b/src/trunnel/meson.build
@@ -0,0 +1,13 @@
+trunnel_sources = [
+ '../ext/trunnel/trunnel.c',
+ 'ed25519_cert.c',
+ 'link_handshake.c',
+ 'pwbox.c',
+ 'hs/cell_common.c',
+ 'hs/cell_establish_intro.c',
+ 'hs/cell_introduce1.c',
+ 'hs/cell_rendezvous.c',
+ 'channelpadding_negotiation.c',
+]
+
+libor_trunnel = static_library('or-trunnel', trunnel_sources)