@@ -1087,9 +1087,59 @@ module Install_conf = struct
1087
1087
str)
1088
1088
1089
1089
module File_entry = struct
1090
+ module Without_include = struct
1091
+ type t =
1092
+ | File_binding of File_binding.Unexpanded .t
1093
+ | Glob_files of Glob_files .t
1094
+
1095
+ let decode =
1096
+ let open Dune_lang.Decoder in
1097
+ let file_binding_decode =
1098
+ let + file_binding = File_binding.Unexpanded. decode in
1099
+ File_binding file_binding
1100
+ in
1101
+ let glob_files_decode =
1102
+ let version_check = Dune_lang.Syntax. since Stanza. syntax (3 , 6 ) in
1103
+ let + glob_files =
1104
+ sum
1105
+ [ ( " glob_files"
1106
+ , let + glob = version_check >>> String_with_vars. decode in
1107
+ { Glob_files. glob; recursive = false } )
1108
+ ; ( " glob_files_rec"
1109
+ , let + glob = version_check >>> String_with_vars. decode in
1110
+ { Glob_files. glob; recursive = true } )
1111
+ ]
1112
+ in
1113
+ Glob_files glob_files
1114
+ in
1115
+ file_binding_decode < |> glob_files_decode
1116
+
1117
+ let to_file_bindings_unexpanded t ~expand_str ~dir =
1118
+ match t with
1119
+ | File_binding file_binding -> Memo. return [ file_binding ]
1120
+ | Glob_files glob_files ->
1121
+ let open Memo.O in
1122
+ let + paths =
1123
+ Glob_files.Expand. memo glob_files ~f: expand_str ~base_dir: dir
1124
+ in
1125
+ let glob_loc = String_with_vars. loc glob_files.glob in
1126
+ List. map paths ~f: (fun path ->
1127
+ let src = (glob_loc, path) in
1128
+ File_binding.Unexpanded. make ~src ~dst: src)
1129
+
1130
+ let to_file_bindings_expanded t ~expand_str ~dir =
1131
+ to_file_bindings_unexpanded t ~expand_str ~dir
1132
+ |> Memo. bind
1133
+ ~f:
1134
+ (Memo.List. map
1135
+ ~f:
1136
+ (File_binding.Unexpanded. expand ~dir
1137
+ ~f: (expand_str_with_check_for_local_path ~expand_str )))
1138
+ end
1139
+
1090
1140
include
1091
1141
Recursive_include. Make
1092
- (File_binding. Unexpanded )
1142
+ (Without_include )
1093
1143
(struct
1094
1144
let include_keyword = " include"
1095
1145
@@ -1101,24 +1151,51 @@ module Install_conf = struct
1101
1151
let expand_include_multi ts ~expand_str ~dir =
1102
1152
Memo.List. concat_map ts ~f: (expand_include ~expand_str ~dir )
1103
1153
1104
- let of_file_binding = of_base
1154
+ let of_file_binding file_binding =
1155
+ of_base (Without_include. File_binding file_binding)
1156
+
1157
+ let to_file_bindings_unexpanded ts ~expand_str ~dir =
1158
+ expand_include_multi ts ~expand_str ~dir
1159
+ |> Memo. bind
1160
+ ~f:
1161
+ (Memo.List. concat_map
1162
+ ~f:
1163
+ (Without_include. to_file_bindings_unexpanded ~expand_str ~dir ))
1164
+
1165
+ let to_file_bindings_expanded ts ~expand_str ~dir =
1166
+ expand_include_multi ts ~expand_str ~dir
1167
+ |> Memo. bind
1168
+ ~f:
1169
+ (Memo.List. concat_map
1170
+ ~f: (Without_include. to_file_bindings_expanded ~expand_str ~dir ))
1171
+ end
1105
1172
1106
- let expand t ~expand_str ~dir =
1107
- let open Memo.O in
1108
- let * unexpanded = expand_include t ~expand_str ~dir in
1109
- Memo.List. map unexpanded
1110
- ~f:
1111
- (File_binding.Unexpanded. expand ~dir
1112
- ~f: (expand_str_with_check_for_local_path ~expand_str ))
1173
+ module Dir_entry = struct
1174
+ include
1175
+ Recursive_include. Make
1176
+ (File_binding. Unexpanded )
1177
+ (struct
1178
+ let include_keyword = " include"
1113
1179
1114
- let expand_multi ts ~expand_str ~dir =
1115
- Memo.List. concat_map ts ~f: (expand ~expand_str ~dir )
1180
+ let include_allowed_in_versions = `Since (3 , 5 )
1181
+
1182
+ let non_sexp_behaviour = `User_error
1183
+ end )
1184
+
1185
+ let to_file_bindings_expanded ts ~expand_str ~dir =
1186
+ Memo.List. concat_map ts ~f: (expand_include ~expand_str ~dir )
1187
+ |> Memo. bind
1188
+ ~f:
1189
+ (Memo.List. map
1190
+ ~f:
1191
+ (File_binding.Unexpanded. expand ~dir
1192
+ ~f: (expand_str_with_check_for_local_path ~expand_str )))
1116
1193
end
1117
1194
1118
1195
type t =
1119
1196
{ section : Install.Section_with_site .t
1120
1197
; files : File_entry .t list
1121
- ; dirs : File_entry .t list
1198
+ ; dirs : Dir_entry .t list
1122
1199
; package : Package .t
1123
1200
; enabled_if : Blang .t
1124
1201
}
@@ -1131,7 +1208,7 @@ module Install_conf = struct
1131
1208
and + dirs =
1132
1209
field_o " dirs"
1133
1210
(Dune_lang.Syntax. since Stanza. syntax (3 , 5 )
1134
- >>> repeat File_entry . decode)
1211
+ >>> repeat Dir_entry . decode)
1135
1212
and + package = Stanza_common.Pkg. field ~stanza: " install"
1136
1213
and + enabled_if =
1137
1214
let allowed_vars = Enabled_if. common_vars ~since: (2 , 6 ) in
@@ -1147,9 +1224,9 @@ module Install_conf = struct
1147
1224
1148
1225
{ section; dirs; files; package; enabled_if })
1149
1226
1150
- let expand_files t = File_entry. expand_multi t.files
1227
+ let expand_files t = File_entry. to_file_bindings_expanded t.files
1151
1228
1152
- let expand_dirs t = File_entry. expand_multi t.dirs
1229
+ let expand_dirs t = Dir_entry. to_file_bindings_expanded t.dirs
1153
1230
end
1154
1231
1155
1232
module Executables = struct
0 commit comments