abidw: add option to omit the compilation directory
authorMatthias Maennich <maennich@google.com>
Tue, 21 May 2019 04:39:21 +0000 (05:39 +0100)
committerDodji Seketeli <dodji@redhat.com>
Wed, 22 May 2019 12:33:45 +0000 (14:33 +0200)
commitbf9e8b94480cc8de8fb80369060c7c1e520cdf0a
tree9e94e5fafac22d89bc8a8fde5659fe62eec06b08
parentfca2661581af6412dde955a04c8291f13230fd5b
abidw: add option to omit the compilation directory

The compilation directory contains machine specific information
therefore breaks reproducibility of abidw's output across different
build paths. Hence introduce --no-comp-dir-path (as in the xml
attribute). Internally I decided to not carry on the duplication of
'dir' and 'path' and used 'comp_dir'.

Thanks to earlier changes, adding an option boils down to adding it to
set_common_options and to the write_context along with some auxiliary
functions for setting and getting.

write_translation_unit uses the flag in the write_context and omits the
comp-dir-path if asked for.

* include/abg-writer.h (set_write_comp_dir): Declare new function.
(set_common_options): Use it.
* src/abg-writer.cc (write_context::m_write_comp_dir): Define new
data member.
(write_context::write_context): Initialize it.
(write_context::{g,s}et_write_comp_dir): Define new member
accessors.
(set_write_comp_dir): Define new free-form getter.
(write_translation_unit): Teach to respect write_comp_dir flag of
write_context.
* tools/abidw.cc (options::write_corpus_path): Define new data
member.
(options::options): Initialize it.
(display_usage): Add doc string for a new command line option: --no-comp-dir-path.
(parse_command_line): Parse the new command line option --no-comp-dir-path.

Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
include/abg-writer.h
src/abg-writer.cc
tools/abidw.cc