|
| 1 | +#!/bin/bash |
| 2 | +# This file should be executed with ruby |
| 3 | + |
| 4 | +set -ex |
| 5 | + |
| 6 | +# --- begin runfiles.bash initialization --- |
| 7 | +# Copy-pasted from Bazel's Bash runfiles library (tools/bash/runfiles/runfiles.bash). |
| 8 | +set -euo pipefail |
| 9 | +if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then |
| 10 | + if [[ -f "$0.runfiles_manifest" ]]; then |
| 11 | + export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest" |
| 12 | + elif [[ -f "$0.runfiles/MANIFEST" ]]; then |
| 13 | + export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST" |
| 14 | + elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then |
| 15 | + export RUNFILES_DIR="$0.runfiles" |
| 16 | + fi |
| 17 | +fi |
| 18 | +if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then |
| 19 | + source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash" |
| 20 | +elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then |
| 21 | + source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \ |
| 22 | + "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)" |
| 23 | +else |
| 24 | +echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash" |
| 25 | +exit 1 |
| 26 | +fi |
| 27 | +# --- end runfiles.bash initialization --- |
| 28 | + |
| 29 | +# rvm use ruby-3.0 |
| 30 | + |
| 31 | +# Make a temporary directory and move to it to do all packaging work |
| 32 | +mkdir -p tmp |
| 33 | +cd tmp |
| 34 | + |
| 35 | +# Move all generated files to lib/google/protobuf |
| 36 | +mkdir -p lib/google/protobuf |
| 37 | +cp "$(rlocation com_google_protobuf/src/google/protobuf/any_pb.rb)" lib/google/protobuf |
| 38 | +cp "$(rlocation com_google_protobuf/src/google/protobuf/api_pb.rb)" lib/google/protobuf |
| 39 | +cp "$(rlocation com_google_protobuf/src/google/protobuf/descriptor_pb.rb)" lib/google/protobuf |
| 40 | +cp "$(rlocation com_google_protobuf/src/google/protobuf/duration_pb.rb)" lib/google/protobuf |
| 41 | +cp "$(rlocation com_google_protobuf/src/google/protobuf/empty_pb.rb)" lib/google/protobuf |
| 42 | +cp "$(rlocation com_google_protobuf/src/google/protobuf/field_mask_pb.rb)" lib/google/protobuf |
| 43 | +cp "$(rlocation com_google_protobuf/src/google/protobuf/source_context_pb.rb)" lib/google/protobuf |
| 44 | +cp "$(rlocation com_google_protobuf/src/google/protobuf/struct_pb.rb)" lib/google/protobuf |
| 45 | +cp "$(rlocation com_google_protobuf/src/google/protobuf/timestamp_pb.rb)" lib/google/protobuf |
| 46 | +cp "$(rlocation com_google_protobuf/src/google/protobuf/type_pb.rb)" lib/google/protobuf |
| 47 | +cp "$(rlocation com_google_protobuf/src/google/protobuf/wrappers_pb.rb)" lib/google/protobuf |
| 48 | + |
| 49 | +# Move all utf-8 files to ext/google/protobuf_c/third_party/utf8_range |
| 50 | +UTF8_DIR=ext/google/protobuf_c/third_party/utf8_range |
| 51 | +mkdir -p $UTF8_DIR |
| 52 | +cp "$(rlocation utf8_range/LICENSE)" $UTF8_DIR/LICENSE |
| 53 | +cp "$(rlocation utf8_range/naive.c)" $UTF8_DIR |
| 54 | +cp "$(rlocation utf8_range/range2-neon.c)" $UTF8_DIR |
| 55 | +cp "$(rlocation utf8_range/range2-sse.c)" $UTF8_DIR |
| 56 | +cp "$(rlocation utf8_range/utf8_range.h)" $UTF8_DIR |
| 57 | + |
| 58 | +# Move all source files to the correct location |
| 59 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/convert.c)" ext/google/protobuf_c |
| 60 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/convert.h)" ext/google/protobuf_c |
| 61 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/defs.c)" ext/google/protobuf_c |
| 62 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/defs.h)" ext/google/protobuf_c |
| 63 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/extconf.rb)" ext/google/protobuf_c |
| 64 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/map.c)" ext/google/protobuf_c |
| 65 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/map.h)" ext/google/protobuf_c |
| 66 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/message.c)" ext/google/protobuf_c |
| 67 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/message.h)" ext/google/protobuf_c |
| 68 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/protobuf.c)" ext/google/protobuf_c |
| 69 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/protobuf.h)" ext/google/protobuf_c |
| 70 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/repeated_field.c)" ext/google/protobuf_c |
| 71 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/repeated_field.h)" ext/google/protobuf_c |
| 72 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/ruby-upb.c)" ext/google/protobuf_c |
| 73 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/ruby-upb.h)" ext/google/protobuf_c |
| 74 | +cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/wrap_memcpy.c)" ext/google/protobuf_c |
| 75 | +cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf.rb)" lib/google |
| 76 | +cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/descriptor_dsl.rb)" lib/google/protobuf |
| 77 | +cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/message_exts.rb)" lib/google/protobuf |
| 78 | +cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/repeated_field.rb)" lib/google/protobuf |
| 79 | +cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/well_known_types.rb)" lib/google/protobuf |
| 80 | + |
| 81 | +# Move gemspec file to current directory |
| 82 | +cp "$(rlocation com_google_protobuf/ruby/google.protobuf.gemspec)" . |
| 83 | + |
| 84 | +# Make all files global readable/writable/executable |
| 85 | +chmod -R 777 ./ |
| 86 | + |
| 87 | +# Build gem |
| 88 | +gem build google-protobuf.gemspec |
0 commit comments