User:Gszorc/Build frontend shootout: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
mNo edit summary
Line 11: Line 11:
===Makefile===
===Makefile===


This is what things would look like in a Makefile.in today in mozilla-central.
This is what things would look like in a Makefile.in today in mozilla-central. This example is abbreviated from dom/base/Makefile.in.


<code><pre>
<code><pre>
Line 18: Line 18:
srcdir := @srcdir@
srcdir := @srcdir@
VPATH := @srcdir@
VPATH := @srcdir@
FAIL_ON_WARNINGS := 1


include $(DEPTH)/config/autoconf.mk
include $(DEPTH)/config/autoconf.mk


CPPSRCS := \
MODULE = dom
   foo.cpp \
LIBRARY_NAME = jsdombase_s
   bar.cpp \
LIBXUL_LIBRARY = 1
FORCE_STATIC_LIB = 1
 
DIRS = \
  test \
   $(NULL)
 
EXTRA_PP_COMPONENTS = \
  ConsoleAPI.js \
  ConsoleAPI.manifest \
   $(NULL)
 
EXTRA_JS_MODULES = ConsoleAPIStorage.jsm \
   $(NULL)
   $(NULL)


CXXFLAGS += -DFOO=1
EXTRA_JS_MODULES += \
  DOMRequestHelper.jsm \
  IndexedDBHelper.jsm \
  ObjectWrapper.jsm \
  $(NULL)


ifneq (,WIN32)
XPIDLSRCS = \
CPPSRCS += win32.cpp
  nsIDOMDOMError.idl \
  nsIDOMDOMRequest.idl \
  nsIEntropyCollector.idl \
  nsIScriptChannel.idl \
  $(NULL)
 
EXPORTS = \
  nsDOMCID.h \
  nsDOMClassInfoClasses.h \
  nsDOMClassInfoID.h \
  nsDOMJSUtils.h \
  $(NULL)
 
EXPORTS_NAMESPACES = mozilla/dom
EXPORTS_mozilla/dom = \
  DOMError.h \
  DOMRequest.h \
  StructuredCloneTags.h \
  ScreenOrientation.h \
  $(NULL)
 
CPPSRCS =               \
  nsBarProps.cpp        \
  nsDOMException.cpp \
  nsDOMWindowUtils.cpp \
  nsJSEnvironment.cpp \
  $(NULL)
 
include $(topsrcdir)/dom/dom-config.mk
 
ifdef MOZ_JSDEBUGGER
DEFINES += -DMOZ_JSDEBUGGER
endif
endif
ifdef MOZ_B2G_RIL
DEFINES += -DMOZ_B2G_RIL
endif
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk


include $(topsrcdir)/config/rules.mk
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += \
  -I$(topsrcdir)/js/xpconnect/src \
  -I$(topsrcdir)/js/xpconnect/wrappers \
  -I$(topsrcdir)/xpcom/ds \
  $(NULL)
ifdef MOZ_X11
CXXFLAGS += $(TK_CFLAGS)
LDFLAGS += $(TK_LIBS)
endif
XPIDL_FLAGS += \
  -I$(topsrcdir)/dom/interfaces/events \
  $(NULL)
</pre></code>
</pre></code>


Line 40: Line 110:


<code><pre>
<code><pre>
CPP_SOURCES = ['foo.cpp', 'bar.cpp']
FAIL_ON_WARNINGS = True
CPP_FLAGS = ['-DFOO=1']
 
MODULE = {
    'name': 'dom',
    'library_name': 'jsdombase_s',
    'libxul': True,
    'static': True,
}


if ENV.WIN32:
DIRS = ['test']
     CPP_SOURCES += ['win32.cpp']
 
EXTRA_PP_COMPONENTS = [
    'ConsoleAPI.js',
    'ConsoleAPI.manifest'
]
 
EXTRA_JS_MODULES = ['ConsoleAPIStorage.jsm']
 
EXTRA_JS_MODULES = [
    'DOMRequestHelper.jsm',
    'IndexedDBHelper.jsm',
    'ObjectWrapper.jsm',
]
 
XPIDLSRCS = [
    'nsIDOMDOMError.idl',
    'nsIDOMDOMRequest.idl',
    'nsIEntropyCollector.idl',
    'nsIScriptChannel.idl',
]
 
EXPORTS['__main__'] = [
    'nsDOMCID.h',
    'nsDOMClassInfoClasses.h',
    'nsDOMClassInfoID.h',
    'nsDOMJSUtils.h',
]
 
EXPORTS['mozilla/dom'] = [
    'DOMError.h,
    'DOMRequest.h,
    'StructuredCloneTags.h',
    'ScreenOrientation.h',
]
 
CPPSRCS = [
    'nsBarProps.cpp',
    'nsDOMException.cpp',
    'nsDOMWindowUtils.cpp',
    'nsJSEnvironment.cpp',
]
 
if not ENV.MOZ_JSDEBUGGER:
     DEFINES += ['MOZ_JSDEBUGGER']
 
if not ENV.MOZ_B2G_RIL:
    DEFINES += ['MOZ_B2G_RIL']
 
LOCAL_SRCDIR_INCLUDES = [
    'js/xpconnect/src',
    'js/xpconnect/wrappers',
    'xpcom/ds',
]
 
if ENV.MOZ_X11:
    CXXFLAGS += ENV.TK_CFLAGS
    LDFLAGS += ENV.TK_LIBS
 
XPIDL_SRCDIR_INCLUDES = ['dom/interfaces/events']
</pre></code>
</pre></code>


Line 52: Line 186:


<code><pre>
<code><pre>
CPP_SOURCES('foo.cpp', 'bar.cpp')
TODO
CPP_FLAGS('-DFOO=1')
 
