1
1
# ' The code of this function was copied/pasted from
2
2
# ' https://github.com/PRQL/prqlc-r/blob/main/dev/vendoring.R
3
3
# ' (licensed under MIT - (c) prqlr authors)
4
- # ' with minor modification to remove the vendor folder
5
- # ' after the vendor.tar.xz has been created
4
+ # ' with minor modification to :
5
+ # ' - remove the vendor folder after the vendor.tar.xz has been created
6
+ # ' - replace cr/crlf line end by lf in savvy-bindgen/src/gen/templates/Makevars.in
7
+ # ' (and any other file if necessary)
6
8
vendor_crates <- function (path = " ." ) {
7
9
src_dir <- rprojroot :: find_package_root_file(" src" , path = path )
8
10
@@ -23,11 +25,18 @@ vendor_crates <- function(path = ".") {
23
25
)
24
26
)$ stdout
25
27
28
+ config_toml_content <- stringr :: str_replace_all(config_toml_content , " rust/vendor" , " vendor" )
29
+
26
30
brio :: write_lines(
27
31
text = config_toml_content ,
28
32
path = config_toml_file
29
33
)
30
34
35
+ # We need to replace CR/CRLF line endings by LF in
36
+ # src/rust/vendor/savvy-bindgen/src/gen/templates/Makevars.in in an attempt to fix
37
+ # https://github.com/riatelab/distanamo/actions/runs/12913965346/job/36012421388#step:6:132
38
+ find_and_replace_crlf(file.path(src_dir , " rust" , " vendor" ))
39
+
31
40
withr :: local_dir(file.path(src_dir , vendor_rel_path ))
32
41
withr :: local_envvar(c(XZ_OPT = " -9" ))
33
42
processx :: run(
@@ -48,4 +57,24 @@ vendor_crates <- function(path = ".") {
48
57
unlink(file.path(src_dir , " rust" , " vendor" ), recursive = TRUE )
49
58
}
50
59
60
+ replace_crcrlf <- function (file_path ) {
61
+ content <- readLines(file_path , warn = FALSE )
62
+ content <- stringr :: str_replace_all(content , " \r\n |\r " , " \n " )
63
+ writeLines(content , file_path , sep = " \n " )
64
+ }
65
+
66
+ find_and_replace_crlf <- function (directory_path ) {
67
+ files_and_dirs <- list.files(directory_path , full.names = TRUE )
68
+
69
+ for (item in files_and_dirs ) {
70
+ if (file.info(item )$ isdir ) {
71
+ find_and_replace_crlf(item )
72
+ } else {
73
+ if (startsWith(basename(item ), " Makevars" )) {
74
+ replace_crcrlf(item )
75
+ }
76
+ }
77
+ }
78
+ }
79
+
51
80
vendor_crates()
0 commit comments