Skip to content

Do not clone common arguments multiple times #51

@CohenArthur

Description

@CohenArthur

IIUC most of the Options are common to all gccrs invocations. So

rustc --crate-type=dyn --crate-type=bin src/<file>.rs --other-flag-1 --other-flag-2

becomes

gccrs src/<file>.rs --converted-other-flag-1 --converted-other-flag-2  # bin
gccrs -shared src/<file>.rs -o libfile.so --converted-other-flag-1 --converted-other-flag-2  # shared lib

where --converted-other-flag-1 --converted-other-flag-2 are common to all invocations. So why not only store them once?

pub struct OptionsCollection {
    common_args: Vec<Arg>,
    crate_types: Vec<CrateType>,
    ... // Other fields that require multiple gccrs invocations, if any
}

I think that would make things way cleaner and would avoid saving the common options and input+output file name N times.

Maybe even:

pub struct Args {
    input_files: Vec<String/PathBuf>,
    output_file: String/PathBuf,
    common_args: Vec<Arg>,
    crate_types: Vec<CrateType>,
    ... // Other fields that require multiple gccrs invocations, if any
}

And only once you generate the gccrs commands, you will build the whole Vec<Vec> argument matrix.

Originally posted by @flip1995 in #47 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority:highHigh priority issue. Essential to the project's operation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions