Permalink
Browse files

Add the necessary bits to build gecko on ICS

  • Loading branch information...
1 parent 58ae4dd commit 0b1d99b913bd1c50cef511a8a7ad6d605b34c22b @michaelwu michaelwu committed Mar 20, 2012
Showing with 186 additions and 5 deletions.
  1. +3 −0 .gitmodules
  2. +6 −4 Makefile
  3. +174 −0 Unicode.h
  4. +2 −1 config/gecko-prof-gonk
  5. +1 −0 toolchains
View
@@ -349,3 +349,6 @@
[submodule "glue/gonk/external/busybox"]
path = glue/gonk/external/busybox
url = git://android.git.linaro.org/platform/external/busybox.git
+[submodule "toolchains"]
+ path = toolchains
+ url = git://github.com/mozilla-b2g/b2g-toolchains.git
View
@@ -16,7 +16,7 @@ GONK_BASE ?= glue/gonk
FASTBOOT ?= $(abspath $(GONK_BASE)/out/host/linux-x86/bin/fastboot)
HEIMDALL ?= heimdall
TOOLCHAIN_HOST = linux-x86
-TOOLCHAIN_PATH = $(GONK_BASE)/prebuilt/$(TOOLCHAIN_HOST)/toolchain/arm-eabi-4.4.3/bin
+TOOLCHAIN_PATH ?= $(GONK_BASE)/prebuilt/$(TOOLCHAIN_HOST)/toolchain/arm-eabi-4.4.3/bin
GAIA_PATH ?= $(abspath gaia)
GECKO_PATH ?= $(abspath gecko)
@@ -183,7 +183,7 @@ define GECKO_BUILD_CMD
export GONK_PRODUCT="$(GONK)" && \
export GONK_PATH="$(GONK_PATH)" && \
export TARGET_TOOLS_PREFIX="$(abspath $(TOOLCHAIN_PATH))" && \
- export EXTRA_INCLUDE="-include $(abspath Unicode.h)" && \
+ export EXTRA_INCLUDE="$(EXTRA_INCLUDE)" && \
ulimit -n 4096 && \
$(MAKE) -C $(GECKO_PATH) -f client.mk -s $(MAKE_FLAGS) && \
$(MAKE) -C $(GECKO_OBJDIR) package
@@ -374,6 +374,8 @@ config-nexuss-ics: blobs-nexuss-ics gonk-ics-sync config-gecko
echo "KERNEL_PATH = ./boot/kernel-android-samsung" >> .config.mk && \
echo "GONK = crespo" >> .config.mk && \
echo "GONK_BASE = glue/gonk-ics" >> .config.mk && \
+ echo "TOOLCHAIN_PATH = ./toolchains/arm-linux-androideabi-4.6.3/linux-x86/bin/arm-linux-androideabi-" >> .config.mk && \
+ echo "EXTRA_INCLUDE = -include \"$(abspath Unicode.h)\"" >> .config.mk && \
echo OK
.PHONY: config-qemu
@@ -627,7 +629,7 @@ test:
GDB_PORT=22576
GDBINIT=/tmp/b2g.gdbinit.$(shell whoami)
-GDB=$(abspath $(GONK_BASE)/prebuilt/linux-x86/tegra-gdb/arm-eabi-gdb)
+GDB=$(abspath toolchains/arm-linux-androideabi-4.6.3/linux-x86/bin/arm-linux-androideabi-gdb)
B2G_BIN=/system/b2g/b2g
.PHONY: forward-gdb-port
@@ -666,7 +668,7 @@ restore-auto-restart: adb-check-version
.PHONY: run-gdb-server
run-gdb-server: adb-check-version forward-gdb-port kill-gdb-server disable-auto-restart
- $(ADB) shell gdbserver :$(GDB_PORT) $(B2G_BIN).d &
+ $(ADB) shell LD_LIBRARY_PATH=/system/b2g gdbserver :$(GDB_PORT) $(B2G_BIN).d &
sleep 1
.PHONY: run-gdb
View
174 Unicode.h
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2005 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_UNICODE_H
+#define ANDROID_UNICODE_H
+
+#define __STDC_LIMIT_MACROS 1
+
+#include <sys/types.h>
+#include <stdint.h>
+
+extern "C" {
+
+// char32_t and char16_t are built-in types as of c++0x.
+#if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
+typedef uint32_t char32_t;
+typedef uint16_t char16_t;
+#endif
+
+// Standard string functions on char16_t strings.
+int strcmp16(const char16_t *, const char16_t *);
+int strncmp16(const char16_t *s1, const char16_t *s2, size_t n);
+size_t strlen16(const char16_t *);
+size_t strnlen16(const char16_t *, size_t);
+char16_t *strcpy16(char16_t *, const char16_t *);
+char16_t *strncpy16(char16_t *, const char16_t *, size_t);
+
+// Version of comparison that supports embedded nulls.
+// This is different than strncmp() because we don't stop
+// at a nul character and consider the strings to be different
+// if the lengths are different (thus we need to supply the
+// lengths of both strings). This can also be used when
+// your string is not nul-terminated as it will have the
+// equivalent result as strcmp16 (unlike strncmp16).
+int strzcmp16(const char16_t *s1, size_t n1, const char16_t *s2, size_t n2);
+
+// Version of strzcmp16 for comparing strings in different endianness.
+int strzcmp16_h_n(const char16_t *s1H, size_t n1, const char16_t *s2N, size_t n2);
+
+// Standard string functions on char32_t strings.
+size_t strlen32(const char32_t *);
+size_t strnlen32(const char32_t *, size_t);
+
+/**
+ * Measure the length of a UTF-32 string in UTF-8. If the string is invalid
+ * such as containing a surrogate character, -1 will be returned.
+ */
+ssize_t utf32_to_utf8_length(const char32_t *src, size_t src_len);
+
+/**
+ * Stores a UTF-8 string converted from "src" in "dst", if "dst_length" is not
+ * large enough to store the string, the part of the "src" string is stored
+ * into "dst" as much as possible. See the examples for more detail.
+ * Returns the size actually used for storing the string.
+ * dst" is not null-terminated when dst_len is fully used (like strncpy).
+ *
+ * Example 1
+ * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84)
+ * "src_len" == 2
+ * "dst_len" >= 7
+ * ->
+ * Returned value == 6
+ * "dst" becomes \xE3\x81\x82\xE3\x81\x84\0
+ * (note that "dst" is null-terminated)
+ *
+ * Example 2
+ * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84)
+ * "src_len" == 2
+ * "dst_len" == 5
+ * ->
+ * Returned value == 3
+ * "dst" becomes \xE3\x81\x82\0
+ * (note that "dst" is null-terminated, but \u3044 is not stored in "dst"
+ * since "dst" does not have enough size to store the character)
+ *
+ * Example 3
+ * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84)
+ * "src_len" == 2
+ * "dst_len" == 6
+ * ->
+ * Returned value == 6
+ * "dst" becomes \xE3\x81\x82\xE3\x81\x84
+ * (note that "dst" is NOT null-terminated, like strncpy)
+ */
+void utf32_to_utf8(const char32_t* src, size_t src_len, char* dst);
+
+/**
+ * Returns the unicode value at "index".
+ * Returns -1 when the index is invalid (equals to or more than "src_len").
+ * If returned value is positive, it is able to be converted to char32_t, which
+ * is unsigned. Then, if "next_index" is not NULL, the next index to be used is
+ * stored in "next_index". "next_index" can be NULL.
+ */
+int32_t utf32_from_utf8_at(const char *src, size_t src_len, size_t index, size_t *next_index);
+
+
+/**
+ * Returns the UTF-8 length of UTF-16 string "src".
+ */
+ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len);
+
+/**
+ * Converts a UTF-16 string to UTF-8. The destination buffer must be large
+ * enough to fit the UTF-16 as measured by utf16_to_utf8_length with an added
+ * NULL terminator.
+ */
+void utf16_to_utf8(const char16_t* src, size_t src_len, char* dst);
+
+/**
+ * Returns the length of "src" when "src" is valid UTF-8 string.
+ * Returns 0 if src is NULL or 0-length string. Returns -1 when the source
+ * is an invalid string.
+ *
+ * This function should be used to determine whether "src" is valid UTF-8
+ * characters with valid unicode codepoints. "src" must be null-terminated.
+ *
+ * If you are going to use other utf8_to_... functions defined in this header
+ * with string which may not be valid UTF-8 with valid codepoint (form 0 to
+ * 0x10FFFF), you should use this function before calling others, since the
+ * other functions do not check whether the string is valid UTF-8 or not.
+ *
+ * If you do not care whether "src" is valid UTF-8 or not, you should use
+ * strlen() as usual, which should be much faster.
+ */
+ssize_t utf8_length(const char *src);
+
+/**
+ * Measure the length of a UTF-32 string.
+ */
+size_t utf8_to_utf32_length(const char *src, size_t src_len);
+
+/**
+ * Stores a UTF-32 string converted from "src" in "dst". "dst" must be large
+ * enough to store the entire converted string as measured by
+ * utf8_to_utf32_length plus space for a NULL terminator.
+ */
+void utf8_to_utf32(const char* src, size_t src_len, char32_t* dst);
+
+/**
+ * Returns the UTF-16 length of UTF-8 string "src".
+ */
+ssize_t utf8_to_utf16_length(const uint8_t* src, size_t srcLen);
+
+/**
+ * Convert UTF-8 to UTF-16 including surrogate pairs.
+ * Returns a pointer to the end of the string (where a null terminator might go
+ * if you wanted to add one).
+ */
+char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* src, size_t srcLen, char16_t* dst);
+
+/**
+ * Convert UTF-8 to UTF-16 including surrogate pairs. The destination buffer
+ * must be large enough to hold the result as measured by utf8_to_utf16_length
+ * plus an added NULL terminator.
+ */
+void utf8_to_utf16(const uint8_t* src, size_t srcLen, char16_t* dst);
+
+}
+
+#undef __STDC_LIMIT_MACROS
+#endif
View
@@ -10,6 +10,7 @@ sys=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
ac_add_options --target=arm-android-eabi
ac_add_options --with-gonk="$gonk"
+ac_add_options --with-gonk-toolchain-prefix="$TARGET_TOOLS_PREFIX"
ac_add_options --with-endian=little
ac_add_options --enable-application=b2g
@@ -23,4 +24,4 @@ ac_add_options --enable-marionette
ac_add_options --enable-omx-plugin
# Enable dump() from JS.
-export CXXFLAGS=-DMOZ_ENABLE_JS_DUMP
+export CXXFLAGS="-DMOZ_ENABLE_JS_DUMP $EXTRA_INCLUDE"
Submodule toolchains added at 70cd8f

0 comments on commit 0b1d99b

Please sign in to comment.