Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How deploy a OSX or IOS Delphi project from the Command line?

I'm building my Delphi Apps using a script like

call "C:\Program Files (x86)\Embarcadero\RAD Studio\11.0\bin\rsvars.bat"
msbuild.exe "C:\Projects\Foo\Bar.dproj"

And now I want add an option to deploy the application to an OSX (or IOS) system modifing such script, so is possible deploy a OSX or IOS Delphi project from the Command line?

like image 675
Salvador Avatar asked Aug 19 '13 19:08

Salvador


2 Answers

To deploy your application to a remote location , you must use the paclient.exe (Platform Assistant Client Application) tool.

In order to get the passed parameters Build and Run you project from RAD Studio and then check the Build tab of the message windows of the IDE.

Check the next image for a OSX Application using a profile called Local

enter image description here

From here you can extract all the parameters passed to the paclient.exe

  • Delete in the host the previous files (is exists)

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --Clean="Project7.app,C:\Users\RRUZ\Desktop\Test Deploy_@emb_.tmp"

the _@emb_.tmp file is a temp file created by the ide that contains all the files to deploy in this case the content is like so

Project7.app\Contents\MacOS\Project7.rsm
Project7.app\Contents\Entitlements.plist
Project7.app\Contents\MacOS\libcgunwind.1.0.dylib
Project7.app\Contents\MacOS\Project7
Project7.app\Contents\Resources\Project7.icns
  • Copy the Info.plist (contains settup info the the .app like the icon used and the version) file to the Host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="OSX32\Debug\Project7.info.plist,Project7.app\Contents\,1,Info.plist" Local

  • Copy the libcgunwind.1.0.dylib file (library) to the host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="c:\program files (x86)\embarcadero\rad studio\11.0\Redist\osx32\libcgunwind.1.0.dylib,Project7.app\Contents\MacOS\,1,libcgunwind.1.0.dylib" Local

  • Copy the bundler to the host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="OSX32\Debug\Project7,Project7.app\Contents\MacOS\,1,Project7" Local

  • Copy the Remote debug symbols file to the Host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="OSX32\Debug\Project7.rsm,Project7.app\Contents\MacOS\,1,Project7.rsm" Local

  • Copy the project icon to the Host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="c:\program files (x86)\embarcadero\rad studio\11.0\bin\delphi_PROJECTICNS.icns,Project7.app\Contents\Resources\,1,Project7.icns" Local

  • Copy the Entitlements.plist file to the Host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="OSX32\Debug\Project7.entitlements,Project7.app\Contents\,1,Entitlements.plist" Local

Final script

Finally you can put all this in a script file like so

call "C:\Program Files (x86)\Embarcadero\RAD Studio\11.0\bin\rsvars.bat"
MSBuild Project7.dproj 
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --Clean="Project7.app,C:\Users\RRUZ\Desktop\Test Deploy\files.txt"  
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="OSX32\Debug\Project7.info.plist,Project7.app\Contents\,1,Info.plist" Local 
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="c:\program files (x86)\embarcadero\rad studio\11.0\Redist\osx32\libcgunwind.1.0.dylib,Project7.app\Contents\MacOS\,1,libcgunwind.1.0.dylib" Local 
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="OSX32\Debug\Project7,Project7.app\Contents\MacOS\,1,Project7" Local 
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="OSX32\Debug\Project7.rsm,Project7.app\Contents\MacOS\,1,Project7.rsm" Local
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="c:\program files (x86)\embarcadero\rad studio\11.0\bin\delphi_PROJECTICNS.icns,Project7.app\Contents\Resources\,1,Project7.icns" Local 
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="OSX32\Debug\Project7.entitlements,Project7.app\Contents\,1,Entitlements.plist" Local 

Note : Remember create a file with the file names of all the files to deploy , in this sample script is called files.txt, this file is use by the paclient to cleanup previus deployed files.

like image 72
RRUZ Avatar answered Sep 18 '22 17:09

RRUZ


This answer is late, but I thought it might still be useful for other people. As part of a build script I also wanted to deploy a project automatically to OSX, but it is not directly possible with msbuild or Embarcadero's paclient.exe tool.

I wrote a helper command line tool called Embdeploy to automate the task. The source and a compiled binary are available on GitHub.

Here is some sample usage:

embdeploy.exe -deploy myproject.dproj
embdeploy.exe -platform OSX32 -config Release -deploy myproject.dproj
embdeploy.exe -profile <remote profile> -platform OSX32 -deploy myproject.dproj

The Embdeploy tool parses the .dproj file, which is XML, and generates a list of files to be copied for the specified configuration, platform, etc. It also detects the default platform, profile, configuration from the project if they are not given in the command line. You can define the deployment options in the Delphi IDE and then use the tool to do the deployment automatically.
To clean the remote project folder and do the actual deployment the tool uses paclient.exe and executes it with the appropriate parameters. Paclient.exe is detected from Delphi's install path.

There is another issue that the tool solves for me. My project includes additional bundled binaries, which are deployed with the app, but the Delphi IDE doesn't give enough control in this case. E.g. it deploys the additional binaries, but it doesn't set the Execute permission on the OSX, which has to be set by hand later. It is also not possible to 'codesign' those binaries and this is required for publishing the app to the Appstore.

To fix that I added the functionality to execute custom commands on the remote machine after deploying the file.
This is done like this:

embdeploy.exe -cmd "chmod +x myproject.app/Contents/MacOS/somebinary" myproject.dproj
embdeploy.exe -cmd "codesign .... myproject.app/Contents/MacOS/somebinary" myproject.dproj

This is done again with paclient.exe. The Embarcadero tool provides an option to deploy a script file, execute it and then delete it. I used this to execute my own commands by making a temporary shell file with the command, deploying it and executing it.
This way I could use "chmod", "productbuild" and whatever else I needed.

The tool is a bit basic and not optimized currently as I wrote it for my immediate needs, but I plan to expand it with a few more features. E.g. making a ZIP file of the OSX application bundle on Windows.

like image 44
VGeorgiev Avatar answered Sep 18 '22 17:09

VGeorgiev