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;
|
constructor Create; override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function addConfig(const aname: string): XCBuildConfiguration;
|
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
|
// Count and Items are just for convenience. MUST NOT BE in "published" section
|
||||||
property Count: integer read GetCount;
|
property Count: integer read GetCount;
|
||||||
property Items[i: integer]: XCBuildConfiguration read GetConfigItem; default;
|
property Items[i: integer]: XCBuildConfiguration read GetConfigItem; default;
|
||||||
@ -175,7 +176,8 @@ 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;
|
function findGroup(const aname: string; aforce: Boolean = false): PBXGroup;
|
||||||
|
function findFileRefByPathName(const afilename: string): PBXFileReference;
|
||||||
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;
|
||||||
@ -305,6 +307,8 @@ procedure ProjectUpdateForXcode3_2(prj: PBXProject);
|
|||||||
function ProjectCreate3_2: PBXProject;
|
function ProjectCreate3_2: PBXProject;
|
||||||
|
|
||||||
function ProjectAddTarget(prj: PBXProject; const ATargetName: string): PBXNativeTarget;
|
function ProjectAddTarget(prj: PBXProject; const ATargetName: string): PBXNativeTarget;
|
||||||
|
// adds if doesn't exist
|
||||||
|
function ProjectForceTarget(prj: PBXProject; const ATargetName: string): PBXNativeTarget;
|
||||||
|
|
||||||
const
|
const
|
||||||
SCRIPT_RUNPATH = '/bin/sh';
|
SCRIPT_RUNPATH = '/bin/sh';
|
||||||
@ -495,6 +499,21 @@ begin
|
|||||||
fbuildConfigurations.Add(Result);
|
fbuildConfigurations.Add(Result);
|
||||||
end;
|
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 }
|
{ XCBuildConfiguration }
|
||||||
|
|
||||||
constructor XCBuildConfiguration.Create;
|
constructor XCBuildConfiguration.Create;
|
||||||
@ -532,7 +551,7 @@ begin
|
|||||||
Result.sourceTree:=SRCTREE_GROUP;
|
Result.sourceTree:=SRCTREE_GROUP;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PBXGroup.findGroup(const aname: string): PBXGroup;
|
function PBXGroup.findGroup(const aname: string; aforce: Boolean = false): PBXGroup;
|
||||||
var
|
var
|
||||||
i : integer;
|
i : integer;
|
||||||
obj : TObject;
|
obj : TObject;
|
||||||
@ -544,6 +563,24 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
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;
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -662,6 +699,18 @@ begin
|
|||||||
Result:=prj.addTarget(ATargetName);
|
Result:=prj.addTarget(ATargetName);
|
||||||
end;
|
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;
|
function TargetAddRunScript(atarget: PBXNativeTarget): PBXShellScriptBuildPhase;
|
||||||
begin
|
begin
|
||||||
Result:=PBXShellScriptBuildPhase.Create;
|
Result:=PBXShellScriptBuildPhase.Create;
|
||||||
|
@ -23,6 +23,7 @@ uses
|
|||||||
|
|
||||||
procedure PrepareTemplateFile_(Src, TemplateValues: TStrings; BuildSettings: TFPStringHashTable);
|
procedure PrepareTemplateFile_(Src, TemplateValues: TStrings; BuildSettings: TFPStringHashTable);
|
||||||
procedure PrepareTemplateFile(Src, TemplateValues, ResFiles: TStrings);
|
procedure PrepareTemplateFile(Src, TemplateValues, ResFiles: TStrings);
|
||||||
|
procedure PrepareTemplateFile(prj: PBXProject; TemplateValues, ResFiles: TStrings);
|
||||||
procedure UpdateBldConfig(const proj: PBXProject; optName, optVal: string);
|
procedure UpdateBldConfig(const proj: PBXProject; optName, optVal: string);
|
||||||
procedure UpdateMainFile(const proj: PBXProject; mainfile: string);
|
procedure UpdateMainFile(const proj: PBXProject; mainfile: string);
|
||||||
procedure UpdateCompileOpts(const proj: PBXProject; options: string);
|
procedure UpdateCompileOpts(const proj: PBXProject; options: string);
|
||||||
@ -368,6 +369,13 @@ end;
|
|||||||
procedure PrepareTemplateFile(Src, TemplateValues, ResFiles: TStrings);
|
procedure PrepareTemplateFile(Src, TemplateValues, ResFiles: TStrings);
|
||||||
var
|
var
|
||||||
prj : PBXProject;
|
prj : PBXProject;
|
||||||
|
begin
|
||||||
|
prj:=ProjectCreate3_2;
|
||||||
|
PrepareTemplateFile(prj, TemplateValues, ResFiles);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure PrepareTemplateFile(prj: PBXProject; TemplateValues, ResFiles: TStrings);
|
||||||
|
var
|
||||||
trg : PBXNativeTarget;
|
trg : PBXNativeTarget;
|
||||||
cfg : XCBuildConfiguration;
|
cfg : XCBuildConfiguration;
|
||||||
fr : PBXFileReference;
|
fr : PBXFileReference;
|
||||||
@ -383,19 +391,20 @@ var
|
|||||||
main : string;
|
main : string;
|
||||||
fnm : string;
|
fnm : string;
|
||||||
begin
|
begin
|
||||||
prj:=ProjectCreate3_2;
|
|
||||||
|
|
||||||
targetName:=TemplateValues.Values['targetname'];
|
targetName:=TemplateValues.Values['targetname'];
|
||||||
bundle:=TemplateValues.Values['bundle'];
|
bundle:=TemplateValues.Values['bundle'];
|
||||||
plist:=TemplateValues.Values['plist'];
|
plist:=TemplateValues.Values['plist'];
|
||||||
if plist='' then plist:='info.plist';
|
if plist='' then plist:='info.plist';
|
||||||
main:=TemplateValues.Values['mainfile'];
|
main:=TemplateValues.Values['mainfile'];
|
||||||
|
|
||||||
trg:=ProjectAddTarget(prj, targetName);
|
trg:=ProjectForceTarget(prj, targetName);
|
||||||
for i:=0 to prj.buildConfigurationList.Count-1 do begin
|
for i:=0 to prj.buildConfigurationList.Count-1 do begin
|
||||||
cfg:=prj.buildConfigurationList[i];
|
cfg:=prj.buildConfigurationList[i];
|
||||||
ConfigIOS(cfg, TARGET_IOS_8_1);
|
ConfigIOS(cfg, TARGET_IOS_8_1);
|
||||||
// Enable Build Active Architecture Only When Debugging
|
// 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');
|
if cfg.name='Debug' then cfg.buildSettings.AddStr('ONLY_ACTIVE_ARCH','YES');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -404,34 +413,43 @@ begin
|
|||||||
trg.productType:=PRODTYPE_APP;
|
trg.productType:=PRODTYPE_APP;
|
||||||
|
|
||||||
// target configuration
|
// target configuration
|
||||||
trg.buildConfigurationList:=XCConfigurationList.Create;
|
if not Assigned(trg.buildConfigurationList) then
|
||||||
|
trg.buildConfigurationList:=XCConfigurationList.Create;
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
cfg:=trg.buildConfigurationList.addConfig('Debug');
|
cfg:=trg.buildConfigurationList.findConfig('Debug', true);
|
||||||
cfg.buildSettings.AddStr('INFOPLIST_FILE', '$(SRCROOT)/'+plist);
|
cfg.buildSettings.AddStr('INFOPLIST_FILE', '$(SRCROOT)/'+plist);
|
||||||
cfg.buildSettings.AddStr('PRODUCT_NAME', trg.productName);
|
cfg.buildSettings.AddStr('PRODUCT_NAME', trg.productName);
|
||||||
// Build
|
// Build
|
||||||
cfg:=trg.buildConfigurationList.addConfig('Release');
|
cfg:=trg.buildConfigurationList.findConfig('Release', true);
|
||||||
cfg.buildSettings.AddStr('INFOPLIST_FILE', '$(SRCROOT)/'+plist);
|
cfg.buildSettings.AddStr('INFOPLIST_FILE', '$(SRCROOT)/'+plist);
|
||||||
cfg.buildSettings.AddStr('PRODUCT_NAME', trg.productName);
|
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
|
// Adding the ".app" directory for the bundle and bind it to the target
|
||||||
fr:=FileRefCreate(bundle, FILETYPE_MACHO);
|
if not Assigned(trg.productReference) then begin
|
||||||
fr.sourceTree:= SRCTREE_PRODUCT;
|
fr:=FileRefCreate(bundle, FILETYPE_MACHO);
|
||||||
trg.productReference:=fr;
|
fr.sourceTree:= SRCTREE_PRODUCT;
|
||||||
|
trg.productReference:=fr;
|
||||||
|
end else
|
||||||
|
fr:=trg.productReference;
|
||||||
|
|
||||||
// Creating "content" for the directory. It should also contain .plist
|
// Creating "content" for the directory. It should also contain .plist
|
||||||
pgrp:=prj.mainGroup.addSubGroup(targetName); // name must match to the target name!
|
pgrp:=prj.mainGroup.findGroup(targetName, true); // name must match to the target name!
|
||||||
grp:=pgrp.addSubGroup('Supporting Files'); // name must match!
|
grp:=pgrp.findGroup('Supporting Files', true); // name must match!
|
||||||
|
|
||||||
// creating a reference to info.plist. It's located at "xcode" folder.
|
// creating a reference to info.plist. It's located at "xcode" folder.
|
||||||
// Thus at the same directar as .xcodeproj dir
|
// Thus at the same directar as .xcodeproj dir
|
||||||
fr:=FileRefCreate(plist, FILETYPE_PLIST );
|
if not Assigned(grp.findFileRefByPathName(plist)) then
|
||||||
fr.sourceTree:=SRCTREE_PROJECT;
|
begin
|
||||||
|
fr:=FileRefCreate(plist, FILETYPE_PLIST );
|
||||||
|
fr.sourceTree:=SRCTREE_PROJECT;
|
||||||
|
|
||||||
fr.path:=plist;
|
fr.path:=plist;
|
||||||
grp.children.Add( fr );
|
grp.children.Add( fr );
|
||||||
|
end;
|
||||||
|
|
||||||
scr:=TargetAddRunScript(trg);
|
scr:=TargetAddRunScript(trg);
|
||||||
scr.shellScript:=BuildScript;
|
scr.shellScript:=BuildScript;
|
||||||
|
Reference in New Issue
Block a user