Closed Bug 1122812 Opened 10 years ago Closed 10 years ago

Change the visual studio project generator to add the Unified_foo_bar_baz0.cpp files to the project, and not the sources specified in UNIFIED_SOURCES

Categories

(Firefox Build System :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

(firefox38 fixed)

RESOLVED FIXED
mozilla38
Tracking Status
firefox38 --- fixed

People

(Reporter: ehsan.akhgari, Assigned: froydnj)

References

(Blocks 1 open bug)

Details

Attachments

(4 files, 2 obsolete files)

This should fix the issues with removing non-unified builds that people are reporting.
I will do this, I already have some patches written in my head.
Assignee: nobody → nfroyd
Thank you!
How will we handle changes that modify the number of generated cpp files?
Depends on: 1108750
(In reply to ben turner [:bent] (use the needinfo? flag!) from comment #3) > How will we handle changes that modify the number of generated cpp files? It won't. The project needs to be reconstructed in that case anyway, right?
Depends on: 1129635
UnifiedSources, not the recursivemake backend, should be responsible for figuring out what unified files to generate, and what those unified files should contain.
Attachment #8559988 - Flags: review?(mshal)
UnifiedSources will be processed outside of consume_object, so we need some way of accessing the backend file for an object outside of consume_object as well.
Attachment #8559990 - Flags: review?(mshal)
CommonBackend is where the writing of the unified files belong, since that's an operation common to all backends. A special hook into subclasses is used to enable subclass-specific processing of UnifiedSources.
Attachment #8559991 - Flags: review?(mshal)
With the previous changes, we can now tell Visual Studio about the actual unified files, rather than the files that are #include'd in them. I believe this is much closer to what Visual Studio wants to see, and enables things like Intellisense to work properly.
Attachment #8559992 - Flags: review?(mshal)
This series follows bug 1129635 comment 0's suggestion; I don't know if there's a better way to do it, but I couldn't figure out a pleasant way to do it within the constraints assumed by consume_object and the .ack() flag on a moz.build object.
With the previous changes, we can now tell Visual Studio about the actual unified files, rather than the files that are #include'd in them. I believe this is much closer to what Visual Studio wants to see, and enables things like Intellisense to work properly. This version of the patch actually ensures that Unified*.cpp files are written into the vcxproj files. The visualstudio backend doesn't follow the consume_object protocol (insofar as we have one...) and processes only the few frontend object types it's interested in, ack()'ing all the rest. This means that CommonBackend.consume_object never gets called, so the _process_unified_sources hook never gets called. What this also means is that building the Visual Studio backend on its own won't work without building the recursive make backend first. I don't think this is a problem currently, as many other things won't work with the Visual Studio backend (e.g. WebIDL/IPDL/XPIDL), but it's good to note it here for completeness.
Attachment #8559992 - Attachment is obsolete: true
Attachment #8559992 - Flags: review?(mshal)
Attachment #8561613 - Flags: review?(mshal)
Attachment #8559988 - Flags: review?(mshal) → review+
Attachment #8559990 - Flags: review?(mshal) → review+
Comment on attachment 8559991 [details] [diff] [review] part 3 - move unified files writing for UnifiedSources to CommonBackend >diff --git a/python/mozbuild/mozbuild/backend/common.py b/python/mozbuild/mozbuild/backend/common.py >index 90e7189..992fd40 100644 >--- a/python/mozbuild/mozbuild/backend/common.py >+++ b/python/mozbuild/mozbuild/backend/common.py >+ elif isinstance(obj, UnifiedSources): >+ if obj.have_unified_mapping: >+ self._write_unified_files(obj.unified_source_mapping, obj.objdir) >diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py >index ebb7038..e62775d 100644 >--- a/python/mozbuild/mozbuild/backend/recursivemake.py >+++ b/python/mozbuild/mozbuild/backend/recursivemake.py >+ if obj.have_unified_mapping: >+ self._write_unified_files(obj.unified_source_mapping, backend_file.objdir) Why are both recursivemake.py and common.py writing out the unified files? It looks like they both are trying to write out the same files when generating the make backend -- in an strace, I can see Unified_XYZ.cpp is opened twice - once to write the file and once to read it & compare, or opened for reading twice if it already exists. I think we would just want to do that in common.py, right?
Attachment #8559991 - Flags: review?(mshal) → feedback+
Comment on attachment 8561613 [details] [diff] [review] part 4 - update the Visual Studio backend for UnifiedSources changes >diff --git a/python/mozbuild/mozbuild/backend/visualstudio.py b/python/mozbuild/mozbuild/backend/visualstudio.py >index 7f0cfac..69e3ffa 100644 >--- a/python/mozbuild/mozbuild/backend/visualstudio.py >+++ b/python/mozbuild/mozbuild/backend/visualstudio.py >@@ -105,17 +105,19 @@ class VisualStudioBackend(CommonBackend): > elif isinstance(obj, UnifiedSources): >- self._add_sources(reldir, obj) >+ # XXX we should be letting CommonBackend.consume_object call this >+ # for us instead. >+ self._process_unified_sources(obj); So why doesn't CommonBackend.consume_object work here?
Attachment #8561613 - Flags: review?(mshal) → review+
CommonBackend is where the writing of the unified files belong, since that's an operation common to all backends. A special hook into subclasses is used to enable subclass-specific processing of UnifiedSources. Now with the _write_unified_files call removed from recursivemake.py.
Attachment #8559991 - Attachment is obsolete: true
Attachment #8562816 - Flags: review?(mshal)
(In reply to Michael Shal [:mshal] from comment #11) > Why are both recursivemake.py and common.py writing out the unified files? > It looks like they both are trying to write out the same files when > generating the make backend -- in an strace, I can see Unified_XYZ.cpp is > opened twice - once to write the file and once to read it & compare, or > opened for reading twice if it already exists. I think we would just want to > do that in common.py, right? Yeah, I just fail at moving the code out of recursivemake.py. New patch up. (In reply to Michael Shal [:mshal] from comment #12) > Comment on attachment 8561613 [details] [diff] [review] > part 4 - update the Visual Studio backend for UnifiedSources changes > > >diff --git a/python/mozbuild/mozbuild/backend/visualstudio.py b/python/mozbuild/mozbuild/backend/visualstudio.py > >index 7f0cfac..69e3ffa 100644 > >--- a/python/mozbuild/mozbuild/backend/visualstudio.py > >+++ b/python/mozbuild/mozbuild/backend/visualstudio.py > >@@ -105,17 +105,19 @@ class VisualStudioBackend(CommonBackend): > > elif isinstance(obj, UnifiedSources): > >- self._add_sources(reldir, obj) > >+ # XXX we should be letting CommonBackend.consume_object call this > >+ # for us instead. > >+ self._process_unified_sources(obj); > > So why doesn't CommonBackend.consume_object work here? Because visualstudio.py never calls CommonBackend.consume_object. I think this should be fixed, but it may also be part of a larger fix deciding how we want the common backend and sub-backends to work together.
Comment on attachment 8562816 [details] [diff] [review] part 3 - move unified files writing for UnifiedSources to CommonBackend Looks good to me!
Attachment #8562816 - Flags: review?(mshal) → review+
Depends on: 1138250
This hurts my productivity greatly as it breaks intellisense. Can we back this out? At least until we can provide a command line option so that we can generate a project in which intellisense and all the other awesome code navigation things works?
Flags: needinfo?(nfroyd)
(In reply to Chris Pearce (:cpearce) from comment #17) > This hurts my productivity greatly as it breaks intellisense. > > Can we back this out? At least until we can provide a command line option so > that we can generate a project in which intellisense and all the other > awesome code navigation things works? Sorry, I meant to address this in bug 1138250 yesterday. I'll do that today.
Flags: needinfo?(nfroyd)
Blocks: 1142654
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: