Skip to content

Commit

Permalink
Start splitting src/or
Browse files Browse the repository at this point in the history
This is a very gentle commit that just lays the groundwork in the
build system: it puts the include files to build libtor-app.a into
src/core, and to build the tor executable into src/app.  The
executable is now "src/app/tor".
  • Loading branch information
nmathewson committed Jul 5, 2018
1 parent 4eac5c6 commit 81cb0af
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 74 deletions.
19 changes: 9 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,15 @@ uptime-*.json
/src/lib/libtor-wallclock.a
/src/lib/libtor-wallclock-testing.a

# /src/or/
/src/or/Makefile
/src/or/Makefile.in
/src/or/tor
/src/or/tor.exe
/src/or/tor-cov
/src/or/tor-cov.exe
/src/or/libtor-app.a
/src/or/libtor-app-testing.a
/src/or/libtor.lib
# /src/tor
/src/core/libtor-app.a
/src/core/libtor-app-testing.a

# /src/app
/src/app/tor
/src/app/tor.exe
/src/app/tor-cov
/src/app/tor-cov.exe

# /src/rust
/src/rust/.cargo/config
Expand Down
8 changes: 4 additions & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ AM_CFLAGS=@TOR_SYSTEMD_CFLAGS@ @CFLAGS_BUGTRAP@ @TOR_LZMA_CFLAGS@ @TOR_ZSTD_CFLA
SHELL=@SHELL@

if COVERAGE_ENABLED
TESTING_TOR_BINARY=$(top_builddir)/src/or/tor-cov$(EXEEXT)
TESTING_TOR_BINARY=$(top_builddir)/src/app/tor-cov$(EXEEXT)
else
TESTING_TOR_BINARY=$(top_builddir)/src/or/tor$(EXEEXT)
TESTING_TOR_BINARY=$(top_builddir)/src/app/tor$(EXEEXT)
endif

if USE_RUST
Expand Down Expand Up @@ -108,7 +108,7 @@ TOR_CRYPTO_TESTING_LIBS = \

# All static libraries used to link tor.
TOR_INTERNAL_LIBS = \
src/or/libtor-app.a \
src/core/libtor-app.a \
src/lib/libtor-compress.a \
src/lib/libtor-evloop.a \
$(TOR_CRYPTO_LIBS) \
Expand All @@ -119,7 +119,7 @@ TOR_INTERNAL_LIBS = \
# Variants of the above for linking the testing variant of tor (for coverage
# and tests)
TOR_INTERNAL_TESTING_LIBS = \
src/or/libtor-app-testing.a \
src/core/libtor-app-testing.a \
src/lib/libtor-compress-testing.a \
src/lib/libtor-evloop-testing.a \
$(TOR_CRYPTO_TESTING_LIBS) \
Expand Down
6 changes: 3 additions & 3 deletions doc/HACKING/HelpfulTools.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Jenkins
Valgrind
--------

valgrind --leak-check=yes --error-limit=no --show-reachable=yes src/or/tor
valgrind --leak-check=yes --error-limit=no --show-reachable=yes src/app/tor

