From 4a3c029c1909e258a73fe5b2b1b2bde6a6fc2ceb Mon Sep 17 00:00:00 2001 From: Matej Ferencevic Date: Sun, 30 Jul 2017 10:58:19 +0200 Subject: [PATCH] Created debug and release build scripts. Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D609 --- tools/apollo/build_debug | 24 ++++++++++++++++++++++ tools/{apollo_build => apollo/build_diff} | 6 +++--- tools/apollo/build_release | 17 +++++++++++++++ tools/apollo/cppcheck | 16 +++++++++++++-- tools/{apollo_generate => apollo/generate} | 17 +++++++++++---- 5 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 tools/apollo/build_debug rename tools/{apollo_build => apollo/build_diff} (93%) create mode 100644 tools/apollo/build_release rename tools/{apollo_generate => apollo/generate} (94%) diff --git a/tools/apollo/build_debug b/tools/apollo/build_debug new file mode 100644 index 000000000..c7914a49d --- /dev/null +++ b/tools/apollo/build_debug @@ -0,0 +1,24 @@ +# WARNING: do not run this script without defining THREADS! +# If THREADS isn't defined then this script will call 'make -j'. +# From the manpage: "If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously." +# That means that the whole build will be started simultaneously and IT WILL CRASH YOUR COMPUTER! + +cd ../.. + +TIMEOUT=600 ./init +bash -c "doxygen Doxyfile >/dev/null 2>/dev/null" + +cd build +cmake .. +TIMEOUT=1000 make -j$THREADS + +cd .. +mkdir build_release +cd build_release + +cmake -DCMAKE_BUILD_TYPE=release .. +TIMEOUT=1000 make -j$THREADS memgraph_link_target + +cd ../tools/apollo + +./generate debug diff --git a/tools/apollo_build b/tools/apollo/build_diff similarity index 93% rename from tools/apollo_build rename to tools/apollo/build_diff index 54d23b1ab..2ec14464a 100644 --- a/tools/apollo_build +++ b/tools/apollo/build_diff @@ -3,7 +3,7 @@ # From the manpage: "If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously." # That means that the whole build will be started simultaneously and IT WILL CRASH YOUR COMPUTER! -cd .. +cd ../.. TIMEOUT=600 ./init bash -c "doxygen Doxyfile >/dev/null 2>/dev/null" @@ -19,6 +19,6 @@ cd build_release cmake -DCMAKE_BUILD_TYPE=release .. TIMEOUT=1000 make -j$THREADS memgraph_link_target -cd ../tools +cd ../tools/apollo -./apollo_generate +./generate diff diff --git a/tools/apollo/build_release b/tools/apollo/build_release new file mode 100644 index 000000000..558d673fe --- /dev/null +++ b/tools/apollo/build_release @@ -0,0 +1,17 @@ +# WARNING: do not run this script without defining THREADS! +# If THREADS isn't defined then this script will call 'make -j'. +# From the manpage: "If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously." +# That means that the whole build will be started simultaneously and IT WILL CRASH YOUR COMPUTER! + +cd ../.. + +TIMEOUT=600 ./init +bash -c "doxygen Doxyfile >/dev/null 2>/dev/null" + +cd build +cmake -DCMAKE_BUILD_TYPE=release .. +TIMEOUT=1000 make -j$THREADS + +cd ../tools/apollo + +./generate release diff --git a/tools/apollo/cppcheck b/tools/apollo/cppcheck index daec18b2a..e61d63ed6 100755 --- a/tools/apollo/cppcheck +++ b/tools/apollo/cppcheck @@ -5,8 +5,20 @@ cd "$DIR/../../" errfile="$DIR/.cppcheck_errors" -files=$( git diff --name-only HEAD~1 HEAD | egrep '^(src|tests|poc)' | egrep '.(hpp|h|cpp)$' ) -cppcheck --enable=all --force --suppress=missingInclude -Isrc $files 2>"$errfile" +if [ "$1" == "" ]; then + mode=diff +else + mode=$1 +fi + +if [ "$mode" == diff ]; then + files=$( git diff --name-only HEAD~1 HEAD | egrep '^(src|tests|poc)' | egrep '.(hpp|h|cpp)$' ) + flags="" +else + files=src/ + flags="-j$THREADS" +fi +cppcheck --enable=all --force --suppress=missingInclude $flags -Isrc $files 2>"$errfile" cat "$errfile" >&2 diff --git a/tools/apollo_generate b/tools/apollo/generate similarity index 94% rename from tools/apollo_generate rename to tools/apollo/generate index e46cc7d1c..547f8a743 100755 --- a/tools/apollo_generate +++ b/tools/apollo/generate @@ -25,8 +25,8 @@ sys.stderr = UnbufferedFile(sys.stderr) # paths SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) -BASE_DIR = os.path.join(*os.path.split(SCRIPT_DIR)[:-1]) -WORKSPACE_DIR = os.path.join(*os.path.split(BASE_DIR)[:-1]) +BASE_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, "..", "..")) +WORKSPACE_DIR = os.path.normpath(os.path.join(BASE_DIR, "..")) BASE_DIR_NAME = os.path.basename(BASE_DIR) BUILD_DIR = os.path.join(BASE_DIR, "build") TESTS_DIR = os.path.join(BUILD_DIR, "tests") @@ -36,6 +36,12 @@ OUTPUT_DIR = os.path.join(BUILD_DIR, "apollo") ARCHIVES = [] RUNS = [] +# generation mode +if len(sys.argv) >= 2: + mode = sys.argv[1] +else: + mode = "diff" + # helper functions def run_cmd(cmd, cwd): ret = subprocess.run(cmd, cwd = cwd, stdout = subprocess.PIPE, check = True) @@ -99,7 +105,7 @@ check_dirs = list(map(lambda x: os.path.join(BASE_DIR, x), ["src", "tests", archive = create_archive("cppcheck", check_dirs, WORKSPACE_DIR) cmd = os.path.relpath(cppcheck, WORKSPACE_DIR) outfile_paths = "\./" + cmd.replace("cppcheck", ".cppcheck_errors").replace(".", "\\.") -RUNS.append(generate_run("cppcheck", commands = './{}'.format(cmd), +RUNS.append(generate_run("cppcheck", commands = './{} {}'.format(cmd, mode), infile = archive, outfile_paths = outfile_paths)) # ctest tests @@ -173,7 +179,10 @@ RUNS.append(generate_run("quality_assurance", commands = commands, BASE_DIR_NAME))) # macro benchmark tests -BUILD_RELEASE_DIR = os.path.join(BASE_DIR, "build_release") +if mode == "release": + BUILD_RELEASE_DIR = os.path.join(BASE_DIR, "build") +else: + BUILD_RELEASE_DIR = os.path.join(BASE_DIR, "build_release") binary_release_name = run_cmd(["find", ".", "-maxdepth", "1", "-executable", "-type", "f", "-name", "memgraph*"], BUILD_RELEASE_DIR).split("\n")[0][2:] binary_release_path = os.path.join(BUILD_RELEASE_DIR, binary_release_name)