Files
VisualSapfor/src/_VisualDVM/Passes/All/GCOV.java
2024-10-14 12:54:52 +03:00

145 lines
5.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package _VisualDVM.Passes.All;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.LanguageName;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.LinkedHashMap;
public class GCOV extends Precompilation {
protected File getBinary() {
return new File(workspace, getBinaryName());
}
protected String getBinaryName() {
return Utils_.isWindows() ? "0.exe" : "0";
}
@Override
public boolean needsConfirmations() {
return false;
}
@Override
public String getIconPath() {
return "/icons/GCOV.PNG";
}
@Override
public boolean hasStats() {
return true;
}
@Override
protected String getLinkFlags() {
return "-O2 -g -fprofile-arcs -ftest-coverage";
}
@Override
protected String getFortranFlags() {
return "-O2 -g -fprofile-arcs -ftest-coverage";
}
@Override
protected void prepareForParse() throws Exception {
//-- тут анализы чистить не надо.
}
@Override
protected void performPreparation() throws Exception {
super.performPreparation();
target.ClearGCOV();
}
@Override
protected void showPreparation() throws Exception {
//super.showPreparation(); тут не надо отображать пустые анализы.
if (Global.mainModule.HasFile()) {
Global.mainModule.getFile().form.ShowNoRunOutput();
Global.mainModule.getFile().form.ShowNoGCOVLog();
}
}
@Override
protected String genMakefileText(LinkedHashMap<LanguageName, Module> modules) throws Exception {
return makefile.Generate(target, false, modules);
}
@Override
protected void body() throws Exception {
ShowMessage1("Сборка для GCOV");
super.body();
super.performFinish(); //тут только обработка вывода.
if (getBinary().exists()) {
ShowMessage1("Запуск для GCOV");
name_to_kill = "0.exe";
StartProcess(Utils_.isWindows()?"0.exe":"./0", target.run_maxtime);
target.updateRunOut(output);
} else {
Log.Writeln_("Не удалось собрать проект.");
return;
}
ShowMessage1("Получение тестовых покрытий для файлов..");
for (DBProjectFile file : target.getPrograms().get(LanguageName.fortran)) {
ShowMessage2(file.name);
String uname = file.last_assembly_name.substring(0, file.last_assembly_name.length() - 2);
String gcno = uname + ".gcno";
File gcov = Paths.get(workspace.getAbsolutePath(), file.file.getName() + ".gcov").toFile();
Utils_.forceDeleteWithCheck(gcov);
name_to_kill = "gcov.exe";
StartProcess("gcov -b " +
Utils_.DQuotes(
Paths.get(workspace.getAbsolutePath(), uname))
+ " -o " +
Utils_.DQuotes(
Paths.get(workspace.getAbsolutePath(), gcno)
), 40);
if (gcov.exists()) {
file.GCOVLog = output;
target.db.Update(file);
File targetGcov = Paths.get(
target.getGCOVDirectory().getAbsolutePath(),
(Utils_.isWindows()?file.name:file.getUnixName()) + ".gcov").toFile();
Files.copy(gcov.toPath(), targetGcov.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
}
}
@Override
protected boolean validate() {
return Log.isEmpty();
}
@Override
protected void performFinish() throws Exception {
}
@Override
protected void showDone() throws Exception {
super.showDone();
if (Global.mainModule.HasFile()) {
Global.mainModule.getFile().form.ShowRunOutput();
Global.mainModule.getFile().form.ShowGCOVLog();
}
}
@Override
protected void showFail() throws Exception {
super.showFail();
if (Global.mainModule.HasFile())
Global.mainModule.getFile().form.FocusCompilationOut();
}
@Override
protected void performDone() throws Exception {
// target.updateGCOV_status(1);
}
@Override
protected void FocusResult() {
if (Global.mainModule.HasFile())
Global.mainModule.getFile().form.FocusGCOVLog();
}
/*
@Override
protected boolean canStart(Object... args) throws Exception {
if (super.canStart(args)){
if (passes.get(PassCode_2021.SPF_GetArrayDistribution).isDone()){
Log.Writeln_("Не разрешено при выполненном анализе кода/построенном распределении данных.Сбросьте актуальность анализов.");
return false;
}
else return true;
};
return false;
}
*/
}