From 1f7671cb3649f41a864013bf528f0a94d3229e52 Mon Sep 17 00:00:00 2001 From: Laszlo Nagy Date: Fri, 7 Feb 2020 10:48:47 +0000 Subject: [PATCH] scripts/adi_env.tcl: helper function for environment variables Ease the access of the environment variables. --- projects/scripts/adi_env.tcl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/projects/scripts/adi_env.tcl b/projects/scripts/adi_env.tcl index 7656d740c..8e8fb63d0 100644 --- a/projects/scripts/adi_env.tcl +++ b/projects/scripts/adi_env.tcl @@ -15,3 +15,17 @@ if [info exists ::env(ADI_GHDL_DIR)] { set ad_ghdl_dir [file normalize $::env(ADI_GHDL_DIR)] } + +# This helper pocedure retrieves the value of varible from environment if exists, +# other case returns the provided default value +# name - name of the environment variable +# default_value - returned vale in case environment variable does not exists +proc get_env_param {name default_value} { + if [info exists ::env($name)] { + return $::env($name) + } else { + return $default_value + } +} + +