Skip to content

Commit

Permalink
Change scripts to restore the previous automation
Browse files Browse the repository at this point in the history
  • Loading branch information
evpo committed Feb 23, 2019
1 parent d2b9395 commit d3b5a11
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 27 deletions.
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ script:
- PATH="$QTDIR/bin:$PATH"
- qt53-env.sh
- qmake -v
- ./configure.sh --all
- ./configure.sh --back-end --debug
- ./configure.sh --tests
- ./configure.sh --run-tests
- ./configure.sh --run-func-tests --debug

- ./configure.py
- make
- ./configure.py --back-end --debug --test
- make
- ./scripts/tool.sh --run-tests
- ./scripts/tool.sh --run-func-tests --debug

addons:
apt:
sources:
Expand Down
83 changes: 80 additions & 3 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,60 @@ def execute_qmake(options):
if result != 0:
raise UserError('%s returned non zero exit code' % options.qmake_bin)

def get_botan_build_dir():
botan_dir = os.path.join('deps', 'botan')
return botan_dir

def configure_botan(options):
botan_dir = get_botan_build_dir()

# There is an option in botan to change the build directory
# Unfortunately it does not work with amalgamation
botan_build_dir = botan_dir

if not os.path.isdir(botan_build_dir):
os.mkdir(botan_build_dir)

cmd = [
sys.executable,
'./configure.py',
# '--with-build-dir', botan_build_dir,
'--cc', options.compiler,
'--cpu', options.cpu,
'--amalgamation',
'--disable-shared',
'--with-zlib',
'--enable-modules', 'aes,pbkdf2,auto_rng,compression']

logging.info('Executing: %s', ' '.join(cmd))

try:
botan_proc = subprocess.Popen(cmd, cwd = botan_dir)
result = botan_proc.wait()
except OSError as e:
raise UserError('Error while executing qmake: %s' % e)

def get_zlib_dir():
return os.path.join('deps', 'zlib')

def is_windows(options):
return options.os in ['windows','mingw']

def configure_zlib(options):
if is_windows(options):
return

zlib_dir = get_zlib_dir()
cmd = [
'./configure',
'--static']
logging.info('Executing: %s', ' '.join(cmd))
try:
zlib_proc = subprocess.Popen(cmd, cwd = zlib_dir)
result = zlib_proc.wait()
except OSError as e:
raise UserError('Error while executing qmake: %s' % e)

def process_command_line(args):
"""
Handle command line options
Expand Down Expand Up @@ -1683,8 +1737,6 @@ def configure_back_end(system_command, options):

template_vars['include_paths'] = include_paths

template_vars['botan_cxxflags'] = '$(shell pkg-config --cflags botan-2)'
template_vars['botan_ldflags'] = '$(shell pkg-config --libs botan-2)'

#qt build
template_vars['build_qt_ui'] = (not options.back_end and not options.test)
Expand All @@ -1698,8 +1750,29 @@ def configure_back_end(system_command, options):

template_vars['default_targets'] = ' '.join(default_targets)

do_io_for_build(cc, arch, osinfo, info_modules.values(), build_paths, source_paths, template_vars, options)
template_vars['build_botan'] = not options.use_system_libs
template_vars['build_zlib'] = not options.use_system_libs

if options.use_system_libs:
botan_cxxflags = '$(shell pkg-config --cflags botan-2)'
botan_ldflags = '$(shell pkg-config --libs botan-2)'
else:
botan_build_dir = get_botan_build_dir()
botan_target = os.path.join(botan_build_dir,
'botan.lib' if is_windows(options) else 'libbotan-2.a')
template_vars['botan_target'] = botan_target
template_vars['botan_build_dir'] = botan_build_dir
botan_cxxflags = '-I %s' % os.path.join('deps', 'botan', 'build', 'include')
botan_ldflags = '%s -ldl -lm' % botan_target
zlib_dir = os.path.join('deps', 'zlib')
template_vars['zlib_dir'] = zlib_dir
template_vars['zlib_target'] = os.path.join(zlib_dir, 'libz.a')


template_vars['botan_cxxflags'] = botan_cxxflags
template_vars['botan_ldflags'] = botan_ldflags

do_io_for_build(cc, arch, osinfo, info_modules.values(), build_paths, source_paths, template_vars, options)

def main(argv):
"""
Expand All @@ -1714,6 +1787,10 @@ def main(argv):
configure_back_end(argv[0], options)
if not options.back_end:
execute_qmake(options)

if not options.use_system_libs:
configure_botan(options)
configure_zlib(options)
return 0

if __name__ == '__main__':
Expand Down
File renamed without changes.
9 changes: 5 additions & 4 deletions scripts/configure.sh → scripts/tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ OPTIONS:\n\

TARGET=encryptpad
OSX_APP=EncryptPad.app
TEST_TARGET=encrypt_pad_tests
TEST_TARGET=encrypt_pad_test

