iphonelazext: added support for iphone resouce files (sim only)

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1147 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2010-01-29 15:27:06 +00:00
parent 79dfe275b2
commit 469e43fa0e
7 changed files with 169 additions and 16 deletions

View File

@ -41,9 +41,11 @@ type
procedure FillBunldeInfo(forSimulator: Boolean; var info: TiPhoneBundleInfo); procedure FillBunldeInfo(forSimulator: Boolean; var info: TiPhoneBundleInfo);
procedure InstallAppToSim; procedure InstallAppToSim;
function FixCustomOptions(const Options: String; isRealDevice: Boolean): String; function FixCustomOptions(const Options: String; isRealDevice: Boolean): String;
function WriteIconTo(const FullName: String): Boolean;
function ProjectBuilding(Sender: TObject): TModalResult; function ProjectBuilding(Sender: TObject): TModalResult;
function ProjectOpened(Sender: TObject; AProject: TLazProject): TModalResult; function ProjectOpened(Sender: TObject; AProject: TLazProject): TModalResult;
function WriteIconTo(const FullName: String): Boolean;
procedure OnProjOptionsChanged(Sender: TObject); procedure OnProjOptionsChanged(Sender: TObject);
public public
isiPhoneMenu :TIDEMenuCommand; isiPhoneMenu :TIDEMenuCommand;
@ -119,6 +121,12 @@ begin
WriteIconTo( IncludeTrailingPathDelimiter(bundlepath)+'Icon.png'); WriteIconTo( IncludeTrailingPathDelimiter(bundlepath)+'Icon.png');
CopySymLinks(
ResolveProjectPath(ProjOptions.ResourceDir),
bundlepath,
ProjOptions.ExcludeMask
);
if nm<>'' then begin if nm<>'' then begin
symlink:=UTF8Encode(exepath); symlink:=UTF8Encode(exepath);
FpUnlink(symlink); FpUnlink(symlink);
@ -426,8 +434,10 @@ var
begin begin
t :=TProcess.Create(nil); t :=TProcess.Create(nil);
try try
//ProjectBuilding(nil);
path:=IncludeTrailingPathDelimiter(EnvOptions.SimBundle)+'Contents/MacOS/iPhone Simulator'; path:=IncludeTrailingPathDelimiter(EnvOptions.SimBundle)+'Contents/MacOS/iPhone Simulator';
t.CommandLine:='"'+path+'"'; t.CommandLine:='"'+path+'"';
t.CurrentDirectory:=UTF8Encode(GetSandBoxDir(ProjOptions.SpaceName));
t.Execute; t.Execute;
except except
on E: Exception do on E: Exception do

View File

@ -52,6 +52,8 @@ function WriteDefInfoList(const InfoFileName, BundleName, ExeName: WideString; c
procedure CreateBundle(const BundleName, ExeName: WideString; const Info: TiPhoneBundleInfo; var FullBundlePath, FullExeName: WideString); procedure CreateBundle(const BundleName, ExeName: WideString; const Info: TiPhoneBundleInfo; var FullBundlePath, FullExeName: WideString);
procedure CreateBundle(const BundleName, SpaceName, ExeName: WideString; const Info: TiPhoneBundleInfo; var RealSpace, FullBundlePath, FullExeName: WideString); procedure CreateBundle(const BundleName, SpaceName, ExeName: WideString; const Info: TiPhoneBundleInfo; var RealSpace, FullBundlePath, FullExeName: WideString);
function GetBundleFullDir(const BundleName, SpaceName: WideString): WideString;
function GetSandBoxDir(const SpaceName: WideString): WideString;
function AddPathDelim(const w: WideString): WideString; function AddPathDelim(const w: WideString): WideString;
@ -88,6 +90,32 @@ begin
WriteDefInfoList(appdir+'Info.plist', BundleName, ExeName, Info); WriteDefInfoList(appdir+'Info.plist', BundleName, ExeName, Info);
end; end;
function GetBundleFullDir(const BundleName, SpaceName: WideString): WideString;
var
path8 : String;
space8 : String;
p : string;
begin
path8:=UTF8Encode(GetiPhoneSimUserPath);
space8:=UTF8Encode(SpaceName);
p:=IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(path8)+space8);
Result:=UTF8Decode(p+UTF8Encode(BundleName)+'.app');
end;
function GetSandBoxDir(const SpaceName: WideString): WideString;
var
path8 : String;
space8 : String;
p : string;
begin
path8:=UTF8Encode(GetiPhoneSimUserPath);
space8:=UTF8Encode(SpaceName);
p:=IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(path8)+space8);
Result:=UTF8Decode(p);
end;
procedure CreateBundle(const BundleName, ExeName: WideString; const Info: TiPhoneBundleInfo; var FullBundlePath, FullExeName: WideString); procedure CreateBundle(const BundleName, ExeName: WideString; const Info: TiPhoneBundleInfo; var FullBundlePath, FullExeName: WideString);
var var
sp : WideString; sp : WideString;

