forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrevsaveasstandalone.livecodescript
More file actions
2674 lines (2299 loc) · 113 KB
/
revsaveasstandalone.livecodescript
File metadata and controls
2674 lines (2299 loc) · 113 KB
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
script "revSaveAsStandalone"
#####################################################################
# Standalone Application Builder
# @Version: 1.2.1
#
# Developed from Distribution Builder Code by Monte goulding
# @Email: [email protected]
#
# The Standalone Application Builder relies on a custom property
# set in each stack named cRevStandaloneSettings.
#
# Platform specific properties are in muti-dimensional form
# <platform>,<setting>
#
# Stacks included in the Standalone Application are the stackFiles
# of the standalone and all of their stackFiles recusively. In
# this way the file dependencies in development are transferred into
# the application without user intervention.
#
#####################################################################
private function revListFolders pPath
local tOldFolder, tFolders
put the folder into tOldFolder
set the folder to pPath
put the folders into tFolders
set the folder to tOldFolder
filter tFolders without "[.][.]" -- filter out ".." folder
return tFolders
end revListFolders
private function revListFiles pPath
local tOldFolder, tFiles
put the folder into tOldFolder
set the folder to pPath
put the files into tFiles
set the folder to tOldFolder
return tFiles
end revListFiles
local sPlatformDirectoriesA -- the list of desktop build directories
local sResetA -- stored info for resetting to the pre-build state
local sGenericNumber -- a simple counter for the generic file naming
local sStandaloneSettingsA -- a copy of the cRevStandaloneSettings of stack pFolder
local sIconA -- array for icons
local sPlatformCount -- the total number of platforms to build for
# OK-2007-08-09 : Temporary storage for list of user script libraries. This is required to support building for ialiMac OS Classic
local sUserScriptLibraries
-- list of info fields for the windows engine
constant kVersionFlds = "Comments,CompanyName,FileDescription,FileVersion,InternalName,LegalCopyright,LegalTrademarks,OriginalFilename,PrivateBuild,ProductName,ProductVersion,SpecialBuild"
# AL-2015-01-29: [[ Scriptify revSaveAsStandalone ]] Initialise script locals here to replace custom props of stack
local sWindowsMaxLengthsA
function getWindowsMaxLength pField
return sWindowsMaxLengthsA[pField]
end getWindowsMaxLength
#####################################################################
# Main public API for the Standalone Application Builder
#
# Both parameters are optional.
# @param pStack = the stack to become a standalone to build a stack other than the topStack
# @param pFolder = the build folder to avoid the script asking
#
#####################################################################
local sStubPath
# OK-2009-05-22 : Added ability to remember default folder
private function getBuildFolder pStack, pFolder, pSettings
# If the standalone builder has been passed a folder to build in from outside, we just use this.
if pFolder is not empty then
return pFolder
end if
# This means the user has chosen to build directly to the default folder without prompt (and the folder exists) so we just go for it.
if pSettings["defaultBuildFolder"] is not empty and \
pSettings["automaticallyBuildInDefaultFolder"] and \
there is a folder (pSettings["defaultBuildFolder"]) then
return pSettings["defaultBuildFolder"]
end if
# If a default folder is chosen and exists, but the user does not want to automatically build there, we
# prompt as normal, but with the difference being that we use the specified folder as the default path,
# saving browsing for it.
local tFolder
if pSettings["defaultBuildFolder"] is not empty and \
there is a folder (pSettings["defaultBuildFolder"]) then
if pStack is among the lines of the openStacks and the visible of stack pStack and \
the mode of stack pStack <= 2 then
set the defaultStack to pStack
answer folder "Choose a folder to build in:" with pSettings["defaultBuildFolder"]
else
answer folder "Choose a folder to build in:" with pSettings["defaultBuildFolder"]
end if
else
if pStack is among the lines of the openStacks and the visible of stack pStack and \
the mode of stack pStack <= 2 then
set the defaultStack to pStack
answer folder "Choose a folder to build in:"
else
answer folder "Choose a folder to build in:"
end if
end if
if it is "" or the result is "Cancel" then
--exit to top
return empty
end if
put it into tFolder
return tFolder
end getBuildFolder
on revSaveAsStandalone pStack, pFolder, pPreview, pSuppressSuccessMsg
global gREVStackStatus
if pStack = empty then
put the short name of the topStack into pStack
end if
if the fileName of stack pStack = empty then
put "edited" into gREVStackStatus[pStack]
end if
# OK-2008-03-13 : Bug 5874. Do a complete check to see if the stack needs to be saved here
# so we can remove the later check from revCloseOpenStacks.
local tEdited
put false into tEdited
# Find out if the stack or any substack has been edited
if gREVStackStatus[the short name of stack pStack] is "edited" then
put true into tEdited
else
local tSubstacks
put the substacks of stack pStack into tSubstacks
repeat for each line tSubstack in tSubstacks
if gREVStackStatus[the short name of stack tSubstack] is "edited" then
put true into tEdited
end if
end repeat
end if
local tSettings
put revSBGetSettings(pStack) into tSettings
-- MM-2014-03-21: [[ PPC Support Dropped ]] Assume all mac builds to now be Intel.
if tSettings["MacOSX"] then
delete variable tSettings["MacOSX"]
put true into tSettings["MacOSX x86-64"]
put true into tEdited
end if
if tSettings["MacOSX PowerPC-32"] then
delete variable tSettings["MacOSX PowerPC-32"]
put true into tSettings["MacOSX x86-64"]
put true into tEdited
end if
if tSettings["MacOSX x86-32"] then
delete variable tSettings["MacOSX x86-32"]
put true into tSettings["MacOSX x86-64"]
put true into tEdited
end if
-- Make sure there is actually something to build..
if revSBNoPlatforms(tSettings) then
local tMessage
put "You have not selected any platforms to build for. Please do so using Standalone Settings." into tMessage
if revSBSuppressDialogs() then
return tMessage
else
answer error tMessage
end if
exit revSaveAsStandalone
end if
# OK-2010-03-31: Ensure that the standalone name doesn't contain stuff that is not allowed in folder names,
# otherwise this could cause problems. In particular a return char at the end of the name causes the cleanup
# routines to try and delete the parent folder, which can result in data loss. The data loss potential has also
# been eliminated at a lower level by redirecting all calls to revDeleteFolder through a wrapper, which checks that
# the folder is safe to delete using some rather strict tests. This may result in ocassional problems with cleanup not
# working.
if folderNameIsIllegal(tSettings["name"]) then
put folderNameMakeLegal(tSettings["name"]) into tSettings["name"]
put true into tEdited
revStandaloneAddWarning "Standalone name was changed because it contained illegal characters"
end if
# OK-2009-05-22 : Added ability to remember default folder. We now do the folder check before saving the stack,
# so that if the user chose a different folder, it can be remembered for next time.
local tFolder
put getBuildFolder(pStack, pFolder, tSettings) into tFolder
if tFolder is empty then
exit to top
end if
# If the folder was changed, then we flag the stack as edited so it gets remembered
if tSettings["defaultBuildFolder"] is not tFolder then
put tFolder into tSettings["defaultBuildFolder"]
put true into tEdited
end if
put tFolder into pFolder
# If any have been edited, force the save dialog by setting edited on the mainstack
if tEdited then
revIDESetEdited pStack
revSBSetSettings pStack, tSettings
end if
local tError
# Do the check and continue building as normal.
if revSaveCheck(pStack) then
local tStandalonePaths
revDoSaveAsStandalone pStack, pFolder, ,tStandalonePaths
put the result into tError
else
answer warning "Saving as standalone application was canceled"
exit revSaveAsStandalone
end if
if revStandaloneGetWarnings() is not empty and tError is empty then
set the cWarnings of stack "revBuildResults" to revStandaloneGetWarnings()
else
if not revSBSuppressDialogs() and pSuppressSuccessMsg is not true and tError is empty then
answer information "Standalone application saved successfully."
end if
if pPreview is not "false" and sStubPath is not empty then
launch document sStubPath
end if
end if
return tError
end revSaveAsStandalone
command revDoSaveAsStandalone pStack, pFolder, pSettings, @xStandalonePaths
# OK-2007-12-18 : Bug 3612 Changed sGenericNumber from 1 to 0.
put 0 into sGenericNumber
lock cursor
set cursor to watch
put empty into sUserScriptLibraries
put empty into sStubPath
put the directory into sResetA["Directory"]
put the fileType into sResetA["FileType"]
if pSettings is not an array then
put revSBGetSettings(pStack) into sStandaloneSettingsA
else
put pSettings into sStandaloneSettingsA
end if
put the mainStack of stack pStack into pStack
set the defaultStack to pStack
revStandaloneResetWarnings
local tError, tStandaloneFolder
-- Don't build for any platform we are not licensed for
local tRemoved
put revSBRemoveUnlicensedTargetsFromSettings(sStandaloneSettingsA) into tRemoved
replace return with comma in tRemoved
if revSBNoPlatforms(sStandaloneSettingsA) then
local tMessage
put "You are not licensed to build for any selected platforms." into tMessage
if not revSBSuppressDialogs() then
answer error tMessage
end if
return tMessage
end if
if tRemoved is not empty then
revStandaloneAddWarning "Not licensed to build for the following selected platforms:" && tRemoved
end if
revStandaloneProgress "Preparing to build standalone..."
-- pre build message
local tHasDesktop
repeat for each item tTarget in revSBDesktopTargets()
if sStandaloneSettingsA[tTarget] then
put true into tHasDesktop
exit repeat
end if
end repeat
local tStackFileName, tRestoreFileName
if tHasDesktop then
put the effective filename of stack pStack into tStackFileName
if the mode of stack pStack > 0 then
put the long name of stack pStack & return after sResetA["Reopen"]
end if
__SendSavingStandaloneMessage pStack
--Save copy of stack in its post-savingStandalone message state
__SaveCopyOfStackInTemporaryLocation pStack, tRestoreFileName
end if
try
-- Create an appropriate output dir
local tOutputFolder
revOutputDirectories pFolder & slash
put the result into tOutputFolder
if there is no folder tOutputFolder then
create folder tOutputFolder
if the result is not empty then
throw format("Cannot create a folder '%s'", tOutputFolder)
end if
end if
local tBuildPlatforms, tPlatform
repeat for each item tTarget in revSBDesktopTargets() & comma & revSBAdditionalTargets()
if sStandaloneSettingsA[tTarget] then
put revSBTargetToPlatform(tTarget) into tPlatform
put true into tBuildPlatforms[tPlatform]
end if
end repeat
-- If we're searching for inclusions, do it here
revSearchForInclusions pStack, sStandaloneSettingsA
-- keep a copy of the standalone settings to restore after each build
local tStandaloneSettingsA
put sStandaloneSettingsA into tStandaloneSettingsA
repeat for each key tPlatform in tBuildPlatforms
put tStandaloneSettingsA into sStandaloneSettingsA
local tTargetFolder
-- If we are building for multiple platforms, then build in a platform-specific subfolder
if sPlatformCount > 1 then
put tOutputFolder & slash & tPlatform into tTargetFolder
else
put tOutputFolder into tTargetFolder
end if
-- Make sure folder exists
if tStandaloneSettingsA[tPlatform] then
revSBEnsureFolder tTargetFolder
end if
switch tPlatform
case "iOS"
if not (the platform begins with "MacOS") then
next repeat
end if
put tTargetFolder & slash & sStandaloneSettingsA["name"] & ".app" into xStandalonePaths[tPlatform]
dispatch "revSaveAsMobileStandalone" to stack "revSaveAsIOSStandalone" with \
pStack, xStandalonePaths[tPlatform], "Device", sStandaloneSettingsA
break
case "Android"
put tTargetFolder & slash & sStandaloneSettingsA["name"] & ".apk" into xStandalonePaths[tPlatform]
dispatch "revSaveAsMobileStandalone" to stack "revSaveAsAndroidStandalone" with \
pStack, xStandalonePaths[tPlatform], "Build", sStandaloneSettingsA, xStandalonePaths
break
case "Emscripten"
put tTargetFolder into xStandalonePaths[tPlatform]
dispatch "revSaveAsEmscriptenStandalone" to stack "revSaveAsEmscriptenStandalone" with \
pStack, xStandalonePaths[tPlatform], sStandaloneSettingsA, xStandalonePaths
break
case "MacOSX"
revSaveAsMacStandalone pStack, tRestoreFileName, tTargetFolder, xStandalonePaths
break
case "Windows"
revSaveAsWindowsStandalone pStack, tRestoreFileName, tTargetFolder, xStandalonePaths
break
case "Linux"
revSaveAsLinuxStandalone pStack, tRestoreFileName, tTargetFolder, xStandalonePaths
break
end switch
end repeat
-- post build message
if tHasDesktop then
__ReloadOriginalStackFile tStackFileName, pStack
__SendStandaloneSavedMessage pStack, tOutputFolder
end if
catch tError
revAbort
if word 1 of tError = "Standalone:" then
put word 2 to -1 of tError into tError
if not revSBSuppressDialogs() then
answer error word 2 to -1 of tError
end if
else
if not revSBSuppressDialogs() then
answer error "There was an error while saving the standalone application"&cr&tError
end if
end if
return tError
end try
revReset
return empty
end revDoSaveAsStandalone
private function folderNameIllegalChars
return revFolderNameIllegalChars()
end folderNameIllegalChars
private function folderNameIsIllegal pName
return revFolderNameIsIllegal(pName)
end folderNameIsIllegal
private function folderNameMakeLegal pName
return revFolderNameMakeLegal(pName)
end folderNameMakeLegal
private function revStandalonePlatformDetails pTarget
local tPlatform
put revSBTargetToPlatform(pTarget) into tPlatform
local tDetailsA
-- SN-2015-03-04: [[ IDE Restructure ]] Externals folder contains the externals,
-- and Support contains support libraries (revpdfprinter and revsecurity):
-- they should have their own keys in the details array.
local tArchFolder
switch tPlatform
case "MacOSX"
-- MM-2014-03-21: [[ PPC Support Dropped ]] We now only support intel Mac builds. Assume all mac builds to be intel.
-- MW-2013-06-13: [[ CloneAndRun ]] If not installated type, then take from the binaries folder.
put "Mac OS X/x86-64" into tArchFolder
put ".bundle" into tDetailsA["loadable_extension"]
put ".dylib" into tDetailsA["shared_extension"]
put "MacOSX" into tDetailsA["platform"]
put "x86-64" into tDetailsA["architecture"]
break
case "Windows"
if pTarget is "Windows" then
put "Windows/x86-32" into tArchFolder
put "x86-32" into tDetailsA["architecture"]
else if pTarget is "Windows x86-64" then
put "Windows/x86-64" into tArchFolder
put "x86-64" into tDetailsA["architecture"]
end if
put ".dll" into tDetailsA["loadable_extension"]
put "Windows" into tDetailsA["platform"]
break
case "Linux"
if pTarget is "Linux" then
put "Linux/x86-32" into tArchFolder
put "x86-32" into tDetailsA["architecture"]
else if pTarget is "Linux x64" then
-- MW-2013-11-06: [[ LinuxX64 ]] Compute the correct path for 64-bit linux.
put "Linux/x86-64" into tArchFolder
put "x86-64" into tDetailsA["architecture"]
else -- if pPlatform is "Linux armv6-hf" then
-- FG-2014-08-19: [[ RPi ]] Compute the correct path for 64-bit Linux
put "Linux/armv6-hf" into tArchFolder
put "armv6-hf" into tDetailsA["architecture"]
end if
put ".so" into tDetailsA["loadable_extension"]
put "Linux" into tDetailsA["platform"]
break
default
throw "invalid target" && pTarget
end switch
-- SN-2015-03-04: [[ CloneAndRun ]] Refactor the setting of externals / support location
local tRuntimeFolder
if revEnvironmentIsInstalled() then
put revEnvironmentRuntimePath() & slash & tArchFolder into tRuntimeFolder
put tRuntimeFolder & slash & "Support" into tDetailsA["support_folder"]
put tRuntimeFolder & slash & "Externals" into tDetailsA["externals_folder"]
else
put revEnvironmentBinariesPath() into tDetailsA["externals_folder"]
put revEnvironmentBinariesPath() into tDetailsA["support_folder"]
end if
return tDetailsA
end revStandalonePlatformDetails
#####################################################################
# Main use-case controller for the Standalone Application Builder
#####################################################################
command revSearchForInclusions pStack, @xSettings
if not xSettings["searchedForInclusions"] then
revSBSearchForInclusions pStack, xSettings
put true into xSettings["searchedForInclusions"]
end if
end revSearchForInclusions
private on revStandalonePreBuild pStack, pFolder, pPlatform, pArchs, @rStackName, @rStackFileList
revStandaloneProgress "Loading settings..."
-- Make sure all dependencies are included
revSBUpdateForDependencies pPlatform, pArchs, , sStandaloneSettingsA
revSBEnsurePerExtensionSettings pPlatform, sStandaloneSettingsA
if the result is not empty then
return the result
end if
local tCount
if there is a file (pFolder & "/" & sStandaloneSettingsA["name"]) then
put " Standalone" after sStandaloneSettingsA["name"]
put empty into tCount
repeat while (there is a file (pFolder & "/" & sStandaloneSettingsA["name"] & tCount) or there is a folder (pFolder & "/" & sStandaloneSettingsA["name"] & tCount))
add 1 to tCount
end repeat
put sStandaloneSettingsA["name"] & tCount into sStandaloneSettingsA["name"]
end if
local tStackFileName, tStackName
put the effective filename of stack pStack into tStackFileName
set the itemdelimiter to slash
put item -1 of tStackFileName into tStackName
local tExtension
set the itemdelimiter to "."
put item -1 of tStackName into tExtension
set the itemdelimiter to comma
if tExtension is not among the items of revIDELiveCodeFileExtensions() then
put ".livecode" after tStackName
end if
local tStackFileList
revSBRelativeStackFilesList pStack, tStackFileList
-- close the open stacks (ask to save if need be)
revCloseOpenStacks tStackFileList, pStack
set the defaultStack to the short name of stack tStackFileName
put tStackName into rStackName
put tStackFileList into rStackFileList
end revStandalonePreBuild
private on revStandalonePostBuild pStack, pFolder
end revStandalonePostBuild
private command revStandaloneCopyInclusions pStack, pStackFileList, pStackSourceFile, \
pTarget, pDirectory, pStackPath, pStandalonePath, pEngineSourceFile
-- copy resources (inclusions) to files
revCopyResources pStack, pStackFileList, pDirectory
revCopyFiles pTarget, pDirectory, pStackPath
-- copy database drivers
revCopyDatabaseDrivers pTarget, pStackSourceFile, pStandalonePath, pEngineSourceFile
-- copy externals
revCopyExternals pTarget, pStackSourceFile, pEngineSourceFile, pStandalonePath
// IM-2015-10-14: [[ BrowserWidget ]] Copy CEF files needed for the browser widget.
// IM-2014-03-20: [[ revBrowserCEF ]] Ensure CEF support files are copied if requested
local tRevBrowser, tLibBrowser
put "Browser (CEF)" is among the lines of sStandaloneSettingsA["scriptLibraries"] into tRevBrowser
put "com.livecode.widget.browser" is among the lines of sStandaloneSettingsA["extensions"] into tLibBrowser
revCopyCEFResources pTarget, pStandalonePath, tRevBrowser, tLibBrowser
end revStandaloneCopyInclusions
local sLastUsedSettingsA
function revStandaloneLastUsedSettings
return sLastUsedSettingsA
end revStandaloneLastUsedSettings
private function revStandaloneInitialDeployParams pTarget, pStackSourceFile, pStandalonePath, pEngineSourceFile
-- This array contains the parameters for the deploy command
local tDeployInfo
-- Set up file references common to all platforms
put pStackSourceFile into tDeployInfo["stackfile"]
put pStandalonePath into tDeployInfo["output"]
put pEngineSourceFile into tDeployInfo["engine"]
-- Store settings used to create deploy params
put sStandaloneSettingsA into sLastUsedSettingsA
# AL-2015-01-29: [[ Scriptify IDE ]] Add the library inclusions to the deploy parameters
revSBUpdateDeployParams pStackSourceFile, pTarget, sStandaloneSettingsA, tDeployInfo
# AL-2015-01-29: [[ Scriptify IDE ]] Add user script libraries to deploy parameters
-- PM-2015-12-07: [[ Bug 15706 ]] Put double quotes around the stack name to avoid confusing the
-- parser when the stack name is 'copy of ...'
repeat for each line tLine in sUserScriptLibraries
put return & "if there is a stack" && quote & tLine & quote && "then library" && quote & tLine & quote after tDeployInfo["startup_script"]
end repeat
return tDeployInfo
end revStandaloneInitialDeployParams
private command __SaveCopyOfStackInTemporaryLocation pStack, @rLocation
local tFilename, tTemp
put the effective filename of stack pStack into tFilename
lock messages
put the tempname into tTemp
save stack pStack as tTemp
set the filename of stack pStack to tFilename
unlock messages
put tTemp into rLocation
end __SaveCopyOfStackInTemporaryLocation
private command __RestoreStackFromTemporaryLocation pStack, pLocation, pOriginalFileName
__ReloadOriginalStackFile pLocation, pStack
set the filename of stack pStack to pOriginalFileName
end __RestoreStackFromTemporaryLocation
private command __SendSavingStandaloneMessage pStack
try
dispatch "savingStandalone" to stack pStack
end try
end __SendSavingStandaloneMessage
private command __SendStandaloneSavedMessage pStack, pFolder
if char -1 of pFolder is not slash then
put slash after pFolder
end if
try
dispatch "standaloneSaved" to stack pStack with pFolder
end try
end __SendStandaloneSavedMessage
command revSaveAsMacStandalone pStack, pRestoreFileName, pFolder, @xStandalonePaths
local tStackFileList, tEngineSourceFile, tCount, tStackName, tStandalonePath
local tDirectory, tStackSourceFile, tName, tOriginalFileName, tStackPath
local tTargetDir
set the itemDelimiter to slash
put the effective filename of stack pStack into tOriginalFileName
put item 1 to -2 of tOriginalFileName into tStackPath
-- icon and resource file relative path handling
if there is a file (tStackPath&"/" & sStandaloneSettingsA["MacOS,includeResources"]) then
put tStackPath & "/" before sStandaloneSettingsA["MacOS,includeResources"]
end if
-- OK-2008-03-24 : Bug 6171. Restructured a little to ensure that the icon can be either relative or absolute.
-- If the icon cannot be found at the exact location, assume its relative to the stack and put the stack path before it.
if sStandaloneSettingsA["OSX,iconFile"] is not empty then
if there is no file sStandaloneSettingsA["OSX,iconFile"] or \
(the folder is tStackPath and \
there is a file (the folder & "/" & sStandaloneSettingsA["OSX,iconFile"])) then
put tStackPath & "/" before sStandaloneSettingsA["OSX,iconFile"]
end if
end if
-- If the icon cannot be found (and we are building for OS X and its not empty) then add a warning.
if sStandaloneSettingsA["MACOSX"] is true and there is no file sStandaloneSettingsA["OSX,iconFile"] and sStandaloneSettingsA["OSX,iconFile"] is not empty then
revStandaloneAddWarning "Icon does not exist:" & tStackPath & "/" & sStandaloneSettingsA["OSX,iconFile"]
end if
if there is a file (tStackPath & "/" & sStandaloneSettingsA["OSX,documenticonFile"]) then
put tStackPath & "/" before sStandaloneSettingsA["OSX,documenticonFile"]
end if
if there is a file (tStackPath & "/" & sStandaloneSettingsA["OSX,plist"]) then
put tStackPath & "/" before sStandaloneSettingsA["OSX,plist"]
end if
-- Architectures
local tArchitectures
put "x86-64" into tArchitectures
-- keep a copy of the standalone settings to restore after each build
local tStandaloneSettingsA
put sStandaloneSettingsA into tStandaloneSettingsA
repeat for each key tTarget in sPlatformDirectoriesA["MacOSX"]
put sPlatformDirectoriesA["MacOSX"][tTarget] into tTargetDir
put tTargetDir & normalizeForDisk(sStandaloneSettingsA["name"]) & ".app/Contents/MacOS/" into tDirectory
-- Ensure standalone settings script local is reset when building for subsequent targets
put tStandaloneSettingsA into sStandaloneSettingsA
revStandalonePreBuild pStack, pFolder, "macosx", tArchitectures, tStackName, tStackFileList
if the result is not empty then
return the result
end if
-- copy files to each directory
-- put the path to the engine into tEngineSourceFile
put revSBEnginePath(tTarget) into tEngineSourceFile
-- Allows the test system to build a standalone against any version
if revOverrideRuntimePath() is not empty then
put revOverrideRuntimePath() into tEngineSourceFile
end if
-- Ensure executable is at the expected location
if there is not a file tEngineSourceFile then
throw "Standalone: Ensure that you have not renamed the main LiveCode executable file: " \
& return & tEngineSourceFile
end if
put tDirectory & normalizeForDisk(sStandaloneSettingsA["name"]) into tStandalonePath
put tStandalonePath into xStandalonePaths[tTarget]
put tDirectory & tStackName into tStackSourceFile
revStandaloneCopyInclusions pStack, tStackFileList, tStackSourceFile, \
tTarget, tDirectory, tStackPath, tStandalonePath, tEngineSourceFile
local tDeployInfo
put revStandaloneInitialDeployParams(tTarget, tStackSourceFile, \
tStandalonePath, tEngineSourceFile) into tDeployInfo
put tArchitectures into tDeployInfo["architectures"]
# AL-2015-01-29: [[ Scriptify IDE ]] Add OSX App icons to deploy parameters
if sStandaloneSettingsA["OSX,appicon"] is not empty then
put return & "revInternal__SetAppIcon" && sStandaloneSettingsA["OSX,appicon"] after tDeployInfo["startup_script"]
end if
if sStandaloneSettingsA["OSX,smallappicon"] is not empty then
put return & "revInternal__SetSmallAppIcon" && sStandaloneSettingsA["OSX,smallappicon"] after tDeployInfo["startup_script"]
end if
-- Add a random uuid to use in the executable's uuid load command.
put uuid() into tDeployInfo["uuid"]
revStandaloneDeployWithParams tTarget, tStackSourceFile, tDeployInfo
-- Make sure we finish off the bundle contents
revSetMacOS tStandalonePath, tTarget, tEngineSourceFile
revRedirectMacOSResources tStandalonePath
--Restore stack to its post-savingStandalone message state
__RestoreStackFromTemporaryLocation pStack, pRestoreFileName, tOriginalFileName
end repeat
if the platform is "MacOS" then
local tAppBundle
set the itemDel to slash
put item 1 to -4 of tStandalonepath into tAppBundle
set the itemDel to comma
clearExtendedAttributes tAppBundle
performAdHocCodesign tAppBundle
end if
revStandalonePostBuild pStack, pFolder
return empty
end revSaveAsMacStandalone
private command performAdHocCodesign pAppBundle
local tShell
put "codesign --deep -f -s -" && quote & pAppBundle & quote into tShell
get shell(tShell)
if the result is not zero then
throw "Adding ad-hoc signature failed with error:" && it
end if
end performAdHocCodesign
private command clearExtendedAttributes pAppBundle
local tShell
-- make sure you have permission to clear extended attributes from bundle files
put "chmod -R u+w" && quote & pAppBundle & quote into tShell
get shell(tShell)
if the result is not zero then
throw "Setting permissions failed with error:" && it
end if
put "xattr -cr" && quote & pAppBundle & quote into tShell
get shell(tShell)
if the result is not zero then
throw "Clearing extended attributes failed with error:" && it
end if
end clearExtendedAttributes
command revSaveAsWindowsStandalone pStack, pRestoreFileName, pFolder, @xStandalonePaths
local tStackFileList, tEngineSourceFile, tCount, tStackName, tStandalonePath
local tDirectory, tStackSourceFile, tName, tStackPath, tOriginalFileName
set the itemDelimiter to slash
put the effective filename of stack pStack into tOriginalFileName
put item 1 to -2 of tOriginalFileName into tStackPath
put revEnvironmentRuntimePath() & "/Windows/x86-32/Support/Sample Icons" into tName
if sStandaloneSettingsA["Windows,iconFile"] = "" then
put tName & "/genericapp.ico" into sStandaloneSettingsA["Windows,iconFile"]
end if
if sStandaloneSettingsA["Windows,documenticonFile"] = "" then
put tName & "/genericdoc.ico" into sStandaloneSettingsA["Windows,documenticonFile"]
end if
if there is a file (tStackPath&"/" & sStandaloneSettingsA["Windows,iconFile"]) then
put tStackPath & "/" before sStandaloneSettingsA["Windows,iconFile"]
end if
if there is not a file (sStandaloneSettingsA["Windows,iconFile"]) and sStandaloneSettingsA["Windows"] is true and sStandaloneSettingsA["Windows,iconFile"] is not empty then
revStandaloneAddWarning "Icon does not exist:" & sStandaloneSettingsA["Windows,iconFile"]
end if
if there is not a file sStandaloneSettingsA["Windows,iconFile"] then
put item 1 to -2 of tName & "/Sample Icons/genericapp.ico" into sStandaloneSettingsA["Windows,iconFile"]
end if
if there is a file (tStackPath & "/" & sStandaloneSettingsA["Windows,documentIconFile"]) then
put tStackPath & "/" before sStandaloneSettingsA["Windows,documentIconFile"]
end if
if there is not a file sStandaloneSettingsA["Windows,documentIconFile"] then
put item 1 to -2 of tName & "/Sample Icons/genericdoc.ico" into sStandaloneSettingsA["Windows,documenticonFile"]
end if
-- keep a copy of the standalone settings to restore after each build
local tStandaloneSettingsA
put sStandaloneSettingsA into tStandaloneSettingsA
repeat for each key tTarget in sPlatformDirectoriesA["Windows"]
put sPlatformDirectoriesA["Windows"][tTarget] into tDirectory
-- Ensure standalone settings script local is reset when building for subsequent targets
put tStandaloneSettingsA into sStandaloneSettingsA
local tArch, tRuntimeDir
if word 2 of tTarget is among the items of "x64,x86-64,x86_64" then
put "x86_64" into tArch
put "x86-64" into tRuntimeDir
else if word 2 of tTarget is not empty then
put word 2 of tTarget into tArch
put word 2 of tTarget into tRuntimeDir
else
put "x86" into tArch
put "x86-32" into tRuntimeDir
end if
revStandalonePreBuild pStack, pFolder, "windows", tArch, tStackName, tStackFileList
if the result is not empty then
return the result
end if
-- copy files to each directory
-- put the path to the engine into tEngineSourceFile
put revSBEnginePath(tTarget) into tEngineSourceFile
-- Allows the test system to build a standalone against any version
if revOverrideRuntimePath() is not empty then
put revOverrideRuntimePath() into tEngineSourceFile
end if
-- Ensure executable is at the expected location
if there is not a file tEngineSourceFile then
throw "Standalone: Ensure that you have not renamed the main LiveCode executable file: " \
& return & tEngineSourceFile
end if
put tDirectory & sStandaloneSettingsA["name"] into tStandalonePath
-- add ".exe" to windows standalone file
put ".exe" after tStandalonePath
put tStandalonePath into xStandalonePaths[tTarget]
put tDirectory & tStackName into tStackSourceFile
revStandaloneCopyInclusions pStack, tStackFileList, tStackSourceFile, \
tTarget, tDirectory, tStackPath, tStandalonePath, tEngineSourceFile
local tDeployInfo
put revStandaloneInitialDeployParams(tTarget, tStackSourceFile, \
tStandalonePath, tEngineSourceFile) into tDeployInfo
-- Set windows-specific info
-- Make sure we include the app icon if any
if sStandaloneSettingsA["Windows,iconFile"] is not empty then
put sStandaloneSettingsA["Windows,iconFile"] into tDeployInfo["appIcon"]
-- MW-2013-06-14: [[ CloneAndRun ]] Use the icon from 'rsrc' if generic.
if not revEnvironmentIsInstalled() and tDeployInfo["appIcon"] contains "genericapp.ico" then
put revEnvironmentRepositoryPath() & slash & "engine/rsrc/standalone.ico" into tDeployInfo["appIcon"]
end if
end if
-- Make sure we include the doc icon if any
if sStandaloneSettingsA["Windows,documentIconFile"] is not empty then
put sStandaloneSettingsA["Windows,documentIconFile"] into tDeployInfo["docIcon"]
-- MW-2013-06-14: [[ CloneAndRun ]] Use the icon from 'rsrc' if generic.
if not revEnvironmentIsInstalled() and tDeployInfo["docIcon"] contains "genericdoc.ico" then
put revEnvironmentRepositoryPath() & slash & "engine/rsrc/document.ico" into tDeployInfo["docIcon"]
end if
end if
-- Make sure we use the user's version info data
put sStandaloneSettingsA["Windows,fileversion1"]&"."&sStandaloneSettingsA["Windows,fileversion2"]&"." & sStandaloneSettingsA["Windows,fileversion3"]&"."&sStandaloneSettingsA["Windows,fileversion4"] into sStandaloneSettingsA["Windows,FileVersion"]
put sStandaloneSettingsA["Windows,productversion1"]&"."&sStandaloneSettingsA["Windows,productversion2"]&"." & sStandaloneSettingsA["Windows,productversion3"]&"."&sStandaloneSettingsA["Windows,productversion4"] into sStandaloneSettingsA["Windows,ProductVersion"]
set the itemDelimiter to comma
repeat for each item tField in kVersionFlds
put sStandaloneSettingsA["Windows", tField] into tDeployInfo["version"][tField]
end repeat
// IM-2014-08-15: [[ Bug 13118 ]] Split manifest sections into separate template files.
local tManifestData, tManifestPath, tManifestNeeded
put empty into tManifestData
put false into tManifestNeeded
put revEnvironmentRuntimePath() & "/Windows/" & tRuntimeDir & "/w32-manifest-template.xml" into tManifestPath
if there is not a file tManifestPath then
revStandaloneAddWarning "Windows, manifest template not found: " & quote & tManifestPath & quote
else
put url ("file:" & tManifestPath) into tManifestData
end if
# OK-2009-09-25 : UAC Manifest. If the user has choosen "default" from the drop-down, or the stack doesn't have this setting at all, we don't
# include the manifest.
local tManifestTrustInfo
put empty into tManifestTrustInfo
if sStandaloneSettingsA["Windows,uacExecutionLevel"] is not empty and sStandaloneSettingsA["Windows,uacExecutionLevel"] is not "default" then
local tManifestTrustInfoPath
put revEnvironmentRuntimePath() & "/Windows/" & tRuntimeDir & "/w32-manifest-template-trustinfo.xml" into tManifestTrustInfoPath
if there is not a file tManifestTrustInfoPath then
revStandaloneAddWarning "Windows, manifest trustinfo template not found: " & quote & tManifestTrustInfoPath & quote
else
put url ("file:" & tManifestTrustInfoPath) into tManifestTrustInfo
replace "[[executionLevel]]" with sStandaloneSettingsA["Windows,uacExecutionLevel"] in tManifestTrustInfo
put true into tManifestNeeded
end if
end if
local tManifestApplication
// IM-2014-08-15: [[ Bug 13118 ]] Pull in dpiAware section if set.
if sStandaloneSettingsA["Windows,usePixelScaling"] is empty or sStandaloneSettingsA["Windows,usePixelScaling"] is true then
local tManifestApplicationPath
put revEnvironmentRuntimePath() & "/Windows/" & tRuntimeDir & "/w32-manifest-template-dpiaware.xml" into tManifestApplicationPath
if there is not a file tManifestApplicationPath then
revStandaloneAddWarning "Windows, manifest dpiaware template not found: " & quote & tManifestApplicationPath & quote
else
put url ("file:" & tManifestApplicationPath) into tManifestApplication
put true into tManifestNeeded
end if
end if
if tManifestNeeded and tManifestData is not empty then
replace "[[trustInfo]]" with tManifestTrustInfo in tManifestData
replace "[[application]]" with tManifestApplication in tManifestData
local tManifestFile
put the tempName into tManifestFile
put tManifestData into url ("binfile:" & tManifestFile)
put tManifestFile into tDeployInfo["manifest"]
end if
revStandaloneDeployWithParams tTarget, tStackSourceFile, tDeployInfo
--Restore stack to its post-savingStandalone message state
__RestoreStackFromTemporaryLocation pStack, pRestoreFileName, tOriginalFileName
end repeat
revStandalonePostBuild pStack, pFolder
return empty
end revSaveAsWindowsStandalone
command revSaveAsLinuxStandalone pStack, pRestoreFileName, pFolder, @xStandalonePaths
local tStackFileList, tEngineSourceFile, tCount, tStackName, tStandalonePath
local tDirectory, tStackSourceFile, tName, tStackPath, tOriginalFileName
set the itemDelimiter to slash
put the effective filename of stack pStack into tOriginalFileName
put item 1 to -2 of tOriginalFileName into tStackPath
set the itemDelimiter to comma
-- keep a copy of the standalone settings to restore after each build
local tStandaloneSettingsA
put sStandaloneSettingsA into tStandaloneSettingsA
repeat for each key tTarget in sPlatformDirectoriesA["Linux"]
put sPlatformDirectoriesA["Linux"][tTarget] into tDirectory
-- Ensure standalone settings script local is reset when building for subsequent targets
put tStandaloneSettingsA into sStandaloneSettingsA
local tArch
if word 2 of tTarget is among the items of "x64,x86-64,x86_64" then
put "x86_64" into tArch
else if word 2 of tTarget is not empty then
put word 2 of tTarget into tArch
else
put "x86" into tArch
end if
revStandalonePreBuild pStack, char 1 to -2 of tDirectory, "linux", tArch, tStackName, tStackFileList
if the result is not empty then
return the result
end if
-- Always add print dialogs to linux standalones when searching for inclusions
if sStandaloneSettingsA["inclusions"] = "search" then
put true into sStandaloneSettingsA["revolutionPrintDialogs"]
end if
-- copy files to each directory
-- put the path to the engine into tEngineSourceFile
put revSBEnginePath(tTarget) into tEngineSourceFile