diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c1dd49aa3..980a6e7281 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,7 +55,7 @@ jobs: jobs: 4 containerImage: # Something simple to start. When ready, the projects below should be included in the first job. - projectsString: --projects GafferResources + projectsString: --projects GafferResources BitstreamVera PCG # projectsString: --projects LibFFI TBB Python ZLib Boost Imath OpenEXR HDF5 Alembic BitstreamVera Blosc CMark PyBind11 LibJPEG-Turbo LibTIFF LibPNG OpenJPEG Expat YAML-CPP PyString Minizip OpenColorIO LibRaw PugiXML Fmt LibWebP FreeType OpenImageIO LLVM OpenShadingLanguage GLEW OpenVDB OpenSubdiv PyOpenGL Qt PySide uses: ./.github/workflows/buildDependencyBatch.yml diff --git a/BitstreamVera/config.py b/BitstreamVera/config.py index f4a7f141aa..15bfe0719e 100644 --- a/BitstreamVera/config.py +++ b/BitstreamVera/config.py @@ -10,10 +10,11 @@ "license" : "COPYRIGHT.TXT", - "commands" : [ + "commands" : [], - "mkdir -p {buildDir}/fonts", - "cp *.ttf {buildDir}/fonts" + "postBuildCopy" : [ + + ( None, "*.ttf", "{buildDir}/fonts" ), ], diff --git a/Changes.md b/Changes.md index 98a8bee976..1690eb2172 100644 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,7 @@ 11.x.x (relative to 11.0.0a4) ------ +- build.py : Added `postBuildCopy` and `postBuildMove` configuration steps. 11.0.0a4 (relative to 11.0.0a3) diff --git a/Cycles/config.py b/Cycles/config.py index 21011221d7..e2241c5c3d 100644 --- a/Cycles/config.py +++ b/Cycles/config.py @@ -40,13 +40,20 @@ " ..", "cd build && make install -j {jobs} VERBOSE=1", - "mkdir -p {buildDir}/cycles/include", - "cd src && find . -name '*.h' | cpio -pdm {buildDir}/cycles/include", - "cp -r third_party/atomic/* {buildDir}/cycles/include", - "mkdir -p {buildDir}/cycles/bin", - "mv {buildDir}/cycles/cycles {buildDir}/cycles/bin/cycles", - "cp -r build/lib {buildDir}/cycles", + ], + + "postBuildCopy" : [ + ( "src", "**/*.h", "{buildDir}/cycles/include" ), + ( "third_party/atomic", "**/*.h", "{buildDir}/cycles/include" ), + ( "build/lib", "**/*", "{buildDir}/cycles/lib" ), + + ], + + "postBuildMove" : [ + + ( "{buildDir}/cycles", "cycles", "{buildDir}/cycles/bin" ), + ], "manifest" : [ diff --git a/OpenColorIO/config.py b/OpenColorIO/config.py index eaeef69ac8..ba53809193 100644 --- a/OpenColorIO/config.py +++ b/OpenColorIO/config.py @@ -43,12 +43,19 @@ "cd build && make clean && make VERBOSE=1 -j {jobs} && make install", - "mkdir -p {buildDir}/python", - "mv {buildDir}/lib*/python*/site-packages/PyOpenColorIO* {buildDir}/python", + ], + + "postBuildCopy" : [ + + + ( "..", "studio-config-v3.0.0_aces-v2.0_ocio-v2.4.ocio", "{buildDir}/openColorIO" ), + ( "..", "cg-config-v3.0.0_aces-v2.0_ocio-v2.4.ocio", "{buildDir}/openColorIO" ), + + ], + + "postBuildMove" : [ - "mkdir -p {buildDir}/openColorIO", - "cp ../studio-config-v3.0.0_aces-v2.0_ocio-v2.4.ocio {buildDir}/openColorIO", - "cp ../cg-config-v3.0.0_aces-v2.0_ocio-v2.4.ocio {buildDir}/openColorIO", + ( "{buildDir}/lib/python{pythonVersion}/site-packages", "PyOpenColorIO*/**/*", "{buildDir}/python" ), ], diff --git a/OpenShadingLanguage/config.py b/OpenShadingLanguage/config.py index 26132a6772..80b9e79399 100644 --- a/OpenShadingLanguage/config.py +++ b/OpenShadingLanguage/config.py @@ -45,14 +45,12 @@ " {extraArguments}" " ..", "cd gafferBuild && make install -j {jobs} VERBOSE=1", - "{extraCommands}", ], "variables" : { "extraArguments" : "", - "extraCommands" : "", "useBatched" : "b8_AVX,b8_AVX2,b8_AVX2_noFMA,b8_AVX512,b8_AVX512_noFMA,b16_AVX512,b16_AVX512_noFMA", }, @@ -81,9 +79,14 @@ "platform:macos" : { + "postBuildMove" : [ + + ( "{buildDir}/lib/python{pythonVersion}/site-packages", "oslquery", "{pythonLibDir}/python{pythonVersion}/site-packages" ), + + ], + "variables" : { - "extraCommands" : "mv {buildDir}/lib/python{pythonVersion}/site-packages/oslquery {pythonLibDir}/python{pythonVersion}/site-packages/oslquery", "useBatched" : "0", }, diff --git a/PCG/config.py b/PCG/config.py index 97a7fb671e..68dfe0c450 100644 --- a/PCG/config.py +++ b/PCG/config.py @@ -10,10 +10,11 @@ "license" : "LICENSE-MIT.txt", + "commands" : [], - "commands" : [ - "mkdir -p {buildDir}/include/pcg", - "cp include/*.hpp {buildDir}/include/pcg", + "postBuildCopy" : [ + + ( "include", "*.hpp", "{buildDir}/include/pcg" ), ], diff --git a/PyString/config.py b/PyString/config.py index f933353f67..006c196acc 100644 --- a/PyString/config.py +++ b/PyString/config.py @@ -20,7 +20,12 @@ " -D BUILD_SHARED_LIBS=ON" " ..", "cd build && make -j {jobs} && make install", - "mkdir -p {buildDir}/include/pystring && cp pystring.h {buildDir}/include/pystring", + + ], + + "postBuildCopy" : [ + + ( None, "pystring.h", "{buildDir}/include/pystring" ), ], diff --git a/Qt.py/config.py b/Qt.py/config.py index 3699e53cee..9767a4df14 100644 --- a/Qt.py/config.py +++ b/Qt.py/config.py @@ -11,9 +11,11 @@ "dependencies" : [ "Python" ], - "commands" : [ + "commands" : [], - "cp Qt.py {buildDir}/python", + "postBuildCopy" : [ + + ( None, "Qt.py", "{buildDir}/python" ) ], diff --git a/Qt/config.py b/Qt/config.py index 6c1dcdc228..76003b5bd3 100644 --- a/Qt/config.py +++ b/Qt/config.py @@ -62,9 +62,13 @@ "cmake --build . --parallel {jobs} && cmake --install .", - "cp {buildDir}/libexec/moc {buildDir}/bin", - "cp {buildDir}/libexec/rcc {buildDir}/bin", - "cp {buildDir}/libexec/uic {buildDir}/bin", + ], + + "postBuildCopy" : [ + + ( "{buildDir}/libexec", "moc", "{buildDir}/bin" ), + ( "{buildDir}/libexec", "rcc", "{buildDir}/bin" ), + ( "{buildDir}/libexec", "uic", "{buildDir}/bin" ), ], diff --git a/USD/config.py b/USD/config.py index f0f3bf5672..4ac456e366 100644 --- a/USD/config.py +++ b/USD/config.py @@ -51,7 +51,12 @@ "make install", "rm -rf {buildDir}/python/pxr", - "mv {buildDir}/lib/python/pxr {buildDir}/python", + + ], + + "postBuildMove" : [ + + ( "{buildDir}/lib/python", "pxr/**/*", "{buildDir}/python" ), ], diff --git a/build.py b/build.py index 0ec0bbffd4..8fb19597f3 100755 --- a/build.py +++ b/build.py @@ -8,8 +8,10 @@ import os import operator import multiprocessing +import pathlib import subprocess import shutil +import stat import sys import tarfile import zipfile @@ -39,6 +41,13 @@ - enabled : May be set to `False` to disable a project entirely. This is only expected to be useful in conjunction with platform overrides or variants. +- postBuildCopy / postBuildMove : List of copy / move directives, each + of the form ( sourceRoot, globPattern, destinationRoot ) + specifying paths that should be copied / moved after all `commands` + have run. Files in `sourceRoot` that match `globPattern` (including + the recursive `**` pattern) are copied / moved, with their path relative + to `sourceRoot`, to `destinationRoot`. Destination directories will be + created if necessary. ### Packaging @@ -188,6 +197,8 @@ def __updateDigest( project, config ) : __appendHash( config["digest"], config.get( "environment" ) ) __appendHash( config["digest"], config.get( "commands" ) ) __appendHash( config["digest"], config.get( "symbolicLinks" ) ) + __appendHash( config["digest"], config.get( "postBuildCopy" ) ) + __appendHash( config["digest"], config.get( "postBuildMove" ) ) for e in config.get( "requiredEnvironment", [] ) : __appendHash( config["digest"], os.environ.get( e, "" ) ) @@ -316,6 +327,19 @@ def __buildProject( project, config, buildDir, cleanup ) : sys.stderr.write( command + "\n" ) subprocess.check_call( command, shell = True, env = environment ) + for operation in [ "postBuildCopy", "postBuildMove" ] : + for sourceRoot, pattern, destinationRoot in config.get( operation, () ) : + sourceRoot = pathlib.Path( sourceRoot or "." ) + destinationRoot = pathlib.Path( destinationRoot ) + + for p in sourceRoot.glob( pattern ) : + destinationPath = destinationRoot / p.relative_to( sourceRoot ) + destinationPath.parent.mkdir( parents = True, exist_ok = True ) + if operation == "postBuildCopy" : + shutil.copy( p, destinationPath ) + else : + p.replace( destinationPath ) + for link in config.get( "symbolicLinks", [] ) : sys.stderr.write( "Linking {} to {}\n".format( link[0], link[1] ) ) if os.path.lexists( link[0] ) : @@ -323,8 +347,12 @@ def __buildProject( project, config, buildDir, cleanup ) : os.symlink( link[1], link[0] ) if cleanup : + def removeReadonly( func, path, *unused ) : + os.chmod( path, stat.S_IWRITE ) + func( path ) + os.chdir( buildRootDirectory ) - shutil.rmtree( fullWorkingDir ) + shutil.rmtree( fullWorkingDir, onexc = removeReadonly ) def __checkConfigs( projects, configs ) :