# Copyright 2024 The Pigweed Authors
#
# 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
#
#     https://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.

load("@bazel_skylib//rules:native_binary.bzl", "native_binary")

def sense_host_console(name, binary, extra_args = []):
    """Create a host binary console run target

    Args:
    name: target name
    binary: target binary the console is for
    extra_args: additional arguments added to the console invocation
    """
    native_binary(
        name = name,
        src = "//tools:console",
        args = [
            # This arg lets us skip manual port selection.
            "--socket",
            "default",
            "--config-file",
            "$(rootpath //:pw_console_config)",
        ] + extra_args,
        data = [
            binary,
            "//:pw_console_config",
        ],
    )

def sense_device_console(name, binary, extra_args = []):
    """Create a device binary console run target

    Makes running a console for a binary easy, and ensures the associated binary is
    up to date (but does not flash the device).

    Args:
    name: target name
    binary: target binary the console is for
    extra_args: additional arguments added to the console invocation
    """
    native_binary(
        name = name,
        src = "//tools:console",
        args = [
            "-b",
            "115200",
            "--token-databases",
            "$(rootpath " + binary + ")",
            "--config-file",
            "$(rootpath //:pw_console_config)",
        ] + extra_args,
        data = [
            binary,
            "//:pw_console_config",
        ],
    )

def sense_device_script(name, src, binary, extra_args = []):
    """Create a device binary script run target

    Makes running a script for a binary easy, and ensures the associated binary is
    up to date (but does not flash the device).

    Args:
    name: target name
    src: script target
    binary: target binary the console is for
    extra_args: additional arguments added to the console invocation
    """
    native_binary(
        name = name,
        src = src,
        args = [
            "-b",
            "115200",
            "--token-databases",
            "$(rootpath " + binary + ")",
        ] + extra_args,
        data = [
            binary,
        ],
    )
