fix(developer): run kmlmc from Keyman source path

Makes it possible to run the kmlmc.cmd compiler wrapper script from
Keyman Developer while debugging from source.

Adds a new class `TKeymanDeveloperPaths` which is similar to
`TKeymanPaths`, to provide a future single location for all Keyman
Developer path-related functions. There are a number scattered through
the source at present, e.g. in `RedistFiles.pas`, so this is just a
starting point.
This commit is contained in:
Marc Durdin 2021-09-21 06:25:35 +10:00
parent 1d9d40106e
commit e6190ee05f
4 changed files with 42 additions and 3 deletions

View file

@ -291,7 +291,8 @@ uses
Keyman.System.VisualKeyboardImportKMX in 'main\Keyman.System.VisualKeyboardImportKMX.pas',
Keyman.UI.Debug.CharacterGridRenderer in 'debug\Keyman.UI.Debug.CharacterGridRenderer.pas',
UfrmDebugStatus_Platform in 'debug\UfrmDebugStatus_Platform.pas' {frmDebugStatus_Platform},
UfrmDebugStatus_Options in 'debug\UfrmDebugStatus_Options.pas' {frmDebugStatus_Options};
UfrmDebugStatus_Options in 'debug\UfrmDebugStatus_Options.pas' {frmDebugStatus_Options},
Keyman.Developer.System.KeymanDeveloperPaths in 'main\Keyman.Developer.System.KeymanDeveloperPaths.pas';
{$R *.RES}
{$R ICONS.RES}

View file

@ -557,6 +557,9 @@
<Form>frmDebugStatus_Options</Form>
<FormType>dfm</FormType>
</DCCReference>
<DCCReference Include="main\Keyman.Developer.System.KeymanDeveloperPaths.pas">
<Form>$R *.RES</Form>
</DCCReference>
<None Include="Profiling\AQtimeModule1.aqt"/>
<BuildConfiguration Include="Debug">
<Key>Cfg_2</Key>

View file

@ -0,0 +1,33 @@
unit Keyman.Developer.System.KeymanDeveloperPaths;
interface
uses
System.SysUtils,
KeymanPaths;
type
TKeymanDeveloperPaths = class sealed
private
public
const S_LexicalModelCompiler = 'kmlmc.cmd';
class function LexicalModelCompilerPath: string; static;
end;
implementation
{ TKeymanDeveloperPaths }
class function TKeymanDeveloperPaths.LexicalModelCompilerPath: string;
var
KeymanRoot: string;
begin
if TKeymanPaths.RunningFromSource(KeymanRoot)
then Result := KeymanRoot + 'windows\src\developer\tike\'
else Result := ExtractFilePath(ParamStr(0));
Result := Result + S_LexicalModelCompiler;
end;
end.

View file

@ -4,7 +4,8 @@ interface
uses
Keyman.Developer.System.Project.ProjectFile,
Keyman.Developer.System.Project.ProjectLog;
Keyman.Developer.System.Project.ProjectLog,
Keyman.Developer.System.KeymanDeveloperPaths;
function CompileModelFile(ProjectFile: TProjectFile; infile, outfile: string; debug: Boolean): Boolean;
@ -25,7 +26,8 @@ var
begin
ec := 0;
logtext := '';
cmdline := Format('"%skmlmc.cmd" "%s" -o "%s"', [ExtractFilePath(ParamStr(0)), infile, outfile]);
cmdline := Format('"%s" "%s" -o "%s"', [TKeymanDeveloperPaths.LexicalModelCompilerPath, infile, outfile]);
Result := TUtilExecute.Console(cmdline, ExtractFileDir(infile), logtext, ec);
logtext := UTF8ToString(AnsiString(logtext));