123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100(*********************************************************************************)(* Dunolint - A tool to lint and help manage files in dune projects *)(* Copyright (C) 2024-2025 Mathieu Barbin <mathieu.barbin@gmail.com> *)(* *)(* This file is part of Dunolint. *)(* *)(* Dunolint is free software; you can redistribute it and/or modify it *)(* under the terms of the GNU Lesser General Public License as published by *)(* the Free Software Foundation either version 3 of the License, or any later *)(* version, with the LGPL-3.0 Linking Exception. *)(* *)(* Dunolint is distributed in the hope that it will be useful, but WITHOUT *)(* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *)(* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *)(* and the file `NOTICE.md` at the root of this repository for more details. *)(* *)(* You should have received a copy of the GNU Lesser General Public License *)(* and the LGPL-3.0 Linking Exception along with this library. If not, see *)(* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)(*********************************************************************************)typet={mutablebackend:Dune.Instrumentation.Backend.Name.t}[@@derivingsexp_of]letcreate~backend={backend}letbackendt=t.backendletset_backendt~backend=t.backend<-backendletfield_name="instrumentation"letread~sexps_rewriter~field=letargs=Dunolinter.Sexp_handler.get_args~field_name~sexps_rewriter~fieldinmatchList.find_mapargs~f:(function|List[Atom"backend";Atomname]->Some(Dune.Instrumentation.Backend.Name.vname)|_->None)with|Somebackend->create~backend|None->letloc=Sexps_rewriter.locsexps_rewriterfieldinErr.raise~locPp.O.[Pp.text"Required "++Pp_tty.kwd(moduleString)"backend"++Pp.text" value in instrumentation."];;letwrite(t:t)=Sexp.List[Atomfield_name;List[Atom"backend";Atom(Dune.Instrumentation.Backend.Name.to_stringt.backend)]];;letrewritet~sexps_rewriter~field=letargs=Dunolinter.Sexp_handler.get_args~field_name~sexps_rewriter~fieldinletfile_rewriter=Sexps_rewriter.file_rewritersexps_rewriterinList.iterargs~f:(function|List[Atom"backend";(Atom_asname)]->letrange=Sexps_rewriter.rangesexps_rewriternameinFile_rewriter.replacefile_rewriter~range~text:(Dune.Instrumentation.Backend.Name.to_stringt.backend)|_->());;typepredicate=Dune.Instrumentation.Predicate.tletevalt~predicate=match(predicate:predicate)with|`backendname->Dune.Instrumentation.Backend.Name.equalnamet.backend|>Dunolint.Trilang.const;;letenforce=Dunolinter.Linter.enforce(moduleDune.Instrumentation.Predicate)~eval~enforce:(funtpredicate->matchpredicatewith|Not(`backend_)->Eval|T(`backendname)->t.backend<-name;Ok);;letdefault_backend=Dune.Instrumentation.Backend.Name.v"bisect_ppx"letinitialize~condition=letbackend=List.find_map(Dunolinter.Linter.at_positive_enforcing_positioncondition)~f:(function`backendname->Somename)|>Option.value~default:default_backendin{backend};;