View File

@ -33,6 +33,8 @@ type
fSDK : string; fSDK : string;
DataWritten : Boolean; DataWritten : Boolean;
fSpaceName : string; fSpaceName : string;
fResourceDir : string;
fExcludeMask : string;
public public
constructor Create; constructor Create;
class function GetGroupCaption: string; override; class function GetGroupCaption: string; override;
@ -44,6 +46,8 @@ type
property SDK: string read fSDK write fSDK; property SDK: string read fSDK write fSDK;
property AppID: string read fAppID write fAppID; property AppID: string read fAppID write fAppID;
property SpaceName: string read fSpaceName write fSpaceName; property SpaceName: string read fSpaceName write fSpaceName;
property ResourceDir: string read fResourceDir write fResourceDir;
property ExcludeMask: string read fExcludeMask write fExcludeMask;
end; end;
{ TiPhoneEnvironmentOptions } { TiPhoneEnvironmentOptions }
@ -126,7 +130,8 @@ const
optSDK = 'iPhone/SDK'; optSDK = 'iPhone/SDK';
optAppID = 'iPhone/AppID'; optAppID = 'iPhone/AppID';
optSpaceName = 'iPhone/SimSpaceName'; optSpaceName = 'iPhone/SimSpaceName';
optResourceDir = 'iPhone/ResourceDir';
optExcludeMask = 'iPhone/ExcludeMask';
function EnvOptions: TiPhoneEnvironmentOptions; function EnvOptions: TiPhoneEnvironmentOptions;
begin begin
@ -373,6 +378,8 @@ begin
if CustomData.Contains(optAppID) then fAppID:=CustomData.Values[optAppID]; if CustomData.Contains(optAppID) then fAppID:=CustomData.Values[optAppID];
fSpaceName:=CustomData.Values[optSpaceName]; fSpaceName:=CustomData.Values[optSpaceName];
if fSpaceName='' then fSpaceName:=RandomSpaceName; if fSpaceName='' then fSpaceName:=RandomSpaceName;
if CustomData.Contains(optResourceDir) then fResourceDir:=CustomData.Values[optResourceDir];
if CustomData.Contains(optExcludeMask) then fExcludeMask:=CustomData.Values[optExcludeMask];
end; end;
end; end;
@ -388,6 +395,8 @@ begin
CustomData.Values[optSDK]:=fSDK; CustomData.Values[optSDK]:=fSDK;
CustomData.Values[optAppID]:=fAppID; CustomData.Values[optAppID]:=fAppID;
CustomData.Values[optSpaceName]:=fSpaceName; CustomData.Values[optSpaceName]:=fSpaceName;
CustomData.Values[optResourceDir]:=fResourceDir;
CustomData.Values[optExcludeMask]:=fExcludeMask;
end; end;
end; end;
@ -452,7 +461,6 @@ var
end; end;
begin begin
writeln('scan for SDK');
Result:=Assigned(FoundProc); Result:=Assigned(FoundProc);
if not Result then Exit; if not Result then Exit;

View File

