1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798(*********************************************************************************)(* 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}letfield_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;;letrecenforcet~condition=match(condition:predicateBlang.t)with|Base(`backendname)->t.backend<-name|(And_|If_|True|False|Not_|Or_)ascondition->Dunolinter.Linter.enforce_blang(moduleDune.Instrumentation.Predicate)t~condition~eval~enforce;;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};;