Example #1
0
// Commit
//------------------------------------------------------------------------------
/*virtual*/ bool FunctionCopyDir::Commit( NodeGraph & nodeGraph, const BFFIterator & funcStartIter ) const
{
    // Get input paths
    Array< AString > inputPaths;
    if ( !GetFolderPaths( funcStartIter, inputPaths, ".SourcePaths", true ) )
    {
        return false; // GetFolderPaths will have emitted an error
    }

    // get the optional params
    Array< AString > patterns;
    bool recurse = true;
    Array< AString > excludePaths;
    if ( !GetStrings( funcStartIter, patterns, ".SourcePathsPattern" ) ||
         !GetBool( funcStartIter, recurse, ".SourcePathsRecurse", true ) || // recursive by default
         !GetStrings( funcStartIter, excludePaths, ".SourceExcludePaths" ) )
    {
        return false; // Get* will have emitted error
    }

    // convert input paths to DirectoryListNodes
    Dependencies staticDeps( inputPaths.GetSize() );
    if ( !GetDirectoryListNodeList( nodeGraph, funcStartIter, inputPaths, excludePaths, Array< AString >(), Array< AString >(), recurse, patterns.IsEmpty() ? nullptr : &patterns, ".SourcePaths", staticDeps ) )
    {
        return false; // GetDirectoryListNodeList will have emitted an error
    }

    // Get output path
    AStackString<> destPath;
    if ( !GetString( funcStartIter, destPath, ".Dest", true ) )
    {
        return false;
    }
    NodeGraph::CleanPath( destPath );

    // Pre-build dependencies
    Dependencies preBuildDeps;
    if ( !GetNodeList( nodeGraph, funcStartIter, ".PreBuildDependencies", preBuildDeps, false ) )
    {
        return false; // GetNodeList will have emitted an error
    }

    // sanity check we defined something useful
    if ( staticDeps.IsEmpty() )
    {
        Error::Error_1006_NothingToBuild( funcStartIter, this );
        return false;
    }

    // check node doesn't already exist
    if ( nodeGraph.FindNode( m_AliasForFunction ) )
    {
        Error::Error_1100_AlreadyDefined( funcStartIter, this, m_AliasForFunction );
        return false;
    }

    // create our node
    nodeGraph.CreateCopyDirNode( m_AliasForFunction, staticDeps, destPath, preBuildDeps );
    return true;
}
Example #2
0
// Commit
//------------------------------------------------------------------------------
/*virtual*/ bool FunctionSettings::Commit( NodeGraph & /*nodeGraph*/, const BFFIterator & funcStartIter ) const
{
    // using a cache plugin?
    AStackString<> cachePluginDLL;
    if ( !GetString( funcStartIter, cachePluginDLL, ".CachePluginDLL" ) )
    {
        return false;
    }
    FBuild::Get().SetCachePluginDLL( cachePluginDLL );
    if ( !cachePluginDLL.IsEmpty() )
    {
        FLOG_INFO( "CachePluginDLL: '%s'", cachePluginDLL.Get() );
    }

    // try to get the cache path from the config
    const BFFVariable * cachePathVar;
    if ( !GetString( funcStartIter, cachePathVar, ".CachePath" ) )
    {
        return false;
    }
    if ( cachePathVar )
    {
        s_CachePath = cachePathVar->GetString();

        // override environment default only if not empty
        if ( s_CachePath.IsEmpty() == false )
        {
            FBuild::Get().SetCachePath( s_CachePath );
        }
    }

    // "Workers"
    Array< AString > workerList;
    if ( !GetStrings( funcStartIter, workerList, ".Workers" ) )
    {
        return false;
    }
    if ( !workerList.IsEmpty() )
    {
        FBuild::Get().SetWorkerList( workerList );
    }

    // "Environment"
    Array< AString > environment;
    if ( !GetStrings( funcStartIter, environment, ".Environment" ) )
    {
        return false;
    }
    if ( !environment.IsEmpty() )
    {
        ProcessEnvironment( environment );
    }

    return true;
}
Example #3
0
std::vector<Action*> DLGImporter::GetAction(unsigned int index) const
{
	if (index >= ActionsCount) {
		return std::vector<Action*>();
	}
	str->Seek( ActionsOffset + ( index * 8 ), GEM_STREAM_START );
	ieDword Offset, Length;
	str->ReadDword( &Offset );
	str->ReadDword( &Length );
	str->Seek( Offset, GEM_STREAM_START );
	char* string = ( char* ) malloc( Length + 1 );
	str->Read( string, Length );
	string[Length] = 0;
	unsigned int count;
	char ** lines = GetStrings( string, count );
	std::vector<Action*> actions;
	for (size_t i = 0; i < count; ++i) {
		Action *action = GenerateAction(lines[i]);
		if (!action) {
			printMessage("DLGImporter", "Can't compile action: %s\n" , YELLOW, lines[i]);
		} else {
			action->IncRef();
			actions.push_back(action);
		}
		free( lines[i] );
	}
	free( lines );
	free( string );
	return actions;
}
Example #4
0
static void GetTopology(IXMLDOMElement* e,TOPOLOGY& v)
{
	HRESULT hr;
	IXMLDOMElementPtr categories, connection, name, nodes;
	IXMLDOMNodePtr  categories_node, connection_node, name_node, nodes_node;

	hr = e->selectSingleNode(_bstr_t(L"ksproperty_topology_categories"),&categories_node);
	if(hr!=S_OK) throw _com_error(hr);
	hr = e->selectSingleNode(_bstr_t(L"ksproperty_topology_connections"),&connection_node);
	if(hr!=S_OK) throw _com_error(hr);
	hr = e->selectSingleNode(_bstr_t(L"ksproperty_topology_name"),&name_node);
	if(hr!=S_OK) throw _com_error(hr);
	hr = e->selectSingleNode(_bstr_t(L"ksproperty_topology_nodes"),&nodes_node);
	if(hr!=S_OK) throw _com_error(hr);

	categories=categories_node;
	connection=connection_node;
	name=name_node;
	nodes=nodes_node;

	GetGUIDs(categories,v.categories);
	GetTopologyConnections(connection,v.connection);
	GetStrings(name,v.name);
	GetGUIDs(nodes,v.nodes);
}
Example #5
0
// GetFolderPaths
//------------------------------------------------------------------------------
bool Function::GetFolderPaths(const BFFIterator & iter, Array< AString > & paths, const char * name, bool required) const
{
	if ( !GetStrings(iter, paths, name, required ) )
	{
		return false; // GetStrings will have emitted an error
	}
	CleanFolderPaths( paths );
	return true;
}
Example #6
0
void wxBitmapComboBox::RecreateControl()
{
    //
    // Recreate control so that WM_MEASUREITEM gets called again.
    // Can't use CBS_OWNERDRAWVARIABLE because it has odd
    // mouse-wheel behaviour.
    //
    wxString value = GetValue();
    wxPoint pos = GetPosition();
    wxSize size = GetSize();
    wxArrayString strings = GetStrings();

    wxComboBox::DoClear();

    HWND hwnd = GetHwnd();
    DissociateHandle();
    ::DestroyWindow(hwnd);

    if ( !MSWCreateControl(wxT("COMBOBOX"), value, pos, size) )
        return;

    // initialize the controls contents
    for ( unsigned int i = 0; i < strings.size(); i++ )
    {
        wxComboBox::Append(strings[i]);
    }

    // and make sure it has the same attributes as before
    if ( m_hasFont )
    {
        // calling SetFont(m_font) would do nothing as the code would
        // notice that the font didn't change, so force it to believe
        // that it did
        wxFont font = m_font;
        m_font = wxNullFont;
        SetFont(font);
    }

    if ( m_hasFgCol )
    {
        wxColour colFg = m_foregroundColour;
        m_foregroundColour = wxNullColour;
        SetForegroundColour(colFg);
    }

    if ( m_hasBgCol )
    {
        wxColour colBg = m_backgroundColour;
        m_backgroundColour = wxNullColour;
        SetBackgroundColour(colBg);
    }
    else
    {
        SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
    }
}
// Command Show choices
bool Game_Interpreter::CommandShowChoices(RPG::EventCommand const& com) { // Code ShowChoice
	if (!Game_Message::texts.empty()) {
		return false;
	}

	Game_Message::message_waiting = true;

	// Choices setup
	std::vector<std::string> choices;
	Game_Message::choice_cancel_type = com.parameters[0];
	GetStrings(choices);
	SetupChoices(choices);

	return true;
}
Example #8
0
// Command Show Message
bool Game_Interpreter::CommandShowMessage(RPG::EventCommand const& com) { // Code ShowMessage
	// If there's a text already, return immediately
	if (!Game_Message::texts.empty()) {
		return false;
	}
	unsigned int line_count = 0;

	Game_Message::message_waiting = true;
	Game_Message::owner_id = event_id;

	// Set first line
	Game_Message::texts.push_back(com.string);
	line_count++;

	for (;;) {
		// If next event command is the following parts of the message
		if ( index < list.size() - 1 && list[index+1].code == Cmd::ShowMessage_2 ) {
			// Add second (another) line
			line_count++;
			Game_Message::texts.push_back(list[index+1].string);
		} else {
			// If next event command is show choices
			std::vector<std::string> s_choices;
			if ( (index < list.size() - 1) && (list[index+1].code == Cmd::ShowChoice) ) {
				GetStrings(s_choices);
				// If choices fit on screen
				if (s_choices.size() <= (4 - line_count)) {
					index++;
					Game_Message::choice_start = line_count;
					Game_Message::choice_cancel_type = list[index].parameters[0];
					SetupChoices(s_choices);
				}
			} else if ((index < list.size() - 1) && (list[index+1].code == Cmd::InputNumber) ) {
				// If next event command is input number
				// If input number fits on screen
				if (line_count < 4) {
					index++;
					Game_Message::num_input_start = line_count;
					Game_Message::num_input_digits_max = list[index].parameters[0];
					Game_Message::num_input_variable_id = list[index].parameters[1];
				}
			}

			return true;
		}
		index++;
	} // End for
}
Example #9
0
static Condition* GetCondition(char* string)
{
	unsigned int count;
	char **lines = GetStrings( string, count );
	Condition *condition = new Condition();
	for (size_t i = 0; i < count; ++i) {
		Trigger *trigger = GenerateTrigger(lines[i]);
		if (!trigger) {
			printMessage("DLGImporter", "Can't compile trigger: %s\n" , YELLOW, lines[i]);
		} else {
			condition->triggers.push_back(trigger);
		}
		free( lines[i] );
	}
	free( lines );
	return condition;
}
Example #10
0
int RegExp::ReplaceGlobal(String& t, Callback1<Vector<String>&> cbr)
{
	String t_copy(t);
	int count=0;
	int pos_offset=0;
	int rv_count=0;
	Vector<String> rv; 
	
	first = false;
	while(GlobalMatch(t_copy)) {
		rv.Clear();
		rv=GetStrings();
		cbr(rv);
		rv_count=rv.GetCount();
		count += Replace0(t, rv, rv_count, pos_offset);	
	}
	
	return count;
	
}
Example #11
0
main() 
{
    while (!feof(stdin)) { //пока файл не закончится
        char *s = GetString(); //находим строку
        if (!s) continue;
        
        if (TestWhile(s)) { //проверяем, на то, что это цикл
            int num = 0;
            char **strs = GetStrings(&num); //находим строчки учавствующие в цикле
            if (strs) {
                LoopStrings(strs, num, GetStart(s), GetLimit(s), GetStep(s));
                while (num--) free(strs[num]);
                free(strs);
            }
        }
        else PrintString(s);
        
        free(s);
    }
    
    return 0;
}
Example #12
0
int RegExp::Replace(String& t, Callback1<Vector<String>&> cbr)
{
	String t_copy(t);
	int count=0;
	int pos_offset=0;
	int rv_count=0;
	Vector<String> rv; 

	first=false;
	
	Match(t_copy);
	
	rv=GetStrings();	
	
	cbr(rv);	
	
	rv_count=rv.GetCount();
	
	Replace0(t, rv, rv_count, pos_offset);	

	return count;	
	
}
Example #13
0
bool luLogBox::save(const wxString& fileName)
{
	 wxTextFile file(fileName);
		 
	bool ok = wxFile::Exists(fileName) ? file.Open() : file.Create();

	if (ok)
	{
		file.Clear();
		wxArrayString lines = GetStrings();
		for (size_t i = 0; i < lines.GetCount(); i++)
		{
			file.AddLine(lines[i]);
		}
		ok = file.Write();
		wxLogMessage("Log file is saved: %s", fileName);
	}
	else
	{
		wxLogMessage("Can't open log file: %s", fileName);
	}

	return ok;
}
StringVector&   LogStream::GetStrings(const string entry, int nbLines){
  SetCurrentEntry(entry);
  return GetStrings(nbLines);  
}
Example #15
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static HINSTANCE  hInst ;
     static int        cxChar, cyChar, cxClient, cyClient ;
     static UINT       iDataChangeMsg ;
     CBPARAM           cbparam ;
     HDC               hdc ;
     PAINTSTRUCT       ps ;
     TEXTMETRIC        tm ;
     
     switch (message)
     {
     case WM_CREATE:
          hInst = ((LPCREATESTRUCT) lParam)->hInstance ;
          hdc   = GetDC (hwnd) ;
          GetTextMetrics (hdc, &tm) ;
          cxChar = (int) tm.tmAveCharWidth ;
          cyChar = (int) (tm.tmHeight + tm.tmExternalLeading) ;
          ReleaseDC (hwnd, hdc) ;

               // Register message for notifying instances of data changes

          iDataChangeMsg = RegisterWindowMessage (TEXT ("StrProgDataChange")) ;
          return 0 ;
          
     case WM_COMMAND:
          switch (wParam)
          {
          case IDM_ENTER:
               if (DialogBox (hInst, TEXT ("EnterDlg"), hwnd, &DlgProc))
               {
                    if (AddString (szString))
                         PostMessage (HWND_BROADCAST, iDataChangeMsg, 0, 0) ;
                    else
                         MessageBeep (0) ;
               }
               break ;
               
          case IDM_DELETE:
               if (DialogBox (hInst, TEXT ("DeleteDlg"), hwnd, &DlgProc))
               {
                    if (DeleteString (szString))
                         PostMessage (HWND_BROADCAST, iDataChangeMsg, 0, 0) ;
                    else
                         MessageBeep (0) ;
               }
               break ;
          }
          return 0 ;
          
     case WM_SIZE:
          cxClient = (int) LOWORD (lParam) ;
          cyClient = (int) HIWORD (lParam) ;
          return 0 ;
               
     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;
               
          cbparam.hdc   = hdc ;
          cbparam.xText = cbparam.xStart = cxChar ;
          cbparam.yText = cbparam.yStart = cyChar ;
          cbparam.xIncr = cxChar * MAX_LENGTH ;
          cbparam.yIncr = cyChar ;
          cbparam.xMax  = cbparam.xIncr * (1 + cxClient / cbparam.xIncr) ;
          cbparam.yMax  = cyChar * (cyClient / cyChar - 1) ;
               
          GetStrings ((GETSTRCB) GetStrCallBack, (PVOID) &cbparam) ;
              
          EndPaint (hwnd, &ps) ;
          return 0 ;
               
     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;

     default:
          if (message == iDataChangeMsg)
               InvalidateRect (hwnd, NULL, TRUE) ;
          break ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
Example #16
0
void wxBitmapComboBox::RecreateControl()
{
    //
    // Recreate control so that WM_MEASUREITEM gets called again.
    // Can't use CBS_OWNERDRAWVARIABLE because it has odd
    // mouse-wheel behaviour.
    //
    wxString value = GetValue();
    wxPoint pos = GetPosition();
    wxSize size = GetSize();
    size.y = GetBestSize().y;
    const wxArrayString strings = GetStrings();
    const unsigned numItems = strings.size();
    unsigned i;

    // Save the client data pointers before clearing the control, if any.
    const wxClientDataType clientDataType = GetClientDataType();
    wxVector<wxClientData*> objectClientData;
    wxVector<void*> voidClientData;
    switch ( clientDataType )
    {
        case wxClientData_None:
            break;

        case wxClientData_Object:
            objectClientData.reserve(numItems);
            for ( i = 0; i < numItems; ++i )
                objectClientData.push_back(GetClientObject(i));
            break;

        case wxClientData_Void:
            voidClientData.reserve(numItems);
            for ( i = 0; i < numItems; ++i )
                voidClientData.push_back(GetClientData(i));
            break;
    }

    wxComboBox::DoClear();

    HWND hwnd = GetHwnd();
    DissociateHandle();
    ::DestroyWindow(hwnd);

    if ( !MSWCreateControl(wxT("COMBOBOX"), wxEmptyString, pos, size) )
        return;

    // initialize the controls contents
    for ( i = 0; i < numItems; i++ )
    {
        wxComboBox::Append(strings[i]);

        if ( !objectClientData.empty() )
            SetClientObject(i, objectClientData[i]);
        else if ( !voidClientData.empty() )
            SetClientData(i, voidClientData[i]);
    }

    // and make sure it has the same attributes as before
    if ( m_hasFont )
    {
        // calling SetFont(m_font) would do nothing as the code would
        // notice that the font didn't change, so force it to believe
        // that it did
        wxFont font = m_font;
        m_font = wxNullFont;
        SetFont(font);
    }

    if ( m_hasFgCol )
    {
        wxColour colFg = m_foregroundColour;
        m_foregroundColour = wxNullColour;
        SetForegroundColour(colFg);
    }

    if ( m_hasBgCol )
    {
        wxColour colBg = m_backgroundColour;
        m_backgroundColour = wxNullColour;
        SetBackgroundColour(colBg);
    }
    else
    {
        SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
    }

    ::SendMessage(GetHwnd(), CB_SETITEMHEIGHT, 0, MeasureItem(0));

    // Revert the old string value
    if ( !HasFlag(wxCB_READONLY) )
        ChangeValue(value);
}
Example #17
0
short Directives()
{	
	int t;
	
	SkipWhiteSpace();

	if (*FilePtr != '.')
		return 0;

	DataCharPtr = FilePtr;

	if (QToken(".eof"))
	{
		// mark end of label array as end of bss
		
		strcpy(Name, "_________eof_________");
		Section = SECT_bss;
		DefineLabel(label_Local);

		SourceFileCheckEOF(LastTokenPtr() - FileTop);

		EndFile = 1;
		return 1;
	}


	GetToken();	
	t = ScanAsmToken();

	switch(t)
	{

//---------------------------------------------------------

	case 0:
		Error(Error_Skip, "Illegal directive '%s'",Name);


//---------------------------------------------------------

	case dir_sourcefile:
	{		
		int file;
		
		SkipWhiteSpace();
		GetLFileName();	

//		SetCSourceFile(Name);
		file = SetSLD_Name(Name);

		SetCSourceFile(Name, file);
		return 1;
	}

//---------------------------------------------------------


	case dir_model:
	{	
		int model=0;
	
		if (Token("full"))				// Get return type
			model = MODEL_full;
		else if (Token("half"))				// Get return type
			model = MODEL_half;
		else if (Token("compact"))			// Get return type
			model = MODEL_compact;
		else if (Token("mini"))				// Get return type
			model = MODEL_mini;
		else if (Token("tiny"))				// Get return type
			model = MODEL_tiny;
		else 
			Error(Error_Fatal, "invalid model type");

		// if model is not set then set it
			
		if (!CurrentModel)
			CurrentModel = model;
		else
		{
			if (model != CurrentModel)
				Error(Error_Fatal, "multiple architectual models defined");
		}

		return 1;
	}

//---------------------------------------------------------

	case dir_ctor:
	{
		SYMBOL* ref;
		imm = GetExpression();				// Get the number
		ref = GetLastSymbolRef();

		if(pass_count > 1)
		{
			if (!ref)
				Error(Error_Fatal, "Constructor has bad reference");

			ArraySet(&CtorArrayImm, CtorCount, imm);
			ArraySet(&CtorArray, CtorCount++, (int) ref);
		}
		return 1;		
	}

//---------------------------------------------------------

	case dir_dtor:
	{		
		SYMBOL* ref;
		imm = GetExpression();				// Get the number
		ref = GetLastSymbolRef();

		if(pass_count > 1)
		{
			if (!ref)
				Error(Error_Fatal, "Destructor has bad reference");

			ArraySet(&DtorArrayImm, DtorCount, imm);
			ArraySet(&DtorArray, DtorCount++, (int) ref);
		}
		return 1;		
	}


//---------------------------------------------------------

	case dir_sourcedir:
	{		
		SkipWhiteSpace();
		GetLFileName();	
		SetCSourceDir(Name);
		return 1;
	}

//---------------------------------------------------------

	case dir_line:
	{
		int v;
		
		SkipWhiteSpace();
		v = GetNum();	
		SetCSourceLine(v);
		SetSLD_Line(v);

		return 1;
	}

//---------------------------------------------------------

	case dir_dlab:
	{
		if (!ArgUseStabs)
		{
			SkipLine();			// Skip excess debug labels
			return 1;
		}

		// Define a label

		Section = SECT_code;

		GetAsmName();
		DefineLabel(label_Local);
		return 1;
	}

//---------------------------------------------------------

	case dir_library:
	{
		SkipLine();
		return 1;
	}

//---------------------------------------------------------

	case dir_exit:
	{
		if (NextToken("\""))
		{
			GetStringName(1024);

			Error(Error_Fatal, "User: %s", Name);
			return 1;
		}
	
	
		Error(Error_Fatal, "Exiting with user error");
		return 1;
	}

//---------------------------------------------------------

	case dir_asm_on:
	{
		return 1;
	}

//---------------------------------------------------------

	case dir_asm_off:
	{
/*		if (QToken(".asm_off"))
		{
			return 1;
		}
*/
		return 1;
	}

//---------------------------------------------------------

	case dir_AllowFarBranches:
	{
		AllowFarBranches = 1;
		return 1;
	}

//---------------------------------------------------------

	case dir_bp:
	{
		return 1;
	}

//---------------------------------------------------------

	case dir_localscope:
	{
		SkipWhiteSpace();

		if (Token("+"))
		{
			LocalScope++;
			return 1;
		}

		if (Token("reset"))
		{
			LocalScope = 1;
			return 1;
		}

		Error(Error_Fatal, "Bad .localscope type");
		return 1;
	}

//---------------------------------------------------------

	case dir_func:
	{	
		Function_Return_Type = RET_void;

		GetName();

		ReplaceChar(Name, '.', '_');

		Function_Param_Count = -1;

		if (Token(","))
		{
			Function_Param_Count = GetNum();

			if (Token(","))				// Get param count
			{				
				if (Token("int"))				// Get return type
					Function_Return_Type = RET_int;
				else if (Token("float"))
					Function_Return_Type = RET_float;
				else if (Token("double"))
					Function_Return_Type = RET_double;
				else if (Token("void"))
					Function_Return_Type = RET_void;
				else if (Token("?"))
					Function_Return_Type = RET_double;	//patch fix
			}
		}

		DefineLabel(label_Function);		
		return 1;
	}

//---------------------------------------------------------

	case dir_local:
	{
		GetName();
		return 1;
	}

//---------------------------------------------------------

	case dir_vec_elt:
	{
		GetName();
		return 1;
	}

//---------------------------------------------------------

	case dir_syscall:
	{
		char SysCallName[256];
		char istr[4096];
		char *iptr = 0;
		
		int v, p, r;
		
		p = 0;
		r = RET_void;
		
		GetName();
		strcpy(SysCallName,Name);
	
		SkipWhiteSpace();

		v = GetExpression();

		if (Token(","))				// Get param count
		{
			p = GetExpression();

			NeedToken(",");
			
			if (Token("int"))				// Get return type
				r = RET_int;
			else if (Token("float"))
				r = RET_float;
			else if (Token("double"))
				r = RET_double;
			else if (Token("void"))
				r = RET_void;

			if (Token(","))				// Get interface
			{
				GetStringName(2048);
				strcpy(istr,Name);
				iptr = istr;
			}

		}

		if (Pass == 1)
			MapSysCall(SysCallName, v, p, r, iptr);

		return 1;
	}

//---------------------------------------------------------

	case dir_lfile:
	{
		SkipWhiteSpace();
		GetLFileName();
		
		strcpy(CurrentFile, Name);
//		CurrentFileLine = GetLineNumber(FileTop,GetPrevFilePtr());
		
		AddFileSym(Name, LocalScope+1);
		
		GetRelPath(CurrentFile);
		return 1;
	}

//---------------------------------------------------------

	case dir_org:
	{
		int v = GetExpression();

		if (v >= MAX_CODE_MEM)
			Error(Error_Fatal, ".org has illegal address");

		CodeIP = v;
//!		CodePtr = &CodeMem[v];
		printf("*Warning* org %x\n", v);
		return 1;
	}


//---------------------------------------------------------

	case dir_set:
	{
		
		SkipWhiteSpace();

		// Catch Thunks
		
		if (Token("%"))
		{
			SYMBOL *ThunkSym;
			int v;

			v = GetDecNum(5);
			
			if (GetDecNumDigitCount() == 0)
				Error(Error_Fatal, "Missing Thunk Number");

			NeedToken("=");
			SkipWhiteSpace();

			GetName();			// Get the name of the thunk alias
			GetEnumValue(Name);	// Evaluate the symbol


			ThunkSym = GetLastSymbolRef();

			//N_FUN 141 4935 '_Z7XPClosev:F(0,6)'

			StabsEmit("N_THUNK %d %d '%s'\n", v, ThunkSym, Name);

			RegisterThunk(v, ThunkSym);
			return 1;
		}
		
		// Catch normal sets
		
		GetName();							// Get the new type Name	
		NeedToken("=");
		RedefENum(Name, GetExpression());	
		return 1;
	}

//---------------------------------------------------------

	case dir_debug:
	{
		DEBUG = (short)GetExpression();	
		return 1;
	}


//---------------------------------------------------------

	case dir_info:
	{
		INFO = (short)GetExpression();	
		return 1;
	}

//---------------------------------------------------------

	case dir_list:
	{
		LIST = (short)GetExpression();	
		return 1;
	}

//---------------------------------------------------------

	case dir_show:
	{
		int exp = GetExpression();
		
		if (Pass == 1)
			printf("%d",exp);

		if (!Token(";"))
			if (Pass == 1) printf("\n");
	
		return 1;
	}

//---------------------------------------------------------

	case dir_print:
	//if (QToken(".print") || QToken(".?"))
	{
		int exp;
		char v;
	
		if (Token("\""))
		{
			while(1)	
			{
				v = *FilePtr;
				
				if (v == 0 || v == '"')
					break;
				
				printf("%c",v);

				FilePtr++;
			}

			NeedToken("\"");

			if (!Token(";"))
				printf("\n");

			return 1;
		}

		exp = GetExpression();

		printf("%d",exp);

		if (!Token(";"))
			printf("\n");
	
		return 1;
	}

//---------------------------------------------------------

	case dir_ifdef:
	{
		GetName();							// Get the new type Name	
		SkipWhiteSpace();
		
		if (!SymbolExists(Name, section_Script, -1))
		{
			if (NextToken("{"))
			{
				SkipPair('{','}');
			}
		}
		return 1;
	}

//---------------------------------------------------------

	case dir_ifdefglobal:
	{
		GetName();							// Get the new type Name	
		SkipWhiteSpace();
		
		if (!SymbolExists(Name, section_Enum, 0))
		{
			if (NextToken("{"))
			{
				SkipPair('{','}');
			}
		}
		return 1;
	}

//---------------------------------------------------------

	case dir_ifndefglobal:
	{
		GetName();							// Get the new type Name	
		SkipWhiteSpace();
		
		if (SymbolExists(Name, section_Enum, 0))
		{
			if (NextToken("{"))
			{
				SkipPair('{','}');
			}
		}
		return 1;
	}

//---------------------------------------------------------

	case dir_ifndef:
	{
		GetName();							// Get the new type Name	
		SkipWhiteSpace();
		
		if (SymbolExists(Name, section_Script, -1))
		{
			if (NextToken("{"))
			{
				SkipPair('{','}');
			}
		}
		return 1;
	}

//---------------------------------------------------------

	case dir_if:
	{

		if (!GetExpression())
		{
			SkipWhiteSpace();

			if (NextToken("{"))
			{
				SkipPair('{','}');
			}
		}
		return 1;
	}


//---------------------------------------------------------

	case dir_do:
	{

		// If we have a '{' just ignore it an keep going
		
		if (Token("{"))
			return 1;
	
		// Must be an expression then

		// if false then skip to while

		if (!GetExpression())
		{
			SearchScopeForward();
			NeedToken(".enddo");
		}
			
		return 1;
	}

//---------------------------------------------------------

	case dir_enddo:
	{
		FilePtr = SearchScope(FilePtr);			
		return 1;
	}


//---------------------------------------------------------

	case dir_while:
	{
		if (GetExpression())
		{
			FilePtr = SearchScope(FilePtr);
		}
		return 1;
	}

//---------------------------------------------------------

	case dir_enum:
	{
		AsmEnums();
		return 1;
	}


//---------------------------------------------------------

	case dir_breakpoint:
	{
		SkipWhiteSpace();
		return 1;
	}

//---------------------------------------------------------

	case dir_globals_in_code:
	{
		GlobalsInCode = 1;
		SkipWhiteSpace();
		return 1;
	}

//---------------------------------------------------------

	case dir_globl:
//	if (QToken(".globl") || QToken(".global") || QToken(".weak"))
	{
		unsigned int n;
		
		GetAsmName();

		if (GlobalsInCode && (Section == SECT_code))
		{
//!			*CodePtr++ = '*';

			ArraySet(&CodeMemArray, CodeIP, '*');
			CodeIP++;

			for (n=0;n<strlen(Name);n++)
			{
//!				*CodePtr++ = Name[n];

				ArraySet(&CodeMemArray, CodeIP, Name[n]);
				CodeIP++;
			}
	
//!			*CodePtr++ = '*';

			ArraySet(&CodeMemArray, CodeIP, '*');
			CodeIP++;
		}

		if (LIST)
			printf("Found global '%s'\n",Name);

		DefineLabelGlobal();

//#ifdef INCLUDE_JAVAGEN
//		if (JavaPass)
//			JavaGen_Global(Name);
//#endif
		
		SkipWhiteSpace();
		return 1;
	}

//---------------------------------------------------------

	case dir_extern:
//	if (QToken(".extern") || QToken(".extrn"))
	{
		GetAsmName();

		if (LIST)
			printf("Found external '%s'\n",Name);

		// SHOULD DO NOTHING 
		//ExternDecl(Name);

		SkipWhiteSpace();
		return 1;
	}

//---------------------------------------------------------

	case dir_byte:
	{
		SetAsmDataChar();

		do
		{
			imm = GetExpression();					// Get the number

			WriteDataTypeArray(dir_byte, 1);
			WriteByte(imm);
		}
		while (QToken(","));

		return 1;

	}

//---------------------------------------------------------

	case dir_half:
	{
		SetAsmDataChar();

		do
		{
			imm = GetExpression();					// Get the number

			WriteDataTypeArray(dir_half, 2);
			WriteWord(imm);
		}
		while (QToken(","));

		return 1;
	}

//---------------------------------------------------------

	case dir_word:
	{
		SYMBOL *ref;
		
		if (Section != SECT_data)
			Error(Error_Skip,"data word in not in data section");

		SetAsmDataChar();
		
		do
		{
			imm = GetExpression();				// Get the number

			WriteDataTypeArray(dir_word, 4);

			ref = GetLastSymbolRef();
			WriteLongRef(imm, ref);

		}
		while (QToken(","));
		return 1;
	}

//---------------------------------------------------------

	case dir_space:
	{
		SetAsmDataChar();

		imm = GetExpression();					// Get the number

		if (LIST)
			printf("space %d\n",imm);
	
		if (!imm)
			return 1;

		WriteDataTypeArray(dir_space, imm);
		
		do
		{
			WriteByteSpace(0);
		}
		while(--imm);

		return 1;
	}

//---------------------------------------------------------

	case dir_string:
	{
		SetAsmDataChar();

		WriteDataTypeArray(dir_string, 1);

		GetStrings();
		return 1;
	}

//---------------------------------------------------------

	case dir_comm:
	{
		int LastSect = Section;

		SetAsmDataChar();

		Section = SECT_bss;

		GetAsmName();
		
		//!! make this global too

		DefineLabelGlobal();
		DefineLabel(label_Local);
		
		NeedToken(",");
				
		imm = GetExpression();					// Get the number

		if (LIST)
			printf("comm %d to .bss\n",imm);
	
		if (imm == 0)
			return 1;

		WriteDataTypeArray(dir_comm, imm);
		
		BssIP += imm;

		Section = LastSect;

		return 1;
	}

//---------------------------------------------------------

	case dir_lcomm:
	{
		int LastSect = Section;

		SetAsmDataChar();

		Section = SECT_bss;

		GetAsmName();
		DefineLabel(label_Local);
		
		NeedToken(",");
				
		imm = GetExpression();					// Get the number

		if (LIST)
			printf("lcomm %d to .bss\n",imm);
	
		if (imm == 0)
			return 1;

		WriteDataTypeArray(dir_lcomm, imm);
		
		BssIP += imm;

		Section = LastSect;

		return 1;
	}

//---------------------------------------------------------

	case dir_align:
	{
		imm = GetExpression();					// Get the number

		if (Section == SECT_code)
			return 1;

		AddAlignRef(imm);
		return 1;
	}


//---------------------------------------------------------

	case dir_bss:
	{
		Section = SECT_bss;

		if (LIST)
			printf("** Section .bss IP = %x\n",BssIP);

		return 1;
	}

//---------------------------------------------------------

	case dir_data:
	{
		Section = SECT_data;

		if (LIST)
			printf("** Section .data IP = %x\n",DataIP);

		return 1;
	}

//---------------------------------------------------------

	case dir_code:
//	if (QToken(".code") || QToken(".text"))
	{
		Section = SECT_code;

		if (LIST)
			printf("** Section .code IP = %x\n",CodeIP);

		return 1;
	}

//---------------------------------------------------------

	case dir_ent:
	{
		SkipLine();
		return 1;
	}


//---------------------------------------------------------

	case dir_end:
		return 1;

//---------------------------------------------------------

	case dir_stabs:
	{
		Parse_stabs();
		//SkipLine();
		return 1;
	}

//---------------------------------------------------------

	case dir_stabn:
	{
		Parse_stabn();
		//SkipLine();
		return 1;
	}

//---------------------------------------------------------

	case dir_stabd:
	{
		SkipLine();
		return 1;
	}

//---------------------------------------------------------

	}		// End of switch

	return 0;
}
// Commit
//------------------------------------------------------------------------------
/*virtual*/ bool FunctionCSAssembly::Commit( NodeGraph & nodeGraph, const BFFIterator & funcStartIter ) const
{
	// make sure all required variables are defined
	const BFFVariable * compiler;
	const BFFVariable * compilerOptions;
	const BFFVariable * compilerOutput;
	if ( !GetString( funcStartIter, compiler, ".Compiler", true ) ||
		 !GetString( funcStartIter, compilerOptions, ".CompilerOptions", true ) ||
		 !GetString( funcStartIter, compilerOutput, ".CompilerOutput", true ) )
	{
		return false;
	}

	Dependencies staticDeps( 32, true );

	// do we want to build a files in a directory?
	const BFFVariable * inputPath = BFFStackFrame::GetVar( ".CompilerInputPath" );
	if ( inputPath )
	{
		// get the optional pattern and recurse options related to InputPath
		Array< AString > patterns;
		if ( !GetStrings( funcStartIter, patterns, ".CompilerInputPattern", false ) )
		{
			return false; // GetString will have emitted an error
		}
		if ( patterns.IsEmpty() )
		{
			patterns.Append( AStackString<>( "*.cs" ) );
		}

		// recursive?  default to true
		bool recurse = true;
		if ( !GetBool( funcStartIter, recurse, ".CompilerInputPathRecurse", true, false ) )
		{
			return false; // GetBool will have emitted an error
		}

		// Support an exclusion path
		Array< AString > excludePaths;
		if ( !GetFolderPaths( funcStartIter, excludePaths, ".CompilerInputExcludePath", false ) )
		{
			return false; // GetFolderPaths will have emitted an error
		}

        Array< AString > filesToExclude(0, true);
        if ( !GetStrings( funcStartIter, filesToExclude, ".CompilerInputExcludedFiles", false ) ) // not required
        {
            return false; // GetStrings will have emitted an error
        }
	    CleanFileNames( filesToExclude );

		// Input paths
		Array< AString > inputPaths;
		if ( !GetFolderPaths( funcStartIter, inputPaths, ".CompilerInputPath", false ) )
		{
			return false; // GetFolderPaths will have emitted an error
		}

		Dependencies dirNodes( inputPaths.GetSize() );
		if ( !GetDirectoryListNodeList( nodeGraph, funcStartIter, inputPaths, excludePaths, filesToExclude, recurse, &patterns, "CompilerInputPath", dirNodes ) )
		{
			return false; // GetDirectoryListNodeList will have emitted an error
		}
		staticDeps.Append( dirNodes );
	}

	// do we want to build a specific list of files?
	if ( !GetNodeList( nodeGraph, funcStartIter, ".CompilerInputFiles", staticDeps, false ) )
	{
		// helper will emit error
		return false;
	}

	if ( staticDeps.IsEmpty() )
	{
		Error::Error_1006_NothingToBuild( funcStartIter, this );
		return false;
	}

	// additional references?
	Dependencies extraRefs( 0, true );
	if ( !GetNodeList( nodeGraph, funcStartIter, ".CompilerReferences", extraRefs, false ) )
	{
		// helper function will have emitted an error
		return false;
	}

    // Pre-build dependencies
	Dependencies preBuildDependencies;
	if ( !GetNodeList( nodeGraph, funcStartIter, ".PreBuildDependencies", preBuildDependencies, false ) )
	{
		return false; // GetNodeList will have emitted an error
	}

	// Create library node which depends on the single file or list
	if ( nodeGraph.FindNode( compilerOutput->GetString() ) )
	{
		Error::Error_1100_AlreadyDefined( funcStartIter, this, compilerOutput->GetString() );
		return false;
	}
	Node * csNode = nodeGraph.CreateCSNode( compilerOutput->GetString(),
									 staticDeps,
									 compiler->GetString(),
									 compilerOptions->GetString(),
									 extraRefs,
									 preBuildDependencies );

	// should we create an alias?
	return ProcessAlias( nodeGraph, funcStartIter, csNode );
}
Example #19
0
// GetInputs
//------------------------------------------------------------------------------
bool FunctionObjectList::GetInputs( const BFFIterator & iter, Dependencies & inputs ) const
{
	NodeGraph & ng = FBuild::Get().GetDependencyGraph();

	// do we want to build files via a unity blob?
    Array< AString > inputUnities;
    if ( !GetStrings( iter, inputUnities, ".CompilerInputUnity", false ) ) // not required
	{
		return false;
	}
    for ( const auto& unity : inputUnities )
    {
        Node * n = ng.FindNode( unity );
		if ( n == nullptr )
		{
			Error::Error_1104_TargetNotDefined( iter, this, "CompilerInputUnity", unity );
			return false;
		}
		if ( n->GetType() != Node::UNITY_NODE )
		{
			Error::Error_1102_UnexpectedType( iter, this, "CompilerInputUnity", unity, n->GetType(), Node::UNITY_NODE );
			return false;
		}
		inputs.Append( Dependency( n ) );
    }

	// do we want to build a files in a directory?
	const BFFVariable * inputPath = BFFStackFrame::GetVar( ".CompilerInputPath" );
	if ( inputPath )
	{
		// get the optional pattern and recurse options related to InputPath
		Array< AString > patterns;
		if ( !GetStrings( iter, patterns, ".CompilerInputPattern", false ) )
		{
			return false; // GetString will have emitted an error
		}
		if ( patterns.IsEmpty() )
		{
			patterns.Append( AStackString<>( "*.cpp" ) );
		}

		// recursive?  default to true
		bool recurse = true;
		if ( !GetBool( iter, recurse, ".CompilerInputPathRecurse", true, false ) )
		{
			return false; // GetBool will have emitted an error
		}

		// Support an exclusion path
		Array< AString > excludePaths;
		if ( !GetFolderPaths( iter, excludePaths, ".CompilerInputExcludePath", false ) )
		{
			return false; // GetFolderPaths will have emitted an error
		}

        Array< AString > filesToExclude;
        if ( !GetStrings( iter, filesToExclude, ".CompilerInputExcludedFiles", false ) ) // not required
        {
            return false; // GetStrings will have emitted an error
        }
	    CleanFileNames( filesToExclude );

		// Input paths
		Array< AString > inputPaths;
		if ( !GetFolderPaths( iter, inputPaths, ".CompilerInputPath", false ) )
		{
			return false; // GetFolderPaths will have emitted an error
		}

		Dependencies dirNodes( inputPaths.GetSize() );
		if ( !GetDirectoryListNodeList( iter, inputPaths, excludePaths, filesToExclude, recurse, &patterns, "CompilerInputPath", dirNodes ) )
		{
			return false; // GetDirectoryListNodeList will have emitted an error
		}
		inputs.Append( dirNodes );
	}

	// do we want to build a specific list of files?
	if ( !GetNodeList( iter, ".CompilerInputFiles", inputs, false ) )
	{
		// helper will emit error
		return false;
	}

	return true;
}
// Commit
//------------------------------------------------------------------------------
/*virtual*/ bool FunctionVCXProject::Commit( const BFFIterator & funcStartIter ) const
{
	// required
	AStackString<> projectOutput;
	AStackString<> rootNamespace;
	AStackString<> projectGuid;
	AStackString<> defaultLanguage;
	AStackString<> applicationEnvironment;
	if ( !GetString( funcStartIter, projectOutput,		".ProjectOutput", true ) ||
		 !GetString( funcStartIter, rootNamespace,		".RootNamespace", false ) ||
		 !GetString( funcStartIter, projectGuid,		".ProjectGuid", false ) ||
		 !GetString( funcStartIter, defaultLanguage,	".DefaultLanguage", false ) ||
		 !GetString( funcStartIter, applicationEnvironment,	".ApplicationEnvironment", false ) )
	{
		return false;
	}

	// optional inputs
	Array< AString > inputPaths;
	Array< AString > inputPathsExclude;
	if ( !GetStrings( funcStartIter, inputPaths,		".ProjectInputPaths", false ) ||
		 !GetStrings( funcStartIter, inputPathsExclude,	".ProjectInputPathsExclude", false ) )
	{
		return false;
	}

	// project base
	Array< AString > basePaths;
	if ( !GetStrings( funcStartIter, basePaths,	".ProjectBasePath", false ) )
	{
		return false;
	}
	CleanFolderPaths( basePaths );

	// references
	Array< AString > references;
	Array< AString > projectReferences;
	if ( !GetStrings( funcStartIter, references,		".ProjectReferences", false ) ||
		 !GetStrings( funcStartIter, projectReferences,	".ProjectProjectReferences", false ) )
	{
		return false;
	}

	// permitted file extensions
	Array< AString > allowedFileExtensions( 8, true );
	if ( !GetStrings( funcStartIter, allowedFileExtensions, ".ProjectAllowedFileExtensions", false ) )
	{
		return true;
	}
	if ( allowedFileExtensions.IsEmpty() )
	{
		const char * extensions[] = { ".cpp", ".hpp", ".cxx",".hxx",".c",".h",".cc",".hh",
									  ".cp",".hp",".cs",".inl",".bff",".rc",".resx",".m",".mm",
									  ".cu",
									  nullptr };
		AStackString<> tmp;
		const char ** item = extensions;
		while ( *item )
		{
			tmp.Assign( *item );
			allowedFileExtensions.Append( tmp );
			++item;
		}
	}

	// files and filesToExclude
	Array< AString > files( 8, true );
	Array< AString > filesToExclude( 8, true );	
	if ( !GetStrings( funcStartIter, files,				".ProjectFiles", false ) ||
 		 !GetStrings( funcStartIter, filesToExclude,	".ProjectFilesToExclude", false ) )
	{
		return false;
	}

	// filetypes
	Array< VSProjectFileType > fileTypes;
	const BFFVariable * projectFileTypes = BFFStackFrame::GetVar( ".ProjectFileTypes" );
	if ( projectFileTypes )
	{
		if ( projectFileTypes->IsArrayOfStructs() == false )
		{
			Error::Error_1050_PropertyMustBeOfType( funcStartIter, this, ".ProjectFileTypes", projectFileTypes->GetType(), BFFVariable::VAR_ARRAY_OF_STRUCTS );
			return false;
		}

		const Array< const BFFVariable * > & structs = projectFileTypes->GetArrayOfStructs();
		const BFFVariable * const * end = structs.End();
		for ( const BFFVariable ** it = structs.Begin(); it != end; ++it )
		{
			const BFFVariable * s = *it;

			VSProjectFileType ft;

			// .FileType must be provided
			if ( !GetStringFromStruct( s, ".FileType",	ft.m_FileType ) )
			{
				// TODO:B custom error
				Error::Error_1101_MissingProperty( funcStartIter, this, AStackString<>( ".FileType" ) );
				return false;
			}

			// .Pattern must be provided
			if ( !GetStringFromStruct( s, ".Pattern",	ft.m_Pattern ) )
			{
				// TODO:B custom error
				Error::Error_1101_MissingProperty( funcStartIter, this, AStackString<>( ".Pattern" ) );
				return false;
			}

			fileTypes.Append( ft );
		}
	}

	// path cleaning
	CleanFolderPaths( inputPaths );			// input paths
	CleanFolderPaths( inputPathsExclude );	// exclude paths
	CleanFilePaths( files );				// explicit files

	// per-config options
	VSProjectConfig baseConfig;

	// various options
	if ( !GetString( funcStartIter, baseConfig.m_BuildCommand,	".ProjectBuildCommand", false ) ||
		 !GetString( funcStartIter, baseConfig.m_RebuildCommand,".ProjectRebuildCommand", false ) ||
		 !GetString( funcStartIter, baseConfig.m_CleanCommand,	".ProjectCleanCommand", false ) ||
		 !GetString( funcStartIter, baseConfig.m_Output,		".Output", false ) ||
		 !GetString( funcStartIter, baseConfig.m_PreprocessorDefinitions,	".PreprocessorDefinitions", false ) ||
		 !GetString( funcStartIter, baseConfig.m_IncludeSearchPath,		".IncludeSearchPath", false ) ||
		 !GetString( funcStartIter, baseConfig.m_ForcedIncludes,		".ForcedIncludes", false ) ||
		 !GetString( funcStartIter, baseConfig.m_AssemblySearchPath,	".AssemblySearchPath", false ) ||
		 !GetString( funcStartIter, baseConfig.m_ForcedUsingAssemblies,	".ForcedUsingAssemblies", false ) ||
		 !GetString( funcStartIter, baseConfig.m_AdditionalOptions,		".AdditionalOptions", false ) ||
		 !GetString( funcStartIter, baseConfig.m_OutputDirectory,		".OutputDirectory", false ) ||
		 !GetString( funcStartIter, baseConfig.m_IntermediateDirectory,	".IntermediateDirectory", false ) ||
		 !GetString( funcStartIter, baseConfig.m_Xbox360DebuggerCommand,".Xbox360DebuggerCommand", false ) ||
		 !GetString( funcStartIter, baseConfig.m_LayoutDir,				".LayoutDir", false ) ||
		 !GetString( funcStartIter, baseConfig.m_LayoutExtensionFilter,	".LayoutExtensionFilter", false ) ||
		 !GetString( funcStartIter, baseConfig.m_DebuggerFlavor,		".DebuggerFlavor", false ) ||
		 !GetString( funcStartIter, baseConfig.m_AumidOverride,			".AumidOverride", false ) ||
		 !GetString( funcStartIter, baseConfig.m_PlatformToolset,		".PlatformToolset", false ) ||
		 !GetString( funcStartIter, baseConfig.m_DeploymentType,		".DeploymentType", false ) ||
		 !GetString( funcStartIter, baseConfig.m_DeploymentFiles,		".DeploymentFiles", false ) ||
		 !GetString( funcStartIter, baseConfig.m_LocalDebuggerCommandArguments,	".LocalDebuggerCommandArguments", false ) ||
		 !GetString( funcStartIter, baseConfig.m_LocalDebuggerWorkingDirectory,	".LocalDebuggerWorkingDirectory", false ) ||
		 !GetString( funcStartIter, baseConfig.m_LocalDebuggerCommand,			".LocalDebuggerCommand", false ) ||
		 !GetString( funcStartIter, baseConfig.m_LocalDebuggerEnvironment,		".LocalDebuggerEnvironment", false ) )
	{
		return false;
	}

	// create configs
	Array< VSProjectConfig > configs( 16, true );

	const BFFVariable * projectConfigs = BFFStackFrame::GetVar( ".ProjectConfigs" );
	if ( projectConfigs )
	{
		if ( projectConfigs->IsArrayOfStructs() == false )
		{
			Error::Error_1050_PropertyMustBeOfType( funcStartIter, this, ".ProjectConfigs", projectConfigs->GetType(), BFFVariable::VAR_ARRAY_OF_STRUCTS );
			return false;
		}

		const Array< const BFFVariable * > & structs = projectConfigs->GetArrayOfStructs();
		const BFFVariable * const * end = structs.End();
		for ( const BFFVariable ** it = structs.Begin(); it != end; ++it )
		{
			const BFFVariable * s = *it;

			// start with the base configuration
			VSProjectConfig newConfig( baseConfig );

			// .Platform must be provided
			if ( !GetStringFromStruct( s, ".Platform",	newConfig.m_Platform ) )
			{
				// TODO:B custom error
				Error::Error_1101_MissingProperty( funcStartIter, this, AStackString<>( ".Platform" ) );
				return false;
			}

			// .Config must be provided
			if ( !GetStringFromStruct( s, ".Config",	newConfig.m_Config ) )
			{
				// TODO:B custom error
				Error::Error_1101_MissingProperty( funcStartIter, this, AStackString<>( ".Config" ) );
				return false;
			}

			GetStringFromStruct( s, ".ProjectBuildCommand",		newConfig.m_BuildCommand );
			GetStringFromStruct( s, ".ProjectRebuildCommand",	newConfig.m_RebuildCommand );
			GetStringFromStruct( s, ".ProjectCleanCommand",		newConfig.m_CleanCommand );
			GetStringFromStruct( s, ".Output",					newConfig.m_Output );
			GetStringFromStruct( s, ".PreprocessorDefinitions",	newConfig.m_PreprocessorDefinitions );
			GetStringFromStruct( s, ".IncludeSearchPath",		newConfig.m_IncludeSearchPath );
			GetStringFromStruct( s, ".ForcedIncludes",			newConfig.m_ForcedIncludes );
			GetStringFromStruct( s, ".AssemblySearchPath",		newConfig.m_AssemblySearchPath );
			GetStringFromStruct( s, ".ForcedUsingAssemblies",	newConfig.m_ForcedUsingAssemblies );
			GetStringFromStruct( s, ".AdditionalOptions",		newConfig.m_AdditionalOptions );
			GetStringFromStruct( s, ".OutputDirectory",			newConfig.m_OutputDirectory );
			GetStringFromStruct( s, ".IntermediateDirectory",	newConfig.m_IntermediateDirectory );
		 	GetStringFromStruct( s, ".LayoutDir",				newConfig.m_LayoutDir );
			GetStringFromStruct( s, ".LayoutExtensionFilter",	newConfig.m_LayoutExtensionFilter );
			GetStringFromStruct( s, ".Xbox360DebuggerCommand",	newConfig.m_Xbox360DebuggerCommand );
			GetStringFromStruct( s, ".DebuggerFlavor",			newConfig.m_DebuggerFlavor );
			GetStringFromStruct( s, ".AumidOverride",			newConfig.m_AumidOverride );
			GetStringFromStruct( s, ".PlatformToolset",			newConfig.m_PlatformToolset );
			GetStringFromStruct( s, ".DeploymentType",			newConfig.m_DeploymentType );
			GetStringFromStruct( s, ".DeploymentFiles",			newConfig.m_DeploymentFiles );
			GetStringFromStruct( s, ".LocalDebuggerCommandArguments",	newConfig.m_LocalDebuggerCommandArguments );
			GetStringFromStruct( s, ".LocalDebuggerWorkingDirectory",	newConfig.m_LocalDebuggerWorkingDirectory );
			GetStringFromStruct( s, ".LocalDebuggerCommand",			newConfig.m_LocalDebuggerCommand );
			GetStringFromStruct( s, ".LocalDebuggerEnvironment",		newConfig.m_LocalDebuggerEnvironment );

			configs.Append( newConfig );
		}
	}
	else
	{
		// no user specified configs, make some defaults

		// start from the default
		VSProjectConfig config( baseConfig );

		// make the configs
		config.m_Platform	= "Win32";
		config.m_Config		= "Debug";
		configs.Append( config );
		config.m_Config		= "Release";
		configs.Append( config );
		config.m_Platform	= "x64";
		configs.Append( config );
		config.m_Config		= "Debug";
		configs.Append( config );
	}

	NodeGraph & ng = FBuild::Get().GetDependencyGraph();

	// create all of the DirectoryListNodes we need
	Dependencies dirNodes( inputPaths.GetSize() );
	if ( !GetDirectoryListNodeList( funcStartIter, inputPaths, Array< AString >(), Array< AString >(), true, nullptr, "ProjectInputPaths", dirNodes ) )
	{
		return false; // GetDirectoryListNodeList will have emitted an error
	}

	// Check for existing node
	if ( ng.FindNode( projectOutput ) )
	{
		Error::Error_1100_AlreadyDefined( funcStartIter, this, projectOutput );
		return false;
	}

	VCXProjectNode * pn = ng.CreateVCXProjectNode( projectOutput,
												   basePaths,
												   dirNodes,
												   inputPathsExclude, // TODO:B Remove this (handled by DirectoryListNode now)
												   allowedFileExtensions, // TODO:B Remove this (handled by DirectoryListNode now)
												   files,
												   filesToExclude,
												   rootNamespace,
												   projectGuid,
												   defaultLanguage,
												   applicationEnvironment,
												   configs,
												   fileTypes,
												   references,
												   projectReferences );

	ASSERT( pn );

	return ProcessAlias( funcStartIter, pn );
}
Example #21
0
short ResourceCommands()
{
	char *filemem;
	int filelen;
	int n,v;

	SkipWhiteSpace();

//---------------------------------------------------------

	if (QToken(".library"))
	{
		SkipLine();
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".lfile"))
	{
		SkipWhiteSpace();

		GetLFileName();

		GetRelPath(Name);
		return 1;
	}


	if (QToken(".localscope"))
	{
		SkipWhiteSpace();
		NeedToken("+");

//		LocalScope++;
		return 1;
	}


	if (QToken(".res"))
	{
		// If there is previous data to be written out
		// do it here !!

		if (ResType != 0)
		{
			FinalizeResource();
		}

		SkipWhiteSpace();

		ResName[0] = 0;
		Name[0] = 0;

		if (isalpha(*FilePtr))
		{
			GetName();						// Get the new type Name
			strcpy(ResName, Name);
		}


		// Clear index table

		IndexCount = 0;
		IndexWidth = 0;

		MakeNewResource(Name);				// Make this symbolic
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".index"))
	{
		int IndexOffset = GetDataIndex();

		SkipWhiteSpace();

		Name[0] = 0;

		if (isalpha(*FilePtr))
			GetName();						// Get the index ref name

		// add index to table

		IndexTable[IndexCount] = IndexOffset;

//		MakeIndexedResource(IndexName, IndexCount);

		infoprintf("%d: index = %d ('%s')\n",IndexCount, IndexOffset, Name);

		if (Pass == 2)
			if (Name[0])
				fprintf(HeaderFile,"#define idx_%s %d\n", Name, IndexCount);

		IndexCount++;
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".wideindex"))
	{
		IndexWidth = 1;
		SkipWhiteSpace();
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".extension"))
	{
		SkipWhiteSpace();

		v = GetExpression();		// x

		ResType = v;

		infoprintf("%d: Prototype = %d\n",CurrentResource, ResType);
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".dispose"))
	{
		SkipWhiteSpace();

		ResDispose = 1;
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".placeholder"))
	{
		ResType = ResType_PlaceHolder;

		infoprintf("%d: Placeholder\n",CurrentResource);
		return 1;
	}


