1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
|
;**********************************************************************
; We don't use the INNO Setup preprocessor. It is unfortunately quite buggy.
; So, this script must be preprocessed by our own tools.
; The preprocessor will replace anything enclosed in percent characters
; by the value specified in it's config file. Standard there are only
; the following things;
; FPCVERSION Version of FPC.
; BUILDDIR Build directory.
;**********************************************************************
;
; ISS Build script generated on %BUILDDATE% - %BUILDTIME%
;
[Setup]
AppName=Free Pascal Android
OutputBaseFilename=fpc-setup
; this must match with the main installer
AppID=FreePascal
AppVerName=Free Pascal Android %FPCVERSION%
AppPublisher=Free Pascal Team
AppPublisherURL=http://www.freepascal.org/
AppSupportURL=http://www.freepascal.org/
AppUpdatesURL=http://www.freepascal.org/
DefaultDirName={sd}\FPC\%FPCVERSION%
DefaultGroupName=Free Pascal
AllowNoIcons=yes
; InfoAfterFile=doc\fpc\whatsnew.txt
Compression=lzma/max
SolidCompression=true
SourceDir=%BUILDDIR%
InternalCompressLevel=max
AppCopyright=GPL
AppendDefaultDirName=false
AlwaysShowComponentsList=false
ShowLanguageDialog=yes
UsePreviousAppDir=yes
; for the addon installer
CreateUninstallRegKey=no
UpdateUninstallLogAppName=no
[Files]
; Cross compilers
Source: bin\i386-win32\ppcrossarm.exe; DestDir: {app}\bin\i386-win32; Flags: ignoreversion; Components: base
Source: bin\i386-win32\ppcrossa64.exe; DestDir: {app}\bin\i386-win32; Flags: ignoreversion; Components: base
Source: bin\i386-win32\ppcross386.exe; DestDir: {app}\bin\i386-win32; Flags: ignoreversion; Components: base
Source: bin\i386-win32\ppcrossx64.exe; DestDir: {app}\bin\i386-win32; Flags: ignoreversion; Components: base
Source: bin\i386-win32\ppcrossmipsel.exe; DestDir: {app}\bin\i386-win32; Flags: ignoreversion; Components: base
; Include license and readme files, so they are available even if somebody installs this package alone though
; it will not result in a working fpc installation
Source: doc\fpc\COPYING; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist; Components: base
Source: doc\fpc\copying.dj; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist; Components: base
Source: doc\fpc\copying.emx; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist; Components: base
Source: doc\fpc\copying.fpc; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist; Components: base
Source: doc\fpc\copying.rsx; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist; Components: base
Source: doc\fpc\COPYING.v2; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist; Components: base
Source: doc\fpc\COPYING.v3; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist; Components: base
Source: doc\fpc\faq.txt; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist; Components: base
Source: doc\fpc\faq.htm; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist; Components: base
Source: doc\fpc\licensez.ip; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist; Components: base
Source: doc\fpc\readme.txt; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist isreadme; Components: base
Source: doc\fpc\whatsnew.txt; DestDir: {app}\doc\fpc; Flags: onlyifdoesntexist; Components: base
; arm
Source: units\armv5t-android\*.*; DestDir: {app}\units\arm-android; Flags: ignoreversion recursesubdirs sortfilesbyextension solidbreak; Components: units_arm\arm
Source: fpmkinst\armv5t-android\*.*; DestDir: {app}\fpmkinst\arm-android; Flags: ignoreversion recursesubdirs solidbreak; Components: units_arm\arm
; arm-v7a
Source: units\armv7a-android\*.*; DestDir: {app}\units\arm-android; Flags: ignoreversion recursesubdirs sortfilesbyextension solidbreak; Components: units_arm\armv7a
Source: fpmkinst\armv7a-android\*.*; DestDir: {app}\fpmkinst\arm-android; Flags: ignoreversion recursesubdirs solidbreak; Components: units_arm\armv7a
; aarch64
Source: units\aarch64-android\*.*; DestDir: {app}\units\aarch64-android; Flags: ignoreversion recursesubdirs sortfilesbyextension solidbreak; Components: units_arm64
Source: fpmkinst\aarch64-android\*.*; DestDir: {app}\fpmkinst\aarch64-android; Flags: ignoreversion recursesubdirs solidbreak; Components: units_arm64
; i386
Source: units\i386-android\*.*; DestDir: {app}\units\i386-android; Flags: ignoreversion recursesubdirs sortfilesbyextension solidbreak; Components: units_x86
Source: fpmkinst\i386-android\*.*; DestDir: {app}\fpmkinst\i386-android; Flags: ignoreversion recursesubdirs solidbreak; Components: units_x86
; x86_64
Source: units\x86_64-android\*.*; DestDir: {app}\units\x86_64-android; Flags: ignoreversion recursesubdirs sortfilesbyextension solidbreak; Components: units_x86_64
Source: fpmkinst\x86_64-android\*.*; DestDir: {app}\fpmkinst\x86_64-android; Flags: ignoreversion recursesubdirs solidbreak; Components: units_x86_64
; mipsel
Source: units\mipsel-android\*.*; DestDir: {app}\units\mipsel-android; Flags: ignoreversion recursesubdirs sortfilesbyextension solidbreak; Components: units_mips
Source: fpmkinst\mipsel-android\*.*; DestDir: {app}\fpmkinst\mipsel-android; Flags: ignoreversion recursesubdirs solidbreak; Components: units_mips
[Components]
Name: base; Description: "Free Pascal cross compilers for Android"; Flags: fixed; Types: Custom Minimum Full
Name: units_arm; Description: "Units for ARM CPU"; Types: Full Custom
Name: units_arm\armv7a; Description: "ARMv7a with VFPv3 FPU"; Flags: exclusive; Types: Full Custom
Name: units_arm\arm; Description: "ARMv5 with soft FPU (support for legacy Android devices)"; Flags: exclusive;
Name: units_arm64; Description: "Units for ARM64 CPU"; Types: Full Custom
Name: units_x86; Description: "Units for x86 CPU"; Types: Full Custom
Name: units_x86_64; Description: "Units for x86_64 CPU"; Types: Full Custom
Name: units_mips; Description: "Units for MIPS CPU"; Types: Full
[Types]
Name: Custom; Description: Custom installation; Flags: iscustom
Name: Full; Description: Full installation
Name: Minimum; Description: Minimum installation
[Code]
const
ArchCount = 5;
type
TArchInfo = record
Arch: string;
CPUDef: string;
UtilsPrefix: string;
ToolchainDir: string;
LibBits: string;
UtilsPath: string;
LibPath: string;
ApiLevel: integer;
end;
var
NdkPathPage: TInputDirWizardPage;
NdkPath: string;
Archs: array[1..5] of TArchInfo;
procedure InitializeWizard;
begin
NdkPathPage:=CreateInputDirPage(wpSelectProgramGroup, 'Android NDK', 'Where Android NDK files are located?', 'Select a path where Android NDK files are located:', False, 'NewFolder');
NdkPathPage.Add('');
NdkPath:=GetPreviousData('NdkPath', '');
NdkPathPage.Values[0]:=NdkPath;
Archs[1].Arch:='arm';
Archs[1].CPUDef:='arm';
Archs[1].UtilsPrefix:='arm-linux-androideabi';
Archs[1].ToolchainDir:='arm-linux-androideabi';
Archs[2].Arch:='arm64';
Archs[2].CPUDef:='aarch64';
Archs[2].UtilsPrefix:='aarch64-linux-android';
Archs[2].ToolchainDir:='aarch64-linux-android';
Archs[3].Arch:='x86';
Archs[3].CPUDef:='i386';
Archs[3].UtilsPrefix:='i686-linux-android';
Archs[3].ToolchainDir:='x86';
Archs[4].Arch:='x86_64';
Archs[4].CPUDef:='x86_64';
Archs[4].UtilsPrefix:='x86_64-linux-android';
Archs[4].ToolchainDir:='x86_64';
Archs[4].LibBits:='64';
Archs[5].Arch:='mips';
Archs[5].CPUDef:='mips32';
Archs[5].UtilsPrefix:='mipsel-linux-android';
Archs[5].ToolchainDir:='mipsel-linux-android';
end;
function FindNdkBinUtils: boolean;
var
sr: TFindRec;
dir, p: string;
res: boolean;
i: integer;
begin
for i:=1 to ArchCount do begin
Archs[i].UtilsPath:='';
dir:=NdkPath + 'toolchains\';
res:=FindFirst(dir + Archs[i].ToolchainDir + '-*.*', sr);
while res do begin
if sr.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then begin
p:=dir + sr.Name + '\prebuilt\windows\bin';
if FileExists(p + '\' + Archs[i].UtilsPrefix + '-ld.bfd.exe') then
Archs[i].UtilsPath:=p
else
if IsWin64 then begin
p:=dir + sr.Name + '\prebuilt\windows-x86_64\bin';
if FileExists(p + '\' + Archs[i].UtilsPrefix + '-ld.bfd.exe') then
Archs[i].UtilsPath:=p;
end;
if Archs[i].UtilsPath <> '' then
break;
end;
res:=FindNext(sr);
end;
FindClose(sr);
if (Archs[i].UtilsPath = '') and IsComponentSelected('units_' + Archs[i].Arch) then begin
MsgBox('Unable to find NDK binutils for "' + Archs[i].UtilsPrefix + '".', mbError, MB_OK);
Result:=False;
exit;
end;
end;
Result:=True;
end;
function FindNdkLibPath: boolean;
var
sr: TFindRec;
dir, p: string;
res: boolean;
i, api: integer;
begin
for i:=1 to ArchCount do begin
Archs[i].ApiLevel:=0;
Archs[i].LibPath:='';
end;
dir:=NdkPath + 'platforms\';
res:=FindFirst(dir + 'android-*', sr);
while res do begin
if sr.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then begin
api:=StrToIntDef(Copy(sr.Name, 9, 6), 0);
for i:=1 to ArchCount do begin
if api > Archs[i].ApiLevel then begin
p:=dir + sr.Name + '\arch-' + Archs[i].Arch + '\usr\lib' + Archs[i].LibBits;
if FileExists(p + '\crtbegin_so.o') then begin
Archs[i].LibPath:=p;
Archs[i].ApiLevel:=api;
end;
end;
end;
end;
res:=FindNext(sr);
end;
FindClose(sr);
for i:=1 to ArchCount do
if (Archs[i].LibPath = '') and IsComponentSelected('units_' + Archs[i].Arch) then begin
MsgBox('Unable to find NDK libraries for the "' + Archs[i].Arch + '" CPU target.', mbError, MB_OK);
Result:=False;
exit;
end;
Result:=True;
end;
function NextButtonClick(CurPage: Integer): Boolean;
begin
Result:=True;
if CurPage = NdkPathPage.ID then begin
NdkPath:=Trim(NdkPathPage.Values[0])
Result:=NdkPath <> '';
NdkPath:=AddBackslash(NdkPath);
if not Result then begin
MsgBox('Please select an NDK path.', mbError, MB_OK);
exit;
end;
Result:=False;
// Quck check for NDK
if not DirExists(NdkPath + 'platforms') or not DirExists(NdkPath + 'toolchains') then begin
MsgBox('The selected path does not point to an Android NDK.', mbError, MB_OK);
exit;
end;
// Find libs
if not FindNdkLibPath then
exit;
// Find binutils
if not FindNdkBinUtils then
exit;
Result:=True;
end;
end;
const
strStartConf = '# --- Android NDK config begin ---';
strEndConf = '# --- Android NDK config end ---';
procedure WriteConfig;
var
conf, nconf: TStringList;
fn: string;
i, j, idx: integer;
begin
fn:=ExpandConstant('{app}\bin\i386-win32\fpc.cfg');
nconf:=nil;
conf:=TStringList.Create;
try
if FileExists(fn) then
conf.LoadFromFile(fn);
i:=conf.IndexOf(strStartConf);
j:=conf.IndexOf(strEndConf);
if (i >= 0) and (j >= 0) and (i < j) then begin
// Delete existing config
for j:=j downto i do
conf.Delete(i);
end
else
if i >= 0 then
conf.Delete(i)
else
if j >= 0 then begin
i:=j;
conf.Delete(i);
end
else
i:=conf.Count;
if Trim(conf.Text) = '' then
// Add path to units if the config is empty
conf.Add(ExpandConstant('-Fu{app}\units\$fpctarget\*'));
if (i > 0) and (Trim(conf[i - 1]) <> '') then begin
conf.Insert(i, '');
i:=i + 1;
end;
if (i < conf.Count) and (Trim(conf[i]) <> '') then
conf.Insert(i, '');
idx:=i;
// NDK config
nconf:=TStringList.Create;
nconf.Add(strStartConf);
nconf.Add('');
nconf.Add('#ifdef android');
for i:=1 to ArchCount do begin
if (Archs[i].UtilsPath = '') or (Archs[i].LibPath = '') then
continue;
nconf.Add(' #ifdef cpu' + Archs[i].CPUDef);
if (Archs[i].CPUDef = 'arm') and IsComponentSelected('units_arm\armv7a') then begin
nconf.Add(' # Use CPU armv7a and FPU vfpv3-d16 since corresponding units are installed');
nconf.Add(' -Cparmv7a');
nconf.Add(' -Cfvfpv3_d16');
end;
nconf.Add(' -Fl' + Archs[i].LibPath);
nconf.Add(' -FD' + Archs[i].UtilsPath);
nconf.Add(' #endif');
end;
nconf.Add('#endif');
nconf.Add('');
nconf.Add(strEndConf);
for j:=nconf.Count - 1 downto 0 do
conf.Insert(idx, nconf[j]);
conf.SaveToFile(fn);
finally
conf.Free;
nconf.Free;
end;
// Save NDK path
if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FreePascal_is1') then
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FreePascal_is1',
'Inno Setup CodeFile: NdkPath', NdkPath);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then begin
WriteConfig;
end;
end;
|