Skip to content

Commit

Permalink
Merge GH #1318 Build improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
randombit committed Nov 29, 2017
2 parents 07bc7ad + fb3dc25 commit 93466a5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 23 deletions.
36 changes: 29 additions & 7 deletions configure.py
Expand Up @@ -268,6 +268,10 @@ def src_info(self, typ):


def make_build_doc_commands(source_paths, build_paths, options):

if options.with_documentation is False:
return ""

def build_manual_command(src_dir, dst_dir):
if options.with_sphinx:
sphinx = 'sphinx-build -c $(SPHINX_CONFIG) $(SPHINX_OPTS) '
Expand Down Expand Up @@ -448,6 +452,13 @@ def process_command_line(args): # pylint: disable=too-many-locals
build_group.add_option('--without-doxygen', action='store_false',
dest='with_doxygen', help=optparse.SUPPRESS_HELP)

build_group.add_option('--with-documentation', action='store_true',
help=optparse.SUPPRESS_HELP)

build_group.add_option('--without-documentation', action='store_false',
default=True, dest='with_documentation',
help='Skip building/installing documentation')

build_group.add_option('--maintainer-mode', dest='maintainer_mode',
action='store_true', default=False,
help="Enable extra warnings")
Expand Down Expand Up @@ -1206,10 +1217,11 @@ def gen_flags():

return (' '.join(gen_flags())).strip()

def cc_lang_flags(self):
return self.lang_flags

def cc_compile_flags(self, options):
def gen_flags():
yield self.lang_flags

if options.with_debug_info:
yield self.debug_info_flags

Expand Down Expand Up @@ -1628,12 +1640,14 @@ def _write_footer(self, fd, library_link, cli_link, tests_link):
fd.write('option(ENABLED_OPTIONAL_WARINIGS "If enabled more strict warning policy will be used" OFF)\n')
fd.write('option(ENABLED_LTO "If enabled link time optimization will be used" OFF)\n\n')

