function [status, mesg] = clang_tools_validator(tool)
% CLANG_TOOLS_VALIDATOR Private validator for Clang. Uses xcrun -f to find
% the path of the tool specified.

% Copyright 2012-2020 The MathWorks, Inc.

command = getCommand(tool);
findCommand = strrep(command, 'xcrun', 'xcrun -f');
buildLogger = [];
[status, filepath] = coder.make.internal.system(findCommand, buildLogger);
if (status == 0)
    filepath = strtrim(filepath);
    status = exist(filepath,'file') == 2;
else
    status = false;
end

toolName = getName(tool);
if (status)
    m = message('coder_compile:toolchain:LocatedBuildTool', toolName, command);
    mesg = m.getString();
else
    m = message('coder_compile:toolchain:MissingBuildTool', toolName, command);
    mesg = m.getString();
end

% LocalWords:  xcrun toolchain
