Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actually fixed not getting wrong protoc
Browse files Browse the repository at this point in the history
John-LittleBearLabs committed Dec 3, 2024
1 parent 81fee81 commit e9f3b82
Showing 6 changed files with 45 additions and 29 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -14,9 +14,12 @@ project(ipfs_client
set(TESTING ON CACHE BOOL "Do we want to run tests?")
set(CXX_VERSION 20 CACHE STRING "Should be no less than your conan profile.")

file(READ bld/protobuf_version.txt pb_ver)
string(STRIP "${pb_ver}" pb_ver)

include(dependencies)

dependency(protobuf VERSION 3.20.0)
dependency(protobuf VERSION ${pb_ver})
dependency(absl)
dependency(Boost)
dependency(c-ares)
@@ -54,7 +57,7 @@ foreach(proto ${protos})
OUTPUT "${p}.h" "${p}.cc"
MAIN_DEPENDENCY "${proto}"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${d}"
COMMAND protobuf::protoc "--proto_path=${CMAKE_CURRENT_SOURCE_DIR}/proto" "--cpp_out=${d}" "${proto}"
COMMAND bash -ex "${CMAKE_CURRENT_SOURCE_DIR}/bld/protoc.sh" "${CMAKE_CURRENT_SOURCE_DIR}/proto" "${d}" "${proto}"
)
list(APPEND pb_gen "${p}.h" )
list(APPEND pb_gen "${p}.cc")
@@ -73,6 +76,7 @@ target_compile_features(ic_proto
target_include_directories(ic_proto
PUBLIC
"${CMAKE_CURRENT_BINARY_DIR}/gen"
"${protobuf_INCLUDE_DIR}"
)
target_link_libraries(ic_proto
PUBLIC
1 change: 1 addition & 0 deletions bld/protobuf_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.27.0
3 changes: 3 additions & 0 deletions bld/protoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -ex
source build/Debug/generators/conanbuild.sh
protoc "--proto_path=${1}" "--cpp_out=${2}" "${3}"
44 changes: 24 additions & 20 deletions bld/version.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

def git(git_args):
cmd_args = ['git', '-C', here] + git_args
result = subprocess.run(args=cmd_args, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True)
result = subprocess.run(args=cmd_args, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True, check=True)
return result.stdout.strip()


@@ -30,39 +30,43 @@ def tag_to_version(tag):
return 0


git(['fetch', '--all', '--tags'])


def dist(x):
return int(git(['rev-list', '--count', f'{x}..HEAD']))


def recent():
git(['fetch', '--all', '--tags'])
tags = [(dist(x), x) for x in git(['tag']).splitlines() if tag_to_version(x) > 0]
return min(tags)[1]


def on_tag():
git(['fetch', '--all', '--tags'])
return git(['describe', '--tags', '--exact-match', 'HEAD'])


def deduce():
tag = on_tag()
if tag and tag_to_version(tag) > 0:
result = tag
else:
git(['fetch', '--tags'])
tags = git(['tag']).splitlines()
versions = map(tag_to_version, tags)
last = max(versions)
next = last + 1
major = str(next//1000)
minor = str((next//100) % 10)
revision = str((next//10) % 10)
build = str(next % 10)
result = '.'.join([major, minor, revision, build])
with open(join(here, 'version.txt'), 'w') as txt:
print(result, file=txt)
try:
git(['fetch', '--all', '--tags'])
tag = on_tag()
if tag and tag_to_version(tag) > 0:
result = tag
else:
git(['fetch', '--tags'])
tags = git(['tag']).splitlines()
versions = map(tag_to_version, tags)
last = max(versions)
next = last + 1
major = str(next//1000)
minor = str((next//100) % 10)
revision = str((next//10) % 10)
build = str(next % 10)
result = '.'.join([major, minor, revision, build])
with open(join(here, 'version.txt'), 'w') as txt:
print(result, file=txt)
except subprocess.CalledProcessError:
with open(join(here, 'version.txt')) as txt:
result = txt.read().strip()
return result


4 changes: 2 additions & 2 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ function(dependency name)
"VERSION" #single-value
"" # multi-value
)
if(${arg_VERSION})
if(arg_VERSION)
find_package(
${name}
${arg_VERSION}
@@ -34,7 +34,7 @@ function(dependency name)
endif()
# message(WARNING "${name}_FOUND=${${name}_FOUND}")
if (${name}_FOUND)
message(STATUS "${name} found at version ${${name}_VERSION} in ${${name}_DIR}")
message(WARNING "${name} found at version ${${name}_VERSION} in ${${name}_DIR} inc ${${protobuf}_INCLUDE_DIR}")
else()
message(WARNING "Did not find ${name}, will try conan fetching.")
if(TESTING)
14 changes: 9 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,11 @@
VERSION = open(join(here, 'version.txt'), 'r').read().strip()


def protobuf_version():
with open(join(here, 'bld', 'protobuf_version.txt')) as f:
return f.read().strip()


class IpfsChromium(ConanFile):
name = "ipfs_client"
version = VERSION
@@ -25,15 +30,14 @@ class IpfsChromium(ConanFile):
topics = ("ipfs", "ipns", "dweb", "web", "content-addressed", "network", "client", "io", "api", "file-sharing", "gateway", "kubo")
license = "MIT,Apache-2.0,https://raw.githubusercontent.com/little-bear-labs/ipfs-chromium/main/library/LICENSE"
settings = "os", "compiler", "build_type", "arch"
_PB = 'protobuf/3.20.0'
require_transitively = [
'abseil/20230125.3',
'abseil/20240116.2',
'boost/1.81.0',
'bzip2/1.0.8',
'c-ares/1.22.1',
'nlohmann_json/3.11.2',
'openssl/1.1.1w',
_PB,
f'protobuf/{protobuf_version()}',
]
options = {
"testing": [True, False],
@@ -46,10 +50,10 @@ class IpfsChromium(ConanFile):
tool_requires = [
'cmake/3.22.6',
'ninja/1.11.1',
_PB,
f'protobuf/{protobuf_version()}',
]
extensions = ['h', 'cc', 'hpp', 'proto']
exports_sources = [ '*.txt' ] + [f'**/*.{e}' for e in extensions]
exports_sources = ['*.txt'] + [f'**/*.{e}' for e in extensions]
exports = 'version.txt'
package_type = 'static-library'

0 comments on commit e9f3b82

Please sign in to comment.