vscode: Add configurations to run the executables under the debugger
[lttng-tools.git] / .vscode / build.sh
CommitLineData
a881d7c9
JG
1#!/usr/bin/env bash
2# Copyright (C) 2024 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3#
4# SPDX-License-Identifier: LGPL-2.1-only
5#
6
7source_dir="$1"
8
9# Run make quietly to check if a Makefile exists
10make_output=$(make -C "$source_dir" -q 2>&1)
11make_exit_status=$?
12
13# Check the return status of make -q
14if [ $make_exit_status -eq 2 ]; then
15 # It seems the Makefiles don't exist. Most likely the user forgot to
16 # setup their tree.
17 echo "$make_output"
18 echo -e "\033[33mMake couldn't find a Makefile: did you run ./bootstrap and ./configure ?\033[0m"
19 exit 1
20fi
21
22# Check if compile_commands.json does not exist in the source directory and if bear is installed
23if [ ! -f "$source_dir/compile_commands.json" ] && which bear >/dev/null 2>&1; then
24 # Bear is installed and compile_commands.json is not present
25 # Perform a make clean since compile_commands.json is missing and bear is installed
26 make -C "$source_dir" clean
27
28 # Prefix bear to the make command
29 command_prefix="bear -- "
30fi
31
32# Run make with or without bear prefix, depending on the condition above
33eval "${command_prefix}"make -C "$source_dir" -j "$(nproc)"
This page took 0.023082 seconds and 4 git commands to generate.