Skip to content

Commit 79565d2

Browse files
Fix Conan build: include obfs4_cpp sources in package export
The conan create command copies tor_relays sources to an isolated cache directory where the sibling ../obfs4_cpp path doesn't exist. Replace the static exports_sources with an export_sources() method that also copies obfs4_cpp into the export folder, and add a conditional path check in CMakeLists.txt to find obfs4_cpp in either location. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6c101d1 commit 79565d2

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
4444
endif()
4545

4646
# Add obfs4_cpp library (standalone obfs4 transport implementation)
47-
add_subdirectory(${CMAKE_SOURCE_DIR}/../obfs4_cpp ${CMAKE_BINARY_DIR}/obfs4_cpp)
47+
# Check Conan-exported path first, then monorepo sibling path
48+
if(EXISTS "${CMAKE_SOURCE_DIR}/obfs4_cpp/CMakeLists.txt")
49+
add_subdirectory(${CMAKE_SOURCE_DIR}/obfs4_cpp ${CMAKE_BINARY_DIR}/obfs4_cpp)
50+
elseif(EXISTS "${CMAKE_SOURCE_DIR}/../obfs4_cpp/CMakeLists.txt")
51+
add_subdirectory(${CMAKE_SOURCE_DIR}/../obfs4_cpp ${CMAKE_BINARY_DIR}/obfs4_cpp)
52+
else()
53+
message(FATAL_ERROR "obfs4_cpp not found at ${CMAKE_SOURCE_DIR}/obfs4_cpp or ${CMAKE_SOURCE_DIR}/../obfs4_cpp")
54+
endif()
4855

4956
# Source files
5057
set(TOR_SOURCES

conanfile.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import os
2+
13
from conan import ConanFile
24
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
5+
from conan.tools.files import copy
36

47

58
class TorRelaysConan(ConanFile):
@@ -9,13 +12,17 @@ class TorRelaysConan(ConanFile):
912
license = "Proprietary"
1013
url = "https://github.com/scorpiondefense/tor_relays"
1114
settings = "os", "compiler", "build_type", "arch"
12-
exports_sources = (
13-
"CMakeLists.txt",
14-
"cmake/*",
15-
"src/*",
16-
"include/*",
17-
"tests/*",
18-
)
15+
16+
def export_sources(self):
17+
copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder)
18+
copy(self, "cmake/*", src=self.recipe_folder, dst=self.export_sources_folder)
19+
copy(self, "src/*", src=self.recipe_folder, dst=self.export_sources_folder)
20+
copy(self, "include/*", src=self.recipe_folder, dst=self.export_sources_folder)
21+
copy(self, "tests/*", src=self.recipe_folder, dst=self.export_sources_folder)
22+
# Include obfs4_cpp dependency sources alongside tor_relays
23+
obfs4_src = os.path.join(self.recipe_folder, "..", "obfs4_cpp")
24+
if os.path.exists(obfs4_src):
25+
copy(self, "*", src=obfs4_src, dst=os.path.join(self.export_sources_folder, "obfs4_cpp"))
1926

2027
# Migrated from conanfile.txt
2128
def requirements(self):

0 commit comments

Comments
 (0)