diff --git a/windows/src/developer/TIKE/compile/MergeKeyboardInfo.pas b/windows/src/developer/TIKE/compile/MergeKeyboardInfo.pas index 9de3298e65..a718d878bd 100644 --- a/windows/src/developer/TIKE/compile/MergeKeyboardInfo.pas +++ b/windows/src/developer/TIKE/compile/MergeKeyboardInfo.pas @@ -56,12 +56,13 @@ type FKMXFiles: array of TKeyboardInfoMap; FJSFileData: string; FVersion: string; + FSourcePath: string; function Failed(message: string): Boolean; function Execute: Boolean; overload; function LoadJsonFile: Boolean; function LoadKMPFile: Boolean; function LoadJSFile: Boolean; - constructor Create(AJsFile, AKmpFile, AJsonFile: string; AMergingValidateIds, ASilent: Boolean; ACallback: TCompilerCallback); + constructor Create(ASourcePath, AJsFile, AKmpFile, AJsonFile: string; AMergingValidateIds, ASilent: Boolean; ACallback: TCompilerCallback); procedure AddAuthor; procedure AddAuthorEmail; procedure CheckOrAddEncodings; @@ -78,9 +79,10 @@ type function SaveJsonFile: Boolean; procedure CheckKMXFilenames; procedure AddIsRTL; + procedure AddSourcePath; public destructor Destroy; override; - class function Execute(AJsFile, AKmpFile, AJsonFile: string; AMergingValidateIds, ASilent: Boolean; ACallback: TCompilerCallback): Boolean; overload; + class function Execute(ASourcePath, AJsFile, AKmpFile, AJsonFile: string; AMergingValidateIds, ASilent: Boolean; ACallback: TCompilerCallback): Boolean; overload; end; implementation @@ -102,10 +104,10 @@ type { TMergeKeyboardInfo } -class function TMergeKeyboardInfo.Execute(AJsFile, AKmpFile, AJsonFile: string; +class function TMergeKeyboardInfo.Execute(ASourcePath, AJsFile, AKmpFile, AJsonFile: string; AMergingValidateIds, ASilent: Boolean; ACallback: TCompilerCallback): Boolean; begin - with TMergeKeyboardInfo.Create(AJsFile, AKmpFile, AJsonFile, AMergingValidateIds, ASilent, ACallback) do + with TMergeKeyboardInfo.Create(ASourcePath, AJsFile, AKmpFile, AJsonFile, AMergingValidateIds, ASilent, ACallback) do try Result := Execute; finally @@ -113,11 +115,12 @@ begin end; end; -constructor TMergeKeyboardInfo.Create(AJsFile, AKmpFile, AJsonFile: string; +constructor TMergeKeyboardInfo.Create(ASourcePath, AJsFile, AKmpFile, AJsonFile: string; AMergingValidateIds, ASilent: Boolean; ACallback: TCompilerCallback); begin inherited Create; + FSourcePath := ASourcePath; FMergingValidateIds := AMergingValidateIds; FSilent := ASilent; FCallback := ACallback; @@ -165,6 +168,7 @@ begin AddAuthor; AddAuthorEmail; AddLastModifiedDate; + AddSourcePath; CheckOrAddVersion; // must be called before CheckOrAddJsFilename @@ -728,6 +732,20 @@ begin json.AddPair('platformSupport', v); end; +// +// Add sourcePath field, from commandline parameter +// +procedure TMergeKeyboardInfo.AddSourcePath; +begin + if FSourcePath = '' then + Exit; + + if not TRegEx.IsMatch(FSourcePath, '^(release|legacy|experimental)\/.+\/.+$') then + raise EInvalidKeyboardInfo.CreateFmt('The source path "%s" is an invalid format, '+ + 'expecting "(release|legacy|experimental)/n/name".', [FSourcePath]); + json.AddPair('sourcePath', FSourcePath); +end; + procedure TMergeKeyboardInfo.CheckKMXFilenames; begin // Check that the id of the kmx files matches the filename; used only for release/ keyboards diff --git a/windows/src/developer/kmcomp/main.pas b/windows/src/developer/kmcomp/main.pas index eb0657d0b6..76318ea51d 100644 --- a/windows/src/developer/kmcomp/main.pas +++ b/windows/src/developer/kmcomp/main.pas @@ -111,6 +111,7 @@ var FParamDistribution: Boolean; FMergingValidateIds: Boolean; FJsonSchemaPath: string; + FParamSourcePath: string; begin FSilent := False; FFullySilent := False; @@ -170,6 +171,11 @@ begin FParamInfile2 := ParamStr(i); end; end + else if s = '-source-path' then + begin + Inc(i); + FParamSourcePath := ParamStr(i); + end else if s = '-schema-path' then begin Inc(i); @@ -205,7 +211,8 @@ begin if FError or (FParamInfile = '') then begin writeln(''); - writeln('Usage: kmcomp [-s[s]] [-nologo] [-c] [-d] [-w] [-v[s|d]] [-schema-path path] [-m] infile [-m infile] [-t target] [outfile.kmx|outfile.js [error.log]]'); // I4699 + writeln('Usage: kmcomp [-s[s]] [-nologo] [-c] [-d] [-w] [-v[s|d]] [-source-path path] [-schema-path path] '); + writeln(' [-m] infile [-m infile] [-t target] [outfile.kmx|outfile.js [error.log]]'); // I4699 writeln(' [-extract-keyboard-info field[,field...]]'); writeln(' infile can be a .kmn file (Keyboard Source, .kps file (Package Source), or .kpj (project)'); // I4699 // I4825 writeln(' if -v specified, can also be a .keyboard_info file'); @@ -227,6 +234,7 @@ begin writeln(' -m merge information from infile (can be .kmp and .js) into .keyboard_info output file'); writeln(' -m-validate-id validate the id against the .js, .kmx and .kmp filenames when merging'); writeln(' -json-extract print json data .keyboard_info for build script integration'); + writeln(' -source-path specify path to add to the sourcePath field in the .keyboard_info output file'); writeln(' -schema-path specify path to the keyboard_info json schema definitions'); writeln(' if not specified, then defaults to same folder as kmcomp.exe'); @@ -246,7 +254,7 @@ begin hOutfile := 0; if FMerging then - FError := not TMergeKeyboardInfo.Execute(FParamInfile, FParamInfile2, FParamOutfile, FMergingValidateIds, FSilent, @CompilerMessage) + FError := not TMergeKeyboardInfo.Execute(FParamSourcePath, FParamInfile, FParamInfile2, FParamOutfile, FMergingValidateIds, FSilent, @CompilerMessage) else if FValidating then FError := not TValidateKeyboardInfo.Execute(FParamInfile, FJsonSchemaPath, FParamDistribution, FSilent, @CompilerMessage) else if FJsonExtract then