Commit 643f72a8 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Improving build structure

parent 50b1e157
......@@ -6,10 +6,25 @@ list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
# dependencies
vista_use_package( ITABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( VANet REQUIRED FIND_DEPENDENCIES )
vista_use_package( VABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( Lua REQUIRED )
vista_use_package( VistaCoreLibs REQUIRED COMPONENTS VistaTools FIND_DEPENDENCIES )
vista_use_package( VABase REQUIRED FIND_DEPENDENCIES )
# Build settings
if( BUILD_SHARED_LIBS )
add_definitions( -DVALUA_EXPORTS )
else( )
add_definitions( -DVALUA_STATIC -DVABASE_STATIC )
endif( )
if( ITA_VISTA_BUILD_STATIC )
add_definitions( -DVISTA_STATIC )
endif( )
if( NOT WIN32 )
add_definitions( -std=gnu++11 )
endif( )
# includes
......@@ -21,13 +36,6 @@ include( "include/_SourceFiles.cmake" )
include( "src/_SourceFiles.cmake" )
if( BUILD_SHARED_LIBS )
add_definitions( -DVANET_EXPORTS )
else()
add_definitions( -DVABASE_STATIC -DVACORE_STATIC -DVANET_STATIC )
endif( )
# linker
add_library( VALua ${ProjectSources} )
target_link_libraries( VALua ${VISTA_USE_PACKAGE_LIBRARIES} )
......
......@@ -18,21 +18,25 @@
#include <VACore.h>
#include <VACoreVersion.h>
#include <ITAAtomicPrimitives.h>
#include <ITAException.h>
#include <ITAFilesystemUtils.h>
#include <VistaTools/VistaFileSystemFile.h>
#include <VistaBase/VistaTimeUtils.h>
#include <atomic>
#include <cmath>
#include <iostream>
#include <windows.h>
// TODO: Memory-Leak wenn Core berschrieben wird
static IVACore* pGlobalVACore = NULL;
static std::ostream* pGlobalStdOut = NULL;
static std::ostream* pGlobalStdErr = NULL;
static ITAAtomicInt g_iGlobalStatus = 0;
static std::atomic< int > g_iGlobalStatus = 0;
#ifdef WIN32
// This is required for timers. Not available on other platforms.
#include <windows.h>
static HANDLE g_hWaitableTimer = 0;
#endif
// berladene Print-Funktion
......@@ -329,11 +333,11 @@ static int lSetShellStatus( lua_State *L )
static int lSleep( lua_State *L )
{
double dTime = luaL_checknumber( L, 1 );
if( dTime <= 0 )
const double dTimeSeconds = luaL_checknumber( L, 1 );
if(dTimeSeconds <= 0 )
return luaL_error( L, "Time must be greater zero" );
Sleep( ( DWORD ) ceil( dTime ) );
VistaTimeUtils::Sleep( ceil( 1000.0f * dTimeSeconds ) );
return 0;
}
......@@ -344,6 +348,9 @@ static int lWaitForKey( lua_State *L )
return 0;
}
#ifdef WIN32
// Timer only available on Windows platforms.
static int lSetTimer( lua_State *L )
{
double dPeriod = luaL_checknumber( L, 1 );
......@@ -395,6 +402,25 @@ static int lWaitForTimer( lua_State *L )
return 0;
}
#else // NOT WIN32
static int lSetTimer(lua_State *L)
{
VA_EXCEPT_NOT_IMPLEMENTED;
}
static void ClearTimer()
{
VA_EXCEPT_NOT_IMPLEMENTED;
}
static int lWaitForTimer(lua_State *L)
{
VA_EXCEPT_NOT_IMPLEMENTED;
}
#endif // WIN32
static int lSin( lua_State *L ) {
double x = luaL_checknumber( L, 1 );
lua_pushnumber( L, sin( x ) );
......@@ -538,10 +564,10 @@ void CVALuaShellImpl::SetStatus( int iStatus ) {
g_iGlobalStatus = iStatus;
}
void CVALuaShellImpl::ExecuteLuaScript( const std::string& sFilename )
void CVALuaShellImpl::ExecuteLuaScript( const std::string& sFilePath )
{
std::string sCorrectedFileName = correctPath( sFilename );
int error = luaL_dofile( L, sCorrectedFileName.c_str() );
VistaFileSystemFile oFile(sFilePath);
int error = luaL_dofile( L, oFile.GetName().c_str() );
if( error )
{
( *m_posStdErr ) << "Error: " << lua_tostring( L, -1 ) << std::endl;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment