forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrevsblibrary.livecodescript
More file actions
3177 lines (2715 loc) · 112 KB
/
revsblibrary.livecodescript
File metadata and controls
3177 lines (2715 loc) · 112 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 "revSBLibrary"
#?library
# Standalone Builder Library functions
#?author
# Marcus van Houdt
on extensionInitialize
if the target is me then
insert the script of me into back
__InitialiseScriptLibraries
__InitialiseInclusionDependencies
__InitialiseBuiltInInclusions
end if
end extensionInitialize
on extensionFinalize
if the target is me then
remove the script of me from back
end if
end extensionFinalize
local sScriptLibraries
-- Some higher level wrappers..
#?semantics
# Copies the file pSourceFile to the folder pTargetFolder (which is not created if it does not exist).
#?author
# Marcus van Houdt
on revSBCopyFileToFolder pSourceFile, pTargetFolder, pCallback, pCallbackTarget
if there is no folder pTargetFolder then
return "target folder not found"
end if
set the itemDelimiter to "/"
local tTargetFile
put pTargetFolder & "/" & item -1 of pSourceFile into tTargetFile
__revSBCopyFile pSourceFile, tTargetFile, pCallback, pCallbackTarget
return the result
end revSBCopyFileToFolder
on revSBCopyFile pSourceFile, pTargetFile, pCallback, pCallbackTarget
__revSBCopyFile pSourceFile, pTargetFile, pCallback, pCallbackTarget
return the result
end revSBCopyFile
on revSBCopyFileToFile pSourceFile, pTargetFile, pCallback, pCallbackTarget
__revSBCopyFile pSourceFile, pTargetFile, pCallback, pCallbackTarget
return the result
end revSBCopyFileToFile
on revSBCopyFolder pSource, pTarget, pCallback, pCallbackTarget
__revSBCopyFolder pSource, pTarget, pCallback, pCallbackTarget
return the result
end revSBCopyFolder
# Slightly unfortunate naming, perhaps, but what do I call it folderToFolder?!
on revSBCopyFolderToDestination pSourceFolder, pDestinationFolder, pCallback, pCallbackTarget, pSettings
if there is no folder pDestinationFolder then
return "destination folder not found"
end if
set the itemDelimiter to "/"
local tTargetFolder
put pDestinationFolder & "/" & item -1 of pSourceFolder into tTargetFolder
__revSBCopyFolder pSourceFolder, tTargetFolder, pCallback, pCallbackTarget, pSettings
return the result
end revSBCopyFolderToDestination
on revSBReadFile pFile, pMode, @rData, pCallback, pCallbackTarget
local tResult
if tResult is empty then
if there is no file pFile then
put "file not found" into tResult
end if
end if
local tTotalSize
if tResult is empty then
local tOldFolder
put the defaultFolder into tOldFolder
set the itemDelimiter to "/"
set the defaultFolder to item 1 to -2 of pFile
get the detailed files
filter it with (the urlEncode of item -1 of pFile) & "*"
set the itemDelimiter to ","
put item 2 of it into tTotalSize
set the defaultFolder to tOldFolder
end if
if tResult is empty then
if pMode is "binary" then
open file pFile for binary read
else
open file pFile for text read
end if
end if
put the result into tResult
local tAmountRead
if tResult is empty then
if pCallbackTarget is not empty and there is a pCallbackTarget then
send pCallback to pCallbackTarget
end if
repeat forever
read from file pFile for 524288
if the result is not empty and the result is not "eof" then
put the result into tResult
exit repeat
end if
put it after rData
if the result is "eof" or it is empty then
exit repeat
end if
add 524288 to tAmountRead
if pCallbackTarget is not empty and there is a pCallbackTarget then
send pCallback && tAmountRead, tTotalSize to pCallbackTarget
end if
end repeat
end if
if tResult is empty then
if pCallbackTarget is not empty and there is a pCallbackTarget then
send pCallback && tAmountRead, tTotalSize to pCallbackTarget
end if
end if
if tResult is empty then
close file pFile
end if
return tResult
end revSBReadFile
local sLog = "false"
private command log pMessage
#put pMessage & return after msg
end log
# This handler has not been tested..
on revSBWriteFile pFile, pMode, @pData, pCallback, pCallbackTarget, pLog
local tResult
put pLog into sLog
if tResult is empty then
if "binary" is in pMode then
if "update" is in pMode then
open file pFile for binary update
else
open file pFile for binary write
end if
else
if "update" is in pMode then
open file pFile for text update
else
open file pFile for text write
end if
end if
end if
put the result into tResult
log "Result of opening file: " & tResult
local tTotalSize
local tCurrentCount
if tResult is empty then
put the number of chars of pData into tTotalSize
put 1 into tCurrentCount
if pCallbackTarget is not empty and there is a pCallbackTarget then
send pCallback to pCallbackTarget
end if
repeat forever
get char tCurrentCount to (tCurrentCount + 524288 - 1) of pData
if it is empty then
exit repeat
end if
write it to file pFile
if the result is not empty then
put the result into tResult
exit repeat
end if
add 524288 to tCurrentCount
if pCallbackTarget is not empty and there is a pCallbackTarget then
send pCallback && tCurrentCount, tTotalSize to pCallbackTarget
end if
end repeat
end if
if tResult is not empty then
if pCallbackTarget is not empty and there is a pCallbackTarget then
send pCallback && tTotalSize, tTotalSize to pCallbackTarget
end if
end if
if tResult is empty then
close file pFile
end if
return tResult
end revSBWriteFile
---
#?semantics
# Copies a folder and all it's contents, under which we understand:
# - (sub)folders
# - (ordinary) files (including finder shortcuts etc)
# - bsd symlinks (TO DO)
#?author
# Marcus van Houdt
private command __revSBCopyFolder pSource, pTarget, pCallback, pCallbackTarget, pSettings
local tResourceList
local tResult
put revSBReadLink(pSource) into pSource
local tOldFolder
put the defaultfolder into tOldFolder
if there is no folder pSource then
put "no such source folder found" into tResult
end if
# OK-2008-09-10 : Bug 7147
set the defaultFolder to pSource
if the defaultFolder is not pSource then
put "can't enter source folder" into tResult
end if
local tTotalNumber
put __EnumerateFolder(pSource) into tResourceList
put the number of lines of tResourceList into tTotalNumber
if there is no folder pTarget then
__revSBEnsureFolder pTarget -- create it and all its parents as required...
put the result into tResult
end if
local tNumberCopied
put 0 into tNumberCopied
if tResult is empty then
if pCallbackTarget is not empty and there is a pCallbackTarget then
send pCallback to pCallbackTarget -- with empty paramaters..
end if
repeat for each line tResource in tResourceList
add 1 to tNumberCopied
if char -1 of tResource is "/" then
-- create the folder, stat the source
local tSubFolder
put pTarget & "/" & char 1 to -2 of tResource into tSubFolder
if there is not a folder tSubFolder then
create folder tSubFolder
if the result is not empty then
put "cannot create subfolder ", the result , tResource into tResult
exit repeat
end if
end if
if the platform is "macos" or the platform is "Linux" then -- stat it and set some flags
local tUser, tGroup
set the itemDelimiter to "/"
set the defaultFolder to pSource & "/" & item 1 to -2 of tResource
get the detailed folders
filter it with (the urlEncode of item -1 of tResource) & "*"
set the itemDelimiter to ","
put item 8 of it into tUser
put item 9 of it into tGroup
if tUser is not empty or tGroup is not empty then
get shell("chown" && tUser & ":" & tGroup && quote & pTarget & "/" & char 1 to -2 of tResource & quote)
end if
end if
# Creating a folder takes no time, so do not send a callback.
else if tResource is not empty then
local tFileCallback
put pCallback && tNumberCopied, tTotalNumber & comma into tFileCallback
__revSBCopyFile pSource & "/" & tResource, pTarget & "/" & tResource, tFileCallback, pCallbackTarget, pSettings
if the result is not empty then
put the result into tResult
exit repeat
end if
end if
-- Send the callback ones every 50 items, say, if for some reason no files were encountered..
if tNumberCopied mod 50 is 0 and pCallbackTarget is not empty and there is a pCallbackTarget then
send pCallback && tNumberCopied, tTotalNumber to pCallbackTarget
end if
end repeat
end if
-- make sure we finish on a "full" callback
if tResult is empty then
if pCallbackTarget is not empty and there is a pCallbackTarget then
send pCallback && tTotalNumber, tTotalNumber to pCallbackTarget
end if
end if
set the defaultFolder to tOldFolder
if tResult is not empty then
revStandaloneAddWarning tResult & ":" && quote & pSource & quote
end if
return tResult
end __revSBCopyFolder
#?semantics
# Copy a file and it's attributes for as much as we can.
# Sends a callback with the number of bytes currently copied and the number left to copy..
#?author
# Marcus van Houdt
private command __revSBCopyFile pSourceFile, pTargetFile, pCallback, pCallbackTarget, pSettings
-- Stat the source file
local tOldFolder, tSize, tPermissions, tUser, tGroup, tFileType
local tResult
local tSourceFileIsLink
if tResult is empty then
if __readlink(pSourceFile) is not empty then
put true into tSourceFileIsLink
else if there is no file pSourceFile then
put "cannot find source file" into tResult
end if
end if
if tResult is empty then
put the defaultFolder into tOldFolder
set the itemDelimiter to "/"
set the defaultFolder to item 1 to -2 of pSourceFile
get the detailed files
filter it with (the urlEncode of item -1 of pSourceFile) & "*"
set the itemDelimiter to ","
put item 2 of it into tSize
put item 8 of it into tUser
put item 9 of it into tGroup
put item 10 of it into tPermissions
put item 11 of it into tFileType
if there is a file pTargetFile then
delete file pTargetFile
if the result is not empty then
put "cannot overwrite existing target file" into tResult
end if
end if
local tOldFileType
if tResult is empty then
put the fileType into tOldFileType
if tFileType is not empty then
set the fileType to tFileType
else
set the fileType to "????????"
end if
end if
end if
if tSourceFileIsLink then
if tResult is empty then
# __readlink only works for MacOS and Linux so no need for a switch here
get shell("cp -a" && quote & pSourceFile & quote && \
quote & pTargetfile & quote)
if it is not empty then
put "cannot copy symbolic link" into tResult
end if
# Copying a symbolic link takes no time, so do not send a callback.
end if
else # regular file
if tResult is empty then
open file pTargetFile for binary write
if the result is not empty then
put "cannot create target file" into tResult
end if
end if
if tResult is empty then
open file pSourceFile for binary read
if the result is not empty then
put "cannot read from source file", the result into tResult
end if
end if
local tAmountCopied
if tResult is empty then
if pCallbackTarget is not empty and there is a pCallbackTarget then
send pCallback && 0, tSize to pCallbackTarget
end if
repeat forever
read from file pSourceFile for 1048576
if the result is not empty and the result is not "eof" then
put "cannot read from source file", the result into tResult
exit repeat
end if
if it is empty then
exit repeat
end if
write it to file pTargetFile
if the result is not empty then
put "cannot write to target file" into tResult
exit repeat
end if
add the number of chars of it to tAmountCopied
if pCallbackTarget is not empty and there is a pCallbackTarget then
send pCallback && tAmountCopied, tSize to pCallbackTarget
end if
end repeat
end if
if pTargetFile is among the lines of the openFiles then
close file pTargetFile
end if
if pSourceFile is among the lines of the openFiles then
close file pSourceFile
end if
end if
# OK-2007-11-30 : Modified to work for Linux too
if tResult is empty and the platform is "macos" or the platform is "Linux" then
if tPermissions is not empty then
get shell("chmod" && tPermissions && quote & pTargetfile & quote)
end if
if tUser is not empty or tGroup is not empty then
get shell("chown" && tUser & ":" & tGroup && quote & pTargetFile & quote)
end if
end if
-- Remove unneeded slices from the MacOS externals
set the itemDel to slash
if pSettings["externals"] contains item -1 of pTargetFile then
revSBRemoveUnneededSlicesFromMacCode pTargetFile, pSettings
end if
if tOldFolder is not empty then
set the defaultFolder to tOldFolder
end if
if tOldFileType is not empty then
set the fileType to tOldFileType
end if
/* WORKAROUND: BUG 22255
*
* Multiple shell calls in a tight loop can cause a deadlock on macOS */
wait 0 with messages
return tResult
end __revSBCopyFile
#?semantics
# Creates a folder and all parents as required.
#?author
# Marcus van Houdt
on revSBEnsureFolder pFolder
__revSBEnsureFolder pFolder
return the result
end revSBEnsureFolder
command revSBRemoveUnneededSlicesFromMacCode pTargetFile, pSettings
if the platform is "macos" and pSettings is not empty then
local tRemove
if pSettings["MacOSX x86-64"] is true and pSettings["MacOSX x86-32"] is not true then
put "i386" into tRemove
else if pSettings["MacOSX x86-32"] is true and pSettings["MacOSX x86-64"] is not true then
put "x86_64" into tRemove
end if
if tRemove is not empty then
replace " " with "\ " in pTargetFile
local tShell
put "lipo " & pTargetFile & " -remove " & tRemove & " -output " & pTargetFile into tShell
get shell(tShell)
end if
end if
end revSBRemoveUnneededSlicesFromMacCode
private command __revSBEnsureFolder pFolder
set the itemDel to "/"
if there is no folder pFolder and pFolder is not empty then
__revSBEnsureFolder item 1 to -2 of pFolder
if the result is not empty then
return the result
end if
create folder pFolder
return the result
end if
end __revSBEnsureFolder
function revSBEnumerateFolder pFolder, pRecursive
return __EnumerateFolder(pFolder, "", pRecursive)
end revSBEnumerateFolder
private function __EnumerateFolder pFolder, pPrefix, pRecursive
local tRecursive
-- recursive by default
put pRecursive is not false into tRecursive
local tResult
local tSubFolder
repeat for each line tSubFolder in folders(pFolder)
if tSubFolder is among the items of ".,.." then
next repeat
end if
# For our purposes we need the folder first, so it can be created ahead of file creation..
appendToStringList pPrefix & tSubFolder & "/", tResult
if tRecursive then
get __EnumerateFolder(pFolder & "/" & tSubFolder, pPrefix & tSubFolder & "/")
if it is not empty then
appendToStringList it, tResult
end if
end if
end repeat
local tFile
repeat for each line tFile in files(pFolder)
appendToStringList pPrefix & tFile, tResult
end repeat
return tResult
end __EnumerateFolder
function revSBCalculateRelativePath pRoot, pFile
local tResult, tCount
set the itemDel to "/"
put 1 into tCount
local tIsFolder
put there is a folder pFile into tIsFolder
repeat for each item tNode in pRoot
if item 1 to tCount of pRoot is item 1 to tCount of pFile then
else
put "../" before tResult
if item tCount of pFile is not empty then
put item tCount of pFile & "/" after tResult
end if
end if
add 1 to tCount
end repeat
put "./" before tResult
put item tCount to -1 of pFile after tResult
if char -1 of tResult is "/" then
delete char -1 of tResult
end if
return tResult
end revSBCalculateRelativePath
function revSBCalculateAbsolutePath pRoot, pRelativeFile
if pRelativeFile is empty then
return __revSBCalculateAbsolutePath(pRoot)
else
local tRoot
put pRoot into tRoot
if char -1 of tRoot is "/" then
delete char -1 of tRoot
end if
if char 1 of pRelativeFile is "/" then
return __revSBCalculateAbsolutePath(tRoot & pRelativeFile)
else
return __revSBCalculateAbsolutePath(tRoot & "/" & pRelativeFile)
end if
end if
end revSBCalculateAbsolutePath
private function __revSBCalculateAbsolutePath pPath
local tPath
set the itemDelimiter to "/"
repeat for each item tPart in pPath
switch tPart
case "."
next repeat
case ".."
delete the last item of tPath
break
default
put tPart & "/" after tPath
end switch
end repeat
if tPath is not "/" then
delete the last char of tPath
end if
return tPath
end __revSBCalculateAbsolutePath
#?Semantics
# Returns "absolute" or "relative" depending on the type of path.
function revSBPathType pPath
if the platform is "macos" then
if char 1 of pPath is "/" then
return "absolute"
else
return "relative"
end if
end if
if the platform is "win32" then
if char 2 of pPath is ":" then
return "absolute"
else
return "relative"
end if
end if
end revSBPathType
function revSBGenerateUUID
_internal call "generate_uuid"
return the result
end revSBGenerateUUID
private function __readlink pPath
if the platform is "Win32" then
return empty
end if
local tLink
put shell("readlink " & quote & pPath & quote) into tLink
if the last char of tLink is cr then
delete the last char of tLink
end if
return tLink
end __readlink
// Resolve symbolic links
private function revSBReadLink pPath
repeat forever
local tLink
put __readlink(pPath) into tLink
if tLink is empty then
return pPath
end if
if the first char of tLink is not slash then
set the itemdel to slash
put revSBCalculateAbsolutePath(item 1 to -2 of pPath, tLink) into tLink
end if
put tLink into pPath
end repeat
end revSBReadLink
----------
local sWarnings
command revStandaloneResetWarnings
put empty into sWarnings
end revStandaloneResetWarnings
function revStandaloneGetWarnings
return sWarnings
end revStandaloneGetWarnings
command revStandaloneAddWarning pWarning
if pWarning is not among the lines of sWarnings then
put pWarning & return after sWarnings
end if
end revStandaloneAddWarning
----------
command revStandaloneProgress pMessage
if not revSBSuppressDialogs() then
send "revUpdateStandaloneProgress pMessage" to stack "revStandaloneSettings"
end if
end revStandaloneProgress
# This is an event handler, not a command.
on revStandaloneProgressCallback
if not revSBSuppressDialogs() then
wait 0 ticks with messages
end if
end revStandaloneProgressCallback
command revStandaloneProgressFinished
if not revSBSuppressDialogs() then
close stack "revStandaloneProgress"
end if
end revStandaloneProgressFinished
----------
# AL-2015-01-29: [[ Scriptify revSaveAsStandalone ]] Move some general utility code into revSBLibrary
function revFolderNameIllegalChars
return "\/:*?<>|" & quote & return
end revFolderNameIllegalChars
function revFolderNameIsIllegal pName
repeat for each char tChar in revFolderNameIllegalChars()
if pName contains tChar then
return true
end if
end repeat
# This appears to be the max length from looking at older code. There was also a limit of
# 27 chars on Mac, but i think this is left over from classic so removed it.
if the length of pName > 246 then
return true
end if
return false
end revFolderNameIsIllegal
function revFolderNameMakeLegal pName
local tLegalName
put pName into tLegalName
repeat for each char tChar in revFolderNameIllegalChars()
replace tChar with space in tLegalName
end repeat
return tLegalName
end revFolderNameMakeLegal
// List of all desktop target platforms + architecture
constant kDesktopTargets = "Windows,Windows x86-64,MacOSX x86-32,MacOSX x86-64,Linux,Linux x64,Linux armv6-hf"
function revSBDesktopTargets
return kDesktopTargets
end revSBDesktopTargets
constant kAdditionalTargets = "iOS,Android,Emscripten"
function revSBAdditionalTargets
return kAdditionalTargets
end revSBAdditionalTargets
function revSBTargetToPlatform pTarget
if pTarget begins with "MacOSX" then
return "MacOSX"
else if pTarget begins with "Linux" then
return "Linux"
else if pTarget begins with "Windows" then
return "Windows"
else
return pTarget
end if
end revSBTargetToPlatform
-- item 1 of the architectures should be the default architecture
constant kWindowsArchitectures = "x86-32,x86-64"
constant kMacOSXArchitectures = "x86-32,x86-64"
constant kLinuxArchitectures = "x86-32,x86-64,armv6-hf"
constant kAndroidArchitectures = "armv7,arm64,x86,x86_64"
constant kiOSArchitectures = "armv7,arm64"
constant kEmscriptenArchitectures = "js"
function revSBPlatformArchitectures pPlatform
switch pPlatform
case "Windows"
return kWindowsArchitectures
case "MacOSX"
return kMacOSXArchitectures
case "Linux"
return kLinuxArchitectures
case "Android"
return kAndroidArchitectures
case "iOS"
return kiOSArchitectures
case "Emscripten"
return kEmscriptenArchitectures
default
return empty
end switch
end revSBPlatformArchitectures
private function __ArchitectureSynonyms pArchitecture
switch pArchitecture
case "x86-32"
return pArchitecture,"x86,i386"
case "x86-64"
return pArchitecture,"x64,x86_64"
end switch
return pArchitecture
end __ArchitectureSynonyms
private command __ExternalArchitecture pPlatform, @xName, @rArchitecture
local tArchitectures
put revSBPlatformArchitectures(pPlatform) into tArchitectures
local tArchitecture,tFoundArchitecture
repeat for each item tArchitecture in tArchitectures
local tArchitectureIdentifier
repeat for each item tArchitectureIdentifier in __ArchitectureSynonyms(tArchitecture)
if xName ends with tArchitectureIdentifier then
put tArchitecture into tFoundArchitecture
set the itemDelimiter to "-"
if the number of items of xName > 1 then
delete item -(the number of items of tArchitectureIdentifier) to -1 of xName
else
set the itemDelimiter to "_"
if the number of items of xName > 1 then
delete item -(the number of items of tArchitectureIdentifier) to -1 of xName
end if
end if
set the itemDelimiter to comma
exit repeat
end if
end repeat
if tFoundArchitecture is not empty then
exit repeat
end if
end repeat
if tFoundArchitecture is empty then
if pPlatform is "MacOSX" then
put tArchitectures into tFoundArchitecture
else
put item 1 of tArchitectures into tFoundArchitecture
end if
end if
put tFoundArchitecture into rArchitecture
end __ExternalArchitecture
private function __TargetArchitecture pTarget
local tPlatform
put revSBTargetToPlatform(pTarget) into tPlatform
local tArchitectures
put revSBPlatformArchitectures(tPlatform) into tArchitectures
local tArchitecture
repeat for each item tArchitecture in tArchitectures
local tArchitectureIdentifier
repeat for each item tArchitectureIdentifier in __ArchitectureSynonyms(tArchitecture)
if pTarget ends with tArchitectureIdentifier then
return tArchitecture
end if
end repeat
end repeat
return item 1 of tArchitectures
end __TargetArchitecture
constant kDefaultCreator = "????"
constant kDefaultDocumentType = ""
constant kDefaultDocumentExtension = ""
constant kDefaultDynamicMemory = "true"
constant kDefaultMinimumSize = 15000
constant kDefaultPreferredSize = 15000
constant kDefaultRegion = 1
constant kDefaultRelease = "Final"
constant kDefaultVersionNumber = "1.0.0.0"
constant kDefaultScriptLibraries = ""
constant kAskDialog = "true"
constant kAnswerDialog = "true"
constant kCursors = "false"
// SN-2015-01-21: [[ Bug 14371 ]] 'MacOSX' has been replaced by 'MacOSX x86-32'
constant kInitialTargets = "Windows,MacOSX x86-64,Linux"
on revSBDefaultStandaloneSettings pStack, @xSettingsA
local tPlatform,tName
-- name
if xSettingsA["name"] = "" then put pStack into xSettingsA["name"]
put char 1 to 246 of xSettingsA["name"] into xSettingsA["name"]
if xSettingsA["inclusions"] = "" then put "search" into xSettingsA["inclusions"]
if xSettingsA["OSX,name"] = "" then put pStack into xSettingsA["OSX,name"]
if xSettingsA["Windows,ProductName"] = "" then put pStack into xSettingsA["Windows,ProductName"]
-- main resources
if xSettingsA["askDialog"] = "" then
put kAskDialog into xSettingsA["askDialog"]
-- assume no properties set
if xSettingsA["scriptLibraries"] = "" then put replaceText(kDefaultScriptLibraries,",",cr) into xSettingsA["scriptLibraries"]
put revEnvironmentRuntimePath() & "/Windows/x86-32/Support/Sample Icons" into tName
if xSettingsA["Windows,iconFile"] = "" then put tName & "/genericapp.ico" into xSettingsA["Windows,iconFile"]
if xSettingsA["Windows,documenticonFile"] = "" then put tName & "/genericdoc.ico" into xSettingsA["Windows,documenticonFile"]
end if
if xSettingsA["answerDialog"] = "" then put kAnswerDialog into xSettingsA["answerDialog"]
if xSettingsA["cursors"] = "" then put kCursors into xSettingsA["cursors"]
-- version
set the itemDel to "."
repeat with X=1 to the number of items of kDefaultVersionNumber
if xSettingsA["Windows,fileversion"&X] = "" then put item X of kDefaultVersionNumber into xSettingsA["Windows,fileversion"&X]
if xSettingsA["Windows,productversion"&X] = "" then put item X of kDefaultVersionNumber into xSettingsA["Windows,productversion"&X]
end repeat
set the itemDel to ","
if xSettingsA["OSX,longVersion"] = "" then put pStack&&kDefaultVersionNumber into xSettingsA["OSX,longVersion"]
if xSettingsA["OSX,info"] = "" then put pStack&&"Version"&&kDefaultVersionNumber into xSettingsA["OSX,info"]
if xSettingsA["OSX,shortVersion"] = "" then put kDefaultVersionNumber into xSettingsA["OSX,shortVersion"]
if xSettingsA["Windows,FileDescription"] = "" then put pStack&&kDefaultVersionNumber&&"for Windows" into xSettingsA["Windows,FileDescription"]
-- document types
if the number of chars of xSettingsA["OSX,signature"] <> 4 then put kDefaultCreator into xSettingsA["OSX,signature"]
if xSettingsA["OSX,documentType"] = "" then put kDefaultDocumentType into xSettingsA["OSX,documentType"]
if xSettingsA["OSX,documentExtension"] = "" then put kDefaultDocumentExtension into xSettingsA["OSX,documentExtension"]
-- set the unix stuff to true because they will only be imported into unix builds anyway
if xSettingsA["UNIX,colorChooser"] = "" then put true into xSettingsA["UNIX,colorChooser"]
if xSettingsA["UNIX,printerChooser"] = "" then put true into xSettingsA["UNIX,printerChooser"]
if xSettingsA["UNIX,pageSetup"] = "" then put true into xSettingsA["UNIX,pageSetup"]
if xSettingsA["UNIX,fileSelector"] = "" then put true into xSettingsA["UNIX,fileSelector"]
-- build for every platform we have engines for
repeat for each item tTarget in kInitialTargets
if tTarget is "MacOSX x86-64" then
if xSettingsA["MacOSX x86-32"] then next repeat
end if
if xSettingsA[tTarget] = "" then
put revEngineCheck(tTarget) into xSettingsA[tTarget]
end if
end repeat
-- copyright
get the seconds
convert it to dateItems
if xSettingsA["OSX,copyright"] = "" then put item 1 of it&&the cUserOrganisation of stack "Home"&&"All rights reserved worldwide" into xSettingsA["OSX,copyright"]
if xSettingsA["OSX,identifier"] = "" then put "com."&replaceText(toLower(the cUserOrganisation of stack "Home")," ","")&"."&replaceText(toLower(xSettingsA["name"])," ","") into xSettingsA["OSX,identifier"]
if xSettingsA["Windows,LegalCopyright"] = "" then put item 1 of it&&the cUserOrganisation of stack "Home"&&"All rights reserved worldwide" into xSettingsA["Windows,LegalCopyright"]
if xSettingsA["Windows,companyname"] = "" then put the cUserOrganisation of stack "Home" into xSettingsA["Windows,companyname"]
-- Since the intel choice, set the default here:
-- MM-2014-03-21: [[ PPC Support Dropped ]] Only create standalone setting for Intel (for OS X) by default.
if xSettingsA["MacOSX x86-64"] is empty and xSettingsA["MacOSX x86-32"] is empty then
put true into xSettingsA["MacOSX x86-64"]
end if
-- Auto-remove stack passwords from community stacks
if not revEnvironmentEditionProperty("password_protection") then
if xSettingsA["password"] is not empty then
delete variable xSettingsA["password"]
end if
end if
end revSBDefaultStandaloneSettings
function revSBRemoveUnlicensedTargetsFromSettings @xSettingsA
-- don't build for any platform we are not licensed for
local tRemoved
repeat for each item tTarget in kDesktopTargets, kAdditionalTargets
if xSettingsA[tTarget] then
if not revSBLicensedToDeployToTarget(tTarget) then
put false into xSettingsA[tTarget]
put true into tRemoved[tTarget]
end if
end if
end repeat
return the keys of tRemoved
end revSBRemoveUnlicensedTargetsFromSettings
command revSBRelativeStackFilesList pStack, @rStackFiles
local tLine,tChars,tMainStackPath
local tFullStackFiles
revSBGetStackFilesList pStack, tFullStackFiles
local tRelativeStackFiles
set the itemDelimiter to slash
put item 1 to -2 of line 1 of tFullStackFiles & "/" into tMainStackPath
repeat for each line tLine in tFullStackFiles
put utilityMakePathRelative(tLine, tMainStackPath) into tLine
appendToStringList tLine, tRelativeStackFiles
end repeat
put tFullStackFiles into rStackFiles["full"]
put tRelativeStackFiles into rStackFiles["relative"]
end revSBRelativeStackFilesList
command revSBGetStackFilesList pStack, @rStackFiles
local tStackFiles
put the effective fileName of stack pStack into tStackFiles
__RecursiveStackFileList pStack, tStackFiles
put tStackFiles into rStackFiles
end revSBGetStackFilesList
private command __RecursiveStackFileList pStack, @xStackFiles
local tFileName
set the itemDelimiter to slash
put item 1 to -2 of the fileName of stack pStack & slash into tFileName
local tStackFiles
put the stackFiles of stack pStack into tStackFiles
split tStackFiles by return and comma
set the itemDel to comma
local tStack
repeat for each key tStack in tStackFiles
if there is not a stack tStackFiles[tStack] then put tFileName before tStackFiles[tStack]
if there is a stack tStackFiles[tStack] then
local tEffectiveFilename
put the effective fileName of stack tStackFiles[tStack] into tEffectiveFilename
if tEffectiveFilename is not among the lines of xStackFiles then
appendToStringList tEffectiveFilename, xStackFiles
__RecursiveStackFileList tStack, xStackFiles
end if
end if
end repeat
repeat for each line tStack in the substacks of stack pStack
__RecursiveStackFileList tStack, xStackFiles
end repeat
end __RecursiveStackFileList
function revDownloadEngine pEngine
if revEngineCheck(pEngine) then
return true
else
return false