More migration to T_FSPath
This commit is contained in:
parent
3f6c61cfd3
commit
68f6c49066
8 changed files with 68 additions and 44 deletions
|
@ -36,7 +36,8 @@ class T_OpsParser : public ebcl::A_PrivateImplementation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parse( ebcl::T_SRDList const& input ) noexcept;
|
bool parse( T_FSPath const& filePath ,
|
||||||
|
ebcl::T_SRDList const& input ) noexcept;
|
||||||
|
|
||||||
T_Array< ebcl::T_SRDError > const& errors( ) const noexcept
|
T_Array< ebcl::T_SRDError > const& errors( ) const noexcept
|
||||||
{ return errors_; }
|
{ return errors_; }
|
||||||
|
@ -92,7 +93,7 @@ class T_ScriptManager : public A_ProjectPathListener
|
||||||
{ return errors_; }
|
{ return errors_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T_String path_;
|
T_FSPath path_;
|
||||||
T_WatchedFiles watcher_;
|
T_WatchedFiles watcher_;
|
||||||
|
|
||||||
T_OpsParser parser_;
|
T_OpsParser parser_;
|
||||||
|
|
12
c-opmgr.cc
12
c-opmgr.cc
|
@ -58,7 +58,7 @@ void T_ScriptManager::projectPathChanged( ) noexcept
|
||||||
{
|
{
|
||||||
path_ = Common::Project( ).pathOf( "demo.srd" );
|
path_ = Common::Project( ).pathOf( "demo.srd" );
|
||||||
watcher_.clear( );
|
watcher_.clear( );
|
||||||
watcher_.watch( path_ );
|
watcher_.watch( path_.toString( ) );
|
||||||
loadScript( );
|
loadScript( );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ void T_ScriptManager::loadScript( ) noexcept
|
||||||
errors_.clear( );
|
errors_.clear( );
|
||||||
|
|
||||||
using namespace ebcl;
|
using namespace ebcl;
|
||||||
T_File input( path_ , E_FileMode::READ_ONLY );
|
T_File input( path_.toString( ) , E_FileMode::READ_ONLY );
|
||||||
try {
|
try {
|
||||||
input.open( );
|
input.open( );
|
||||||
} catch ( X_StreamError const& e ) {
|
} catch ( X_StreamError const& e ) {
|
||||||
|
@ -80,7 +80,7 @@ void T_ScriptManager::loadScript( ) noexcept
|
||||||
sb << " (error code " << e.systemError( ) << ")";
|
sb << " (error code " << e.systemError( ) << ")";
|
||||||
}
|
}
|
||||||
errors_.addNew( std::move( sb ) ,
|
errors_.addNew( std::move( sb ) ,
|
||||||
T_SRDLocation{ path_ , 1 , 1 } );
|
T_SRDLocation{ path_.toString( ) , 1 , 1 } );
|
||||||
DumpSRDErrors( "Script not found" , errors_ );
|
DumpSRDErrors( "Script not found" , errors_ );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ void T_ScriptManager::loadScript( ) noexcept
|
||||||
try {
|
try {
|
||||||
T_SRDTextReader srdReader{ srdOut };
|
T_SRDTextReader srdReader{ srdOut };
|
||||||
T_FileInputStream fis{ input };
|
T_FileInputStream fis{ input };
|
||||||
srdReader.read( path_ , fis );
|
srdReader.read( path_.toString( ) , fis );
|
||||||
} catch ( X_StreamError const& e ) {
|
} catch ( X_StreamError const& e ) {
|
||||||
T_StringBuilder sb;
|
T_StringBuilder sb;
|
||||||
sb << "could not load: " << e.what( );
|
sb << "could not load: " << e.what( );
|
||||||
|
@ -99,7 +99,7 @@ void T_ScriptManager::loadScript( ) noexcept
|
||||||
sb << " (error code " << e.systemError( ) << ")";
|
sb << " (error code " << e.systemError( ) << ")";
|
||||||
}
|
}
|
||||||
errors_.addNew( std::move( sb ) ,
|
errors_.addNew( std::move( sb ) ,
|
||||||
T_SRDLocation{ path_ , 1 , 1 } );
|
T_SRDLocation{ path_.toString( ) , 1 , 1 } );
|
||||||
DumpSRDErrors( "Script not loaded" , errors_ );
|
DumpSRDErrors( "Script not loaded" , errors_ );
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void T_ScriptManager::loadScript( ) noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the fuck
|
// Parse the fuck
|
||||||
if ( !parser_.parse( srdOut.list( ) ) ) {
|
if ( !parser_.parse( path_ , srdOut.list( ) ) ) {
|
||||||
errors_.addAll( parser_.errors( ) );
|
errors_.addAll( parser_.errors( ) );
|
||||||
DumpSRDErrors( "Parse errors" , errors_ );
|
DumpSRDErrors( "Parse errors" , errors_ );
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2219,6 +2219,7 @@ T_OpsParser::T_OpsParser( ) noexcept
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool T_OpsParser::parse(
|
bool T_OpsParser::parse(
|
||||||
|
T_FSPath const& filePath ,
|
||||||
T_SRDList const& input ) noexcept
|
T_SRDList const& input ) noexcept
|
||||||
{
|
{
|
||||||
errors_.clear( );
|
errors_.clear( );
|
||||||
|
|
22
c-project.cc
22
c-project.cc
|
@ -31,14 +31,26 @@ void T_Project::setBasePath(
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
T_String T_Project::pathOf(
|
T_FSPath T_Project::pathOf(
|
||||||
T_String const& file ) const noexcept
|
T_FSPath const& file ) const noexcept
|
||||||
{
|
{
|
||||||
return ( basePath_ + T_FSPath{ file } ).canonical( ).toString( );
|
return ( basePath_ + file ).canonical( );
|
||||||
}
|
}
|
||||||
|
|
||||||
T_String T_Project::pathOf(
|
T_FSPath T_Project::pathOf(
|
||||||
char const* file ) const noexcept
|
char const* file ) const noexcept
|
||||||
{
|
{
|
||||||
return ( basePath_ + T_FSPath{ file } ).canonical( ).toString( );
|
return pathOf( T_String{ file } );
|
||||||
|
}
|
||||||
|
|
||||||
|
T_String T_Project::strPathOf(
|
||||||
|
T_FSPath const& file ) const noexcept
|
||||||
|
{
|
||||||
|
return pathOf( file ).toString( );
|
||||||
|
}
|
||||||
|
|
||||||
|
T_String T_Project::strPathOf(
|
||||||
|
char const* file ) const noexcept
|
||||||
|
{
|
||||||
|
return strPathOf( T_String{ file } );
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,11 @@ struct T_Project
|
||||||
T_FSPath const& basePath( ) const noexcept
|
T_FSPath const& basePath( ) const noexcept
|
||||||
{ return basePath_; }
|
{ return basePath_; }
|
||||||
|
|
||||||
T_String pathOf( T_String const& file ) const noexcept;
|
T_FSPath pathOf( T_FSPath const& file ) const noexcept;
|
||||||
T_String pathOf( char const* file ) const noexcept;
|
T_FSPath pathOf( char const* file ) const noexcept;
|
||||||
|
|
||||||
|
T_String strPathOf( T_FSPath const& file ) const noexcept;
|
||||||
|
T_String strPathOf( char const* file ) const noexcept;
|
||||||
|
|
||||||
void addListener( A_ProjectPathListener* listener ) noexcept
|
void addListener( A_ProjectPathListener* listener ) noexcept
|
||||||
{ listeners_.add( listener ); }
|
{ listeners_.add( listener ); }
|
||||||
|
|
|
@ -684,7 +684,7 @@ T_SyncManager::T_SyncManager( ) noexcept
|
||||||
{
|
{
|
||||||
auto& p{ Common::Project( ) };
|
auto& p{ Common::Project( ) };
|
||||||
p.addListener( this );
|
p.addListener( this );
|
||||||
curvesFile_ = p.pathOf( "curves.srd" );
|
curvesFile_ = p.strPathOf( "curves.srd" );
|
||||||
watcher_.watch( curvesFile_ );
|
watcher_.watch( curvesFile_ );
|
||||||
loadCurves( false );
|
loadCurves( false );
|
||||||
}
|
}
|
||||||
|
@ -977,7 +977,7 @@ void T_SyncManager::visitOverrides(
|
||||||
|
|
||||||
void T_SyncManager::projectPathChanged( ) noexcept
|
void T_SyncManager::projectPathChanged( ) noexcept
|
||||||
{
|
{
|
||||||
curvesFile_ = Common::Project( ).pathOf( "curves.srd" );
|
curvesFile_ = Common::Project( ).strPathOf( "curves.srd" );
|
||||||
watcher_.clear( );
|
watcher_.clear( );
|
||||||
watcher_.watch( curvesFile_ );
|
watcher_.watch( curvesFile_ );
|
||||||
loadCurves( false );
|
loadCurves( false );
|
||||||
|
|
48
m-builder.cc
48
m-builder.cc
|
@ -31,11 +31,12 @@ const struct option CmdLineOpts_[] = {
|
||||||
|
|
||||||
void PrintStreamError(
|
void PrintStreamError(
|
||||||
char const* const prefix ,
|
char const* const prefix ,
|
||||||
T_String const& name ,
|
T_FSPath const& name ,
|
||||||
X_StreamError const& error ) noexcept
|
X_StreamError const& error ) noexcept
|
||||||
{
|
{
|
||||||
|
const T_FSPath rp{ name.makeRelative( Filesystem::Cwd( ) ) };
|
||||||
T_StringBuilder sb;
|
T_StringBuilder sb;
|
||||||
sb << prefix << " '" << name << "': " << error.what( );
|
sb << prefix << " '" << rp << "': " << error.what( );
|
||||||
if ( error.code( ) == E_StreamError::SYSTEM_ERROR ) {
|
if ( error.code( ) == E_StreamError::SYSTEM_ERROR ) {
|
||||||
sb << " (error code " << error.systemError( ) << ")";
|
sb << " (error code " << error.systemError( ) << ")";
|
||||||
}
|
}
|
||||||
|
@ -89,19 +90,15 @@ void WriteSRDErrors(
|
||||||
fprintf( stderr , "%s" , sb.data( ) );
|
fprintf( stderr , "%s" , sb.data( ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
T_String FilePath(
|
T_FSPath FilePath(
|
||||||
T_String const& path ,
|
T_FSPath const& path ,
|
||||||
char const* const name ) noexcept
|
char const* const name ) noexcept
|
||||||
{
|
{
|
||||||
T_StringBuilder sb;
|
const T_FSPath fp{ name };
|
||||||
if ( path ) {
|
if ( fp.isAbsolute( ) ) {
|
||||||
sb << path;
|
return fp.canonical( );
|
||||||
if ( !path.endsWith( "/" ) ) {
|
|
||||||
sb << '/';
|
|
||||||
}
|
}
|
||||||
}
|
return ( path + fp ).canonical( );
|
||||||
sb << name;
|
|
||||||
return T_String{ std::move( sb ) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,6 +138,17 @@ int main( int argc , char** argv )
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const T_FSPath srcPath{ ([&](){
|
||||||
|
const T_FSPath raw{ oSrcPath };
|
||||||
|
if ( !raw.isAbsolute( ) ) {
|
||||||
|
return ( Filesystem::Cwd( ) + raw ).canonical( );
|
||||||
|
}
|
||||||
|
return raw.canonical( );
|
||||||
|
})() };
|
||||||
|
if ( !srcPath.isValid( ) ) {
|
||||||
|
fprintf( stderr , "Invalid source path\n" );
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// Logger setup
|
// Logger setup
|
||||||
const uint32_t logLevel{ oLogLevel ? *oLogLevel : 0 };
|
const uint32_t logLevel{ oLogLevel ? *oLogLevel : 0 };
|
||||||
|
@ -155,11 +163,11 @@ int main( int argc , char** argv )
|
||||||
|
|
||||||
// Build configurations
|
// Build configurations
|
||||||
M_LOGSTR( "Loading build configurations" , 1 );
|
M_LOGSTR( "Loading build configurations" , 1 );
|
||||||
const T_String bcfgFile{ FilePath( oSrcPath , "build.srd" ) };
|
const auto bcfgFile{ FilePath( srcPath , "build.srd" ) };
|
||||||
const T_BuildConfiguration cfg{ [&]() {
|
const T_BuildConfiguration cfg{ [&]() {
|
||||||
try {
|
try {
|
||||||
T_BuildConfigurationLoader bcfgLoader;
|
T_BuildConfigurationLoader bcfgLoader;
|
||||||
T_BuildConfigurations cfs{ bcfgLoader.load( bcfgFile ) };
|
T_BuildConfigurations cfs{ bcfgLoader.load( bcfgFile.toString( ) ) };
|
||||||
if ( oBuildCfg && !cfs.contains( oBuildCfg ) ) {
|
if ( oBuildCfg && !cfs.contains( oBuildCfg ) ) {
|
||||||
fprintf( stderr , "===== BUILD CONFIGURATIONS\n" );
|
fprintf( stderr , "===== BUILD CONFIGURATIONS\n" );
|
||||||
fprintf( stderr , "Build configuration not found\n" );
|
fprintf( stderr , "Build configuration not found\n" );
|
||||||
|
@ -186,10 +194,10 @@ int main( int argc , char** argv )
|
||||||
|
|
||||||
// Load curves
|
// Load curves
|
||||||
M_LOGSTR( "Loading curves data" , 1 );
|
M_LOGSTR( "Loading curves data" , 1 );
|
||||||
const T_String curvesFile{ FilePath( oSrcPath , "curves.srd" ) };
|
const auto curvesFile{ FilePath( srcPath , "curves.srd" ) };
|
||||||
T_SyncCurvesIO::T_Data p;
|
T_SyncCurvesIO::T_Data p;
|
||||||
try {
|
try {
|
||||||
p = T_SyncCurvesIO{}.load( curvesFile );
|
p = T_SyncCurvesIO{}.load( curvesFile.toString( ) );
|
||||||
} catch ( ebcl::X_StreamError const& e ) {
|
} catch ( ebcl::X_StreamError const& e ) {
|
||||||
fprintf( stderr , "===== CURVES DATA\n" );
|
fprintf( stderr , "===== CURVES DATA\n" );
|
||||||
PrintStreamError( "Could not open" , curvesFile , e );
|
PrintStreamError( "Could not open" , curvesFile , e );
|
||||||
|
@ -202,10 +210,10 @@ int main( int argc , char** argv )
|
||||||
|
|
||||||
// Open and load script
|
// Open and load script
|
||||||
M_LOGSTR( "Loading script" , 1 );
|
M_LOGSTR( "Loading script" , 1 );
|
||||||
const T_String inputName{ FilePath( oSrcPath , "demo.srd" ) };
|
const auto inputName{ FilePath( srcPath , "demo.srd" ) };
|
||||||
T_SRDMemoryTarget srdOut;
|
T_SRDMemoryTarget srdOut;
|
||||||
{
|
{
|
||||||
T_File input( inputName , E_FileMode::READ_ONLY );
|
T_File input( inputName.toString( ) , E_FileMode::READ_ONLY );
|
||||||
try {
|
try {
|
||||||
input.open( );
|
input.open( );
|
||||||
} catch ( X_StreamError const& e ) {
|
} catch ( X_StreamError const& e ) {
|
||||||
|
@ -216,7 +224,7 @@ int main( int argc , char** argv )
|
||||||
try {
|
try {
|
||||||
T_SRDTextReader srdReader{ srdOut };
|
T_SRDTextReader srdReader{ srdOut };
|
||||||
T_FileInputStream fis{ input };
|
T_FileInputStream fis{ input };
|
||||||
srdReader.read( inputName , fis );
|
srdReader.read( inputName.toString( ) , fis );
|
||||||
} catch ( X_StreamError const& e ) {
|
} catch ( X_StreamError const& e ) {
|
||||||
fprintf( stderr , "===== SCRIPT\n" );
|
fprintf( stderr , "===== SCRIPT\n" );
|
||||||
PrintStreamError( "Could not open" , inputName , e );
|
PrintStreamError( "Could not open" , inputName , e );
|
||||||
|
@ -231,7 +239,7 @@ int main( int argc , char** argv )
|
||||||
M_LOGSTR( "Parsing script" , 1 );
|
M_LOGSTR( "Parsing script" , 1 );
|
||||||
T_OpsParser parser;
|
T_OpsParser parser;
|
||||||
parser.setLogger( logger );
|
parser.setLogger( logger );
|
||||||
if ( !parser.parse( srdOut.list( ) ) ) {
|
if ( !parser.parse( inputName , srdOut.list( ) ) ) {
|
||||||
WriteSRDErrors( "SCRIPT" , parser.errors( ) );
|
WriteSRDErrors( "SCRIPT" , parser.errors( ) );
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
|
@ -536,10 +536,10 @@ void T_ShaderManager::update( )
|
||||||
|
|
||||||
// Check for missing files
|
// Check for missing files
|
||||||
for ( auto it = missing_.keys( ).cbegin( ) ; it.valid( ) ; ++it ) {
|
for ( auto it = missing_.keys( ).cbegin( ) ; it.valid( ) ; ++it ) {
|
||||||
const bool exists( ([&sb] ( T_String const& name ) -> bool {
|
const bool exists( ([] ( T_String const& name ) -> bool {
|
||||||
|
T_FSPath p{ T_FSPath{ "shaders" } + T_FSPath{ name } };
|
||||||
struct stat buffer;
|
struct stat buffer;
|
||||||
sb << "shaders/" << name << '\0';
|
return ( stat( Common::Project( ).strPathOf( p ).data( ) , &buffer ) == 0 );
|
||||||
return ( stat( Common::Project( ).pathOf( std::move( sb ) ).data( ) , &buffer ) == 0 );
|
|
||||||
})( *it ) );
|
})( *it ) );
|
||||||
if ( !exists ) {
|
if ( !exists ) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -726,7 +726,7 @@ T_ShaderInput const* T_ShaderManager::getInput(
|
||||||
sb << "shaders/" << name;
|
sb << "shaders/" << name;
|
||||||
return std::move( sb );
|
return std::move( sb );
|
||||||
}() };
|
}() };
|
||||||
if ( !ni.load( Common::Project( ).pathOf( path ) ) ) {
|
if ( !ni.load( Common::Project( ).strPathOf( path ) ) ) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
inputs_.add( name , NewOwned< T_ShaderInput >( std::move( ni ) ) );
|
inputs_.add( name , NewOwned< T_ShaderInput >( std::move( ni ) ) );
|
||||||
|
@ -864,9 +864,8 @@ void T_ShaderManager::initProgram(
|
||||||
for ( auto i = 0u ; i < nf ; i ++ ) {
|
for ( auto i = 0u ; i < nf ; i ++ ) {
|
||||||
T_String const& fn( code.files.keys( )[ i ] );
|
T_String const& fn( code.files.keys( )[ i ] );
|
||||||
if ( code.files.values( )[ i ] ) {
|
if ( code.files.values( )[ i ] ) {
|
||||||
T_StringBuilder sb;
|
T_FSPath p{ T_FSPath{ "shaders" } + T_FSPath{ fn } };
|
||||||
sb << "shaders/" << fn;
|
w.watch( Common::Project( ).strPathOf( p ) );
|
||||||
w.watch( Common::Project( ).pathOf( std::move( sb ) ) );
|
|
||||||
} else {
|
} else {
|
||||||
auto& mset( missing_.getOrCreate( fn ) );
|
auto& mset( missing_.getOrCreate( fn ) );
|
||||||
if ( !mset.contains( name ) ) {
|
if ( !mset.contains( name ) ) {
|
||||||
|
|
Loading…
Reference in a new issue