//------------------------------------
//
//------------------------------------

	if (QToken(".skip"))
	{
		ResType = ResType_Skip;

		infoprintf("%d: Skip\n",CurrentResource);
		return 1;
	}


//------------------------------------
//
//------------------------------------

	if (QToken(".bin"))
	{
		ResType = ResType_Binary;

		infoprintf("%d: Binary\n",CurrentResource);
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".ubin"))
	{
		ResType = ResType_UBinary;

		infoprintf("%d: UBinary\n",CurrentResource);
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".media"))
	{
		int slen;

		SkipWhiteSpace();

		ResType = ResType_Binary;			//ResType_Media;
		GetStringName(128);

		slen = strlen(Name) + 1;

		for (n=0;n<slen;n++)
			WriteByte(Name[n]);

		SkipWhiteSpace();
		NeedToken(",");
		SkipWhiteSpace();

		GetStringName(128);

		if(Do_Export_Dependencies && Pass == 2) {
			ExportFileDependency(Name);
		}

		filemem = Open_FileAlloc(AddRelPrefix(Name));

		if (!filemem)
		{
			Error(Error_Fatal, "Error reading data file '%s'", Name);
			return 1;
		}

		filelen = FileAlloc_Len();

		for (n=0;n<filelen;n++)
		{
			WriteByte(filemem[n]);
		}

		Free_File(filemem);

		infoprintf("%d: Media Binary\n",CurrentResource);
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".umedia"))
	{
		int slen;

		SkipWhiteSpace();

		ResType = ResType_UBinary; //ResType_UMedia;
		GetStringName(128);

		slen = strlen(Name) + 1;

		for (n=0;n<slen;n++)
			WriteByte(Name[n]);

		SkipWhiteSpace();
		NeedToken(",");
		SkipWhiteSpace();

		GetStringName(128);

		if(Do_Export_Dependencies && Pass == 2) {
			ExportFileDependency(Name);
		}

		filemem = Open_FileAlloc(AddRelPrefix(Name));

		if (!filemem)
		{
			Error(Error_Fatal, "Error reading data file '%s'", Name);
			return 1;
		}

		filelen = FileAlloc_Len();

		for (n=0;n<filelen;n++)
		{
			WriteByte(filemem[n]);
		}

		Free_File(filemem);

		infoprintf("%d: Media Binary\n",CurrentResource);
		return 1;
	}

