Skip to content

Instantly share code, notes, and snippets.

@zachlewis
Created December 7, 2020 23:43
Show Gist options
  • Save zachlewis/c6e765ba5668189766da538cd33efb6d to your computer and use it in GitHub Desktop.
Save zachlewis/c6e765ba5668189766da538cd33efb6d to your computer and use it in GitHub Desktop.
protobuf_cpp rez package
# -*- coding: utf-8 -*-
name = 'protobuf_cpp'
version = '3.5.1'
description = 'protocol buffers'
authors = ['google']
tools = ['protoc']
private_build_requires = [
'cmake-3',
'gcc-5+',
#'setuptools-41+',
#'pip-19+'
]
def pre_build_commands():
ver = '.'.join(map(str, this.version[0:3]))
archive_url = ('https://github.com/protocolbuffers/protobuf/releases/download/v{ver}/' 'protobuf-cpp-{ver}.tar.gz')
env.REZ_BUILD_ARCHIVE_URL = 'wget {archive_url}'
build_command = """
wget $REZ_BUILD_ARCHIVE_URL
tar -xzf *.tar.gz --strip 1
./configure --prefix=$REZ_BUILD_INSTALL_PATH
make {install} -j$REZ_BUILD_THREAD_COUNT
"""
@early()
def uuid():
import uuid
return str(uuid.uuid5(uuid.NAMESPACE_DNS, name))
@early()
def variants():
from rez.package_py_utils import expand_requires
requires = ["platform-**", "arch-**", "os-**"]
return [expand_requires(*requires)]
def commands():
env.PATH.append('{root}/bin')
env.LD_LIBRARY_PATH.append('{root}/lib')
env.PROTOC_INCLUDEDIR = "{root}/include"
if building:
env.Protobuff_ROOT = '{root}'
env.CMAKE_MODULE_PATH.append("{root}/cmake")
env.PKG_CONFIG_PATH.append("{root}/lib/pkgconfig")
env.LDFLAGS = '-L{root}/lib -Wl,-rpath,{root}/lib $LDFLAGS'
for c in ['CFLAGS', 'CPPFLAGS', 'CXXFLAGS']:
setenv(c, '-I{root}/include $%s' % c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment