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
* move extern Io_MvLoadFileBz2 to header, use hdr in cmd.c

Signed-off-by: Stephen L Arnold <sarnold@vctlabs.com>
  • Loading branch information
sarnold committed Dec 3, 2023
1 parent eb45ee9 commit 5c8bf28
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 109 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
42 changes: 21 additions & 21 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,14 +18,15 @@
***********************************************************************/

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

#include "base/abc/abc.h"
#include "base/io/ioInt.h"
#include "base/main/mainInt.h"
#include "cmdInt.h"
#include "misc/util/utilSignal.h"
Expand All @@ -50,7 +51,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__)) && !defined(__cplusplus)
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 +104,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__)) && !defined(__cplusplus)
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 +1149,7 @@ int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
#endif


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

Expand Down Expand Up @@ -1334,7 +1335,6 @@ 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 +1836,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 +1848,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 +1864,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 +1919,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 +1949,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 +1988,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 +2541,7 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand All @@ -2568,7 +2568,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 +2626,7 @@ int CmdCommandStarter( Abc_Frame_t * pAbc, int argc, char ** argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand Down Expand Up @@ -2654,7 +2654,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 +2775,7 @@ int CmdCommandVersion( Abc_Frame_t * pAbc, int argc, char **argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand All @@ -2800,7 +2800,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 +2826,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
5 changes: 2 additions & 3 deletions src/base/cmd/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Synopsis [External declarations of the command package.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Expand Down Expand Up @@ -60,7 +60,7 @@ extern char * Cmd_FlagReadByName( Abc_Frame_t * pAbc, char * flag );
extern void Cmd_FlagDeleteByName( Abc_Frame_t * pAbc, const char * key );
extern void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, const char * key, char * value );
/*=== cmdHist.c ========================================================*/
extern void Cmd_HistoryAddCommand( Abc_Frame_t * pAbc, const char * command );
extern void Cmd_HistoryAddCommand( Abc_Frame_t * pAbc, const char * command );
extern void Cmd_HistoryRead( Abc_Frame_t * p );
extern void Cmd_HistoryWrite( Abc_Frame_t * p, int Limit );
extern void Cmd_HistoryPrint( Abc_Frame_t * p, int Limit );
Expand All @@ -78,4 +78,3 @@ ABC_NAMESPACE_HEADER_END
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////

4 changes: 2 additions & 2 deletions src/base/io/ioInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Synopsis [External declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Expand Down Expand Up @@ -45,6 +45,7 @@ ABC_NAMESPACE_HEADER_START
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////

extern char * Io_MvLoadFileBz2( char * pFileName, int * pnFileSize );


ABC_NAMESPACE_HEADER_END
Expand All @@ -54,4 +55,3 @@ ABC_NAMESPACE_HEADER_END
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////

Loading

0 comments on commit 5c8bf28

Please sign in to comment.