lazbuild: fixed --add-package pkgname

git-svn-id: trunk@61467 -
This commit is contained in:
mattias 2019-06-24 14:18:37 +00:00
parent ab42c14b9f
commit 81580355ac
2 changed files with 55 additions and 40 deletions

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="10"/>
<Version Value="12"/>
<General>
<Flags>
<LRSInOutputDirectory Value="False"/>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InIDEConfig"/>
<MainUnit Value="0"/>
</General>
<BuildModes Count="2">
<Item1 Name="Debug" Default="True"/>
@ -42,15 +42,19 @@
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<CommandLineParams Value="c:/lazarus/source/lazarus/examples/hello.lpi"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T &apos;Lazarus Run Output&apos; -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
<FormatVersion Value="2"/>
<Modes Count="1">
<Mode0 Name="default">
<local>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T &apos;Lazarus Run Output&apos; -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</Mode0>
</Modes>
</RunParams>
<RequiredPackages Count="3">
<Item1>
@ -112,7 +116,6 @@
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
<UseHeaptrc Value="True"/>
<TrashVariables Value="True"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>

View File

@ -367,42 +367,52 @@ var
begin
Result:=false;
OriginalFilename:=FileName;
// Check for packages if the specified name is a valid identifier
debugln(['TLazBuildApplication.BuildFile ',OriginalFilename]);
if IsValidPkgName(OriginalFileName) then begin
if PackageAction=lpaAddPkgLinks then begin
Error(ErrorFileNotFound,'lpk file expected, but '+OriginalFilename+' found');
Exit;
end;
// Initialize package graph with base packages etc:
if not Init then exit;
// Could be a known but not installed package
// so try and get package filename from all other known packages
Package:=TLazPackageLink(LazPackageLinks.FindLinkWithPkgName(OriginalFileName));
if Package=nil then begin
// Not found after everything we tried
if CompareFileExt(Filename,'.lpi')=0 then
Error(ErrorFileNotFound,'file not found: '+OriginalFilename)
else
Error(ErrorFileNotFound,'package not found: '+OriginalFilename);
end
else begin
// We found a package link
case PackageAction of
lpaBuild:
begin
Result:=BuildPackage(Package.LPKFilename);
exit;
end;
lpaInstall:
exit(true); // this is handled in AddPackagesToInstallList
end;
end;
end;
Filename:=CleanAndExpandFilename(Filename);
if not FileExistsUTF8(Filename) then
begin
// Check for packages if the specified name is a valid identifier
if PackageFileNameIsValid(OriginalFileName) then begin
if PackageAction=lpaAddPkgLinks then begin
Error(ErrorFileNotFound,'lpk file expected, but '+OriginalFilename+' found');
Exit;
end;
// Initialize package graph with base packages etc:
if not Init then exit;
// Could be a known but not installed package
// so try and get package filename from all other known packages
Package:=TLazPackageLink(LazPackageLinks.FindLinkWithPkgName(OriginalFileName));
if Package=nil then begin
// Not found after everything we tried
if CompareFileExt(Filename,'.lpi')=0 then
Error(ErrorFileNotFound,'file not found: '+OriginalFilename)
else
Error(ErrorFileNotFound,'package not found: '+OriginalFilename);
end
else begin
// We found a package link
case PackageAction of
lpaBuild: Result:=BuildPackage(Package.LPKFilename);
lpaInstall: Result:=true; // this is handled in AddPackagesToInstallList
end;
end;
end
else begin
// File is not an identifier and doesn't exist.
Error(ErrorFileNotFound, 'package not found: '+OriginalFilename);
Exit;
end;
// File is not an identifier and doesn't exist.
Error(ErrorFileNotFound, 'file not found: '+OriginalFilename);
Exit;
end
else if DirPathExists(Filename) then
begin
Error(ErrorFileNotFound,'file "'+Filename+'" is a directory');
Exit;
end
else begin
// File exists:
if CompareFileExt(Filename,'.lpk')=0 then begin
@ -1047,6 +1057,8 @@ begin
// Look for package name in all known packages
PackageName:='';
PkgFilename:='';
if pvPkgSearch in fPkgGraphVerbosity then
debugln(['Info: (lazarus) [TLazBuildApplication.AddPackagesToInstallList] "',PackageNamesOrFiles[i],'"']);
if CompareFileExt(PackageNamesOrFiles[i],'.lpk')=0 then
PkgFilename:=ExpandFileNameUTF8(PackageNamesOrFiles[i])
else if IsValidPkgName(PackageNamesOrFiles[i]) then begin