//------------------------------------
//
//------------------------------------
/*
	if (QToken(".file"))
	{
		SkipWhiteSpace();

		ResType = ResType_File;

		GetStringName(128);

		filemem = Open_FileAlloc(AddRelPrefix(Name));

		if (!filemem)
		{
			Error("Error reading data file '%s'", Name);
			return 1;
		}

		filelen = FileAlloc_Len();

		for (n=0;n<filelen;n++)
		{
			WriteByte(filemem[n]);
		}

		Free_File(filemem);

		printf("%d: File '%s' size %d\n", CurrentResource, Name, filelen);
		return 1;
	}
*/

//------------------------------------
//
//------------------------------------

	if (QToken(".label"))			// filename
	{
		int slen;

		SkipWhiteSpace();

		ResType = ResType_Label;
		GetStringName(128);

		slen = strlen(Name) + 1;

		for (n=0;n<slen;n++)
			WriteByte(Name[n]);

		return 1;
	}


//------------------------------------
//
//------------------------------------

// ResType_TileSet = 7
// ushort xsize, ysize
// bytes png_image

	if (QToken(".tileset"))			// filename
	{
		int xsize,ysize;

		SkipWhiteSpace();

		ResType = ResType_TileSet;

		GetStringName(128);

		SkipWhiteSpace();
		NeedToken(",");
		SkipWhiteSpace();

		xsize = GetExpression();		// xsize

		SkipWhiteSpace();
		NeedToken(",");
		SkipWhiteSpace();

		ysize = GetExpression();		// ysize

		WriteWord(xsize);
		WriteWord(ysize);

		if(Do_Export_Dependencies && Pass == 2) {
			ExportFileDependency(Name);
		}

		filemem = Open_FileAlloc(AddRelPrefix(Name));

		if (!filemem)
		{
			Error(Error_Fatal, "Error reading tileset file '%s'", Name);
			return 1;
		}

		filelen = FileAlloc_Len();

		for (n=0;n<filelen;n++)
			WriteByte(filemem[n]);

		Free_File(filemem);

		infoprintf("%d: Tileset '%s' cxy %d,%d size %d\n", CurrentResource, Name, xsize, ysize, filelen);
		return 1;
	}

