@@ -30,18 +30,18 @@ usage: $0 [OPTIONS]
3030
3131OPTIONS:
3232 -cmake='-<key>=<value> [-<key>=<value> ...]' User defined cmake options
33- Note: use single quote after
34- -cmake= and double quotes if
35- <key> has multiple <values>
36- e.g.: -cmake='-DFLAGS="-a -b"'
37- -compiler=COMPILER_NAME Compiler name: gcc or clang
38- Default: gcc
33+ Note: use single quote after
34+ -cmake= and double quotes if
35+ <key> has multiple <values>
36+ e.g.: -cmake='-DFLAGS="-a -b"'
37+ -compiler=COMPILER_NAME Compiler name: gcc or clang
38+ Default: gcc
3939 -no-warnings
4040 Compiler warnings are
4141 considered errors, i.e.,
4242 use -Werror flag during build.
4343 -dir=PATH Path to store build files.
44- Default: ./build
44+ Default: ./build
4545 -coverage Enable cmake coverage options
4646 -clean Remove build dir before compile
4747 -no-gui Disable GUI support
@@ -50,16 +50,16 @@ OPTIONS:
5050 -cpp20 Use C++20 standard
5151 -build-man Build Man Pages (optional)
5252 -threads=NUM_THREADS Number of threads to use during
53- compile. Default: \` nproc\` on linux
54- or \` sysctl -n hw.logicalcpu\` on macOS
53+ compile. Default: \` nproc\` on linux
54+ or \` sysctl -n hw.logicalcpu\` on macOS
5555 -keep-log Keep a compile log in build dir
5656 -help Shows this message
5757 -gpu Enable GPU to accelerate the process
5858 -deps-prefixes-file=FILE File with CMake packages roots,
59- its content extends -cmake argument.
60- By default, "openroad_deps_prefixes.txt"
61- file from OpenROAD's "etc" directory
62- or from system "/etc".
59+ its content extends -cmake argument.
60+ By default, "openroad_deps_prefixes.txt"
61+ file from OpenROAD's "etc" directory
62+ or from system "/etc".
6363
6464EOF
6565 exit " ${1:- 1} "
@@ -206,6 +206,57 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
206206 export CMAKE_PREFIX_PATH=$( brew --prefix or-tools)
207207fi
208208
209+ # ==============================================================================
210+ # PRE-COMPILATION SYSTEM CHECKS
211+ # ==============================================================================
212+ if [[ -t 1 ]]; then
213+ RED=$( tput setaf 1)
214+ GREEN=$( tput setaf 2)
215+ YELLOW=$( tput setaf 3)
216+ NC=$( tput sgr0) # No Color
217+ else
218+ RED=' '
219+ GREEN=' '
220+ YELLOW=' '
221+ NC=' '
222+ fi
223+
224+ echo -e " ${YELLOW} Running pre-compilation system checks...${NC} "
225+
226+ check_command () {
227+ if ! command -v " $1 " & > /dev/null; then
228+ echo -e " ${RED} [ERROR] Required dependency '$1 ' is missing!${NC} "
229+ echo " Please install it using 'sudo ./etc/DependencyInstaller.sh' before building."
230+ exit 1
231+ else
232+ echo -e " ${GREEN} [OK] Found $1 ${NC} "
233+ fi
234+ }
235+
236+ # Essential build tools required for OpenROAD
237+ check_command " cmake"
238+ check_command " bison"
239+ check_command " flex"
240+ check_command " swig"
241+
242+ # Compiler check based on user selection
243+ if [[ " ${compiler:- gcc} " == " gcc" ]]; then
244+ check_command " gcc"
245+ check_command " g++"
246+ elif [[ " ${compiler} " == " clang" ]]; then
247+ check_command " clang"
248+ check_command " clang++"
249+ elif [[ " ${compiler} " == " clang-16" ]]; then
250+ check_command " clang-16"
251+ check_command " clang++-16"
252+ else
253+ # Handle unknown compilers gracefully - suggested by gemini-bot
254+ echo -e " ${YELLOW} [WARNING] Unsupported compiler '${compiler} ' specified. Skipping compiler pre-compilation check.${NC} "
255+ fi
256+
257+ echo -e " ${GREEN} All pre-compilation checks passed! Proceeding...${NC} \n"
258+ # ==============================================================================
259+
209260echo " [INFO] Using ${numThreads} threads."
210261if [[ " $isNinja " == " yes" ]]; then
211262 eval cmake " ${cmakeOptions} " -B " ${buildDir} " .
@@ -214,4 +265,4 @@ if [[ "$isNinja" == "yes" ]]; then
214265 exit 0
215266fi
216267eval cmake " ${cmakeOptions} " -B " ${buildDir} " .
217- eval time cmake --build " ${buildDir} " -j " ${numThreads} "
268+ eval time cmake --build " ${buildDir} " -j " ${numThreads} "
0 commit comments