-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
305 changed files
with
6,530 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
userPreferences.* | ||
Data/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Lipo : _CLI | ||
|
||
`Lipo` is a subclass of `_CLI` to execute the `lipo` program on macOS. | ||
|
||
## .onResponse() | ||
|
||
**.onResponse**($files : Collection; $parameters : Collection) | ||
|
||
Used internally to process files returned from an instance of `_Find`. | ||
|
||
## .thin() | ||
|
||
**.thin**($option : Variant)->$this : cs.Lipo | ||
|
||
Process a collection of files/folders or a single file/folder. | ||
|
||
Chained calls are queued as sequential tasks. | ||
|
||
An option should have the following properties: | ||
|
||
|Property|Type|Description| | ||
|:-|:-|:-| | ||
|src|4D.File or 4D.Folder|the input file or folder| | ||
|dst|4D.File or 4D.Folder|the output file or folder| | ||
|arch|Text|the architecture type to keep `arm64` (default) or `x86_64`| | ||
|
||
`src` and `dst` must be matching objects. | ||
|
||
When `src` and `dst` are folders, an instance of `_Find` is used to find files that have the UNIX executable bit set. The filtered result is received asynchronously in `.onResponse()` and passed to `.thin()`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# LipoForm : _Form | ||
|
||
`LipoForm` is a subclass of `_Form` to execute the `lipo` program. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# _Basic_Controller : _CLI_Controller | ||
|
||
`_Basic_Controller` is a subclass of `_CLI_Controller` to execute the `lipo` program in a worker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# _CLI | ||
|
||
`_CLI` is the base class to implement console program proxies. Extend this class to implement a specific command line interface. | ||
|
||
## .new() | ||
|
||
**.new**($executableName : Text) : cs._CLI | ||
|
||
Pass the name of the CLI agent. It should be placed in the following location: | ||
|
||
``` | ||
/RESOURCES/bin/{macOS|Windows}/ | ||
``` | ||
|
||
The constructor defines the following properties: | ||
|
||
|Property|Type|Description| | ||
|:-|:-|:-| | ||
|controller|cs._CLI_Controller|read-only| | ||
|currentDirectory|4D.Folder|read-only| | ||
|EOL|Text|read-only| | ||
|executableFile|4D.File|read-only| | ||
|executableName|Text|read-only| | ||
|executablePath|Text|read-only| | ||
|name|Text|read-only| | ||
|platform|Text|read-only| | ||
|
||
The class is intended to be subclassed. `.name` returns the value `OB Class(This).name` which is the name of the extended class, not this class. | ||
|
||
## .escape() | ||
|
||
**.escape()**($in : Text) : Text | ||
|
||
Add double quotes on each sides of a string that contains metacharacters on Windows, except when the last character is a backslash in which case the backslash is escaped with a backslash before the whole string is quoted. Escape metacharacters on Mac. Not all CLI agent respect this type of escaping. | ||
|
||
## .quote() | ||
|
||
**.quote**($in : Text) : Text | ||
|
||
Simply add double quotes on each sides of a string. Some CLI agent prefer this type of escaping. | ||
|
||
## ._chmod() | ||
|
||
**._chmod()** | ||
|
||
Executable files transferred from server to client in `/RESOURCES/` are copies as regular documents and missing the UNIX executable bit. This internal function is internally called once in the constructor to make sure that the CLI agent is ready to run on a Mac client. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# _CLI_Controller | ||
|
||
`_CLI_Controller` is the base class for `_CLI` controllers. Extend this class to control a specific console program. | ||
|
||
## .new() | ||
|
||
**.new**($CLI : cs._CLI) : cs._CLI_Controller | ||
|
||
The constructor should not be called directly. It is invoked when a `_CLI` is instantiated. | ||
|
||
You can over-ride the following properties: | ||
|
||
|Property|Type|Description| | ||
|:-|:-|:-| | ||
|currentDirectory|4D.Folder|| | ||
|dataType|Text|| | ||
|encoding|Text|| | ||
|hideWindow|Boolean|| | ||
|onData|4D.Function|| | ||
|onDataError|4D.Function|| | ||
|onError|4D.Function|| | ||
|onResponse|4D.Function|| | ||
|onTerminate|4D.Function|| | ||
|timeout|Integer|| | ||
|variables|Object|| | ||
|
||
The constructor defines the following properties: | ||
|
||
|Property|Type|Description| | ||
|:-|:-|:-| | ||
|commands|Collection|read-only| | ||
|complete|Boolean|read-only| | ||
|instance|cs._CLI|read-only| | ||
|worker|4D.SystemWorker|read-only| | ||
|
||
## .execute() | ||
|
||
**.execute**($command : Variant) | ||
|
||
Execute one or more commands sequentially. Pass either a text or a collection of text. Subsequent calls to `.execute()` will add the new command to the task queue if an assoicaited worker is already running or else launch a new worker. Private callback functions intecept the `onResponse` and `onTerminate` events during exection to manage to task queue. All custom event hooks, including `onResponse` and `onTerminate` are invoked. Test `This.complete` to know if the event is the last in queue. | ||
|
||
## .terminate() | ||
|
||
**.terminate**() | ||
|
||
Clear the task queue and abort the running system worker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# _Find : _CLI | ||
|
||
`_Find_` is a subclass of `_CLI` to execute the `find` command on macOS. | ||
|
||
## .findExecutables() | ||
|
||
**.findExecutables**($option : Variant)->$this : cs._Find | ||
|
||
Find files that have the UNIX executable bit set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# _Find_Controller : _CLI_Controller | ||
|
||
`_Find_Controller` is a subclass of `_CLI_Controller` to execute the `find` command on macOS without UI. | ||
|
||
## .bind() | ||
|
||
**.bind**($instance : cs._CLI) | ||
|
||
Binds the `cs._CLI` instance to a callback functionality. | ||
|
||
The instance will receive callback methods for the following events: | ||
|
||
* **.onResponse**($files : Collection; $parameters : Collection) | ||
* **.onTerminate**($parameters : Collection) | ||
|
||
`$parameters` is `Copy parameters(2)` from `.bind()`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# _Form | ||
|
||
`_Form` is the base class for form controllers. | ||
|
||
This class is prototype only. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# _Form_Controller : _CLI_Controller | ||
|
||
`_Form_Controller` is a subclass of `_CLI_Controller` to execute a console program in a form. | ||
|
||
The class defines the following properties: | ||
|
||
|Property|Type|Description| | ||
|:-|:-|:-| | ||
|stdOut|Text|read-only| | ||
|stdErr|Text|read-only| | ||
|onDataCount|Integer|read-only| | ||
|onDataErrorCount|Integer|read-only| | ||
|onResponseCount|Integer|read-only| | ||
|onTerminateCount|Integer|read-only| | ||
|
||
## .bind() | ||
|
||
**.bind**($options : Object) | ||
|
||
Binds the supplied form object names to a specific functionality. | ||
|
||
The following object names are supported: | ||
|
||
|Property|Type|Description| | ||
|:-|:-|:-| | ||
|startButton|Text|| | ||
|stopButton|Text|| | ||
|
||
The enabled/disabled status of each button object is toggled automatically. | ||
|
||
**.start**() | ||
|
||
## .start() | ||
|
||
**.start**() | ||
|
||
## .stop() | ||
|
||
**.stop**() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# _LipoForm : _Form | ||
|
||
`_LipoForm` is a subclass of `_Form` to run the `lipo` program. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# _LipoUI_Controller : _Lipo_Controller : _CLI_Controller | ||
|
||
`_LipoUI_Controller` is an example subclass of `_CLI_Controller` to execute the `lipo` program on macOS with UI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# _Lipo_Controller : _CLI_Controller | ||
|
||
`_Lipo_Controller` is an example subclass of `_CLI_Controller` to execute the `lipo` program on macOS without UI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"forms": { | ||
"Lipo": { | ||
"timeStamp": "2024-02-20T07:56:27Z", | ||
"destination": "detailScreen" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"methods": { | ||
"TEST_Worker": { | ||
"timeStamp": "2024-02-20T05:32:40Z", | ||
"attributes": { | ||
"invisible": true | ||
} | ||
}, | ||
"TEST_Lipo": { | ||
"timeStamp": "2024-02-20T05:04:07Z" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
Class extends _CLI | ||
|
||
property files : Collection | ||
|
||
Class constructor($controller : 4D:C1709.Class) | ||
|
||
Super:C1705("lipo"; $controller) | ||
|
||
This:C1470.reset() | ||
|
||
Function reset() : cs:C1710.Lipo | ||
|
||
This:C1470.files:=[] | ||
|
||
return This:C1470 | ||
|
||
Function terminate() | ||
|
||
This:C1470.controller.terminate() | ||
|
||
Function onResponse($files : Collection; $parameters : Collection) | ||
|
||
//find complete | ||
|
||
This:C1470.files.combine($files) | ||
|
||
var $srcFolder; $dstFolder : 4D:C1709.Folder | ||
|
||
$srcFolder:=$parameters.at(0) | ||
$dstFolder:=$parameters.at(1) | ||
|
||
$dstFolder.create() | ||
|
||
$srcFolder.copyTo($dstFolder; fk overwrite:K87:5) | ||
|
||
var $src; $dst : 4D:C1709.File | ||
|
||
var $arch : Text | ||
$arch:=$parameters.at(2) | ||
|
||
$options:=New collection:C1472 | ||
|
||
$srcPath:=Split string:C1554($srcFolder.parent.path; "/"; sk ignore empty strings:K86:1) | ||
|
||
For each ($src; $files) | ||
|
||
$pathComponents:=Split string:C1554($src.path; "/"; sk ignore empty strings:K86:1) | ||
|
||
$dst:=$dstFolder.file($pathComponents.slice($srcPath.length).join("/")) | ||
|
||
$options.push(New object:C1471("src"; $src; "dst"; $dst; "arch"; $arch)) | ||
|
||
End for each | ||
|
||
This:C1470.thin($options) | ||
|
||
Function thin($option : Variant)->$this : cs:C1710.Lipo | ||
|
||
$this:=This:C1470 | ||
|
||
var $commands; $options : Collection | ||
$commands:=New collection:C1472 | ||
|
||
Case of | ||
: (Value type:C1509($option)=Is object:K8:27) | ||
$options:=New collection:C1472($option) | ||
: (Value type:C1509($option)=Is collection:K8:32) | ||
$options:=$option | ||
End case | ||
|
||
For each ($option; $options) | ||
|
||
Case of | ||
: (OB Instance of:C1731($option.src; 4D:C1709.File)) && (OB Instance of:C1731($option.dst; 4D:C1709.File)) | ||
|
||
$input:=File:C1566($option.src.platformPath; fk platform path:K87:2) | ||
$output:=File:C1566($option.dst.platformPath; fk platform path:K87:2) | ||
|
||
$output.parent.create() | ||
|
||
$command:=This:C1470.escape(This:C1470.executablePath) | ||
$command:=$command+" "+This:C1470.escape($input.path) | ||
Case of | ||
: (Value type:C1509($option.arch)=Is text:K8:3) && ($option.arch#"") | ||
$command:=$command+" -thin "+This:C1470.escape($option.arch) | ||
Else | ||
$command:=$command+" -thin arm64" | ||
End case | ||
$command:=$command+" -output "+This:C1470.escape($output.path) | ||
$commands.push($command) | ||
|
||
: (OB Instance of:C1731($option.src; 4D:C1709.Folder)) && (OB Instance of:C1731($option.dst; 4D:C1709.Folder)) | ||
|
||
$find:=cs:C1710._Find.new(cs:C1710._Find_Controller) | ||
$find.controller.bind(This:C1470; $option.src; $option.dst; $option.arch) | ||
$find.findExecutables($option.src) | ||
|
||
End case | ||
End for each | ||
|
||
This:C1470.controller.execute($commands) |
Oops, something went wrong.