a57d4b2 Automatically strip foreign dependencies

Authored and Committed by zbyszek 2 years ago
    Automatically strip foreign dependencies
    
    The basic workflow is that very similarly to how we would open an editor to do
    manual patching of Cargo.toml, we automatically rewrite the file first. In this
    automatic rewrite, for any sections like [target.cfg(…)], we evaluate the
    conditional and drop the whole section if the conditional is known to be false.
    
    When the conditional cannot be evaluated because it uses some form that we don't
    understand, it is left untouched. But it seems that the conditionals used in
    practice don't have too much variety. If parser and evaluator certainly don't
    cover all the corner cases, but it might not matter in practice. We can always
    fix them later if unsupported cases are found.
    
    Removed dependencies are filter out from [feature] lists:
    
    For example for tokio:
    [features]
    -net = ["libc", "mio/os-poll", "mio/os-ext", "mio/net", "socket2", "winapi/namedpipeapi"]
    +net = ["libc", "mio/os-poll", "mio/os-ext", "mio/net", "socket2"]
    
    If -p was used, after the automatic filtering, the editor is opened for the user
    to do further manual patching.
    
    Automatic and manual changes land in separate patches.
    
    Fixes #2.
    
        
file modified
+144 -40
file modified
+4 -1
file modified
+4 -2
file modified
+8 -4