template("install_package") {
    forward_variables_from(invoker, [ "package_file", "install_deps" ])

    action(target_name) {
        package_file = rebase_path(package_file, root_out_dir)
        sdb_args = "install $package_file"

        command = "$tizen_core/tz"
        description = "INSTALL $package_file"
        args = [
            "sdb",
            sdb_args,
        ]
        outputs = [ "$root_out_dir/install.$package_file" ]
        deps = install_deps
    }
}

template("uninstall_package") {
    forward_variables_from(invoker, [ ])

    action(target_name) {
        sdb_args = "uninstall $package_id"

        command = "$tizen_core/tz"
        description = "UNINSTALL $package_id"
        args = [
            "sdb",
            sdb_args,
        ]
        outputs = [ "$root_out_dir/uninstall.$package_id" ]
        deps = []
    }
}

template("run_package") {
    forward_variables_from(invoker, [ "exe_name", "run_deps" ])

    action(target_name) {
        sdb_args = "launch -p $package_id -e $exe_name -m run"
        if (test_build) {
            sdb_args += " -t gtest --gtest_output=xml:/tmp/$package_id.$exe_name/data/gtest_result.xml Coverage"
        }

        command = "$tizen_core/tz"
        description = "RUN $exe_name in $package_id"
        args = [
            "sdb",
            sdb_args,
        ]
        outputs = [ "$root_out_dir/launch.$package_id.$exe_name" ]
        deps = run_deps
    }
}
