Skip to content

Commit

Permalink
Merge pull request #79 from The-Chinese-Room/master
Browse files Browse the repository at this point in the history
updated Inkpot plugin
  • Loading branch information
TCR-Nick authored Mar 25, 2024
2 parents 4fe8d06 + f886785 commit a40f524
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace InkCompiler
TSharedPtr<IPlugin> inkpotPlugin = pluginManager.FindPlugin("Inkpot");
if(inkpotPlugin)
path = inkpotPlugin->GetBaseDir();
path = FPaths::ConvertRelativePathToFull( path );
return path;
}

Expand All @@ -38,31 +39,34 @@ namespace InkCompiler
{
// Check if inklecate exists
const FString inkExePath = GetInkleCatePath();
FString InkFilePathStripped = InkFilePath;
FPaths::CollapseRelativeDirectories(InkFilePathStripped);
if (!FPaths::FileExists(inkExePath))
{
INKPOT_ERROR("CompileInkFile_Internal - %s could not locate inklecate.exe.", *InkFilePathStripped);
INKPOT_ERROR("CompileInkFile_Internal - could not locate inklecate.exe." );
return false;
}

FString compiledJsonPath = GetScratchDirectory() + FPaths::GetCleanFilename(InkFilePathStripped) + TEXT(".json");;
// resolve file paths
FString sourceInkPath = InkFilePath;
FPaths::CollapseRelativeDirectories(sourceInkPath );
sourceInkPath = FPaths::ConvertRelativePathToFull( sourceInkPath );

FString compiledJsonPath = GetScratchDirectory() + FPaths::GetCleanFilename(sourceInkPath ) + TEXT(".json");
FPaths::CollapseRelativeDirectories(compiledJsonPath);

FString args = FString::Printf(TEXT("%s -j -o \"%s\" \"%s\""), shouldCountVisits?TEXT(" -c"):TEXT(" "), *compiledJsonPath, *InkFilePathStripped );
FString args = FString::Printf(TEXT("%s -j -o \"%s\" \"%s\""), shouldCountVisits?TEXT(" -c"):TEXT(" "), *compiledJsonPath, *sourceInkPath );

// Execute compile using inklecate and output compiled JSON to Intermediate/InkCommandline.
FString stdOut;
FString stdErr;
int32 returnCode;
FString wkDir = GetScratchDirectory();
FString baseDir = FString( FPlatformProcess::BaseDir() );

INKPOT_LOG("ExecProcess :\n\tcmd : %s\n\targ : %s\n\tcwd : %s", *inkExePath, *args, *wkDir );
INKPOT_LOG("ExecProcess :\n\tcmd : %s\n\targ : %s\n\tbsd : %s", *inkExePath, *args, *baseDir );

bool bSuccess = FPlatformProcess::ExecProcess(*inkExePath, *args, &returnCode, &stdOut, &stdErr, *wkDir, true );
bool bSuccess = FPlatformProcess::ExecProcess(*inkExePath, *args, &returnCode, &stdOut, &stdErr );
if (!bSuccess)
{
INKPOT_ERROR("CompileInkFile_Internal - %s failed ExecProcess. Error %s: ", *InkFilePathStripped, *(stdOut + stdErr));
INKPOT_ERROR("CompileInkFile_Internal - %s failed ExecProcess. Error %s: ", *sourceInkPath, *(stdOut + stdErr));
return false;
}

Expand All @@ -74,13 +78,13 @@ namespace InkCompiler
// supress warnings for tests that we expect to fail compilation
if(!bIsCompilationFailExpected)
{
INKPOT_ERROR( "CompileInkFile_Internal - %s failed to compile ink. Error %s: ", *InkFilePathStripped, *(stdOut + stdErr) );
INKPOT_ERROR( "CompileInkFile_Internal - %s failed to compile ink. Error %s: ", *sourceInkPath, *(stdOut + stdErr) );
}
return false;
}
if (!bExported)
{
INKPOT_ERROR("CompileInkFile_Internal - %s failed to export ink.json . Error : %s", *InkFilePathStripped, *(stdOut + stdErr));
INKPOT_ERROR("CompileInkFile_Internal - %s failed to export ink.json . Error : %s", *sourceInkPath, *(stdOut + stdErr));
return false;
}

Expand Down

0 comments on commit a40f524

Please sign in to comment.