Recent

Author Topic: Best way to maintain different versions?  (Read 1933 times)

AL

  • Sr. Member
  • ****
  • Posts: 261
Best way to maintain different versions?
« on: October 05, 2020, 03:29:32 pm »
My main programming OS is windows and when I add new feature to an application I do it in the Windows version.  I have ported my application to MacOs and Linux.  So when I am satisfied of the working on Windows I make a copy to the virtual Mac and to the Linux machine where I am a Lazarus copy installed and try it there also.  Many times I have to make small adjustments and then need to copy back to windows.
There should be a better / more efficient way of doing this.
What are you doing?
Thanks for suggestions.
Laz 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Best way to maintain different versions?
« Reply #1 on: October 05, 2020, 04:17:11 pm »
Use conditional compilation directive in the source code:
https://www.freepascal.org/docs-html/prog/progch2.html

Make your Lazarus/FPC able to cross compile to the targets you want:
https://wiki.lazarus.freepascal.org/Cross_compiling

If you use Lazarus, don't forget to use Build Modes:
Lazarus main menu > Project > Project Options > left panel: Compiler Options > Config and Target > Build modes
https://wiki.lazarus.freepascal.org/IDE_Window:_Compiler_Options#Build_modes

Use VirtualBox or something similar.
And set Shared Folders. Shared folders allow you to easily copy/paste file between host and virtual machines.

Because compiling projects on virtual machines usually is slower than on host system, you should do the compilation on your main system. But you first need to make your Lazarus/FPC to be able to do cross compilation to target MacOS and Linux from your Windows.

When working on your projects, after compiling the project, copy/paste the binary and all the necessary files to to shared folder and test it on the virtual machines. You don't have to close your Lazarus on the Windows. So you can easily improve the project, recompile, send it and test it on the virtual machines easily.

To be able to switch between host and virtual machines smoothly, your computer needs much memory. Buy an at least 8 GB RAM.
« Last Edit: October 05, 2020, 04:22:29 pm by Handoko »

AL

  • Sr. Member
  • ****
  • Posts: 261
Re: Best way to maintain different versions?
« Reply #2 on: October 05, 2020, 06:55:07 pm »
Thank you for your input Handoko, I am doing most of the recommandation already. 
I do have the conditionnal directive in the code for Win,Darwin and Linux.  So my code is the same for all versions.
I started the mac version by cross-compiling on windows, but I was advised that it was safer to compile on the target system.  I use shared folders to copy the source to the target MacOS.
Linux is on a separate computer. So there I use a USB Stick.  Possibly I could use the network, but so far the connection windows10-Ubuntu is not real smooth.
May be that now the app is stable, I can come back, as you suggest,  to cross-compiling and transfering only the binary to the target system for testing.
I have 12 Gb ram on my Windows, so I am OK there.
Laz 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Best way to maintain different versions?
« Reply #3 on: October 05, 2020, 07:11:08 pm »
... I was advised that it was safer to compile on the target system.

When developing, it will be easier and faster doing the coding, bug fixing and compilation on the host system and send only the binary to the virtual machines. Also, if you do the coding of the same project on multiple locations, you have chances to mess up the source code.

But, of course you should always test it on the real machine before release it to the public.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Best way to maintain different versions?
« Reply #4 on: October 06, 2020, 05:41:27 am »
I develop on a 2018 Mac mini (16G memory) running Mojave (for 32 bit) and cross-compile for Windows 32/64 which I test on Parallels VMs for 2000, XP, XP64, 7 and 10.

For the FreeBSD and Linux versions, I have Lazarus + FPC installed in VMware and Parallels VMs (I need to use VMware as Parallels no longer gives me appropriate screen resolutions for FreeBSD after PD v14). I also use VMware for macOS Big Sur betas because, again, Parallels 16 claimed support for it but fails miserably with a pathetic maximum 1024x768 screen resolution.

In the Windows VMs, I use File Explorer to access the binary.

In the FreeBSD and Linux VMs, I use rsync to sync the files.

