Bug 1478813 - Auto-generate ServoStyleConsts. r=xidorn,ted
☠☠ backed out by 22d17330182c ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 17 Aug 2018 18:43:06 +0200
changeset 487301 4b9dcf8f2e6c1b9b295193d13647664f6cee3d07
parent 487281 7800cf98a6e7d80dbd8cb3c66fdc06020e303c44
child 487302 22d17330182c653df514ba1fa8b22e4e3d235f88
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn, ted
bugs1478813
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1478813 - Auto-generate ServoStyleConsts. r=xidorn,ted Differential Revision: https://phabricator.services.mozilla.com/D2447
browser/config/mozconfigs/linux64/plain-opt
browser/config/mozconfigs/win64/plain-opt
build/moz.configure/rust.configure
build/moz.configure/toolchain.configure
build/mozconfig.no-compile
build/mozconfig.rust
layout/style/GenerateServoStyleConsts.py
layout/style/ServoStyleConsts.h
layout/style/moz.build
--- a/browser/config/mozconfigs/linux64/plain-opt
+++ b/browser/config/mozconfigs/linux64/plain-opt
@@ -1,15 +1,16 @@
 export TOOLTOOL_DIR="$topsrcdir"
 export LLVM_CONFIG="${TOOLTOOL_DIR}/clang/bin/llvm-config"
 
 CARGO="${TOOLTOOL_DIR}/rustc/bin/cargo"
 RUSTC="${TOOLTOOL_DIR}/rustc/bin/rustc"
 RUSTDOC="${TOOLTOOL_DIR}/rustc/bin/rustdoc"
 RUSTFMT="${TOOLTOOL_DIR}/rustc/bin/rustfmt"
+CBINDGEN="${TOOLTOOL_DIR}/cbindgen/cbindgen"
 
 export NODEJS="${TOOLTOOL_DIR}/node/bin/node"
 
 CC="${TOOLTOOL_DIR}/gcc/bin/gcc"
 CXX="${TOOLTOOL_DIR}/gcc/bin/g++"
 
 mk_add_options "export PATH=${TOOLTOOL_DIR}/gcc/bin:${PATH}"
 mk_add_options "export LD_LIBRARY_PATH=${TOOLTOOL_DIR}/gcc/lib64:${TOOLTOOL_DIR}/gcc/lib32:${TOOLTOOL_DIR}/gcc/lib"
--- a/browser/config/mozconfigs/win64/plain-opt
+++ b/browser/config/mozconfigs/win64/plain-opt
@@ -1,15 +1,16 @@
 TOOLTOOL_DIR=${topsrcdir}
 export MAKECAB=$TOOLTOOL_DIR/makecab.exe
 export LLVM_CONFIG="${TOOLTOOL_DIR}/clang/bin/llvm-config"
 
 RUSTC="${TOOLTOOL_DIR}/rustc/bin/rustc"
 CARGO="${TOOLTOOL_DIR}/rustc/bin/cargo"
 RUSTDOC="${TOOLTOOL_DIR}/rustc/bin/rustdoc"
 RUSTFMT="${TOOLTOOL_DIR}/rustc/bin/rustfmt"
