Merge pull request #6696 from keymanapp/fix/developer/kmcomp-package-compiler-race-condition

fix(developer): kmcomp package compiler race condition
This commit is contained in:
Marc Durdin 2022-06-03 09:42:24 +10:00 committed by GitHub
commit deb6695ea0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View file

@ -4,7 +4,6 @@ c expected: \U0001F601yx
c context:
store(&version) '10.0'
store(&name) '028smp'
begin Unicode > use(Main)

View file

@ -77,7 +77,7 @@ tests = [
]
if build_machine.system() == 'windows'
kmcomp = find_program('kmcomp.exe', required: false)
kmcomp = find_program(join_paths(meson.source_root(),'..','..','..','windows','bin','developer','kmcomp.exe'), 'kmcomp.exe', required: false)
kmcomp_cmd = [kmcomp]
copy_cmd = [find_program('cmd.exe', required: true), '/c', 'copy']
cat_cmd = [find_program('cmd.exe', required: true), '/c', 'type']

View file

@ -159,6 +159,7 @@ function TCompilePackage.Compile: Boolean;
var
buf: array[0..260] of Char;
n: Integer;
b: Boolean;
f: TSearchRec;
begin
Result := False;
@ -187,10 +188,15 @@ begin
FTempPath := buf;
GetTempFileName(PChar(FTempPath), 'kmn', 0, buf);
FTempPath := buf;
if FileExists(FTempPath) then DeleteFile(FTempPath);
FTempPath := buf + '.dir';
b := CreateDir(FTempPath);
if not b then
begin
FatalMessage('Unable to create temp folder '+FTempPath);
if FileExists(buf) then DeleteFile(buf);
Exit;
end;
CreateDir(FTempPath);
try
Result := BuildKMP;
finally
@ -205,6 +211,7 @@ begin
FindClose(f);
end;
RemoveDirectory(PChar(FTempPath));
if FileExists(buf) then DeleteFile(buf);
end;
end;