mirror of https://gitlab.com/basile.b/dexed.git
added common project interface funct to get imports paths
This commit is contained in:
parent
e1e86c258f
commit
911a183c0b
|
|
@ -19,6 +19,7 @@ type
|
|||
fSrcs: TStringList;
|
||||
fProjectSubject: TCEProjectSubject;
|
||||
fConfigsCount: integer;
|
||||
fImportPaths: TStringList;
|
||||
fBuildTypes: TStringList;
|
||||
fConfigs: TStringList;
|
||||
fBuiltTypeIx: integer;
|
||||
|
|
@ -33,6 +34,7 @@ type
|
|||
procedure udpateConfigsFromJson;
|
||||
procedure updateSourcesFromJson;
|
||||
procedure updateTargetKindFromJson;
|
||||
procedure updateImportPathsFromJson;
|
||||
function findTargetKindInd(value: TJSONObject): boolean;
|
||||
procedure dubProcOutput(proc: TProcess);
|
||||
function getCurrentCustomConfig: TJSONObject;
|
||||
|
|
@ -54,12 +56,14 @@ type
|
|||
function modified: boolean;
|
||||
function binaryKind: TProjectBinaryKind;
|
||||
function getCommandLine: string;
|
||||
function outputFilename: string;
|
||||
//
|
||||
function isSource(const aFilename: string): boolean;
|
||||
function sourcesCount: integer;
|
||||
function sourceRelative(index: integer): string;
|
||||
function sourceAbsolute(index: integer): string;
|
||||
function outputFilename: string;
|
||||
function importsPathCount: integer;
|
||||
function importPath(index: integer): string;
|
||||
//
|
||||
function configurationCount: integer;
|
||||
procedure setActiveConfiguration(index: integer);
|
||||
|
|
@ -95,6 +99,7 @@ begin
|
|||
fBuildTypes := TStringList.Create;
|
||||
fConfigs := TStringList.Create;
|
||||
fSrcs := TStringList.Create;
|
||||
fImportPaths := TStringList.Create;
|
||||
//
|
||||
subjProjNew(fProjectSubject, self);
|
||||
subjProjChanged(fProjectSubject, self);
|
||||
|
|
@ -109,6 +114,7 @@ begin
|
|||
fBuildTypes.Free;
|
||||
fConfigs.Free;
|
||||
fSrcs.Free;
|
||||
fImportPaths.Free;
|
||||
inherited;
|
||||
end;
|
||||
{$ENDREGION --------------------------------------------------------------------}
|
||||
|
|
@ -242,6 +248,16 @@ begin
|
|||
else
|
||||
result := expandFilenameEx(fBasePath, fname);
|
||||
end;
|
||||
|
||||
function TCEDubProject.importsPathCount: integer;
|
||||
begin
|
||||
result := fImportPaths.Count;
|
||||
end;
|
||||
|
||||
function TCEDubProject.importPath(index: integer): string;
|
||||
begin
|
||||
result := expandFilenameEx(fBasePath, fImportPaths.Strings[index]);
|
||||
end;
|
||||
{$ENDREGION --------------------------------------------------------------------}
|
||||
|
||||
{$REGION ICECommonProject: configs ---------------------------------------------}
|
||||
|
|
@ -555,12 +571,38 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TCEDubProject.updateImportPathsFromJson;
|
||||
procedure addFrom(obj: TJSONObject);
|
||||
var
|
||||
arr: TJSONArray;
|
||||
item: TJSONData;
|
||||
i: integer;
|
||||
begin
|
||||
item := obj.Find('importPaths');
|
||||
if assigned(item) then
|
||||
begin
|
||||
arr := TJSONArray(item);
|
||||
for i:= 0 to arr.Count-1 do
|
||||
fImportPaths.Add(arr.Strings[i]);
|
||||
end;
|
||||
end;
|
||||
var
|
||||
conf: TJSONObject;
|
||||
begin
|
||||
if fJSON = nil then exit;
|
||||
//
|
||||
addFrom(fJSON);
|
||||
conf := getCurrentCustomConfig;
|
||||
if assigned(conf) then addFrom(conf);
|
||||
end;
|
||||
|
||||
procedure TCEDubProject.updateFields;
|
||||
begin
|
||||
updatePackageNameFromJson;
|
||||
udpateConfigsFromJson;
|
||||
updateSourcesFromJson;
|
||||
updateTargetKindFromJson;
|
||||
updateImportPathsFromJson;
|
||||
end;
|
||||
|
||||
procedure TCEDubProject.beginModification;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ type
|
|||
|
||||
// project sources ---------------------------------------------------------
|
||||
|
||||
// returns the count of source file in th e project
|
||||
// returns the count of source files for the current config
|
||||
function sourcesCount: integer;
|
||||
// returns the source absolute filename.
|
||||
function sourceAbsolute(index: integer): string;
|
||||
|
|
@ -67,6 +67,10 @@ type
|
|||
function sourceRelative(index: integer): string;
|
||||
// returns true if aFilename is a project source.
|
||||
function isSource(const aFilename: string): boolean;
|
||||
// returns the count of import paths for the current config
|
||||
function importsPathCount: integer;
|
||||
// returns the import absolute path
|
||||
function importPath(index: integer): string;
|
||||
|
||||
// sub routines for the actions --------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -97,6 +97,8 @@ type
|
|||
function sourceRelative(index: integer): string;
|
||||
function sourceAbsolute(index: integer): string;
|
||||
function isSource(const aFilename: string): boolean;
|
||||
function importsPathCount: integer;
|
||||
function importPath(index: integer): string;
|
||||
//
|
||||
function run(const runArgs: string = ''): Boolean;
|
||||
function compile: Boolean;
|
||||
|
|
@ -182,13 +184,16 @@ end;
|
|||
procedure TCENativeProject.addSource(const aFilename: string);
|
||||
var
|
||||
relSrc, absSrc: string;
|
||||
expand: boolean;
|
||||
begin
|
||||
if not isDlangCompilable(ExtractFileExt(aFilename)) then
|
||||
exit;
|
||||
expand := DirectoryExists(fBasePath);
|
||||
for relSrc in fSrcs do
|
||||
begin
|
||||
absSrc := expandFilenameEx(fBasePath,relsrc);
|
||||
if aFilename = absSrc then exit;
|
||||
if not expand then absSrc := relSrc
|
||||
else absSrc := expandFilenameEx(fBasePath, relsrc);
|
||||
if SameFileName(aFilename, absSrc) then exit;
|
||||
end;
|
||||
fSrcs.Add(ExtractRelativepath(fBasePath, aFilename));
|
||||
end;
|
||||
|
|
@ -900,6 +905,18 @@ begin
|
|||
result := expandFilenameEx(fBasePath, fname);
|
||||
end;
|
||||
|
||||
function TCENativeProject.importsPathCount: integer;
|
||||
begin
|
||||
result := currentConfiguration.pathsOptions.importModulePaths.Count;
|
||||
end;
|
||||
|
||||
function TCENativeProject.importPath(index: integer): string;
|
||||
begin
|
||||
result := currentConfiguration.pathsOptions.importModulePaths.Strings[index];
|
||||
if DirectoryExists(fBasePath) then
|
||||
result := expandFilenameEx(fBasePath, result);
|
||||
end;
|
||||
|
||||
function isValidNativeProject(const filename: string): boolean;
|
||||
var
|
||||
maybe: TCENativeProject;
|
||||
|
|
|
|||
Loading…
Reference in New Issue