mirror of https://gitlab.com/basile.b/dexed.git
add CE proj option to auto solve deps, close #102
This commit is contained in:
parent
90c6f43d4e
commit
88f47a0441
|
@ -13,7 +13,7 @@ uses
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, process, strUtils, RegExpr,
|
Classes, SysUtils, process, strUtils, RegExpr,
|
||||||
ce_common, ce_writableComponent, ce_dmdwrap, ce_observer, ce_interfaces,
|
ce_common, ce_writableComponent, ce_dmdwrap, ce_observer, ce_interfaces,
|
||||||
ce_processes, LazFileUtils;
|
ce_processes, LazFileUtils, ce_dastworx;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ type
|
||||||
fBasePath: string;
|
fBasePath: string;
|
||||||
fRunnerOldCwd: string;
|
fRunnerOldCwd: string;
|
||||||
fLibAliases: TStringList;
|
fLibAliases: TStringList;
|
||||||
|
fAutoDeps: boolean;
|
||||||
fConfigs: TCollection;
|
fConfigs: TCollection;
|
||||||
fSrcs: TStringList;
|
fSrcs: TStringList;
|
||||||
fConfIx: Integer;
|
fConfIx: Integer;
|
||||||
|
@ -81,6 +82,7 @@ type
|
||||||
property Sources: TStringList read fSrcs write setSrcs; // 'read' should return a copy to avoid abs/rel errors
|
property Sources: TStringList read fSrcs write setSrcs; // 'read' should return a copy to avoid abs/rel errors
|
||||||
property ConfigurationIndex: Integer read fConfIx write setConfIx;
|
property ConfigurationIndex: Integer read fConfIx write setConfIx;
|
||||||
property LibraryAliases: TStringList read fLibAliases write setLibAliases;
|
property LibraryAliases: TStringList read fLibAliases write setLibAliases;
|
||||||
|
property AutoSolveDependencies: boolean read fAutoDeps write fAutoDeps;
|
||||||
public
|
public
|
||||||
constructor create(aOwner: TComponent); override;
|
constructor create(aOwner: TComponent); override;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
|
@ -90,7 +92,7 @@ type
|
||||||
procedure addDefaults;
|
procedure addDefaults;
|
||||||
procedure addSource(const fname: string);
|
procedure addSource(const fname: string);
|
||||||
function addConfiguration: TCompilerConfiguration;
|
function addConfiguration: TCompilerConfiguration;
|
||||||
procedure getOpts(const list: TStrings);
|
procedure getOpts(opts: TStrings);
|
||||||
//
|
//
|
||||||
procedure activate;
|
procedure activate;
|
||||||
procedure inGroup(value: boolean);
|
procedure inGroup(value: boolean);
|
||||||
|
@ -408,28 +410,29 @@ begin
|
||||||
fModified := false;
|
fModified := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCENativeProject.getOpts(const list: TStrings);
|
procedure TCENativeProject.getOpts(opts: TStrings);
|
||||||
var
|
var
|
||||||
rel: string;
|
|
||||||
i: Integer;
|
i: Integer;
|
||||||
exc: TStringList;
|
exc: TStringList;
|
||||||
libAliasesPtr: TStringList;
|
als: TStringList;
|
||||||
conf: TCompilerConfiguration;
|
cfg: TCompilerConfiguration;
|
||||||
str: string;
|
str: string;
|
||||||
|
rel: string;
|
||||||
|
lst: TStringList;
|
||||||
begin
|
begin
|
||||||
if fConfIx = -1 then exit;
|
if fConfIx = -1 then exit;
|
||||||
exc := TStringList.Create;
|
exc := TStringList.Create;
|
||||||
try
|
try
|
||||||
conf := currentConfiguration;
|
cfg := currentConfiguration;
|
||||||
// prepares the exclusions
|
// prepares the exclusions
|
||||||
for i := 0 to conf.pathsOptions.exclusions.Count-1 do
|
for i := 0 to cfg.pathsOptions.exclusions.Count-1 do
|
||||||
begin
|
begin
|
||||||
str := fSymStringExpander.expand(conf.pathsOptions.exclusions[i]);
|
str := fSymStringExpander.expand(cfg.pathsOptions.exclusions[i]);
|
||||||
exc.Add(str)
|
exc.Add(str)
|
||||||
end;
|
end;
|
||||||
// sources
|
// sources
|
||||||
for rel in fSrcs do if rel <> '' then
|
for rel in fSrcs do if rel <> '' then
|
||||||
list.Add(expandFilenameEx(fBasePath, rel)); // note: process.inc ln 249. double quotes are added if there's a space.
|
opts.Add(expandFilenameEx(fBasePath, rel)); // note: process.inc ln 249. double quotes are added if there's a space.
|
||||||
// exclusions
|
// exclusions
|
||||||
if exc.Count > 0 then with TRegExpr.Create do
|
if exc.Count > 0 then with TRegExpr.Create do
|
||||||
try
|
try
|
||||||
|
@ -438,9 +441,9 @@ begin
|
||||||
try
|
try
|
||||||
Expression:= globToReg(str);
|
Expression:= globToReg(str);
|
||||||
Compile;
|
Compile;
|
||||||
for i := list.Count-1 downto 0 do
|
for i := opts.Count-1 downto 0 do
|
||||||
if Exec(list[i]) then
|
if Exec(opts[i]) then
|
||||||
list.Delete(i);
|
opts.Delete(i);
|
||||||
except
|
except
|
||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
|
@ -449,10 +452,10 @@ begin
|
||||||
free;
|
free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// libraries: an asterisk in list selects all the entries
|
// libraries: an asterisk in opts selects all the entries
|
||||||
libAliasesPtr := fLibAliases;
|
als := fLibAliases;
|
||||||
if (fLibAliases.Count > 0) and (fLibAliases[0] = '*') then
|
if (fLibAliases.Count > 0) and (fLibAliases[0] = '*') then
|
||||||
libAliasesPtr := nil;
|
als := nil;
|
||||||
|
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
// only link lib file if executable/shared lib
|
// only link lib file if executable/shared lib
|
||||||
|
@ -460,21 +463,39 @@ begin
|
||||||
if (conf.outputOptions.binaryKind in [executable, sharedlib]) or
|
if (conf.outputOptions.binaryKind in [executable, sharedlib]) or
|
||||||
conf.outputOptions.alwaysLinkStaticLibs then
|
conf.outputOptions.alwaysLinkStaticLibs then
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
LibMan.getLibFiles(libAliasesPtr, list);
|
LibMan.getLibFiles(als, opts);
|
||||||
|
|
||||||
// but always adds -I<path>
|
// but always adds -I<path>
|
||||||
LibMan.getLibSourcePath(libAliasesPtr, list);
|
LibMan.getLibSourcePath(als, opts);
|
||||||
// config
|
|
||||||
if conf.isOverriddenConfiguration then
|
if fAutoDeps then
|
||||||
begin
|
begin
|
||||||
conf.getOpts(list, fBaseConfig);
|
lst := TStringList.Create;
|
||||||
conf.otherOptions.getCompilerSpecificOpts(list, fBaseConfig.otherOptions,
|
try
|
||||||
|
str := '';
|
||||||
|
for i := 0 to fSrcs.Count-1 do
|
||||||
|
str += sourceAbsolute(i) + PathSeparator;
|
||||||
|
cfg.pathsOptions.getExtraSources(lst);
|
||||||
|
for i := 0 to lst.Count-1 do
|
||||||
|
str += lst[i] + PathSeparator;
|
||||||
|
lst.Clear;
|
||||||
|
getModulesImports(str, lst);
|
||||||
|
Libman.getLibFilesForImports(lst, opts);
|
||||||
|
finally
|
||||||
|
lst.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// config
|
||||||
|
if cfg.isOverriddenConfiguration then
|
||||||
|
begin
|
||||||
|
cfg.getOpts(opts, fBaseConfig);
|
||||||
|
cfg.otherOptions.getCompilerSpecificOpts(opts, fBaseConfig.otherOptions,
|
||||||
CEProjectCompiler);
|
CEProjectCompiler);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
conf.getOpts(list);
|
cfg.getOpts(opts);
|
||||||
conf.otherOptions.getCompilerSpecificOpts(list, nil, CEProjectCompiler);
|
cfg.otherOptions.getCompilerSpecificOpts(opts, nil, CEProjectCompiler);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
exc.Free;
|
exc.Free;
|
||||||
|
|
|
@ -230,6 +230,7 @@ type
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
procedure assign(source: TPersistent); override;
|
procedure assign(source: TPersistent); override;
|
||||||
procedure getOpts(list: TStrings; base: TOptsGroup = nil); override;
|
procedure getOpts(list: TStrings; base: TOptsGroup = nil); override;
|
||||||
|
procedure getExtraSources(list: TStrings);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(*****************************************************************************
|
(*****************************************************************************
|
||||||
|
@ -975,6 +976,29 @@ begin
|
||||||
// EndUpdate is not called to avoid an infinite loop
|
// EndUpdate is not called to avoid an infinite loop
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPathsOpts.getExtraSources(list: TStrings);
|
||||||
|
var
|
||||||
|
e: TStringList;
|
||||||
|
s: string;
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
e := TStringList.create;
|
||||||
|
try
|
||||||
|
e.AddStrings(['.d','.di']);
|
||||||
|
for i := 0 to fExtraSrcs.Count-1 do
|
||||||
|
begin
|
||||||
|
s := fExtraSrcs[i];
|
||||||
|
if isStringDisabled(s) then
|
||||||
|
continue;
|
||||||
|
s := fSymStringExpander.expand(s);
|
||||||
|
if not listAsteriskPath(s, list, e) then
|
||||||
|
list.Add(s);
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
e.free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPathsOpts.getOpts(list: TStrings; base: TOptsGroup = nil);
|
procedure TPathsOpts.getOpts(list: TStrings; base: TOptsGroup = nil);
|
||||||
var
|
var
|
||||||
str, sym: string;
|
str, sym: string;
|
||||||
|
|
|
@ -120,6 +120,7 @@ type
|
||||||
* in "paths", as required by the specified "source" code.
|
* in "paths", as required by the specified "source" code.
|
||||||
*)
|
*)
|
||||||
procedure getLibsForSource(source, libs, paths: TStrings);
|
procedure getLibsForSource(source, libs, paths: TStrings);
|
||||||
|
procedure getLibFilesForImports(imports: TStrings; opts: TStrings);
|
||||||
//
|
//
|
||||||
procedure updateDCD;
|
procedure updateDCD;
|
||||||
// find the aliases of the libraries used by the libraries.
|
// find the aliases of the libraries used by the libraries.
|
||||||
|
@ -625,6 +626,27 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLibraryManager.getLibFilesForImports(imports: TStrings; opts: TStrings);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
b: TLibraryItem;
|
||||||
|
s: string;
|
||||||
|
begin
|
||||||
|
for i := 0 to imports.Count-1 do
|
||||||
|
begin
|
||||||
|
b := libraryByImport[imports[i]];
|
||||||
|
if b.isNotNil and b.enabled then
|
||||||
|
begin
|
||||||
|
s := b.libFile;
|
||||||
|
if (opts.IndexOf(s) = -1) and (not s.isEmpty) then
|
||||||
|
begin
|
||||||
|
opts.Add(s);
|
||||||
|
opts.Add('-I' + b.libSourcePath);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLibraryManager.updateCrossDependencies;
|
procedure TLibraryManager.updateCrossDependencies;
|
||||||
var
|
var
|
||||||
i, j, m: integer;
|
i, j, m: integer;
|
||||||
|
|
Loading…
Reference in New Issue