//------------------------------------
//
//------------------------------------

// ResType_TileMap = 8
// ushort mapWidth, mapHeight
// ushort map[mapWidth*mapHeight]

	if (QToken(".tilemap"))			// filename
	{
		int xsize,ysize;

		SkipWhiteSpace();

		ResType = ResType_TileMap;

		GetStringName(128);

		SkipWhiteSpace();
		NeedToken(",");
		SkipWhiteSpace();

		xsize = GetExpression();		// xsize

		SkipWhiteSpace();
		NeedToken(",");
		SkipWhiteSpace();

		ysize = GetExpression();		// ysize

		if(Do_Export_Dependencies && Pass == 2) {
			ExportFileDependency(Name);
		}

		filemem = Open_FileAlloc(AddRelPrefix(Name));

		if (!filemem)
		{
			Error(Error_Fatal, "Error reading tilemap file '%s'", Name);
			return 1;
		}

		filelen = FileAlloc_Len();

		if (filelen != (xsize * ysize * 2))
		{
			Error(Error_Fatal, "%d: Tilemap '%s' xy %d,%d size %d\n", CurrentResource, Name, xsize, ysize, filelen);
			return 1;
		}

		WriteWord(xsize);
		WriteWord(ysize);

		for (n=0;n<filelen;n++)
			WriteByte(filemem[n]);

		Free_File(filemem);

		infoprintf("%d: Tilemap '%s' cxy %d,%d size %d\n", CurrentResource, Name, xsize, ysize, filelen);
		return 1;


	}

