Skip to content

Commit 71f8412

Browse files
committed
Merge branch 'Dev' into main
2 parents 4bcd2b2 + ff0c53a commit 71f8412

9 files changed

Lines changed: 1510 additions & 3 deletions

File tree

File renamed without changes.
File renamed without changes.
File renamed without changes.

Project/Sources/Classes/_Build.4dm

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
Class constructor
2+
This:C1470._SettingsUsed:=""
3+
This:C1470._Source:=""
4+
5+
Function Compile($options : Object)->$error : Object
6+
If (Count parameters:C259>0)
7+
$error:=Compile project:C1760($options)
8+
Else
9+
$error:=Compile project:C1760
10+
End if
11+
12+
Function Build($PathToSettings : Text)->$error : Object
13+
// this function uses LAUNCH EXTERNAL PROCESS and not 4D.SystemWorker to allow v19 LTS to use the class
14+
If (Count parameters:C259>0)
15+
This:C1470._SettingsUsed:=$PathToSettings
16+
Else
17+
This:C1470._SettingsUsed:=File:C1566(Build application settings file:K5:60).platformPath
18+
End if
19+
BUILD APPLICATION:C871(This:C1470._SettingsUsed)
20+
21+
If (OK=0)
22+
$errortext:=File:C1566(Build application log file:K5:46).getText()
23+
$error:=New object:C1471("success"; False:C215; "log"; $errortext)
24+
Else
25+
$error:=New object:C1471("success"; True:C214)
26+
End if
27+
28+
Function Notarize($zipfilepath : Text)->$error : Object
29+
ASSERT:C1129($zipfilepath#""; "zip file path must not be empty")
30+
$in:=""
31+
$out:=""
32+
$err:=""
33+
$cmd:="xcrun notarytool submit "+Char:C90(34)+Convert path system to POSIX:C1106($zipfilepath)+Char:C90(34)+" --keychain-profile notarytool --wait"
34+
LAUNCH EXTERNAL PROCESS:C811($cmd; $in; $out; $err)
35+
If (($err#"") & ($err#"@Current status: Accepted@"))
36+
$error:=New object:C1471("success"; False:C215; "log"; $err)
37+
Else
38+
Case of
39+
: ($out="@ status: Accepted@")
40+
$error:=New object:C1471("success"; True:C214)
41+
: ($out="@ status: Invalid@")
42+
$pos:=Position:C15(" id: "; $out)
43+
If ($pos>0)
44+
$id:=Substring:C12($out; $pos+7)
45+
$pos:=Position:C15(Char:C90(10); $id)
46+
$id:=Substring:C12($id; 1; $pos)
47+
$in:=""
48+
$out2:=""
49+
$err:=""
50+
$logpath:=Get 4D folder:C485(Logs folder:K5:19)+"notarizing log.json"
51+
$cmd:="xcrun notarytool log "+$id+" --keychain-profile \"notarytool\" "+Char:C90(34)+Convert path system to POSIX:C1106($logpath)+Char:C90(34)
52+
LAUNCH EXTERNAL PROCESS:C811($cmd; $in; $out2; $err)
53+
If (Test path name:C476($logpath)=Is a document:K24:1)
54+
$logtext:=Document to text:C1236($logpath)
55+
$log:=JSON Parse:C1218($logtext)
56+
Else
57+
$log:=New object:C1471
58+
End if
59+
$error:=New object:C1471("success"; False:C215; "log"; $out; "id"; $id; "invalid"; $log)
60+
Else
61+
$error:=New object:C1471("success"; False:C215; "log"; $out)
62+
End if
63+
Else
64+
$error:=New object:C1471("success"; False:C215; "log"; $out)
65+
End case
66+
67+
End if
68+
69+
Function Zip($sourcepath : Text; $targetpath : Text)->$error : Object
70+
// if $sourcepath is ommitted, it reads path from settings, only for components on Mac
71+
If (Count parameters:C259=0)
72+
If (This:C1470._SettingsUsed#"")
73+
$settings:=File:C1566(This:C1470._SettingsUsed; fk platform path:K87:2).getText()
74+
$settingsXML:=DOM Parse XML variable:C720($settings)
75+
$Found:=DOM Find XML element:C864($settingsXML; "/Preferences4D/BuildApp/BuildMacDestFolder")
76+
If (ok=1)
77+
DOM GET XML ELEMENT VALUE:C731($Found; $value)
78+
Case of
79+
: ($value="::@")
80+
// cannot use Folder(fk database folder).parent, as we need to go outside of protected area
81+
$sourcefolder:=Folder:C1567(Get 4D folder:C485(Database folder:K5:14); fk platform path:K87:2)
82+
$sourcefolder:=Folder:C1567($sourcefolder.parent.platformPath+Substring:C12($value; 3)+"Components"; fk platform path:K87:2)
83+
$sourcefolderfiles:=$sourcefolder.folders()
84+
If ($sourcefolderfiles.length>0)
85+
$source:=$sourcefolderfiles[0].platformPath
86+
End if
87+
: ($value=":@")
88+
$sourcefolder:=Folder:C1567(Folder:C1567(fk database folder:K87:14).platformPath+Substring:C12($value; 2)+"Components"; fk platform path:K87:2)
89+
$sourcefolderfiles:=$sourcefolder.folders()
90+
If ($sourcefolderfiles.length>0)
91+
$source:=$sourcefolderfiles[0].platformPath
92+
End if
93+
Else
94+
$source:=$value
95+
End case
96+
End if
97+
DOM CLOSE XML:C722($settingsXML)
98+
End if
99+
Else
100+
$source:=$sourcepath
101+
End if
102+
This:C1470._Source:=$source
103+
104+
If (Count parameters:C259<2)
105+
If (($source#"") & ($source="@.4dbase:"))
106+
$target:=Replace string:C233($source; ".4dbase:"; ".zip")
107+
End if
108+
Else
109+
$target:=$targetpath
110+
End if
111+
112+
// now we can finally zip
113+
If (($source#"") & ($target#""))
114+
If (Test path name:C476($target)=Is a document:K24:1)
115+
DELETE DOCUMENT:C159($target) // just to be sure that zip works and we can fetch errors
116+
End if
117+
$cmd:="/usr/bin/ditto -c -k --keepParent "+Char:C90(34)+Convert path system to POSIX:C1106($source)+Char:C90(34)+" "+Char:C90(34)+Convert path system to POSIX:C1106($target)+Char:C90(34)
118+
$in:=""
119+
$out:=""
120+
$err:=""
121+
LAUNCH EXTERNAL PROCESS:C811($cmd; $in; $out; $err)
122+
123+
If ($err#"")
124+
$error:=New object:C1471("success"; False:C215; "reason"; "Zip error "+$err)
125+
Else
126+
$error:=New object:C1471("success"; True:C214; "target"; $target)
127+
End if
128+
Else
129+
$error:=New object:C1471("success"; False:C215; "reason"; "source or target path empty")
130+
End if
131+
132+
133+
Function Staple()->$error : Object
134+
$cmd:="xcrun stapler staple '"+Convert path system to POSIX:C1106(This:C1470._Source)+"'"
135+
$in:=""
136+
$out:=""
137+
$err:=""
138+
LAUNCH EXTERNAL PROCESS:C811($cmd; $in; $out; $err)
139+
If ($err#"")
140+
$error:=New object:C1471("success"; False:C215; "log"; "Staple error "+$out)
141+
Else
142+
$source:=This:C1470._Source
143+
$error:=This:C1470.Zip($source)
144+
End if
145+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//%attributes = {}
2+
//%attributes = {}
3+
/* internal method, only to build/update
4+
handles component build, notarize (needs to run on Mac) and upload to git
5+
6+
to use setup build application settings using dialog.requires to enter an Apple certificate
7+
certificate such as "Developer ID Application: Companyname (id)"
8+
follow https://blog.4d.com/how-to-notarize-your-merged-4d-application/
9+
10+
in case you have several xcode, select the 'good' one with
11+
###########
12+
sudo xcode-select -s /path/to/Xcode13.app
13+
14+
Tested with XCode 13. Minimum Version XCode 13, for older you need to use altool, see:
15+
https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow/notarizing_apps_when_developing_with_xcode_12_and_earlier
16+
17+
Run XCode at least once manual to make sure it is correctly installed and license is accepted.
18+
After an XCode/System update another manual run might be necesssary to accept modified license.
19+
20+
###########
21+
expects that you have installed your password in keychain named "altool" with:
22+
xcrun altool --list-providers -u "AC_USERNAME" -p secret_2FA_password
23+
Sign in to your Apple ID account page. In the Security section, click the “Generate Password” option below the “App-Specific Passwords” option, enter a password label as requested and click the “Create” button.
24+
If unclear, read Apple docu above!
25+
26+
########### NOTES
27+
you might need to start Xcode once manually after every macOS update to accept Xcode changes
28+
you might need to start Xcode to accept Apple contract changes or update expired certificates (visit developer.apple.com)
29+
*/
30+
31+
var $builder : cs:C1710._Build
32+
33+
$builder:=cs:C1710._Build.new()
34+
35+
$progress:=Progress New
36+
Progress SET MESSAGE($progress; "Compile...")
37+
38+
$error:=$builder.Compile()
39+
If ($error.success=True:C214)
40+
Progress SET MESSAGE($progress; "Build...")
41+
$error:=$builder.Build() // $1 could be path to settings, if you have other than default ones
42+
End if
43+
44+
If ($error.success=True:C214)
45+
Progress SET MESSAGE($progress; "Zip...")
46+
$error:=$builder.Zip()
47+
End if
48+
49+
If ($error.success=True:C214)
50+
$target:=$error.target
51+
Progress SET MESSAGE($progress; "Notarize and wait for Apple's approval...")
52+
$error:=$builder.Notarize($target) // returned by zip
53+
End if
54+
55+
If ($error.success=True:C214)
56+
$error:=$builder.Staple($target)
57+
End if
58+
59+
Progress QUIT($progress)
60+
61+
62+
If ($error.success=False:C215)
63+
ALERT:C41(JSON Stringify:C1217($error; *))
64+
SET TEXT TO PASTEBOARD:C523(JSON Stringify:C1217($error; *))
65+
End if
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?><preferences stamp="2">
2+
<com.4d>
3+
<compiler>
4+
<options syntax_file="true"/>
5+
</compiler>
6+
<general component_classStore_name="FileTransfer"/>
7+
</com.4d>
8+
</preferences>

Readme.MD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ $result:=$ftp.download($source; $target)
6464
# Documentation
6565

6666
## cURL (FTP - FTPS - SFTP - HTTP - HTTPS)
67-
[Documentation](ReadMe_curl.MD)
67+
[Documentation](Documentation/ReadMe_curl.MD)
6868

6969
## Dropbox
70-
[Documentation](ReadMe_dropbox.MD)
70+
[Documentation](Documentation/ReadMe_dropbox.MD)
7171

7272
## GDrive
73-
[Documentation](ReadMe_GDrive.MD)
73+
[Documentation](Documentation/ReadMe_GDrive.MD)
7474

7575

0 commit comments

Comments
 (0)