We can detect improper combinations of --list and
--additional-sections/--category very soon when executing the script.
Assert in those cases. This used to be a warning.
Because of the way Python uses references for lists, the logic around
`oldFileArgs`, `newFileArgs`, and `curFiles` is difficult to follow.
Use a less efficient algorithm to find and split the elements based on
the '--' separator.
Although its performance is negligibly worse O(2n) as opposed to O(n), it's
easier to understand and uses one less imperative loop. Also, it's not as if
we'll ever encounter input that makes the performance difference
matter, so :shipit:!
Rather than manually parse the arguments passed to cmpcodesize, use the
Python stdlib. By doing so, we can eliminate a lot of redundant code.
One problem: argparse can't handle positional arguments of the string
'--', since it misinterprets them as optional arguments. We replace
that stirng with a special token.
In order to prevent the Python interpreter from running code that is
meant to be executed directly, the convention is to check the context
in which the code is being interpreted.
Add a check for the context stored in the `__name__` variable, and only
execute the cmpcodesize script if it is being run as a command-line
script (that is, `__main__`).
This script can:
*) Compare sizes of text sections (or other sections)
*) Compare sizes of function categories (Swift functions, Protocol Witnesses, Specializations, etc.)
*) Provide a detailed list or comparison of all functions
Use cmpcodesize -h to get info on the usage.
I copied the internals of Nadav's analyzeDylibSize script (Thanks!).
As the function of the analyzeDylibSize is now covered by this new script I deleted the old script.
Sorry that I implemented in ruby and not in python (I know ruby much better than python).
Swift SVN r25501