Skip to content

Commit 2d82a9d

Browse files
committed
fix: dev: address toolchain requirement changes
* use more specific if check for windows includes * add missing win32 link library * try forcing no-dirent on mingw/win32 * add pragmas to expose Io_MvLoadFileBz2 used in cmd.c Signed-off-by: Stephen L Arnold <[email protected]>
1 parent eb45ee9 commit 2d82a9d

File tree

3 files changed

+109
-103
lines changed

3 files changed

+109
-103
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ target_include_directories(
132132
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
133133
)
134134

135-
target_link_libraries(abc_interface INTERFACE ${CMAKE_DL_LIBS})
135+
if(MINGW)
136+
target_link_libraries(abc_interface INTERFACE ${CMAKE_DL_LIBS} shlwapi)
137+
else()
138+
target_link_libraries(abc_interface INTERFACE ${CMAKE_DL_LIBS})
139+
endif()
136140

137141
if(NOT ABC_USE_NO_CUDD)
138142
message(STATUS "Compiling with CUDD")

src/base/cmd/cmd.c

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Synopsis [Command file.]
1010
1111
Author [Alan Mishchenko]
12-
12+
1313
Affiliation [UC Berkeley]
1414
1515
Date [Ver. 1.0. Started - June 20, 2005.]
@@ -18,11 +18,11 @@
1818
1919
***********************************************************************/
2020

21-
#ifdef WIN32
21+
#if defined(WIN32) || defined(__MINGW32__)
2222
#include <process.h>
2323
#else
24-
#include <unistd.h>
2524
#include <dirent.h>
25+
#include <unistd.h>
2626
#endif
2727

