Merge pull request #263 from gregdavill/bugfix/xilinx-flash
msys2: Fix windows paths
This commit is contained in:
commit
02424ca6cd
|
|
@ -196,6 +196,9 @@ target_link_libraries(openFPGALoader
|
|||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
# winsock provides ntohs
|
||||
target_link_libraries(openFPGALoader ws2_32)
|
||||
|
||||
target_sources(openFPGALoader PRIVATE src/pathHelper.cpp)
|
||||
list(APPEND OPENFPGALOADER_HEADERS src/pathHelper.hpp)
|
||||
endif()
|
||||
|
||||
# libusb_attach_kernel_driver is only available on Linux.
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ build() {
|
|||
-G "MSYS Makefiles" \
|
||||
-DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
|
||||
../../../..
|
||||
cmake --build .
|
||||
MSYS2_ARG_CONV_EXCL="-DDATA_DIR=" cmake --build .
|
||||
}
|
||||
|
||||
check() {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@
|
|||
#include "epcq.hpp"
|
||||
#include "progressBar.hpp"
|
||||
#include "rawParser.hpp"
|
||||
#if defined (_WIN64) || defined (_WIN32)
|
||||
#include "pathHelper.hpp"
|
||||
#endif
|
||||
|
||||
#define IDCODE 6
|
||||
#define USER0 0x0C
|
||||
|
|
@ -181,6 +184,11 @@ bool Altera::load_bridge()
|
|||
bitname += _device_package + ".rbf";
|
||||
#endif
|
||||
|
||||
#if defined (_WIN64) || defined (_WIN32)
|
||||
/* Convert relative path embedded at compile time to an absolute path */
|
||||
bitname = PathHelper::absolutePath(bitname);
|
||||
#endif
|
||||
|
||||
std::cout << "use: " << bitname << std::endl;
|
||||
|
||||
/* first: load spi over jtag */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
* Copyright (C) 2022 Greg Davill <greg.davill@gmail.com>
|
||||
*/
|
||||
|
||||
#if defined (_WIN64) || defined (_WIN32)
|
||||
#include "pathHelper.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <regex>
|
||||
|
||||
std::string PathHelper::absolutePath(std::string input_path) {
|
||||
|
||||
/* Attempt to execute cygpath */
|
||||
std::string cmd = std::string("cygpath -m " + input_path);
|
||||
|
||||
std::array<char, 128> buffer;
|
||||
std::string result;
|
||||
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"), pclose);
|
||||
if (!pipe) {
|
||||
/* If cygpath fails to run, return original path */
|
||||
return input_path;
|
||||
}
|
||||
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
|
||||
result += buffer.data();
|
||||
}
|
||||
|
||||
/* Trim trailing newline */
|
||||
static const std::regex tws{"[[:space:]]*$", std::regex_constants::extended};
|
||||
return std::regex_replace(result, tws, "");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
* Copyright (C) 2022 Greg Davill <greg.davill@gmail.com>
|
||||
*/
|
||||
|
||||
#if defined (_WIN64) || defined (_WIN32)
|
||||
#include <string>
|
||||
|
||||
class PathHelper{
|
||||
public:
|
||||
static std::string absolutePath(std::string input_path);
|
||||
};
|
||||
#endif
|
||||
|
|
@ -24,6 +24,9 @@
|
|||
#include "xilinxMapParser.hpp"
|
||||
#include "part.hpp"
|
||||
#include "progressBar.hpp"
|
||||
#if defined (_WIN64) || defined (_WIN32)
|
||||
#include "pathHelper.hpp"
|
||||
#endif
|
||||
|
||||
Xilinx::Xilinx(Jtag *jtag, const std::string &filename,
|
||||
const std::string &file_type,
|
||||
|
|
@ -323,6 +326,11 @@ bool Xilinx::load_bridge()
|
|||
std::string bitname = DATA_DIR "/openFPGALoader/spiOverJtag_";
|
||||
bitname += _device_package + ".bit.gz";
|
||||
|
||||
#if defined (_WIN64) || defined (_WIN32)
|
||||
/* Convert relative path embedded at compile time to an absolute path */
|
||||
bitname = PathHelper::absolutePath(bitname);
|
||||
#endif
|
||||
|
||||
std::cout << "use: " << bitname << std::endl;
|
||||
|
||||
/* first: load spi over jtag */
|
||||
|
|
|
|||
Loading…
Reference in New Issue