|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. 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, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +# R builds a package by copying only the sources under the directory of the R |
| 19 | +# package, which means it cannot refer to the Rust files above the directory. |
| 20 | +# So, this R script copies the necessary Rust crates under the R package dir. |
| 21 | +# Note that, this is not a standard mechanism of R, but is only invoked by |
| 22 | +# pkgbuild (cf. https://github.com/r-lib/pkgbuild/pull/157) |
| 23 | + |
| 24 | +# Tweak Cargo.toml |
| 25 | +cargo_toml <- "src/rust/Cargo.toml" |
| 26 | +lines <- readLines(cargo_toml) |
| 27 | +writeLines( |
| 28 | + gsub("../../../../", "../", lines, fixed = TRUE), |
| 29 | + cargo_toml |
| 30 | +) |
| 31 | + |
| 32 | +dir.create("src/dep_crates/") |
| 33 | +file.copy( |
| 34 | + c( |
| 35 | + "../../rust", |
| 36 | + "../../c", |
| 37 | + "../../Cargo.toml", |
| 38 | + "../../Cargo.lock" |
| 39 | + ), |
| 40 | + "src/", |
| 41 | + recursive = TRUE |
| 42 | +) |
| 43 | + |
| 44 | +# Tweak workspace Cargo.toml |
| 45 | +top_cargo_toml <- "src/Cargo.toml" |
| 46 | +lines <- readLines(top_cargo_toml) |
| 47 | +# change the path to the R package's Rust code |
| 48 | +lines <- gsub("r/sedonadb/src/rust", "rust", lines, fixed = TRUE) |
| 49 | +# remove unnecessary workspace members |
| 50 | +lines <- gsub('"python/sedonadb",', "", lines, fixed = TRUE) |
| 51 | +lines <- gsub('"sedona-cli",', "", lines, fixed = TRUE) |
| 52 | +writeLines(lines, top_cargo_toml) |
0 commit comments