// Copyright 2022 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package rust

import (
	"fmt"

	"android/soong/cc"
)

const afdoFlagFormat = "-Zprofile-sample-use=%s"

type afdo struct {
	Properties cc.AfdoProperties
}

func (afdo *afdo) props() []interface{} {
	return []interface{}{&afdo.Properties}
}

func (afdo *afdo) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) {
	if ctx.Host() {
		return flags, deps
	}

	if afdo != nil && afdo.Properties.Afdo {
		if profileFile := afdo.Properties.GetAfdoProfileFile(ctx, ctx.ModuleName()); profileFile.Valid() {
			profileUseFlag := fmt.Sprintf(afdoFlagFormat, profileFile)
			flags.RustFlags = append(flags.RustFlags, profileUseFlag)

			profileFilePath := profileFile.Path()
			deps.AfdoProfiles = append(deps.AfdoProfiles, profileFilePath)
		}
	}
	return flags, deps
}