2828
#include "base/abc/abc.h"
@@ -50,7 +50,7 @@ static int CmdCommandUnsetVariable ( Abc_Frame_t * pAbc, int argc, char ** argv
5050
static int CmdCommandUndo ( Abc_Frame_t * pAbc, int argc, char ** argv );
5151
static int CmdCommandRecall ( Abc_Frame_t * pAbc, int argc, char ** argv );
5252
static int CmdCommandEmpty ( Abc_Frame_t * pAbc, int argc, char ** argv );
53-
#if defined(WIN32) && !defined(__cplusplus)
53+
#if defined(WIN32) || defined(__MINGW32__)
5454
static int CmdCommandScanDir ( Abc_Frame_t * pAbc, int argc, char ** argv );
5555
static int CmdCommandRenameFiles ( Abc_Frame_t * pAbc, int argc, char ** argv );
5656
static int CmdCommandLs ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -103,7 +103,7 @@ void Cmd_Init( Abc_Frame_t * pAbc )
103103
Cmd_CommandAdd( pAbc, "Basic", "undo", CmdCommandUndo, 0 );
104104
Cmd_CommandAdd( pAbc, "Basic", "recall", CmdCommandRecall, 0 );
105105
Cmd_CommandAdd( pAbc, "Basic", "empty", CmdCommandEmpty, 0 );
106-
#if defined(WIN32) && !defined(__cplusplus)
106+
#if defined(WIN32) || defined(__MINGW32__)
107107
Cmd_CommandAdd( pAbc, "Basic", "scandir", CmdCommandScanDir, 0 );
108108
Cmd_CommandAdd( pAbc, "Basic", "renamefiles", CmdCommandRenameFiles, 0 );
109109
Cmd_CommandAdd( pAbc, "Basic", "ls", CmdCommandLs, 0 );
@@ -1148,7 +1148,7 @@ int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
11481148
#endif
11491149

11501150

1151-
#if defined(WIN32) && !defined(__cplusplus)
1151+
#if defined(WIN32) || defined(__MINGW32__)
11521152
#include <direct.h>
11531153
#include <io.h>
11541154

@@ -1335,6 +1335,7 @@ int CmfFindNumber( char * pName )
13351335
void CnfDupFileUnzip( char * pOldName )
13361336
{
13371337
extern char * Io_MvLoadFileBz2( char * pFileName, int * pnFileSize );
1338+
13381339
char pNewName[1000];
13391340
FILE * pFile;
13401341
int nFileSize;
@@ -1836,7 +1837,7 @@ int CmdCommandScrGen( Abc_Frame_t * pAbc, int argc, char **argv )
18361837

18371838
#else
18381839

1839-
Vec_Ptr_t * CmdReturnFileNames( char * pDirStr )
1840+
Vec_Ptr_t * CmdReturnFileNames( char * pDirStr )
18401841
{
18411842
Vec_Ptr_t * vRes = Vec_PtrAlloc( 100 );
18421843
struct dirent **namelist;
@@ -1848,7 +1849,7 @@ Vec_Ptr_t * CmdReturnFileNames( char * pDirStr )
18481849
for (int i = 0; i < num_files; i++) {
18491850
char * pExt = strstr(namelist[i]->d_name, ".");
18501851
if ( !pExt || !strcmp(pExt, ".") || !strcmp(pExt, "..") || !strcmp(pExt, ".s") || !strcmp(pExt, ".txt") )
1851-
continue;
1852+
continue;
18521853
Vec_PtrPush( vRes, Abc_UtilStrsav(namelist[i]->d_name) );
18531854
free(namelist[i]);
18541855
}
@@ -1864,7 +1865,7 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
18641865
char * pDirStr = (char *)".";
18651866
char * pComStr = (char *)"ps";
18661867
char * pWriteStr = NULL;
1867-
char * pWriteExt = NULL;
1868+
char * pWriteExt = NULL;
18681869
char Line[2000], * pName;
18691870
int nFileNameMax;
18701871
int fBatch = 0;
@@ -1919,7 +1920,7 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
19191920
}
19201921
pWriteExt = argv[globalUtilOptind];
19211922
globalUtilOptind++;
1922-
break;
1923+
break;
19231924
case 'b':
19241925
fBatch ^= 1;
19251926
break;
@@ -1949,8 +1950,8 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
19491950
int fAndSpace = pComStr[0] == '&';
19501951
fprintf( pFile, "# Script file produced by ABC on %s\n", Extra_TimeStamp() );
19511952
fprintf( pFile, "# Command line was: scrgen -F %s -D %s -C \"%s\"%s%s%s%s\n",
1952-
pFileStr, pDirStr, pComStr,
1953-
pWriteStr?" -W ":"", pWriteStr?pWriteStr:"",
1953+
pFileStr, pDirStr, pComStr,
1954+
pWriteStr?" -W ":"", pWriteStr?pWriteStr:"",
19541955
pWriteExt?" -E ":"", pWriteExt?pWriteExt:"" );
19551956
Vec_PtrForEachEntry( char *, vNames, pName, k ) {
19561957
char * pExt = strstr(pName, ".");
@@ -1988,7 +1989,7 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
19881989
fprintf( pAbc->Err, "\t-C str : the sequence of commands to run [default = \"ps\"]\n" );
19891990
fprintf( pAbc->Err, "\t-W str : the directory to write the resulting files [default = no writing]\n" );
19901991
fprintf( pAbc->Err, "\t-E str : the output files extension (with \".\") [default = the same as input files]\n" );
1991-
fprintf( pAbc->Err, "\t-b : toggles adding batch mode support [default = %s]\n", fBatch? "yes": "no" );
1992+
fprintf( pAbc->Err, "\t-b : toggles adding batch mode support [default = %s]\n", fBatch? "yes": "no" );
19921993
fprintf( pAbc->Err, "\t-h : print the command usage\n\n");
19931994
fprintf( pAbc->Err, "\tExample : scrgen -F test1.s -R a/in -C \"ps; st; ps\" -W a/out -E .blif\n" );
19941995
return 1;
@@ -2541,7 +2542,7 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
25412542
Synopsis []
25422543
25432544
Description []
2544-
2545+
25452546
SideEffects []
25462547
25472548
SeeAlso []
@@ -2568,7 +2569,7 @@ int CmdCommandStarter( Abc_Frame_t * pAbc, int argc, char ** argv )
25682569
}
25692570
nCores = atoi(argv[globalUtilOptind]);
25702571
globalUtilOptind++;
2571-
if ( nCores < 0 )
2572+
if ( nCores < 0 )
25722573
goto usage;
25732574
break;
25742575
case 'C':
@@ -2626,7 +2627,7 @@ int CmdCommandStarter( Abc_Frame_t * pAbc, int argc, char ** argv )
26262627
Synopsis []
26272628
26282629
Description []
2629-
2630+
26302631
SideEffects []
26312632
26322633
SeeAlso []
@@ -2654,7 +2655,7 @@ int CmdCommandAutoTuner( Abc_Frame_t * pAbc, int argc, char ** argv )
26542655
}
26552656
nCores = atoi(argv[globalUtilOptind]);
26562657
globalUtilOptind++;
2657-
if ( nCores < 0 )
2658+
if ( nCores < 0 )
26582659
goto usage;
26592660
break;
26602661
case 'C':
@@ -2775,7 +2776,7 @@ int CmdCommandVersion( Abc_Frame_t * pAbc, int argc, char **argv )
27752776
Synopsis []
27762777
27772778
Description []
2778-
2779+
27792780
SideEffects []
27802781
27812782
SeeAlso []
@@ -2800,7 +2801,7 @@ int CmdCommandSGen( Abc_Frame_t * pAbc, int argc, char ** argv )
28002801
}
28012802
nParts = atoi(argv[globalUtilOptind]);
28022803
globalUtilOptind++;
2803-
if ( nParts < 0 )
2804+
if ( nParts < 0 )
28042805
goto usage;
28052806
break;
28062807
case 'I':
@@ -2826,7 +2827,7 @@ int CmdCommandSGen( Abc_Frame_t * pAbc, int argc, char ** argv )
28262827
Abc_Print( -2, "There is no current network.\n" );
28272828
return 1;
28282829
}
2829-
if ( !Abc_NtkIsStrash(Abc_FrameReadNtk(pAbc)) )
2830+
if ( !Abc_NtkIsStrash(Abc_FrameReadNtk(pAbc)) )
28302831
{
28312832
Abc_Print( -2, "The current network is not an AIG.\n" );
28322833
return 1;

0 commit comments

Comments
 (0)