Last active
January 25, 2021 01:16
-
-
Save zachlewis/6a87445194e67d760da7f1c5589679f9 to your computer and use it in GitHub Desktop.
zlib rez package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = 'zlib' | |
version = '1.2.11' | |
description = \ | |
''' | |
zlib is designed to be a free, general-purpose, legally unencumbered, lossless data-compression library. | |
''' | |
authors = ['www.zlib.net'] | |
tools = [ | |
] | |
private_build_requires = [ | |
'gcc', | |
] | |
@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 pre_build_commands(): | |
env.CXXFLAGS = '-fPIC $CXXFLAGS' | |
env.CFLAGS = '-fPIC $CFLAGS' | |
env.LDFLAGS = '-Wl,-rpath,$REZ_BUILD_INSTALL_PATH/lib' | |
src_url = 'http://www.zlib.net/zlib-%s.tar.gz' % ".".join(str(this.version).split(".")[0:3]) | |
env.REZ_BUILD_SOURCE_URL = src_url | |
build_command = """ | |
wget $REZ_BUILD_SOURCE_URL | |
tar -xzf zlib* --strip 1 | |
./configure --prefix=$REZ_BUILD_INSTALL_PATH | |
make {install} -j$REZ_BUILD_THREAD_COUNT | |
""" | |
def commands(): | |
env.PATH.prepend('{root}/bin') | |
if building: | |
env.LDFLAGS.set('-L{root}/lib -Wl,-rpath,{root}/lib $LDFLAGS') | |
env.CFLAGS.set('-I{root}/include $CFLAGS') | |
env.CPPFLAGS.set('-I{root}/include $CPPFLAGS') | |
env.CXXFLAGS.set('-I{root}/include $CXXFLAGS') | |
env.PKG_CONFIG_PATH.prepend('{root}/lib/pkgconfig') | |
env.CMAKE_MODULE_PATH.prepend('{root}/lib/cmake') | |
env.CMAKE_INCLUDE_PATH.prepend('{root}/include') | |
env.CMAKE_LIBRARY_PATH.prepend('{root}/lib') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exactly, that's the main reason -- since Rez itself is written in python, the Rez installer goes through some trouble to insulate "rez-python" from the outside world; and in fact, the Rez command line tools are invoked from the sanitized rez-python binary. Were that not the case, Rez wouldn't behave reliably (for multiple users, over spans of time, etc.).
Probably not :). I don't really know how others are using
pre_build_commands
; and I feel like I'm straight-up abusingbuild_command
people invoke external build systems, instead of abusing thebuild_command
as I am. Rez intends to be build-system-agnostic, but it really shines with CMake -- and if CMake is your thing, definitely check out the Rez CMake macros.For my personal stash of rez packages, what started as a proof of concept almost a year ago has now become my go-to method for building stuff with rez, primarily cuz I can read package definitions like a story -- how a given package is born, how it normally behaves, and how it behaves in build contexts (i.e., when invoked as a dependency when building other packages).
What you're doing sounds like it should definitely work nicely..! And super useful, in fact. It's a major pain in the ass installing all these libraries manually.
( Pinging @maxnbk, this is right up his alley )
Definitely keep me posted, and let me know if you any questions...