From 8655fdfd7ffce95aa3a345c6b5984d590a371e1d Mon Sep 17 00:00:00 2001 From: Gustavo Jose de Sousa Date: Fri, 5 Feb 2016 16:09:21 +0000 Subject: [PATCH] waf: use git_submodule tool through GIT_SUBMODULES variable With this change, there's no need to verify if the submodule is initialized, because the submodules in GIT_SUBMODULES are automatically initialized and updated if necessary before the build tasks are performed. One downside of this change is that Google Benchmark configuration is now done only during build. However that is minor, since now there are easy ways to separately build different targets and program groups, so that a fail in benchmark build doesn't really affect the other targets. --- Tools/ardupilotwaf/gbenchmark.py | 22 ++-------------------- Tools/ardupilotwaf/gtest.py | 8 +------- Tools/ardupilotwaf/mavgen.py | 8 +------- wscript | 2 ++ 4 files changed, 6 insertions(+), 34 deletions(-) diff --git a/Tools/ardupilotwaf/gbenchmark.py b/Tools/ardupilotwaf/gbenchmark.py index e13f47ff75..9ce2ee1b00 100644 --- a/Tools/ardupilotwaf/gbenchmark.py +++ b/Tools/ardupilotwaf/gbenchmark.py @@ -49,13 +49,6 @@ def configure(cfg): ) return - cfg.start_msg('Checking for gbenchmark submodule') - cmake_lists = cfg.srcnode.find_resource('modules/gbenchmark/CMakeLists.txt') - if not cmake_lists: - cfg.end_msg('not initialized', color='YELLOW') - return - cfg.end_msg('yes') - cfg.find_program('cmake', mandatory=False) if not env.CMAKE: @@ -74,25 +67,18 @@ def configure(cfg): bldnode = cfg.bldnode.make_node(cfg.variant) prefix_node = bldnode.make_node('gbenchmark') my_build_node = bldnode.make_node('gbenchmark_build') - my_src_node = cfg.srcnode.find_dir('modules/gbenchmark') + my_src_node = cfg.srcnode.make_node('modules/gbenchmark') env.GBENCHMARK_PREFIX_REL = prefix_node.path_from(bldnode) env.GBENCHMARK_BUILD = my_build_node.abspath() env.GBENCHMARK_BUILD_REL = my_build_node.path_from(bldnode) env.GBENCHMARK_SRC = my_src_node.abspath() - cfg.start_msg('Configuring gbenchmark') - try: - _configure_cmake(cfg, bldnode) - cfg.end_msg('done') - except: - cfg.end_msg('failed', color='YELLOW') - return - env.INCLUDES_GBENCHMARK = [prefix_node.make_node('include').abspath()] env.LIBPATH_GBENCHMARK = [prefix_node.make_node('lib').abspath()] env.LIB_GBENCHMARK = ['benchmark'] + env.append_value('GIT_SUBMODULES', 'gbenchmark') env.HAS_GBENCHMARK = True class gbenchmark_build(Task.Task): @@ -116,10 +102,6 @@ class gbenchmark_build(Task.Task): bld = self.generator.bld cmds = [] - cmake_lists = bld.srcnode.find_resource('modules/gbenchmark/CMakeLists.txt') - if not cmake_lists: - bld.fatal('Submodule gbenchmark not initialized, please run configure again') - try: # Generate build system first, if necessary my_build_node = bld.bldnode.find_dir(self.env.GBENCHMARK_BUILD_REL) diff --git a/Tools/ardupilotwaf/gtest.py b/Tools/ardupilotwaf/gtest.py index bf4b91372a..58ed9ebc22 100644 --- a/Tools/ardupilotwaf/gtest.py +++ b/Tools/ardupilotwaf/gtest.py @@ -20,13 +20,7 @@ def configure(cfg): ) return - cfg.start_msg('Checking for gtest submodule') - readme = cfg.srcnode.find_resource('modules/gtest/README') - if not readme: - cfg.end_msg('not initialized', color='YELLOW') - return - cfg.end_msg('yes') - + cfg.env.append_value('GIT_SUBMODULES', 'gtest') cfg.env.HAS_GTEST = True @conf diff --git a/Tools/ardupilotwaf/mavgen.py b/Tools/ardupilotwaf/mavgen.py index c00b68e3e5..72cc65e31e 100644 --- a/Tools/ardupilotwaf/mavgen.py +++ b/Tools/ardupilotwaf/mavgen.py @@ -53,11 +53,5 @@ def configure(cfg): env = cfg.env - cfg.start_msg('Checking for mavgen') - if not cfg.srcnode.find_resource('modules/mavlink/pymavlink/tools/mavgen.py'): - cfg.fatal('not found, please run: git submodule init && git submodule update') - return - cfg.end_msg('yes') - - env.MAVLINK_DIR = cfg.srcnode.find_dir('modules/mavlink/').abspath() + env.MAVLINK_DIR = cfg.srcnode.make_node('modules/mavlink/').abspath() env.MAVGEN = env.MAVLINK_DIR + '/pymavlink/tools/mavgen.py' diff --git a/wscript b/wscript index 61c7152b46..aa0abf4001 100644 --- a/wscript +++ b/wscript @@ -97,6 +97,8 @@ def configure(cfg): else: cfg.end_msg('disabled', color='YELLOW') + cfg.env.append_value('GIT_SUBMODULES', 'mavlink') + cfg.env.prepend_value('INCLUDES', [ cfg.srcnode.abspath() + '/libraries/', ])