gecko-dev/dom/base/moz.build
Nika Layzell 568787b95f Bug 1448426 - Wrap windows.h to avoid problematic define statements, r=froydnj,glandium
By default, windows.h exposes a large number of problematic define statements
which are UpperCamelCase, such as a define from `CreateWindow` to
`CreateWindow{A,W}`.

As many of these names are generic (e.g. CreateFile, CreateWindow), they can
mess up Gecko code that may legitimately have its own methods with the same
names.

The header also defines some traditional SCREAMING_SNAKE_CASE defines which
can mess up our code by conflicting with local values.

This patch adds a simple code generator which generates wrappers for these
defines, and uses them to wrap the windows.h wrapper using the `stl_wrappers`
mechanism, allowing us to use windows.h in more places.

Differential Revision: https://phabricator.services.mozilla.com/D10932
2018-11-28 12:56:20 -05:00

524 lines
13 KiB
Python

# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files('*Selection*'):
BUG_COMPONENT = ('Core', 'Selection')
with Files("**"):
BUG_COMPONENT = ("Core", "DOM")
TEST_DIRS += ['test']
XPIDL_SOURCES += [
'mozIDOMWindow.idl',
'nsIContentPolicy.idl',
'nsIDocumentEncoder.idl',
'nsIDOMRequestService.idl',
'nsIDroppedLinkHandler.idl',
'nsIFrameLoaderOwner.idl',
'nsIImageLoadingContent.idl',
'nsIMessageManager.idl',
'nsIObjectLoadingContent.idl',
'nsIRemoteWindowContext.idl',
'nsIScriptChannel.idl',
'nsISelectionController.idl',
'nsISelectionDisplay.idl',
'nsISelectionListener.idl',
'nsISlowScriptDebug.idl',
]
XPIDL_MODULE = 'dom'
EXPORTS += [
'AttrArray.h',
'AutocompleteFieldList.h',
'Crypto.h',
'HTMLSplitOnSpacesTokenizer.h',
'IframeSandboxKeywordList.h',
'mozAutoDocUpdate.h',
'NodeUbiReporting.h',
'nsAttrName.h',
'nsAttrValue.h',
'nsAttrValueInlines.h',
'nsCaseTreatment.h',
'nsChildContentList.h',
'nsContentCID.h',
'nsContentCreatorFunctions.h',
'nsContentList.h',
'nsContentListDeclarations.h',
'nsContentPermissionHelper.h',
'nsContentPolicyUtils.h',
'nsContentSink.h',
'nsContentTypeParser.h',
'nsContentUtils.h',
'nsCopySupport.h',
'nsDeprecatedOperationList.h',
'nsDocElementCreatedNotificationRunner.h',
'nsDocumentWarningList.h',
'nsDOMAttributeMap.h',
'nsDOMCID.h',
'nsDOMJSUtils.h',
'nsDOMNavigationTiming.h',
'nsDOMString.h',
'nsDOMTokenList.h',
'nsFocusManager.h',
'nsFrameLoader.h', # Because binding headers include it.
'nsFrameMessageManager.h',
'nsGlobalWindow.h', # Because binding headers include it.
'nsGlobalWindowInner.h', # Because binding headers include it.
'nsGlobalWindowOuter.h', # Because binding headers include it.
'nsIAnimationObserver.h',
'nsIContent.h',
'nsIContentInlines.h',
'nsIContentIterator.h',
'nsIContentSerializer.h',
'nsIdentifierMapEntry.h',
'nsIDocument.h',
'nsIDocumentInlines.h',
'nsIDocumentObserver.h',
'nsIGlobalObject.h',
'nsImageLoadingContent.h',
'nsIMutationObserver.h',
'nsINode.h',
'nsINodeList.h',
'nsIScriptContext.h',
'nsIScriptGlobalObject.h',
'nsIScriptObjectPrincipal.h',
'nsIScriptTimeoutHandler.h',
'nsIStyleSheetLinkingElement.h',
'nsITimeoutHandler.h',
'nsJSEnvironment.h',
'nsJSUtils.h',
'nsLineBreaker.h',
'nsMappedAttributeElement.h',
'nsNameSpaceManager.h',
'nsNodeInfoManager.h',
'nsNodeUtils.h',
'nsPIDOMWindow.h',
'nsPIDOMWindowInlines.h',
'nsPIWindowRoot.h',
'nsPropertyTable.h',
'nsRange.h',
'nsSandboxFlags.h',
'nsStructuredCloneContainer.h',
'nsStubAnimationObserver.h',
'nsStubDocumentObserver.h',
'nsStubMutationObserver.h',
'nsStyledElement.h',
'nsStyleLinkElement.h',
'nsTextFragment.h',
'nsTraversal.h',
'nsTreeSanitizer.h',
'nsViewportInfo.h',
'nsWindowMemoryReporter.h',
'nsWindowSizes.h',
'nsWrapperCache.h',
'nsWrapperCacheInlines.h',
'XPathGenerator.h',
]
if CONFIG['MOZ_WEBRTC']:
EXPORTS += [
'nsDOMDataChannel.h',
'nsDOMDataChannelDeclarations.h',
]
EXPORTS.mozilla += [
'CORSMode.h',
'FlushType.h',
'FullscreenChange.h',
'RangeBoundary.h',
'SelectionChangeEventDispatcher.h',
'TextInputProcessor.h',
'UseCounter.h',
]
EXPORTS.mozilla.dom += [
'!UseCounterList.h',
'AnonymousContent.h',
'Attr.h',
'BarProps.h',
'BodyUtil.h',
'BorrowedAttrInfo.h',
'CharacterData.h',
'ChildIterator.h',
'ChildProcessMessageManager.h',
'ChromeMessageBroadcaster.h',
'ChromeMessageSender.h',
'ChromeNodeList.h',
'ChromeUtils.h',
'Comment.h',
'ContentBlockingLog.h',
'ContentFrameMessageManager.h',
'ContentProcessMessageManager.h',
'CustomElementRegistry.h',
'DirectionalityUtils.h',
'DispatcherTrait.h',
'DocGroup.h',
'DocumentFragment.h',
'DocumentOrShadowRoot.h',
'DocumentType.h',
'DOMError.h',
'DOMException.h',
'DOMImplementation.h',
'DOMIntersectionObserver.h',
'DOMMatrix.h',
'DOMMozPromiseRequestHolder.h',
'DOMParser.h',
'DOMPoint.h',
'DOMPrefs.h',
'DOMPrefsInternal.h',
'DOMQuad.h',
'DOMRect.h',
'DOMRequest.h',
'DOMStringList.h',
'DOMTokenListSupportedTokens.h',
'Element.h',
'ElementInlines.h',
'EventSource.h',
'FormData.h',
'FragmentOrElement.h',
'FromParser.h',
'GeneratedImageContent.h',
'IdleDeadline.h',
'IdleRequest.h',
'IDTracker.h',
'ImageEncoder.h',
'ImageTracker.h',
'IntlUtils.h',
'Link.h',
'Location.h',
'MessageBroadcaster.h',
'MessageListenerManager.h',
'MessageManagerGlobal.h',
'MessageSender.h',
'MimeType.h',
'MozQueryInterface.h',
'NameSpaceConstants.h',
'Navigator.h',
'NodeInfo.h',
'NodeInfoInlines.h',
'NodeIterator.h',
'ParentProcessMessageManager.h',
'PlacesBookmark.h',
'PlacesBookmarkAddition.h',
'PlacesEvent.h',
'PlacesObservers.h',
'PlacesVisit.h',
'PlacesWeakCallbackWrapper.h',
'Pose.h',
'ProcessMessageManager.h',
'ResponsiveImageSelector.h',
'SameProcessMessageQueue.h',
'ScreenLuminance.h',
'ScreenOrientation.h',
'Selection.h',
'ShadowRoot.h',
'StructuredCloneBlob.h',
'StructuredCloneHolder.h',
'StructuredCloneTags.h',
'StructuredCloneTester.h',
'StyleSheetList.h',
'SubtleCrypto.h',
'SyncMessageSender.h',
'TabGroup.h',
'Text.h',
'Timeout.h',
'TimeoutHandler.h',
'TimeoutManager.h',
'TreeIterator.h',
'TreeWalker.h',
'VisualViewport.h',
'WebKitCSSMatrix.h',
'WindowOrientationObserver.h',
]
if CONFIG['FUZZING']:
EXPORTS.mozilla.dom += [
'FuzzingFunctions.h',
]
UNIFIED_SOURCES += [
'AnonymousContent.cpp',
'Attr.cpp',
'AttrArray.cpp',
'BarProps.cpp',
'BodyUtil.cpp',
'BorrowedAttrInfo.cpp',
'CharacterData.cpp',
'ChildIterator.cpp',
'ChromeMessageBroadcaster.cpp',
'ChromeMessageSender.cpp',
'ChromeNodeList.cpp',
'ChromeUtils.cpp',
'Comment.cpp',
'ContentFrameMessageManager.cpp',
'ContentProcessMessageManager.cpp',
'Crypto.cpp',
'CustomElementRegistry.cpp',
'DirectionalityUtils.cpp',
'DispatcherTrait.cpp',
'DocGroup.cpp',
'DocumentFragment.cpp',
'DocumentOrShadowRoot.cpp',
'DocumentType.cpp',
'DOMError.cpp',
'DOMException.cpp',
'DOMImplementation.cpp',
'DOMMatrix.cpp',
'DOMParser.cpp',
'DOMPoint.cpp',
'DOMPrefs.cpp',
'DOMQuad.cpp',
'DOMRect.cpp',
'DOMRequest.cpp',
'DOMStringList.cpp',
'Element.cpp',
'EventSource.cpp',
'FormData.cpp',
'FragmentOrElement.cpp',
'GeneratedImageContent.cpp',
'IdleDeadline.cpp',
'IdleRequest.cpp',
'IDTracker.cpp',
'ImageEncoder.cpp',
'ImageTracker.cpp',
'InProcessTabChildMessageManager.cpp',
'IntlUtils.cpp',
'Link.cpp',
'Location.cpp',
'MessageBroadcaster.cpp',
'MessageListenerManager.cpp',
'MessageManagerGlobal.cpp',
'MessageSender.cpp',
'MimeType.cpp',
'MozQueryInterface.cpp',
'Navigator.cpp',
'NodeInfo.cpp',
'NodeIterator.cpp',
'NodeUbiReporting.cpp',
'nsAttrValue.cpp',
'nsAttrValueOrString.cpp',
'nsCCUncollectableMarker.cpp',
'nsContentAreaDragDrop.cpp',
'nsContentIterator.cpp',
'nsContentList.cpp',
'nsContentPermissionHelper.cpp',
'nsContentPolicy.cpp',
'nsContentSink.cpp',
'nsContentTypeParser.cpp',
'nsCopySupport.cpp',
'nsDataDocumentContentPolicy.cpp',
'nsDocument.cpp',
'nsDocumentEncoder.cpp',
'nsDOMAttributeMap.cpp',
'nsDOMCaretPosition.cpp',
'nsDOMMutationObserver.cpp',
'nsDOMNavigationTiming.cpp',
'nsDOMSerializer.cpp',
'nsDOMTokenList.cpp',
'nsDOMWindowList.cpp',
'nsFocusManager.cpp',
'nsFrameLoader.cpp',
'nsGlobalWindowCommands.cpp',
'nsHistory.cpp',
'nsHTMLContentSerializer.cpp',
'nsIGlobalObject.cpp',
'nsINode.cpp',
'nsJSEnvironment.cpp',
'nsJSTimeoutHandler.cpp',
'nsJSUtils.cpp',
'nsLineBreaker.cpp',
'nsMappedAttributeElement.cpp',
'nsMappedAttributes.cpp',
'nsMimeTypeArray.cpp',
'nsNameSpaceManager.cpp',
'nsNoDataProtocolContentPolicy.cpp',
'nsNodeInfoManager.cpp',
'nsNodeUtils.cpp',
'nsOpenURIInFrameParams.cpp',
'nsPlainTextSerializer.cpp',
'nsPropertyTable.cpp',
'nsQueryContentEventResult.cpp',
'nsRange.cpp',
'nsScreen.cpp',
'nsStructuredCloneContainer.cpp',
'nsStubAnimationObserver.cpp',
'nsStubDocumentObserver.cpp',
'nsStubMutationObserver.cpp',
'nsStyledElement.cpp',
'nsStyleLinkElement.cpp',
'nsSyncLoadService.cpp',
'nsTextFragment.cpp',
'nsTextNode.cpp',
'nsTraversal.cpp',
'nsTreeSanitizer.cpp',
'nsViewportInfo.cpp',
'nsWindowMemoryReporter.cpp',
'nsWindowRoot.cpp',
'nsWrapperCache.cpp',
'nsXHTMLContentSerializer.cpp',
'nsXMLContentSerializer.cpp',
'ParentProcessMessageManager.cpp',
'Pose.cpp',
'PostMessageEvent.cpp',
'ProcessMessageManager.cpp',
'ResponsiveImageSelector.cpp',
'SameProcessMessageQueue.cpp',
'ScreenLuminance.cpp',
'ScreenOrientation.cpp',
'Selection.cpp',
'SelectionChangeEventDispatcher.cpp',
'ShadowRoot.cpp',
'StorageAccessPermissionRequest.cpp',
'StructuredCloneBlob.cpp',
'StructuredCloneHolder.cpp',
'StructuredCloneTester.cpp',
'StyleSheetList.cpp',
'SubtleCrypto.cpp',
'TabGroup.cpp',
'Text.cpp',
'TextInputProcessor.cpp',
'ThirdPartyUtil.cpp',
'Timeout.cpp',
'TimeoutBudgetManager.cpp',
'TimeoutExecutor.cpp',
'TimeoutHandler.cpp',
'TimeoutManager.cpp',
'TreeWalker.cpp',
'VisualViewport.cpp',
'WebKitCSSMatrix.cpp',
'WindowDestroyedEvent.cpp',
'WindowNamedPropertiesHandler.cpp',
'WindowOrientationObserver.cpp',
'XPathGenerator.cpp',
]
if CONFIG['MOZ_WEBRTC']:
UNIFIED_SOURCES += [
'nsDOMDataChannel.cpp',
]
if CONFIG['FUZZING']:
UNIFIED_SOURCES += [
'FuzzingFunctions.cpp',
]
if CONFIG['MOZ_PLACES']:
UNIFIED_SOURCES += [
'PlacesEvent.cpp',
'PlacesObservers.cpp',
'PlacesWeakCallbackWrapper.cpp',
]
# these files couldn't be in UNIFIED_SOURCES for now for reasons given below:
SOURCES += [
# Several conflicts with other bindings.
'DOMIntersectionObserver.cpp',
# Because of OS X headers.
'nsContentUtils.cpp',
# this file doesn't like windows.h
'nsDOMWindowUtils.cpp',
# Conflicts with windows.h's definition of SendMessage.
'nsFrameMessageManager.cpp',
# These files have a #error "Never include unwrapped windows.h in this file!"
'nsGlobalWindowInner.cpp',
'nsGlobalWindowOuter.cpp',
# Conflicts with windows.h's definition of LoadImage.
'nsImageLoadingContent.cpp',
# Because of OS X headers.
'nsObjectLoadingContent.cpp',
# nsPluginArray.cpp includes npapi.h indirectly, and that includes a lot of system headers
'nsPluginArray.cpp',
]
# Are we targeting x86-32 or x86-64? If so, we want to include SSE2 code for
# nsTextFragment.cpp
if CONFIG['INTEL_ARCHITECTURE']:
SOURCES += ['nsTextFragmentSSE2.cpp']
SOURCES['nsTextFragmentSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
EXTRA_COMPONENTS += [
'contentAreaDropListener.js',
'contentAreaDropListener.manifest',
'ProcessSelector.js',
'ProcessSelector.manifest',
'SlowScriptDebug.js',
'SlowScriptDebug.manifest',
]
EXTRA_JS_MODULES += [
'DOMRequestHelper.jsm',
'IndexedDBHelper.jsm',
]
LOCAL_INCLUDES += [
'../battery',
'../events',
'../media',
'../network',
'/caps',
'/docshell/base',
'/dom/base',
'/dom/file',
'/dom/geolocation',
'/dom/html',
'/dom/ipc',
'/dom/storage',
'/dom/svg',
'/dom/u2f',
'/dom/xbl',
'/dom/xml',
'/dom/xslt/xpath',
'/dom/xul',
'/gfx/2d',
'/image',
'/js/xpconnect/loader',
'/js/xpconnect/src',
'/js/xpconnect/wrappers',
'/layout/base',
'/layout/forms',
'/layout/generic',
'/layout/style',
'/layout/svg',
'/layout/xul',
'/netwerk/base',
'/security/manager/ssl',
'/widget',
'/xpcom/ds',
]
if CONFIG['MOZ_WEBRTC']:
LOCAL_INCLUDES += [
'/netwerk/sctp/datachannel',
]
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']:
DEFINES['HAVE_SIDEBAR'] = True
if CONFIG['MOZ_X11']:
CXXFLAGS += CONFIG['TK_CFLAGS']
GENERATED_FILES += [
'PropertyUseCounterMap.inc',
'UseCounterList.h',
]
countermap = GENERATED_FILES['PropertyUseCounterMap.inc']
countermap.script = 'gen-usecounters.py:property_map'
countermap.inputs = ['UseCounters.conf']
counterlist = GENERATED_FILES['UseCounterList.h']
counterlist.script = 'gen-usecounters.py:use_counter_list'
counterlist.inputs = ['UseCounters.conf']
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']