spiegel-keyman/windows/src/buildtools/devtools/SourceRootPath.pas
2017-08-10 19:28:42 +07:00

55 lines
1.6 KiB
ObjectPascal

unit SourceRootPath;
interface
function CSourcePath: string;
function CSourceRootPath: string; //='C:\Projects\keyman\open\windows\src';
function CSourceBinRootPath: string; //='C:\Projects\keyman\open\windows\bin';
function CSourceRootLibPath: string; //='C:\Projects\keyman\open\windows\lib';
implementation
uses
System.SysUtils;
function CSourcePath: string;
begin
// Root path of repo should be found in environment variable KEYMAN_ROOT
// e.g. C:\projects\keyman\open
Result := GetEnvironmentVariable('KEYMAN_ROOT');
if Result = '' then
begin
// If not found, look at path of executable. It should be either
// src\buildtools\<app>\<app.exe> or bin\buildtools\<app.exe>
Result := ExtractFileDir(ParamStr(0));
if not SameText(ExtractFileName(Result), 'buildtools') then
Result := ExtractFileDir(Result);
if not SameText(ExtractFileName(Result), 'buildtools') then
begin
raise Exception.Create('Unable to locate source root path. Set KEYMAN_ROOT environment variable accordingly');
end;
Result := ExtractFileDir(Result); //src or bin
Result := ExtractFileDir(Result); //windows
Result := ExtractFileDir(Result); //root
end
else
Result := ExcludeTrailingPathDelimiter(Result);
end;
function CSourceRootPath: string; //='C:\Projects\keyman\open\windows\src';
begin
Result := CSourcePath + '\windows\src';
end;
function CSourceBinRootPath: string; //='C:\Projects\keyman\open\windows\bin';
begin
Result := CSourcePath + '\windows\bin';
end;
function CSourceRootLibPath: string; //='C:\Projects\keyman\open\windows\lib';
begin
Result := CSourcePath + '\windows\lib';
end;
end.