Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ACT/LibMCEnv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2602,6 +2602,14 @@
<param name="BuildUUID" type="string" pass="return" description="UUID of the build." />
</method>

<method name="GetCreatedTimestamp" description="Returns creation timestamp of the build in ISO-8601 format.">
<param name="Timestamp" type="string" pass="return" description="Creation timestamp in ISO-8601 format (e.g., 2025-10-23T14:30:00.000Z)." />
</method>

<method name="GetLastExecutionTimestamp" description="Returns the most recent execution timestamp in ISO-8601 format. Returns empty string if build has never been executed.">
<param name="Timestamp" type="string" pass="return" description="Most recent execution timestamp in ISO-8601 format. Empty string if never executed." />
</method>

<method name="GetStorageUUID" description="Returns storage uuid of the build stream.">
<param name="StorageUUID" type="string" pass="return" description="Storage UUID of the build." />
</method>
Expand Down
24 changes: 24 additions & 0 deletions Framework/HeadersDev/CppDynamic/libmcenv_dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -4260,6 +4260,28 @@ typedef LibMCEnvResult (*PLibMCEnvBuild_GetNamePtr) (LibMCEnv_Build pBuild, cons
*/
typedef LibMCEnvResult (*PLibMCEnvBuild_GetBuildUUIDPtr) (LibMCEnv_Build pBuild, const LibMCEnv_uint32 nBuildUUIDBufferSize, LibMCEnv_uint32* pBuildUUIDNeededChars, char * pBuildUUIDBuffer);

/**
* Returns creation timestamp of the build in ISO-8601 format.
*
* @param[in] pBuild - Build instance.
* @param[in] nTimestampBufferSize - size of the buffer (including trailing 0)
* @param[out] pTimestampNeededChars - will be filled with the count of the written bytes, or needed buffer size.
* @param[out] pTimestampBuffer - buffer of Creation timestamp in ISO-8601 format (e.g., 2025-10-23T14:30:00.000Z)., may be NULL
* @return error code or 0 (success)
*/
typedef LibMCEnvResult (*PLibMCEnvBuild_GetCreatedTimestampPtr) (LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer);

/**
* Returns the most recent execution timestamp in ISO-8601 format. Returns empty string if build has never been executed.
*
* @param[in] pBuild - Build instance.
* @param[in] nTimestampBufferSize - size of the buffer (including trailing 0)
* @param[out] pTimestampNeededChars - will be filled with the count of the written bytes, or needed buffer size.
* @param[out] pTimestampBuffer - buffer of Most recent execution timestamp in ISO-8601 format. Empty string if never executed., may be NULL
* @return error code or 0 (success)
*/
typedef LibMCEnvResult (*PLibMCEnvBuild_GetLastExecutionTimestampPtr) (LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer);

/**
* Returns storage uuid of the build stream.
*
Expand Down Expand Up @@ -11406,6 +11428,8 @@ typedef struct {
PLibMCEnvBuildExecutionIterator_GetCurrentExecutionPtr m_BuildExecutionIterator_GetCurrentExecution;
PLibMCEnvBuild_GetNamePtr m_Build_GetName;
PLibMCEnvBuild_GetBuildUUIDPtr m_Build_GetBuildUUID;
PLibMCEnvBuild_GetCreatedTimestampPtr m_Build_GetCreatedTimestamp;
PLibMCEnvBuild_GetLastExecutionTimestampPtr m_Build_GetLastExecutionTimestamp;
PLibMCEnvBuild_GetStorageUUIDPtr m_Build_GetStorageUUID;
PLibMCEnvBuild_GetStorageSHA256Ptr m_Build_GetStorageSHA256;
PLibMCEnvBuild_EnsureStorageSHA256IsValidPtr m_Build_EnsureStorageSHA256IsValid;
Expand Down
60 changes: 60 additions & 0 deletions Framework/HeadersDev/CppDynamic/libmcenv_dynamic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2248,6 +2248,8 @@ class CBuild : public CBase {

inline std::string GetName();
inline std::string GetBuildUUID();
inline std::string GetCreatedTimestamp();
inline std::string GetLastExecutionTimestamp();
inline std::string GetStorageUUID();
inline std::string GetStorageSHA256();
inline void EnsureStorageSHA256IsValid();
Expand Down Expand Up @@ -4023,6 +4025,8 @@ class CUIEnvironment : public CBase {
pWrapperTable->m_BuildExecutionIterator_GetCurrentExecution = nullptr;
pWrapperTable->m_Build_GetName = nullptr;
pWrapperTable->m_Build_GetBuildUUID = nullptr;
pWrapperTable->m_Build_GetCreatedTimestamp = nullptr;
pWrapperTable->m_Build_GetLastExecutionTimestamp = nullptr;
pWrapperTable->m_Build_GetStorageUUID = nullptr;
pWrapperTable->m_Build_GetStorageSHA256 = nullptr;
pWrapperTable->m_Build_EnsureStorageSHA256IsValid = nullptr;
Expand Down Expand Up @@ -8250,6 +8254,24 @@ class CUIEnvironment : public CBase {
if (pWrapperTable->m_Build_GetBuildUUID == nullptr)
return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT;

#ifdef _WIN32
pWrapperTable->m_Build_GetCreatedTimestamp = (PLibMCEnvBuild_GetCreatedTimestampPtr) GetProcAddress(hLibrary, "libmcenv_build_getcreatedtimestamp");
#else // _WIN32
pWrapperTable->m_Build_GetCreatedTimestamp = (PLibMCEnvBuild_GetCreatedTimestampPtr) dlsym(hLibrary, "libmcenv_build_getcreatedtimestamp");
dlerror();
#endif // _WIN32
if (pWrapperTable->m_Build_GetCreatedTimestamp == nullptr)
return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT;

#ifdef _WIN32
pWrapperTable->m_Build_GetLastExecutionTimestamp = (PLibMCEnvBuild_GetLastExecutionTimestampPtr) GetProcAddress(hLibrary, "libmcenv_build_getlastexecutiontimestamp");
#else // _WIN32
pWrapperTable->m_Build_GetLastExecutionTimestamp = (PLibMCEnvBuild_GetLastExecutionTimestampPtr) dlsym(hLibrary, "libmcenv_build_getlastexecutiontimestamp");
dlerror();
#endif // _WIN32
if (pWrapperTable->m_Build_GetLastExecutionTimestamp == nullptr)
return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT;

#ifdef _WIN32
pWrapperTable->m_Build_GetStorageUUID = (PLibMCEnvBuild_GetStorageUUIDPtr) GetProcAddress(hLibrary, "libmcenv_build_getstorageuuid");
#else // _WIN32
Expand Down Expand Up @@ -15521,6 +15543,14 @@ class CUIEnvironment : public CBase {
if ( (eLookupError != 0) || (pWrapperTable->m_Build_GetBuildUUID == nullptr) )
return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT;

eLookupError = (*pLookup)("libmcenv_build_getcreatedtimestamp", (void**)&(pWrapperTable->m_Build_GetCreatedTimestamp));
if ( (eLookupError != 0) || (pWrapperTable->m_Build_GetCreatedTimestamp == nullptr) )
return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT;

eLookupError = (*pLookup)("libmcenv_build_getlastexecutiontimestamp", (void**)&(pWrapperTable->m_Build_GetLastExecutionTimestamp));
if ( (eLookupError != 0) || (pWrapperTable->m_Build_GetLastExecutionTimestamp == nullptr) )
return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT;

eLookupError = (*pLookup)("libmcenv_build_getstorageuuid", (void**)&(pWrapperTable->m_Build_GetStorageUUID));
if ( (eLookupError != 0) || (pWrapperTable->m_Build_GetStorageUUID == nullptr) )
return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT;
Expand Down Expand Up @@ -23347,6 +23377,36 @@ class CUIEnvironment : public CBase {
return std::string(&bufferBuildUUID[0]);
}

/**
* CBuild::GetCreatedTimestamp - Returns creation timestamp of the build in ISO-8601 format.
* @return Creation timestamp in ISO-8601 format (e.g., 2025-10-23T14:30:00.000Z).
*/
std::string CBuild::GetCreatedTimestamp()
{
LibMCEnv_uint32 bytesNeededTimestamp = 0;
LibMCEnv_uint32 bytesWrittenTimestamp = 0;
CheckError(m_pWrapper->m_WrapperTable.m_Build_GetCreatedTimestamp(m_pHandle, 0, &bytesNeededTimestamp, nullptr));
std::vector<char> bufferTimestamp(bytesNeededTimestamp);
CheckError(m_pWrapper->m_WrapperTable.m_Build_GetCreatedTimestamp(m_pHandle, bytesNeededTimestamp, &bytesWrittenTimestamp, &bufferTimestamp[0]));

return std::string(&bufferTimestamp[0]);
}

/**
* CBuild::GetLastExecutionTimestamp - Returns the most recent execution timestamp in ISO-8601 format. Returns empty string if build has never been executed.
* @return Most recent execution timestamp in ISO-8601 format. Empty string if never executed.
*/
std::string CBuild::GetLastExecutionTimestamp()
{
LibMCEnv_uint32 bytesNeededTimestamp = 0;
LibMCEnv_uint32 bytesWrittenTimestamp = 0;
CheckError(m_pWrapper->m_WrapperTable.m_Build_GetLastExecutionTimestamp(m_pHandle, 0, &bytesNeededTimestamp, nullptr));
std::vector<char> bufferTimestamp(bytesNeededTimestamp);
CheckError(m_pWrapper->m_WrapperTable.m_Build_GetLastExecutionTimestamp(m_pHandle, bytesNeededTimestamp, &bytesWrittenTimestamp, &bufferTimestamp[0]));

return std::string(&bufferTimestamp[0]);
}

/**
* CBuild::GetStorageUUID - Returns storage uuid of the build stream.
* @return Storage UUID of the build.
Expand Down
45 changes: 45 additions & 0 deletions Framework/InterfacesCore/libmcenv_abi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4247,6 +4247,19 @@ LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_buildexecution_loadattachedjournal(Lib
*/
LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_buildexecutioniterator_getcurrentexecution(LibMCEnv_BuildExecutionIterator pBuildExecutionIterator, LibMCEnv_BuildExecution * pBuildExecutionInstance);

/*************************************************************************************************************************
Class definition for BuildIterator
**************************************************************************************************************************/

/**
* Returns the build the iterator points at.
*
* @param[in] pBuildIterator - BuildIterator instance.
* @param[out] pBuildInstance - returns the Build instance.
* @return error code or 0 (success)
*/
LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_builditerator_getcurrentbuild(LibMCEnv_BuildIterator pBuildIterator, LibMCEnv_Build * pBuildInstance);

/*************************************************************************************************************************
Class definition for Build
**************************************************************************************************************************/
Expand All @@ -4273,6 +4286,28 @@ LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_build_getname(LibMCEnv_Build pBuild, c
*/
LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_build_getbuilduuid(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nBuildUUIDBufferSize, LibMCEnv_uint32* pBuildUUIDNeededChars, char * pBuildUUIDBuffer);

/**
* Returns creation timestamp of the build in ISO-8601 format.
*
* @param[in] pBuild - Build instance.
* @param[in] nTimestampBufferSize - size of the buffer (including trailing 0)
* @param[out] pTimestampNeededChars - will be filled with the count of the written bytes, or needed buffer size.
* @param[out] pTimestampBuffer - buffer of Creation timestamp in ISO-8601 format (e.g., 2025-10-23T14:30:00.000Z)., may be NULL
* @return error code or 0 (success)
*/
LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_build_getcreatedtimestamp(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer);

/**
* Returns the most recent execution timestamp in ISO-8601 format. Returns empty string if build has never been executed.
*
* @param[in] pBuild - Build instance.
* @param[in] nTimestampBufferSize - size of the buffer (including trailing 0)
* @param[out] pTimestampNeededChars - will be filled with the count of the written bytes, or needed buffer size.
* @param[out] pTimestampBuffer - buffer of Most recent execution timestamp in ISO-8601 format. Empty string if never executed., may be NULL
* @return error code or 0 (success)
*/
LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_build_getlastexecutiontimestamp(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer);

/**
* Returns storage uuid of the build stream.
*
Expand Down Expand Up @@ -10600,6 +10635,16 @@ LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_hasbuildexecution(LibMCE
*/
LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_getbuildexecution(LibMCEnv_UIEnvironment pUIEnvironment, const char * pExecutionUUID, LibMCEnv_BuildExecution * pExecutionInstance);

/**
* Returns an iterator for recent build jobs, ordered by timestamp (newest first).
*
* @param[in] pUIEnvironment - UIEnvironment instance.
* @param[in] nMaxCount - Maximum number of jobs to return. Must be greater than 0.
* @param[out] pBuildIterator - Iterator for build jobs, ordered newest first.
* @return error code or 0 (success)
*/
LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_getrecentbuildjobs(LibMCEnv_UIEnvironment pUIEnvironment, LibMCEnv_uint32 nMaxCount, LibMCEnv_BuildIterator * pBuildIterator);

/**
* Creates an empty discrete field.
*
Expand Down
12 changes: 12 additions & 0 deletions Framework/InterfacesCore/libmcenv_interfaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3535,6 +3535,18 @@ class IBuild : public virtual IBase {
*/
virtual std::string GetBuildUUID() = 0;

/**
* IBuild::GetCreatedTimestamp - Returns creation timestamp of the build in ISO-8601 format.
* @return Creation timestamp in ISO-8601 format (e.g., 2025-10-23T14:30:00.000Z).
*/
virtual std::string GetCreatedTimestamp() = 0;

/**
* IBuild::GetLastExecutionTimestamp - Returns the most recent execution timestamp in ISO-8601 format. Returns empty string if build has never been executed.
* @return Most recent execution timestamp in ISO-8601 format. Empty string if never executed.
*/
virtual std::string GetLastExecutionTimestamp() = 0;

/**
* IBuild::GetStorageUUID - Returns storage uuid of the build stream.
* @return Storage UUID of the build.
Expand Down
100 changes: 100 additions & 0 deletions Framework/InterfacesCore/libmcenv_interfacewrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12286,6 +12286,102 @@ LibMCEnvResult libmcenv_build_getbuilduuid(LibMCEnv_Build pBuild, const LibMCEnv
}
}

LibMCEnvResult libmcenv_build_getcreatedtimestamp(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer)
{
IBase* pIBaseClass = (IBase *)pBuild;

try {
if ( (!pTimestampBuffer) && !(pTimestampNeededChars) )
throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_INVALIDPARAM);
std::string sTimestamp("");
IBuild* pIBuild = dynamic_cast<IBuild*>(pIBaseClass);
if (!pIBuild)
throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST);

bool isCacheCall = (pTimestampBuffer == nullptr);
if (isCacheCall) {
sTimestamp = pIBuild->GetCreatedTimestamp();

pIBuild->_setCache (new ParameterCache_1<std::string> (sTimestamp));
}
else {
auto cache = dynamic_cast<ParameterCache_1<std::string>*> (pIBuild->_getCache ());
if (cache == nullptr)
throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST);
cache->retrieveData (sTimestamp);
pIBuild->_setCache (nullptr);
}

if (pTimestampNeededChars)
*pTimestampNeededChars = (LibMCEnv_uint32) (sTimestamp.size()+1);
if (pTimestampBuffer) {
if (sTimestamp.size() >= nTimestampBufferSize)
throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_BUFFERTOOSMALL);
for (size_t iTimestamp = 0; iTimestamp < sTimestamp.size(); iTimestamp++)
pTimestampBuffer[iTimestamp] = sTimestamp[iTimestamp];
pTimestampBuffer[sTimestamp.size()] = 0;
}
return LIBMCENV_SUCCESS;
}
catch (ELibMCEnvInterfaceException & Exception) {
return handleLibMCEnvException(pIBaseClass, Exception);
}
catch (std::exception & StdException) {
return handleStdException(pIBaseClass, StdException);
}
catch (...) {
return handleUnhandledException(pIBaseClass);
}
}

LibMCEnvResult libmcenv_build_getlastexecutiontimestamp(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer)
{
IBase* pIBaseClass = (IBase *)pBuild;

try {
if ( (!pTimestampBuffer) && !(pTimestampNeededChars) )
throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_INVALIDPARAM);
std::string sTimestamp("");
IBuild* pIBuild = dynamic_cast<IBuild*>(pIBaseClass);
if (!pIBuild)
throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST);

bool isCacheCall = (pTimestampBuffer == nullptr);
if (isCacheCall) {
sTimestamp = pIBuild->GetLastExecutionTimestamp();

pIBuild->_setCache (new ParameterCache_1<std::string> (sTimestamp));
}
else {
auto cache = dynamic_cast<ParameterCache_1<std::string>*> (pIBuild->_getCache ());
if (cache == nullptr)
throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST);
cache->retrieveData (sTimestamp);
pIBuild->_setCache (nullptr);
}

if (pTimestampNeededChars)
*pTimestampNeededChars = (LibMCEnv_uint32) (sTimestamp.size()+1);
if (pTimestampBuffer) {
if (sTimestamp.size() >= nTimestampBufferSize)
throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_BUFFERTOOSMALL);
for (size_t iTimestamp = 0; iTimestamp < sTimestamp.size(); iTimestamp++)
pTimestampBuffer[iTimestamp] = sTimestamp[iTimestamp];
pTimestampBuffer[sTimestamp.size()] = 0;
}
return LIBMCENV_SUCCESS;
}
catch (ELibMCEnvInterfaceException & Exception) {
return handleLibMCEnvException(pIBaseClass, Exception);
}
catch (std::exception & StdException) {
return handleStdException(pIBaseClass, StdException);
}
catch (...) {
return handleUnhandledException(pIBaseClass);
}
}

LibMCEnvResult libmcenv_build_getstorageuuid(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nStorageUUIDBufferSize, LibMCEnv_uint32* pStorageUUIDNeededChars, char * pStorageUUIDBuffer)
{
IBase* pIBaseClass = (IBase *)pBuild;
Expand Down Expand Up @@ -33871,6 +33967,10 @@ LibMCEnvResult LibMCEnv::Impl::LibMCEnv_GetProcAddress (const char * pProcName,
*ppProcAddress = (void*) &libmcenv_build_getname;
if (sProcName == "libmcenv_build_getbuilduuid")
*ppProcAddress = (void*) &libmcenv_build_getbuilduuid;
if (sProcName == "libmcenv_build_getcreatedtimestamp")
*ppProcAddress = (void*) &libmcenv_build_getcreatedtimestamp;
if (sProcName == "libmcenv_build_getlastexecutiontimestamp")
*ppProcAddress = (void*) &libmcenv_build_getlastexecutiontimestamp;
if (sProcName == "libmcenv_build_getstorageuuid")
*ppProcAddress = (void*) &libmcenv_build_getstorageuuid;
if (sProcName == "libmcenv_build_getstoragesha256")
Expand Down
33 changes: 33 additions & 0 deletions Implementation/LibMCEnv/libmcenv_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,39 @@ std::string CBuild::GetBuildUUID()
return pBuildJob->GetUUID();
}

std::string CBuild::GetCreatedTimestamp()
{
auto pBuildJobHandler = m_pDataModel->CreateBuildJobHandler();
auto pBuildJob = pBuildJobHandler->RetrieveJob(m_sBuildJobUUID);
return pBuildJob->GetTimeStamp();
}

std::string CBuild::GetLastExecutionTimestamp()
{
auto pBuildJobHandler = m_pDataModel->CreateBuildJobHandler();
auto pBuildJob = pBuildJobHandler->RetrieveJob(m_sBuildJobUUID);

// Find the latest execution timestamp
std::string sLatestExecutionTime = "";
uint64_t nLatestExecutionMicroseconds = 0;

auto pJobExecutionIterator = pBuildJob->RetrieveBuildJobExecutions("");
while (pJobExecutionIterator->MoveNext()) {
auto pJobExecution = pJobExecutionIterator->GetCurrentJobExecution();
uint64_t nExecutionTime = pJobExecution->GetStartTimeStampInMicroseconds();
if (nExecutionTime > nLatestExecutionMicroseconds) {
nLatestExecutionMicroseconds = nExecutionTime;
}
}

// Convert to ISO 8601 format if we found any executions
if (nLatestExecutionMicroseconds > 0) {
sLatestExecutionTime = AMCCommon::CChrono::convertToISO8601TimeUTC(nLatestExecutionMicroseconds);
}

return sLatestExecutionTime;
}

std::string CBuild::GetStorageUUID()
{
auto pBuildJobHandler = m_pDataModel->CreateBuildJobHandler();
Expand Down
4 changes: 4 additions & 0 deletions Implementation/LibMCEnv/libmcenv_build.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class CBuild : public virtual IBuild, public virtual CBase {

std::string GetBuildUUID() override;

std::string GetCreatedTimestamp() override;

std::string GetLastExecutionTimestamp() override;

std::string GetStorageUUID() override;

std::string GetStorageSHA256() override;
Expand Down
Loading