Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | build_cpp() { |
| 4 | ./autogen.sh |
| 5 | ./configure |
| 6 | make -j2 |
| 7 | make check -j2 |
| 8 | cd conformance && make test_cpp && cd .. |
| 9 | } |
| 10 | |
| 11 | build_cpp_distcheck() { |
| 12 | ./autogen.sh |
| 13 | ./configure |
| 14 | make distcheck -j2 |
| 15 | } |
| 16 | |
| 17 | use_java() { |
| 18 | if [ `uname` != "Linux" ]; then |
| 19 | # It's nontrivial to programmatically install a new JDK from the command |
| 20 | # line on OS X, so we rely on testing on Linux for Java code. |
| 21 | echo "Java not tested on OS X." |
| 22 | exit 0 # success |
| 23 | fi |
| 24 | version=$1 |
| 25 | case "$version" in |
| 26 | jdk6) |
| 27 | sudo apt-get install openjdk-6-jdk |
| 28 | export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH |
| 29 | ;; |
| 30 | jdk7) |
| 31 | sudo apt-get install openjdk-7-jdk |
| 32 | export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH |
| 33 | ;; |
| 34 | oracle7) |
| 35 | sudo apt-get install python-software-properties # for apt-add-repository |
| 36 | echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \ |
| 37 | sudo debconf-set-selections |
| 38 | yes | sudo apt-add-repository ppa:webupd8team/java |
| 39 | yes | sudo apt-get install oracle-java7-installer |
| 40 | export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH |
| 41 | ;; |
| 42 | esac |
| 43 | |
| 44 | which java |
| 45 | java -version |
| 46 | } |
| 47 | |
| 48 | build_java() { |
| 49 | # Java build needs `protoc`. |
| 50 | ./autogen.sh |
| 51 | ./configure |
| 52 | make -j2 |
| 53 | cd java && mvn test && cd .. |
| 54 | cd conformance && make test_java && cd .. |
| 55 | } |
| 56 | |
| 57 | build_javanano() { |
| 58 | # Java build needs `protoc`. |
| 59 | ./autogen.sh |
| 60 | ./configure |
| 61 | make -j2 |
| 62 | cd javanano && mvn test && cd .. |
| 63 | } |
| 64 | |
| 65 | build_java_jdk6() { |
| 66 | use_java jdk6 |
| 67 | build_java |
| 68 | } |
| 69 | build_java_jdk7() { |
| 70 | use_java jdk7 |
| 71 | build_java |
| 72 | } |
| 73 | build_java_oracle7() { |
| 74 | use_java oracle7 |
| 75 | build_java |
| 76 | } |
| 77 | |
| 78 | build_javanano_jdk6() { |
| 79 | use_java jdk6 |
| 80 | build_javanano |
| 81 | } |
| 82 | build_javanano_jdk7() { |
| 83 | use_java jdk7 |
| 84 | build_javanano |
| 85 | } |
| 86 | build_javanano_oracle7() { |
| 87 | use_java oracle7 |
| 88 | build_javanano |
| 89 | } |
| 90 | |
| 91 | build_python() { |
| 92 | ./autogen.sh |
| 93 | ./configure |
| 94 | make -j2 |
| 95 | cd python |
| 96 | python setup.py build |
| 97 | python setup.py test |
| 98 | cd .. |
| 99 | } |
| 100 | |
| 101 | build_python_cpp() { |
| 102 | ./autogen.sh |
| 103 | ./configure |
| 104 | make -j2 |
| 105 | export LD_LIBRARY_PATH=../src/.libs |
| 106 | cd python |
| 107 | python setup.py build --cpp_implementation |
| 108 | python setup.py test --cpp_implementation |
| 109 | cd .. |
| 110 | } |
| 111 | |
| 112 | build_ruby19() { |
| 113 | cd ruby && bash travis-test.sh ruby-1.9 && cd .. |
| 114 | } |
| 115 | build_ruby20() { |
| 116 | cd ruby && bash travis-test.sh ruby-2.0 && cd .. |
| 117 | } |
| 118 | build_ruby21() { |
| 119 | cd ruby && bash travis-test.sh ruby-2.1 && cd .. |
| 120 | } |
| 121 | build_ruby22() { |
| 122 | cd ruby && bash travis-test.sh ruby-2.2 && cd .. |
| 123 | } |
| 124 | build_jruby() { |
| 125 | cd ruby && bash travis-test.sh jruby && cd .. |
| 126 | } |
| 127 | |
| 128 | # -------- main -------- |
| 129 | |
| 130 | if [ "$#" -ne 1 ]; then |
| 131 | echo " |
| 132 | Usage: $0 { cpp | |
| 133 | java_jdk6 | |
| 134 | java_jdk7 | |
| 135 | java_oracle7 | |
| 136 | javanano_jdk6 | |
| 137 | javanano_jdk7 | |
| 138 | javanano_oracle7 | |
| 139 | python | |
| 140 | python_cpp | |
| 141 | ruby_19 | |
| 142 | ruby_20 | |
| 143 | ruby_21 | |
| 144 | ruby_22 | |
| 145 | jruby } |
| 146 | " |
| 147 | exit 1 |
| 148 | fi |
| 149 | |
| 150 | set -e # exit immediately on error |
| 151 | set -x # display all commands |
| 152 | eval "build_$1" |