From f2e5d70062acf010929342119eaf40f47b062e96 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 9 Dec 2020 13:29:17 -0500 Subject: [PATCH] SConstruct : Use Scons builder for file string substitution Windows does not include a `sed` command by default. Previous builds were succeeding on Github Actions because the Windows image it uses includes a `bash` command environment that does include `sed`. Many developers building Windows-only projects would likely not have a `sed` installation. This commit uses the Scons Substfile builder for cross-platform compatibility. --- SConstruct | 30 ++++++++++++++++++---------- doc/config/{Doxyfile => Doxyfile.in} | 0 2 files changed, 20 insertions(+), 10 deletions(-) rename doc/config/{Doxyfile => Doxyfile.in} (100%) diff --git a/SConstruct b/SConstruct index b4f40c005c..96a6ae1761 100644 --- a/SConstruct +++ b/SConstruct @@ -50,7 +50,7 @@ import re import subprocess import platform -EnsureSConsVersion( 0, 97 ) +EnsureSConsVersion( 3, 0, 2 ) # Substfile is a default builder as of 3.0.2 SConsignFile() ieCoreMilestoneVersion = 10 # for announcing major milestones - may contain all of the below @@ -1703,14 +1703,19 @@ coreEnv.Alias( "installLib", [ coreLibraryInstall ] ) # headers # take special care for the Version header -sedSubstitutions = "s/IE_CORE_MILESTONEVERSION/$IECORE_MILESTONE_VERSION/g" -sedSubstitutions += "; s/IE_CORE_MAJORVERSION/$IECORE_MAJOR_VERSION/g" -sedSubstitutions += "; s/IE_CORE_MINORVERSION/$IECORE_MINOR_VERSION/g" -sedSubstitutions += "; s/IE_CORE_PATCHVERSION/$IECORE_PATCH_VERSION/g" # windows seems to return the glob matches with a delightful mix of path seperators (eg "include/IECore\\Version.h") versionHeader = os.path.join( "include/IECore", "Version.h" ) coreHeaders.remove( versionHeader ) -versionHeaderInstall = env.Command( "$INSTALL_HEADER_DIR/IECore/Version.h", versionHeader, "sed \"" + sedSubstitutions + "\" $SOURCE > $TARGET" ) +versionHeaderInstall = env.Substfile( + "$INSTALL_HEADER_DIR/IECore/Version.h", + versionHeader, + SUBST_DICT = { + "IE_CORE_MILESTONEVERSION": "$IECORE_MILESTONE_VERSION", + "IE_CORE_MAJORVERSION": "$IECORE_MAJOR_VERSION", + "IE_CORE_MINORVERSION": "$IECORE_MINOR_VERSION", + "IE_CORE_PATCHVERSION": "$IECORE_PATCH_VERSION", + } +) # handle the remaining core headers headerInstall = coreEnv.Install( "$INSTALL_HEADER_DIR/IECore", coreHeaders ) coreEnv.AddPostAction( "$INSTALL_HEADER_DIR/IECore", lambda target, source, env : makeSymLinks( coreEnv, coreEnv["INSTALL_HEADER_DIR"] ) ) @@ -3553,10 +3558,15 @@ if doConfigure : sys.stdout.write( "yes\n" ) - if env["PLATFORM"] != "win32": - docs = docEnv.Command( "doc/html/index.html", "doc/config/Doxyfile", "sed s/!CORTEX_VERSION!/$IECORE_VERSION/g $SOURCE | $DOXYGEN -" ) - else: - docs = docEnv.Command( "doc/html/index.html", "doc/config/Doxyfile", "powershell -Command \"cat $SOURCE | % { $$_ -replace \\\"\!CORTEX_VERSION\!\\\",\\\"$IECORE_VERSION\\\" } | $DOXYGEN -\"" ) + substDocs = docEnv.Substfile( + "doc/config/Doxyfile", + SUBST_DICT = { + "!CORTEX_VERSION!" : env.subst( "$IECORE_VERSION" ), + } + ) + docEnv.NoCache( substDocs ) + + docs = docEnv.Command( "doc/html/index.html", "doc/config/Doxyfile", "$DOXYGEN $SOURCE") docEnv.NoCache( docs ) for modulePath in ( "python/IECore", "python/IECoreGL", "python/IECoreNuke", "python/IECoreMaya", "python/IECoreHoudini" ) : diff --git a/doc/config/Doxyfile b/doc/config/Doxyfile.in similarity index 100% rename from doc/config/Doxyfile rename to doc/config/Doxyfile.in