@ -19,7 +19,8 @@ unit lazfilesutils;
interface interface
uses uses
Classes, SysUtils, FileUtil, {$ifdef Unix}BaseUnix,{$endif}
Classes, SysUtils, FileUtil, Masks,
LazIDEIntf,ProjectIntf; LazIDEIntf,ProjectIntf;
@ -30,8 +31,53 @@ function BreakPathsStringToOption(const Paths, Switch: String; const Quotes: str
function RelativeToFullPath(const BasePath, Relative: string): String; function RelativeToFullPath(const BasePath, Relative: string): String;
function NeedQuotes(const path: string): Boolean; function NeedQuotes(const path: string): Boolean;
function CopySymLinks(const SrcDir, DstDir, FilterMask: string): Boolean;
implementation implementation
{$ifdef Unix}
function CopySymLinks(const SrcDir, DstDir, FilterMask: string): Boolean;
var
allfiles : TStringList;
i : Integer;
pth : string;
MaskList : TMaskList;
curdir : string;
linkdir : string;
linkname : string;
begin
Result:=DirectoryExistsUTF8(SrcDir) and ForceDirectoriesUTF8(DstDir);
if not Result then Exit;
//todo: don't use FindAllFiles(), use sub dir search
allfiles:=FindAllFiles(SrcDir, AllFilesMask, False);
Result:=Assigned(allfiles);
if not Result then Exit;
MaskList := TMaskList.Create(FilterMask);
curdir:=IncludeTrailingPathDelimiter(SrcDir);
linkdir:=IncludeTrailingPathDelimiter(DstDir);
for i:=0 to allfiles.Count-1 do begin
pth:=allfiles[i];
if (FilterMask='') or (not MaskList.Matches(pth)) then begin
linkname:=linkdir+Copy(pth, length(curdir), length(pth));
writeln('link from: ', pth);
writeln(' to: ', linkname);
fpSymlink(PAnsiChar(pth), PAnsiChar(linkname));
end;
end;
allfiles.Free;
end;
{$else}
function CopySymLinks(const SrcDir, DstDir, FilterMask: string): Boolean;
begin
Result:=false;
end;
{$endif}
function GetNextDir(const Path: string; var index: integer; var Name: string): Boolean; function GetNextDir(const Path: string; var index: integer; var Name: string): Boolean;
var var
i : Integer; i : Integer;

View File

@ -60,12 +60,49 @@ inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor
Style = csDropDownList Style = csDropDownList
TabOrder = 2 TabOrder = 2
end end
object lblXibFiles: TLabel[6] object edtResDir: TEdit[6]
Left = 120
Height = 22
Top = 176
Width = 480
Anchors = [akTop, akLeft, akRight]
TabOrder = 3
Text = 'Resources'
end
object Label1: TLabel[7]
Left = 16 Left = 16
Height = 18 Height = 18
Top = 168 Top = 176
Width = 219 Width = 89
Caption = '.XIB files might appear here soon...' Caption = 'Resources dir:'
ParentColor = False ParentColor = False
end end
object edtExclude: TEdit[8]
Left = 120
Height = 22
Top = 224
Width = 480
Anchors = [akTop, akLeft, akRight]
OnChange = edtExcludeChange
TabOrder = 4
Text = '.svn'
end
object Label2: TLabel[9]
Left = 16
Height = 18
Top = 224
Width = 81
Caption = 'Ignore mask:'
ParentColor = False
end
object Label3: TLabel[10]
Left = 16
Height = 14
Top = 200
Width = 364
Caption = 'It''s recommended to set resource dir as a relative (to project .lpr file) path'
Font.Height = -10
ParentColor = False
ParentFont = False
end
end end

View File

@ -18,7 +18,17 @@ LazarusResources.Add('TiPhoneProjectOptionsEditor','FORMDATA',[
+#2'3'#5'Width'#2'P'#7'Caption'#6#12'SDK version:'#11'ParentColor'#8#0#0#242#2 +#2'3'#5'Width'#2'P'#7'Caption'#6#12'SDK version:'#11'ParentColor'#8#0#0#242#2
+#5#9'TComboBox'#7'cmbSDKs'#4'Left'#2'p'#6'Height'#2#20#3'Top'#2'0'#5'Width'#3 +#5#9'TComboBox'#7'cmbSDKs'#4'Left'#2'p'#6'Height'#2#20#3'Top'#2'0'#5'Width'#3
+#184#0#10'ItemHeight'#2#0#8'OnChange'#7#13'cmbSDKsChange'#5'Style'#7#14'csDr' +#184#0#10'ItemHeight'#2#0#8'OnChange'#7#13'cmbSDKsChange'#5'Style'#7#14'csDr'
+'opDownList'#8'TabOrder'#2#2#0#0#242#2#6#6'TLabel'#11'lblXibFiles'#4'Left'#2 +'opDownList'#8'TabOrder'#2#2#0#0#242#2#6#5'TEdit'#9'edtResDir'#4'Left'#2'x'#6
+#16#6'Height'#2#18#3'Top'#3#168#0#5'Width'#3#219#0#7'Caption'#6'$.XIB files ' +'Height'#2#22#3'Top'#3#176#0#5'Width'#3#224#1#7'Anchors'#11#5'akTop'#6'akLef'
+'might appear here soon...'#11'ParentColor'#8#0#0#0 +'t'#7'akRight'#0#8'TabOrder'#2#3#4'Text'#6#9'Resources'#0#0#242#2#7#6'TLabel'
+#6'Label1'#4'Left'#2#16#6'Height'#2#18#3'Top'#3#176#0#5'Width'#2'Y'#7'Captio'
+'n'#6#14'Resources dir:'#11'ParentColor'#8#0#0#242#2#8#5'TEdit'#10'edtExclud'
+'e'#4'Left'#2'x'#6'Height'#2#22#3'Top'#3#224#0#5'Width'#3#224#1#7'Anchors'#11
+#5'akTop'#6'akLeft'#7'akRight'#0#8'OnChange'#7#16'edtExcludeChange'#8'TabOrd'
+'er'#2#4#4'Text'#6#4'.svn'#0#0#242#2#9#6'TLabel'#6'Label2'#4'Left'#2#16#6'He'
+'ight'#2#18#3'Top'#3#224#0#5'Width'#2'Q'#7'Caption'#6#12'Ignore mask:'#11'Pa'
+'rentColor'#8#0#0#242#2#10#6'TLabel'#6'Label3'#4'Left'#2#16#6'Height'#2#14#3
+'Top'#3#200#0#5'Width'#3'l'#1#7'Caption'#6'NIt''s recommended to set resourc'
+'e dir as a relative (to project .lpr file) path'#11'Font.Height'#2#246#11'P'
+'arentColor'#8#10'ParentFont'#8#0#0#0
]); ]);

