You've already forked lazarus-ccr
iphonelazext: refactoring of names for xcode project utility functions
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3716 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -23,6 +23,8 @@ unit pbxcontainer;
|
|||||||
* for array of strings TPBXStringArray must be used *
|
* for array of strings TPBXStringArray must be used *
|
||||||
* for key-value set use TPBXKeyValue class *
|
* for key-value set use TPBXKeyValue class *
|
||||||
* string and integer properties are supported... anything else? *
|
* string and integer properties are supported... anything else? *
|
||||||
|
* booleans are (always) written as 0 or 1 to the file
|
||||||
|
*
|
||||||
* *
|
* *
|
||||||
* todo: add more documentions *
|
* todo: add more documentions *
|
||||||
* *
|
* *
|
||||||
@@ -450,6 +452,9 @@ begin
|
|||||||
tkInteger, tkInt64, tkQWord: begin
|
tkInteger, tkInt64, tkQWord: begin
|
||||||
SetInt64Prop(obj, p.Name, StrToIntDef(p.Value, GetInt64Prop(obj, p.Name)) );
|
SetInt64Prop(obj, p.Name, StrToIntDef(p.Value, GetInt64Prop(obj, p.Name)) );
|
||||||
end;
|
end;
|
||||||
|
tkBool: begin
|
||||||
|
SetOrdProp(obj, p.Name, StrToIntDef(p.Value, GetInt64Prop(obj, p.Name)) );
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
SetStrProp(obj, p.Name, p.Value);
|
SetStrProp(obj, p.Name, p.Value);
|
||||||
end;
|
end;
|
||||||
@@ -660,6 +665,9 @@ begin
|
|||||||
end else if p^[i].PropType.Kind in [tkInteger, tkInt64, tkQWord] then begin
|
end else if p^[i].PropType.Kind in [tkInteger, tkInt64, tkQWord] then begin
|
||||||
vl:=IntToStr(GetInt64Prop(pbx, p^[i]));
|
vl:=IntToStr(GetInt64Prop(pbx, p^[i]));
|
||||||
isstr:=(vl<>'') or (WriteEmpty.indexOf(nm)>=0);
|
isstr:=(vl<>'') or (WriteEmpty.indexOf(nm)>=0);
|
||||||
|
end else if p^[i].PropType.Kind = tkBool then begin
|
||||||
|
vl:=IntToStr(GetOrdProp(pbx, p^[i]));
|
||||||
|
isstr:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if isstr then begin
|
if isstr then begin
|
||||||
|
@@ -110,7 +110,7 @@ type
|
|||||||
private
|
private
|
||||||
fbuildActionMask : Integer;
|
fbuildActionMask : Integer;
|
||||||
ffiles: TPBXObjectsList;
|
ffiles: TPBXObjectsList;
|
||||||
frunOnlyForDeploymentPostprocessing: string;
|
frunOnlyForDeploymentPostprocessing: Boolean;
|
||||||
fname: string;
|
fname: string;
|
||||||
public
|
public
|
||||||
constructor Create; override;
|
constructor Create; override;
|
||||||
@@ -119,7 +119,7 @@ type
|
|||||||
property buildActionMask: Integer read fbuildActionMask write fbuildActionMask;
|
property buildActionMask: Integer read fbuildActionMask write fbuildActionMask;
|
||||||
property files: TPBXObjectsList read ffiles;
|
property files: TPBXObjectsList read ffiles;
|
||||||
property name: string read fname write fname;
|
property name: string read fname write fname;
|
||||||
property runOnlyForDeploymentPostprocessing: string read frunOnlyForDeploymentPostprocessing write frunOnlyForDeploymentPostprocessing;
|
property runOnlyForDeploymentPostprocessing: Boolean read frunOnlyForDeploymentPostprocessing write frunOnlyForDeploymentPostprocessing;
|
||||||
end;
|
end;
|
||||||
{ PBXFrameworksBuildPhase }
|
{ PBXFrameworksBuildPhase }
|
||||||
|
|
||||||
@@ -160,6 +160,7 @@ type
|
|||||||
constructor Create; override;
|
constructor Create; override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function addSubGroup(const aname: string): PBXGroup;
|
function addSubGroup(const aname: string): PBXGroup;
|
||||||
|
function findGroup(const aname: string): PBXGroup;
|
||||||
published
|
published
|
||||||
property children: TPBXObjectsList read fchildren;
|
property children: TPBXObjectsList read fchildren;
|
||||||
property name: string read fname write fname;
|
property name: string read fname write fname;
|
||||||
@@ -226,7 +227,7 @@ type
|
|||||||
fattributes : TPBXKeyValue;
|
fattributes : TPBXKeyValue;
|
||||||
fcompatibilityVersion : string;
|
fcompatibilityVersion : string;
|
||||||
fdevelopmentRegion : string;
|
fdevelopmentRegion : string;
|
||||||
fhasScannedForEncodings: string;
|
fhasScannedForEncodings: Boolean;
|
||||||
fmainGroup: PBXGroup;
|
fmainGroup: PBXGroup;
|
||||||
fknownRegions: TPBXStringArray;
|
fknownRegions: TPBXStringArray;
|
||||||
fproductRefGroup: PBXGroup;
|
fproductRefGroup: PBXGroup;
|
||||||
@@ -245,7 +246,7 @@ type
|
|||||||
property buildConfigurationList: XCConfigurationList read fbuildConfigurationList write fbuildConfigurationList;
|
property buildConfigurationList: XCConfigurationList read fbuildConfigurationList write fbuildConfigurationList;
|
||||||
property compatibilityVersion: string read fcompatibilityVersion write fcompatibilityVersion;
|
property compatibilityVersion: string read fcompatibilityVersion write fcompatibilityVersion;
|
||||||
property developmentRegion: string read fdevelopmentRegion write fdevelopmentRegion;
|
property developmentRegion: string read fdevelopmentRegion write fdevelopmentRegion;
|
||||||
property hasScannedForEncodings: string read fhasScannedForEncodings write fhasScannedForEncodings;
|
property hasScannedForEncodings: Boolean read fhasScannedForEncodings write fhasScannedForEncodings;
|
||||||
property knownRegions: TPBXStringArray read fknownRegions;
|
property knownRegions: TPBXStringArray read fknownRegions;
|
||||||
property mainGroup: PBXGroup read fmainGroup write fmainGroup;
|
property mainGroup: PBXGroup read fmainGroup write fmainGroup;
|
||||||
property productRefGroup: PBXGroup read fproductRefGroup write fproductRefGroup;
|
property productRefGroup: PBXGroup read fproductRefGroup write fproductRefGroup;
|
||||||
@@ -254,12 +255,23 @@ type
|
|||||||
property targets: TPBXObjectsList read ftargets;
|
property targets: TPBXObjectsList read ftargets;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LoadProjectFromStream(st: TStream; var prj: PBXProject): Boolean;
|
function ProjectLoadFromStream(st: TStream; var prj: PBXProject): Boolean;
|
||||||
function LoadProjectFromFile(const fn: string; var prj: PBXProject): Boolean;
|
function ProjectLoadFromFile(const fn: string; var prj: PBXProject): Boolean;
|
||||||
|
|
||||||
|
// serializes a PBX project to the string, using PBXContainer structure
|
||||||
function ProjectWrite(prj: PBXProject): string;
|
function ProjectWrite(prj: PBXProject): string;
|
||||||
|
|
||||||
function CreateMinProject: PBXProject;
|
// creates a minimum possible project
|
||||||
|
function ProjectCreateMin: PBXProject;
|
||||||
|
|
||||||
|
// creates main group and product groups
|
||||||
|
procedure ProjectDefaultGroups(prj: PBXProject);
|
||||||
|
|
||||||
|
// adds necessary flags for Xcode3.2 not to throw any warnings
|
||||||
|
procedure ProjectUpdateForXcode3_2(prj: PBXProject);
|
||||||
|
// creates a minimum project, defaults the structure and sets Xcode 3.2 compat flags
|
||||||
|
function ProjectCreate3_2: PBXProject;
|
||||||
|
|
||||||
function ProjectAddTarget(prj: PBXProject; const ATargetName: string): PBXNativeTarget;
|
function ProjectAddTarget(prj: PBXProject; const ATargetName: string): PBXNativeTarget;
|
||||||
|
|
||||||
const
|
const
|
||||||
@@ -274,15 +286,15 @@ const
|
|||||||
FILETYPE_EXEC = 'compiled.mach-o.executable';
|
FILETYPE_EXEC = 'compiled.mach-o.executable';
|
||||||
FILETYPE_MACHO = FILETYPE_EXEC;
|
FILETYPE_MACHO = FILETYPE_EXEC;
|
||||||
|
|
||||||
function CreateFileRef(const afilename: string; const filetype: string = ''): PBXFileReference;
|
function FileRefCreate(const afilename: string; const filetype: string = ''): PBXFileReference;
|
||||||
|
|
||||||
const
|
const
|
||||||
GROUPSRC_ABSOLUTE = '<absolute>';
|
GROUPSRC_ABSOLUTE = '<absolute>';
|
||||||
GROUPSRC_GROUP = '<group>';
|
GROUPSRC_GROUP = '<group>';
|
||||||
|
|
||||||
function CreateGroup(const aname: string; const srcTree: string = GROUPSRC_GROUP): PBXGroup;
|
function GroupCreate(const aname: string; const srcTree: string = GROUPSRC_GROUP): PBXGroup;
|
||||||
//todo: need a rountine to update the path whenever the project is saved
|
//todo: need a rountine to update the path whenever the project is saved
|
||||||
function CreateRootGroup(const projectfolder: string): PBXGroup;
|
function GroupCreateRoot(const projectfolder: string = ''): PBXGroup;
|
||||||
|
|
||||||
const
|
const
|
||||||
PRODTYPE_TOOL = 'com.apple.product-type.tool';
|
PRODTYPE_TOOL = 'com.apple.product-type.tool';
|
||||||
@@ -439,6 +451,21 @@ begin
|
|||||||
Result.sourceTree:=GROUPSRC_GROUP;
|
Result.sourceTree:=GROUPSRC_GROUP;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function PBXGroup.findGroup(const aname: string): PBXGroup;
|
||||||
|
var
|
||||||
|
i : integer;
|
||||||
|
obj : TObject;
|
||||||
|
begin
|
||||||
|
for i:=0 to fchildren.Count-1 do begin
|
||||||
|
obj:=fchildren[i];
|
||||||
|
if (obj is PBXGroup) and (PBXGroup(obj).name=aname) then begin
|
||||||
|
Result:=PBXGroup(obj);
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Result:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
{ PBXBuildPhase }
|
{ PBXBuildPhase }
|
||||||
|
|
||||||
constructor PBXBuildPhase.Create;
|
constructor PBXBuildPhase.Create;
|
||||||
@@ -452,7 +479,7 @@ begin
|
|||||||
ffiles.Free;
|
ffiles.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LoadProjectFromStream(st: TStream; var prj: PBXProject): Boolean;
|
function ProjectLoadFromStream(st: TStream; var prj: PBXProject): Boolean;
|
||||||
var
|
var
|
||||||
c : TPBXContainer;
|
c : TPBXContainer;
|
||||||
info : TPBXFileInfo;
|
info : TPBXFileInfo;
|
||||||
@@ -473,13 +500,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LoadProjectFromFile(const fn: string; var prj: PBXProject): Boolean;
|
function ProjectLoadFromFile(const fn: string; var prj: PBXProject): Boolean;
|
||||||
var
|
var
|
||||||
fs :TFileStream;
|
fs :TFileStream;
|
||||||
begin
|
begin
|
||||||
fs:=TFileStream.Create(fn, fmOpenRead or fmShareDenyNone);
|
fs:=TFileStream.Create(fn, fmOpenRead or fmShareDenyNone);
|
||||||
try
|
try
|
||||||
Result:=LoadProjectFromStream(fs, prj);
|
Result:=ProjectLoadFromStream(fs, prj);
|
||||||
finally
|
finally
|
||||||
fs.Free;
|
fs.Free;
|
||||||
end;
|
end;
|
||||||
@@ -495,7 +522,7 @@ begin
|
|||||||
Result:=PBXWriteContainer(info);
|
Result:=PBXWriteContainer(info);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CreateMinProject: PBXProject;
|
function ProjectCreateMin: PBXProject;
|
||||||
var
|
var
|
||||||
p : PBXProject;
|
p : PBXProject;
|
||||||
cfg : XCBuildConfiguration;
|
cfg : XCBuildConfiguration;
|
||||||
@@ -506,7 +533,7 @@ begin
|
|||||||
p._headerComment:='Project object';
|
p._headerComment:='Project object';
|
||||||
|
|
||||||
p.buildConfigurationList:=XCConfigurationList.Create;
|
p.buildConfigurationList:=XCConfigurationList.Create;
|
||||||
p.buildConfigurationList._headerComment:='Build configuration list';
|
p.buildConfigurationList._headerComment:='Build configuration list for PBXProject';
|
||||||
p.buildConfigurationList.defaultConfigurationIsVisible:='0';
|
p.buildConfigurationList.defaultConfigurationIsVisible:='0';
|
||||||
|
|
||||||
cfg:=p.buildConfigurationList.addConfig('Default');
|
cfg:=p.buildConfigurationList.addConfig('Default');
|
||||||
@@ -516,6 +543,37 @@ begin
|
|||||||
Result:=p;
|
Result:=p;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure ProjectDefaultGroups(prj: PBXProject);
|
||||||
|
var
|
||||||
|
prd : PBXGroup;
|
||||||
|
begin
|
||||||
|
if not Assigned(prj) then Exit;
|
||||||
|
if not Assigned(prj.mainGroup) then
|
||||||
|
prj.mainGroup:=GroupCreateRoot;
|
||||||
|
|
||||||
|
if not Assigned(prj.productRefGroup) then begin
|
||||||
|
prd:=prj.mainGroup.findGroup('Products');
|
||||||
|
if not Assigned(prd) then
|
||||||
|
prd:=prj.mainGroup.addSubGroup('Products');
|
||||||
|
prj.productRefGroup:=prd;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ProjectUpdateForXcode3_2(prj: PBXProject);
|
||||||
|
begin
|
||||||
|
if not Assigned(prj) then Exit;
|
||||||
|
// without the attribute Xcode complains aboutt updating settings
|
||||||
|
prj.attributes.AddStr('LastUpgradeCheck','0600');
|
||||||
|
prj.compatibilityVersion:='Xcode 3.2';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ProjectCreate3_2: PBXProject;
|
||||||
|
begin
|
||||||
|
Result:=ProjectCreateMin;
|
||||||
|
ProjectDefaultGroups(Result);
|
||||||
|
ProjectUpdateForXcode3_2(Result);
|
||||||
|
end;
|
||||||
|
|
||||||
function ProjectAddTarget(prj: PBXProject; const ATargetName: string): PBXNativeTarget;
|
function ProjectAddTarget(prj: PBXProject; const ATargetName: string): PBXNativeTarget;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
@@ -533,7 +591,7 @@ begin
|
|||||||
atarget.buildPhases.Add(Result);
|
atarget.buildPhases.Add(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CreateFileRef(const afilename: string; const filetype: string ): PBXFileReference;
|
function FileRefCreate(const afilename: string; const filetype: string ): PBXFileReference;
|
||||||
begin
|
begin
|
||||||
Result:=PBXFileReference.Create;
|
Result:=PBXFileReference.Create;
|
||||||
Result.path:=afilename;
|
Result.path:=afilename;
|
||||||
@@ -541,7 +599,7 @@ begin
|
|||||||
Result.explicitFileType:=FILETYPE_EXEC;
|
Result.explicitFileType:=FILETYPE_EXEC;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CreateGroup(const aname, srcTree: string): PBXGroup;
|
function GroupCreate(const aname, srcTree: string): PBXGroup;
|
||||||
begin
|
begin
|
||||||
Result:=PBXGroup.Create;
|
Result:=PBXGroup.Create;
|
||||||
Result.name:=aname;
|
Result.name:=aname;
|
||||||
@@ -549,9 +607,9 @@ begin
|
|||||||
Result._headerComment:=aname;
|
Result._headerComment:=aname;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CreateRootGroup(const projectfolder: string): PBXGroup;
|
function GroupCreateRoot(const projectfolder: string): PBXGroup;
|
||||||
begin
|
begin
|
||||||
Result:=CreateGroup('', GROUPSRC_ABSOLUTE);
|
Result:=GroupCreate('', GROUPSRC_ABSOLUTE);
|
||||||
Result.path:=projectfolder;
|
Result.path:=projectfolder;
|
||||||
Result._headerComment:=projectfolder;
|
Result._headerComment:=projectfolder;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user