mirror of
https://github.com/servo/servo.git
synced 2025-07-02 21:13:39 +01:00
Auto merge of #10194 - emilio:stylo-fixes-and-doc, r=bholley
geckolib: Add style structs bindings and documentation
See the description of 6c851c8
to see which incorrect bindings remain. They're just nine types.
cc @bholley @SimonSapin @pcwalton
(I don't know who should review this actually)
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10194)
<!-- Reviewable:end -->
This commit is contained in:
commit
d77c7b21ae
7 changed files with 4667 additions and 45 deletions
4494
ports/geckolib/gecko_style_structs.rs
Normal file
4494
ports/geckolib/gecko_style_structs.rs
Normal file
File diff suppressed because it is too large
Load diff
2
ports/geckolib/tools/.gitignore
vendored
Normal file
2
ports/geckolib/tools/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
llvm/
|
||||
rust-bindgen/
|
30
ports/geckolib/tools/README.md
Normal file
30
ports/geckolib/tools/README.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
# GeckoLib tools
|
||||
|
||||
This directory contains mostly simple tools for working with
|
||||
[stylo](https://public.etherpad-mozilla.org/p/stylo).
|
||||
|
||||
Some scripts require [multirust](https://github.com/brson/multirust) in order to
|
||||
work.
|
||||
|
||||
You can see a description of them below.
|
||||
|
||||
## `build_custom_clang.sh`
|
||||
|
||||
Download a patched LLVM which is needed to use bindgen properly with C++.
|
||||
|
||||
## `setup_bindgen.sh`
|
||||
|
||||
This uses downloads a custom version of bindgen, up to date to generate the
|
||||
bindings, and uses the custom `clang` to build it.
|
||||
|
||||
It will also rebuild it if it's already downloaded.
|
||||
|
||||
## `regen_bindings.sh`
|
||||
|
||||
This will regenerate the bindings for the `ServoBindings.h` file in your gecko
|
||||
build (which are in `ports/geckolib/bindings.rs`).
|
||||
|
||||
## `regen_style_structs.sh`
|
||||
|
||||
This will generate the bindings for Gecko's style structs. Current bindings are
|
||||
actually in `ports/geckolib/gecko_style_structs.rs`.
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run in the tools directory.
|
||||
cd `dirname $0`
|
||||
cd "$(dirname $0)"
|
||||
|
||||
# Don't run twice.
|
||||
if [ -d llvm ]; then
|
||||
|
@ -12,15 +12,13 @@ fi
|
|||
# Download and build a custom llvm
|
||||
git clone https://github.com/llvm-mirror/llvm
|
||||
cd llvm
|
||||
git checkout release_37
|
||||
git checkout release_38
|
||||
cd tools
|
||||
git clone https://github.com/llvm-mirror/clang
|
||||
cd clang
|
||||
git remote add mwu https://github.com/michaelwu/clang
|
||||
git fetch mwu
|
||||
git checkout release_37_smhacks
|
||||
git checkout release_38
|
||||
cd ../.. # llvm root dir
|
||||
mkdir build
|
||||
cd build
|
||||
../configure --enable-optimized
|
||||
make
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
|
||||
make -j8
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run in the tools directory.
|
||||
cd `dirname $0`
|
||||
cd "$(dirname $0)"
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: $0 /path/to/objdir/"
|
||||
echo "Usage: $0 /path/to/gecko/objdir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -15,12 +15,13 @@ if [ ! -d rust-bindgen ]; then
|
|||
fi
|
||||
|
||||
export RUST_BACKTRACE=1
|
||||
export LIBCLANG_PATH=`pwd`/llvm/build/Release+Asserts/lib
|
||||
export DYLD_LIBRARY_PATH=`pwd`/llvm/build/Release+Asserts/lib
|
||||
export DIST_INCLUDE=$1/dist/include
|
||||
export LIBCLANG_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
|
||||
export DYLD_LIBRARY_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
|
||||
export LD_LIBRARY_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
|
||||
export DIST_INCLUDE="$1/dist/include"
|
||||
|
||||
# Check for the include directory.
|
||||
if [ ! -d $DIST_INCLUDE ]; then
|
||||
if [ ! -d "$DIST_INCLUDE" ]; then
|
||||
echo "$DIST_INCLUDE: directory not found"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -30,4 +31,8 @@ fi
|
|||
# library in DYLD_LIBRARY_PATH.
|
||||
#
|
||||
# /Applications/Xcode.app/Contents/Developer/usr/bin/lldb --
|
||||
./rust-bindgen/target/debug/bindgen -x c++ -std=gnu++0x -I$DIST_INCLUDE -o ../bindings.rs $DIST_INCLUDE/mozilla/ServoBindings.h
|
||||
./rust-bindgen/target/debug/bindgen \
|
||||
-x c++ -std=gnu++0x \
|
||||
"-I$DIST_INCLUDE" \
|
||||
-o ../bindings.rs \
|
||||
"$DIST_INCLUDE/mozilla/ServoBindings.h"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run in the tools directory.
|
||||
cd `dirname $0`
|
||||
cd "$(dirname $0)"
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: $0 /path/to/objdir/"
|
||||
echo "Usage: $0 /path/to/gecko/objdir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -15,27 +15,116 @@ if [ ! -d rust-bindgen ]; then
|
|||
fi
|
||||
|
||||
# Need to find a way to avoid hardcoding these
|
||||
STD_LIB_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include
|
||||
STDXX_LIB_PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
|
||||
if [ ! -d $STD_LIB_PATH ] || [ ! -d $STDXX_LIB_PATH ]; then
|
||||
echo "Please update the above environmental variables to point to your standard library."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export RUST_BACKTRACE=1
|
||||
export LIBCLANG_PATH=`pwd`/llvm/build/Release+Asserts/lib
|
||||
export DYLD_LIBRARY_PATH=`pwd`/llvm/build/Release+Asserts/lib
|
||||
export DIST_INCLUDE=$1/dist/include
|
||||
export LIBCLANG_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
|
||||
export DYLD_LIBRARY_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
|
||||
export LD_LIBRARY_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
|
||||
export DIST_INCLUDE="$1/dist/include"
|
||||
CLANG_SEARCH_DIRS=$(clang++ -E -x c++ - -v < /dev/null 2>&1 | awk '{ \
|
||||
if ($0 == "#include <...> search starts here:") \
|
||||
in_headers = 1; \
|
||||
else if ($0 == "End of search list.") \
|
||||
in_headers = 0; \
|
||||
else if (in_headers == 1) { \
|
||||
gsub(/^[ \t]+/, "", $0); \
|
||||
gsub(/[ \t].+$/, "", $0); \
|
||||
printf " -isystem \"%s\"", $0; \
|
||||
}
|
||||
}' | sed -e s/:$//g)
|
||||
|
||||
# Check for the include directory.
|
||||
if [ ! -d $DIST_INCLUDE ]; then
|
||||
if [ ! -d "$DIST_INCLUDE" ]; then
|
||||
echo "$DIST_INCLUDE: directory not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Uncomment the following line to run rust-bindgen in a debugger on mac.
|
||||
# The absolute path is required to allow launching lldb with an untrusted
|
||||
# library in DYLD_LIBRARY_PATH.
|
||||
PLATFORM_DEPENDENT_DEFINES="";
|
||||
if [ "$(uname)" == "Linux" ]; then
|
||||
PLATFORM_DEPENDENT_DEFINES+="-DOS_LINUX";
|
||||
else
|
||||
PLATFORM_DEPENDENT_DEFINES+="-DOS_MACOSX";
|
||||
fi
|
||||
|
||||
# Uncomment the following line to run rust-bindgen in a debugger on mac. The
|
||||
# absolute path is required to allow launching lldb with an untrusted library
|
||||
# in DYLD_LIBRARY_PATH.
|
||||
#
|
||||
# /Applications/Xcode.app/Contents/Developer/usr/bin/lldb --
|
||||
./rust-bindgen/target/debug/bindgen -x c++ -std=gnu++0x -ignore-functions -allow-unknown-types -isystem $STDXX_LIB_PATH -isystem $STD_LIB_PATH -I$DIST_INCLUDE -I$DIST_INCLUDE/nspr -DDEBUG=1 -DTRACING=1 -DOS_POSIX=1 -DOS_MACOSX=1 -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -include $1/mozilla-config.h -o ../gecko_style_structs.rs $DIST_INCLUDE/nsStyleStruct.h
|
||||
# gdb -ex "break rust_panic" -ex run --args \
|
||||
# -enable-cxx-namespaces \
|
||||
./rust-bindgen/target/debug/bindgen \
|
||||
-o ../gecko_style_structs.rs \
|
||||
-x c++ -std=gnu++0x \
|
||||
-allow-unknown-types \
|
||||
$CLANG_SEARCH_DIRS \
|
||||
"-I$DIST_INCLUDE" "-I$DIST_INCLUDE/nspr" \
|
||||
"-I$1/../nsprpub/pr/include" \
|
||||
$PLATFORM_DEPENDENT_DEFINES \
|
||||
-ignore-functions \
|
||||
-no-bitfield-methods \
|
||||
-no-type-renaming \
|
||||
-DMOZILLA_INTERNAL_API \
|
||||
-DMOZ_STYLO_BINDINGS=1 \
|
||||
-DDEBUG=1 -DTRACING=1 -DOS_POSIX=1 \
|
||||
-DIMPL_LIBXUL \
|
||||
-match "RefCountType.h" \
|
||||
-match "nscore.h" \
|
||||
-match "nsError.h" \
|
||||
-match "nsID.h" \
|
||||
-match "nsString" \
|
||||
-match "nsAString" \
|
||||
-match "nsSubstring" \
|
||||
-match "nsTSubstring" \
|
||||
-match "nsTString" \
|
||||
-match "nsISupportsBase.h" \
|
||||
-match "nsCOMPtr.h" \
|
||||
-match "nsIAtom.h" \
|
||||
-match "nsIURI.h" \
|
||||
-match "nsAutoPtr.h" \
|
||||
-match "nsColor.h" \
|
||||
-match "nsCoord.h" \
|
||||
-match "nsPoint.h" \
|
||||
-match "nsRect.h" \
|
||||
-match "nsMargin.h" \
|
||||
-match "nsCSSProperty.h" \
|
||||
-match "CSSVariableValues.h" \
|
||||
-match "nsFont.h" \
|
||||
-match "nsTHashtable.h" \
|
||||
-match "PLDHashTable.h" \
|
||||
-match "nsColor.h" \
|
||||
-match "nsStyleStruct.h" \
|
||||
-match "nsStyleCoord.h" \
|
||||
-match "RefPtr.h" \
|
||||
-match "nsISupportsImpl.h" \
|
||||
-match "gfxFontFamilyList.h" \
|
||||
-match "gfxFontFeatures.h" \
|
||||
-match "imgRequestProxy.h" \
|
||||
-match "nsIRequest.h" \
|
||||
-match "imgIRequest.h" \
|
||||
-match "CounterStyleManager.h" \
|
||||
-match "nsStyleConsts.h" \
|
||||
-match "nsCSSValue.h" \
|
||||
-match "SheetType.h" \
|
||||
-match "nsIPrincipal.h" \
|
||||
-match "nsDataHashtable.h" \
|
||||
-match "nsCSSScanner.h" \
|
||||
-blacklist-type "IsDestructibleFallbackImpl" \
|
||||
-blacklist-type "IsDestructibleFallback" \
|
||||
-opaque-type "nsIntMargin" \
|
||||
-opaque-type "nsIntPoint" \
|
||||
-opaque-type "nsIntRect" \
|
||||
-opaque-type "nsTArray" \
|
||||
-opaque-type "nsCOMArray" \
|
||||
-opaque-type "nsDependentString" \
|
||||
-opaque-type "EntryStore" \
|
||||
-opaque-type "gfxFontFeatureValueSet" \
|
||||
-opaque-type "imgRequestProxy" \
|
||||
-opaque-type "imgRequestProxyStatic" \
|
||||
-opaque-type "CounterStyleManager" \
|
||||
-opaque-type "ImageValue" \
|
||||
-opaque-type "URLValue" \
|
||||
-opaque-type "nsIPrincipal" \
|
||||
-opaque-type "nsDataHashtable" \
|
||||
-opaque-type "imgIRequest" \
|
||||
-include "$1/mozilla-config.h" \
|
||||
"$DIST_INCLUDE/nsStyleStruct.h"
|
||||
|
|
|
@ -1,30 +1,34 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run in the tools directory.
|
||||
cd `dirname $0`
|
||||
cd "$(dirname $0)"
|
||||
|
||||
# Setup and build bindgen.
|
||||
export LIBCLANG_PATH="$(pwd)/llvm/build/lib"
|
||||
export LD_LIBRARY_PATH="$(pwd)/llvm/build/lib"
|
||||
export DYLD_LIBRARY_PATH="$(pwd)/llvm/build/lib"
|
||||
|
||||
|
||||
# Make sure we have a custom clang set up.
|
||||
if [ ! -d llvm ]; then
|
||||
if [ ! -d "$LIBCLANG_PATH" ]; then
|
||||
echo "Custom LLVM/Clang not found. Run build_custom_clang.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Don't run twice.
|
||||
if [ -d rust-bindgen ]; then
|
||||
echo "rust-bindgen directory already exists."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for multirust
|
||||
if [ ! -x "$(command -v multirust)" ]; then
|
||||
echo 'multirust must be installed.'
|
||||
echo "multirust must be installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Setup and build bindgen.
|
||||
export LIBCLANG_PATH=`pwd`/llvm/build/Release+Asserts/lib
|
||||
git clone https://github.com/bholley/rust-bindgen.git
|
||||
cd rust-bindgen
|
||||
git checkout sm-hacks
|
||||
# Don't try to clone twice.
|
||||
if [ ! -d rust-bindgen ]; then
|
||||
git clone https://github.com/ecoal95/rust-bindgen.git
|
||||
cd rust-bindgen
|
||||
git checkout sm-hacks-rebase-squashed
|
||||
else
|
||||
cd rust-bindgen
|
||||
fi
|
||||
|
||||
multirust override nightly
|
||||
cargo build
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue