SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: assafb on May 31, 2007, 01:59:30 PM

Title: Automating tag files creation
Post by: assafb on May 31, 2007, 01:59:30 PM
Hi,

In my environment the procedure I follow is:
1. I 'Pull' code base (from specific branch/label) into a root-directory <WS_DIR>.
2. I create SlickEdit Workspace/Project inside WS_DIR/my_slick
3. I add files into the tag file. Since there are >40K files in the code space I only select the directories I need. There are currently 5 such dirs.

I repeat the above procedure very often and so I would like to know if there is a way to automate it from a script - sort of how cscope works.

Any ideas?

Thanks,
Assaf
Title: Re: Automating tag files creation
Post by: StephenW on May 31, 2007, 09:59:24 PM
What I would to to automate this is to first use the Macros/Record Macro tool to record myself manually doing that sequence of things for a project.  After the macro is recorded, I would save it as a named macro and then copy the results across to the "custom" directory where I have all the macros I use for customising SlickEdit.  Then I would edit it to generalise it to allow it to be used with parameters for names involved (branch/label, root directory, automatically tagged directories).  After that, you can set up the macro to be run from the SlickEdit command line, from a toolbar button, a menu item or a hotkey.

Doing this does take a certain level of competence in writing SlickEdit macros, which I have.  If you are not able to do that yet, this sounds like a good project to learn on as it does not sound too difficult to do.  It is well worth the effort to be able to write your own SlickEdit macros, and people in the "Macro Programming" forum are ready and willing to help with problems getting things to work.
Title: Re: Automating tag files creation
Post by: hs2 on June 01, 2007, 01:02:14 AM
Just a little comment: The key is the automated creation of a workspace/project. Tagfile creation could be simplified by using the commandline tool vsmktags[.exe].

Good luck,

HS2
Title: Re: Automating tag files creation
Post by: assafb on June 02, 2007, 02:31:15 AM
HS2, Stepehn, thank you both for replying!

I've tried going along the path suggested by Stephen (recording macro), however the resulting macro fails to capture the
tag files added as part of the ws creation.

#include "slick.sh"
_command my_ws_create() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   _macro('R',1);
   workspace_new_project('0','(Generic)','my_proj',
                         '/auto/wsassafb/ws-xb_th_3_5_1/my_slick','0',
                         'my_proj','');
}


Adding files to the tag after it's creation did not help much either, as the resulting macro was just:

_command add_my_tag() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   _macro('R',1);
}

Bottom line - this task seems above my SlickC abilities level  :-)
Title: Re: Automating tag files creation
Post by: StephenW on June 04, 2007, 11:38:32 PM
I have never written any macros to do with loading projects, so I do not know my way around that code yet.  I did a little digging, and here are some things I found.

The macro called when you edit a project is "project_edit".  The way it is called (using "execute") is likely why the macro recording did not work past that point.  It is found, naturally enough, in the "project.e" file.  Its entry in the help file cross-references a macro called "project_add_file", which looks like the macro you need to add files to a project.  To use it you would have to run through all the files in the directories you wanted to add to the project and call it on each file.  I believe f_match is what you need to find the files in a directory.  As best I can tell, that would be the only way to do this using documented macros, but on first look it would seem fairly straightforward to write a macro to do it that way.

However, the toolbar that SE uses itself to edit projects has lots more functionality, such as adding an entire folder or tree to a project in one go, which is more like what you need.  The toolbar is in ptoolbar.e, and the code that adds folders or trees seems to be projecttbAddTree / projecttbAddFolder (which display the forms) and _OnUpdate_projecttbAddFolder / _OnUpdate_projecttbAddTree, which seem to do the real work.  So it might be possible to use the code from _OnUpdate_projecttbAddFolder / _OnUpdate_projecttbAddTree as a template for what you want to do.  But it is complicated code, and tied up with how SE does forms and how its GUI works, so probably not for a beginner at SE macros.  I am not sure I would want to try that myself as I have never written forms/GUI macros and am not really confident I know exactly how they work.  It is certainly a good idea to have a look at that code for ideas though, such as what error checks are done.
Title: Re: Automating tag files creation
Post by: assafb on October 04, 2007, 01:59:17 AM
Thanks for the tips.

I finally got to this and succeeded in pulling it through.

I'm attaching the macro to this post in case someone else is interested.

Assaf
Title: Re: Automating tag files creation
Post by: cdouble on October 05, 2007, 10:43:01 PM
I would like something similar - I have a list of the files for the project in a text file. Is there a way to get them into a slick-edit project easily? Or would I have to write a macro to parse the list?

Thanks,

CD
Title: Re: Automating tag files creation
Post by: assafb on October 05, 2007, 11:06:10 PM
You don't have to write a macro - as you can use the macro that I attached.. :-)