<commit_before>extern crate gcc;

use std::path::Path;
use std::process::Command;

struct Perl {
    bin: String,
}

impl Perl {
    fn new() -> Perl {
        Perl {
            bin: std::env::var("PERL").unwrap(),
        }
    }

    fn cfg(&self, key: &str) -> String {
        let out = Command::new(&self.bin)
            .arg("-MConfig")
            .arg("-e")
            .arg(format!("print $Config::Config{{{}}}", key))
            .output()
            .unwrap();

        String::from_utf8(out.stdout).unwrap()
    }

    fn run(&self, script: &str) {
        Command::new(&self.bin)
            .arg(script)
            .status()
            .unwrap();
    }
}

fn main() {
    let perl = Perl::new();

    let prefix = perl.cfg("archlibexp");
    let perl_multi = perl.cfg("usemultiplicity");

    let perl_inc = Path::new(&prefix).join("CORE");

    perl.run("build/regen.pl");

    gcc::Config::new()
        .file("ouroboros/libouroboros.c")
        .include(&perl_inc)
        .compile("libouroboros.a");

    if perl_multi == "define" {
        println!("cargo:rustc-cfg=perl_multiplicity");
    }
}<commit_msg>Pass perl ccflags when building libouroboros.<commit_after>extern crate gcc;

use std::path::Path;
use std::process::Command;

struct Perl {
    bin: String,
}

impl Perl {
    fn new() -> Perl {
        Perl {
            bin: std::env::var("PERL").unwrap(),
        }
    }

    fn cfg(&self, key: &str) -> String {
        let out = Command::new(&self.bin)
            .arg("-MConfig")
            .arg("-e")
            .arg(format!("print $Config::Config{{{}}}", key))
            .output()
            .unwrap();

        String::from_utf8(out.stdout).unwrap()
    }

    fn run(&self, script: &str) {
        Command::new(&self.bin)
            .arg(script)
            .status()
            .unwrap();
    }
}

fn build_ouro(perl: &Perl) {
    let mut gcc = gcc::Config::new();

    let ccflags = perl.cfg("ccflags");
    for flag in ccflags.split_whitespace() {
        gcc.flag(flag);
    }

    let archlib = perl.cfg("archlibexp");
    let coreinc = Path::new(&archlib).join("CORE");
    gcc.include(&coreinc);

    gcc.file("ouroboros/libouroboros.c");
    gcc.compile("libouroboros.a");
}

fn main() {
    let perl = Perl::new();

    build_ouro(&perl);

    perl.run("build/regen.pl");

    if perl.cfg("usemultiplicity") == "define" {
        println!("cargo:rustc-cfg=perl_multiplicity");
    }
}
{'fraction_non_alphanumeric': 0.18379042161277118, 'fraction_numerical': 0.0008186655751125665, 'mean_word_length': 2.1373555840821568, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4389097', 'n_tokens_mistral': 867, 'n_tokens_neox': 840, 'n_words': 149}