-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report build and version information from the mayaHydra plugin #10
Merged
roopavr-adsk
merged 7 commits into
dev
from
tremblp/HYDRA-491/report_peptide_info_github
Nov 16, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d12d9d8
Working version and build information reporting.
ppt-adsk b8414a9
Moved code to MayaHydra namespace.
ppt-adsk 4da97cc
Added unit test for version and build info.
ppt-adsk a448c24
Read build information from CMake.
ppt-adsk 7157990
Implement build date support.
ppt-adsk fb4e8c4
Addressed code review comments.
ppt-adsk c9a6f95
Removed obsolete MAYAHYDRA_CUT_ID support.
ppt-adsk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// 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 <mayaHydraLib/mhBuildInfo.h> | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// 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 <mayaHydraLib/api.h> | ||
#include <mayaHydraLib/mayaHydra.h> | ||
|
||
#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 { | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,20 +47,16 @@ | |
#error Maya API version 2024+ required | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed namespacing. |
||
#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<MtohRenderOverride*> gsRenderOverrides; | ||
static std::vector<PXR_NS::MtohRenderOverride*> 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<MtohRenderOverride>(desc); | ||
auto mtohRenderer = std::make_unique<PXR_NS::MtohRenderOverride>(desc); | ||
MStatus status = renderer->registerOverride(mtohRenderer.get()); | ||
if (status == MS::kSuccess) { | ||
gsRenderOverrides.push_back(mtohRenderer.release()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|
@@ -20,27 +21,16 @@ | |
#include "renderOverride.h" | ||
|
||
#include <mayaHydraLib/delegates/delegateRegistry.h> | ||
#include <mayaHydraLib/mhBuildInfo.h> | ||
#include <mayaHydraLib/mayaHydra.h> | ||
|
||
#include <maya/MArgDatabase.h> | ||
#include <maya/MGlobal.h> | ||
#include <maya/MSyntax.h> | ||
|
||
#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 | ||
// 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"); | ||
|
||
|
@@ -79,10 +69,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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Core file in the review: add flags to the mayaHydra command to get version and build information. |
||
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 +162,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,15 +285,22 @@ 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; | ||
} | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configure the build information file so that it gets build and version information.