From d7cc37475058b92c83656a1bb446ff2d87285913 Mon Sep 17 00:00:00 2001 From: Paul Molodowitch Date: Sun, 5 Aug 2018 12:40:16 -0700 Subject: [PATCH] [build_usd] fix for building OpenEXR-2.2 with Ninja apparently fixed in dev branch - see: https://github.com/openexr/openexr/issues/94 https://github.com/openexr/openexr/pull/142 --- build_scripts/build_usd.py | 39 ++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/build_scripts/build_usd.py b/build_scripts/build_usd.py index 844af48305..bd7f526c35 100644 --- a/build_scripts/build_usd.py +++ b/build_scripts/build_usd.py @@ -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")) @@ -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")