You've already forked lazarus-ccr
* Add custom-settings to an exported XCode-project to make it possible to compile for iOS _and_ the Simulator
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2647 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -20,7 +20,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Unix, BaseUnix, process,
|
Unix, BaseUnix, process,
|
||||||
Classes, SysUtils,
|
Classes, SysUtils, contnrs,
|
||||||
Graphics, Controls, Forms, Dialogs, FileUtil,
|
Graphics, Controls, Forms, Dialogs, FileUtil,
|
||||||
{Lazarus Interface}
|
{Lazarus Interface}
|
||||||
LazIDEIntf, MenuIntf, ProjectIntf, IDEOptionsIntf, IDEMsgIntf,
|
LazIDEIntf, MenuIntf, ProjectIntf, IDEOptionsIntf, IDEMsgIntf,
|
||||||
@ -352,7 +352,7 @@ end;
|
|||||||
procedure TiPhoneExtension.UpdateXcode(Sender: TObject);
|
procedure TiPhoneExtension.UpdateXcode(Sender: TObject);
|
||||||
var
|
var
|
||||||
templates : TStringList;
|
templates : TStringList;
|
||||||
build : TStringList;
|
build : TFPStringHashTable;
|
||||||
dir : string;
|
dir : string;
|
||||||
projdir : string;
|
projdir : string;
|
||||||
proj : TStringList;
|
proj : TStringList;
|
||||||
@ -366,36 +366,46 @@ var
|
|||||||
name : string;
|
name : string;
|
||||||
|
|
||||||
opt : string;
|
opt : string;
|
||||||
|
optSim: string;
|
||||||
begin
|
begin
|
||||||
FillBunldeInfo(false, Info);
|
FillBunldeInfo(false, Info);
|
||||||
// the create .plist would be used by XCode project
|
// the create .plist would be used by XCode project
|
||||||
// the simulator .plist in created with InstallAppToSim.
|
// the simulator .plist in created with InstallAppToSim.
|
||||||
// they differ with SDKs used
|
// they differ with SDKs used
|
||||||
|
|
||||||
build := TStringList.Create;
|
build := TFPStringHashTable.Create;
|
||||||
|
|
||||||
tname:=ExtractFileName( LazarusIDE.ActiveProject.MainFile.Filename);
|
tname:=ExtractFileName( LazarusIDE.ActiveProject.MainFile.Filename);
|
||||||
tname:=ChangeFileExt(tname, '');
|
tname:=ChangeFileExt(tname, '');
|
||||||
plistname:=tname+'.plist';
|
plistname:=tname+'.plist';
|
||||||
|
|
||||||
build.Values['INFOPLIST_FILE'] := '"'+plistname+'"';
|
build.Add('INFOPLIST_FILE','"'+plistname+'"');
|
||||||
build.Values['PRODUCT_NAME'] := '"'+tname+'"';
|
build.Add('PRODUCT_NAME','"'+tname+'"');
|
||||||
build.Values['SDKROOT'] := EnvOptions.GetSDKName(ProjOptions.SDK, false);
|
build.Add('SDKROOT',EnvOptions.GetSDKName(ProjOptions.SDK, false));
|
||||||
build.Values['FPC_COMPILER_PATH'] := '"'+EnvOptions.CompilerPath+'"';
|
build.Add('FPC_COMPILER_PATH','"'+EnvOptions.CompilerPath+'"');
|
||||||
build.Values['FPC_MAIN_FILE'] := '"'+LazarusIDE.ActiveProject.MainFile.Filename+'"';
|
build.Add('FPC_MAIN_FILE','"'+LazarusIDE.ActiveProject.MainFile.Filename+'"');
|
||||||
opt :=
|
opt :=
|
||||||
' -XR'+EnvOptions.GetSDKFullPath(ProjOptions.SDK, false)+' ' +
|
' -XR'+EnvOptions.GetSDKFullPath(ProjOptions.SDK, false)+' ' +
|
||||||
' -FD'+IncludeTrailingPathDelimiter(EnvOptions.PlatformsBaseDir)+'iPhoneOS.platform/Developer/usr/bin ' +
|
' -FD'+IncludeTrailingPathDelimiter(EnvOptions.PlatformsBaseDir)+'iPhoneOS.platform/Developer/usr/bin ' +
|
||||||
EnvOptions.CommonOpt;
|
EnvOptions.CommonOpt;
|
||||||
|
optSim :=
|
||||||
|
' -XR'+EnvOptions.GetSDKFullPath(ProjOptions.SDK, true)+' ' +
|
||||||
|
' -FD'+IncludeTrailingPathDelimiter(EnvOptions.PlatformsBaseDir)+'iPhoneSimulator.platform/Developer/usr/bin ' +
|
||||||
|
EnvOptions.CommonOpt;
|
||||||
|
|
||||||
with LazarusIDE.ActiveProject.LazCompilerOptions do begin
|
with LazarusIDE.ActiveProject.LazCompilerOptions do begin
|
||||||
opt:=opt + ' ' +BreakPathsStringToOption(OtherUnitFiles, '-Fu', '\"');
|
opt:=opt + ' ' +BreakPathsStringToOption(OtherUnitFiles, '-Fu', '\"');
|
||||||
opt:=opt + ' ' +BreakPathsStringToOption(IncludePath, '-Fi', '\"');
|
opt:=opt + ' ' +BreakPathsStringToOption(IncludePath, '-Fi', '\"');
|
||||||
opt:=opt + ' ' +BreakPathsStringToOption(ObjectPath, '-Fo', '\"');
|
opt:=opt + ' ' +BreakPathsStringToOption(ObjectPath, '-Fo', '\"');
|
||||||
opt:=opt + ' ' +BreakPathsStringToOption(Libraries, '-Fl', '\"');
|
opt:=opt + ' ' +BreakPathsStringToOption(Libraries, '-Fl', '\"');
|
||||||
|
optSim:=optSim + ' ' +BreakPathsStringToOption(OtherUnitFiles, '-Fu', '\"');
|
||||||
|
optSim:=optSim + ' ' +BreakPathsStringToOption(IncludePath, '-Fi', '\"');
|
||||||
|
optSim:=optSim + ' ' +BreakPathsStringToOption(ObjectPath, '-Fo', '\"');
|
||||||
|
optSim:=optSim + ' ' +BreakPathsStringToOption(Libraries, '-Fl', '\"');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
build.Values['FPC_CUSTOM_OPTIONS'] :='"'+opt+'"';
|
build.Add('FPC_CUSTOM_OPTIONS','"'+opt+'"');
|
||||||
|
build.Add('"FPC_CUSTOM_OPTIONS[sdk=iphonesimulator*]"','"'+optSim+'"');
|
||||||
|
|
||||||
dir:=ResolveProjectPath('xcode');
|
dir:=ResolveProjectPath('xcode');
|
||||||
dir:=dir+'/';
|
dir:=dir+'/';
|
||||||
|
@ -21,7 +21,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, contnrs;
|
Classes, SysUtils, contnrs;
|
||||||
|
|
||||||
procedure PrepareTemplateFile(Src, TemplateValues, BuildSettings: TStrings);
|
procedure PrepareTemplateFile(Src, TemplateValues: TStrings; BuildSettings: TFPStringHashTable);
|
||||||
|
|
||||||
const
|
const
|
||||||
XCodeProjectTemplateIconID : AnsiString ='0AE3FFA610F3C9AF00A9B007,';
|
XCodeProjectTemplateIconID : AnsiString ='0AE3FFA610F3C9AF00A9B007,';
|
||||||
@ -137,11 +137,14 @@ const
|
|||||||
' isa = XCBuildConfiguration;'#10+
|
' isa = XCBuildConfiguration;'#10+
|
||||||
' buildSettings = {'#10+
|
' buildSettings = {'#10+
|
||||||
' ARCHS = "$(ARCHS_STANDARD_32_BIT)";'#10+
|
' ARCHS = "$(ARCHS_STANDARD_32_BIT)";'#10+
|
||||||
|
' "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD_32_BIT)";'#10+
|
||||||
' COPY_PHASE_STRIP = YES;'#10+
|
' COPY_PHASE_STRIP = YES;'#10+
|
||||||
' FPC_OUTPUT_FILE = $BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH;'#10+
|
' FPC_OUTPUT_FILE = $BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH;'#10+
|
||||||
' FPC_COMPILER_OPTIONS = "-Parm -o$FPC_OUTPUT_FILE $FPC_CUSTOM_OPTIONS";'#10+
|
' FPC_COMPILER_OPTIONS = "-Parm -o$FPC_OUTPUT_FILE $FPC_CUSTOM_OPTIONS";'#10+
|
||||||
|
' "FPC_COMPILER_OPTIONS[sdk=iphonesimulator*]" = "-Tiphonesim -Pi386 -o$FPC_OUTPUT_FILE $FPC_CUSTOM_OPTIONS";'#10+
|
||||||
' FPC_COMPILER_PATH = ;'#10+
|
' FPC_COMPILER_PATH = ;'#10+
|
||||||
' FPC_CUSTOM_OPTIONS = ;'#10+
|
' FPC_CUSTOM_OPTIONS = ;'#10+
|
||||||
|
' "FPC_CUSTOM_OPTIONS[sdk=iphonesimulator*]" = ;'#10+
|
||||||
' FPC_MAIN_FILE = ;'#10+
|
' FPC_MAIN_FILE = ;'#10+
|
||||||
' SDKROOT = iphoneos2.0;'#10+
|
' SDKROOT = iphoneos2.0;'#10+
|
||||||
' VALID_ARCHS = "armv6 armv7";'#10+
|
' VALID_ARCHS = "armv6 armv7";'#10+
|
||||||
@ -201,17 +204,24 @@ implementation
|
|||||||
function GetValueName(const Source: String; idx: Integer): String;
|
function GetValueName(const Source: String; idx: Integer): String;
|
||||||
var
|
var
|
||||||
i : integer;
|
i : integer;
|
||||||
|
InQuote: boolean;
|
||||||
const
|
const
|
||||||
//todo: expand symbols charset
|
//todo: expand symbols charset
|
||||||
Symbols: set of char = [#9, #32, #10,#13,
|
Symbols: set of char = [#9, #32, #10,#13,
|
||||||
'=',':',';','-','+','*','/','\','!','@','#',
|
'=',':',';','-','+','*','/','\','!','@','#',
|
||||||
'$','%','^','&','(',')','~','`','''','"' ];
|
'$','%','^','&','(',')','~','`',''''];
|
||||||
begin
|
begin
|
||||||
for i:=idx to length(Source) do
|
InQuote:=false;
|
||||||
if Source[i] in Symbols then begin
|
for i:=idx to length(Source) do begin
|
||||||
|
if InQuote then begin
|
||||||
|
if Source[i]='"' then InQuote := false;
|
||||||
|
end else if Source[i] = '"' then
|
||||||
|
InQuote := true
|
||||||
|
else if Source[i] in Symbols then begin
|
||||||
Result:=Copy(Source, idx, i-idx);
|
Result:=Copy(Source, idx, i-idx);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
Result:=Copy(Source, idx, length(Source)-idx+1);
|
Result:=Copy(Source, idx, length(Source)-idx+1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -234,13 +244,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure PrepareTemplateFile(Src, TemplateValues, BuildSettings: TStrings);
|
procedure PrepareTemplateFile(Src, TemplateValues: TStrings; BuildSettings: TFPStringHashTable);
|
||||||
//todo: Better code to update XCode project file!
|
//todo: Better code to update XCode project file!
|
||||||
var
|
var
|
||||||
i, j : Integer;
|
i, j : Integer;
|
||||||
nm, s, v : String;
|
nm, s, v : String;
|
||||||
isSettings : Boolean;
|
isSettings : Boolean;
|
||||||
buildhash : TFPStringHashTable;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if not Assigned(Src) then Exit;
|
if not Assigned(Src) then Exit;
|
||||||
@ -252,10 +261,6 @@ begin
|
|||||||
isSettings:=false;
|
isSettings:=false;
|
||||||
|
|
||||||
if Assigned(BuildSettings) and (BuildSettings.Count>0) then begin
|
if Assigned(BuildSettings) and (BuildSettings.Count>0) then begin
|
||||||
buildhash := TFPStringHashTable.Create;
|
|
||||||
|
|
||||||
for i :=0 to BuildSettings.Count-1 do
|
|
||||||
buildhash.Add(BuildSettings.Names[i], BuildSettings.ValueFromIndex[i]);
|
|
||||||
|
|
||||||
for i:=0 to Src.Count-1 do begin
|
for i:=0 to Src.Count-1 do begin
|
||||||
if not isSettings then
|
if not isSettings then
|
||||||
@ -271,14 +276,13 @@ begin
|
|||||||
|
|
||||||
nm:=GetValueName(s, j);
|
nm:=GetValueName(s, j);
|
||||||
|
|
||||||
if Assigned(buildhash.Find(nm)) then begin
|
if Assigned(BuildSettings.Find(nm)) then begin
|
||||||
v:=buildhash.Items[nm];
|
v:=BuildSettings.Items[nm];
|
||||||
Src[i]:=Copy(Src[i], 1, j-1)+nm+ ' = ' + v + ';';
|
Src[i]:=Copy(Src[i], 1, j-1)+nm+ ' = ' + v + ';';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end; {of else}
|
end; {of else}
|
||||||
end;
|
end;
|
||||||
buildhash.Free;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user