fd.write('set(COMPILER_FEATURES_RELEASE %s %s)\n'
% (self._cc.cc_compile_flags(self._options_release),
fd.write('set(COMPILER_FEATURES_RELEASE %s %s %s)\n'
% (self._cc.cc_lang_flags(),
self._cc.cc_compile_flags(self._options_release),
self._cc.mach_abi_link_flags(self._options_release)))

fd.write('set(COMPILER_FEATURES_DEBUG %s %s)\n'
% (self._cc.cc_compile_flags(self._options_debug),
fd.write('set(COMPILER_FEATURES_DEBUG %s %s %s)\n'
% (self._cc.cc_lang_flags(),
self._cc.cc_compile_flags(self._options_debug),
self._cc.mach_abi_link_flags(self._options_debug)))

fd.write('set(COMPILER_FEATURES $<$<NOT:$<CONFIG:DEBUG>>:${COMPILER_FEATURES_RELEASE}>'
Expand Down Expand Up @@ -1984,6 +1998,7 @@ def configure_command_line():
'libdir': options.libdir or osinfo.lib_dir,
'includedir': options.includedir or osinfo.header_dir,
'docdir': options.docdir or osinfo.doc_dir,
'with_documentation': options.with_documentation,

'out_dir': options.with_build_dir or os.path.curdir,
'build_dir': build_config.build_dir,
Expand Down Expand Up @@ -2018,6 +2033,7 @@ def configure_command_line():
'cxx_abi_flags': cc.mach_abi_link_flags(options),
'linker': cc.linker_name or '$(CXX)',

'cc_lang_flags': cc.cc_lang_flags(),
'cc_compile_flags': cc.cc_compile_flags(options),
'cc_warning_flags': cc.cc_warning_flags(options),

Expand Down Expand Up @@ -2948,7 +2964,7 @@ def deduce_compiler_type_from_cc_bin(cc_bin):
logging.info('Guessing target processor is a %s/%s (use --cpu to set)' % (
options.arch, options.cpu))

if options.with_sphinx is None:
if options.with_sphinx is None and options.with_documentation is True:
if have_program('sphinx-build'):
logging.info('Found sphinx-build (use --without-sphinx to disable)')
options.with_sphinx = True
Expand Down Expand Up @@ -3027,6 +3043,12 @@ def validate_options(options, info_os, info_cc, available_module_policies):
if options.build_fuzzers == 'klee' and options.os != 'llvm':
raise UserError('Building for KLEE requires targetting LLVM')

if options.with_documentation is False:
if options.with_doxygen:
raise UserError('Using --with-doxygen plus --without-documentation makes no sense')
if options.with_sphinx:
raise UserError('Using --with-sphinx plus --without-documentation makes no sense')

# Warnings
if options.os == 'windows' and options.compiler == 'gcc':
logging.warning('Detected GCC on Windows; use --os=cygwin or --os=mingw?')
Expand Down
2 changes: 1 addition & 1 deletion src/build-data/makefile/gmake_fuzzers.in
Expand Up @@ -3,7 +3,7 @@

FUZZER_LINK_CMD = %{fuzzer_link_cmd}
FUZZER_LINKS_TO = %{link_to_botan} $(LIB_LINKS_TO) %{fuzzer_libs}
FUZZER_FLAGS = $(CXXFLAGS) $(WARN_FLAGS)
FUZZER_FLAGS = $(LANG_FLAGS) $(CXXFLAGS) $(WARN_FLAGS)

%{fuzzer_build_cmds}

Expand Down
7 changes: 4 additions & 3 deletions src/build-data/makefile/header.in
Expand Up @@ -4,6 +4,7 @@ LINKER = %{linker}

PYTHON_EXE = %{python_exe}

LANG_FLAGS = %{cc_lang_flags}
CXXFLAGS = %{cc_compile_flags}
WARN_FLAGS = %{cc_warning_flags}
SO_OBJ_FLAGS = %{shared_flags}
Expand All @@ -16,9 +17,9 @@ LIB_LINKS_TO = %{link_to}
CLI_LINKS_TO = %{link_to_botan} $(LIB_LINKS_TO)
TEST_LINKS_TO = %{link_to_botan} $(LIB_LINKS_TO)

LIB_FLAGS = $(SO_OBJ_FLAGS) $(CXXFLAGS) $(WARN_FLAGS)
CLI_FLAGS = $(CXXFLAGS) $(WARN_FLAGS)
TEST_FLAGS = $(CXXFLAGS) $(WARN_FLAGS)
LIB_FLAGS = $(SO_OBJ_FLAGS) $(LANG_FLAGS) $(CXXFLAGS) $(WARN_FLAGS)
CLI_FLAGS = $(LANG_FLAGS) $(CXXFLAGS) $(WARN_FLAGS)
TEST_FLAGS = $(LANG_FLAGS) $(CXXFLAGS) $(WARN_FLAGS)

SCRIPTS_DIR = %{scripts_dir}
INSTALLED_LIB_DIR = %{prefix}/%{libdir}
Expand Down
24 changes: 12 additions & 12 deletions src/scripts/install.py
Expand Up @@ -168,9 +168,6 @@ class PercentSignTemplate(string.Template):

bin_dir = os.path.join(options.prefix, options.bindir)
lib_dir = os.path.join(options.prefix, options.libdir)
target_doc_dir = os.path.join(options.prefix,
options.docdir,
'botan-%d.%d.%d' % (ver_major, ver_minor, ver_patch))
target_include_dir = os.path.join(options.prefix,
options.includedir,
'botan-%d' % (ver_major),
Expand All @@ -182,7 +179,7 @@ class PercentSignTemplate(string.Template):
else:
app_exe = process_template('botan%{program_suffix}')

for d in [options.prefix, lib_dir, bin_dir, target_doc_dir, target_include_dir]:
for d in [options.prefix, lib_dir, bin_dir, target_include_dir]:
makedirs(prepend_destdir(d))

build_include_dir = os.path.join(options.build_dir, 'include', 'botan')
Expand Down Expand Up @@ -259,16 +256,19 @@ class PercentSignTemplate(string.Template):
for py in os.listdir(py_dir):
copy_file(os.path.join(py_dir, py), prepend_destdir(os.path.join(py_lib_path, py)))

shutil.rmtree(prepend_destdir(target_doc_dir), True)
shutil.copytree(cfg['doc_output_dir'], prepend_destdir(target_doc_dir))
if cfg['with_documentation']:
target_doc_dir = os.path.join(options.prefix, options.docdir,
'botan-%d.%d.%d' % (ver_major, ver_minor, ver_patch))

for f in [f for f in os.listdir(cfg['doc_dir']) if f.endswith('.txt')]:
copy_file(os.path.join(cfg['doc_dir'], f), prepend_destdir(os.path.join(target_doc_dir, f)))
shutil.rmtree(prepend_destdir(target_doc_dir), True)
shutil.copytree(cfg['doc_output_dir'], prepend_destdir(target_doc_dir))

copy_file(os.path.join(cfg['base_dir'], 'license.txt'),
prepend_destdir(os.path.join(target_doc_dir, 'license.txt')))
copy_file(os.path.join(cfg['base_dir'], 'news.rst'),
prepend_destdir(os.path.join(target_doc_dir, 'news.txt')))
copy_file(os.path.join(cfg['base_dir'], 'license.txt'),
prepend_destdir(os.path.join(target_doc_dir, 'license.txt')))
copy_file(os.path.join(cfg['base_dir'], 'news.rst'),
prepend_destdir(os.path.join(target_doc_dir, 'news.txt')))
for f in [f for f in os.listdir(cfg['doc_dir']) if f.endswith('.txt')]:
copy_file(os.path.join(cfg['doc_dir'], f), prepend_destdir(os.path.join(target_doc_dir, f)))

logging.info('Botan %s installation complete', cfg['version'])
return 0
Expand Down

0 comments on commit 93466a5

Please sign in to comment.