Skip to content

Add .flags() to cc::Build for passing multiple compiler flags #1465

@fiveseven-lambda

Description

@fiveseven-lambda

cc::Build has .flag() but lacks a .flags() method.

This becomes verbose when integrating with tools like llvm-config. For example:

let output = Command::new("llvm-config")
    .arg("--cxxflags")
    .output()
    .unwrap();
let flags = shell_words::split(std::str::from_utf8(&output.stdout).unwrap()).unwrap();

let mut build = cc::Build::new();
for flag in &flags {
    build.flag(flag);
}

With .flags(), this becomes simpler:

cc::Build::new().flags(&flags);

I think it is reasonable to add .flags() just like .files() method. I'm sorry if I am just missing something.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions