From b49006a4e338c58da23cdccdb092e6747770e7b3 Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Tue, 10 Dec 2024 14:04:56 -0800 Subject: [PATCH] Can we retire buck.{1,2,3} angle now? Summary: These have been retained for a long time based on the `evolves` stuff. Can we get away with just purging those versions? Reviewed By: simonmar Differential Revision: D66998238 fbshipit-source-id: 2aafd9ec9f594cb61b4ac8358d880d448c377339 --- glean/schema/source/archive/buck.angle | 543 ------------------------- glean/schema/source/buck.angle | 1 - 2 files changed, 544 deletions(-) delete mode 100644 glean/schema/source/archive/buck.angle diff --git a/glean/schema/source/archive/buck.angle b/glean/schema/source/archive/buck.angle deleted file mode 100644 index d525688d1..000000000 --- a/glean/schema/source/archive/buck.angle +++ /dev/null @@ -1,543 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. - -schema buck.1 { -import sys -import src - -# Targets in buck -predicate Target : - { - repo : sys.Blob, - name : sys.Blob, - platform : maybe sys.Blob, - } - -# A translation unit (source file and target) -predicate TranslationUnit : - { - file : src.File, - target : Target, - } - -# A target locator (subdir//path:name), subdir can be empty -predicate Locator : - { - subdir : maybe string, - path : string, - name : string, - } - -# A source file reference (either from the repo or generated during build) -predicate File : - { - source : src.File | - generated : Locator - } - -# Buck target type (cxx_libary, cxx_binary, ...) -predicate Type : string - -# Buck platform (fbsource specific) -predicate Platform : string - -# Buck label -predicate Label : string - -# A set of Buck labels -predicate Labels : [Label] - -# Buck dependency (buck.direct_deps) -type Dependency = - { - target : Locator, - explicit_ : bool, # is it in deps in fbsource? - exported : bool, # is it in exported_deps in fbsource? - } - -# Reverse locator dependencies derived from buck.TargetDependencies -predicate LocatorReverseDeps : - { - locator : Locator, # unique key - rdeps : [Locator], - } - -# From buck targets --show-target-hash -predicate TargetHash : - { - locator : Locator, # unique key - targetHash : string, - } - -# From buck targets --show-rulekey -predicate RuleKey : - { - locator : Locator, # unique key - ruleKey : string, - } - -} - -schema buck.2 : buck.1 { -import src - -# Buck target -predicate Target : - { - locator : Locator, - type_ : Type, - defaultPlatform : maybe Platform, - labels : Labels, - } - -# Buck target dependencies -predicate TargetDependencies.1 : - { - target : Target, - dependencies : [Dependency], - } - -# A translation unit (source file and target) -predicate TranslationUnit : - { - file : src.File, - target : Locator, - platform : maybe Platform, - } - -# Buck target link_whole flag -predicate TargetLinkWhole.1 : Target - -# Buck target sources -predicate TargetSources.1 : - { - target : Target, - headers : [File], - exportedHeaders : [File], - srcs : [File], - } - -# Buck target output, indexed by target -predicate TargetOut.1 : - { - target : Target, - file : src.File, - } - -# Buck target output, indexed by file -predicate OutTarget.1 : - { - file : src.File, - target : Target, - } - stored {F,T} where TargetOut {T,F} - -# Which targets mention a file in headers, exportedHeaders, or srcs. -# Derived from buck.TargetSources -predicate Owner.1 : - { - source : src.File, # unique key - owner : TargetSources, - } - stored - {Src,Owner} where - Owner = TargetSources - { - headers = Headers, - exportedHeaders = Exported, - srcs = Srcs - }; - Src = - (S where F = Headers [..]; F = File { source = S }) | - (S where F = Exported [..]; F = File { source = S }) | - (S where F = Srcs [..]; F = File { source = S }) - -} # end schema buck.2 - -schema buck.3 : buck.2 { -import src - -# Named output use OutputLabel as the key, the 'baz' in the form: -# //foo:bar[baz] -predicate OutputLabel : string - -# The named output use locators that end with an extra optional key, e.g. -# 'baz' in //foo:bar[baz] -predicate LocatorWithLabel : - { - locator : Locator, - label : OutputLabel - } - -# Buck target output, indexed by target. These are present if the named outputs -# (the "outs" in buck query) are present. -# -# The "default_outs" attribute is represented by Nothing as the outputLabel. -# If TargetOuts exists for a Target then there ought to be -# an outputLabel = nothing as well. -# The file with (outputLabel = nothing) may or may not -# be present with (outputLabel = just _), the default file can be distinct from -# the files of all labeled outputs. -# -# The target and outputLabel *should* uniquely determine the file, -# but that invariant isn't enforced by the Buck output which returns -# the file as a singleton list, so to be on the safe side this -# predicate allows for the possibility of multiple files per -# (target,outputLabel). - -predicate TargetOuts : - { - target : Target, - outputLabel : maybe OutputLabel, # Nothing means the default_output - file : src.File - } - -# derived predicate, reverse of TargetOuts. The same file may have duplicate -# OutsTarget facts. In particular the outputLabel of nothing -# ("default_outs" attribute) may overlap with a just value. -predicate OutsTarget : - { - file : src.File, - target: Target, - outputLabel : maybe OutputLabel - } - stored - {SF, T, OL} where TargetOuts {T, OL, SF} - -# A source file reference (either from the repo or generated during build) -predicate File : - { - source : src.File | - generated : Locator | - generatedLabel : LocatorWithLabel - } - -derive File default - ({ source = X } where buck.File.1 {source = X}) ++ - ({ generated = X } where buck.File.1 {generated = X}) - -derive buck.File.1 default - ({ source = X } where File {source = X}) ++ - ({ generated = X } where File {generated = X}) - -# Resolve source and generated files to the src.File itself. -predicate FileResolved : - { - buckFile : File, - srcFile : src.File - } - {BF, SF} where - SF = - (SF1 where File { source = SF1 } = BF) ++ - (SF2 where - File { generated = Loc } = BF; - buck.TargetOuts{target = {locator = Loc}, - outputLabel = nothing, file = SF2}) ++ - (SF3 where - File {generatedLabel = LocatorWithLabel{locator = Loc, label = Lab}} = BF; - buck.TargetOuts{target = {locator = Loc}, - outputLabel = {just = Lab}, file = SF3}); - -# New versions of predicates that now depend on File - -# Buck target sources -predicate TargetSources : - { - target : Target, - headers : [File], - exportedHeaders : [File], - srcs : [File], - } - -# Which targets mention a file in headers, exportedHeaders, or srcs. -# (Making the TargetSources a direct owner of the file). -# -# For indirect mentions, via locators, see the Consumer predicate. -predicate Owner : - { - source : src.File, # unique key - owner : TargetSources, - } - stored - {Src, Owner} where - Owner = TargetSources - { - headers = Headers, - exportedHeaders = Exported, - srcs = Srcs - }; - File { source = Src } = Headers[..] | Exported[..] | Srcs [..]; - -# Which targets mention a file in headers, exportedHeaders, or srcs. -# This predicate is just like Owner but returns only the Locator of the owner -# not the whole TargetSources. -predicate FileToTarget : - { - source : src.File, - locator : Locator, - } - {Src, BuckLocator} where - Owner - { - source = Src, - owner = TargetSources { - target = { - locator = BuckLocator - } - } - } - -# New predicate that depends on File - -# Which targets consume a (possibly named) output of another rule. -# (Making the TargetSources a consumer of the file). -predicate Consumer : - { - source : src.File, # unique key - consumer : TargetSources, - } - stored - {Src, Consumer} where - Consumer = TargetSources - { - headers = Headers, - exportedHeaders = Exported, - srcs = Srcs - }; - BF = Headers[..] | Exported[..] | Srcs [..]; - FileResolved{buckFile = BF, srcFile= Src} - -# Name for TargetIndexer, indicating which indexing pass created the target -predicate TargetIndexerName : string - -# Associate a Target with a group, useful for identifying which indexing -# pass is planned -predicate TargetIndexer : - { - name : TargetIndexerName, - target : Target - } - -# The name of an attribute. Allows for enumerating all supported attributes -predicate AttributeName : string - -# Represents a single key -> value mapping in a dictionary-like attribute. -# {"a": "b"} is represented with -# AttributeMapping { "a", {str = "b"} } -# {"a": ["b", "c"]} maps to -# AttributeMapping { "a", {sequence = [{str = "b"}, {str = "c"}] } -# {"a": {"b": "c"}} maps to -# AttributeMapping { "a", {mapping = {"b", {str = "c"}}} } -type AttributeMapping = - { - key : string, - value : AttributeValue, - } - -predicate AttributeValue : - { - str : string | - sequence : [AttributeValue] | - mapping : [AttributeMapping] | - } - -# Maps a target and an attribute name to its value -predicate TargetAttribute : - { - target : Target, - attribute : AttributeName, - value : AttributeValue, - } - -# Returns all sources and their base_module in a target. -predicate TargetSourcesBaseModule: - { - locator: Target, - srcs: [File], - baseModule: maybe AttributeValue, - } - { Tgt, Srcs, BM } where - TargetSources { target = Tgt, srcs = Srcs }; - Attr = AttributeName "base_module"; - ( - TargetAttribute { Tgt, Attr, V }; - BM = {just = V}; - ) | ( - ! TargetAttribute { target = Tgt, attribute = Attr }; - BM = (nothing : maybe AttributeValue); - ) - -# The following predicates and types, add locations -# to Targets and define cross references. -# -# The terminology is a bit inconsistent w.r.t the buck doc. -# A Target is called a "build rule" in the doc, and a -# a Locator is called a "build target". -# -# To be clear, the following is a Target. -# -# cpp_library( -# name = "cpp", -# srcs = [ -# "glean.cpp", -# "sender.cpp", -# ], -# ) -# -# The span goes from `c` to `)` -# - -predicate Definition : { - module : src.File, - name : string, -} - -predicate DefinitionLocation: -{ - definition : Definition, - file: src.File, # redundant with Definition.module - span: src.ByteSpan, -} - -predicate TargetLocation: -{ - locator : Locator, - file: src.File, - span: src.ByteSpan, -} - -predicate SourceFileLocation: -{ - file: src.File, - span: src.ByteSpan, -} - -# Locators of targets defined in a file -# Deprecated: replaced by more general FileEntity -predicate FileTarget: -{ - file : src.File, - locator : Locator, -} - -predicate FileEntity: -{ - file : src.File, - entity : XRefDestination, -} - -predicate FileDefinition: -{ - file : src.File, - definition : Definition, -} - -# Entities which can be referenced elsewhere -type XRefDestination = { - locator : Locator | - file : src.File | - definition : Definition | -} - -type XRef = - { - destination : XRefDestination, - ranges : [src.ByteSpan], - } - -# Cross-references to a target within a file. -predicate FileXRefs: - { - file : src.File, - xrefs : [XRef], - } - -# Uses of a Buck target (inverse of xrefs) -# deprecated, replaced by DestinationUses -predicate TargetUses: - { - locator: Locator, - file: src.File, - spans: [src.ByteSpan], - } stored - { Locator, File, Spans } where - FileXRefs { File, XRefs }; - { { locator = Locator }, Spans } = XRefs[..]; - -predicate DestinationUses: - { - destination: XRefDestination, - file: src.File, - spans: [src.ByteSpan], - } stored - { Destination, File, Spans } where - FileXRefs { File, XRefs }; - { Destination, Spans } = XRefs[..]; - -# Reverse of the TargetDependencies relationship -predicate LocatorReverseDep : - { - locator : Locator, - rdep : Locator, - } - stored - { Parent, Child } where - TargetDependencies { target = { locator = Parent }, dependencies = Deps }; - { target = Child } = Deps[..]; - - -type FailureReason = enum { - # config was intentionally skipped - Skipped | - # config was manually blocked - Blocked | - # Compilation database for this target is empty - EmptyCdb | - # Failed to create Compilation database - FailedCdb | - # Failed to run a buck query on this target - QueryFailed -} - -predicate IndexerName: string - -predicate IndexFailure : - { - # Source of the error - source : Target, - # Any string to identify an Indexer which added this predicate - indexer : IndexerName, - # Predefined classification of errors - reason: FailureReason, - # Additional details - details: string, - } - - type ArgumentMapping = - { - key: string, - value: ArgumentValue, - } - - predicate ArgumentValue: - { - lit: string | - sequence: [ArgumentValue] | - mapping: [ArgumentMapping] - } - -predicate CallArgument: { - label: maybe string, - value: ArgumentValue, - file: src.File, - span: src.ByteSpan, - } - -predicate TargetCall: - { - locator: Locator, - arguments: [CallArgument], - file: src.File, - span: src.ByteSpan, - } - -} # end schema buck.3 diff --git a/glean/schema/source/buck.angle b/glean/schema/source/buck.angle index 33a129939..58412fa19 100644 --- a/glean/schema/source/buck.angle +++ b/glean/schema/source/buck.angle @@ -530,4 +530,3 @@ predicate SearchByLocalName: } # end schema buck.4 -schema buck.4 evolves buck.3