123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100(*
* 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.
*)openPrimitive_derivingtypet=|LibFileofstring|SourceFileofstring|JsonFileofstring(* A resource that might get required, like .css, .jpg, etc. We don't parse
these, just check that they exist *)|ResourceFileofstring[@@deriving_inlineequal]let_=fun(_:t)->()letequal=(funa__001_->funb__002_->ifPpx_compare_lib.phys_equala__001_b__002_thentrueelse(match(a__001_,b__002_)with|(LibFile_a__003_,LibFile_b__004_)->equal_string_a__003__b__004_|(LibFile_,_)->false|(_,LibFile_)->false|(SourceFile_a__005_,SourceFile_b__006_)->equal_string_a__005__b__006_|(SourceFile_,_)->false|(_,SourceFile_)->false|(JsonFile_a__007_,JsonFile_b__008_)->equal_string_a__007__b__008_|(JsonFile_,_)->false|(_,JsonFile_)->false|(ResourceFile_a__009_,ResourceFile_b__010_)->equal_string_a__009__b__010_):t->t->bool)let_=equal[@@@end]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