123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778(*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)typet=|LibFileofstring|SourceFileofstring|JsonFileofstring(* A resource that might get required, like .css, .jpg, etc. We don't parse
these, just check that they exist *)|ResourceFileofstring[@@derivingshow,eq]letto_string=function|LibFilex|SourceFilex|JsonFilex|ResourceFilex->xletto_path=function|LibFilex|SourceFilex|JsonFilex|ResourceFilex->Okxletcompare=(* libs, then source and json files at the same priority since JSON files are
* basically source files. We don't actually read resource files so they come
* last *)letorder_of_filename=function|LibFile_->1|SourceFile_->2|JsonFile_->2|ResourceFile_->3infunab->letk=order_of_filenamea-order_of_filenamebinifk<>0thenkelseString.compare(to_stringa)(to_stringb)letcompare_optab=match(a,b)with|(Some_,None)->-1|(None,Some_)->1|(None,None)->0|(Somea,Someb)->compareabletis_lib_file=function|LibFile_->true|SourceFile_->false|JsonFile_->false|ResourceFile_->falseletmapf=function|LibFilefilename->LibFile(ffilename)|SourceFilefilename->SourceFile(ffilename)|JsonFilefilename->JsonFile(ffilename)|ResourceFilefilename->ResourceFile(ffilename)letexistsf=function|LibFilefilename|SourceFilefilename|JsonFilefilename|ResourceFilefilename->ffilenameletcheck_suffixfilenamesuffix=exists(funfn->Filename.check_suffixfnsuffix)filenameletchop_suffixfilenamesuffix=map(funfn->Filename.chop_suffixfnsuffix)filenameletwith_suffixfilenamesuffix=map(funfn->fn^suffix)filename