Author Topic: Creating a custom project type for PIC assembler projects  (Read 3860 times)

mbirthelmer

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Creating a custom project type for PIC assembler projects
« on: January 20, 2010, 02:23:56 pm »
I'd like to create a custom project template that I can use for my PIC-related projects. The following steps are required in this simple toolchain, using the gputils package:
- compile: %.asm -> %.o - gpasm -c %f
- compile all: *.asm -> *.o - gpasm needs to be called seperately for each file
- build: *.o -> output.hex - gplink ... *.o

It doesn't seem like this should be a big problem, and yet I'm having a hard time figuring out where to specify these steps. Compiling a single file is easy, just by adding a new target for "Compile".
But even with "Compile All", I don't know how to proceed - is there even a way to make SlickEdit apply a command to all files in a project without re-inventing the wheel?
The same problem when trying to build: how can I get a list of all .o files? I imagine I would have to specify somehow that .asm files turn into .o files, and then get SlickEdit to do the conversion for me, but again, I'm absolutely clueless.

For now I've written a simple makefile that does what I need, but it seems like a cludge, and I would prefer to contain these projects entirely within SlickEdit. Any advice is appreciated!

Graeme

  • Senior Community Member
  • Posts: 2385
  • Hero Points: 314
Re: Creating a custom project type for PIC assembler projects
« Reply #1 on: January 21, 2010, 11:58:32 am »
I'm afraid I'm hazy about this stuff and I suspect it's not documented very well in slickedit but you could try reading this thread
http://community.slickedit.com/index.php?topic=3832.0
or maybe someone else can help.

Graeme

Scott H

  • Senior Community Member
  • Posts: 240
  • Hero Points: 9
Re: Creating a custom project type for PIC assembler projects
« Reply #2 on: January 21, 2010, 01:18:23 pm »
Well, this isn't perfect, but it may help get you started while I look into this more.  Attached is a macro file you can save somewhere, then open it in SlickEdit and type "load" on the command line (I included the command code in this post so you could see it).  You'll now have a command available called "GpasmCompileAllFiles" that will iterate through the set of files in your active project and will shell gpasm to compile each *.asm file individually.  Here are some of its limitations:

1. It doesn't output to the build window.  If you want to see the output, you can make shell wait after each compile by using shell(cmd, "W"); instead.
2. I'm not sure how to bind this to a build menu item using the project configuration dialog yet.  I saw the check box to indicate that the command line text was actually a macro call, but I'm not able to get this to work.
3. You will probably need to specify a full path to gpasm in the macro if it's not in your system path.

To run this macro, go to the command line and type "GpasmCompileAllFiles".

Code: [Select]
_command void GpasmCompileAllFiles() name_info(',')
{
   _str file_array[];
   int i = 0;

   file_array._makeempty();
   // get the name of the current project
   _str project_filename = _project_get_filename();
   // get the list of files in that project
   GetProjectFileList(project_filename, file_array);
   // now compile each one
   for (i = 0; i < file_array._length(); i++) {
      _str file_name = maybe_quote_filename(file_array[i]);
      // get the extension of the current file
      _str ext = get_extension(file_name);
      // is this an asm file?
      if (stricmp(ext, 'asm') == 0) {
         // here's where you build the command to shell to the command line
         _str cmd = 'gpasm -c 'file_name;
         //say('Compiling 'file_name);
         shell(cmd);
      }
   }
}

Scott H

  • Senior Community Member
  • Posts: 240
  • Hero Points: 9
Re: Creating a custom project type for PIC assembler projects
« Reply #3 on: January 21, 2010, 07:17:07 pm »
Alright, to bind this to the "Compile All" target, do the following:

1. Go to Project > Project Properties and select the Tools tab. 
2. Select "Compile All" in the list.
3. Put GpasmCompileAllFiles in the "Command line" text box.
4. Check the "Command is a Slick-C macro" checkbox.
5. Click OK.

Now, if you select Build > Compile All, it will run the GpasmCompileAllFiles command for you.