View File

@ -30,12 +30,17 @@ type
TiPhoneProjectOptionsEditor = class(TAbstractIDEOptionsEditor) TiPhoneProjectOptionsEditor = class(TAbstractIDEOptionsEditor)
chkisPhone: TCheckBox; chkisPhone: TCheckBox;
cmbSDKs: TComboBox; cmbSDKs: TComboBox;
edtResDir: TEdit;
edtExclude: TEdit;
edtAppID: TEdit; edtAppID: TEdit;
lblXibFiles: TLabel; Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
lblAppID: TLabel; lblAppID: TLabel;
lblAppIDHint: TLabel; lblAppIDHint: TLabel;
lblSDKVer: TLabel; lblSDKVer: TLabel;
procedure cmbSDKsChange(Sender: TObject); procedure cmbSDKsChange(Sender: TObject);
procedure edtExcludeChange(Sender: TObject);
procedure FrameClick(Sender: TObject); procedure FrameClick(Sender: TObject);
private private
{ private declarations } { private declarations }
@ -60,6 +65,11 @@ begin
end; end;
procedure TiPhoneProjectOptionsEditor.edtExcludeChange(Sender: TObject);
begin
end;
procedure TiPhoneProjectOptionsEditor.FrameClick(Sender: TObject); procedure TiPhoneProjectOptionsEditor.FrameClick(Sender: TObject);
begin begin
@ -99,6 +109,8 @@ begin
i:=cmbSDKs.Items.IndexOf(EnvOptions.DefaultSDK); i:=cmbSDKs.Items.IndexOf(EnvOptions.DefaultSDK);
cmbSDKs.ItemIndex:=i; cmbSDKs.ItemIndex:=i;
edtAppID.Text:=AppID; edtAppID.Text:=AppID;
edtResDir.Text:=ResourceDir;
edtExclude.Text:=ExcludeMask;
end; end;
end; end;
@ -110,6 +122,8 @@ begin
isIPhoneApp:=chkisPhone.Checked; isIPhoneApp:=chkisPhone.Checked;
SDK:=cmbSDKs.Caption; SDK:=cmbSDKs.Caption;
AppID:=edtAppID.Text; AppID:=edtAppID.Text;
ResourceDir:=edtResDir.Text;
ExcludeMask:=edtExclude.Text;
Save; Save;
DoChanged; DoChanged;
end; end;