Skip to content

Commit

Permalink
Don't require it.
Browse files Browse the repository at this point in the history
Doxygen built from Conan
if there's an install.
  • Loading branch information
John-LittleBearLabs committed Jun 16, 2023
1 parent 73b6218 commit 4ac9838
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
if: startsWith(matrix.config.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install --yes cmake ninja-build
sudo apt-get install --yes cmake ninja-build doxygen
ninja --version
cmake --version
g++ --version
Expand Down
6 changes: 3 additions & 3 deletions cmake/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
boost/*:without_test=True
boost/*:without_type_erasure=True

[tool_requires]
cmake/3.26.4
doxygen/1.9.1

[imports]
bin, * -> tools

[tool_requires]
cmake/3.26.4
14 changes: 13 additions & 1 deletion cmake/setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,20 @@ else()
#How incredibly obnoxious is it that conan 2 dropped support for these envs?
file(WRITE "${conan_home}/global.conf" core.net.http:timeout=$ENV{CONAN_REQUEST_TIMEOUT})
endif()
file(COPY_FILE
"${CMAKE_CURRENT_LIST_DIR}/conanfile.txt"
"${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt"
)
find_package(Doxygen)
if (NOT DOXYGEN_FOUND)
message(WARNING "Will attempt to get doxygen from Conan, which doesn't work on some systems like Github's ubuntu-latest runner.")
file(APPEND
"${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt"
doxygen/1.9.4
)
endif()
execute_process(
COMMAND conan install ${CMAKE_CURRENT_LIST_DIR} --output-folder=${CMAKE_CURRENT_BINARY_DIR} --build=missing --settings build_type=${CMAKE_BUILD_TYPE} --generator CMakeDeps
COMMAND conan install ${CMAKE_CURRENT_BINARY_DIR} --output-folder=${CMAKE_CURRENT_BINARY_DIR} --build=missing --settings build_type=${CMAKE_BUILD_TYPE} --generator CMakeDeps
COMMAND_ERROR_IS_FATAL ANY
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
Expand Down
7 changes: 6 additions & 1 deletion library/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from shutil import which
import sys
from os.path import dirname, join, realpath
sys.path.append(realpath(join(dirname(__file__), '..', 'cmake')))
Expand All @@ -22,7 +23,6 @@ class IpfsChromium(ConanFile):
default_options = {"boost/*:header_only": True}
tool_requires = [
'cmake/3.22.6',
'doxygen/1.9.1',
'ninja/1.11.1',
_PB,
]
Expand All @@ -40,4 +40,9 @@ def build(self):
"INSIDE_CONAN": True
})
cmake.build()


def build_requirements(self):
if not which("doxygen"):
self.tool_requires("doxygen/1.9.4")
# gperf doxygen ccache lcov
6 changes: 6 additions & 0 deletions library/src/ipfs_client/gateways.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ std::vector<std::pair<std::string, int>> ipfs::Gateways::DefaultGateways() {
std::vector<std::pair<std::string, int>> result;
std::string gw;
while (user_override >> gw) {
if ( gw.empty() ) {
continue;
}
if ( gw.back() != '/' ) {
gw.push_back('/');
}
result.emplace_back( gw, 0 );
}
auto N = static_cast<int>(result.size());
Expand Down
11 changes: 11 additions & 0 deletions library/src/ipfs_client/gateways_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@ TEST(GatewaysTest, DefaultListMeetsBasicGuidelines) {
EXPECT_LE(dg.at(i).second, dg.at(i - 1).second);
}
}

TEST(GatewaysTest, OverriddenListEndsEntriesInSlash) {
::putenv("IPFS_GATEWAY= a b c d 1 : http://chomp:8080");
auto dg = ipfs::Gateways::DefaultGateways();
EXPECT_EQ(dg.size(), 7U);
EXPECT_EQ(dg.at(0).first, "a/");
for (auto i = 1U; i < dg.size(); ++i) {
EXPECT_EQ(dg.at(i).first.back(), '/');
EXPECT_LE(dg.at(i).second, dg.at(i - 1).second);
}
}

0 comments on commit 4ac9838

Please sign in to comment.