Open-CMSIS-Pack/cbuild

View on GitHub
pkg/builder/cbuildidx/reader.go

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
/*
 * Copyright (c) 2024 Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

package cbuildidx

import (
    "os"

    "gopkg.in/yaml.v3"
)

type Cbuild struct {
    Build struct {
        OutputDirs struct {
            Intdir string `yaml:"intdir"`
            Outdir string `yaml:"outdir"`
        } `yaml:"output-dirs"`
    } `yaml:"build"`
}

func GetBuildDirs(file string) (string, string, error) {
    yfile, err := os.ReadFile(file)
    if err != nil {
        return "", "", err
    }
    data := Cbuild{}
    err = yaml.Unmarshal(yfile, &data)
    return data.Build.OutputDirs.Intdir, data.Build.OutputDirs.Outdir, err
}