if [[ $# > 3 ]] || [[ $# < 1 ]]
then
Expand All @@ -44,7 +44,7 @@ then
fi

pushd ./build >/dev/null
SUBDIR=`./get_subdir.sh`
SUBDIR=`./../scripts/get_subdir.sh`

RELEASE=on
QT_BIN_SUB=release
Expand Down Expand Up @@ -161,8 +161,9 @@ case $COMMAND in
;;
-t|--run-tests)
# Unit tests should run from tests directory because they need files the directory contains
pushd ../tests >/dev/null
../bin/debug/${TEST_TARGET}
# pushd ../src/test >/dev/null
pushd ../src/test
../../bin/debug/${TEST_TARGET}
RESULT=$?
popd >/dev/null

Expand Down
50 changes: 36 additions & 14 deletions src/build-data/makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,53 @@ SCRIPTS_DIR = scripts
BOTAN_CXXFLAGS = %{botan_cxxflags}
BOTAN_LDFLAGS = %{botan_ldflags}

%{if debug_mode}
RELEASE=
%{endif}

%{unless debug_mode}
RELEASE=on
%{endif}

# The primary target
all: %{default_targets}

# Executable targets
CLI = %{cli_exe}
TEST = %{test_exe}
TEST = %{test_exe}
LIBRARIES = %{library_target}

cli: $(CLI)
test: $(TEST)
libs: $(LIBRARIES)
zlib: $(ZLIB)

# QT UI build
QT_BUILD_DIR = %{qt_build_dir}
# Botan

%{if debug_mode}
RELEASE=
%{if build_botan}
BOTAN_TARGET = %{botan_target}
BOTAN_BUILD_DIR = %{botan_build_dir}
$(BOTAN_TARGET):
$(MAKE) -C $(BOTAN_BUILD_DIR)
%{endif}

%{unless debug_mode}
RELEASE=on
botan: $(BOTAN_TARGET)

# Zlib
%{if build_zlib}
ZLIB = %{zlib_target}
ZLIB_DIR = %{zlib_dir}
EXE_LINKS_TO += $(ZLIB)
$(ZLIB) :
$(MAKE) -C $(ZLIB_DIR) RELEASE=$(RELEASE)
%{endif}

qt_ui: libs
$(MAKE) -C $(QT_BUILD_DIR)
# QT UI build

QT_BUILD_DIR = %{qt_build_dir}

qt_ui: libs $(BOTAN_TARGET) $(ZLIB)
$(MAKE) -C $(QT_BUILD_DIR) RELEASE=$(RELEASE)

qt_ui_clean:
%{if build_qt_ui}
Expand Down Expand Up @@ -116,7 +138,7 @@ TEST_LINKS_TO = $(GTEST_TARGET_DIR)/libgtest_main.a $(GTEST_TARGET_DIR)/libgtest
# Misc targets

%{if make_supports_phony}
.PHONY = all cli libs qt_ui test qt_ui_clean test_clean clean distclean install
.PHONY = all cli libs qt_ui test botan zlib qt_ui_clean test_clean clean distclean install
%{endif}

clean: qt_ui_clean
Expand All @@ -134,12 +156,12 @@ TESTOBJS = %{join test_objs}

# Executable targets

$(CLI): $(LIBRARIES) $(CLIOBJS)
$(EXE_LINK_CMD) $(ABI_FLAGS) $(LDFLAGS) $(BOTAN_LDFLAGS) $(CLIOBJS) $(EXE_LINKS_TO) %{output_to_exe}$@
$(CLI): $(LIBRARIES) $(CLIOBJS) $(BOTAN_TARGET) $(ZLIB)
$(EXE_LINK_CMD) $(ABI_FLAGS) $(LDFLAGS) $(CLIOBJS) $(BOTAN_LDFLAGS) $(EXE_LINKS_TO) %{output_to_exe}$@
$(POST_LINK_CMD)

$(TEST): $(LIBRARIES) $(TESTOBJS) $(GTEST)
$(EXE_LINK_CMD) $(ABI_FLAGS) $(LDFLAGS) $(BOTAN_LDFLAGS) $(TESTOBJS) $(EXE_LINKS_TO) $(TEST_LINKS_TO) %{output_to_exe}$@
$(TEST): $(LIBRARIES) $(TESTOBJS) $(GTEST) $(BOTAN_TARGET) $(ZLIB)
$(EXE_LINK_CMD) $(ABI_FLAGS) $(LDFLAGS) $(TESTOBJS) $(BOTAN_LDFLAGS) $(EXE_LINKS_TO) $(TEST_LINKS_TO) %{output_to_exe}$@
$(POST_LINK_CMD)

# Library targets
Expand Down

0 comments on commit d3b5a11

Please sign in to comment.