|
| 1 | +#!/bin/bash |
| 2 | +# Copyright 2026 Google LLC |
| 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 | +set -e |
| 17 | + |
| 18 | +SKIP_CLONE=$1 |
| 19 | +SPANNER_LIB_BRANCH="${2:-main}" |
| 20 | + |
| 21 | +if ! [ "$SKIP_CLONE" == "true" ]; then |
| 22 | + git clone https://github.com/googleapis/go-sql-spanner.git --branch "$SPANNER_LIB_BRANCH" |
| 23 | +fi |
| 24 | + |
| 25 | +mkdir -p spannerlib-node |
| 26 | +rm -rf spannerlib-node/* |
| 27 | + |
| 28 | +cp -r go-sql-spanner/spannerlib/wrappers/spannerlib-node/* spannerlib-node/ |
| 29 | +mkdir -p spannerlib-node/shared |
| 30 | +cp -r go-sql-spanner/spannerlib/shared/* spannerlib-node/shared/ |
| 31 | + |
| 32 | +# Update build-shared-lib.sh and binding.gyp paths for self-contained spannerlib-node |
| 33 | +if [ -f "spannerlib-node/scripts/build-shared-lib.sh" ]; then |
| 34 | + sed -i '' 's|\.\./\.\./\.\./shared|\.\./shared|g' spannerlib-node/scripts/build-shared-lib.sh 2>/dev/null || \ |
| 35 | + sed -i 's|\.\./\.\./\.\./shared|\.\./shared|g' spannerlib-node/scripts/build-shared-lib.sh |
| 36 | +fi |
| 37 | + |
| 38 | +if [ -f "spannerlib-node/binding.gyp" ]; then |
| 39 | + sed -i '' 's|\.\./\.\./shared|\./shared|g' spannerlib-node/binding.gyp 2>/dev/null || \ |
| 40 | + sed -i 's|\.\./\.\./shared|\./shared|g' spannerlib-node/binding.gyp |
| 41 | +fi |
| 42 | + |
| 43 | +rm -rf go-sql-spanner |
0 commit comments