function name = formToolchainName(toolchain, platform, version, artifact)
%formToolchainName Formulate the complete toolchain name.

% Copyright 2012 The MathWorks, Inc.

platformDesc = getComputerDescription(platform);

if ~isempty(version)
    version = ['v' version];
else
    version = ''; % in case the user did not specify a version
end

% Old name format: name = [desc.bit ' ' toolchain ' ' version ' (' artifact ')'];

name = [toolchain ' ' version ' | ' artifact ' (' platformDesc.arch ')'];

function desc = getComputerDescription(platform)

switch lower(platform)
    case {'win32', 'pcwin'}
        desc.bit       = '32-bit';
        desc.arch      = [desc.bit ' Windows'];
        desc.technical = 'Microsoft Windows on x86';
    case {'win64', 'pcwin64'}
        desc.bit       = '64-bit';
        desc.arch      = [desc.bit ' Windows'];
        desc.technical = 'Microsoft Windows on x64';
    case {'glnx86'}
        desc.bit       = '32-bit';
        desc.arch      = [desc.bit ' Linux'];
        desc.technical = 'Linux on x86';
    case {'glnxa64'}
        desc.bit       = '64-bit';
        desc.arch      = [desc.bit ' Linux'];
        desc.technical = 'Linux on x86_64';
    case {'maci64'}
        desc.bit       = '64-bit';
        desc.arch      = [desc.bit ' Mac'];
        desc.technical = 'Apple Mac OS X on x86_64';
end
