Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
refactor: port daemon and utils to C++ (#1825)
* refactor: compile daemon/ and utils/ as C++

Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
  • Loading branch information
ckerr and mikedld committed Sep 21, 2021
1 parent 21407d6 commit 1ee88c0
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 55 deletions.
40 changes: 29 additions & 11 deletions Transmission.xcodeproj/project.pbxproj
Expand Up @@ -302,7 +302,7 @@
BE75C38A0C72A1ED00DBEFE0 /* libevent.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE75C3490C729E9500DBEFE0 /* libevent.a */; };
BEFC1C050C07753500B0BB3C /* libtransmission.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D18389709DEC0030047D688 /* libtransmission.a */; };
BEFC1C1A0C07756200B0BB3C /* daemon.c in Sources */ = {isa = PBXBuildFile; fileRef = BEFC1C0E0C07756200B0BB3C /* daemon.c */; };
BEFC1D050C07825A00B0BB3C /* remote.c in Sources */ = {isa = PBXBuildFile; fileRef = BEFC1C140C07756200B0BB3C /* remote.c */; };
BEFC1D050C07825A00B0BB3C /* remote.cc in Sources */ = {isa = PBXBuildFile; fileRef = BEFC1C140C07756200B0BB3C /* remote.cc */; };
BEFC1D2D0C0783D900B0BB3C /* libtransmission.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D18389709DEC0030047D688 /* libtransmission.a */; };
BEFC1E290C07861A00B0BB3C /* version.h in Headers */ = {isa = PBXBuildFile; fileRef = BEFC1DF00C07861A00B0BB3C /* version.h */; };
BEFC1E2A0C07861A00B0BB3C /* utils.h in Headers */ = {isa = PBXBuildFile; fileRef = BEFC1DF10C07861A00B0BB3C /* utils.h */; };
Expand Down Expand Up @@ -363,7 +363,7 @@
C1A751E626ED09A30038B90A /* arc4.h in Headers */ = {isa = PBXBuildFile; fileRef = C1A751E426ED09A30038B90A /* arc4.h */; };
C1BF7BA81F2A3CB7008E88A7 /* upnpdev.c in Sources */ = {isa = PBXBuildFile; fileRef = C1BF7BA71F2A3CB7008E88A7 /* upnpdev.c */; };
C1BF7BAA1F2A3CCE008E88A7 /* upnpdev.h in Headers */ = {isa = PBXBuildFile; fileRef = C1BF7BA91F2A3CCE008E88A7 /* upnpdev.h */; };
C1F690FD1AD0627500D95CF0 /* daemon-posix.c in Sources */ = {isa = PBXBuildFile; fileRef = C1F690FC1AD0627500D95CF0 /* daemon-posix.c */; };
C1F690FD1AD0627500D95CF0 /* daemon-posix.cc in Sources */ = {isa = PBXBuildFile; fileRef = C1F690FC1AD0627500D95CF0 /* daemon-posix.cc */; };
C1FEE5771C3223CC00D62832 /* watchdir-common.h in Headers */ = {isa = PBXBuildFile; fileRef = C1FEE5721C3223CC00D62832 /* watchdir-common.h */; };
C1FEE5781C3223CC00D62832 /* watchdir-generic.cc in Sources */ = {isa = PBXBuildFile; fileRef = C1FEE5731C3223CC00D62832 /* watchdir-generic.cc */; };
C1FEE5791C3223CC00D62832 /* watchdir-kqueue.cc in Sources */ = {isa = PBXBuildFile; fileRef = C1FEE5741C3223CC00D62832 /* watchdir-kqueue.cc */; };
Expand Down Expand Up @@ -966,8 +966,8 @@
BE1183680CE160D50002D0F3 /* miniupnpc.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = miniupnpc.c; sourceTree = "<group>"; };
BE75C3490C729E9500DBEFE0 /* libevent.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libevent.a; sourceTree = BUILT_PRODUCTS_DIR; };
BEFC1C000C07750000B0BB3C /* transmission-daemon */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "transmission-daemon"; sourceTree = BUILT_PRODUCTS_DIR; };
BEFC1C0E0C07756200B0BB3C /* daemon.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = daemon.c; sourceTree = "<group>"; };
BEFC1C140C07756200B0BB3C /* remote.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = remote.c; sourceTree = "<group>"; };
BEFC1C0E0C07756200B0BB3C /* daemon.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = daemon.cc; sourceTree = "<group>"; };
BEFC1C140C07756200B0BB3C /* remote.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = remote.cc; sourceTree = "<group>"; };
BEFC1CF90C07822400B0BB3C /* transmission-remote */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "transmission-remote"; sourceTree = BUILT_PRODUCTS_DIR; };
BEFC1DF00C07861A00B0BB3C /* version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
BEFC1DF10C07861A00B0BB3C /* utils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = utils.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1025,7 +1025,7 @@
C1A751E426ED09A30038B90A /* arc4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = arc4.h; path = "third-party/arc4/src/arc4.h"; sourceTree = SOURCE_ROOT; };
C1BF7BA71F2A3CB7008E88A7 /* upnpdev.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = upnpdev.c; sourceTree = "<group>"; };
C1BF7BA91F2A3CCE008E88A7 /* upnpdev.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = upnpdev.h; sourceTree = "<group>"; };
C1F690FC1AD0627500D95CF0 /* daemon-posix.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "daemon-posix.c"; sourceTree = "<group>"; };
C1F690FC1AD0627500D95CF0 /* daemon-posix.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "daemon-posix.cc"; sourceTree = "<group>"; };
C1F690FE1AD0628400D95CF0 /* daemon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = daemon.h; sourceTree = "<group>"; };
C1FEE5721C3223CC00D62832 /* watchdir-common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "watchdir-common.h"; sourceTree = "<group>"; };
C1FEE5731C3223CC00D62832 /* watchdir-generic.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "watchdir-generic.cc"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1734,17 +1734,17 @@
BEFC1C0B0C07754700B0BB3C /* daemon */ = {
isa = PBXGroup;
children = (
BEFC1C0E0C07756200B0BB3C /* daemon.c */,
BEFC1C0E0C07756200B0BB3C /* daemon.cc */,
C1F690FE1AD0628400D95CF0 /* daemon.h */,
C1F690FC1AD0627500D95CF0 /* daemon-posix.c */,
C1F690FC1AD0627500D95CF0 /* daemon-posix.cc */,
);
path = daemon;
sourceTree = "<group>";
};
C15E58AC219A37C600AB292F /* utils */ = {
isa = PBXGroup;
children = (
BEFC1C140C07756200B0BB3C /* remote.c */,
BEFC1C140C07756200B0BB3C /* remote.cc */,
);
path = utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -2683,16 +2683,16 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BEFC1C1A0C07756200B0BB3C /* daemon.c in Sources */,
C1F690FD1AD0627500D95CF0 /* daemon-posix.c in Sources */,
BEFC1C1A0C07756200B0BB3C /* daemon.cc in Sources */,
C1F690FD1AD0627500D95CF0 /* daemon-posix.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
BEFC1CED0C07822400B0BB3C /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BEFC1D050C07825A00B0BB3C /* remote.c in Sources */,
BEFC1D050C07825A00B0BB3C /* remote.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -3085,6 +3085,8 @@
0053D3D60C86774200545606 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -3099,6 +3101,8 @@
0053D3D70C86774200545606 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -3117,6 +3121,8 @@
0053D3D80C86774200545606 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -3261,6 +3267,8 @@
4DDBB71E09E16BF100284745 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -3473,6 +3481,8 @@
A250CFED0CDA19680068B4B6 /* Release - Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -3521,6 +3531,8 @@
A250CFEF0CDA19680068B4B6 /* Release - Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -3539,6 +3551,8 @@
A250CFF00CDA19680068B4B6 /* Release - Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -3684,6 +3698,8 @@
BEFC1C0A0C07753800B0BB3C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -3702,6 +3718,8 @@
BEFC1CF80C07822400B0BB3C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand Down
12 changes: 7 additions & 5 deletions daemon/CMakeLists.txt
Expand Up @@ -4,6 +4,8 @@ if(WITH_SYSTEMD)
add_definitions(-DUSE_SYSTEMD)
endif()

add_compile_options(${CXX_WARNING_FLAGS})

include_directories(
${CMAKE_SOURCE_DIR}
)
Expand All @@ -14,15 +16,15 @@ include_directories(
)

set(${PROJECT_NAME}_SOURCES
daemon.c
daemon-posix.c
daemon-win32.c
daemon.cc
daemon-posix.cc
daemon-win32.cc
)

if(WIN32)
set_source_files_properties(daemon-posix.c PROPERTIES HEADER_FILE_ONLY ON)
set_source_files_properties(daemon-posix.cc PROPERTIES HEADER_FILE_ONLY ON)
else()
set_source_files_properties(daemon-win32.c PROPERTIES HEADER_FILE_ONLY ON)
set_source_files_properties(daemon-win32.cc PROPERTIES HEADER_FILE_ONLY ON)
endif()

set(${PROJECT_NAME}_HEADERS
Expand Down
2 changes: 1 addition & 1 deletion daemon/daemon-posix.c → daemon/daemon-posix.cc
Expand Up @@ -56,7 +56,7 @@ static void handle_signal(int sig)
break;

default:
assert(!"Unexpected signal");
assert("Unexpected signal");
}
}

Expand Down
File renamed without changes.

0 comments on commit 1ee88c0

Please sign in to comment.