You've already forked lazarus-ccr
iphonelazext: started specific project updates (getting rid of rewriting the xcode project file)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4430 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -61,6 +61,7 @@ type
|
||||
constructor Create; override;
|
||||
destructor Destroy; override;
|
||||
function addConfig(const aname: string): XCBuildConfiguration;
|
||||
function findConfig(const aname: string; aforce: Boolean = false): XCBuildConfiguration;
|
||||
// Count and Items are just for convenience. MUST NOT BE in "published" section
|
||||
property Count: integer read GetCount;
|
||||
property Items[i: integer]: XCBuildConfiguration read GetConfigItem; default;
|
||||
@ -175,7 +176,8 @@ type
|
||||
constructor Create; override;
|
||||
destructor Destroy; override;
|
||||
function addSubGroup(const aname: string): PBXGroup;
|
||||
function findGroup(const aname: string): PBXGroup;
|
||||
function findGroup(const aname: string; aforce: Boolean = false): PBXGroup;
|
||||
function findFileRefByPathName(const afilename: string): PBXFileReference;
|
||||
published
|
||||
property children: TPBXObjectsList read fchildren;
|
||||
property name: string read fname write fname;
|
||||
@ -305,6 +307,8 @@ procedure ProjectUpdateForXcode3_2(prj: PBXProject);
|
||||
function ProjectCreate3_2: PBXProject;
|
||||
|
||||
function ProjectAddTarget(prj: PBXProject; const ATargetName: string): PBXNativeTarget;
|
||||
// adds if doesn't exist
|
||||
function ProjectForceTarget(prj: PBXProject; const ATargetName: string): PBXNativeTarget;
|
||||
|
||||
const
|
||||
SCRIPT_RUNPATH = '/bin/sh';
|
||||
@ -495,6 +499,21 @@ begin
|
||||
fbuildConfigurations.Add(Result);
|
||||
end;
|
||||
|
||||
function XCConfigurationList.findConfig(const aname: string; aforce: Boolean): XCBuildConfiguration;
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
for i:=0 to fbuildConfigurations.Count-1 do begin
|
||||
Result:=XCBuildConfiguration(fbuildConfigurations[i]);
|
||||
if Result.name=aname then
|
||||
Exit;
|
||||
end;
|
||||
if aforce then
|
||||
Result:=addConfig(aname)
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
{ XCBuildConfiguration }
|
||||
|
||||
constructor XCBuildConfiguration.Create;
|
||||
@ -532,7 +551,7 @@ begin
|
||||
Result.sourceTree:=SRCTREE_GROUP;
|
||||
end;
|
||||
|
||||
function PBXGroup.findGroup(const aname: string): PBXGroup;
|
||||
function PBXGroup.findGroup(const aname: string; aforce: Boolean = false): PBXGroup;
|
||||
var
|
||||
i : integer;
|
||||
obj : TObject;
|
||||
@ -544,6 +563,24 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
if aforce then
|
||||
Result:=addSubGroup(aname)
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function PBXGroup.findFileRefByPathName(const afilename: string): PBXFileReference;
|
||||
var
|
||||
i : integer;
|
||||
obj : TObject;
|
||||
begin
|
||||
for i:=0 to fchildren.Count-1 do begin
|
||||
obj:=fchildren[i];
|
||||
if (obj is PBXFileReference) and (PBXFileReference(obj).path=afilename) then begin
|
||||
Result:=PBXFileReference(obj);
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
@ -662,6 +699,18 @@ begin
|
||||
Result:=prj.addTarget(ATargetName);
|
||||
end;
|
||||
|
||||
function ProjectForceTarget(prj: PBXProject; const ATargetName: string): PBXNativeTarget;
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
for i:=0 to prj.targets.Count-1 do begin
|
||||
Result:=PBXNativeTarget(prj.targets[i]);
|
||||
if Result.name=ATargetName then
|
||||
Exit;
|
||||
end;
|
||||
Result:=ProjectAddTarget(prj, ATargetName);
|
||||
end;
|
||||
|
||||
function TargetAddRunScript(atarget: PBXNativeTarget): PBXShellScriptBuildPhase;
|
||||
begin
|
||||
Result:=PBXShellScriptBuildPhase.Create;
|
||||
|
@ -23,6 +23,7 @@ uses
|
||||
|
||||
procedure PrepareTemplateFile_(Src, TemplateValues: TStrings; BuildSettings: TFPStringHashTable);
|
||||
procedure PrepareTemplateFile(Src, TemplateValues, ResFiles: TStrings);
|
||||
procedure PrepareTemplateFile(prj: PBXProject; TemplateValues, ResFiles: TStrings);
|
||||
procedure UpdateBldConfig(const proj: PBXProject; optName, optVal: string);
|
||||
procedure UpdateMainFile(const proj: PBXProject; mainfile: string);
|
||||
procedure UpdateCompileOpts(const proj: PBXProject; options: string);
|
||||
@ -368,6 +369,13 @@ end;
|
||||
procedure PrepareTemplateFile(Src, TemplateValues, ResFiles: TStrings);
|
||||
var
|
||||
prj : PBXProject;
|
||||
begin
|
||||
prj:=ProjectCreate3_2;
|
||||
PrepareTemplateFile(prj, TemplateValues, ResFiles);
|
||||
end;
|
||||
|
||||
procedure PrepareTemplateFile(prj: PBXProject; TemplateValues, ResFiles: TStrings);
|
||||
var
|
||||
trg : PBXNativeTarget;
|
||||
cfg : XCBuildConfiguration;
|
||||
fr : PBXFileReference;
|
||||
@ -383,19 +391,20 @@ var
|
||||
main : string;
|
||||
fnm : string;
|
||||
begin
|
||||
prj:=ProjectCreate3_2;
|
||||
|
||||
targetName:=TemplateValues.Values['targetname'];
|
||||
bundle:=TemplateValues.Values['bundle'];
|
||||
plist:=TemplateValues.Values['plist'];
|
||||
if plist='' then plist:='info.plist';
|
||||
main:=TemplateValues.Values['mainfile'];
|
||||
|
||||
trg:=ProjectAddTarget(prj, targetName);
|
||||
trg:=ProjectForceTarget(prj, targetName);
|
||||
for i:=0 to prj.buildConfigurationList.Count-1 do begin
|
||||
cfg:=prj.buildConfigurationList[i];
|
||||
ConfigIOS(cfg, TARGET_IOS_8_1);
|
||||
// Enable Build Active Architecture Only When Debugging
|
||||
// it would be amd-32 for iPhone5 (and earlier)
|
||||
// and amd-64 for iPhone6 (and later)
|
||||
// Release requires to have a fat binary 32+64 amd, if target is less than iphone6
|
||||
if cfg.name='Debug' then cfg.buildSettings.AddStr('ONLY_ACTIVE_ARCH','YES');
|
||||
end;
|
||||
|
||||
@ -404,34 +413,43 @@ begin
|
||||
trg.productType:=PRODTYPE_APP;
|
||||
|
||||
// target configuration
|
||||
trg.buildConfigurationList:=XCConfigurationList.Create;
|
||||
if not Assigned(trg.buildConfigurationList) then
|
||||
trg.buildConfigurationList:=XCConfigurationList.Create;
|
||||
|
||||
// Debug
|
||||
cfg:=trg.buildConfigurationList.addConfig('Debug');
|
||||
cfg:=trg.buildConfigurationList.findConfig('Debug', true);
|
||||
cfg.buildSettings.AddStr('INFOPLIST_FILE', '$(SRCROOT)/'+plist);
|
||||
cfg.buildSettings.AddStr('PRODUCT_NAME', trg.productName);
|
||||
// Build
|
||||
cfg:=trg.buildConfigurationList.addConfig('Release');
|
||||
cfg:=trg.buildConfigurationList.findConfig('Release', true);
|
||||
cfg.buildSettings.AddStr('INFOPLIST_FILE', '$(SRCROOT)/'+plist);
|
||||
cfg.buildSettings.AddStr('PRODUCT_NAME', trg.productName);
|
||||
|
||||
trg.buildConfigurationList.defaultConfigurationName:='Debug';
|
||||
if trg.buildConfigurationList = '' then
|
||||
trg.buildConfigurationList.defaultConfigurationName:='Debug';
|
||||
|
||||
// Adding the ".app" directory for the bundle and bind it to the target
|
||||
fr:=FileRefCreate(bundle, FILETYPE_MACHO);
|
||||
fr.sourceTree:= SRCTREE_PRODUCT;
|
||||
trg.productReference:=fr;
|
||||
if not Assigned(trg.productReference) then begin
|
||||
fr:=FileRefCreate(bundle, FILETYPE_MACHO);
|
||||
fr.sourceTree:= SRCTREE_PRODUCT;
|
||||
trg.productReference:=fr;
|
||||
end else
|
||||
fr:=trg.productReference;
|
||||
|
||||
// Creating "content" for the directory. It should also contain .plist
|
||||
pgrp:=prj.mainGroup.addSubGroup(targetName); // name must match to the target name!
|
||||
grp:=pgrp.addSubGroup('Supporting Files'); // name must match!
|
||||
pgrp:=prj.mainGroup.findGroup(targetName, true); // name must match to the target name!
|
||||
grp:=pgrp.findGroup('Supporting Files', true); // name must match!
|
||||
|
||||
// creating a reference to info.plist. It's located at "xcode" folder.
|
||||
// Thus at the same directar as .xcodeproj dir
|
||||
fr:=FileRefCreate(plist, FILETYPE_PLIST );
|
||||
fr.sourceTree:=SRCTREE_PROJECT;
|
||||
if not Assigned(grp.findFileRefByPathName(plist)) then
|
||||
begin
|
||||
fr:=FileRefCreate(plist, FILETYPE_PLIST );
|
||||
fr.sourceTree:=SRCTREE_PROJECT;
|
||||
|
||||
fr.path:=plist;
|
||||
grp.children.Add( fr );
|
||||
fr.path:=plist;
|
||||
grp.children.Add( fr );
|
||||
end;
|
||||
|
||||
scr:=TargetAddRunScript(trg);
|
||||
scr.shellScript:=BuildScript;
|
||||
|
Reference in New Issue
Block a user