The only issue that I lived with for ages was the different settings in the Project Options, but now that I use "build modes" that is taken care of without having to manually change every different setting between for different operating systems.

The compilation time on macOS (real) and the FreeBSD and Linux VMs is almost identical.

All the VMs are on an external Samsung T7 2TB SSD which is just as fast as the internal 256GB NVMe SSD.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Best way to maintain different versions?
« Reply #5 on: October 06, 2020, 09:42:28 am »
I make a copy to the virtual Mac and to the Linux machine where I am a Lazarus copy installed and try it there also.  Many times I have to make small adjustments and then need to copy back to windows.

For this part: Use git.

You can run git via shared folders, or (as I do) run git-server on one of your OS.
You do not need any external server (like github/lab), but you can  use them (as backup)

You can commit changes on Windows, then checkout on Linux/Mac make changes and commit them back.
If you have a final working version you can "rebase" to keep only the good commits.

wittbo

  • Full Member
  • ***
  • Posts: 150
Re: Best way to maintain different versions?
« Reply #6 on: October 06, 2020, 10:42:08 pm »
For development I use an iMac with macOS High Sierra, which is my main development platform. The iMac runs Windows 10 on VMWare Fusion. Using the Shared folders function Windows 10 accesses the same folder as the Mac. So I only have to recompile the program under windows 10. There is no need to copy the sources and manage multiple versions: there is only one version for mac and windows. The performance under VMWare is good; windows xp ran faster than on the original PC, WIndows 10 is less performant but sufficient. I have not tried a vm with linux yet, but it should work with the same principle.
-wittbo-
MBAir with MacOS 10.14.6 / Lazarus 2.2.4
MacStudio with MacOS 13.0.1 / Lazarus 2.2.4

AL

  • Sr. Member
  • ****
  • Posts: 261
Re: Best way to maintain different versions?
« Reply #7 on: October 07, 2020, 04:14:20 am »
Thank you all.  Many options to explore.
In the mean time I managed to access my Linux files from my Win10 station over the network.
I had a sync software on windows and I set it to sync the files on the Ubuntu computer.
However so far the updated files are in readonly mode.  Well.. nothing is easy!
Might try CWRsync instead.
 
Laz 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

AL

  • Sr. Member
  • ****
  • Posts: 261
Re: Best way to maintain different versions?
« Reply #8 on: October 07, 2020, 11:29:56 pm »
After an afternoon of back anf forth between the 2 computers I have it settled.
Main thing was to change the Samba conf file to include guest user = <my user name>
This is not really a safe method, but for my private home network that will do.
So Linux and Windows are syncing now.  I still need to trigger that manually. But this is really 2-3 clicks.
For the virtual Mac, I will do as wittbo and try to use the shared folder.
Thanks to all for the suggestions.
Laz 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

AL

  • Sr. Member
  • ****
  • Posts: 261
Re: Best way to maintain different versions?
« Reply #9 on: October 25, 2020, 09:32:58 pm »
Compiling to the VM-Shared folder on the virtual Mojave is working..  well almost.
Lazarus cannot update/create the link to the exec in the .app bundle.
Any hints on that?
For the moment, I use a Bash script in Terminal to copy the exec in the bundle and run it from Finder.
So compile with Lazarus, go in terminal to run the update script, go in Finder and clic the App for running.
Not a big problem, just more steps than click RUN!


Laz 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Best way to maintain different versions?
« Reply #10 on: October 25, 2020, 11:49:39 pm »
Project > Project options > Compiler commands - Execute after... might do the trick.

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Best way to maintain different versions?
« Reply #11 on: October 26, 2020, 06:51:32 am »
If you are routinely building of a number of platforms, virtual or real, then you may find it easier on the Mac and Linux at least to build from the command line. You have bash script that calls lazbuild, give lazbuild the project mode and out it pops at the end. Far quicker and repeatable than firing up the IDE.

The IDE is great for dev work, but I find my build scripts the way to go when I am getting ready for a release. Particularly when it comes to packaging ....

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018