//------------------------------------
//
//------------------------------------

	if (QToken(".image"))			// filename
	{
		SkipWhiteSpace();

		ResType = ResType_Image;

		GetStringName(128);

/*
		spr_cx = spr_cy = 0;

		SkipWhiteSpace();

		if (QToken(","))
		{
			spr_cx = GetExpression();		// cx

			SkipWhiteSpace();
			NeedToken(",");
			SkipWhiteSpace();

			spr_cy = GetExpression();		// cy
		}

		WriteWord(spr_cx);
		WriteWord(spr_cy);
*/
		if(Do_Export_Dependencies && Pass == 2) {
			ExportFileDependency(Name);
		}

		filemem = Open_FileAlloc(AddRelPrefix(Name));

		if (!filemem)
		{
			Error(Error_Fatal, "Error reading image file '%s'", Name);
			return 1;
		}

		filelen = FileAlloc_Len();

		// write the length
		//WriteEncodedInt(filelen);

		for (n=0;n<filelen;n++)
			WriteByte(filemem[n]);

		Free_File(filemem);

		infoprintf("%d: Image '%s' cxy %d,%d size %d\n", CurrentResource, Name, spr_cx, spr_cy, filelen);
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".sprite"))			// index, x,y,w,h,cx,cy
	{
		ResType = ResType_Sprite;

		SkipWhiteSpace();

		spr_ind = v = GetExpression();		// ind
		WriteWord(v);

		SkipWhiteSpace();
		NeedToken(",");
		SkipWhiteSpace();

		spr_x = v = GetExpression();		// x
		WriteWord(v);

		SkipWhiteSpace();
		NeedToken(",");
		SkipWhiteSpace();

		spr_y = v = GetExpression();		// y
		WriteWord(v);

		SkipWhiteSpace();
		NeedToken(",");
		SkipWhiteSpace();

		spr_w = v = GetExpression();		// w
		WriteWord(v);

		SkipWhiteSpace();
		NeedToken(",");
		SkipWhiteSpace();

		spr_h = v = GetExpression();		// h
		WriteWord(v);

		spr_cx = spr_cy = 0;

		SkipWhiteSpace();

		if (QToken(","))
		{
			spr_cx = (short)GetExpression();		// cx

			SkipWhiteSpace();
			NeedToken(",");
			SkipWhiteSpace();

			spr_cy = (short)GetExpression();		// cy
		}

		WriteWord(spr_cx);
		WriteWord(spr_cy);


		infoprintf("%d: Sprite ind %d, xy %d,%d, wh %d,%d cxy %d,%d\n",
			CurrentResource, spr_ind, spr_x, spr_y, spr_w, spr_h, spr_cx, spr_cy);

		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".end"))
	{
		SkipLine();
//		EndComp = 1;
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".eof"))
	{
		SkipLine();
		EndComp = 1;
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".parseheader"))
	{
		GetStringName(128);
		ReadAndParseHeaders(Name);
		return 1;
	}

