Author Topic: New Project Wizard - copying files  (Read 13789 times)

Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
New Project Wizard - copying files
« on: November 02, 2018, 03:13:42 pm »
Hello all,

Writing a New Project Wizard. Need to be able to select a set of options using a multi select combo box (I can do that bit) which specifies which code files should be physically copied in to the project directories and added to the project files list, from a 'files' locations. I believe this files location should be under the folder the wizard.script file is in, but been trawling through various wizard.scripts files but not found what I need.

I am sure its obvious, but any hints? Are there functions to do this, is anything done automagically, do I have to simply grab the source file folder from somewhere, and use scripts to manually copy everything to the Projects folder? (They will be in a subfolder of the project itself if possible)

Jimbo

Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: New Project Wizard - copying files
« Reply #1 on: November 02, 2018, 03:36:57 pm »
Forgot to ask, also need to be able to setup various debugger settings so the generated projects can immediately use OpenOCD. Not found any functions for setting debugger options in the Wiizard.script , so any information there would also be useful.

TIA

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: New Project Wizard - copying files
« Reply #2 on: November 03, 2018, 03:51:31 pm »
Forgot to ask, also need to be able to setup various debugger settings so the generated projects can immediately use OpenOCD. Not found any functions for setting debugger options in the Wiizard.script , so any information there would also be useful.

TIA
at the moment this is  not possible:
http://forums.codeblocks.org/index.php/topic,16852.msg149433.html#msg149433
https://sourceforge.net/p/codeblocks/tickets/513/

Maybe i find some time to fix this...
@obfuscated: are changes to the scripting interface still locked?

Can you list the options you want to change?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: New Project Wizard - copying files
« Reply #3 on: November 03, 2018, 04:58:02 pm »
The switch to scrat is frozen at the moment. The original changes you've made left the whole binding without proper error handling. I/we need to find a solution for this problem before continuing. But at the moment I don't have time/energy for it.

Also I'm not sure when I'll resume the work related to the removal of project hooks. Probably I should extract it from my branch with other changes.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: New Project Wizard - copying files
« Reply #4 on: November 04, 2018, 11:50:23 pm »
Quote
I am sure its obvious, but any hints? Are there functions to do this, is anything done automagically, do I have to simply grab the source file folder from somewhere, and use scripts to manually copy everything to the Projects folder?

The Wizard "asks" you for the file to generate in
Code
function GetGeneratedFile(file_index)
function. As described you have to return the filename and content with the syntax:
Code
filename.ext;contents
The variable index is incremented automatically on each call, so you can go trough an array of your files.
If you have templates you have to read them and return the content from this function
Code
    local path = Wizard.FindTemplateFile("YourTemplateFileName");
    local buffer = IO.ReadFileContents(path);
You can modify the content of the file before you return it.

The function
Code
Wizard.FindTemplateFile

Will search for the filename in the
Quote
/templates/wizard/
sub folder. So you should put your template files in a  subfolder of these path. Ofc you have to add this subfolder to the name you provide to the FindTemplateFile function.

I hope this helps a bit...

@oBFusCATed
So is this a no or a go for the api changes to the script binding? Probably not before the next release?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: New Project Wizard - copying files
« Reply #5 on: November 05, 2018, 09:02:22 am »
@oBFusCATed
So is this a no or a go for the api changes to the script binding? Probably not before the next release?
It is fine to add stuff to the script bindings. We'll have to do some conflict resolving, but this is inevitable anyway.
But keep in mind that the project hooks aren't a good design and it is not really a good idea to expose them to scripting.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: New Project Wizard - copying files
« Reply #6 on: November 05, 2018, 10:58:06 am »
Quote
I am sure its obvious, but any hints? Are there functions to do this, is anything done automagically, do I have to simply grab the source file folder from somewhere, and use scripts to manually copy everything to the Projects folder?

The Wizard "asks" you for the file to generate in
Code
function GetGeneratedFile(file_index)
function. As described you have to return the filename and content with the syntax:
Code
filename.ext;contents
The variable index is incremented automatically on each call, so you can go trough an array of your files.
If you have templates you have to read them and return the content from this function
Code
    local path = Wizard.FindTemplateFile("YourTemplateFileName");
    local buffer = IO.ReadFileContents(path);
You can modify the content of the file before you return it.

The function
Code
Wizard.FindTemplateFile

Will search for the filename in the
Quote
/templates/wizard/
sub folder. So you should put your template files in a  subfolder of these path. Ofc you have to add this subfolder to the name you provide to the FindTemplateFile function.

I hope this helps a bit...

@oBFusCATed
So is this a no or a go for the api changes to the script binding? Probably not before the next release?

Thanks.

So the process is :

Put all the requried template files in templates/wizard/jimbo/blahblah

In the script file GetGeneratedFile(idx)
   FindtemplateFile
   IO.ReadFileContents(path)
   Add required destintation file name to front of the file string read in.
   return that new string.
   If finished, return empty string.

Is this sort of process that could/should be in the common scripts file?


I see from the posts above that there are some gaps in the areas we would like to use (setting up debugger is one, we also need a functioning SVD dialog). I do not know who the lead developers are on Code::Blocks, but our company would likely be interested in funding development of any missing features that we are unable to add ourselves. Obviously experienced C::B developers are going to be able to produce results more quickly than we would be able to achieve internally, although we would be throwing resource at this. Who would I need to talk to about that? Would need all this stuff by Q2/3 next year or thereabouts.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: New Project Wizard - copying files
« Reply #7 on: November 09, 2018, 07:07:24 pm »
I'm available for doing patch reviews and guidance how to implement something. If you're going to change something in Code::Blocks it is better to ask first if the direction is good, so there is a change that your modification would be accepted.

I'm not sure if I'll be available to do feature implementations next year.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: New Project Wizard - copying files
« Reply #8 on: November 19, 2018, 05:28:29 pm »
I'm available for doing patch reviews and guidance how to implement something. If you're going to change something in Code::Blocks it is better to ask first if the direction is good, so there is a change that your modification would be accepted.

I'm not sure if I'll be available to do feature implementations next year.

OK, thanks for getting back to me. I'm definitely going to be needing some pointers, but hopefully that will be enough to get the team here up to speed so we can make our own changes. We will of course run them by the devs here to make sure what we do is acceptable upstream  -we would want the work done to expand the feature set of CB for all, not just us. There's likely to be some GUI tidying up work, plus getting good SVD support and improving the New project stuff to allow debugger setup in project wizards.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: New Project Wizard - copying files
« Reply #9 on: September 29, 2019, 05:50:07 pm »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: New Project Wizard - copying files
« Reply #10 on: November 20, 2019, 03:56:27 pm »
The remote debugging feature have been committed.
See these two links:
* https://sourceforge.net/p/codeblocks/tickets/512/#fcab
* http://forums.codeblocks.org/index.php/topic,16852.msg159912.html#msg159912

That's good news. We've been delayed here (by exactly a year looking at the dates of my last post), but now getting back on to this.