Skip to content

Commit

Permalink
fix: run kaitai-struct-compiler correctly in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
hello-adam committed Jun 11, 2020
1 parent 7575c09 commit 8b51480
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/hobbits-plugins/analyzers/KaitaiStruct/kaitaistruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,11 @@ QSharedPointer<const AnalyzerResult> KaitaiStruct::analyzeBits(

progressTracker->setProgressPercent(20);

#ifdef Q_OS_WIN
QStringList kscAgs = {"/C", kscPath, "--debug", "-t", "python", ksy.fileName()};
#else
QStringList kscAgs = {"--debug", "-t", "python", ksy.fileName()};
#endif
QProcess kscProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QProcessEnvironment envUpdate;
Expand All @@ -262,6 +266,11 @@ QSharedPointer<const AnalyzerResult> KaitaiStruct::analyzeBits(
kscProcess.setStandardErrorFile(errorFile.fileName());
kscProcess.setStandardOutputFile(stdoutFile.fileName());
kscProcess.start(kscPath, kscAgs);
#ifdef Q_OS_WIN
kscProcess.start("cmd.exe", kscAgs);
#else
kscProcess.start(kscPath, kscAgs);
#endif

kscProcess.waitForFinished();

Expand Down Expand Up @@ -346,6 +355,14 @@ QSharedPointer<const AnalyzerResult> KaitaiStruct::analyzeBits(
stdoutFile.close();
}

if (!outputRangeFile.exists()) {
QString errorString = "No analysis file was produced - check the Output tab to see if ksc or python produced any errors.";
errorString += "\n\nCommon problems to check for:";
errorString += "\n- Are you pointing to a valid Python 3 with the kaitaistruct package 0.9 installed?";
errorString += "\n- Are you pointing to a valid kaitai-struct-compiler version 0.9?";
return AnalyzerResult::error(errorString);
}

if (!outputRangeFile.open(QIODevice::ReadOnly)) {
return AnalyzerResult::error("Could not open analysis file for reading");
}
Expand Down

0 comments on commit 8b51480

Please sign in to comment.