//------------------------------------
// Other directives
//------------------------------------

	if (QToken(".set"))
	{
		if (QToken("$"))
		{
			char VarName[256];

			// Accept a string

			GetName();							// Get the new type Name
			strcpy(VarName, Name);
			NeedToken("=");
			GetStringName(128);

			printf("string set %s = '%s'\n", VarName, Name);

			RedefENumString(VarName, Name);
			return 1;
		}

		GetName();							// Get the new type Name
		NeedToken("=");
		RedefENum(Name, GetExpression());
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".debug"))
	{
		DEBUG = (short)GetExpression();
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".info"))
	{
		INFO = (short)GetExpression();
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".list"))
	{
		LIST = (short)GetExpression();
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".show"))
	{
		int exp = GetExpression();

		printf("%d",exp);

		if (!Token(";"))
			printf("\n");

		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".print") || QToken(".?"))
	{
		int exp;
		char c;

		if (Token("\""))
		{
			while(1)
			{
				c = *FilePtr;

				if (c == 0 || c == '"')
					break;

				printf("%c",c);

				FilePtr++;
			}

			NeedToken("\"");

			if (!Token(";"))
				printf("\n");

			return 1;
		}

		exp = GetExpression();

		printf("%d",exp);

		if (!Token(";"))
			printf("\n");

		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".if"))
	{
		if (!GetExpression())
		{
			if (NextToken("{"))
			{
				SkipPair('{','}');
			}
		}
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".ifdef"))
	{
		GetName();							// Get the new type Name
		SkipWhiteSpace();

		if (!SymbolExists(Name, section_Script, -1))
		{
			if (NextToken("{"))
			{
				SkipPair('{','}');
			}
		}
		return 1;
	}


