Author Topic: Slickedit creating corrupted makefile  (Read 4016 times)

bremenpl

  • Community Member
  • Posts: 85
  • Hero Points: 0
  • Electrical Engineer
Slickedit creating corrupted makefile
« on: July 13, 2013, 02:19:43 pm »
Hello there guys,
I have a bit of a problem with makefiles in slickedit for a while. The thing is the autogenerated makefile is corrupted somehow, this happened to me before when using gnu arm tools as compiller and now when using gcc and crossgcc, please consider this part of my autogenerated makefile:

COMPILE=/home/bremen/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc-4.7.2 -c   -o "$(OUTDIR)/$(*F)e" $(CFG_INC) $<

See the bold e letter? Why is it getting there? This happend for debug and release. Everytime the autogenerated makefile changes i have to edit it like this:

COMPILE=/home/bremen/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc-4.7.2 -c   -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $<

So it can create regular output files. If anyone encounter this and knows how to fix it, please tell me i would be really gratefull.
« Last Edit: July 13, 2013, 02:22:09 pm by bremenpl »

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Slickedit creating corrupted makefile
« Reply #1 on: July 13, 2013, 07:39:30 pm »
Look in the .vpj file(s) for a node "OutputExts", and make sure it's something reasonable.  I think it might be set to "e" at the moment.

bremenpl

  • Community Member
  • Posts: 85
  • Hero Points: 0
  • Electrical Engineer
Re: Slickedit creating corrupted makefile
« Reply #2 on: July 13, 2013, 07:43:05 pm »
Code: [Select]
OutputExts="*.o"
Has to be something else, but thank you for answer.

Graeme

  • Senior Community Member
  • Posts: 2727
  • Hero Points: 337
Re: Slickedit creating corrupted makefile
« Reply #3 on: July 14, 2013, 09:04:34 am »
After quite a while I figured out that this problem seems to be caused by some code in _parse_project_command that has been commented out in V18 (compared with V16) and prevents the %oe option from working properly for gnu c make file generation.  I think slickedit will probably be able to fix this with a hotfix fairly easily, if you report it to them.

<some time earlier>
If I create a gnu c project with auto generated make file I get this in the make file

COMPILE=g++ -c   -g -o "$(OUTDIR)/$(*F).exee" $(CFG_INC) $<

i.e. I get .exee where you just get e  - probably because I left a checkbox enabled for something to do with .exe

My make file has this
COMMON_OBJ=$(OUTDIR)/testgcc1.o
OBJ=$(COMMON_OBJ) $(CFG_OBJ)
ALL_OBJ=$(OUTDIR)/testgcc1.o
COMPILE=g++ -c   -g -o "$(OUTDIR)/$(*F).exee" $(CFG_INC) $<
LINK=g++  -g -o "$(OUTFILE)" $(ALL_OBJ)

and searching slick macro files for COMMON_OBJ you find this in projmake.e
Code: [Select]
      splitAndInsertValueList("COMMON_OBJ", makeCommandCLSafe(commonObjs));
      insert_line("OBJ=$(COMMON_OBJ) $(CFG_OBJ)");
      splitAndInsertValueList("ALL_OBJ", makeCommandCLSafe(fullObjectList));

      // only add these if there are non-linkable objects
      if(hasNLObjects) {
         splitAndInsertValueList("CFG_OBJ_NL", makeCommandCLSafe(nlCfgObjs));
         splitAndInsertValueList("COMMON_OBJ_NL", makeCommandCLSafe(nlCommonObjs));
         insert_line("OBJ_NL=$(COMMON_OBJ_NL) $(CFG_OBJ_NL)");
      }

      // get the commands and modify them for use in the makefile
      insert_line("");

      // add compile target from <Menu> container (this was parsed earlier)
      insert_line(compileToolLine);

So compileToolLine is the string we're having a problem with. It is generated with this code

Code: [Select]
         _str cmdLine = _ProjectGet_TargetCmdLine(projectHandle, compileTargetNode);
         say(cmdLine);
         _str otherOpts = _ProjectGet_TargetOtherOptions(projectHandle, compileTargetNode);

         // build and save the compile command for insertion into the makefile later
         cmdLine = prepareCommand(projectName, makefileFormat, cmdLine, "compile", "", otherOpts, replaceEnvVars);
         compileToolLine = "COMPILE=" makeCommandCLSafe(cmdLine);

I added the "say" command to capture the output  - I got this
g++ -c %xup %defd -g -o "%bd%n%oe" %i %f
g++ -c %xup %defd -o "%bd%n%oe" %i %f

The first line is for the compiler, the second for linking (I think).
In the help file it says %oe is for "Output extension with dot"  - but it's obviously not working because %o is getting translated to .exe (in my case) and the "e" is just getting left there


