mirror of
https://github.com/trabucayre/openFPGALoader.git
synced 2026-08-31 10:16:11 +02:00
DATA_DIR override with environment variable (#333)
This commit is contained in:
+4
-4
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "jtag.hpp"
|
||||
#include "device.hpp"
|
||||
#include "epcq.hpp"
|
||||
@@ -181,12 +182,11 @@ bool Altera::load_bridge()
|
||||
return false;
|
||||
}
|
||||
|
||||
// DATA_DIR is defined at compile time.
|
||||
bitname = DATA_DIR "/openFPGALoader/spiOverJtag_";
|
||||
bitname = get_shell_env_var("OPENFPGALOADER_SOJ_DIR", DATA_DIR "/openFPGALoader");
|
||||
#ifdef HAS_ZLIB
|
||||
bitname += _device_package + ".rbf.gz";
|
||||
bitname += "/spiOverJtag_" + _device_package + ".rbf.gz";
|
||||
#else
|
||||
bitname += _device_package + ".rbf";
|
||||
bitname += "/spiOverJtag_" + _device_package + ".rbf";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
* Copyright (C) 2023 Gwenhael Goavec-Merou <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include "common.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
|
||||
/*!
|
||||
* \brief return shell environment variable value
|
||||
* \param[in] key: variable name
|
||||
* \return variable value or ""
|
||||
*/
|
||||
const std::string get_shell_env_var(const char* key,
|
||||
const char *def_val) noexcept {
|
||||
const char* ret = std::getenv(key);
|
||||
return std::string(ret ? ret : def_val);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
* Copyright (C) 2023 Gwenhael Goavec-Merou <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef SRC_COMMON_HPP_
|
||||
#define SRC_COMMON_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
/*!
|
||||
* \brief return shell environment variable value
|
||||
* \param[in] key: variable name
|
||||
* \param[in] def_val: value to return when not found
|
||||
* \return variable value or def_val
|
||||
*/
|
||||
const std::string get_shell_env_var(const char* key,
|
||||
const char *def_val="") noexcept;
|
||||
|
||||
#endif // SRC_COMMON_HPP_
|
||||
+3
-3
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "jtag.hpp"
|
||||
#include "bitparser.hpp"
|
||||
#include "common.hpp"
|
||||
#include "configBitstreamParser.hpp"
|
||||
#include "jedParser.hpp"
|
||||
#include "mcsParser.hpp"
|
||||
@@ -468,9 +469,8 @@ bool Xilinx::load_bridge()
|
||||
return false;
|
||||
}
|
||||
|
||||
// DATA_DIR is defined at compile time.
|
||||
bitname = DATA_DIR "/openFPGALoader/spiOverJtag_";
|
||||
bitname += _device_package + ".bit.gz";
|
||||
bitname = get_shell_env_var("OPENFPGALOADER_SOJ_DIR", DATA_DIR "/openFPGALoader");
|
||||
bitname += "/spiOverJtag_" + _device_package + ".bit.gz";
|
||||
}
|
||||
|
||||
#if defined (_WIN64) || defined (_WIN32)
|
||||
|
||||
Reference in New Issue
Block a user