xref: /aosp_15_r20/build/soong/cmd/release_config/release_config_lib/flag_declaration.go (revision 333d2b3687b3a337dbcca9d65000bca186795e39)
1// Copyright 2024 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package release_config_lib
16
17import (
18	rc_proto "android/soong/cmd/release_config/release_config_proto"
19)
20
21var (
22	// Allowlist: these flags may have duplicate (identical) declarations
23	// without generating an error.  This will be removed once all such
24	// declarations have been fixed.
25	DuplicateDeclarationAllowlist = map[string]bool{}
26)
27
28func FlagDeclarationFactory(protoPath string) (fd *rc_proto.FlagDeclaration) {
29	fd = &rc_proto.FlagDeclaration{}
30	if protoPath != "" {
31		LoadMessage(protoPath, fd)
32	}
33	// If the input didn't specify a value, create one (== UnspecifiedValue).
34	if fd.Value == nil {
35		fd.Value = &rc_proto.Value{Val: &rc_proto.Value_UnspecifiedValue{false}}
36	}
37	return fd
38}
39