Skip to content

Commit

Permalink
SConstruct : Use Scons builder for file string substitution
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ericmehl committed Jan 4, 2021
1 parent 33f3b61 commit f2e5d70
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"] ) )
Expand Down Expand Up @@ -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" ) :
Expand Down
File renamed without changes.

0 comments on commit f2e5d70

Please sign in to comment.