blob: ca2e66e34d2579ad999910b252b1fb4d86656d9b [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package build
import (
"encoding/json"
"errors"
)
// ErrArgNotSet represents an arg not having been set in the build.
var ErrArgNotSet = errors.New("arg not set")
// Args represents the GN arguments set in the build.
type Args map[string]json.RawMessage
// BoolValue returns the value of a boolean GN arg set in the build. If unset,
// ErrArgNotSet will be returned.
func (args Args) BoolValue(name string) (bool, error) {
msg, ok := args[name]
if !ok {
return false, ErrArgNotSet
}
var val bool
err := json.Unmarshal(msg, &val)
return val, err
}