function buildInfoCopy = cloneBuildInfo(buildInfoIn)
%cloneBuildInfo makes a deep copy of buildInfo
%   TODO(g2115755: replace this function with buildInfo copy method)
    
%   Copyright 2007-2019 The MathWorks, Inc.

    % Serialize the buildInfo to be cloned
    tempMATFile = [tempname '.mat'];
    deleteTempMATFile = onCleanup(@() delete(tempMATFile));
    save(tempMATFile, 'buildInfoIn');
    
    % reload
    contents = load(tempMATFile);
    buildInfoCopy = contents.buildInfoIn;
    
    % delete temporary mat file
    deleteTempMATFile.delete();