//------------------------------------
//
//------------------------------------

	if (QToken(".ifndef"))
	{
		GetName();							// Get the new type Name
		SkipWhiteSpace();

		if (SymbolExists(Name, section_Script, -1))
		{
			if (NextToken("{"))
			{
				SkipPair('{','}');
			}
		}
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".while"))
	{

		if (GetExpression())
		{
			FilePtr = SearchScope(FilePtr);
		}
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".enum"))
	{
		AsmEnums();
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".include"))			// filename
	{
		SkipWhiteSpace();

		GetStringName(128);

		if(Do_Export_Dependencies && Pass == 2) {
			ExportFileDependency(Name);
		}

		filemem = Open_FileAlloc(AddRelPrefix(Name));

		if (!filemem)
		{
			Error(Error_Fatal, "Error reading include file '%s'", Name);
			return 1;
		}

		filelen = FileAlloc_Len();

		for (n=0;n<filelen;n++)
			WriteByte(filemem[n]);

		Free_File(filemem);

		infoprintf("bin include '%s' size %d\n", Name, filelen);
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".varint"))
	{
		do
		{
			imm = GetExpression();					// Get the number
			WriteEncodedInt(imm);
		}
		while (QToken(","));

		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".varsint"))
	{
		do
		{
			imm = GetExpression();					// Get the number
			WriteEncodedSignedInt(imm);
		}
		while (QToken(","));

		return 1;

	}

//------------------------------------
//
//------------------------------------

	if (QToken(".byte"))
	{
		do
		{
			imm = GetExpression();					// Get the number
			WriteByte(imm);
		}
		while (QToken(","));

		return 1;

	}

//------------------------------------
//
//------------------------------------

	if (QToken(".half"))
	{

		do
		{
			imm = GetExpression();					// Get the number

			WriteWord(imm);
		}
		while (QToken(","));

		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".word"))
	{
		do
		{
			imm = GetExpression();				// Get the number

			WriteLong(imm);
		}
		while (QToken(","));
		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".fill"))
	{
		imm = GetExpression();					// Get the number

		if (!imm)
			return 1;

		NeedToken(",");

		v = GetExpression();

		do
		{
			WriteByte(v);
		}
		while(--imm);

		return 1;
	}


//------------------------------------
//
//------------------------------------

	if (QToken(".pstring"))
	{
		int dataStart;
		int len;

		// Write length byte

		WriteByte(0);

		// Get current data location

		dataStart = DataIP;

		// read string to mem

		GetStrings();

		// find the string length

		len = DataIP - dataStart;

		if (len > 255)
		{
			Error(Error_Skip, "pstring is longer that 255 chars\n");
			return 1;
		}

		// Patch the string length

		ArraySet(&DataMemArray, dataStart-1, len);


		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".cstring"))
	{
		GetStrings();
		WriteByte(0);

		return 1;
	}

//------------------------------------
//
//------------------------------------

	if (QToken(".string"))
	{
		GetStrings();
		return 1;
	}

//------------------------------------
//
//------------------------------------

