Files
VisualSapfor/src/_VisualDVM/Passes/All/GCOV.java

146 lines
5.2 KiB
Java
Raw Normal View History

2024-10-14 12:14:01 +03:00
package _VisualDVM.Passes.All;
2024-10-11 00:00:30 +03:00
import Common.Utils.Utils_;
import _VisualDVM.Global;
2024-10-09 22:01:19 +03:00
import _VisualDVM.Utils;
2024-10-09 22:21:57 +03:00
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.LanguageName;
2023-09-17 22:13:42 +03:00
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() {
2024-10-11 00:00:30 +03:00
return Utils_.isWindows() ? "0.exe" : "0";
2023-09-17 22:13:42 +03:00
}
@Override
public boolean needsConfirmations() {
return false;
}
@Override
public String getIconPath() {
return "/icons/GCOV.PNG";
}
@Override
public boolean hasStats() {
2023-09-17 22:13:42 +03:00
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();
2023-09-17 22:13:42 +03:00
}
}
@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";
2024-10-11 00:00:30 +03:00
StartProcess(Utils_.isWindows()?"0.exe":"./0", target.run_maxtime);
2023-09-17 22:13:42 +03:00
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 " +
2024-10-11 00:00:30 +03:00
Utils_.DQuotes(
2023-09-17 22:13:42 +03:00
Paths.get(workspace.getAbsolutePath(), uname))
+ " -o " +
2024-10-11 00:00:30 +03:00
Utils_.DQuotes(
2023-09-17 22:13:42 +03:00
Paths.get(workspace.getAbsolutePath(), gcno)
), 40);
if (gcov.exists()) {
file.GCOVLog = output;
target.db.Update(file);
File targetGcov = Paths.get(
target.getGCOVDirectory().getAbsolutePath(),
2024-10-11 00:00:30 +03:00
(Utils_.isWindows()?file.name:file.getUnixName()) + ".gcov").toFile();
2023-09-17 22:13:42 +03:00
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();
2023-09-17 22:13:42 +03:00
}
}
@Override
protected void showFail() throws Exception {
super.showFail();
if (Global.mainModule.HasFile())
Global.mainModule.getFile().form.FocusCompilationOut();
2023-09-17 22:13:42 +03:00
}
@Override
protected void performDone() throws Exception {
// target.updateGCOV_status(1);
}
@Override
protected void FocusResult() {
if (Global.mainModule.HasFile())
Global.mainModule.getFile().form.FocusGCOVLog();
2023-09-17 22:13:42 +03:00
}
/*
@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;
}
*/
}