Skip to content

Commit 4e47712

Browse files
authored
Merge pull request lnis-uofu#2446 from oscarcheng105/oscar_windows_support
[WIP] Minimum build for Windows support
2 parents a7cb301 + 0f6e3c3 commit 4e47712

16 files changed

Lines changed: 251 additions & 32 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ vpr/vpr
5454
node_modules
5555
package-lock.json
5656
/_*/
57+
.vs/
58+
openfpga_flow/.vs/
59+
vcpkg_installed/
60+
CMakeSettings.json

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ set_property(CACHE VTR_ASSERT_LEVEL PROPERTY STRINGS 0 1 2 3 4)
4444
#Create the project
4545
project("OpenFPGA-tool-suites" C CXX)
4646

47+
# Windows fixes
48+
if (MSVC)
49+
add_compile_definitions(
50+
NOMINMAX
51+
_CRT_SECURE_NO_WARNINGS
52+
)
53+
else()
54+
add_compile_definitions(NOMINMAX)
55+
endif()
56+
57+
4758
# Version number
4859
file (STRINGS "VERSION.md" VERSION_NUMBER)
4960
string (REPLACE "." ";" VERSION_LIST ${VERSION_NUMBER})
@@ -81,7 +92,12 @@ message(STATUS "CMAKE_OPENFPGA_WITH_INSTALLER: ${OPENFPGA_WITH_INSTALLER}")
8192
message(STATUS "CMAKE_OPENFPGA_INSTALL_DOC: ${OPENFPGA_INSTALL_DOC}")
8293

8394
# Options pass on to VTR
95+
96+
if(MSVC)
97+
set(WITH_ABC OFF CACHE BOOL "Enable building ABC in Verilog-to-Routing")
98+
else()
8499
set(WITH_ABC ON CACHE BOOL "Enable building ABC in Verilog-to-Routing")
100+
endif()
85101
set(WITH_ODIN OFF CACHE BOOL "Enable building Odin in Verilog-to-Routing")
86102
set(ODIN_DEBUG OFF CACHE BOOL "Enable building odin with debug flags in Verilog-to-Routing")
87103
set(ODIN_WARN OFF CACHE BOOL "Enable building odin with extra warning flags in Verilog-to-Routing")

cmake/modules/SwigLib.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ function(SwigLib)
8484
get_target_property(GEN_SRCS ${ARG_NAME} SOURCES)
8585

8686
foreach(GEN_SRC ${GEN_SRCS})
87-
set_source_files_properties(${GEN_SRC}
88-
PROPERTIES
89-
COMPILE_OPTIONS "-Wno-cast-qual;-Wno-missing-braces"
90-
)
87+
if(NOT MSVC)
88+
set_source_files_properties(${GEN_SRC}
89+
PROPERTIES
90+
COMPILE_OPTIONS "-Wno-cast-qual;-Wno-missing-braces"
91+
)
92+
endif()
9193
endforeach()
9294

9395
# These includes are always needed.

libs/libini/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ endif()
1616
target_include_directories(libini INTERFACE ${LIB_INCLUDE_DIRS})
1717
set_target_properties(libini PROPERTIES PREFIX "")
1818

19-
install(TARGETS libini
19+
install(DIRECTORY src/
2020
DESTINATION bin
2121
COMPONENT openfpga_package
22-
)
22+
)

libs/libopenfpgashell/CMakeLists.txt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ cmake_minimum_required(VERSION 3.9)
33
project("libopenfpgashell")
44

55
# We need readline to compile
6-
find_package(Readline REQUIRED)
6+
if(WIN32)
7+
find_package(unofficial-readline-win32 CONFIG REQUIRED)
8+
else()
9+
find_package(Readline REQUIRED)
10+
endif()
711