+CBINDGEN="${TOOLTOOL_DIR}/cbindgen/cbindgen"
 
 NODEJS="${TOOLTOOL_DIR}/node/node.exe"
 
 ac_add_options --target=x86_64-pc-mingw32
 ac_add_options --host=x86_64-pc-mingw32
 
 . $topsrcdir/build/win64/mozconfig.vs-latest
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -279,16 +279,21 @@ option('--enable-rust-tests',
 def rust_tests(enable_rust_tests, rustdoc):
     if enable_rust_tests and not rustdoc:
         die('--enable-rust-tests requires rustdoc')
     return bool(enable_rust_tests)
 
 
 set_config('MOZ_RUST_TESTS', rust_tests)
 
+# cbindgen is needed by the style system build.
+cbindgen = check_prog('CBINDGEN', add_rustup_path('cbindgen'), paths=toolchain_search_path,
+                      when=depends(build_project)
+                      (lambda build_project: build_project != 'js'))
+
 # Bindgen can use rustfmt to format Rust file, but it's not required.
 js_option(env='RUSTFMT', nargs=1, help='Path to the rustfmt program')
 
 rustfmt = check_prog('RUSTFMT', add_rustup_path('rustfmt'),
                      input='RUSTFMT', allow_missing=True)
 
 js_option(env='WIN64_LINK', nargs=1, help='Path to link.exe that targets win64')
 js_option(env='WIN64_LIB', nargs=1, help='Paths to libraries for the win64 linker')
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -649,16 +649,19 @@ def toolchain_search_path(vc_compiler_pa
 
     # Also add in the location to which `mach bootstrap` or
     # `mach artifact toolchain` installs clang.
     mozbuild_state_dir = environ.get('MOZBUILD_STATE_PATH',
                                      os.path.expanduser(os.path.join('~', '.mozbuild')))
     bootstrap_clang_path = os.path.join(mozbuild_state_dir, 'clang', 'bin')
     result.append(bootstrap_clang_path)
 
+    bootstrap_cbindgen_path = os.path.join(mozbuild_state_dir, 'cbindgen')
+    result.append(bootstrap_cbindgen_path)
+
     if vc_compiler_path:
         # We're going to alter PATH for good in windows.configure, but we also
         # need to do it for the valid_compiler() check below. This is only needed
         # on Windows, where MSVC needs PATH set to find dlls.
         environ['PATH'] = os.pathsep.join(result)
 
     return result
 
--- a/build/mozconfig.no-compile
+++ b/build/mozconfig.no-compile
@@ -11,16 +11,17 @@ unset CC
 unset CXX
 unset HOST_CC
 unset HOST_CXX
 unset LINKER
 unset RUSTC
 unset CARGO
 unset RUSTDOC
 unset RUSTFMT
+unset CBINDGEN
 unset MAKECAB
 unset TOOLCHAIN_PREFIX
 unset BINDGEN_CFLAGS
 unset LLVM_CONFIG
 unset WIN64_LINK
 unset WIN64_LIB
 
 unset MOZ_STDCXX_COMPAT
--- a/build/mozconfig.rust
+++ b/build/mozconfig.rust
@@ -2,10 +2,11 @@
 
 TOOLTOOL_DIR=${TOOLTOOL_DIR:-$topsrcdir}
 
 # Tell configure to use the tooltool rustc.
 RUSTC="$TOOLTOOL_DIR/rustc/bin/rustc"
 CARGO="$TOOLTOOL_DIR/rustc/bin/cargo"
 RUSTDOC="$TOOLTOOL_DIR/rustc/bin/rustdoc"
 RUSTFMT="$TOOLTOOL_DIR/rustc/bin/rustfmt"
+CBINDGEN="$TOOLTOOL_DIR/cbindgen/cbindgen"
 
 ac_add_options --enable-rust-simd
new file mode 100644
--- /dev/null
+++ b/layout/style/GenerateServoStyleConsts.py
@@ -0,0 +1,38 @@
+# 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/.
+
+from __future__ import print_function
+import buildconfig
+import mozpack.path as mozpath
+import os
+import subprocess
+
+STYLE = mozpath.join(buildconfig.topsrcdir, "servo", "components", "style")
+CARGO_LOCK = mozpath.join(buildconfig.topsrcdir, "Cargo.lock")
+
+def generate(output, cbindgen_toml_path):
+    env = os.environ.copy()
+    env['CARGO'] = str(buildconfig.substs['CARGO'])
+    p = subprocess.Popen([
+        buildconfig.substs['CBINDGEN'],
+        mozpath.join(buildconfig.topsrcdir, "toolkit", "library", "rust"),
+        "--lockfile",
+        CARGO_LOCK,
+        "--crate",
+        "style"
+    ], env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+    stdout, stderr = p.communicate()
+    if p.returncode == 0:
+        output.write(stdout)
+    else:
+        print("cbindgen failed: %s" % stderr)
+
+    deps = set()
+    deps.add(CARGO_LOCK)
+    for path, dirs, files in os.walk(STYLE):
+        for file in files:
+            if os.path.splitext(file)[1] == ".rs":
+                deps.add(mozpath.join(path, file))
+    return deps
deleted file mode 100644
--- a/layout/style/ServoStyleConsts.h
+++ /dev/null
@@ -1,316 +0,0 @@
-/* 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/. */
-
-/* Generated with cbindgen:0.6.1 */
-
-/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
- * To generate this file:
- *   1. Get the latest cbindgen using `cargo install --force cbindgen`
- *      a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release
- *   2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate style -o layout/style/ServoStyleConsts.h`
- */
-
-#include <cstdint>
-#include <cstdlib>
-
-namespace mozilla {
-
-// The value for the `appearance` property.
-//
-// https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-appearance
-//
-// NOTE(emilio): When changing this you may want to regenerate the C++ bindings
-// (see components/style/cbindgen.toml)
-enum class StyleAppearance : uint8_t {
-  // No appearance at all.
-  None,
-  // A typical dialog button.
-  Button,
-  // Various arrows that go in buttons
-  ButtonArrowDown,
-  ButtonArrowNext,
-  ButtonArrowPrevious,
-  ButtonArrowUp,
-  // A rectangular button that contains complex content
-  // like images (e.g. HTML <button> elements)
-  ButtonBevel,
-  // The focus outline box inside of a button.
-  ButtonFocus,
-  // The caret of a text area
-  Caret,
-  // A dual toolbar button (e.g., a Back button with a dropdown)
-  Dualbutton,
-  // A groupbox.
-  Groupbox,
-  // A inner-spin button.
-  InnerSpinButton,
-  // List boxes.
-  Listbox,
-  // A listbox item.
-  Listitem,
-  // Menu Bar background
-  Menubar,
-  // <menu> and <menuitem> appearances
-  Menuitem,
-  Checkmenuitem,
-  Radiomenuitem,
-  // For text on non-iconic menuitems only
-  Menuitemtext,
-  // A dropdown list.
-  Menulist,
-  // The dropdown button(s) that open up a dropdown list.
-  MenulistButton,
-  // The text part of a dropdown list, to left of button.
-  MenulistText,
-  // An editable textfield with a dropdown list (a combobox).
-  MenulistTextfield,
-  // Menu Popup background.
-  Menupopup,
-  // menu checkbox/radio appearances
-  Menucheckbox,
-  Menuradio,
-  Menuseparator,
-  Menuarrow,
-  // An image in the menu gutter, like in bookmarks or history.
-  Menuimage,
-  // A horizontal meter bar.
-  Meterbar,
-  // The meter bar's meter indicator.
-  Meterchunk,
-  // The "arrowed" part of the dropdown button that open up a dropdown list.
-  MozMenulistButton,
-  // For HTML's <input type=number>
-  NumberInput,
-  // A horizontal progress bar.
-  Progressbar,
-  // The progress bar's progress indicator
-  Progresschunk,
-  // A vertical progress bar.
-  ProgressbarVertical,
-  // A vertical progress chunk.
-  ProgresschunkVertical,
-  // A checkbox element.
-  Checkbox,
-  // A radio element within a radio group.
-  Radio,
-  // A generic container that always repaints on state changes. This is a
-  // hack to make XUL checkboxes and radio buttons work.
-  CheckboxContainer,
-  RadioContainer,
-  // The label part of a checkbox or radio button, used for painting a focus
-  // outline.
-  CheckboxLabel,
-  RadioLabel,
-  // nsRangeFrame and its subparts
-  Range,
-  RangeThumb,
-  // The resizer background area in a status bar for the resizer widget in
-  // the corner of a window.
-  Resizerpanel,
-  // The resizer itself.
-  Resizer,
-  // A slider.
-  ScaleHorizontal,
-  ScaleVertical,
-  // A slider's thumb.
-  ScalethumbHorizontal,
-  ScalethumbVertical,
-  // If the platform supports it, the left/right chunks of the slider thumb.
-  Scalethumbstart,
-  Scalethumbend,
-  // The ticks for a slider.
-  Scalethumbtick,
-  // A scrollbar.
-  Scrollbar,
-  // A small scrollbar.
-  ScrollbarSmall,
-  // The scrollbar slider
-  ScrollbarHorizontal,
-  ScrollbarVertical,
-  // A scrollbar button (up/down/left/right).
-  // Keep these in order (some code casts these values to `int` in order to
-  // compare them against each other).
-  ScrollbarbuttonUp,
-  ScrollbarbuttonDown,
-  ScrollbarbuttonLeft,
-  ScrollbarbuttonRight,
-  // The scrollbar thumb.
-  ScrollbarthumbHorizontal,
-  ScrollbarthumbVertical,
-  // The scrollbar track.
-  ScrollbartrackHorizontal,
-  ScrollbartrackVertical,
-  // The scroll corner
-  Scrollcorner,
-  // A searchfield.
-  Searchfield,
-  // A separator.  Can be horizontal or vertical.
-  Separator,
-  // A spin control (up/down control for time/date pickers).
-  Spinner,
-  // The up button of a spin control.
-  SpinnerUpbutton,
-  // The down button of a spin control.
-  SpinnerDownbutton,
-  // The textfield of a spin control
-  SpinnerTextfield,
-  // A splitter.  Can be horizontal or vertical.
-  Splitter,
-  // A status bar in a main application window.
-  Statusbar,
-  // A single pane of a status bar.
-  Statusbarpanel,
-  // A single tab in a tab widget.
-  Tab,
-  // A single pane (inside the tabpanels container).
-  Tabpanel,
-  // The tab panels container.
-  Tabpanels,
-  // The tabs scroll arrows (left/right).
-  TabScrollArrowBack,
-  TabScrollArrowForward,
-  // A textfield or text area.
-  Textfield,
-  // A multiline text field.
-  TextfieldMultiline,
-  // A toolbar in an application window.
-  Toolbar,
-  // A single toolbar button (with no associated dropdown).
-  Toolbarbutton,
-  // The dropdown portion of a toolbar button
-  ToolbarbuttonDropdown,
-  // The gripper for a toolbar.
-  Toolbargripper,
-  // The toolbox that contains the toolbars.
-  Toolbox,
-  // A tooltip.
-  Tooltip,
-  // A listbox or tree widget header
-  Treeheader,
-  // An individual header cell
-  Treeheadercell,
-  // The sort arrow for a header.
-  Treeheadersortarrow,
-  // A tree item.
-  Treeitem,
-  // A tree widget branch line
-  Treeline,
-  // A tree widget twisty.
-  Treetwisty,
-  // Open tree widget twisty.
-  Treetwistyopen,
-  // A tree widget.
-  Treeview,
-  // Window and dialog backgrounds.
-  Window,
-  Dialog,
-  // Vista Rebars.
-  MozWinCommunicationsToolbox,
-  MozWinMediaToolbox,
-  MozWinBrowsertabbarToolbox,
-  // Vista glass.
-  MozWinGlass,
-  MozWinBorderlessGlass,
-  // -moz-apperance style used in setting proper glass margins.
-  MozWinExcludeGlass,
-  // Titlebar elements on the Mac.
-  MozMacFullscreenButton,
-  // Mac help button.
-  MozMacHelpButton,
-  // Windows themed window frame elements.
-  MozWindowButtonBox,
-  MozWindowButtonBoxMaximized,
-  MozWindowButtonClose,
-  MozWindowButtonMaximize,
-  MozWindowButtonMinimize,
-  MozWindowButtonRestore,
-  MozWindowFrameBottom,
-  MozWindowFrameLeft,
-  MozWindowFrameRight,
-  MozWindowTitlebar,
-  MozWindowTitlebarMaximized,
-  MozGtkInfoBar,
-  MozMacActiveSourceListSelection,
-  MozMacDisclosureButtonClosed,
-  MozMacDisclosureButtonOpen,
-  MozMacSourceList,
-  MozMacSourceListSelection,
-  MozMacVibrancyDark,
-  MozMacVibrancyLight,
-  MozMacVibrantTitlebarDark,
-  MozMacVibrantTitlebarLight,
-  // A non-disappearing scrollbar.
-  ScrollbarNonDisappearing,
-  // A themed focus outline (for outline:auto).
-  //
-  // This isn't exposed to CSS at all, just here for convenience.
-  FocusOutline,
-  // A dummy variant that should be last to let the GTK widget do hackery.
-  Count,
-};
-
-// Defines an element’s display type, which consists of
-// the two basic qualities of how an element generates boxes
-// <https://drafts.csswg.org/css-display/#propdef-display>
-//
-//
-// NOTE(emilio): Order is important in Gecko!
-//
-// If you change it, make sure to take a look at the
-// FrameConstructionDataByDisplay stuff (both the XUL and non-XUL version), and
-// ensure it's still correct!
-//
-// Also, when you change this from Gecko you may need to regenerate the
-// C++-side bindings (see components/style/cbindgen.toml).
-enum class StyleDisplay : uint8_t {
-  None = 0,
-  Block,
-  FlowRoot,
-  Inline,
-  InlineBlock,
-  ListItem,
-  Table,
-  InlineTable,
-  TableRowGroup,
-  TableColumn,
-  TableColumnGroup,
-  TableHeaderGroup,
-  TableFooterGroup,
-  TableRow,
-  TableCell,
-  TableCaption,
-  Flex,
-  InlineFlex,
-  Grid,
-  InlineGrid,
-  Ruby,
-  RubyBase,
-  RubyBaseContainer,
-  RubyText,
-  RubyTextContainer,
-  Contents,
-  WebkitBox,
-  WebkitInlineBox,
-  MozBox,
-  MozInlineBox,
-  MozGrid,
-  MozInlineGrid,
-  MozGridGroup,
-  MozGridLine,
-  MozStack,
-  MozInlineStack,
-  MozDeck,
-  MozGroupbox,
-  MozPopup,
-};
-
-// Values for the display-mode media feature.
-enum class StyleDisplayMode : uint8_t {
-  Browser = 0,
-  MinimalUi,
-  Standalone,
-  Fullscreen,
-};
-
-} // namespace mozilla
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -78,17 +78,16 @@ EXPORTS.mozilla += [
     'ServoBindings.h',
     'ServoBindingTypes.h',
     'ServoComputedData.h',
     'ServoComputedDataInlines.h',
     'ServoCSSParser.h',
     'ServoCSSRuleList.h',
     'ServoElementSnapshot.h',
     'ServoElementSnapshotTable.h',
-    'ServoStyleConsts.h',
     'ServoStyleSet.h',
     'ServoStyleSetInlines.h',
     'ServoTraversalStatistics.h',
     'ServoTypes.h',
     'ServoUtils.h',
     'SheetType.h',
     'StyleAnimationValue.h',
     'StyleComplexColor.h',
@@ -271,25 +270,36 @@ servo_props.script = 'GenerateServoCSSPr
 servo_props.inputs = [
     'ServoCSSPropList.mako.py',
 ]
 
 if CONFIG['COMPILE_ENVIRONMENT']:
     GENERATED_FILES += [
         'nsComputedDOMStyleGenerated.cpp',
         'nsCSSPropsGenerated.inc',
+        'ServoStyleConsts.h',
+    ]
+
+    EXPORTS.mozilla += [
+        '!ServoStyleConsts.h',
     ]
 
     computed = GENERATED_FILES['nsComputedDOMStyleGenerated.cpp']
     computed.script = 'GenerateComputedDOMStyleGenerated.py:generate'
     computed.inputs = [
         '!ServoCSSPropList.py',
     ]
 
     css_props = GENERATED_FILES['nsCSSPropsGenerated.inc']
     css_props.script = 'GenerateCSSPropsGenerated.py:generate'
     css_props.inputs = [
         '!ServoCSSPropList.py',
     ]
 
+    consts = GENERATED_FILES['ServoStyleConsts.h']
+    consts.script = 'GenerateServoStyleConsts.py:generate'
+    consts.inputs = [
+        '/servo/components/style/cbindgen.toml',
+    ]
+
     CONFIGURE_SUBST_FILES += [
         'bindgen.toml',
     ]