Skip to content

Commit

Permalink
fix: dev: address toolchain requirement changes
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
sarnold committed Dec 2, 2023
1 parent eb45ee9 commit 2d82a9d
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 103 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ target_include_directories(
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(abc_interface INTERFACE ${CMAKE_DL_LIBS})
if(MINGW)
target_link_libraries(abc_interface INTERFACE ${CMAKE_DL_LIBS} shlwapi)
else()
target_link_libraries(abc_interface INTERFACE ${CMAKE_DL_LIBS})
endif()

if(NOT ABC_USE_NO_CUDD)
message(STATUS "Compiling with CUDD")
Expand Down
41 changes: 21 additions & 20 deletions src/base/cmd/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Synopsis [Command file.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Expand All @@ -18,11 +18,11 @@
***********************************************************************/

#ifdef WIN32
#if defined(WIN32) || defined(__MINGW32__)
#include <process.h>
#else
#include <unistd.h>
#include <dirent.h>
#include <unistd.h>
#endif

#include "base/abc/abc.h"
Expand Down Expand Up @@ -50,7 +50,7 @@ static int CmdCommandUnsetVariable ( Abc_Frame_t * pAbc, int argc, char ** argv
static int CmdCommandUndo ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int CmdCommandRecall ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int CmdCommandEmpty ( Abc_Frame_t * pAbc, int argc, char ** argv );
#if defined(WIN32) && !defined(__cplusplus)
#if defined(WIN32) || defined(__MINGW32__)
static int CmdCommandScanDir ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int CmdCommandRenameFiles ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int CmdCommandLs ( Abc_Frame_t * pAbc, int argc, char ** argv );
Expand Down Expand Up @@ -103,7 +103,7 @@ void Cmd_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Basic", "undo", CmdCommandUndo, 0 );
Cmd_CommandAdd( pAbc, "Basic", "recall", CmdCommandRecall, 0 );
Cmd_CommandAdd( pAbc, "Basic", "empty", CmdCommandEmpty, 0 );
#if defined(WIN32) && !defined(__cplusplus)
#if defined(WIN32) || defined(__MINGW32__)
Cmd_CommandAdd( pAbc, "Basic", "scandir", CmdCommandScanDir, 0 );
Cmd_CommandAdd( pAbc, "Basic", "renamefiles", CmdCommandRenameFiles, 0 );
Cmd_CommandAdd( pAbc, "Basic", "ls", CmdCommandLs, 0 );
Expand Down Expand Up @@ -1148,7 +1148,7 @@ int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
#endif


#if defined(WIN32) && !defined(__cplusplus)
#if defined(WIN32) || defined(__MINGW32__)
#include <direct.h>
#include <io.h>

Expand Down Expand Up @@ -1335,6 +1335,7 @@ int CmfFindNumber( char * pName )
void CnfDupFileUnzip( char * pOldName )
{
extern char * Io_MvLoadFileBz2( char * pFileName, int * pnFileSize );

char pNewName[1000];
FILE * pFile;
int nFileSize;
Expand Down Expand Up @@ -1836,7 +1837,7 @@ int CmdCommandScrGen( Abc_Frame_t * pAbc, int argc, char **argv )

#else

Vec_Ptr_t * CmdReturnFileNames( char * pDirStr )
Vec_Ptr_t * CmdReturnFileNames( char * pDirStr )
{
Vec_Ptr_t * vRes = Vec_PtrAlloc( 100 );
struct dirent **namelist;
Expand All @@ -1848,7 +1849,7 @@ Vec_Ptr_t * CmdReturnFileNames( char * pDirStr )
for (int i = 0; i < num_files; i++) {
char * pExt = strstr(namelist[i]->d_name, ".");
if ( !pExt || !strcmp(pExt, ".") || !strcmp(pExt, "..") || !strcmp(pExt, ".s") || !strcmp(pExt, ".txt") )
continue;
continue;
Vec_PtrPush( vRes, Abc_UtilStrsav(namelist[i]->d_name) );
free(namelist[i]);
}
Expand All @@ -1864,7 +1865,7 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
char * pDirStr = (char *)".";
char * pComStr = (char *)"ps";
char * pWriteStr = NULL;
char * pWriteExt = NULL;
char * pWriteExt = NULL;
char Line[2000], * pName;
int nFileNameMax;
int fBatch = 0;
Expand Down Expand Up @@ -1919,7 +1920,7 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
}
pWriteExt = argv[globalUtilOptind];
globalUtilOptind++;
break;
break;
case 'b':
fBatch ^= 1;
break;
Expand Down Expand Up @@ -1949,8 +1950,8 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
int fAndSpace = pComStr[0] == '&';
fprintf( pFile, "# Script file produced by ABC on %s\n", Extra_TimeStamp() );
fprintf( pFile, "# Command line was: scrgen -F %s -D %s -C \"%s\"%s%s%s%s\n",
pFileStr, pDirStr, pComStr,
pWriteStr?" -W ":"", pWriteStr?pWriteStr:"",
pFileStr, pDirStr, pComStr,
pWriteStr?" -W ":"", pWriteStr?pWriteStr:"",
pWriteExt?" -E ":"", pWriteExt?pWriteExt:"" );
Vec_PtrForEachEntry( char *, vNames, pName, k ) {
char * pExt = strstr(pName, ".");
Expand Down Expand Up @@ -1988,7 +1989,7 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
fprintf( pAbc->Err, "\t-C str : the sequence of commands to run [default = \"ps\"]\n" );
fprintf( pAbc->Err, "\t-W str : the directory to write the resulting files [default = no writing]\n" );
fprintf( pAbc->Err, "\t-E str : the output files extension (with \".\") [default = the same as input files]\n" );
fprintf( pAbc->Err, "\t-b : toggles adding batch mode support [default = %s]\n", fBatch? "yes": "no" );
fprintf( pAbc->Err, "\t-b : toggles adding batch mode support [default = %s]\n", fBatch? "yes": "no" );
fprintf( pAbc->Err, "\t-h : print the command usage\n\n");
fprintf( pAbc->Err, "\tExample : scrgen -F test1.s -R a/in -C \"ps; st; ps\" -W a/out -E .blif\n" );
return 1;
Expand Down Expand Up @@ -2541,7 +2542,7 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand All @@ -2568,7 +2569,7 @@ int CmdCommandStarter( Abc_Frame_t * pAbc, int argc, char ** argv )
}
nCores = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nCores < 0 )
if ( nCores < 0 )
goto usage;
break;
case 'C':
Expand Down Expand Up @@ -2626,7 +2627,7 @@ int CmdCommandStarter( Abc_Frame_t * pAbc, int argc, char ** argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand Down Expand Up @@ -2654,7 +2655,7 @@ int CmdCommandAutoTuner( Abc_Frame_t * pAbc, int argc, char ** argv )
}
nCores = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nCores < 0 )
if ( nCores < 0 )
goto usage;
break;
case 'C':
Expand Down Expand Up @@ -2775,7 +2776,7 @@ int CmdCommandVersion( Abc_Frame_t * pAbc, int argc, char **argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand All @@ -2800,7 +2801,7 @@ int CmdCommandSGen( Abc_Frame_t * pAbc, int argc, char ** argv )
}
nParts = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nParts < 0 )
if ( nParts < 0 )
goto usage;
break;
case 'I':
Expand All @@ -2826,7 +2827,7 @@ int CmdCommandSGen( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -2, "There is no current network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(Abc_FrameReadNtk(pAbc)) )
if ( !Abc_NtkIsStrash(Abc_FrameReadNtk(pAbc)) )
{
Abc_Print( -2, "The current network is not an AIG.\n" );
return 1;
Expand Down
Loading

0 comments on commit 2d82a9d

Please sign in to comment.