// Error


	GetAsmName();
	Error(Error_Fatal, "Illegal resource directive '%s'",Name);

	return 0;
}
Example #22
0
// Commit
//------------------------------------------------------------------------------
/*virtual*/ bool FunctionCopy::Commit( NodeGraph & nodeGraph, const BFFIterator & funcStartIter ) const
{
    // make sure all required variables are defined
    Array< AString > sources( 16, true );
    const BFFVariable * dstFileV;
    if ( !GetStrings( funcStartIter, sources, ".Source", true ) ||
         !GetString( funcStartIter, dstFileV, ".Dest", true ) )
    {
        return false; // GetString will have emitted errors
    }

    // Optional
    AStackString<> sourceBasePath;
    if ( !GetString( funcStartIter, sourceBasePath, ".SourceBasePath", false ) )
    {
        return false; // GetString will have emitted errors
    }

    // Canonicalize the SourceBasePath
    if ( !sourceBasePath.IsEmpty() )
    {
        AStackString<> cleanValue;
        NodeGraph::CleanPath( sourceBasePath, cleanValue );
        PathUtils::EnsureTrailingSlash( cleanValue );
        sourceBasePath = cleanValue;
    }

    // check sources are not paths
    {
        const AString * const end = sources.End();
        for ( const AString * it = sources.Begin(); it != end; ++it )
        {
            const AString & srcFile( *it );

            // source must be a file, not a  path
            if ( PathUtils::IsFolderPath( srcFile ) )
            {
                Error::Error_1105_PathNotAllowed( funcStartIter, this, ".Source", srcFile );
                return false;
            }
        }
    }

    // Pre-build dependencies
    Dependencies preBuildDependencies;
    if ( !GetNodeList( nodeGraph, funcStartIter, ".PreBuildDependencies", preBuildDependencies, false ) )
    {
        return false; // GetNodeList will have emitted an error
    }
    Array< AString > preBuildDependencyNames( preBuildDependencies.GetSize(), false );
    for ( const auto & dep : preBuildDependencies )
    {
        preBuildDependencyNames.Append( dep.GetNode()->GetName() );
    }

    // get source node
    Array< Node * > srcNodes;
    {
        const AString * const end = sources.End();
        for ( const AString * it = sources.Begin(); it != end; ++it )
        {

            Node * srcNode = nodeGraph.FindNode( *it );
            if ( srcNode )
            {
                if ( GetSourceNodes( funcStartIter, srcNode, srcNodes ) == false )
                {
                    return false;
                }
            }
            else
            {
                // source file not defined by use - assume an external file
                srcNodes.Append( nodeGraph.CreateFileNode( *it ) );
            }
        }
    }

    AStackString<> dstFile;
    NodeGraph::CleanPath( dstFileV->GetString(), dstFile );
    const bool dstIsFolderPath = PathUtils::IsFolderPath( dstFile );

    // make all the nodes for copies
    Dependencies copyNodes( srcNodes.GetSize(), false );
    for ( const Node * srcNode : srcNodes )
    {
        AStackString<> dst( dstFile );

        // dest can be a file OR a path.  If it's a path, use the source filename part
        if ( dstIsFolderPath )
        {
            // find filename part of source
            const AString & srcName = srcNode->GetName();

            // If the sourceBasePath is specified (and valid) use the name relative to that
            if ( !sourceBasePath.IsEmpty() && PathUtils::PathBeginsWith( srcName, sourceBasePath ) )
            {
                // Use everything relative to the SourceBasePath
                dst += srcName.Get() + sourceBasePath.GetLength();
            }
            else
            {
                // Use just the file name
                const char * lastSlash = srcName.FindLast( NATIVE_SLASH );
                dst += lastSlash ? ( lastSlash + 1 )    // append filename part if found
                                     : srcName.Get();   // otherwise append whole thing
            }
        }

        // check node doesn't already exist
        if ( nodeGraph.FindNode( dst ) )
        {
            // TODO:C could have a specific error for multiple sources with only 1 output
            // to differentiate from two rules creating the same dst target
            Error::Error_1100_AlreadyDefined( funcStartIter, this, dst );
            return false;
        }

        // create our node
        CopyFileNode * copyFileNode = nodeGraph.CreateCopyFileNode( dst );
        copyFileNode->m_Source = srcNode->GetName();
        copyFileNode->m_PreBuildDependencyNames = preBuildDependencyNames;
        if ( !copyFileNode->Initialize( nodeGraph, funcStartIter, this ) )
        {
            return false; // Initialize will have emitted an error
        }

        copyNodes.Append( Dependency( copyFileNode ) );
    }

    // handle alias creation
    return ProcessAlias( nodeGraph, funcStartIter, copyNodes );
}
Example #23
0
// Commit
//------------------------------------------------------------------------------
/*virtual*/ bool FunctionSLN::Commit( const BFFIterator & funcStartIter ) const
{
    AStackString<> solutionOutput;
    Array< AString > solutionProjects( 8, true );
    if ( !GetString( funcStartIter, solutionOutput,     ".SolutionOutput", true ) ||
         !GetStrings( funcStartIter, solutionProjects,  ".SolutionProjects", false ) )
    {
        return false;
    }

    // optional inputs
    AString solutionBuildProject;
    AString solutionVisualStudioVersion;
    AString solutionMinimumVisualStudioVersion;
    if ( !GetString( funcStartIter, solutionBuildProject,                 ".SolutionBuildProject", false ) ||
         !GetString( funcStartIter, solutionVisualStudioVersion,          ".SolutionVisualStudioVersion", false ) ||
         !GetString( funcStartIter, solutionMinimumVisualStudioVersion,   ".SolutionMinimumVisualStudioVersion", false ) )
    {
        return false;
    }

    // base config
    VSProjectConfig baseConfig;

    // create configs
    Array< VSProjectConfig > configs( 16, true );

    const BFFVariable * solutionConfigs = BFFStackFrame::GetVar( ".SolutionConfigs" );
    if ( solutionConfigs )
    {
        if ( solutionConfigs->IsArrayOfStructs() == false )
        {
            Error::Error_1050_PropertyMustBeOfType( funcStartIter, this, ".SolutionConfigs", solutionConfigs->GetType(), BFFVariable::VAR_ARRAY_OF_STRUCTS );
            return false;
        }

        const Array< const BFFVariable * > & structs = solutionConfigs->GetArrayOfStructs();
        const BFFVariable * const * end = structs.End();
        for ( const BFFVariable ** it = structs.Begin(); it != end; ++it )
        {
            const BFFVariable * s = *it;

            // start with the base configuration
            VSProjectConfig newConfig( baseConfig );

            // .Platform must be provided
            if ( !GetStringFromStruct( s, ".Platform",  newConfig.m_Platform ) )
            {
                // TODO:B custom error
                Error::Error_1101_MissingProperty( funcStartIter, this, AStackString<>( ".Platform" ) );
                return false;
            }

            // .Config must be provided
            if ( !GetStringFromStruct( s, ".Config",    newConfig.m_Config ) )
            {
                // TODO:B custom error
                Error::Error_1101_MissingProperty( funcStartIter, this, AStackString<>( ".Config" ) );
                return false;
            }

            configs.Append( newConfig );
        }
    }
    else
    {
        // no user specified configs, make some defaults

        // start from the default
        VSProjectConfig config( baseConfig );

        // make the configs
        config.m_Platform   = "Win32";
        config.m_Config     = "Debug";
        configs.Append( config );
        config.m_Config     = "Release";
        configs.Append( config );
        config.m_Platform   = "x64";
        configs.Append( config );
        config.m_Config     = "Debug";
        configs.Append( config );
    }

    // sort project configs by config and by platform (like visual)
    configs.Sort( VSProjectConfigComp() );

    // create solution folders
    Array< SLNSolutionFolder > folders( 16, true );

    const BFFVariable * solutionFolders = BFFStackFrame::GetVar( ".SolutionFolders" );
    if ( solutionFolders )
    {
        if ( solutionFolders->IsArrayOfStructs() == false )
        {
            Error::Error_1050_PropertyMustBeOfType( funcStartIter, this, ".SolutionFolders", solutionFolders->GetType(), BFFVariable::VAR_ARRAY_OF_STRUCTS );
            return false;
        }

        const Array< const BFFVariable * > & structs = solutionFolders->GetArrayOfStructs();
        const BFFVariable * const * end = structs.End();
        for ( const BFFVariable ** it = structs.Begin(); it != end; ++it )
        {
            const BFFVariable * s = *it;

            // start with the base configuration
            SLNSolutionFolder newFolder;

            // .Path must be provided
            if ( !GetStringFromStruct( s, ".Path", newFolder.m_Path ) )
            {
                // TODO:B custom error
                Error::Error_1101_MissingProperty( funcStartIter, this, AStackString<>( ".Path" ) );
                return false;
            }

            newFolder.m_Path.Replace( OTHER_SLASH, NATIVE_SLASH );

            // check if this path was already defined
            {
                const SLNSolutionFolder * const end2 = folders.End();
                for ( const SLNSolutionFolder * it2 = folders.Begin() ; it2 != end2 ; ++it2 )
                {
                    if ( it2->m_Path == newFolder.m_Path  )
                    {
                        // TODO:B custom error
                        Error::Error_1100_AlreadyDefined( funcStartIter, this, it2->m_Path );
                        return false;
                    }
                }
            }

            // .Projects must be provided
            if ( !GetStringOrArrayOfStringsFromStruct( funcStartIter, s, ".Projects", newFolder.m_ProjectNames ) )
            {
                return false; // GetStringOrArrayOfStringsFromStruct has emitted an error
            }

            // check if this project is included in the solution
            for ( const AString & projectName : newFolder.m_ProjectNames )
            {
                if ( solutionProjects.Find( projectName ) == nullptr )
                {
					solutionProjects.Append( projectName );
                }
            }

            folders.Append( newFolder );
        }
    }

    NodeGraph & ng = FBuild::Get().GetDependencyGraph();

    // Check for existing node
    if ( ng.FindNode( solutionOutput ) )
    {
        Error::Error_1100_AlreadyDefined( funcStartIter, this, solutionOutput );
        return false;
    }

    // resolves VCXProject nodes associated to solutionProjects
    Array< VCXProjectNode * > projects( solutionProjects.GetSize(), false );
    {
        const AString * const end = solutionProjects.End();
        for ( const AString * it = solutionProjects.Begin(); it != end; ++it )
        {
            VCXProjectNode * project = ResolveVCXProject( funcStartIter, *it );
            if ( project == nullptr )
            {
                return false; // ResolveVCXProject will have emitted error
            }

            // check that this project contains all .SolutionConfigs
            const Array< VSProjectConfig > & projectConfigs = project->GetConfigs();

            const size_t configsSize = configs.GetSize();
            for ( size_t i = 0 ; i < configsSize ; ++i )
            {
                bool containsConfig = false;

                const VSProjectConfig * const config = &configs[i];
                const VSProjectConfig * const end2 = projectConfigs.End();
                for ( const VSProjectConfig * it2 = projectConfigs.Begin(); it2 != end2; ++it2 )
                {
                    if ( it2->m_Platform == config->m_Platform &&
                         it2->m_Config   == config->m_Config )
                    {
                        containsConfig = true;
                        break;
                    }
                }

                if ( containsConfig == false )
                {
                    // TODO: specific error message "ProjectConfigNotFound"
                    AStackString<> configName;
                    configName.Format( "%s|%s", config->m_Platform.Get(), config->m_Config.Get() );
                    Error::Error_1104_TargetNotDefined( funcStartIter, this, configName.Get(), project->GetName() );
                    return false;
                }
            }

            // append vcxproject node to solution
            projects.Append( project );
        }
    }

    // sort projects by name (like visual)
    projects.Sort( VCXProjectNodeComp() );

    // resolves VCXProject nodes associated to solutionFolders
    {
        SLNSolutionFolder * const end = folders.End();
        for ( SLNSolutionFolder * it = folders.Begin(); it != end; ++it )
        {
            // retrieves full path of contained vcxprojects

            AString * const end2 = it->m_ProjectNames.End();
            for ( AString * it2 = it->m_ProjectNames.Begin(); it2 != end2; ++it2 )
            {
				// Get associate project file
				VCXProjectNode * project = ResolveVCXProject( funcStartIter, *it2 );
				if ( project == nullptr )
				{
					return false; // ResolveVCXProjectRecurse will have emitted error
				}

                ASSERT( projects.Find( project ) ); // Sanity check in global list

				// fixup name to be to final project
                *it2 = project->GetName();
            }
        }
    }

    // resolves VCXProject node referenced by solutionBuildProject
    if ( solutionBuildProject.GetLength() > 0 )
    {
		// Get associate project file
		const VCXProjectNode * project = ResolveVCXProject( funcStartIter, solutionBuildProject );
		if ( project == nullptr )
		{
			return false; // ResolveVCXProject will have emitted error
		}

        if ( projects.Find( project ) == nullptr )
        {
            // project referenced in .SolutionBuildProject is not referenced in .SolutionProjects
            Error::Error_1104_TargetNotDefined( funcStartIter, this, ".SolutionBuildProject", project->GetName() );
            return false;
        }

        solutionBuildProject = project->GetName();
    }

    // Project Dependencies
    Array< SLNDependency > slnDeps( 0, true );
    const BFFVariable * projectDepsVar = BFFStackFrame::GetVar( ".SolutionDependencies" );
    if ( projectDepsVar )
    {
        if ( projectDepsVar->IsArrayOfStructs() == false )
        {
            Error::Error_1050_PropertyMustBeOfType( funcStartIter, this, ".SolutionDependencies", projectDepsVar->GetType(), BFFVariable::VAR_ARRAY_OF_STRUCTS );
            return false;
        }
	
		slnDeps.SetCapacity( projectDepsVar->GetArrayOfStructs().GetSize() );
		for ( const BFFVariable * s : projectDepsVar->GetArrayOfStructs() )
		{
            // .Projects must be provided
            // .Dependencies must be provided
			SLNDependency deps;
            if ( !GetStringOrArrayOfStringsFromStruct( funcStartIter, s, ".Projects", deps.m_Projects ) ||
				 !GetStringOrArrayOfStringsFromStruct( funcStartIter, s, ".Dependencies", deps.m_Dependencies ) )
            {
                return false; // GetStringOrArrayOfStringsFromStruct has emitted an error
            }

			// fixup
			for ( AString & projectName : deps.m_Projects )
			{
				// Get associated project file
				const VCXProjectNode * project = ResolveVCXProject( funcStartIter, projectName );
				if ( project == nullptr )
				{
					return false; // ResolveVCXProject will have emitted error
				}
				projectName = project->GetName();
			}
			for ( AString & projectName : deps.m_Dependencies )
			{
				// Get associated project file
				const VCXProjectNode * project = ResolveVCXProject( funcStartIter, projectName );
				if ( project == nullptr )
				{
					return false; // ResolveVCXProject will have emitted error
				}
				projectName = project->GetName();
			}

			slnDeps.Append( deps );
		}
	}

    SLNNode * sln = ng.CreateSLNNode(   solutionOutput,
                                        solutionBuildProject,
                                        solutionVisualStudioVersion,
                                        solutionMinimumVisualStudioVersion,
                                        configs,
                                        projects,
										slnDeps,
                                        folders );

    ASSERT( sln );

    return ProcessAlias( funcStartIter, sln );
}