// SPDX-FileCopyrightText: 2023 CELESTIFYX Team
// SPDX-License-Identifier: GPL-3.0-or-later

use std::env::var;

fn require(key: &str) -> String {
    var(key).unwrap_or_else(|_| {
        panic!("\n\nBuild error: environment variable `{}` must be set.\n", key);
    })
}

fn main() -> () {
    println!("cargo:rerun-if-env-changed=PKG_COMMAND");
    println!("cargo:rerun-if-env-changed=PKG_REPO_LIST");
    println!("cargo:rerun-if-env-changed=PKG_INSTALLED_DB");
    println!("cargo:rerun-if-env-changed=PKG_MASK_FILE");
    println!("cargo:rerun-if-env-changed=PKG_BUILDFILE_NAME");

    println!("cargo:rustc-env=PKG_COMMAND={}", require("PKG_COMMAND"));
    println!("cargo:rustc-env=PKG_REPO_LIST={}", require("PKG_REPO_LIST"));
    println!("cargo:rustc-env=PKG_INSTALLED_DB={}", require("PKG_INSTALLED_DB"));
    println!("cargo:rustc-env=PKG_MASK_FILE={}", require("PKG_MASK_FILE"));
    println!("cargo:rustc-env=PKG_BUILDFILE_NAME={}", require("PKG_BUILDFILE_NAME"));
}
