Building using MSVC works
This commit is contained in:
parent
c9d1bce859
commit
b96727549c
@ -126,9 +126,10 @@ set(CMAKE_BUILD_TYPE Release)
|
||||
if(MINGW)
|
||||
add_definitions("-Wa,-mbig-obj")
|
||||
endif(MINGW)
|
||||
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /DNDEBUG /O2 /MT")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Od /MTd")
|
||||
endif()
|
||||
|
||||
foreach (family ${FAMILIES})
|
||||
|
@ -124,8 +124,16 @@ PortPin Arch::portPinFromId(IdString type) const
|
||||
|
||||
static const ChipInfoPOD *get_chip_info(const RelPtr<ChipInfoPOD> *ptr) { return ptr->get(); }
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
void load_chipdb();
|
||||
#endif
|
||||
|
||||
Arch::Arch(ArchArgs args) : args(args)
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
load_chipdb();
|
||||
#endif
|
||||
|
||||
#ifdef ICE40_HX1K_ONLY
|
||||
if (args.type == ArchArgs::HX1K) {
|
||||
chip_info = get_chip_info(reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_1k));
|
||||
|
@ -185,10 +185,17 @@ struct ChipInfoPOD
|
||||
RelPtr<PackageInfoPOD> packages_data;
|
||||
});
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
extern const char* chipdb_blob_384;
|
||||
extern const char* chipdb_blob_1k;
|
||||
extern const char* chipdb_blob_5k;
|
||||
extern const char* chipdb_blob_8k;
|
||||
#else
|
||||
extern const char chipdb_blob_384[];
|
||||
extern const char chipdb_blob_1k[];
|
||||
extern const char chipdb_blob_5k[];
|
||||
extern const char chipdb_blob_8k[];
|
||||
#endif
|
||||
|
||||
/************************ End of chipdb section. ************************/
|
||||
|
||||
|
@ -8,13 +8,32 @@ else()
|
||||
endif()
|
||||
|
||||
set(DB_PY ${CMAKE_CURRENT_SOURCE_DIR}/ice40/chipdb.py)
|
||||
|
||||
set(ICEBOX_ROOT "/usr/local/share/icebox" CACHE STRING "icebox location root")
|
||||
file(MAKE_DIRECTORY ice40/chipdbs/)
|
||||
add_library(ice40_chipdb OBJECT ice40/chipdbs/)
|
||||
target_compile_options(ice40_chipdb PRIVATE -g0 -O0 -w)
|
||||
target_compile_definitions(ice40_chipdb PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family})
|
||||
target_include_directories(ice40_chipdb PRIVATE ${family}/)
|
||||
set(ICEBOX_ROOT "/usr/local/share/icebox" CACHE STRING "icebox location root")
|
||||
foreach (dev ${devices})
|
||||
if (MSVC)
|
||||
target_sources(ice40_chipdb PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ice40/resource/embed.cc)
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ice40/resources/chipdb.rc PROPERTIES LANGUAGE RC)
|
||||
foreach (dev ${devices})
|
||||
set(DEV_TXT_DB ${ICEBOX_ROOT}/chipdb-${dev}.txt)
|
||||
set(DEV_CC_DB ${CMAKE_CURRENT_SOURCE_DIR}/ice40/chipdbs/chipdb-${dev}.bin)
|
||||
set(DEV_PORTS_INC ${CMAKE_CURRENT_SOURCE_DIR}/ice40/portpins.inc)
|
||||
add_custom_command(OUTPUT ${DEV_CC_DB}
|
||||
COMMAND python3 ${DB_PY} -b -p ${DEV_PORTS_INC} ${DEV_TXT_DB} > ${DEV_CC_DB}
|
||||
DEPENDS ${DEV_TXT_DB} ${DB_PY}
|
||||
)
|
||||
target_sources(ice40_chipdb PRIVATE ${DEV_CC_DB})
|
||||
set_source_files_properties(${DEV_CC_DB} PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
foreach (target ${family_targets})
|
||||
target_sources(${target} PRIVATE $<TARGET_OBJECTS:ice40_chipdb> ${CMAKE_CURRENT_SOURCE_DIR}/ice40/resource/chipdb.rc)
|
||||
endforeach (target)
|
||||
endforeach (dev)
|
||||
else()
|
||||
target_compile_options(ice40_chipdb PRIVATE -g0 -O0 -w)
|
||||
foreach (dev ${devices})
|
||||
set(DEV_TXT_DB ${ICEBOX_ROOT}/chipdb-${dev}.txt)
|
||||
set(DEV_CC_DB ${CMAKE_CURRENT_SOURCE_DIR}/ice40/chipdbs/chipdb-${dev}.cc)
|
||||
set(DEV_PORTS_INC ${CMAKE_CURRENT_SOURCE_DIR}/ice40/portpins.inc)
|
||||
@ -27,4 +46,5 @@ foreach (dev ${devices})
|
||||
foreach (target ${family_targets})
|
||||
target_sources(${target} PRIVATE $<TARGET_OBJECTS:ice40_chipdb>)
|
||||
endforeach (target)
|
||||
endforeach (dev)
|
||||
endforeach (dev)
|
||||
endif()
|
||||
|
6
ice40/resource/chipdb.rc
Normal file
6
ice40/resource/chipdb.rc
Normal file
@ -0,0 +1,6 @@
|
||||
#include "resource.h"
|
||||
|
||||
IDR_CHIPDB_384 BINARYFILE "..\chipdbs\chipdb-384.bin"
|
||||
IDR_CHIPDB_1K BINARYFILE "..\chipdbs\chipdb-1k.bin"
|
||||
IDR_CHIPDB_5K BINARYFILE "..\chipdbs\chipdb-5k.bin"
|
||||
IDR_CHIPDB_8K BINARYFILE "..\chipdbs\chipdb-8k.bin"
|
31
ice40/resource/embed.cc
Normal file
31
ice40/resource/embed.cc
Normal file
@ -0,0 +1,31 @@
|
||||
#include <windows.h>
|
||||
#include <cstdio>
|
||||
#include "nextpnr.h"
|
||||
#include "resource.h"
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
const char* chipdb_blob_384;
|
||||
const char* chipdb_blob_1k;
|
||||
const char* chipdb_blob_5k;
|
||||
const char* chipdb_blob_8k;
|
||||
|
||||
const char* LoadFileInResource(int name, int type, DWORD& size)
|
||||
{
|
||||
HMODULE handle = ::GetModuleHandle(NULL);
|
||||
HRSRC rc = ::FindResource(handle, MAKEINTRESOURCE(name),
|
||||
MAKEINTRESOURCE(type));
|
||||
HGLOBAL rcData = ::LoadResource(handle, rc);
|
||||
size = ::SizeofResource(handle, rc);
|
||||
return static_cast<const char*>(::LockResource(rcData));
|
||||
}
|
||||
void load_chipdb()
|
||||
{
|
||||
DWORD size = 0;
|
||||
chipdb_blob_384 = LoadFileInResource(IDR_CHIPDB_384, BINARYFILE, size);
|
||||
chipdb_blob_1k = LoadFileInResource(IDR_CHIPDB_1K, BINARYFILE, size);
|
||||
chipdb_blob_5k = LoadFileInResource(IDR_CHIPDB_5K, BINARYFILE, size);
|
||||
chipdb_blob_8k = LoadFileInResource(IDR_CHIPDB_8K, BINARYFILE, size);
|
||||
}
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
5
ice40/resource/resource.h
Normal file
5
ice40/resource/resource.h
Normal file
@ -0,0 +1,5 @@
|
||||
#define BINARYFILE 256
|
||||
#define IDR_CHIPDB_384 101
|
||||
#define IDR_CHIPDB_1K 102
|
||||
#define IDR_CHIPDB_5K 103
|
||||
#define IDR_CHIPDB_8K 104
|
Loading…
Reference in New Issue
Block a user