Author Topic: invoke "Generate makefile" via command line  (Read 14296 times)

aoehlke

  • Community Member
  • Posts: 48
  • Hero Points: 1
invoke "Generate makefile" via command line
« on: February 14, 2007, 12:28:50 am »
can it be done?

I use .vpj to manage my project and it does nice dependency checking... but our integration team requires a makefile.
I know I can force one frmo the vpj by right clicking the project file and choose "generate makefile" but I am wondering if this can also be invoked via command line?
that way, the integration team and first invoke the command to gen the makefile, then invoke the command to make it :)

and they can leave me the h3ll alone :)

anyone now if it can be done?  a lot of guys here think so, but just dont know how to do it... everyone says slick is so "open" that way.

hs2

  • Senior Community Member
  • Posts: 2733
  • Hero Points: 285
Re: invoke "Generate makefile" via command line
« Reply #1 on: February 14, 2007, 12:48:14 am »
vs "-#generate_makefile <abs-path-to.vpj> <makefile-filename>" could to the job.
(see projmake.e - generate_makefile() for help and maybe project.e - _maybeGenerateMakefile () in case you want to write a more sophisticated wrapper macro)

G00d luck,

HS2

aoehlke

  • Community Member
  • Posts: 48
  • Hero Points: 1
Re: invoke "Generate makefile" via command line
« Reply #2 on: February 14, 2007, 01:28:41 pm »
this doesnt seem to work.

what I entered was:

vs "-#generate_makefile /vobs/MPH/MCPACS/components/Code_Repository/3_0_GUI/m_omi/build/pio.vpj /home/c7777/test.mak"

I also tried it with angle brackets around the path to the vpj and the path to the makefile.

In both instances, the result is that the vslick GUI launches, but no makefile is generated


aoehlke

  • Community Member
  • Posts: 48
  • Hero Points: 1
Re: invoke "Generate makefile" via command line
« Reply #3 on: February 14, 2007, 01:34:24 pm »
I also tried it without the quotes, this seemed to work better, but still no makefile was generated.
in this case, the gui was launched, it started to recreate the tag file (I dont know why) and then it prompted me about the test.mak not existing and did I want to create it.

I said yes in the dialog, but it did not generate the makefile in the end.

aoehlke

  • Community Member
  • Posts: 48
  • Hero Points: 1
Re: invoke "Generate makefile" via command line
« Reply #4 on: February 14, 2007, 01:36:46 pm »
would it matter if I told you I was using slick v11.0.2 for solaris 9 (sparc)

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2171
  • Hero Points: 114
Re: invoke "Generate makefile" via command line
« Reply #5 on: February 14, 2007, 01:48:30 pm »
I think the issue is that generate make file does not parse the first argument.  When dealing with a _command, all items passed from the command line go to the first argument.

Here is a little wrapper command that will do what you want:
Code: [Select]
_command int my_generate_makefile(_str cmdline="") name_info(',')
{
   _str projectName=parse_file(cmdline);
   _str makefileName=parse_file(cmdline);

   if ( !file_exists(projectName) ) {
      _message_box(nls("File '%s' not found",projectName));
      return FILE_NOT_FOUND_RC;
   }
   int status=generate_makefile(projectName,makefileName);
   return status;
}

If you use this with hs2's command line (changing the command line of course) that will work.  Also, you could use -p instead of -# the editor will exit after the command runs.

aoehlke

  • Community Member
  • Posts: 48
  • Hero Points: 1
Re: invoke "Generate makefile" via command line
« Reply #6 on: February 14, 2007, 01:53:40 pm »
Hi Dan, and hs2... so you both seem to know what you are doing... but something is missing for me.
I am not sure exactly what I am to do with that bit of code Dan posted, as well as how it relates to hs2's post.

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2171
  • Hero Points: 114
Re: invoke "Generate makefile" via command line
« Reply #7 on: February 14, 2007, 02:16:45 pm »
Create a new ".e" file that has the following code:

Code: [Select]
#include "slick.sh"

_command int my_generate_makefile(_str cmdline="") name_info(',')
{
   _str projectName=parse_file(cmdline);
   _str makefileName=parse_file(cmdline);

   if ( !file_exists(projectName) ) {
      _message_box(nls("File '%s' not found",projectName));
      return FILE_NOT_FOUND_RC;
   }
   int status=generate_makefile(projectName,makefileName);
   return status;
}

And then load it using Macro>Load Module.

You can then run it from the command line by running:

vs "-#my_generate_makefile /vobs/MPH/MCPACS/components/Code_Repository/3_0_GUI/m_omi/build/pio.vpj /home/c7777/test.mak"

If you wanted to create a batch file that ran this and immediately exited the editor, rather than use "-#", you could use "-p" (but you would need to take the double quotes out).  I hope this helps (if not let me know).

hs2

  • Senior Community Member
  • Posts: 2733
  • Hero Points: 285
Re: invoke "Generate makefile" via command line
« Reply #8 on: February 14, 2007, 02:17:24 pm »
Congrats Dan - you were quicker ;)
@aoehlke:
Have a look at my simple example below, which is also taking care about opening the right workspace the project is assoc. to. This should help.
You can also take the best parts of Dan's and my code to create your own command.

add this to e.g. your vusrmacs.e:
Code: [Select]
_command void gmkf ( _str args='')
{
   _str workspace = '', project = '', makefile = 'makefile';
   parse args with workspace project makefile;
   if( ( workspace != '' ) && ( project != '' ) )
   {
      workspace_open( workspace, "", "", true, false );
      generate_makefile( project, makefile, false, false, false, true );
   }
}

and use this in your shell:
Code: [Select]
vs +new -p gmkf D:\Tools\Editor\SlickEdit\Projects\HS2.vpw D:\Tools\Editor\SlickEdit\Projects\HS2\HS2.
vpj

HS2

hs2

  • Senior Community Member
  • Posts: 2733
  • Hero Points: 285
Re: invoke "Generate makefile" via command line
« Reply #9 on: February 14, 2007, 02:19:56 pm »
And again the winner is .. Dan (HP++) :)

HS2

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2171
  • Hero Points: 114
Re: invoke "Generate makefile" via command line
« Reply #10 on: February 14, 2007, 02:21:51 pm »
Thanks hs2... but I did over look the workspace - a fairly significant detail.

aoehlke

  • Community Member
  • Posts: 48
  • Hero Points: 1
Re: invoke "Generate makefile" via command line
« Reply #11 on: February 14, 2007, 02:23:04 pm »
ok, i think i get it... the code goes into some "user customization area" file.
I guess I will have to ask the sysadmins to add this to the global slick edit settings for the company, as the integration team who uses this script, arent realy slickedit users.

where would this macro/command go if it were to be installed into a site wide customaization file (on solaris)

aoehlke

  • Community Member
  • Posts: 48
  • Hero Points: 1
Re: invoke "Generate makefile" via command line
« Reply #12 on: February 14, 2007, 02:26:06 pm »
well, I went looking for vusrmacs.e and didnt see one in my home directory slickedit folder.

to think I am in h3ll simply because of dependency checking... rats!

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2171
  • Hero Points: 114
Re: invoke "Generate makefile" via command line
« Reply #13 on: February 14, 2007, 02:30:52 pm »
Ok, what you need is a batch macro.  That is a little different.  I will post something in a little bit.

Dan

aoehlke

  • Community Member
  • Posts: 48
  • Hero Points: 1
Re: invoke "Generate makefile" via command line
« Reply #14 on: February 14, 2007, 02:31:42 pm »
well I am reading away here... and I think vusrmacs.e would get created in my home dir had a I recorded or loaded at least 1 macro.

I need to do 2 things...
I need to test this with my personal setup... then once it works, deploy it to the whole company.