From d12d9d858675c43e06394f14f8e3e27415455094 Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Mon, 6 Nov 2023 10:50:24 -0500 Subject: [PATCH 1/7] Working version and build information reporting. --- lib/mayaHydra/hydraExtensions/CMakeLists.txt | 5 ++ lib/mayaHydra/hydraExtensions/mhBuildInfo.cpp | 28 +++++++++ .../hydraExtensions/mhBuildInfo.h.src | 46 ++++++++++++++ lib/mayaHydra/mayaPlugin/viewCommand.cpp | 63 ++++++++++++------- 4 files changed, 121 insertions(+), 21 deletions(-) create mode 100644 lib/mayaHydra/hydraExtensions/mhBuildInfo.cpp create mode 100644 lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src diff --git a/lib/mayaHydra/hydraExtensions/CMakeLists.txt b/lib/mayaHydra/hydraExtensions/CMakeLists.txt index e8997ec658..2417b114cf 100644 --- a/lib/mayaHydra/hydraExtensions/CMakeLists.txt +++ b/lib/mayaHydra/hydraExtensions/CMakeLists.txt @@ -11,6 +11,7 @@ target_sources(${TARGET_NAME} hydraUtils.cpp interfaceImp.cpp mayaUtils.cpp + mhBuildInfo.cpp mixedUtils.cpp mayaHydraSceneProducer.cpp ) @@ -146,6 +147,10 @@ set(SRCFILE ${CMAKE_CURRENT_SOURCE_DIR}/mayaHydra.h.src) set(DSTFILE ${CMAKE_BINARY_DIR}/include/mayaHydraLib/mayaHydra.h) configure_file(${SRCFILE} ${DSTFILE}) +set(SRCFILE ${CMAKE_CURRENT_SOURCE_DIR}/mhBuildInfo.h.src) +set(DSTFILE ${CMAKE_BINARY_DIR}/include/mayaHydraLib/mhBuildInfo.h) +configure_file(${SRCFILE} ${DSTFILE}) + mayaUsd_promoteHeaderList( HEADERS ${HEADERS} diff --git a/lib/mayaHydra/hydraExtensions/mhBuildInfo.cpp b/lib/mayaHydra/hydraExtensions/mhBuildInfo.cpp new file mode 100644 index 0000000000..ab6bb5220b --- /dev/null +++ b/lib/mayaHydra/hydraExtensions/mhBuildInfo.cpp @@ -0,0 +1,28 @@ +// +// Copyright 2023 Autodesk, Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include + +#include + +namespace MAYAHYDRA_NS_DEF { + +int MhBuildInfo::buildNumber() { return MAYAHYDRA_BUILD_NUMBER; } +const char* MhBuildInfo::gitCommit() { return MAYAHYDRA_GIT_COMMIT; } +const char* MhBuildInfo::gitBranch() { return MAYAHYDRA_GIT_BRANCH; } +const char* MhBuildInfo::buildDate() { return MAYAHYDRA_BUILD_DATE; } + +} // namespace MAYAHYDRA_NS_DEF diff --git a/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src b/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src new file mode 100644 index 0000000000..e89e532a25 --- /dev/null +++ b/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src @@ -0,0 +1,46 @@ +// +// Copyright 2023 Autodesk, Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef LIB_MAYAHYDRA_HYDRAEXTENSIONS_MHBUILDINFO_H +#define LIB_MAYAHYDRA_HYDRAEXTENSIONS_MHBUILDINFO_H + +#include +#include + +// At time of writing Peptide build variables undefined. PPT, 3-Nov-2023. +// #define MAYAHYDRA_BUILD_NUMBER ${PEPTIDE_JENKINS_BUILD} +// #define MAYAHYDRA_GIT_COMMIT "${PEPTIDE_GIT_COMMIT}" +// #define MAYAHYDRA_GIT_BRANCH "${PEPTIDE_GIT_BRANCH}" +// #define MAYAHYDRA_BUILD_DATE "${PEPTIDE_PRODUCT_DATE}" +#define MAYAHYDRA_BUILD_NUMBER 0 +#define MAYAHYDRA_GIT_COMMIT "aGitCommit" +#define MAYAHYDRA_GIT_BRANCH "aGitBranch" +#define MAYAHYDRA_BUILD_DATE "aProductDate" + +namespace MAYAHYDRA_NS_DEF { + +class MAYAHYDRALIB_API MhBuildInfo +{ +public: + static int buildNumber(); + static const char* gitCommit(); + static const char* gitBranch(); + static const char* buildDate(); +}; + +} + +#endif // LIB_MAYAHYDRA_HYDRAEXTENSIONS_MHBUILDINFO_H diff --git a/lib/mayaHydra/mayaPlugin/viewCommand.cpp b/lib/mayaHydra/mayaPlugin/viewCommand.cpp index 9f7bd7b882..1e47229415 100644 --- a/lib/mayaHydra/mayaPlugin/viewCommand.cpp +++ b/lib/mayaHydra/mayaPlugin/viewCommand.cpp @@ -20,20 +20,13 @@ #include "renderOverride.h" #include +#include +#include #include #include #include -#if defined(MAYAHYDRA_CUT_ID) -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) -#define PLUGIN_CUT_ID TOSTRING(MAYAHYDRA_CUT_ID) -#else -#pragma message("MAYAHYDRA_CUT_ID is not defined") -#define PLUGIN_CUT_ID "Maya-Hydra unknown cut" -#endif - PXR_NAMESPACE_OPEN_SCOPE // Bring the MayaHydra namespace into scope. // The following code currently lives inside the pxr namespace, but it would make more sense to @@ -79,10 +72,22 @@ constexpr auto _visibleOnlyLong = "-visibleOnly"; constexpr auto _sceneDelegateId = "-sid"; constexpr auto _sceneDelegateIdLong = "-sceneDelegateId"; -// MAYA-127221: We will need to replace this with a flag inside of the pluginInfo command in an -// upcoming release. -constexpr auto _pluginInfoCutId = "-cid"; -constexpr auto _pluginInfoCutIdLong = "-pluginInfoCut"; +// Versioning and build information. +constexpr auto _majorVersion = "-mjv"; +constexpr auto _minorVersion = "-mnv"; +constexpr auto _patchVersion = "-pv"; +constexpr auto _majorVersionLong = "-majorVersion"; +constexpr auto _minorVersionLong = "-minorVersion"; +constexpr auto _patchVersionLong = "-patchVersion"; + +constexpr auto _buildNumber = "-bn"; +constexpr auto _gitCommit = "-gc"; +constexpr auto _gitBranch = "-gb"; +constexpr auto _buildDate = "-bd"; +constexpr auto _buildNumberLong = "-buildNumber"; +constexpr auto _gitCommitLong = "-gitCommit"; +constexpr auto _gitBranchLong = "-gitBranch"; +constexpr auto _buildDateLong = "-buildDate"; constexpr auto _rendererId = "-r"; constexpr auto _rendererIdLong = "-renderer"; @@ -160,7 +165,16 @@ MSyntax MtohViewCmd::createSyntax() syntax.addFlag(_sceneDelegateId, _sceneDelegateIdLong, MSyntax::kString); - syntax.addFlag(_pluginInfoCutId, _pluginInfoCutIdLong); + // Versioning and build information flags. + + syntax.addFlag(_majorVersion, _majorVersionLong); + syntax.addFlag(_minorVersion, _minorVersionLong); + syntax.addFlag(_patchVersion, _patchVersionLong); + + syntax.addFlag(_buildNumber, _buildNumberLong); + syntax.addFlag(_gitCommit, _gitCommitLong); + syntax.addFlag(_gitBranch, _gitBranchLong); + syntax.addFlag(_buildDate, _buildDateLong); return syntax; } @@ -274,13 +288,20 @@ MStatus MtohViewCmd::doIt(const MArgList& args) SdfPath delegateId = MtohRenderOverride::RendererSceneDelegateId( renderDelegateName, TfToken(sceneDelegateName.asChar())); setResult(MString(delegateId.GetText())); - } else if (db.isFlagSet(_pluginInfoCutId)) { -#ifdef MAYAHYDRA_CUT_ID - setResult(MString(PLUGIN_CUT_ID)); -#else - MGlobal::displayError(MString("MayaHydra cut id is not available")); - return MS::kInvalidParameter; -#endif + } else if (db.isFlagSet(_majorVersion)) { + setResult(MAYAHYDRA_MAJOR_VERSION); + } else if (db.isFlagSet(_minorVersion)) { + setResult(MAYAHYDRA_MINOR_VERSION); + } else if (db.isFlagSet(_patchVersion)) { + setResult(MAYAHYDRA_PATCH_LEVEL); + } else if (db.isFlagSet(_buildNumber)) { + setResult(MhBuildInfo::buildNumber()); + } else if (db.isFlagSet(_gitCommit)) { + setResult(MhBuildInfo::gitCommit()); + } else if (db.isFlagSet(_gitBranch)) { + setResult(MhBuildInfo::gitBranch()); + } else if (db.isFlagSet(_buildDate)) { + setResult(MhBuildInfo::buildDate()); } return MS::kSuccess; } From b8414a9c3fc32b302a27678ada5a513747249ab6 Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Mon, 6 Nov 2023 11:25:11 -0500 Subject: [PATCH 2/7] Moved code to MayaHydra namespace. --- lib/mayaHydra/hydraExtensions/mhBuildInfo.cpp | 2 -- lib/mayaHydra/mayaPlugin/plugin.cpp | 14 +++++--------- lib/mayaHydra/mayaPlugin/viewCommand.cpp | 13 +++++-------- lib/mayaHydra/mayaPlugin/viewCommand.h | 7 ++++--- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib/mayaHydra/hydraExtensions/mhBuildInfo.cpp b/lib/mayaHydra/hydraExtensions/mhBuildInfo.cpp index ab6bb5220b..2f538cb383 100644 --- a/lib/mayaHydra/hydraExtensions/mhBuildInfo.cpp +++ b/lib/mayaHydra/hydraExtensions/mhBuildInfo.cpp @@ -16,8 +16,6 @@ #include -#include - namespace MAYAHYDRA_NS_DEF { int MhBuildInfo::buildNumber() { return MAYAHYDRA_BUILD_NUMBER; } diff --git a/lib/mayaHydra/mayaPlugin/plugin.cpp b/lib/mayaHydra/mayaPlugin/plugin.cpp index 59c86f4673..c75f7516b5 100644 --- a/lib/mayaHydra/mayaPlugin/plugin.cpp +++ b/lib/mayaHydra/mayaPlugin/plugin.cpp @@ -47,20 +47,16 @@ #error Maya API version 2024+ required #endif -PXR_NAMESPACE_USING_DIRECTIVE +using namespace MayaHydra; // Don't use smart pointers in the static vector: when Maya is doing its // default "quick exit" that does not uninitialize plugins, the atexit // destruction of the overrides in the vector will crash on destruction, // because Hydra has already destroyed structures these rely on. Simply leak // the render overrides in this case. -static std::vector gsRenderOverrides; +static std::vector gsRenderOverrides; -#if defined(MAYAUSD_VERSION) -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) -#define PLUGIN_VERSION TOSTRING(MAYAUSD_VERSION) -#elif defined(MAYAHYDRA_VERSION) +#if defined(MAYAHYDRA_VERSION) #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) #define PLUGIN_VERSION TOSTRING(MAYAHYDRA_VERSION) @@ -101,7 +97,7 @@ PLUGIN_EXPORT MStatus initializePlugin(MObject obj) // Call one time registration of plugins compiled for same USD version as MayaUSD plugin. MayaUsd::registerVersionedPlugins(); #endif - ret = MayaHydraAdapter::Initialize(); + ret = PXR_NS::MayaHydraAdapter::Initialize(); if (!ret) { return ret; } @@ -126,7 +122,7 @@ PLUGIN_EXPORT MStatus initializePlugin(MObject obj) if (auto* renderer = MHWRender::MRenderer::theRenderer()) { for (const auto& desc : MayaHydra::MtohGetRendererDescriptions()) { - auto mtohRenderer = std::make_unique(desc); + auto mtohRenderer = std::make_unique(desc); MStatus status = renderer->registerOverride(mtohRenderer.get()); if (status == MS::kSuccess) { gsRenderOverrides.push_back(mtohRenderer.release()); diff --git a/lib/mayaHydra/mayaPlugin/viewCommand.cpp b/lib/mayaHydra/mayaPlugin/viewCommand.cpp index 1e47229415..1f079b21d8 100644 --- a/lib/mayaHydra/mayaPlugin/viewCommand.cpp +++ b/lib/mayaHydra/mayaPlugin/viewCommand.cpp @@ -1,5 +1,6 @@ // // Copyright 2019 Luma Pictures +// Copyright 2023 Autodesk, Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -27,13 +28,9 @@ #include #include -PXR_NAMESPACE_OPEN_SCOPE -// Bring the MayaHydra namespace into scope. -// The following code currently lives inside the pxr namespace, but it would make more sense to -// have it inside the MayaHydra namespace. This using statement allows us to use MayaHydra symbols -// from within the pxr namespace as if we were in the MayaHydra namespace. -// Remove this once the code has been moved to the MayaHydra namespace. -using namespace MayaHydra; +PXR_NAMESPACE_USING_DIRECTIVE + +namespace MAYAHYDRA_NS_DEF { const MString MtohViewCmd::name("mayaHydra"); @@ -306,4 +303,4 @@ MStatus MtohViewCmd::doIt(const MArgList& args) return MS::kSuccess; } -PXR_NAMESPACE_CLOSE_SCOPE +} diff --git a/lib/mayaHydra/mayaPlugin/viewCommand.h b/lib/mayaHydra/mayaPlugin/viewCommand.h index bd212277ac..630afc1e26 100644 --- a/lib/mayaHydra/mayaPlugin/viewCommand.h +++ b/lib/mayaHydra/mayaPlugin/viewCommand.h @@ -1,5 +1,6 @@ // // Copyright 2019 Luma Pictures +// Copyright 2023 Autodesk, Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,11 +17,11 @@ #ifndef MTOH_CMD_H #define MTOH_CMD_H -#include +#include #include -PXR_NAMESPACE_OPEN_SCOPE +namespace MAYAHYDRA_NS_DEF { class MtohViewCmd : public MPxCommand { @@ -33,6 +34,6 @@ class MtohViewCmd : public MPxCommand MStatus doIt(const MArgList& args) override; }; -PXR_NAMESPACE_CLOSE_SCOPE +} #endif // MTOH_CMD_H From 4da97cc5360ce3971b669970f0fc069820a8aa45 Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Mon, 6 Nov 2023 11:53:24 -0500 Subject: [PATCH 3/7] Added unit test for version and build info. --- .../render/mayaToHydra/testMtohCommand.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/lib/mayaUsd/render/mayaToHydra/testMtohCommand.py b/test/lib/mayaUsd/render/mayaToHydra/testMtohCommand.py index 07b4feb2fb..becc9c44aa 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testMtohCommand.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testMtohCommand.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import sys import unittest import maya.cmds as cmds @@ -115,6 +114,23 @@ def test_createRenderGlobals(self): self.assertFalse(cmds.getAttr( "defaultRenderGlobals.mtohMotionSampleStart")) + def test_versionInfo(self): + self.assertGreaterEqual(cmds.mayaHydra(majorVersion=True), 0) + self.assertGreaterEqual(cmds.mayaHydra(mjv=True), 0) + self.assertGreaterEqual(cmds.mayaHydra(minorVersion=True), 0) + self.assertGreaterEqual(cmds.mayaHydra(mnv=True), 0) + self.assertGreaterEqual(cmds.mayaHydra(patchVersion=True), 0) + self.assertGreaterEqual(cmds.mayaHydra(pv=True), 0) + + def test_buildInfo(self): + self.assertGreaterEqual(cmds.mayaHydra(buildNumber=True), 0) + self.assertGreaterEqual(cmds.mayaHydra(bn=True), 0) + self.assertNotEqual(cmds.mayaHydra(gitCommit=True), '') + self.assertNotEqual(cmds.mayaHydra(gc=True), '') + self.assertNotEqual(cmds.mayaHydra(gitBranch=True), '') + self.assertNotEqual(cmds.mayaHydra(gb=True), '') + self.assertNotEqual(cmds.mayaHydra(buildDate=True), '') + self.assertNotEqual(cmds.mayaHydra(bd=True), '') if __name__ == '__main__': fixturesUtils.runTests(globals()) From a448c248fa2a0585f445dddc063d33a5edd33cbc Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Fri, 10 Nov 2023 16:32:03 -0500 Subject: [PATCH 4/7] Read build information from CMake. --- CMakeLists.txt | 6 ++++++ lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src | 13 ++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2006a247b1..22d330458f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,12 @@ option(CMAKE_WANT_MATERIALX_BUILD "Enable building with MaterialX (experimental) set(PXR_OVERRIDE_PLUGINPATH_NAME PXR_PLUGINPATH_NAME CACHE STRING "Name of env var USD searches to find plugins") +# Build-related information, expected to be passed in by the parent build. +set(PEPTIDE_JENKINS_BUILD 0 CACHE STRING "Build number.") +set(PEPTIDE_GIT_COMMIT "Unknown Git commit" CACHE STRING "Build commit.") +set(PEPTIDE_GIT_BRANCH "Unknown Git branch" CACHE STRING "Build branch.") +set(PEPTIDE_PRODUCT_DATE "Unknown build date" CACHE STRING "Build date.") + #------------------------------------------------------------------------------ # internal flags to control build #------------------------------------------------------------------------------ diff --git a/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src b/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src index e89e532a25..98e6a2b77a 100644 --- a/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src +++ b/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src @@ -20,15 +20,10 @@ #include #include -// At time of writing Peptide build variables undefined. PPT, 3-Nov-2023. -// #define MAYAHYDRA_BUILD_NUMBER ${PEPTIDE_JENKINS_BUILD} -// #define MAYAHYDRA_GIT_COMMIT "${PEPTIDE_GIT_COMMIT}" -// #define MAYAHYDRA_GIT_BRANCH "${PEPTIDE_GIT_BRANCH}" -// #define MAYAHYDRA_BUILD_DATE "${PEPTIDE_PRODUCT_DATE}" -#define MAYAHYDRA_BUILD_NUMBER 0 -#define MAYAHYDRA_GIT_COMMIT "aGitCommit" -#define MAYAHYDRA_GIT_BRANCH "aGitBranch" -#define MAYAHYDRA_BUILD_DATE "aProductDate" +#define MAYAHYDRA_BUILD_NUMBER ${PEPTIDE_JENKINS_BUILD} +#define MAYAHYDRA_GIT_COMMIT "${PEPTIDE_GIT_COMMIT}" +#define MAYAHYDRA_GIT_BRANCH "${PEPTIDE_GIT_BRANCH}" +#define MAYAHYDRA_BUILD_DATE "${PEPTIDE_PRODUCT_DATE}" namespace MAYAHYDRA_NS_DEF { From 71579907e9c6cf420b66be91cdb03718e1124034 Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Mon, 13 Nov 2023 14:30:43 -0500 Subject: [PATCH 5/7] Implement build date support. --- cmake/utils.cmake | 23 +++++++++++++++++++ .../hydraExtensions/mhBuildInfo.h.src | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index bb129c41c4..d5bc1bc57e 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -309,3 +309,26 @@ endfunction(get_external_project_default_values) # Create one for all the project using the default list separator get_external_project_default_values(MAYAUSD_EXTERNAL_PROJECT_GENERAL_SETTINGS "$") + +# +# Adapted from peptide_compute_timestamps() +# +function(mayaHydra_compute_timestamp) + # The date is formated the same way Maya formats its date. + # weekdday month/day/fullyear, CONCAT(fullyear + month + day + fullhour + minute) + string(TIMESTAMP WEEKDAY "%w") + set(MH_WEEK_DAYS "Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat") + list(GET MH_WEEK_DAYS ${WEEKDAY} WEEKDAY) + string(TIMESTAMP PRODUCT_DATE "\"${WEEKDAY} %m/%d/%Y, %Y%m%d%H%M\"") + + set(MH_PRODUCT_DATE "${PRODUCT_DATE}" CACHE STRING "Product Date") + + # For non-Jenkins builds (i.e. developers), don't reset the timestamps + # unless a clean build is made. This is annoying as it causes all the + # version file to be regenerated and thus all libraries and executable to + # be relinked. Else, do force a new timestamp!!! + if (NOT PEPTIDE_JENKINS_BUILD EQUAL 0) + set(MH_PRODUCT_DATE "${PRODUCT_DATE}" CACHE STRING "Product Date" FORCE) + endif() +endfunction(mayaHydra_compute_timestamp) +mayaHydra_compute_timestamp() diff --git a/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src b/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src index 98e6a2b77a..0b21492d22 100644 --- a/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src +++ b/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src @@ -23,7 +23,7 @@ #define MAYAHYDRA_BUILD_NUMBER ${PEPTIDE_JENKINS_BUILD} #define MAYAHYDRA_GIT_COMMIT "${PEPTIDE_GIT_COMMIT}" #define MAYAHYDRA_GIT_BRANCH "${PEPTIDE_GIT_BRANCH}" -#define MAYAHYDRA_BUILD_DATE "${PEPTIDE_PRODUCT_DATE}" +#define MAYAHYDRA_BUILD_DATE ${MH_PRODUCT_DATE} namespace MAYAHYDRA_NS_DEF { From fb4e8c479ff109202f5a1e54c747416657511336 Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Tue, 14 Nov 2023 15:46:01 -0500 Subject: [PATCH 6/7] Addressed code review comments. --- CMakeLists.txt | 7 +++---- cmake/utils.cmake | 16 ++++++++-------- lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src | 8 ++++---- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22d330458f..87543e57b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,10 +34,9 @@ set(PXR_OVERRIDE_PLUGINPATH_NAME PXR_PLUGINPATH_NAME CACHE STRING "Name of env var USD searches to find plugins") # Build-related information, expected to be passed in by the parent build. -set(PEPTIDE_JENKINS_BUILD 0 CACHE STRING "Build number.") -set(PEPTIDE_GIT_COMMIT "Unknown Git commit" CACHE STRING "Build commit.") -set(PEPTIDE_GIT_BRANCH "Unknown Git branch" CACHE STRING "Build branch.") -set(PEPTIDE_PRODUCT_DATE "Unknown build date" CACHE STRING "Build date.") +set(MAYAHYDRA_BUILD_NUMBER 0 CACHE STRING "Build number.") +set(MAYAHYDRA_GIT_COMMIT "Unknown_Git_commit" CACHE STRING "Build commit.") +set(MAYAHYDRA_GIT_BRANCH "Unknown_Git_branch" CACHE STRING "Build branch.") #------------------------------------------------------------------------------ # internal flags to control build diff --git a/cmake/utils.cmake b/cmake/utils.cmake index d5bc1bc57e..1c106386ac 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -319,16 +319,16 @@ function(mayaHydra_compute_timestamp) string(TIMESTAMP WEEKDAY "%w") set(MH_WEEK_DAYS "Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat") list(GET MH_WEEK_DAYS ${WEEKDAY} WEEKDAY) - string(TIMESTAMP PRODUCT_DATE "\"${WEEKDAY} %m/%d/%Y, %Y%m%d%H%M\"") + string(TIMESTAMP BUILD_DATE "\"${WEEKDAY} %m/%d/%Y, %Y%m%d%H%M\"") - set(MH_PRODUCT_DATE "${PRODUCT_DATE}" CACHE STRING "Product Date") + set(MAYAHYDRA_BUILD_DATE "${BUILD_DATE}" CACHE STRING "Build Date") - # For non-Jenkins builds (i.e. developers), don't reset the timestamps - # unless a clean build is made. This is annoying as it causes all the - # version file to be regenerated and thus all libraries and executable to - # be relinked. Else, do force a new timestamp!!! - if (NOT PEPTIDE_JENKINS_BUILD EQUAL 0) - set(MH_PRODUCT_DATE "${PRODUCT_DATE}" CACHE STRING "Product Date" FORCE) + # For build pipeline builds, force a new timestamp. For developer builds, + # resetting the timestamps is annoying as it causes all the version file to + # be regenerated and thus all libraries and executable to be relinked. + # Therefore, don't reset the timestamps unless a clean build is made. + if (NOT MAYAHYDRA_BUILD_NUMBER EQUAL 0) + set(MAYAHYDRA_BUILD_DATE "${BUILD_DATE}" CACHE STRING "Build Date" FORCE) endif() endfunction(mayaHydra_compute_timestamp) mayaHydra_compute_timestamp() diff --git a/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src b/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src index 0b21492d22..d6c9eb152f 100644 --- a/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src +++ b/lib/mayaHydra/hydraExtensions/mhBuildInfo.h.src @@ -20,10 +20,10 @@ #include #include -#define MAYAHYDRA_BUILD_NUMBER ${PEPTIDE_JENKINS_BUILD} -#define MAYAHYDRA_GIT_COMMIT "${PEPTIDE_GIT_COMMIT}" -#define MAYAHYDRA_GIT_BRANCH "${PEPTIDE_GIT_BRANCH}" -#define MAYAHYDRA_BUILD_DATE ${MH_PRODUCT_DATE} +#define MAYAHYDRA_BUILD_NUMBER ${MAYAHYDRA_BUILD_NUMBER} +#define MAYAHYDRA_GIT_COMMIT "${MAYAHYDRA_GIT_COMMIT}" +#define MAYAHYDRA_GIT_BRANCH "${MAYAHYDRA_GIT_BRANCH}" +#define MAYAHYDRA_BUILD_DATE ${MAYAHYDRA_BUILD_DATE} namespace MAYAHYDRA_NS_DEF { From c9a6f954aa321048c123e98cf37b1f8b177793d9 Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Tue, 14 Nov 2023 15:52:51 -0500 Subject: [PATCH 7/7] Removed obsolete MAYAHYDRA_CUT_ID support. --- CMakeLists.txt | 3 --- lib/mayaHydra/hydraExtensions/CMakeLists.txt | 6 ------ lib/mayaHydra/mayaPlugin/CMakeLists.txt | 6 ------ 3 files changed, 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87543e57b0..1b71eaf7fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,9 +86,6 @@ endif() include(cmake/mayahydra_version.info) set(MAYAHYDRA_VERSION "${MAYAHYDRA_MAJOR_VERSION}.${MAYAHYDRA_MINOR_VERSION}.${MAYAHYDRA_PATCH_LEVEL}") -if(DEFINED ENV{PLUGIN_CUT_ID}) - set(MAYAHYDRA_CUT_ID $ENV{PLUGIN_CUT_ID}) -endif() include(cmake/flowViewport_version.info) set(FLOWVIEWPORT_VERSION "${FLOWVIEWPORT_MAJOR_VERSION}.${FLOWVIEWPORT_MINOR_VERSION}.${FLOWVIEWPORT_PATCH_LEVEL}") diff --git a/lib/mayaHydra/hydraExtensions/CMakeLists.txt b/lib/mayaHydra/hydraExtensions/CMakeLists.txt index 2417b114cf..4b23d883ca 100644 --- a/lib/mayaHydra/hydraExtensions/CMakeLists.txt +++ b/lib/mayaHydra/hydraExtensions/CMakeLists.txt @@ -90,12 +90,6 @@ if(DEFINED MAYAHYDRA_VERSION) MAYAHYDRA_VERSION=${MAYAHYDRA_VERSION} ) endif() -if(DEFINED MAYAHYDRA_CUT_ID) - target_compile_definitions(${TARGET_NAME} - PRIVATE - MAYAHYDRA_CUT_ID=${MAYAHYDRA_CUT_ID} - ) -endif() # ----------------------------------------------------------------------------- # link libraries diff --git a/lib/mayaHydra/mayaPlugin/CMakeLists.txt b/lib/mayaHydra/mayaPlugin/CMakeLists.txt index 598192b3da..d06d73e95b 100644 --- a/lib/mayaHydra/mayaPlugin/CMakeLists.txt +++ b/lib/mayaHydra/mayaPlugin/CMakeLists.txt @@ -61,12 +61,6 @@ if(DEFINED MAYAHYDRA_VERSION) MAYAHYDRA_VERSION=${MAYAHYDRA_VERSION} ) endif() -if(DEFINED MAYAHYDRA_CUT_ID) - target_compile_definitions(${TARGET_NAME} - PRIVATE - MAYAHYDRA_CUT_ID=${MAYAHYDRA_CUT_ID} - ) -endif() mayaHydra_compile_config(${TARGET_NAME})