├── protobuf-2.5.0 ├── README.md ├── BUILD └── BUILD.src.google.protobuf ├── README.md ├── android-prebuilts ├── README.md ├── get-toolchains.sh ├── BUILD └── gen-crosstool.py ├── android-ndk ├── BUILD.sysroot ├── README.md ├── BUILD └── CROSSTOOL ├── CONTRIBUTING.md ├── re2 └── BUILD └── LICENSE.txt /protobuf-2.5.0/README.md: -------------------------------------------------------------------------------- 1 | # Building protoc with Bazel 2 | 3 | Instructions 4 | 5 | 1. Put BUILD into the root source directory 6 | 2. Put BUILD.src.google.protobuf into src/google/protobuf/BUILD 7 | 3. Run configure 8 | 4. Run bazel: 9 | 10 | ```` 11 | touch WORKSPACE 12 | bazel build //src/google/protobuf:protoc 13 | ```` 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # These are example snippets and BUILD files for [Bazel](github.com/google/bazel). 3 | 4 | * A [recipe](android-prebuilts/README.md) for configuring AOSP 5 | prebuilt toolchains for Bazel. 6 | 7 | * A [recipe](protobuf-2.5.0/README.md) for compiling the 8 | protobuf 2.5.0 compiler with Bazel. We used this with AOSP i686 9 | toolchain to produce the `protoc` binary in the Bazel repo. 10 | 11 | * A [BUILD file](re2/BUILD) for compiling RE2. 12 | 13 | * An example of setting up a [cross-compiler](android-ndk/README.md) 14 | -------------------------------------------------------------------------------- /protobuf-2.5.0/BUILD: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2014 Google Inc. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | cc_library( 20 | name = "config", 21 | hdrs = ["config.h"], 22 | ) 23 | 24 | exports_files([ 25 | "config.h", 26 | "config.h.include", 27 | ]) 28 | -------------------------------------------------------------------------------- /android-prebuilts/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Example: configuring a hermetic toolchain on Linux 3 | 4 | Bazel ships with an example compiler configuration for /usr/bin/gcc. 5 | While these are universally available, they are not hermetic: versions 6 | of the compiler may vary across installations. 7 | 8 | The following example shows how to install a prebuilt toolchain, using 9 | the pre-packaged compilers from the Android Open Source project. The 10 | example includes configurations for 11 | 12 | * Compiling on linux-x86 for linux-x86 (64-bit) 13 | * Compiling on linux-x86 for linux-x86 (32-bit) 14 | * Compiling on linux-x86 for Window 64-bit w32 (untested) 15 | 16 | 1. Create directory ~/toolchains/android-prebuilts/ 17 | 18 | 2. Download the binaries: 19 | 20 | ```` 21 | get-toolchains.sh 22 | ```` 23 | 24 | 3. Create the CROSSTOOL configuration 25 | 26 | ``` 27 | gen-crosstool.py 28 | ``` 29 | 30 | 4. Run Bazel, eg. 31 | 32 | ```` 33 | bazel build --package_path=%workspace%:$HOME/toolchains:$HOME/bazel \ 34 | --crosstool_top=//android-prebuilts:toolchain \ 35 | --cpu=i686 \ 36 | //src/google/protobuf:protoc 37 | ```` 38 | -------------------------------------------------------------------------------- /android-prebuilts/get-toolchains.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2014 Google Inc. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | set -eux 19 | for p in gcc/linux-x86/host/i686-linux-glibc2.7-4.6 \ 20 | gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6 \ 21 | gcc/linux-x86/host/x86_64-w64-mingw32-4.8 \ 22 | gcc/darwin-x86/host/headers \ 23 | gcc/darwin-x86/host/i686-apple-darwin-4.2.1 24 | do 25 | prefix=$(echo $p | sed 's|\(gcc/[^/]*\)/.*|\1|g') 26 | mkdir -p ${prefix} 27 | (cd ${prefix} && 28 | git clone https://android.googlesource.com/platform/prebuilts/$p ) 29 | done 30 | -------------------------------------------------------------------------------- /android-ndk/BUILD.sysroot: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2015 Google Inc. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | package(default_visibility = ["//visibility:public"]) 17 | 18 | filegroup( 19 | name = "everything", 20 | srcs = [ 21 | ":compile", 22 | ":link", 23 | ], 24 | ) 25 | 26 | filegroup( 27 | name = "compile", 28 | srcs = glob( 29 | [ 30 | "usr/include/**/*.h", 31 | ], 32 | ), 33 | ) 34 | 35 | filegroup( 36 | name = "link", 37 | srcs = glob( 38 | [ 39 | "usr/lib/**/*.a", 40 | "usr/lib/**/*.o", 41 | "usr/lib/**/*.so", 42 | ], 43 | ), 44 | ) 45 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributing to this repository. 3 | 4 | We put these examples together because we needed them, and because 5 | they seemed instructive. We encourage you to come up with variations 6 | of this within your own source tree. 7 | 8 | Should wish to contribute examples back, please sign Google's CLA 9 | before sending us patches: https://cla.developers.google.com/ 10 | 11 | The CLA is necessary mainly because you own the copyright to your 12 | changes, even after your contribution becomes part of our codebase, so 13 | we need your permission to use and distribute your code. We also need 14 | to be sure of various other things - for instance that you'll tell us 15 | if you know that your code infringes on other people's patents. You 16 | don't have to sign the CLA until after you've submitted your code for 17 | review and a member has approved it, but you must do it before we can 18 | put your code into our codebase. 19 | 20 | Before you start working on a larger contribution, you should get in 21 | touch with us first through bazel-dev@googlegroups.com. 22 | 23 | ### The small print 24 | Contributions made by corporations are covered by a different agreement than 25 | the one above, the Software Grant and Corporate Contributor License Agreement. 26 | -------------------------------------------------------------------------------- /android-ndk/README.md: -------------------------------------------------------------------------------- 1 | # An example of configuring a compiler. 2 | 3 | This gives an example of how to setup a cross-compiler for embedded 4 | development. It is using the cross compiler from the Android NDK, but 5 | other GCC flavors should be similar. 6 | 7 | *This is not an example of how build android NDK apps*. 8 | 9 | ## Instructions 10 | 11 | The following instructions assume Linux 64-bit machine. 12 | 13 | * Download the Android NDK from 14 | https://developer.android.com/tools/sdk/ndk/index.html 15 | 16 | * Unpack it into $HOME/tmp/android such that 17 | `$HOME/tmp/android/android-ndk` contains `README.txt` 18 | 19 | * Put `BUILD` and `CROSSTOOL` into `$HOME/tmp/android/android-ndk` 20 | 21 | * Put `BUILD.sysroot` into 22 | `$HOME/tmp/android/android-ndk/platforms/android-19/arch-arm/BUILD` 23 | (don't forget to rename it.) 24 | 25 | * Now create a separate workspace with a BUILD for a `cc_binary` 26 | 27 | * Run 28 | 29 | ``` 30 | bazel build --dynamic_mode=off \ 31 | --package_path=%workspace%:$HOME/tmp/android:$HOME/bazel-src \ 32 | --crosstool_top=//android-ndk:toolchain \ 33 | --host_crosstool_top=//tools/cpp:toolchain \ 34 | --cpu=armeabi-v7a \ 35 | --custom_malloc=//android-ndk:malloc \ 36 | //my/cc:binary 37 | ``` 38 | 39 | * To deploy and test the resulting to your Android phone, using 40 | 41 | ``` 42 | adb bazel-bin/my/cc/binary data/local/tmp/my-binary 43 | adb shell ./data/local/tmp/my-binary 44 | ``` 45 | 46 | For Darwin, the steps will be similar, but all paths referring to 47 | "linux-x86" should the equivalent darwin-x86 path instead. 48 | -------------------------------------------------------------------------------- /android-prebuilts/BUILD: -------------------------------------------------------------------------------- 1 | # The whole of crosstool for all configurations. 2 | 3 | # 4 | # Copyright 2014 Google Inc. All Rights Reserved. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | package(default_visibility = ["//visibility:public"]) 20 | 21 | cpus = { 22 | "x86_64": "linux-x86/host/x86_64-linux-glibc2.7-4.6", 23 | "i686": "linux-x86/host/i686-linux-glibc2.7-4.6", 24 | "mingw-x86_64": "linux-x86/host/x86_64-w64-mingw32-4.8", 25 | } 26 | 27 | [filegroup( 28 | name = "gcc-toolchain-%s" % cpu, 29 | srcs = glob([ 30 | "gcc/%s/**" % p, 31 | ]), 32 | output_licenses = ["unencumbered"], 33 | ) for cpu, p in cpus.items()] 34 | 35 | filegroup( 36 | name = "empty", 37 | srcs = [], 38 | ) 39 | 40 | filegroup( 41 | name = "toolchain", 42 | srcs = [ 43 | ":empty", 44 | ] + [":cc-compiler-%s" % cpu for cpu in cpus], 45 | ) 46 | 47 | [cc_toolchain( 48 | name = "cc-compiler-%s" % cpu, 49 | all_files = ":gcc-toolchain-%s" % cpu, 50 | compiler_files = ":gcc-toolchain-%s" % cpu, 51 | cpu = cpu, 52 | dwp_files = ":gcc-toolchain-%s" % cpu, 53 | dynamic_runtime_libs = [":gcc-toolchain-%s" % cpu], 54 | linker_files = ":gcc-toolchain-%s" % cpu, 55 | objcopy_files = ":gcc-toolchain-%s" % cpu, 56 | static_runtime_libs = [":gcc-toolchain-%s" % cpu], 57 | strip_files = ":gcc-toolchain-%s" % cpu, 58 | supports_param_files = 0, 59 | ) for cpu in cpus.keys()] 60 | -------------------------------------------------------------------------------- /android-ndk/BUILD: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2015 Google Inc. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | package(default_visibility = ["//visibility:public"]) 17 | 18 | filegroup( 19 | name = "toolchain", 20 | srcs = [ 21 | ":cc-compiler-armeabi-v7a", 22 | ":empty", 23 | "//android-ndk/platforms/android-19/arch-arm:everything", 24 | ], 25 | ) 26 | 27 | cc_library( 28 | name = "malloc", 29 | srcs = [], 30 | ) 31 | 32 | filegroup( 33 | name = "gcc-arm-android-4.8-toolchain", 34 | srcs = glob([ 35 | "toolchains/arm-linux-androideabi-4.8/**", 36 | ]), 37 | output_licenses = ["unencumbered"], 38 | ) 39 | 40 | filegroup( 41 | name = "android-armeabi-v7a-files", 42 | srcs = [ 43 | ":gcc-arm-android-4.8-toolchain", 44 | "//android-ndk/platforms/android-19/arch-arm:everything", 45 | ], 46 | ) 47 | 48 | cc_toolchain( 49 | name = "cc-compiler-armeabi-v7a", 50 | all_files = ":android-armeabi-v7a-files", 51 | compiler_files = ":gcc-arm-android-4.8-toolchain", 52 | cpu = "armeabi-v7a", 53 | dwp_files = ":gcc-arm-android-4.8-toolchain", 54 | dynamic_runtime_libs = [":gcc-arm-android-4.8-toolchain"], 55 | linker_files = ":gcc-arm-android-4.8-toolchain", 56 | objcopy_files = ":gcc-arm-android-4.8-toolchain", 57 | static_runtime_libs = [":gcc-arm-android-4.8-toolchain"], 58 | strip_files = ":gcc-arm-android-4.8-toolchain", 59 | supports_param_files = 0, 60 | ) 61 | -------------------------------------------------------------------------------- /re2/BUILD: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2015 Google Inc. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | package(default_visibility = ["//visibility:public"]) 17 | 18 | cc_library( 19 | name = "util", 20 | srcs = [ 21 | "util/arena.cc", 22 | "util/hash.cc", 23 | "util/rune.cc", 24 | "util/stringpiece.cc", 25 | "util/stringprintf.cc", 26 | "util/strutil.cc", 27 | "util/valgrind.cc", 28 | ], 29 | hdrs = glob(["util/*.h"]), 30 | includes = ["."], 31 | ) 32 | 33 | cc_library( 34 | name = "re2", 35 | srcs = [ 36 | "re2/bitstate.cc", 37 | "re2/compile.cc", 38 | "re2/dfa.cc", 39 | "re2/filtered_re2.cc", 40 | "re2/mimics_pcre.cc", 41 | "re2/nfa.cc", 42 | "re2/onepass.cc", 43 | "re2/parse.cc", 44 | "re2/perl_groups.cc", 45 | "re2/prefilter.cc", 46 | "re2/prefilter_tree.cc", 47 | "re2/prog.cc", 48 | "re2/re2.cc", 49 | "re2/regexp.cc", 50 | "re2/set.cc", 51 | "re2/simplify.cc", 52 | "re2/tostring.cc", 53 | "re2/unicode_casefold.cc", 54 | "re2/unicode_groups.cc", 55 | ], 56 | hdrs = [ 57 | "re2/prog.h", 58 | "re2/re2.h", 59 | "re2/regexp.h", 60 | "re2/unicode_casefold.h", 61 | "re2/unicode_groups.h", 62 | "re2/walker-inl.h", 63 | ], 64 | linkopts = ["-lm"], # C++ random pulls in math.h 65 | deps = [":util"], 66 | ) 67 | 68 | cc_library( 69 | name = "testutil", 70 | srcs = glob( 71 | [ 72 | "re2/testing/*.cc", 73 | "util/pcre.cc", 74 | "util/random.cc", 75 | "util/thread.cc", 76 | ], 77 | exclude = [ 78 | "re2/testing/*_test.cc", 79 | "re2/testing/*_benchmark.cc", 80 | ], 81 | ), 82 | deps = [ 83 | ":re2", 84 | ":util", 85 | ], 86 | ) 87 | 88 | cc_library( 89 | name = "bench-main", 90 | srcs = [ 91 | "util/benchmark.cc", 92 | ], 93 | deps = [ 94 | ":testutil", 95 | ], 96 | ) 97 | 98 | cc_library( 99 | name = "test-main", 100 | srcs = [ 101 | "util/test.cc", 102 | ], 103 | deps = [ 104 | ":testutil", 105 | ], 106 | ) 107 | 108 | [cc_test( 109 | name = f[:-3], 110 | srcs = [ 111 | f, 112 | ], 113 | linkopts = [ 114 | "-lstdc++", 115 | "-lpthread", 116 | ], 117 | deps = [ 118 | ":re2", 119 | ":test-main", 120 | ], 121 | ) for f in glob(["re2/testing/*_test.cc"])] 122 | 123 | [cc_test( 124 | name = f[:-3], 125 | srcs = [ 126 | f, 127 | ], 128 | linkopts = [ 129 | "-lstdc++", 130 | "-lpthread", 131 | ], 132 | deps = [ 133 | ":bench-main", 134 | ":re2", 135 | ], 136 | ) for f in glob(["re2/testing/*_benchmark.cc"])] 137 | -------------------------------------------------------------------------------- /android-prebuilts/gen-crosstool.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright 2014 Google Inc. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | preamble = """major_version: "local" 19 | minor_version: "" 20 | default_target_cpu: "same_as_host" 21 | default_toolchain { 22 | cpu: "k8" 23 | toolchain_identifier: "x86_64-linux-glibc2.7-4.6" 24 | } 25 | """ 26 | 27 | template = """ 28 | 29 | default_toolchain { 30 | cpu: "%(cpu)s" 31 | toolchain_identifier: "%(toolchain_id)s" 32 | } 33 | # Toolchain taken from android AOSP prebuilts, see 34 | toolchain { 35 | # this should be more specific 36 | abi_version: "local" 37 | abi_libc_version: "local" 38 | 39 | builtin_sysroot: "android-prebuilts/gcc/%(host)s/%(toolchain_id)s/sysroot" 40 | compiler: "gcc" 41 | host_system_name: "local" 42 | needsPic: true 43 | supports_gold_linker: false 44 | supports_incremental_linker: false 45 | supports_fission: false 46 | supports_interface_shared_objects: false 47 | supports_normalizing_ar: false 48 | supports_start_end_lib: false 49 | supports_thin_archives: false 50 | target_libc: "local" 51 | 52 | target_cpu: "%(cpu)s" 53 | target_system_name: "%(toolchain_id)s" 54 | toolchain_identifier: "%(toolchain_id)s" 55 | 56 | tool_path { 57 | name: "ar" 58 | path: "gcc/%(host)s/%(toolchain_id)s/bin/%(bin_prefix)sar" 59 | } 60 | 61 | tool_path { name: "compat-ld" 62 | path: "gcc/%(host)s/%(toolchain_id)s/bin/%(bin_prefix)sld" 63 | } 64 | tool_path { name: "cpp" 65 | path: "gcc/%(host)s/%(toolchain_id)s/bin/%(bin_prefix)scpp" 66 | } 67 | tool_path { name: "dwp" path: "/usr/bin/dwp" } 68 | tool_path { name: "gcc" 69 | path: "gcc/%(host)s/%(toolchain_id)s/bin/%(bin_prefix)sgcc" 70 | } 71 | cxx_flag: "-std=c++0x" 72 | compilation_mode_flags { 73 | mode: FASTBUILD 74 | } 75 | compilation_mode_flags { 76 | mode: DBG 77 | } 78 | compilation_mode_flags { 79 | mode: COVERAGE 80 | } 81 | compilation_mode_flags { 82 | mode: OPT 83 | } 84 | 85 | tool_path { 86 | name: "gcov" 87 | path: "/usr/bin/gcov" 88 | } 89 | tool_path { name: "ld" 90 | path: "gcc/%(host)s/%(toolchain_id)s/bin/%(bin_prefix)sld" 91 | } 92 | linking_mode_flags { 93 | mode: FULLY_STATIC 94 | } 95 | tool_path { name: "nm" 96 | path: "gcc/%(host)s/%(toolchain_id)s/bin/%(bin_prefix)snm" 97 | } 98 | tool_path { name: "objcopy" 99 | path: "gcc/%(host)s/%(toolchain_id)s/bin/%(bin_prefix)sobjcopy" 100 | } 101 | objcopy_embed_flag: "-I" 102 | objcopy_embed_flag: "binary" 103 | tool_path { name: "objdump" 104 | path: "gcc/%(host)s/%(toolchain_id)s/bin/%(bin_prefix)sobjdump" 105 | } 106 | tool_path { name: "strip" 107 | path: "gcc/%(host)s/%(toolchain_id)s/bin/%(bin_prefix)sstrip" 108 | } 109 | linking_mode_flags { 110 | mode: MOSTLY_STATIC 111 | } 112 | linking_mode_flags { 113 | mode: DYNAMIC 114 | } 115 | 116 | cxx_builtin_include_directory: "gcc/%(host)s/%(toolchain_id)s/" 117 | cxx_builtin_include_directory: "gcc/%(host)s/%(toolchain_id)s/" 118 | cxx_builtin_include_directory: "gcc/linux-x86/x86_64-linux-glibc2.7-4.6/lib/gcc/x86_64-linux/4.6.x-google/include" 119 | cxx_builtin_include_directory: "%%sysroot%%/usr/include" 120 | 121 | 122 | unfiltered_cxx_flag: "-no-canonical-prefixes" 123 | 124 | linker_flag: "-no-canonical-prefixes" 125 | 126 | # add furthor system include directories using either 127 | # cxx_builtin_include_directory: "DIRECTORY" 128 | # or 129 | # unfiltered_cxx_flag: "-isystemtools/cpp/gcc/something" 130 | 131 | linker_flag: "-lstdc++" 132 | linker_flag: "-lm" 133 | linker_flag: "-lpthread" 134 | } 135 | """ 136 | 137 | cpus = { 138 | "x86_64": "linux-x86/x86_64-linux-glibc2.7-4.6", 139 | "i686": "linux-x86/i686-linux-glibc2.7-4.6", 140 | # "darwin-i686": "darwin-x86/i686-apple-darwin-4.2.1", 141 | "mingw-x86_64": "linux-x86/x86_64-w64-mingw32-4.8", 142 | } 143 | 144 | out = preamble 145 | 146 | for cpu, path in cpus.items(): 147 | rest = path 148 | host = rest[:rest.index('/')] 149 | rest = rest[rest.index('/')+1:] 150 | toolchain_id = rest 151 | 152 | bin_prefix = { 153 | "x86_64": "x86_64-linux-", 154 | "i686": "i686-linux-", 155 | # "darwin-i686": "i686-apple-darwin10-", 156 | "mingw-x86_64": "x86_64-w64-mingw32-", 157 | }[cpu] 158 | 159 | out += template % locals() 160 | 161 | open('CROSSTOOL', 'w').write(out) 162 | -------------------------------------------------------------------------------- /android-ndk/CROSSTOOL: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2015 Google Inc. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | major_version: "local" 17 | minor_version: "" 18 | default_target_cpu: "armeabi-v7a" 19 | default_toolchain { 20 | cpu: "armeabi-v7a" 21 | toolchain_identifier: "arm-linux-androideabi-4.8" 22 | } 23 | 24 | # ARM 32 bits on linux-x86_64. 25 | toolchain { 26 | 27 | # this should be more specific 28 | abi_version: "local" 29 | abi_libc_version: "local" 30 | 31 | builtin_sysroot: "platforms/android-19/arch-arm/" 32 | 33 | # This should contain a BUILD file, defining 'compile' and 'link' filegroups. 34 | default_grte_top: "//android-ndk/platforms/android-19/arch-arm" 35 | 36 | compiler: "gcc" 37 | host_system_name: "local" 38 | needsPic: true 39 | supports_gold_linker: false 40 | supports_incremental_linker: false 41 | supports_fission: false 42 | supports_interface_shared_objects: false 43 | supports_normalizing_ar: false 44 | supports_start_end_lib: false 45 | supports_thin_archives: false 46 | target_libc: "local" 47 | 48 | target_cpu: "armeabi-v7a" 49 | target_system_name: "arm-linux-androideabi-4.8" 50 | toolchain_identifier: "arm-linux-androideabi-4.8" 51 | 52 | tool_path { name: "ar" 53 | path: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar" 54 | } 55 | tool_path { name: "compat-ld" 56 | path: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld" 57 | } 58 | tool_path { name: "cpp" 59 | path: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp" 60 | } 61 | tool_path { name: "dwp" 62 | path: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-dwp" 63 | } 64 | tool_path { name: "gcc" 65 | path: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc" 66 | } 67 | tool_path { name: "gcov" 68 | path: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcov" 69 | } 70 | tool_path { name: "ld" 71 | path: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld" 72 | } 73 | tool_path { name: "nm" 74 | path: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm" 75 | } 76 | tool_path { name: "objcopy" 77 | path: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objcopy" 78 | } 79 | tool_path { name: "strip" 80 | path: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip" 81 | } 82 | tool_path { name: "objdump" 83 | path: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objdump" 84 | } 85 | objcopy_embed_flag: "-I" 86 | 87 | cxx_flag: "-std=c++0x" 88 | compilation_mode_flags { 89 | mode: FASTBUILD 90 | } 91 | compilation_mode_flags { 92 | mode: DBG 93 | } 94 | compilation_mode_flags { 95 | mode: COVERAGE 96 | } 97 | compilation_mode_flags { 98 | mode: OPT 99 | } 100 | 101 | cxx_flag: "-std=gnu++11" 102 | 103 | cxx_builtin_include_directory: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/include" 104 | cxx_builtin_include_directory: "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/include-fixed" 105 | 106 | unfiltered_cxx_flag: "-isystem%sysroot%/usr/include" 107 | unfiltered_cxx_flag: "-isystemandroid-ndk/sources/cxx-stl/gnu-libstdc++/4.8/include" 108 | unfiltered_cxx_flag: "-isystemandroid-ndk/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include" 109 | 110 | unfiltered_cxx_flag: "-isystem" 111 | unfiltered_cxx_flag: "android-ndk/sources/cxx-stl/stlport/stlport" 112 | unfiltered_cxx_flag: "-isystem" 113 | unfiltered_cxx_flag: "android-ndk/sources/cxx-stl/gabi++/include" 114 | 115 | linking_mode_flags { 116 | mode: FULLY_STATIC 117 | } 118 | objcopy_embed_flag: "-I" 119 | objcopy_embed_flag: "binary" 120 | linking_mode_flags { 121 | mode: MOSTLY_STATIC 122 | } 123 | linking_mode_flags { 124 | mode: DYNAMIC 125 | } 126 | 127 | unfiltered_cxx_flag: "-fno-canonical-system-headers" 128 | unfiltered_cxx_flag: "-no-canonical-prefixes" 129 | 130 | linker_flag: "-no-canonical-prefixes" 131 | 132 | compiler_flag: "-fPIE" 133 | compiler_flag: "-DANDROID" 134 | compiler_flag: "-g" 135 | 136 | linker_flag: "-fPIE" 137 | linker_flag: "-pie" 138 | 139 | linker_flag: "-Landroid-ndk/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/" 140 | linker_flag: "-lgnustl_static" 141 | linker_flag: "-lsupc++" 142 | linker_flag: "-lc" 143 | linker_flag: "-lm" 144 | } 145 | -------------------------------------------------------------------------------- /protobuf-2.5.0/BUILD.src.google.protobuf: -------------------------------------------------------------------------------- 1 | # -*- Python -*- 2 | 3 | # 4 | # Copyright 2014 Google Inc. All Rights Reserved. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | cc_library( 20 | name = "libprotobuf-lite", 21 | srcs = [ 22 | "extension_set.cc", 23 | "generated_message_util.cc", 24 | "io/coded_stream.cc", 25 | "io/zero_copy_stream.cc", 26 | "io/zero_copy_stream_impl_lite.cc", 27 | "message_lite.cc", 28 | "repeated_field.cc", 29 | "stubs/atomicops_internals_x86_gcc.cc", 30 | "stubs/atomicops_internals_x86_msvc.cc", 31 | "stubs/common.cc", 32 | "stubs/once.cc", 33 | "stubs/stringprintf.cc", 34 | "wire_format_lite.cc", 35 | ], 36 | hdrs = [ 37 | "io/coded_stream_inl.h", 38 | "stubs/hash.h", 39 | "stubs/stringprintf.h", 40 | ], 41 | includes = [ 42 | "../..", 43 | ], 44 | deps = [ 45 | "//:config", 46 | ], 47 | ) 48 | 49 | cc_library( 50 | name = "libprotobuf", 51 | srcs = [ 52 | "compiler/importer.cc", 53 | "compiler/parser.cc", 54 | "descriptor.cc", 55 | "descriptor.pb.cc", 56 | "descriptor_database.cc", 57 | "dynamic_message.cc", 58 | "extension_set_heavy.cc", 59 | "generated_message_reflection.cc", 60 | "io/gzip_stream.cc", 61 | "io/printer.cc", 62 | "io/tokenizer.cc", 63 | "io/zero_copy_stream_impl.cc", 64 | "message.cc", 65 | "reflection_ops.cc", 66 | "service.cc", 67 | "stubs/structurally_valid.cc", 68 | "stubs/strutil.cc", 69 | "stubs/substitute.cc", 70 | "text_format.cc", 71 | "unknown_field_set.cc", 72 | "wire_format.cc", 73 | ], 74 | hdrs = [ 75 | "stubs/strutil.h", 76 | "stubs/substitute.h", 77 | ], 78 | deps = [":libprotobuf-lite"], 79 | ) 80 | 81 | cc_library( 82 | name = "libprotoc", 83 | srcs = [ 84 | "compiler/code_generator.cc", 85 | "compiler/command_line_interface.cc", 86 | "compiler/cpp/cpp_enum.cc", 87 | "compiler/cpp/cpp_enum_field.cc", 88 | "compiler/cpp/cpp_extension.cc", 89 | "compiler/cpp/cpp_field.cc", 90 | "compiler/cpp/cpp_file.cc", 91 | "compiler/cpp/cpp_generator.cc", 92 | "compiler/cpp/cpp_helpers.cc", 93 | "compiler/cpp/cpp_message.cc", 94 | "compiler/cpp/cpp_message_field.cc", 95 | "compiler/cpp/cpp_primitive_field.cc", 96 | "compiler/cpp/cpp_service.cc", 97 | "compiler/cpp/cpp_string_field.cc", 98 | "compiler/java/java_doc_comment.cc", 99 | "compiler/java/java_enum.cc", 100 | "compiler/java/java_enum_field.cc", 101 | "compiler/java/java_extension.cc", 102 | "compiler/java/java_field.cc", 103 | "compiler/java/java_file.cc", 104 | "compiler/java/java_generator.cc", 105 | "compiler/java/java_helpers.cc", 106 | "compiler/java/java_message.cc", 107 | "compiler/java/java_message_field.cc", 108 | "compiler/java/java_primitive_field.cc", 109 | "compiler/java/java_service.cc", 110 | "compiler/java/java_string_field.cc", 111 | "compiler/plugin.cc", 112 | "compiler/plugin.pb.cc", 113 | "compiler/python/python_generator.cc", 114 | "compiler/subprocess.cc", 115 | "compiler/zip_writer.cc", 116 | ], 117 | hdrs = [ 118 | "compiler/cpp/cpp_enum.h", 119 | "compiler/cpp/cpp_enum_field.h", 120 | "compiler/cpp/cpp_extension.h", 121 | "compiler/cpp/cpp_field.h", 122 | "compiler/cpp/cpp_file.h", 123 | "compiler/cpp/cpp_helpers.h", 124 | "compiler/cpp/cpp_message.h", 125 | "compiler/cpp/cpp_message_field.h", 126 | "compiler/cpp/cpp_options.h", 127 | "compiler/cpp/cpp_primitive_field.h", 128 | "compiler/cpp/cpp_service.h", 129 | "compiler/cpp/cpp_string_field.h", 130 | "compiler/java/java_doc_comment.h", 131 | "compiler/java/java_enum.h", 132 | "compiler/java/java_enum_field.h", 133 | "compiler/java/java_extension.h", 134 | "compiler/java/java_field.h", 135 | "compiler/java/java_file.h", 136 | "compiler/java/java_helpers.h", 137 | "compiler/java/java_message.h", 138 | "compiler/java/java_message_field.h", 139 | "compiler/java/java_primitive_field.h", 140 | "compiler/java/java_service.h", 141 | "compiler/java/java_string_field.h", 142 | "compiler/subprocess.h", 143 | "compiler/zip_writer.h", 144 | ], 145 | linkopts = ["-lm"], 146 | deps = [":libprotobuf"], 147 | ) 148 | 149 | cc_binary( 150 | name = "protoc", 151 | srcs = ["compiler/main.cc"], 152 | deps = [":libprotoc"], 153 | ) 154 | 155 | # This rule is necessary for Protobuf v3.0 156 | genrule( 157 | name = "pbconfig_h", 158 | srcs = [ 159 | "//:config.h", 160 | "//:config.h.include", 161 | ], 162 | outs = ["stubs/pbconfig.h"], 163 | cmd = "(echo \"// Note: Google Protobuf internal only. Do NOT include.\" && " + 164 | "(cat $(location //:config.h) | grep -f $(location //:config.h.include) | " + 165 | "sed 's,#define , #define GOOGLE_PROTOBUF_,')) > $@", 166 | ) 167 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------