812
file(GLOB_RECURSE EXEC_SOURCES test/*.cpp)
913
file(GLOB_RECURSE LIB_SOURCES src/*/*.cpp)
@@ -20,11 +24,18 @@ add_library(libopenfpgashell STATIC
2024
target_include_directories(libopenfpgashell PUBLIC ${LIB_INCLUDE_DIRS})
2125
set_target_properties(libopenfpgashell PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
2226

23-
#Specify link-time dependancies
27+
# Specify link-time dependencies
2428
target_link_libraries(libopenfpgashell
2529
libopenfpgautil
26-
libvtrutil
27-
readline)
30+
libvtrutil)
31+
32+
if(WIN32)
33+
target_link_libraries(libopenfpgashell
34+
unofficial::readline-win32::readline)
35+
else()
36+
target_link_libraries(libopenfpgashell
37+
readline)
38+
endif()
2839

2940
# Create the test executable
3041
foreach(testsourcefile ${EXEC_SOURCES})

libs/libopenfpgautil/src/openfpga_digest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
* This file includes functions that handles the file outputting
33
* in OpenFPGA framework
44
*******************************************************************/
5+
#ifdef _WIN32
6+
#include <direct.h> // Windows: provides mkdir() (POSIX uses <sys/stat.h>)
7+
#endif
8+
59
#include <sys/stat.h>
610

711
#include <algorithm>

libs/libpcf/src/base/pcf_custom_command.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ vtr::Point<int> PcfCustomCommand::custom_decimal_mode_segments_range_to_int(
172172
openfpga::PortParser port_parser(
173173
range, openfpga::PORT_PARSER_SUPPORT_ALL_FORMAT, true);
174174
openfpga::BasicPort pin = port_parser.port();
175-
vtr::Point<int> range_int = {pin.get_lsb(), pin.get_msb()};
175+
vtr::Point<int> range_int = {static_cast<int>(pin.get_lsb()),
176+
static_cast<int>(pin.get_msb())};
176177
return range_int;
177178
}
178179
bool PcfCustomCommand::custom_decimal_mode_segments_valid(

openfpga/src/base/openfpga_basic.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,22 @@ int call_external_command(const Command& cmd,
8989
// Refer
9090
// https://pubs.opengroup.org/onlinepubs/009695399/functions/waitpid.html
9191
int status = system(cmd_ss.c_str());
92+
93+
#ifdef _WIN32
94+
// On Windows, system() returns the command exit code directly.
95+
// Becareful if the final status is 2 or beyond, program will not error
96+
// as it is treated as CMD_EXEC_MINOR_ERROR
97+
return status;
98+
#else
9299
if (WIFEXITED(status)) {
93100
// This is normal program exit, WEXITSTATUS() will help you shift the status
94101
// accordingly (status >> 8)
95102
// Becareful if the final status is 2 or beyond, program will not error
96103
// as it is treated as CMD_EXEC_MINOR_ERROR
97104
return WEXITSTATUS(status);
98105
}
106+
#endif
107+
99108
// Program maybe terminated because of various killed or stopped signal
100109
return CMD_EXEC_FATAL_ERROR;
101110
}

openfpga/src/base/openfpga_bitstream_command_template.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#ifndef OPENFPGA_BITSTREAM_COMMAND_TEMPLATE_H
22
#define OPENFPGA_BITSTREAM_COMMAND_TEMPLATE_H
3+
4+
#include "openfpga_windows_compatibility.h"
5+
36
/********************************************************************
47
* Add commands to the OpenFPGA shell interface,
58
* in purpose of generate Verilog netlists modeling the full FPGA fabric

openfpga/src/base/openfpga_sdc_command_template.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#ifndef OPENFPGA_SDC_COMMAND_TEMPLATE_H
22
#define OPENFPGA_SDC_COMMAND_TEMPLATE_H
3+
4+
#include "openfpga_windows_compatibility.h"
5+
36
/********************************************************************
47
* Add commands to the OpenFPGA shell interface,
58
* in purpose of generate SDC files

0 commit comments

Comments
 (0)