Skip to content

Commit

Permalink
[build_usd] fix for building OpenEXR-2.2 with Ninja
Browse files Browse the repository at this point in the history
  • Loading branch information
pmolodo committed Oct 19, 2018
1 parent 6120da1 commit d7cc374
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,16 @@ def RunCMake(context, force, extraArgs = None):
else "-j{procs}")
.format(procs=context.numJobs)))

def PatchFile(filename, patches):
def PatchFile(filename, patches, multiLineMatches=False):
"""Applies patches to the specified file. patches is a list of tuples
(old string, new string)."""
oldLines = open(filename, 'r').readlines()
if multiLineMatches:
oldLines = [open(filename, 'r').read()]
else:
oldLines = open(filename, 'r').readlines()
newLines = oldLines
for (oldLine, newLine) in patches:
newLines = [s.replace(oldLine, newLine) for s in newLines]
for (oldString, newString) in patches:
newLines = [s.replace(oldString, newString) for s in newLines]
if newLines != oldLines:
PrintInfo("Patching file {filename} (original in {oldFilename})..."
.format(filename=filename, oldFilename=filename + ".old"))
Expand Down Expand Up @@ -648,6 +651,34 @@ def InstallOpenEXR(context, force, buildArgs):

ilmbaseSrcDir = os.path.join(srcDir, "IlmBase")
with CurrentWorkingDirectory(ilmbaseSrcDir):
# openexr 2.2 has a bug with Ninja:
# https://github.com/openexr/openexr/issues/94
# https://github.com/openexr/openexr/pull/142
# Fix commit here:
# https://github.com/openexr/openexr/commit/8eed7012c10f1a835385d750fd55f228d1d35df9
# Merged here:
# https://github.com/openexr/openexr/commit/b206a243a03724650b04efcdf863c7761d5d5d5b
if context.cmakeGenerator == "Ninja":
PatchFile(
os.path.join('Half', 'CMakeLists.txt'),
[
("TARGET eLut POST_BUILD",
"OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/eLut.h"),
(" COMMAND eLut > ${CMAKE_CURRENT_BINARY_DIR}/eLut.h",
" COMMAND eLut ARGS > ${CMAKE_CURRENT_BINARY_DIR}/eLut.h\n"
" DEPENDS eLut"),
("TARGET toFloat POST_BUILD",
"OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/toFloat.h"),
(" COMMAND toFloat > ${CMAKE_CURRENT_BINARY_DIR}/toFloat.h",
" COMMAND toFloat ARGS > ${CMAKE_CURRENT_BINARY_DIR}/toFloat.h\n"
" DEPENDS toFloat"),

(" ${CMAKE_CURRENT_BINARY_DIR}/eLut.h\n"
" OBJECT_DEPENDS\n"
" ${CMAKE_CURRENT_BINARY_DIR}/toFloat.h\n",
' "${CMAKE_CURRENT_BINARY_DIR}/eLut.h;${CMAKE_CURRENT_BINARY_DIR}/toFloat.h"\n'),
],
multiLineMatches=True)
RunCMake(context, force, buildArgs)

openexrSrcDir = os.path.join(srcDir, "OpenEXR")
Expand Down

0 comments on commit d7cc374

Please sign in to comment.