<commit_before>// Build mcuboot as a library, based on the requested features.

extern crate cc;

use std::env;
use std::fs;
use std::io;
use std::path::Path;

fn main() {
    // Feature flags.
    let sig_rsa = env::var("CARGO_FEATURE_SIG_RSA").is_ok();
    let sig_ecdsa = env::var("CARGO_FEATURE_SIG_ECDSA").is_ok();
    let overwrite_only = env::var("CARGO_FEATURE_OVERWRITE_ONLY").is_ok();
    let validate_slot0 = env::var("CARGO_FEATURE_VALIDATE_SLOT0").is_ok();
    let enc_rsa = env::var("CARGO_FEATURE_ENC_RSA").is_ok();
    let enc_kw = env::var("CARGO_FEATURE_ENC_KW").is_ok();

    let mut conf = cc::Build::new();
    conf.define("__BOOTSIM__", None);
    conf.define("MCUBOOT_USE_FLASH_AREA_GET_SECTORS", None);
    conf.define("MCUBOOT_HAVE_ASSERT_H", None);
    conf.define("MCUBOOT_MAX_IMG_SECTORS", Some("128"));

    if validate_slot0 {
        conf.define("MCUBOOT_VALIDATE_SLOT0", None);
    }

    // Currently, mbed TLS cannot build with both RSA and ECDSA.
    if sig_rsa && sig_ecdsa {
        panic!("mcuboot does not support RSA and ECDSA at the same time");
    }

    if sig_rsa {
        conf.define("MCUBOOT_SIGN_RSA", None);
        conf.define("MCUBOOT_USE_MBED_TLS", None);

        conf.include("mbedtls/include");
        conf.file("mbedtls/library/sha256.c");
        conf.file("csupport/keys.c");

        conf.file("mbedtls/library/rsa.c");
        conf.file("mbedtls/library/bignum.c");
        conf.file("mbedtls/library/platform.c");
        conf.file("mbedtls/library/platform_util.c");
        conf.file("mbedtls/library/asn1parse.c");
    } else if sig_ecdsa {
        conf.define("MCUBOOT_SIGN_EC256", None);
        conf.define("MCUBOOT_USE_TINYCRYPT", None);<commit_msg>Enable bootutil logging in simulator<commit_after>// Build mcuboot as a library, based on the requested features.

extern crate cc;

use std::env;
use std::fs;
use std::io;
use std::path::Path;

fn main() {
    // Feature flags.
    let sig_rsa = env::var("CARGO_FEATURE_SIG_RSA").is_ok();
    let sig_ecdsa = env::var("CARGO_FEATURE_SIG_ECDSA").is_ok();
    let overwrite_only = env::var("CARGO_FEATURE_OVERWRITE_ONLY").is_ok();
    let validate_slot0 = env::var("CARGO_FEATURE_VALIDATE_SLOT0").is_ok();
    let enc_rsa = env::var("CARGO_FEATURE_ENC_RSA").is_ok();
    let enc_kw = env::var("CARGO_FEATURE_ENC_KW").is_ok();

    let mut conf = cc::Build::new();
    conf.define("__BOOTSIM__", None);
    conf.define("MCUBOOT_HAVE_LOGGING", None);
    conf.define("MCUBOOT_USE_FLASH_AREA_GET_SECTORS", None);
    conf.define("MCUBOOT_HAVE_ASSERT_H", None);
    conf.define("MCUBOOT_MAX_IMG_SECTORS", Some("128"));

    if validate_slot0 {
        conf.define("MCUBOOT_VALIDATE_SLOT0", None);
    }

    // Currently, mbed TLS cannot build with both RSA and ECDSA.
    if sig_rsa && sig_ecdsa {
        panic!("mcuboot does not support RSA and ECDSA at the same time");
    }

    if sig_rsa {
        conf.define("MCUBOOT_SIGN_RSA", None);
        conf.define("MCUBOOT_USE_MBED_TLS", None);

        conf.include("mbedtls/include");
        conf.file("mbedtls/library/sha256.c");
        conf.file("csupport/keys.c");

        conf.file("mbedtls/library/rsa.c");
        conf.file("mbedtls/library/bignum.c");
        conf.file("mbedtls/library/platform.c");
        conf.file("mbedtls/library/platform_util.c");
        conf.file("mbedtls/library/asn1parse.c");
    } else if sig_ecdsa {
        conf.define("MCUBOOT_SIGN_EC256", None);
        conf.define("MCUBOOT_USE_TINYCRYPT", None);
{'fraction_non_alphanumeric': 0.1485176738882554, 'fraction_numerical': 0.00798175598631699, 'mean_word_length': 3.6415343915343916, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6685187', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1302, 'n_words': 217}