#!/bin/bash # Builds protoc executable into target/protoc.exe; optionally build protoc # plugins into target/protoc-gen-*.exe # To be run from Maven. # Usage: build-protoc.sh # and are ${os.detected.name} and ${os.detected.arch} from os-maven-plugin # can be "protoc" or "protoc-gen-javalite" global OS := $1 global ARCH := $2 global MAKE_TARGET := $3 if [[ $# < 3 ]] { echo "No arguments provided. This script is intended to be run from Maven." exit 1 } matchstr $MAKE_TARGET { protoc-gen-javalite { } protoc { } * { echo "Target ""$TARGET"" invalid." exit 1 } } # Under Cygwin, bash doesn't have these in PATH when called from Maven which # runs in Windows version of Java. export PATH="/bin:/usr/bin:$PATH" ############################################################################ # Helper functions ############################################################################ global E_PARAM_ERR := '98' global E_ASSERT_FAILED := '99' # Usage: proc fail { echo "ERROR: $1" echo exit $E_ASSERT_FAILED } # Usage: assertEq VAL1 VAL2 $LINENO proc assertEq { global lineno := $3 if test -z $lineno { echo "lineno not given" exit $E_PARAM_ERR } if [[ "$1" != "$2" ]] { echo "Assertion failed: \"$1\" == \"$2\"" echo "File \"$0\", line $lineno" # Give name of file and line number. exit $E_ASSERT_FAILED } } # Checks the artifact is for the expected architecture # Usage: checkArch proc checkArch { echo echo "Checking file format ..." if [[ "$OS" == windows || "$OS" == linux ]] { global format := $[objdump -f $1 | grep -o "file format .*$" | grep -o "[^ ]*$] echo Format=$format if [[ "$OS" == linux ]] { if [[ "$ARCH" == x86_32 ]] { assertEq $format "elf32-i386" $LINENO } elif [[ "$ARCH" == x86_64 ]] { assertEq $format "elf64-x86-64" $LINENO } else { fail "Unsupported arch: $ARCH" } } else { # $OS == windows if [[ "$ARCH" == x86_32 ]] { assertEq $format "pei-i386" $LINENO } elif [[ "$ARCH" == x86_64 ]] { assertEq $format "pei-x86-64" $LINENO } else { fail "Unsupported arch: $ARCH" } } } elif [[ "$OS" == osx ]] { global format := $[file -b $1 | grep -o "[^ ]*$] echo Format=$format if [[ "$ARCH" == x86_32 ]] { assertEq $format "i386" $LINENO } elif [[ "$ARCH" == x86_64 ]] { assertEq $format "x86_64" $LINENO } else { fail "Unsupported arch: $ARCH" } } else { fail "Unsupported system: $OS" } echo } # Checks the dependencies of the artifact. Artifacts should only depend on # system libraries. # Usage: checkDependencies proc checkDependencies { if [[ "$OS" == windows ]] { global dump_cmd := "'objdump -x '"$1"' | fgrep "DLL Name""' global white_list := '"KERNEL32\.dll\|msvcrt\.dll'" } elif [[ "$OS" == linux ]] { global dump_cmd := "'ldd '"$1"" if [[ "$ARCH" == x86_32 ]] { global white_list := '"linux-gate\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux\.so\.2'" } elif [[ "$ARCH" == x86_64 ]] { global white_list := '"linux-vdso\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux-x86-64\.so\.2'" } } elif [[ "$OS" == osx ]] { global dump_cmd := "'otool -L '"$1"' | fgrep dylib"' global white_list := '"libz\.1\.dylib\|libstdc++\.6\.dylib\|libSystem\.B\.dylib'" } if [[ -z "$white_list" || -z "$dump_cmd" ]] { fail "Unsupported platform $OS-$ARCH." } echo "Checking for expected dependencies ..." eval $dump_cmd | grep -i $white_list || fail "doesn't show any expected dependencies" echo "Checking for unexpected dependencies ..." eval $dump_cmd | grep -i -v $white_list global ret := $Status if [[ $ret == 0 ]] { fail "found unexpected dependencies (listed above)." } elif [[ $ret != 1 ]] { fail "Error when checking dependencies." } # grep returns 1 when "not found", which is what we expect echo "Dependencies look good." echo } ############################################################################ echo "Building protoc, OS=$OS ARCH=$ARCH TARGET=$TARGET" # Nested double quotes are unintuitive, but it works. cd $[dirname $0] global WORKING_DIR := $[pwd] global CONFIGURE_ARGS := '"--disable-shared'" global TARGET_FILE := "target/$MAKE_TARGET.exe" if [[ "$OS" == windows ]] { global MAKE_TARGET := ""$(MAKE_TARGET).exe"" } # Override the default value set in configure.ac that has '-g' which produces # huge binary. global CXXFLAGS := '"-DNDEBUG'" global LDFLAGS := ''"" if [[ "$(uname)" == CYGWIN* ]] { assertEq $OS windows $LINENO # Use mingw32 compilers because executables produced by Cygwin compiler # always have dependency on Cygwin DLL. if [[ "$ARCH" == x86_64 ]] { global CONFIGURE_ARGS := ""$CONFIGURE_ARGS --host=x86_64-w64-mingw32"" } elif [[ "$ARCH" == x86_32 ]] { global CONFIGURE_ARGS := ""$CONFIGURE_ARGS --host=i686-pc-mingw32"" } else { fail "Unsupported arch by CYGWIN: $ARCH" } } elif [[ "$(uname)" == MINGW32* ]] { assertEq $OS windows $LINENO assertEq $ARCH x86_32 $LINENO } elif [[ "$(uname)" == MINGW64* ]] { assertEq $OS windows $LINENO assertEq $ARCH x86_64 $LINENO } elif [[ "$(uname)" == Linux* ]] { if [[ "$OS" == linux ]] { if [[ "$ARCH" == x86_64 ]] { global CXXFLAGS := ""$CXXFLAGS -m64"" } elif [[ "$ARCH" == x86_32 ]] { global CXXFLAGS := ""$CXXFLAGS -m32"" } else { fail "Unsupported arch: $ARCH" } } elif [[ "$OS" == windows ]] { # Cross-compilation for Windows # TODO(zhangkun83) MinGW 64 always adds dependency on libwinpthread-1.dll, # which is undesirable for repository deployment. global CONFIGURE_ARGS := $CONFIGURE_ARGS if [[ "$ARCH" == x86_64 ]] { global CONFIGURE_ARGS := ""$CONFIGURE_ARGS --host=x86_64-w64-mingw32"" } elif [[ "$ARCH" == x86_32 ]] { global CONFIGURE_ARGS := ""$CONFIGURE_ARGS --host=i686-w64-mingw32"" } else { fail "Unsupported arch: $ARCH" } } else { fail "Cannot build $OS on $[uname]" } } elif [[ "$(uname)" == Darwin* ]] { assertEq $OS osx $LINENO # Make the binary compatible with OSX 10.7 and later global CXXFLAGS := ""$CXXFLAGS -mmacosx-version-min=10.7"" if [[ "$ARCH" == x86_64 ]] { global CXXFLAGS := ""$CXXFLAGS -m64"" } elif [[ "$ARCH" == x86_32 ]] { global CXXFLAGS := ""$CXXFLAGS -m32"" } else { fail "Unsupported arch: $ARCH" } } else { fail "Unsupported system: $[uname]" } # Statically link libgcc and libstdc++. # -s to produce stripped binary. # And they don't work under Mac. if [[ "$OS" != osx ]] { global LDFLAGS := ""$LDFLAGS -static-libgcc -static-libstdc++ -s"" } export CXXFLAGS LDFLAGS cd "$WORKING_DIR"/.. && ./configure $CONFIGURE_ARGS && cd src && make clean && make $MAKE_TARGET && cd $WORKING_DIR && mkdir -p target && cp ../src/$MAKE_TARGET $TARGET_FILE || exit 1 if [[ "$OS" == osx ]] { # Since Mac linker doesn't accept "-s", we need to run strip strip $TARGET_FILE || exit 1 } checkArch $TARGET_FILE && checkDependencies $TARGET_FILE (CommandList children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:OS) op:Equal rhs:{($ VSub_Number "$1")} spids:[22])] spids: [22] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ARCH) op:Equal rhs:{($ VSub_Number "$2")} spids:[25])] spids: [25] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:MAKE_TARGET) op: Equal rhs: {($ VSub_Number "$3")} spids: [28] ) ] spids: [28] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:Redir_Less left:{($ VSub_Pound "$#")} right:{(3)}) ) terminator: ) ] action: [ (C {(echo)} {(DQ ("No arguments provided. This script is intended to be run from Maven."))}) (C {(exit)} {(1)}) ] spids: [-1 45] ) ] spids: [-1 59] ) (Case to_match: {($ VSub_Name "$MAKE_TARGET")} arms: [ (case_arm pat_list:[{(protoc-gen-javalite)}] spids:[697073-1]) (case_arm pat_list:[{(protoc)}] spids:[767780-1]) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (C {(echo)} {(DQ ("Target ")) (DQ ($ VSub_Name "$TARGET")) (DQ (" invalid."))}) (C {(exit)} {(1)}) ] spids: [83 84 -1 104] ) ] spids: [62 66 104] ) (C {(export)} {(Lit_VarLike "PATH=") (DQ ("/bin:/usr/bin:") ($ VSub_Name "$PATH"))}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:E_PARAM_ERR) op:Equal rhs:{(98)} spids:[131])] spids: [131] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:E_ASSERT_FAILED) op:Equal rhs:{(99)} spids:[134])] spids: [134] ) (FuncDef name: fail body: (BraceGroup children: [ (C {(echo)} {(DQ ("ERROR: ") ($ VSub_Number "$1"))}) (C {(echo)}) (C {(exit)} {($ VSub_Name "$E_ASSERT_FAILED")}) ] spids: [145] ) spids: [141 144] ) (FuncDef name: assertEq body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:lineno) op: Equal rhs: {($ VSub_Number "$3")} spids: [177] ) ] spids: [177] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$lineno"))} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(echo)} {(DQ ("lineno not given"))}) (C {(exit)} {($ VSub_Name "$E_PARAM_ERR")}) ] spids: [-1 194] ) ] spids: [-1 209] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {(DQ ($ VSub_Number "$1"))} right: {(DQ ($ VSub_Number "$2"))} ) ) terminator: ) ] action: [ (C {(echo)} { (DQ ("Assertion failed: ") (EscapedLiteralPart token:) ($ VSub_Number "$1") (EscapedLiteralPart token:) (" == ") (EscapedLiteralPart token: ) ($ VSub_Number "$2") (EscapedLiteralPart token:) ) } ) (C {(echo)} { (DQ ("File ") (EscapedLiteralPart token:) ($ VSub_Number "$0") (EscapedLiteralPart token:) (", line ") ($ VSub_Name "$lineno") ) } ) (C {(exit)} {($ VSub_Name "$E_ASSERT_FAILED")}) ] spids: [-1 230] ) ] spids: [-1 267] ) ] spids: [174] ) spids: [169 173] ) (FuncDef name: checkArch body: (BraceGroup children: [ (C {(echo)}) (C {(echo)} {(DQ ("Checking file format ..."))}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(windows)} ) right: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(linux)} ) ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:format) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(objdump)} {(-f)} {(DQ ($ VSub_Number "$1"))}) (C {(grep)} {(-o)} {(DQ ("file format .*") (Lit_Other "$"))}) (C {(grep)} {(-o)} {(DQ ("[^ ]*") (Lit_Other "$"))}) ] negated: False ) ] ) left_token: spids: [326 356] ) ) } spids: [324] ) ] spids: [324] ) (C {(echo)} {(Lit_VarLike "Format=") ($ VSub_Name "$format")}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(linux)} ) ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_32)} ) ) terminator: ) ] action: [ (C {(assertEq)} {($ VSub_Name "$format")} {(DQ (elf32-i386))} {($ VSub_Name "$LINENO")} ) ] spids: [-1 399] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_64)} ) ) terminator: ) ] action: [ (C {(assertEq)} {($ VSub_Name "$format")} {(DQ (elf64-x86-64))} {($ VSub_Name "$LINENO")} ) ] spids: [413 428] ) ] else_action: [ (C {(fail)} {(DQ ("Unsupported arch: ") ($ VSub_Name "$ARCH"))}) ] spids: [442 453] ) ] spids: [-1 381] ) ] else_action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_32)} ) ) terminator: ) ] action: [ (C {(assertEq)} {($ VSub_Name "$format")} {(DQ (pei-i386))} {($ VSub_Name "$LINENO")} ) ] spids: [-1 478] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_64)} ) ) terminator: ) ] action: [ (C {(assertEq)} {($ VSub_Name "$format")} {(DQ (pei-x86-64))} {($ VSub_Name "$LINENO")} ) ] spids: [492 507] ) ] else_action: [(C {(fail)} {(DQ ("Unsupported arch: ") ($ VSub_Name "$ARCH"))})] spids: [521 532] ) ] spids: [456 535] ) ] spids: [-1 321] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(osx)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:format) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(file)} {(-b)} {(DQ ($ VSub_Number "$1"))}) (C {(grep)} {(-o)} {(DQ ("[^ ]*") (Lit_Other "$"))}) ] negated: False ) ] ) left_token: spids: [558 577] ) ) } spids: [556] ) ] spids: [556] ) (C {(echo)} {(Lit_VarLike "Format=") ($ VSub_Name "$format")}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_32)} ) ) terminator: ) ] action: [ (C {(assertEq)} {($ VSub_Name "$format")} {(DQ (i386))} {($ VSub_Name "$LINENO")} ) ] spids: [-1 602] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_64)} ) ) terminator: ) ] action: [ (C {(assertEq)} {($ VSub_Name "$format")} {(DQ (x86_64))} {($ VSub_Name "$LINENO")} ) ] spids: [616 631] ) ] else_action: [(C {(fail)} {(DQ ("Unsupported arch: ") ($ VSub_Name "$ARCH"))})] spids: [645 656] ) ] spids: [538 553] ) ] else_action: [(C {(fail)} {(DQ ("Unsupported system: ") ($ VSub_Name "$OS"))})] spids: [659 670] ) (C {(echo)}) ] spids: [283] ) spids: [278 282] ) (FuncDef name: checkDependencies body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(windows)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dump_cmd) op: Equal rhs: {(SQ <"objdump -x ">) (DQ ($ VSub_Number "$1")) (SQ <" | fgrep \"DLL Name\"">) } spids: [713] ) ] spids: [713] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:white_list) op: Equal rhs: { (DQ (KERNEL32) (EscapedLiteralPart token:) (dll) (EscapedLiteralPart token: ) (msvcrt) (EscapedLiteralPart token:) (dll) ) } spids: [725] ) ] spids: [725] ) ] spids: [-1 710] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(linux)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dump_cmd) op: Equal rhs: {(SQ <"ldd ">) (DQ ($ VSub_Number "$1"))} spids: [755] ) ] spids: [755] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_32)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:white_list) op: Equal rhs: { (DQ (linux-gate) (EscapedLiteralPart token: ) (so) (EscapedLiteralPart token:) (1) (EscapedLiteralPart token: ) (libpthread) (EscapedLiteralPart token:) (so) (EscapedLiteralPart token: ) (0) (EscapedLiteralPart token:) (libm) (EscapedLiteralPart token: ) (so) (EscapedLiteralPart token:) (6) (EscapedLiteralPart token: ) (libc) (EscapedLiteralPart token:) (so) (EscapedLiteralPart token: ) (6) (EscapedLiteralPart token:) (ld-linux) (EscapedLiteralPart token: ) (so) (EscapedLiteralPart token:) (2) ) } spids: [782] ) ] spids: [782] ) ] spids: [-1 779] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_64)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:white_list) op: Equal rhs: { (DQ (linux-vdso) (EscapedLiteralPart token: ) (so) (EscapedLiteralPart token:) (1) (EscapedLiteralPart token: ) (libpthread) (EscapedLiteralPart token:) (so) (EscapedLiteralPart token: ) (0) (EscapedLiteralPart token:) (libm) (EscapedLiteralPart token: ) (so) (EscapedLiteralPart token:) (6) (EscapedLiteralPart token: ) (libc) (EscapedLiteralPart token:) (so) (EscapedLiteralPart token: ) (6) (EscapedLiteralPart token:) (ld-linux-x86-64) (EscapedLiteralPart token: ) (so) (EscapedLiteralPart token:) (2) ) } spids: [834] ) ] spids: [834] ) ] spids: [816 831] ) ] spids: [-1 868] ) ] spids: [737 752] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(osx)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dump_cmd) op: Equal rhs: {(SQ <"otool -L ">) (DQ ($ VSub_Number "$1")) (SQ <" | fgrep dylib">)} spids: [889] ) ] spids: [889] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:white_list) op: Equal rhs: { (DQ (libz) (EscapedLiteralPart token:) (1) (EscapedLiteralPart token: ) (dylib) (EscapedLiteralPart token:) ("libstdc++") (EscapedLiteralPart token: ) (6) (EscapedLiteralPart token:) (dylib) (EscapedLiteralPart token: ) (libSystem) (EscapedLiteralPart token:) (B) (EscapedLiteralPart token: ) (dylib) ) } spids: [901] ) ] spids: [901] ) ] spids: [871 886] ) ] spids: [-1 923] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalOr left: (BoolUnary op_id: BoolUnary_z child: {(DQ ($ VSub_Name "$white_list"))} ) right: (BoolUnary op_id: BoolUnary_z child: {(DQ ($ VSub_Name "$dump_cmd"))} ) ) ) terminator: ) ] action: [ (C {(fail)} { (DQ ("Unsupported platform ") ($ VSub_Name "$OS") (-) ($ VSub_Name "$ARCH") (.)) } ) ] spids: [-1 947] ) ] spids: [-1 961] ) (C {(echo)} {(DQ ("Checking for expected dependencies ..."))}) (AndOr children: [ (Pipeline children: [ (C {(eval)} {($ VSub_Name "$dump_cmd")}) (C {(grep)} {(-i)} {(DQ ($ VSub_Name "$white_list"))}) ] negated: False ) (C {(fail)} {(DQ ("doesn't show any expected dependencies"))}) ] op_id: Op_DPipe ) (C {(echo)} {(DQ ("Checking for unexpected dependencies ..."))}) (Pipeline children: [ (C {(eval)} {($ VSub_Name "$dump_cmd")}) (C {(grep)} {(-i)} {(-v)} {(DQ ($ VSub_Name "$white_list"))}) ] negated: False ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ret) op: Equal rhs: {($ VSub_QMark "$?")} spids: [1018] ) ] spids: [1018] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$ret")} right: {(0)} ) ) terminator: ) ] action: [(C {(fail)} {(DQ ("found unexpected dependencies (listed above)."))})] spids: [-1 1035] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$ret")} right: {(1)} ) ) terminator: ) ] action: [(C {(fail)} {(DQ ("Error when checking dependencies."))})] spids: [1045 1058] ) ] spids: [-1 1068] ) (C {(echo)} {(DQ ("Dependencies look good."))}) (C {(echo)}) ] spids: [692] ) spids: [687 691] ) (C {(echo)} { (DQ ("Building protoc, OS=") ($ VSub_Name "$OS") (" ARCH=") ($ VSub_Name "$ARCH") (" TARGET=") ($ VSub_Name "$TARGET") ) } ) (C {(cd)} { (DQ (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {(DQ ($ VSub_Number "$0"))})]) left_token: spids: [1107 1113] ) ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:WORKING_DIR) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [1118 1120] ) } spids: [1117] ) ] spids: [1117] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CONFIGURE_ARGS) op: Equal rhs: {(DQ (--disable-shared))} spids: [1122] ) ] spids: [1122] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TARGET_FILE) op: Equal rhs: {(target/) ($ VSub_Name "$MAKE_TARGET") (.exe)} spids: [1128] ) ] spids: [1128] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(windows)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:MAKE_TARGET) op: Equal rhs: {(DQ (${ VSub_Name MAKE_TARGET) (.exe))} spids: [1151] ) ] spids: [1151] ) ] spids: [-1 1148] ) ] spids: [-1 1159] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:CXXFLAGS) op:Equal rhs:{(DQ (-DNDEBUG))} spids:[1168])] spids: [1168] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:LDFLAGS) op:Equal rhs:{(DQ )} spids:[1173])] spids: [1173] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(uname)})]) left_token: spids: [1183 1185] ) ) } right: {(CYGWIN) (Lit_Other "*")} ) ) terminator: ) ] action: [ (C {(assertEq)} {(DQ ($ VSub_Name "$OS"))} {(windows)} {($ VSub_Name "$LINENO")}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_64)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CONFIGURE_ARGS) op: Equal rhs: {(DQ ($ VSub_Name "$CONFIGURE_ARGS") (" --host=x86_64-w64-mingw32"))} spids: [1236] ) ] spids: [1236] ) ] spids: [-1 1233] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_32)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CONFIGURE_ARGS) op: Equal rhs: {(DQ ($ VSub_Name "$CONFIGURE_ARGS") (" --host=i686-pc-mingw32"))} spids: [1261] ) ] spids: [1261] ) ] spids: [1243 1258] ) ] else_action: [(C {(fail)} {(DQ ("Unsupported arch by CYGWIN: ") ($ VSub_Name "$ARCH"))})] spids: [1268 1279] ) ] spids: [-1 1196] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(uname)})]) left_token: spids: [1286 1288] ) ) } right: {(MINGW32) (Lit_Other "*")} ) ) terminator: ) ] action: [ (C {(assertEq)} {(DQ ($ VSub_Name "$OS"))} {(windows)} {($ VSub_Name "$LINENO")}) (C {(assertEq)} {(DQ ($ VSub_Name "$ARCH"))} {(x86_32)} {($ VSub_Name "$LINENO")}) ] spids: [1281 1299] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(uname)})]) left_token: spids: [1328 1330] ) ) } right: {(MINGW64) (Lit_Other "*")} ) ) terminator: ) ] action: [ (C {(assertEq)} {(DQ ($ VSub_Name "$OS"))} {(windows)} {($ VSub_Name "$LINENO")}) (C {(assertEq)} {(DQ ($ VSub_Name "$ARCH"))} {(x86_64)} {($ VSub_Name "$LINENO")}) ] spids: [1323 1341] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(uname)})]) left_token: spids: [1370 1372] ) ) } right: {(Linux) (Lit_Other "*")} ) ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(linux)} ) ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_64)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CXXFLAGS) op: Equal rhs: {(DQ ($ VSub_Name "$CXXFLAGS") (" -m64"))} spids: [1422] ) ] spids: [1422] ) ] spids: [-1 1419] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_32)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CXXFLAGS) op: Equal rhs: {(DQ ($ VSub_Name "$CXXFLAGS") (" -m32"))} spids: [1447] ) ] spids: [1447] ) ] spids: [1429 1444] ) ] else_action: [(C {(fail)} {(DQ ("Unsupported arch: ") ($ VSub_Name "$ARCH"))})] spids: [1454 1465] ) ] spids: [-1 1401] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(windows)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CONFIGURE_ARGS) op: Equal rhs: {(DQ ($ VSub_Name "$CONFIGURE_ARGS"))} spids: [1498] ) ] spids: [1498] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_64)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CONFIGURE_ARGS) op: Equal rhs: { (DQ ($ VSub_Name "$CONFIGURE_ARGS") (" --host=x86_64-w64-mingw32") ) } spids: [1522] ) ] spids: [1522] ) ] spids: [-1 1519] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_32)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CONFIGURE_ARGS) op: Equal rhs: { (DQ ($ VSub_Name "$CONFIGURE_ARGS") (" --host=i686-w64-mingw32")) } spids: [1547] ) ] spids: [1547] ) ] spids: [1529 1544] ) ] else_action: [(C {(fail)} {(DQ ("Unsupported arch: ") ($ VSub_Name "$ARCH"))})] spids: [1554 1565] ) ] spids: [1468 1483] ) ] else_action: [ (C {(fail)} { (DQ ("Cannot build ") ($ VSub_Name "$OS") (" on ") (CommandSubPart command_list: (CommandList children:[(C {(uname)})]) left_token: spids: [1577 1579] ) ) } ) ] spids: [1568 1583] ) ] spids: [1365 1383] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(uname)})]) left_token: spids: [1590 1592] ) ) } right: {(Darwin) (Lit_Other "*")} ) ) terminator: ) ] action: [ (C {(assertEq)} {(DQ ($ VSub_Name "$OS"))} {(osx)} {($ VSub_Name "$LINENO")}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CXXFLAGS) op: Equal rhs: {(DQ ($ VSub_Name "$CXXFLAGS") (" -mmacosx-version-min=10.7"))} spids: [1621] ) ] spids: [1621] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_64)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CXXFLAGS) op: Equal rhs: {(DQ ($ VSub_Name "$CXXFLAGS") (" -m64"))} spids: [1646] ) ] spids: [1646] ) ] spids: [-1 1643] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$ARCH"))} right: {(x86_32)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CXXFLAGS) op: Equal rhs: {(DQ ($ VSub_Name "$CXXFLAGS") (" -m32"))} spids: [1671] ) ] spids: [1671] ) ] spids: [1653 1668] ) ] else_action: [(C {(fail)} {(DQ ("Unsupported arch: ") ($ VSub_Name "$ARCH"))})] spids: [1678 1689] ) ] spids: [1585 1603] ) ] else_action: [ (C {(fail)} { (DQ ("Unsupported system: ") (CommandSubPart command_list: (CommandList children:[(C {(uname)})]) left_token: spids: [1698 1700] ) ) } ) ] spids: [1691 1703] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(osx)} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LDFLAGS) op: Equal rhs: {(DQ ($ VSub_Name "$LDFLAGS") (" -static-libgcc -static-libstdc++ -s"))} spids: [1733] ) ] spids: [1733] ) ] spids: [-1 1730] ) ] spids: [-1 1739] ) (C {(export)} {(CXXFLAGS)} {(LDFLAGS)}) (AndOr children: [ (C {(cd)} {(DQ ($ VSub_Name "$WORKING_DIR")) (/..)}) (AndOr children: [ (C {(./configure)} {($ VSub_Name "$CONFIGURE_ARGS")}) (AndOr children: [ (C {(cd)} {(src)}) (AndOr children: [ (C {(make)} {(clean)}) (AndOr children: [ (C {(make)} {($ VSub_Name "$MAKE_TARGET")}) (AndOr children: [ (C {(cd)} {(DQ ($ VSub_Name "$WORKING_DIR"))}) (AndOr children: [ (C {(mkdir)} {(-p)} {(target)}) (AndOr children: [ (C {(cp)} {(../src/) ($ VSub_Name "$MAKE_TARGET")} {($ VSub_Name "$TARGET_FILE")} ) (C {(exit)} {(1)}) ] op_id: Op_DPipe ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OS"))} right: {(osx)} ) ) terminator: ) ] action: [ (AndOr children: [(C {(strip)} {($ VSub_Name "$TARGET_FILE")}) (C {(exit)} {(1)})] op_id: Op_DPipe ) ] spids: [-1 1831] ) ] spids: [-1 1848] ) (AndOr children: [ (C {(checkArch)} {($ VSub_Name "$TARGET_FILE")}) (C {(checkDependencies)} {($ VSub_Name "$TARGET_FILE")}) ] op_id: Op_DAmp ) ] )