prepareCommand does this
Code: [Select]
      case "compile":
         //preparedCmd = stranslate(preparedCmd, "$*", "%bd%n", "I");
         preparedCmd = stranslate(preparedCmd, "$(OUTDIR)" getFileSep(makefileFormat), "%bd", "I");
         preparedCmd = stranslate(preparedCmd, "$(CFG_INC)", "%ir", "I");
         preparedCmd = stranslate(preparedCmd, "$(CFG_INC)", "%i", "I");
         preparedCmd = stranslate(preparedCmd, "$(CFG_LIB)", "%libs", "I");
         preparedCmd = stranslate(preparedCmd, "$(ALL_OBJ)", "%objs", "I");
         preparedCmd = stranslate(preparedCmd, "$<", "%f", "I");
         preparedCmd = stranslate(preparedCmd, "$(*F)", "%n", "I");
         preparedCmd = stranslate(preparedCmd, "$(*D)", "%p", "I");
         preparedCmd = stranslate(preparedCmd, otherOpts, "%~other", "I");

         // special cases
         preparedCmd = stranslate(preparedCmd, "$<", "@?\"?%[Ll][Ff]\"?", "U"); // [@]["]%lf["]
         preparedCmd = stranslate(preparedCmd, '$(OUTFILE)\\1', "%[Oo]([^npe])", "U"); // %o but not %on, %op, or %oe
         break;

So you can see that %bd gets translated to $(OUTDIR)
%n gets translated to $(*F)
%oe becomes .exee
Quotes around the above three are left in
%i becomes $(CFG_INC)
%f becomes $<

So %oe isn't getting translated properly, it's getting left alone.
After the above translation, _parse_project_command is called to translate remaining % sequences and %oe becomes .exee (for me).  The help file says %oe should become "output extension with dot"  -  _parse_project_command does this
    info=_ProjectGet_OutputFile(handle,config);
    // ...
    s = _strip_filename(absOutputFile, 'N');

Slickedit v16.0.3 does this
Code: [Select]
               _str outputExtension = "";
               getExtSpecificCompileInfo(buf_name, _ProjectHandle(project_name), GetCurrentConfigName(),
                                         "", outputExtension, auto compileRuleTargetNode=0, auto linkObject=false, true);

               len = 3;

               // remove the wildcard
               if (first_char(outputExtension) == '*') {
                  outputExtension = substr(outputExtension, 2);
               }

               s = outputExtension;

but the above code has been commented out in V18.  I don't really know how %oe becomes .exee in my case though.

bremenpl

  • Community Member
  • Posts: 85
  • Hero Points: 0
  • Electrical Engineer
Re: Slickedit creating corrupted makefile
« Reply #4 on: July 14, 2013, 09:24:32 am »
Quote
but the above code has been commented out in V18.  I don't really know how %oe becomes .exee in my case though.

Probably the same way my .elf files in gnu-arm projects become .elfe :(

Thank you for explanation, i will report this to slickedit.

Graeme

  • Senior Community Member
  • Posts: 2727
  • Hero Points: 337
Re: Slickedit creating corrupted makefile
« Reply #5 on: July 14, 2013, 09:45:18 am »
If you're generating lots of make files I can probably give you a temporary fix - but means changing some slick c files and recompiling.
You could write a macro to slightly speed up changing "e" to ".o"

Record a macro that does the text change, give it a name and bind to a key

Code: [Select]
_command last_recorded_macro() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   _macro('R',1);
   replace_buffer_text('$(OUTDIR)/$(*F)e','I?','$(OUTDIR)/$(*F).o','0','0','0','0',
                       '0','0');
}

bremenpl

  • Community Member
  • Posts: 85
  • Hero Points: 0
  • Electrical Engineer
Re: Slickedit creating corrupted makefile
« Reply #6 on: July 14, 2013, 09:46:46 am »
Thank you :)!

mwb1100

  • Senior Community Member
  • Posts: 149
  • Hero Points: 13
Re: Slickedit creating corrupted makefile
« Reply #7 on: July 19, 2013, 10:31:35 pm »
I ran into this problem today (with my first project that used a project-maintained makefile).  I noticed that hotfix_se1800_1_cumulative is supposed to have a fix for this in compile.e, so I installed the hotfix.

Unfortunately it's still broken, just in a slightly different way.   Instead of the compiler command having the incorrect "$(OUTDIR)/$(*F)e" for an output file specification, it has "$(OUTDIR)/$(*F)".  This means that the object files get built without an extension.

But when the makefile tries to link the object files, it provides the ".o" extension, so the linker still can't find them.

To get the build to work I still need to manually fix-up the makefile so the COMPILE macro uses "$(OUTDIR)/$(*F).o"