示例#1
0
文件: m2sh.c 项目: duaneg/mongrel2
void taskmain(int argc, char *argv[])
{
    dbg_set_log(stderr);
    int i = 0;

    bstring arguments = bfromcstr(argv[0]);

    for(i = 1; i < argc; i++) {
        bstring a = bfromcstr(argv[i]);

        // compensate for quotes getting taken off by the shell
        // TODO: also need to escape " to bring back that
        if(bstrchr(a, ' ') != -1) {
            bcatcstr(arguments, " \"");
            bconcat(arguments, a);
            bcatcstr(arguments, "\"");
        } else {
            bcatcstr(arguments, " ");
            bconcat(arguments, a);
        }

        bdestroy(a);
    }

    debug("RUNNING: %s", bdata(arguments));
    taskexitall(Command_run(arguments));
}
示例#2
0
int CommandPool_runAll( CommandPool* self )
{
	int result = 1;
	unsigned int max = Set_count( self->commands );
	unsigned int i;
	for ( i=0; i < max; i++ )
	{
		Command* command = (Command*) Set_get( self->commands, i );
		Command_run( command );
	}
	
	for ( i=0; i < max; i++ )
	{
		Command* command = (Command*) Set_get( self->commands, i );
		if ( !Command_hasFinished( command ) )
		{
			Command_waitFor( command );
			result &= Command_getResult( command );
		}
	}
	return result;
}
示例#3
0
void Scheduler_run() {
    // handle buttons (go backwards to preserve priority) //
    ListNode* node = buttonList.lastNode;
    while(node != NULL) {
        Button_executeScheduler((ButtonScheduler*) node->data);
        node = node->prev;
    }
    
    // loop through commands to execute //
    node = runningList.firstNode;
    ListNode* temp;
    while(node != NULL) {
        temp = node->next;
        if(!Command_run((Command*) node->data)) {
            removeRunningNode(node);
        }
        node = temp;
    }
    
    // add queued stuff //
    node = queuedList.firstNode;
    while(node != NULL) {
        temp = node->next;
        addRunningNode(node);
        node = temp;
    }
    
    // add in the defaults //
    node = Subsystems.firstNode;
    while(node != NULL) {
        Subsystem* sys = (Subsystem*) node->data;
        if(!sys->currentCommand) {
            Command* xcmd = Subsystem_getDefaultCommand(sys);
            addRunningNode(getNode(xcmd));
        }
        node = node->next;
    }
}
示例#4
0
static int private_link_library( const void* buildParameters, const void* providerContext, const void* targetIDirectory )
{
//	fprintf( stdout, "ISLabs::linux-gnu::gnu::link()\n" );
    bool status = 1;
    const BuildParameters* parameters = (BuildParameters*) buildParameters;
    const ProviderContext* context = (ProviderContext*) providerContext;
    const IDirectory*      target = (IDirectory*) targetIDirectory;

    SoName* so_name = generateSoName( context->package_name, context->isLib );
    char* target_location_obj       = CharString_cat2( Path_getCondensed( Directory_getRealPath( target ) ), "/obj/" );
    char* target_location_lib       = CharString_cat2( Path_getCondensed( Directory_getRealPath( target ) ), "/lib/" );
    char* target_location_lib_long  = CharString_cat2( target_location_lib, so_name->long_name );
    char* target_location_lib_short = CharString_cat2( target_location_lib, so_name->short_name );

    Command* command;
    IList* arguments = new_List();
    IList* native_arguments;

    //  Linker
    List_copyItem( arguments, context->linker );

    //  Linker flags
    if ( !BuildParameters_isRelease( parameters ) )
    {
        List_copyItem( arguments, "-Wl,-G" );
    }
    List_copyItem( arguments, "-shared" );

    //  Object files: need to be before archive libraries so
    //                symbols can be found.
    addFlags( arguments, target_location_obj, context->objectFiles );

    //  Libraries
    addFlags( arguments, "-L", context->libraryDirs );
    addFlags( arguments, "-l", context->libraries );

    List_addList( arguments, BuildParameters_getGlobal( parameters )->LFLAGS );
    List_addList( arguments, BuildParameters_getGlobal( parameters )->LDFLAGS );

    List_copyItem( arguments, "-Wl,-R$ORIGIN" );
    List_copyItem( arguments, "-Wl,-R$ORIGIN/../lib" );

    if ( BuildParameters_isDeep( parameters ) )
    {
        addFlags( arguments, "-Wl,-R$ORIGIN/../", context->runtimeLibraryDirs );
    }

    List_copyItem( arguments, "-Wl,-soname" );
    List_addItem( arguments, CharString_cat2( "-Wl,", so_name->long_name ) );

    List_copyItem( arguments, "-o" );
    List_copyItem( arguments, target_location_lib_long );

    native_arguments = Path_ConvertListToNative( arguments );
    command = new_Command( context->linker, (const char**) native_arguments->items );
    if ( !BuildParameters_isNo( parameters ) && Command_run( command ) && Command_waitFor( command ) )
    {
        status &= Command_getResult( command );
    } else {
        fprintf( stderr, "failed: " );
        Command_print( command, stderr );
    }
    free_Command( command );
    free_List( native_arguments );

    List_copyItem( arguments, "-o" );
    List_copyItem( arguments, target_location_lib_short );

    native_arguments = Path_ConvertListToNative( arguments );
    command = new_Command( context->linker, (const char**) native_arguments->items );
    Command_print( command, stderr );
//	if ( !BuildParameters_isNo( parameters ) && Command_run( command ) && Command_waitFor( command ) )
//	{
//		status &= Command_getResult( command );
//	} else {
//		fprintf( stderr, "failed: " );
//		Command_print( command, stderr );
//	}
    free_Command( command );
    free_List( native_arguments );

    free_List( arguments );

    free_CharString( target_location_obj );
    free_CharString( target_location_lib );
    free_CharString( target_location_lib_long );
    free_CharString( target_location_lib_short );

    return status;
}