Unit Utils.Workspace
Description
Unit which contains functions to handle a pasc workspace: a repository with multiple apps and internal packages described by a pasc.json file at its root.
Members reference each other as lazarus packages: the .lpi of an app (or the .lpk of a package) lists the required package with a relative DefaultFilename, so lazbuild builds it without a global registration.
Overview
Classes, Interfaces, Objects and Records
| Name | Description |
|---|---|
Record TWorkspaceMember |
A workspace member: an app (.lpi) or a lazarus package (.lpk). |
Functions and Procedures
function FindWorkspaceRoot(const AStartDir: string): string; |
function GetWorkspaceMembers(const AWorkspaceDir: string): TWorkspaceMembers; |
function SortMembersByDependency(const AMembers: TWorkspaceMembers): TWorkspaceMembers; |
function GetPackageReferences(const AProjectFile: string): TArray<string>; |
function AddPackageReference(const AProjectFile, APackageFile: string): Boolean; |
function FindMember(const AMembers: TWorkspaceMembers; const AName: string): TWorkspaceMember; |
function GetModuleSourceDirs(const AWorkspaceDir: string): TArray<string>; |
function SyncModulePaths(const AProjectFile, AWorkspaceDir: string; const AModuleDirs: TArray<string>): Boolean; |
function GetMemberSourceDirs(const AMemberDir: string): TArray<string>; |
function AddSourcePaths(const AProjectFile: string; const ASourceDirs: TArray<string>): Boolean; |
function GetMemberTestProject(const AMemberDir: string): string; |
function GetModulesMissingFromLock(const AWorkspaceDir: string): TArray<string>; |
Types
TWorkspaceMembers = TArray<TWorkspaceMember>; |
Constants
WORKSPACE_FILE = 'pasc.json'; |
WORKSPACE_APPS_DIR = 'apps'; |
WORKSPACE_PACKAGES_DIR = 'packages'; |
Description
Functions and Procedures
function FindWorkspaceRoot(const AStartDir: string): string; |
|
Searches for a workspace manifest from the given directory up to the file system root. Returns the workspace root directory, or empty if the directory is not inside a workspace.
Parameters
|
function GetWorkspaceMembers(const AWorkspaceDir: string): TWorkspaceMembers; |
|
Returns the members of the workspace listed in pasc.json. A member pattern is a folder relative to the root, or a folder followed by /* for each of its subfolders. Folders without a .lpk or .lpi file are ignored.
Parameters
|
function SortMembersByDependency(const AMembers: TWorkspaceMembers): TWorkspaceMembers; |
|
Returns the members sorted so that each package comes before the members that require it. Raises an exception if there is a circular reference.
Parameters
|
function GetPackageReferences(const AProjectFile: string): TArray<string>; |
|
Returns the complete file names of the packages required by a .lpi or .lpk file through a DefaultFilename, resolved relative to the file folder.
Parameters
|
function AddPackageReference(const AProjectFile, APackageFile: string): Boolean; |
|
Adds a required package with a relative DefaultFilename to a .lpi or .lpk file. The file is changed as text to preserve its formatting. Returns false if the package was already required.
Parameters
|
function FindMember(const AMembers: TWorkspaceMembers; const AName: string): TWorkspaceMember; |
|
Returns the member with the given name, or a member with an empty name if it was not found.
Parameters
|
function GetModuleSourceDirs(const AWorkspaceDir: string): TArray<string>; |
|
Returns the complete paths of the source folders of the boss modules installed in the modules folder of the workspace. Like boss, each folder of the "mainsrc" of the module boss.json (separated by ";", or the module root without it) is searched recursively, and every folder with .pas, .pp or .inc files is returned.
Parameters
|
function SyncModulePaths(const AProjectFile, AWorkspaceDir: string; const AModuleDirs: TArray<string>): Boolean; |
|
Replaces, in every OtherUnitFiles of a .lpi or .lpk file, the paths that point to the workspace modules folder by the given module source folders, relative to the file folder. Other paths are kept. The file is changed as text to preserve its formatting. Returns true if the file was changed.
Parameters
|
function GetMemberSourceDirs(const AMemberDir: string): TArray<string>; |
|
Returns the folders under the src folder of a member, src included, that have Pascal sources (.pas, .pp or .inc), sorted. lib and backup folders are not included. Returns empty if the member has no src folder.
Parameters
|
function AddSourcePaths(const AProjectFile: string; const ASourceDirs: TArray<string>): Boolean; |
|
Adds the source folders missing from every OtherUnitFiles of a project, in all its build modes, relative to the project and with / as separator. The existing entries are kept, so it only adds. Returns true if the project file was changed.
Parameters
|
function GetMemberTestProject(const AMemberDir: string): string; |
|
Returns the .lpi of the test project of a member, or empty if the member has no test project.
Parameters
|
function GetModulesMissingFromLock(const AWorkspaceDir: string): TArray<string>; |
|
Returns the module folders recorded in boss-lock.json that are not in the workspace modules folder. The folder name depends on the boss version (3.x uses github_com_user_repo, older versions the repository name), so a difference means the lock was written by another boss version, and the search paths synced from this machine do not match it. Returns empty without a lock or a modules folder.
Parameters
|
Types
TWorkspaceMembers = TArray<TWorkspaceMember>; |
|
This item has no description. |
Constants
WORKSPACE_FILE = 'pasc.json'; |
|
Workspace manifest file name. |
WORKSPACE_APPS_DIR = 'apps'; |
|
Folder of the workspace apps, relative to the workspace root. |
WORKSPACE_PACKAGES_DIR = 'packages'; |
|
Folder of the workspace packages, relative to the workspace root. |
Generated by PasDoc 1.0.4.