Switching compile target makes codetools lose knowledge about units or unit paths (need to restart lazarus or reopen project)
- Lazarus/FPC Version: Lazarus 2.3.0 rmain-2_3-321-g5ae19e4e FPC 3.3.1 x86_64-linux-qt5
- Operating System: Linux
- CPU / Bitness: x86_64
What happens
Switching between two build configurations where on of them uses a cross compiler makes Codetools completely confused, not finding units anymore, errors on code completion, unable to add new event methods, form designer silently losing sync between lfm and pas, etc.
What did you expect
Switching build modes with different target OS is unproblematic and works seamlessly
Steps to reproduce
This has been tested in the main branch but affects the fixes branch in the same way.
I did the following to reproduce it:
- Have lazarus installed and working properly on Linux and have a cross compiler for Windows installed also.
- create a new empty default application project (graphical, using LCL)
- save it somewhere
- make sure it compiles and runs OK (optional).
- open the project settings and add a new build configuration, call it "Windows"
- switch to "Windows" configuration and change target OS to Win64 and CPU to x86_64
- save project settings and make sure it also compiles for Windows without errors.
so far everything seems OK and working. But now the fun begins:
- select "Default" build configuration
- observe that when hovering the mouse (with ctrl-key) over all units in the uses clause all of them are underlined and clickable, this is OK.
- select "Windows" build configuration
- observe that when hovering the mouse (with ctrl-key) over all units in the uses clause "Forms" and "Graphics" is not clickable!
- click the form, select "events" tab, select "OnCreate", observe that in the Message window an error appears: "Unit not found: Graphics"
- Try to add the OnCreate event method and observe that a messagebox pops up: "cannot create new method, please fix the error shown in the message window"
- Try using code completion (shift space) anywhere in the Unit1.pas file and it will complain about units not found and highlight it in the uses clause
- leave it at build configuration "Windows", save the project, close and reopen the project
- it is still at build configuration "Windows", observe that everything is working now!
- switch to build configuration "Default" and observe that now "Default" is broken and shows the symptoms as above
It gets worse if you add and/or remove controls from the form while it is in this state, this is probably how I got my lfm files out of sync with the pas yesterday! All kinds of funny things happening: Try adding a button to the form and observe that the button is added to the lfm file but NO field is added to the form class in the pas file, leading to strange runtime errors during form creation and a lot of headaches!