Original Reporter info from Mantis: RolfW @Rolf_Wetjen
Reporter name: Rolf Wetjen
Description:
My template has a customized file project1.lpi. Projecttemplates copies this file to the ProjDir (and all other files of course) but overwrites the lpi file with some defaults later. function TTemplateProjectDescriptor.InitProject in idetemplateproject.pp sets some defaults for AProject but doesn't take care of the settings from the existing lpi file (the template's one). So the template's lpi file is overwritten with the defaults set here.
My project.ini:
[Variables]
ProjDir=D:\Rolf\Lazarus\Rolf\Test<br/>
ProjName=project1
Looking at the code, your procedure FileReplaceText is very slow.
With sl: TStringList this piece of code : sl.Text:=ReplaceText(sl.Text,AFrom,ATo);
first joins lines to one string, the runs ReplaceText, then splits the string again by NewLines for the StringList.
Iterating the list and replacing line by line may be faster. I didn't test yet, just looking it.
ReplaceText() calls StringReplace() which is slow as well, but should be OK here.
BTW, we usually put used units in the interface section unless really needed in implementation section for cyclic dependency.
It makes following and designing dependencies easier and prevents accidental cyclic dependencies.
I can't remenber that I implemented something special for ProjectFile.
For the moment it's working this way:
project.ini
[Variables]
ProjDir=D:\Rolf\Lazarus\Rolf\Test
ProjName=test1
MainUnit=unit11
[Project]
Name=Test Anwendung für Windows
Description=Eine Windows Anwendung zum Testen
ProjectFile=project1
Recurse=0
The project files in the template folder are project1.lpi, project1.lpr,
project1.lps.
The template project create dialog (frmtemplatevariables) EProjectName
field is prefilled with ProjName (test1) from project.ini and the new
project files are test1.lpi, .lpr, .lps in this example. So, there's a
rename based on the user input in frmtemplatevariables.
This is the 'old' default Lazarus implementation and I didn't change it
as far as I remember.
Maybe I missunderstood something. For me it seems that
project.ini|ProjName and project.ini|ProjectFile variables both want to
rename the same set of project files.
May be the missing point is to set the TProjectTemplate|ProjectFile
property based on project.ini|ProjName instead of
project.ini|ProjectFile. If so, the projectini|ProjectFile variable
isn't needed anymore and the documentation needs a change too.
Something is duplicate here?!
Regards,
Rolf (RolfW)
...
Am 17.11.2021 um 09:23 schrieb Juha Manninen (@JuhaManninen):
You're receiving this email because of your account on gitlab.com. If
you'd like to receive fewer emails, you can unsubscribe
https://gitlab.com/-/sent_notifications/REDACTED/unsubscribe
from this thread or adjust your notification settings.
meanwhile I've verified the code. It's working exactly as described in in projecttemplates wiki (https://wiki.freepascal.org/Project_Templates).
Anyway, I've attached two small patches:
frmtemplatevariables.patch
Allows to prefill the variables in ProjectVariablesForm from project.ini.
[Variables]
VarName1=Description 1[|Value1]
Don't know who may change the wiki?
projecttemplates.patch
ProjectFile in project.ini isn't mandatory. The first *.lpi file will be taken as ProjectFile if it's not specified or ProjectFile.lpi doesn't exist.
A suggestion to change the wiki for a clarification of ProjName and ProjFile:
ProjName: The filename (no extension) of the new project files in ProjDir.
ProjectFile
Filename (no extension) of the project files in the templates folder.
All files ProjectFile.* will be copied to the folder of the new created project (ProjDir) and renamed to the new project name (ProjName). ProjectFile is not mandatory. The first *.lpi file in the trmplate folder will be taken for ProjectFile if it's not specified or if ProjectFile.lpi doesn't exist.
Applied, thanks.
I declared sr: TSearchRec; in var section and used ExtractFileNameOnly(sr.Name) in one place.
I wonder how it compiled for you without sr declared.
Don't know who may change the wiki?
You. The idea of a wiki page is that anybody involved can change it. You know best what your own changes do, so...
Sorry, I've no idea how to reopen the issue.
Up in this page there is a "Close" button. It will say "Reopen" once this issue is closed (after reloading the page). You can close this when you feel the ProjectTemplates pkg is good, and see it yourself.
Or does reopening require a developer status? Not sure.
Ok, I'll update the wiki when 2.2 is final.
sr: TSearchrec was my mistake. Needed of course.
Open/Close/Reopen: Needs more access rights. Now this button shows "Open" (for me) and I can't change it.
Now I understand. You created the issue in the old Mantis and your GitLab user is not mapped to it. GitLab sees you as a different user. No problem, you can close and reopen new issues you create here.
Thanks. I close this now.