geckolib: Add basic documentation, be consistent and safe with quotes

This commit is contained in:
Emilio Cobos Álvarez 2016-03-05 01:56:22 +01:00
parent 38b30c6490
commit a6ffabb2ad
6 changed files with 80 additions and 29 deletions

2
ports/geckolib/tools/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
llvm/
rust-bindgen/

View 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. These bindings are a
work in progress, and are not in master yet.

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Run in the tools directory. # Run in the tools directory.
cd `dirname $0` cd "$(dirname $0)"
# Don't run twice. # Don't run twice.
if [ -d llvm ]; then if [ -d llvm ]; then

View file

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
# Run in the tools directory. # Run in the tools directory.
cd `dirname $0` cd "$(dirname $0)"
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
echo "Usage: $0 /path/to/objdir/" echo "Usage: $0 /path/to/gecko/objdir"
exit 1 exit 1
fi fi
@ -15,13 +15,13 @@ if [ ! -d rust-bindgen ]; then
fi fi
export RUST_BACKTRACE=1 export RUST_BACKTRACE=1
export LIBCLANG_PATH=`pwd`/llvm/build/Release+Asserts/lib export LIBCLANG_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
export DYLD_LIBRARY_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 LD_LIBRARY_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
export DIST_INCLUDE=$1/dist/include export DIST_INCLUDE="$1/dist/include"
# Check for the include directory. # Check for the include directory.
if [ ! -d $DIST_INCLUDE ]; then if [ ! -d "$DIST_INCLUDE" ]; then
echo "$DIST_INCLUDE: directory not found" echo "$DIST_INCLUDE: directory not found"
exit 1 exit 1
fi fi
@ -31,4 +31,8 @@ fi
# library in DYLD_LIBRARY_PATH. # library in DYLD_LIBRARY_PATH.
# #
# /Applications/Xcode.app/Contents/Developer/usr/bin/lldb -- # /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"

View file

@ -4,7 +4,7 @@
cd `dirname $0` cd `dirname $0`
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
echo "Usage: $0 /path/to/objdir/" echo "Usage: $0 /path/to/gecko/objdir"
exit 1 exit 1
fi fi
@ -16,11 +16,10 @@ fi
# Need to find a way to avoid hardcoding these # Need to find a way to avoid hardcoding these
export RUST_BACKTRACE=1 export RUST_BACKTRACE=1
export LIBCLANG_PATH=`pwd`/llvm/build/Release+Asserts/lib export LIBCLANG_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
export DYLD_LIBRARY_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 LD_LIBRARY_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
export DIST_INCLUDE=$1/dist/include export DIST_INCLUDE="$1/dist/include"
CLANG_SEARCH_DIRS=$(clang++ -print-search-dirs | grep 'libraries: ' | cut -d = -f 2)
CLANG_SEARCH_DIRS=$(clang++ -E -x c++ - -v < /dev/null 2>&1 | awk '{ \ CLANG_SEARCH_DIRS=$(clang++ -E -x c++ - -v < /dev/null 2>&1 | awk '{ \
if ($0 == "#include <...> search starts here:") \ if ($0 == "#include <...> search starts here:") \
in_headers = 1; \ in_headers = 1; \
@ -33,17 +32,31 @@ CLANG_SEARCH_DIRS=$(clang++ -E -x c++ - -v < /dev/null 2>&1 | awk '{ \
}' | sed -e s/:$//g) }' | sed -e s/:$//g)
# Check for the include directory. # Check for the include directory.
if [ ! -d $DIST_INCLUDE ]; then if [ ! -d "$DIST_INCLUDE" ]; then
echo "$DIST_INCLUDE: directory not found" echo "$DIST_INCLUDE: directory not found"
exit 1 exit 1
fi fi
# Uncomment the following line to run rust-bindgen in a debugger on mac. PLATFORM_DEPENDENT_DEFINES="";
# The absolute path is required to allow launching lldb with an untrusted if [ "$(uname)" == "Linux" ]; then
# library in DYLD_LIBRARY_PATH. 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 -- # /Applications/Xcode.app/Contents/Developer/usr/bin/lldb --
./rust-bindgen/target/debug/bindgen -x c++ -std=gnu++0x -ignore-functions -allow-unknown-types \ ./rust-bindgen/target/debug/bindgen \
$CLANG_SEARCH_DIRS \ -x c++ -std=gnu++0x \
-I$DIST_INCLUDE -I$DIST_INCLUDE/nspr -DDEBUG=1 -DTRACING=1 -DOS_POSIX=1 -DOS_MACOSX=1 -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL \ -ignore-functions -allow-unknown-types \
-include $1/mozilla-config.h -o ../gecko_style_structs.rs $DIST_INCLUDE/nsStyleStruct.h $CLANG_SEARCH_DIRS \
"-I$DIST_INCLUDE" "-I$DIST_INCLUDE/nspr" \
$PLATFORM_DEPENDENT_DEFINES \
-DDEBUG=1 -DTRACING=1 -DOS_POSIX=1 \
-DMOZILLA_INTERNAL_API -DIMPL_LIBXUL \
-include "$1/mozilla-config.h" \
-o ../gecko_style_structs.rs \
"$DIST_INCLUDE/nsStyleStruct.h"

View file

@ -1,23 +1,25 @@
#!/bin/bash #!/bin/bash
# Run in the tools directory. # Run in the tools directory.
cd `dirname $0` cd "$(dirname $0)"
# Setup and build bindgen.
export LIBCLANG_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
# Make sure we have a custom clang set up. # 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." echo "Custom LLVM/Clang not found. Run build_custom_clang.sh first."
exit 1 exit 1
fi fi
# Check for multirust # Check for multirust
if [ ! -x "$(command -v multirust)" ]; then if [ ! -x "$(command -v multirust)" ]; then
echo 'multirust must be installed.' echo "multirust must be installed."
exit 1 exit 1
fi fi
# Setup and build bindgen. # Don't try to clone twice.
export LIBCLANG_PATH=`pwd`/llvm/build/Release+Asserts/lib
# Don't run twice.
if [ ! -d rust-bindgen ]; then if [ ! -d rust-bindgen ]; then
git clone https://github.com/bholley/rust-bindgen.git git clone https://github.com/bholley/rust-bindgen.git
cd rust-bindgen cd rust-bindgen