if ENV.WIN32:
    CPP_SOURCES('win32.cpp')
</pre></code>
</pre></code>



Revision as of 03:00, 28 August 2012

This article examines alternatives to Makefile's for containing mozilla-central's build system definition. See discussion at https://groups.google.com/forum/?fromgroups=#!topic/mozilla.dev.platform/SACOnl-avMs

Goals

We want a frontend language whose output is a giant data structure. The data structure will be consumed by a generator to produce files that actually build the tree.

The produced data structure can come about many different ways. The frontend files themselves could be a data structure (e.g. JSON). They could be scripts that call built-in functions which register elements with the data structure. They could be scripts that populate specific variables whose values are read post execution.

Comparison

Makefile

This is what things would look like in a Makefile.in today in mozilla-central. This example is abbreviated from dom/base/Makefile.in.

DEPTH := @DEPTH@
topsrcdir := @top_srcdir@
srcdir := @srcdir@
VPATH := @srcdir@
FAIL_ON_WARNINGS := 1

include $(DEPTH)/config/autoconf.mk

MODULE = dom
LIBRARY_NAME = jsdombase_s
LIBXUL_LIBRARY = 1
FORCE_STATIC_LIB = 1

DIRS = \
  test \
  $(NULL)

EXTRA_PP_COMPONENTS = \
  ConsoleAPI.js \
  ConsoleAPI.manifest \
  $(NULL)

EXTRA_JS_MODULES = ConsoleAPIStorage.jsm \
  $(NULL)

EXTRA_JS_MODULES += \
  DOMRequestHelper.jsm \
  IndexedDBHelper.jsm \
  ObjectWrapper.jsm \
  $(NULL)

XPIDLSRCS = \
  nsIDOMDOMError.idl \
  nsIDOMDOMRequest.idl \
  nsIEntropyCollector.idl \
  nsIScriptChannel.idl \
  $(NULL)

EXPORTS = \
  nsDOMCID.h \
  nsDOMClassInfoClasses.h \
  nsDOMClassInfoID.h \
  nsDOMJSUtils.h \
  $(NULL)

EXPORTS_NAMESPACES = mozilla/dom
EXPORTS_mozilla/dom = \
  DOMError.h \
  DOMRequest.h \
  StructuredCloneTags.h \
  ScreenOrientation.h \
  $(NULL)

CPPSRCS =               \
  nsBarProps.cpp        \
  nsDOMException.cpp 	\
  nsDOMWindowUtils.cpp 	\
  nsJSEnvironment.cpp	\
  $(NULL)

include $(topsrcdir)/dom/dom-config.mk

ifdef MOZ_JSDEBUGGER
DEFINES += -DMOZ_JSDEBUGGER
endif

ifdef MOZ_B2G_RIL
DEFINES += -DMOZ_B2G_RIL
endif

include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk

include $(topsrcdir)/config/rules.mk

LOCAL_INCLUDES += \
  -I$(topsrcdir)/js/xpconnect/src \
  -I$(topsrcdir)/js/xpconnect/wrappers \
  -I$(topsrcdir)/xpcom/ds \
  $(NULL)

ifdef MOZ_X11
CXXFLAGS += $(TK_CFLAGS)
LDFLAGS += $(TK_LIBS)
endif

XPIDL_FLAGS += \
  -I$(topsrcdir)/dom/interfaces/events \
  $(NULL)

Python (data oriented)

We use Python as the frontend language. We try to make it is *data oriented* as possible. By that, we mean we value static data structures over function calls.

FAIL_ON_WARNINGS = True

MODULE = {
    'name': 'dom',
    'library_name': 'jsdombase_s',
    'libxul': True,
    'static': True,
}

DIRS = ['test']

EXTRA_PP_COMPONENTS = [
    'ConsoleAPI.js',
    'ConsoleAPI.manifest'
]

EXTRA_JS_MODULES = ['ConsoleAPIStorage.jsm']

EXTRA_JS_MODULES = [
    'DOMRequestHelper.jsm',
    'IndexedDBHelper.jsm',
    'ObjectWrapper.jsm',
]

XPIDLSRCS = [
    'nsIDOMDOMError.idl',
    'nsIDOMDOMRequest.idl',
    'nsIEntropyCollector.idl',
    'nsIScriptChannel.idl',
]

EXPORTS['__main__'] = [
    'nsDOMCID.h',
    'nsDOMClassInfoClasses.h',
    'nsDOMClassInfoID.h',
    'nsDOMJSUtils.h',
]

EXPORTS['mozilla/dom'] = [
    'DOMError.h,
    'DOMRequest.h,
    'StructuredCloneTags.h',
    'ScreenOrientation.h',
]

CPPSRCS = [
    'nsBarProps.cpp',
    'nsDOMException.cpp',
    'nsDOMWindowUtils.cpp',
    'nsJSEnvironment.cpp',
]

if not ENV.MOZ_JSDEBUGGER:
    DEFINES += ['MOZ_JSDEBUGGER']

if not ENV.MOZ_B2G_RIL:
    DEFINES += ['MOZ_B2G_RIL']

LOCAL_SRCDIR_INCLUDES = [
    'js/xpconnect/src',
    'js/xpconnect/wrappers',
    'xpcom/ds',
]

if ENV.MOZ_X11:
    CXXFLAGS += ENV.TK_CFLAGS
    LDFLAGS += ENV.TK_LIBS

XPIDL_SRCDIR_INCLUDES = ['dom/interfaces/events']

Python (procedural oriented)

In this flavor of Python, all relevant tasks are done with calls to built-in functions.

TODO

SCons

TODO

WAF

TODO

Lua

TODO

GYP

TODO