(Note that if you get a zillion openssl warnings, you will also need to
pass `--undef-value-errors=no` to valgrind, or rebuild your openssl
Expand Down Expand Up @@ -232,10 +232,10 @@ Beforehand, install google-perftools.
Now you can run Tor with profiling enabled, and use the pprof utility to look at
performance! See the gperftools manual for more info, but basically:

2. Run `env CPUPROFILE=/tmp/profile src/or/tor -f <path/torrc>`. The profile file
2. Run `env CPUPROFILE=/tmp/profile src/app/tor -f <path/torrc>`. The profile file
is not written to until Tor finishes execuction.

3. Run `pprof src/or/tor /tm/profile` to start the REPL.
3. Run `pprof src/app/tor /tm/profile` to start the REPL.

Generating and analyzing a callgraph
------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion scripts/maint/checkOptionDocs.pl.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ my %torrcSampleOptions = ();
my %manPageOptions = ();

# Load the canonical list as actually accepted by Tor.
open(F, "@abs_top_builddir@/src/or/tor --list-torrc-options |") or die;
open(F, "@abs_top_builddir@/src/app/tor --list-torrc-options |") or die;
while (<F>) {
next if m!\[notice\] Tor v0\.!;
if (m!^([A-Za-z0-9_]+)!) {
Expand Down
38 changes: 38 additions & 0 deletions src/app/include.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

bin_PROGRAMS+= src/app/tor

if COVERAGE_ENABLED
noinst_PROGRAMS+= src/app/tor-cov
endif

noinst_HEADERS += \
src/app/ntmain.h

src_app_tor_SOURCES = src/app/tor_main.c
if BUILD_NT_SERVICES
src_app_tor_SOURCES += src/app/ntmain.c
endif

# -L flags need to go in LDFLAGS. -l flags need to go in LDADD.
# This seems to matter nowhere but on windows, but I assure you that it
# matters a lot there, and is quite hard to debug if you forget to do it.

src_app_tor_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ @TOR_LDFLAGS_libevent@
src_app_tor_LDADD = $(TOR_INTERNAL_LIBS) \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@

if COVERAGE_ENABLED
src_app_tor_cov_SOURCES = $(src_app_tor_SOURCES)
src_app_tor_cov_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
src_app_tor_cov_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
src_app_tor_cov_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ @TOR_LDFLAGS_libevent@
src_app_tor_cov_LDADD = $(TOR_INTERNAL_TESTING_LIBS) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ \
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
endif
2 changes: 1 addition & 1 deletion src/or/ntmain.c → src/app/ntmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "or/or.h"
#include "or/config.h"
#include "or/main.h"
#include "or/ntmain.h"
#include "app/ntmain.h"
#include "lib/log/win32err.h"
#include "lib/fs/winlib.h"
#include "lib/evloop/compat_libevent.h"
Expand Down
File renamed without changes.
File renamed without changes.
60 changes: 10 additions & 50 deletions src/or/include.am → src/core/include.am
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
bin_PROGRAMS+= src/or/tor

noinst_LIBRARIES += \
src/or/libtor-app.a
src/core/libtor-app.a
if UNITTESTS_ENABLED
noinst_LIBRARIES += \
src/or/libtor-app-testing.a
endif
if COVERAGE_ENABLED
noinst_PROGRAMS+= src/or/tor-cov
endif

if BUILD_NT_SERVICES
tor_platform_source=src/or/ntmain.c
else
tor_platform_source=
src/core/libtor-app-testing.a
endif

EXTRA_DIST+= src/or/ntmain.c src/or/Makefile.nmake

LIBTOR_APP_A_SOURCES = \
src/or/addressmap.c \
src/or/address_set.c \
Expand Down Expand Up @@ -110,8 +99,7 @@ LIBTOR_APP_A_SOURCES = \
src/or/torcert.c \
src/or/tor_api.c \
src/or/voting_schedule.c \
src/or/onion_ntor.c \
$(tor_platform_source)
src/or/onion_ntor.c

#
# Modules are conditionnally compiled in tor starting here. We add the C files
Expand All @@ -131,53 +119,26 @@ if BUILD_MODULE_DIRAUTH
LIBTOR_APP_A_SOURCES += $(MODULE_DIRAUTH_SOURCES)
endif

src_or_libtor_app_a_SOURCES = $(LIBTOR_APP_A_SOURCES)
src_core_libtor_app_a_SOURCES = $(LIBTOR_APP_A_SOURCES)
if UNITTESTS_ENABLED

# Add the sources of the modules that are needed for tests to work here.
LIBTOR_APP_TESTING_A_SOURCES += $(MODULE_DIRAUTH_SOURCES)

src_or_libtor_app_testing_a_SOURCES = $(LIBTOR_APP_TESTING_A_SOURCES)
src_core_libtor_app_testing_a_SOURCES = $(LIBTOR_APP_TESTING_A_SOURCES)
else
src_or_libtor_app_testing_a_SOURCES =
src_core_libtor_app_testing_a_SOURCES =
endif

src_or_tor_SOURCES = src/or/tor_main.c

src/or/git_revision.$(OBJEXT) \
src/or/src_or_libtor_app_testing_a-git_revision.$(OBJEXT): micro-revision.i
src/or/src_core_libtor_app_testing_a-git_revision.$(OBJEXT): micro-revision.i

AM_CPPFLAGS += -DSHARE_DATADIR="\"$(datadir)\"" \
-DLOCALSTATEDIR="\"$(localstatedir)\"" \
-DBINDIR="\"$(bindir)\""

src_or_libtor_app_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
src_or_libtor_app_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)

# -L flags need to go in LDFLAGS. -l flags need to go in LDADD.
# This seems to matter nowhere but on windows, but I assure you that it
# matters a lot there, and is quite hard to debug if you forget to do it.


src_or_tor_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ @TOR_LDFLAGS_libevent@
src_or_tor_LDADD = $(TOR_INTERNAL_LIBS) \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@

if COVERAGE_ENABLED
src_or_tor_cov_SOURCES = src/or/tor_main.c
src_or_tor_cov_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
src_or_tor_cov_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
src_or_tor_cov_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ @TOR_LDFLAGS_libevent@
src_or_tor_cov_LDADD = $(TOR_INTERNAL_TESTING_LIBS) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ \
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
endif
src_core_libtor_app_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
src_core_libtor_app_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)

ORHEADERS = \
src/or/addressmap.h \
Expand Down Expand Up @@ -267,7 +228,6 @@ ORHEADERS = \
src/or/nodelist.h \
src/or/node_st.h \
src/or/ns_detached_signatures_st.h \
src/or/ntmain.h \
src/or/onion.h \
src/or/onion_fast.h \
src/or/onion_ntor.h \
Expand Down
5 changes: 4 additions & 1 deletion src/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ include src/lib/tls/include.am
include src/lib/trace/include.am
include src/lib/wallclock/include.am
include src/trunnel/include.am
include src/or/include.am

include src/core/include.am
include src/app/include.am

include src/rust/include.am
include src/test/include.am
include src/tools/include.am
Expand Down
2 changes: 1 addition & 1 deletion src/or/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
#include "or/microdesc.h"
#include "or/networkstatus.h"
#include "or/nodelist.h"
#include "or/ntmain.h"
#include "app/ntmain.h"
#include "or/onion.h"
#include "or/periodic.h"
#include "or/policies.h"
Expand Down
6 changes: 3 additions & 3 deletions src/test/test_zero_length_keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

exitcode=0

"${SHELL:-sh}" "${abs_top_srcdir:-.}/src/test/zero_length_keys.sh" "${builddir:-.}/src/or/tor" -z || exitcode=1
"${SHELL:-sh}" "${abs_top_srcdir:-.}/src/test/zero_length_keys.sh" "${builddir:-.}/src/or/tor" -d || exitcode=1
"${SHELL:-sh}" "${abs_top_srcdir:-.}/src/test/zero_length_keys.sh" "${builddir:-.}/src/or/tor" -e || exitcode=1
"${SHELL:-sh}" "${abs_top_srcdir:-.}/src/test/zero_length_keys.sh" "${builddir:-.}/src/app/tor" -z || exitcode=1
"${SHELL:-sh}" "${abs_top_srcdir:-.}/src/test/zero_length_keys.sh" "${builddir:-.}/src/app/tor" -d || exitcode=1
"${SHELL:-sh}" "${abs_top_srcdir:-.}/src/test/zero_length_keys.sh" "${builddir:-.}/src/app/tor" -e || exitcode=1

exit ${exitcode}

0 comments on commit 81cb0af

Please sign in to comment.