]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
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 | args <- commandArgs(TRUE) | |
19 | VERSION <- args[1] | |
20 | if (!file.exists(sprintf("windows/arrow-%s/include/arrow/api.h", VERSION))) { | |
21 | if (length(args) > 1) { | |
22 | # Arg 2 would be the path/to/lib.zip | |
23 | localfile <- args[2] | |
24 | cat(sprintf("*** Using RWINLIB_LOCAL %s\n", localfile)) | |
25 | if (!file.exists(localfile)) { | |
26 | cat(sprintf("*** %s does not exist; build will fail\n", localfile)) | |
27 | } | |
28 | file.copy(localfile, "lib.zip") | |
29 | } else { | |
30 | # Download static arrow from rwinlib | |
31 | if (getRversion() < "3.3.0") setInternet2() | |
32 | quietly <- !identical(tolower(Sys.getenv("ARROW_R_DEV")), "true") | |
33 | get_file <- function(template, version) { | |
34 | try( | |
35 | suppressWarnings( | |
36 | download.file(sprintf(template, version), "lib.zip", quiet = quietly) | |
37 | ), | |
38 | silent = quietly | |
39 | ) | |
40 | } | |
41 | # URL templates | |
42 | nightly <- "https://arrow-r-nightly.s3.amazonaws.com/libarrow/bin/windows/arrow-%s.zip" | |
43 | rwinlib <- "https://github.com/rwinlib/arrow/archive/v%s.zip" | |
44 | # First look for a nightly | |
45 | get_file(nightly, VERSION) | |
46 | # If not found, then check rwinlib | |
47 | if (!file.exists("lib.zip")) { | |
48 | get_file(rwinlib, VERSION) | |
49 | } | |
50 | if (!file.exists("lib.zip")) { | |
51 | # Try a different version | |
52 | # First, try pruning off a dev number, i.e. go from 0.14.1.1 to 0.14.1 | |
53 | VERSION <- sub("^([0-9]+\\.[0-9]+\\.[0-9]+).*$", "\\1", VERSION) | |
54 | get_file(rwinlib, VERSION) | |
55 | } | |
56 | if (!file.exists("lib.zip")) { | |
57 | # Next, try without a patch release, i.e. go from 0.14.1 to 0.14.0 | |
58 | VERSION <- sub("^([0-9]+\\.[0-9]+\\.).*$", "\\10", VERSION) | |
59 | get_file(rwinlib, VERSION) | |
60 | } | |
61 | } | |
62 | dir.create("windows", showWarnings = FALSE) | |
63 | unzip("lib.zip", exdir = "windows") | |
64 | unlink("lib.zip") | |
65 | } |