[tor-commits] [tor/master] Start splitting src/or

nickm at torproject.org nickm at torproject.org
Thu Jul 5 22:13:17 UTC 2018


commit 81cb0afb2b0163d95a435583041dce1064eec65c
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Jul 5 16:04:32 2018 -0400

    Start splitting src/or
    
    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".
---
 .gitignore                          | 19 ++++++------
 Makefile.am                         |  8 ++---
 doc/HACKING/HelpfulTools.md         |  6 ++--
 scripts/maint/checkOptionDocs.pl.in |  2 +-
 src/app/include.am                  | 38 +++++++++++++++++++++++
 src/{or => app}/ntmain.c            |  2 +-
 src/{or => app}/ntmain.h            |  0
 src/{or => app}/tor_main.c          |  0
 src/{or => core}/include.am         | 60 +++++++------------------------------
 src/include.am                      |  5 +++-
 src/or/main.c                       |  2 +-
 src/test/test_zero_length_keys.sh   |  6 ++--
 12 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/.gitignore b/.gitignore
index 711974450..80c039a68 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/Makefile.am b/Makefile.am
index b2da55cda..e7c46f3cc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
@@ -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) \
@@ -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) \
diff --git a/doc/HACKING/HelpfulTools.md b/doc/HACKING/HelpfulTools.md
index eb068a91f..13d1c4b0d 100644
--- a/doc/HACKING/HelpfulTools.md
+++ b/doc/HACKING/HelpfulTools.md
@@ -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
@@ -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
 ------------------------------------
diff --git a/scripts/maint/checkOptionDocs.pl.in b/scripts/maint/checkOptionDocs.pl.in
index 1f53adf09..6533c762c 100644
--- a/scripts/maint/checkOptionDocs.pl.in
+++ b/scripts/maint/checkOptionDocs.pl.in
@@ -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_]+)!) {
diff --git a/src/app/include.am b/src/app/include.am
new file mode 100644
index 000000000..bbbffb3e5
--- /dev/null
+++ b/src/app/include.am
@@ -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
diff --git a/src/or/ntmain.c b/src/app/ntmain.c
similarity index 99%
rename from src/or/ntmain.c
rename to src/app/ntmain.c
index f6b57753d..63d82f686 100644
--- a/src/or/ntmain.c
+++ b/src/app/ntmain.c
@@ -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"
diff --git a/src/or/ntmain.h b/src/app/ntmain.h
similarity index 100%
rename from src/or/ntmain.h
rename to src/app/ntmain.h
diff --git a/src/or/tor_main.c b/src/app/tor_main.c
similarity index 100%
rename from src/or/tor_main.c
rename to src/app/tor_main.c
diff --git a/src/or/include.am b/src/core/include.am
similarity index 82%
rename from src/or/include.am
rename to src/core/include.am
index ad7ee69bf..d6162196f 100644
--- a/src/or/include.am
+++ b/src/core/include.am
@@ -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				\
@@ -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
@@ -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				\
@@ -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				\
diff --git a/src/include.am b/src/include.am
index 950f9cc0f..b5cca7e30 100644
--- a/src/include.am
+++ b/src/include.am
@@ -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
diff --git a/src/or/main.c b/src/or/main.c
index 7e3eb2b59..2a57aa587 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -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"
diff --git a/src/test/test_zero_length_keys.sh b/src/test/test_zero_length_keys.sh
index f85edb68d..84ca513b0 100755
--- a/src/test/test_zero_length_keys.sh
+++ b/src/test/test_zero_length_keys.sh
@@ -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}





More information about the tor-commits mailing list