Bug 333418 - GNUMakefileGenerator should leave macros as they are
Summary: GNUMakefileGenerator should leave macros as they are
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build-managed (show other bugs)
Version: 7.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-03 07:17 EST by Anna Dushistova CLA
Modified: 2020-09-04 15:19 EDT (History)
3 users (show)

See Also:


Attachments
patch that deletes the corresponding code (3.05 KB, patch)
2011-01-03 07:20 EST, Anna Dushistova CLA
anna.dushistova: review?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anna Dushistova CLA 2011-01-03 07:17:37 EST
Correct me if I am wrong, but it anyways expands them from the environment which is used during the build. Thus there is no particular reason to put the expanded values into the generated makefile.
Comment 1 Anna Dushistova CLA 2011-01-03 07:20:58 EST
Created attachment 185952 [details]
patch that deletes the corresponding code
Comment 2 Chris Recoskie CLA 2011-01-04 10:07:48 EST
It has been a long time but I seem to recall this was needed to prevent file-speciic rules from malfunctioning in certain cases.  I don't think we can just delete this.

Is this causing a problem for you in any way?
Comment 3 Anna Dushistova CLA 2011-01-04 11:54:45 EST
Yes, it does. I need unexpanded macros in my makefile, since I am going to use it later for the headless builds. Rounded brackets don't expand, but in this case I am not able to build a single file.
Comment 4 James Blackburn CLA 2011-01-04 12:05:58 EST
AFAIK by HeadlessBuild Anna means she's running 'make' externally on the generated makefiles, and not using the provided HeadlessBuilder IApplication.
Comment 5 Anna Dushistova CLA 2011-01-04 12:16:15 EST
James is correct.
Comment 6 Chris Recoskie CLA 2011-01-04 13:17:33 EST
(In reply to comment #3)
> Yes, it does. I need unexpanded macros in my makefile, since I am going to use
> it later for the headless builds. Rounded brackets don't expand, but in this
> case I am not able to build a single file.

I don't really follow.  If the makefile builds within the IDE then it would build at the command line too.  Expanding the macros fully should just result in a slightly more verbose makefile that doesn't use any make variables in some of the rules.
Comment 7 Chris Recoskie CLA 2011-01-04 13:24:27 EST
It bears pointing out that the macro expansion is done really so that any internal macros whose values are provided by Eclipse are expanded in their proper context.  Although expanding environment variable might not usually seem useful given that make will do this on its own, it's possible to nest environment variables inside build system macros.  The burden place on the macro suppliers is low, so they generally expect to be given fully expanded arguments.
Comment 8 Chris Recoskie CLA 2011-01-04 13:31:25 EST
(In reply to comment #7)
>The burden place on the
> macro suppliers is low, so they generally expect to be given fully expanded
> arguments.

Actually, to be more correct... the build system macros themselves don't take arguments.  Eclipse Variables are valid to use though as well, and they can take arguments.
Comment 9 Anna Dushistova CLA 2011-01-04 13:32:29 EST
Here is an example for you. If I want to create, say, an rpm package from a project, rpm would provide all the variables it needs. But with the expanded macros, it won't build most likely. Or, sometimes I need a project built with arm/mips/ppc/what else have you toolchains. I really don't want to regenerate a makefile to be able to do it, I just want to change the variables.
Comment 10 James Blackburn CLA 2011-01-04 14:01:13 EST
(In reply to comment #9)
> Here is an example for you. If I want to create, say, an rpm package from a
> project, rpm would provide all the variables it needs. But with the expanded
> macros, it won't build most likely. Or, sometimes I need a project built with
> arm/mips/ppc/what else have you toolchains. I really don't want to regenerate a
> makefile to be able to do it, I just want to change the variables.

But from Chris' point, either it builds from within Eclipse or it doesn't.  If you're building outside of Eclipse, using the makefile with _different_ environment to what's specified in the project configuration, then you're not actually building the same configuration that Eclipse is building.  The build product would be different to what you get using HeadlessBuilder, or building from within the GUI.

When we discussed this as CDT-con I think your use-case was to allow specifying different environment so you could effectively fake up multi-configuration builds without multiple configurations?

The problem is that people assume the current behaviour.  
So I think to get this integrated a few things would need be done:
  - Make the behaviour optional: perhaps a hidden preference that you can toggle programmatically / in your product?
  - What do the tests look like with the patch applied?
Comment 11 Anna Dushistova CLA 2011-01-17 17:56:56 EST
Test results look the same with the patch as without it.
Comment 12 James Blackburn CLA 2011-01-17 17:58:37 EST
(In reply to comment #11)
> Test results look the same with the patch as without it.

Really? That's surprising as a load of the tests compare the generated makefiles...  Are you saying they're all failing for you ;)?
Comment 13 Anna Dushistova CLA 2011-01-17 18:25:29 EST
I ran the managedbuilder.core.tests, they have 3 failures out of 106 on my machine( openSuse 11.2, Eclipse 3.7M4) without my patch. Also sometimes they hang. I don't have a Windows machine to try it unfortunately.
Comment 14 Chris Recoskie CLA 2011-01-18 08:31:45 EST
I don't think there are a lot of tests that exercise the macro functionality (if there are any at all), so I don't think the tests are a good indication.

Honestly I don't think we can use this patch as is, as it will break a lot of things.  We need a more complex solution for the variable expander to know what variables should be expanded and what variables should be left alone.  Variables internal to Eclipse will always have to be expanded;  environment variable references are the only ones that could be left as makefile variables.  Even then, this behaviour would have to be optional.