Skip to content

Commit

Permalink
Merge pull request YosysHQ#109 from xobs/msvc-2019-fixes
Browse files Browse the repository at this point in the history
Fix building for MSVC 2019 and static Windows builds
  • Loading branch information
gatecat committed Oct 18, 2019
2 parents e2e10bf + 089efdc commit 72fe507
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
6 changes: 5 additions & 1 deletion libtrellis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ set(CMAKE_DEFIN)
set(link_param "")
if (STATIC_BUILD)
set(Boost_USE_STATIC_LIBS ON)
if (NOT APPLE)
if(MSVC)
add_definitions(-DBOOST_PYTHON_STATIC_LIB)
set(CMAKE_CXX_FLAGS_RELEASE "/MT")
set(CMAKE_CXX_FLAGS_DEBUG "/MTd")
elseif (NOT APPLE)
set(link_param "-static")
endif()
else()
Expand Down
1 change: 1 addition & 0 deletions libtrellis/src/CRAM.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "CRAM.hpp"
#include <cassert>
#include <stdexcept>

namespace Trellis {
char &CRAMView::bit(int frame, int bit) const {
Expand Down
23 changes: 21 additions & 2 deletions libtrellis/tools/ecpbram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <stdint.h>
#ifdef _WIN32
#define NOMINMAX
#include "Windows.h"
#undef NOMINMAX
#else
#include <unistd.h>
#include <sys/time.h>
#endif

#include <map>
#include <vector>
Expand Down Expand Up @@ -97,8 +103,11 @@ void parse_hexfile_line(const char *filename, int linenr, vector<vector<bool>> &
int main(int argc, char **argv)
{
bool verbose = false;
#ifdef _WIN32
uint32_t seed_nr = GetCurrentProcessId();
#else
uint32_t seed_nr = getpid();

#endif
namespace po = boost::program_options;

std::string database_folder = get_database_path();;
Expand Down Expand Up @@ -186,10 +195,20 @@ int main(int argc, char **argv)
xorshift64star();

if (!vm.count("seed")) {
#ifdef _WIN32
SYSTEMTIME system_time;
FILETIME file_time;
uint64_t time;
GetSystemTime(&system_time);
SystemTimeToFileTime(&system_time, &file_time);
x ^= uint64_t(file_time.dwLowDateTime);
x ^= uint64_t(file_time.dwHighDateTime) << 32;
#else
struct timeval tv;
gettimeofday(&tv, NULL);
x ^= uint64_t(tv.tv_sec) << 20;
x ^= uint64_t(tv.tv_usec);
#endif
}

xorshift64star();
Expand Down

0 comments on commit 72fe507

Please sign in to comment.