Skip to content

Commit

Permalink
feat: deprecate owner prop.
Browse files Browse the repository at this point in the history
This commits enables the warning when setting `owner` prop.
Instead the users should migrate to using the new tag system.

The prop will be removed in the future.

Change-Id: Icd5f944f6da659a0448ada7b7c17f02ad43b4f13
  • Loading branch information
lukokr-aarch64 committed Sep 5, 2023
1 parent 18c5c52 commit 3611363
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bootstrap.bash
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ CONFIG_JSON="${CONFIGDIR}/.bob.config.json"
BOB_LOG_WARNINGS_FILE="${BUILDDIR}/.bob.warnings.csv"

# space separated values, e.g. "*:W RelativeUpLinkWarning:E"
BOB_LOG_WARNINGS="DeprecatedFilegroupSrcs:W"
BOB_LOG_WARNINGS="DeprecatedOwnerProp:W DeprecatedFilegroupSrcs:W"

export BOB_DIR
export CONFIG_FILE
Expand Down
7 changes: 7 additions & 0 deletions core/common_props.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package core

import (
"github.com/ARM-software/bob-build/core/backend"
"github.com/ARM-software/bob-build/internal/utils"
"github.com/ARM-software/bob-build/internal/warnings"
"github.com/google/blueprint"
)

Expand All @@ -25,4 +27,9 @@ func (c *CommonProps) processPaths(ctx blueprint.BaseModuleContext) {
c.LegacySourceProps.processPaths(ctx)
c.InstallableProps.processPaths(ctx)
c.IncludeDirsProps.Local_include_dirs = utils.PrefixDirs(c.IncludeDirsProps.Local_include_dirs, prefix)

// TODO: This should be done in a dedicated mutator for prop checks.
if c.AndroidProps.Owner != nil {
backend.Get().GetLogger().Warn(warnings.DeprecatedOwnerProp, ctx.BlueprintsFile(), ctx.ModuleName())
}
}
10 changes: 10 additions & 0 deletions core/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"path/filepath"
"regexp"

"github.com/ARM-software/bob-build/core/backend"
"github.com/ARM-software/bob-build/core/file"
"github.com/ARM-software/bob-build/core/module"
"github.com/ARM-software/bob-build/core/tag"
"github.com/ARM-software/bob-build/core/toolchain"
"github.com/ARM-software/bob-build/internal/utils"
"github.com/ARM-software/bob-build/internal/warnings"

"github.com/google/blueprint"
)
Expand Down Expand Up @@ -384,4 +386,12 @@ func installGroupMutator(ctx blueprint.TopDownMutatorContext) {
props.InstallGroupPath = path
}
}

// TODO: This should be done in a dedicated mutator for prop checks.
if res, ok := ctx.Module().(*ModuleResource); ok {
if res.Properties.AndroidProps.Owner != nil {
backend.Get().GetLogger().Warn(warnings.DeprecatedOwnerProp, ctx.BlueprintsFile(), ctx.ModuleName())
}
}

}
31 changes: 31 additions & 0 deletions docs/warnings/deprecated-owner-prop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# `deprecated-owner-prop` warning

## Warns when a module sets `owner`

## Problematic code:

```bp
bob_binary {
name: "bin_tagable_defaults",
srcs: ["src.cpp"],
defaults: ["tagable_defaults"],
owner: "baz",
}
```

## Correct code:

```bp
bob_binary {
name: "bin_tagable_defaults",
srcs: ["src.cpp"],
defaults: ["tagable_defaults"],
tags: ["owner:baz"],
}
```

## Rationale:

We are trying to remove Bob attributes which do not have a sensible translation to Bazel. In this instance the generic tagging system in Bazel provides a sensible alternative.
3 changes: 3 additions & 0 deletions internal/warnings/warnings.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
RelativeUpLinkWarning Category = "relative-up-link"
DeprecatedFilegroupSrcs Category = "deprecated-filegroup-srcs"
UnmatchedNonCompileSrcsWarning Category = "unmatched-non-compile-srcs"
DeprecatedOwnerProp Category = "deprecated-owner-prop"
)

var categoriesMap = map[string]Category{
Expand All @@ -28,6 +29,7 @@ var categoriesMap = map[string]Category{
"RelativeUpLinkWarning": RelativeUpLinkWarning,
"DeprecatedFilegroupSrcs": DeprecatedFilegroupSrcs,
"UnmatchedNonCompileSrcsWarning": UnmatchedNonCompileSrcsWarning,
"DeprecatedOwnerProp": DeprecatedOwnerProp,
}

var categoriesMessages = map[Category]string{
Expand All @@ -36,6 +38,7 @@ var categoriesMessages = map[Category]string{
RelativeUpLinkWarning: "Relative up-links in `srcs` are not allowed. Use `bob_filegroup` instead.",
DeprecatedFilegroupSrcs: "Use of `filegroup_srcs` is deprecated. Use `:<target_name>` in `srcs` instead.",
UnmatchedNonCompileSrcsWarning: "Non-compiled sources have not been matched fully.",
DeprecatedOwnerProp: "The `owner` property is no longer used. Please use the `tags` property with `owner:<owner>`.",
}

type Action string
Expand Down

0 comments on commit 3611363

Please sign in to comment.