Example #1
0
File: Task.cs Project: jmclain/Nmp
		/////////////////////////////////////////////////////////////////////////////
		
		private bool SetDefines( NmpEvaluator nmp )
		{
			// ******
			string startDir = Directory.GetCurrentDirectory();
			nmp.AddTextMacro( RESPONSE_PATH, startDir, null );


			// ******
			if( string.IsNullOrEmpty(Defines) ) {
				return true;
			}
		
			// ******
			NmpStringList defines = Utility.SplitDefines( Defines );
			
			foreach( string define in defines ) {
				string	key;
				string	value;
				
				if( Utility.GetValuePair(define, out key, out value) ) {
					nmp.AddTextMacro( key, value, null );
				}
				else {
					Log.LogError( "error in Defines argument: {0}", Defines );
					return false;
				}
			}
			
			// ******
			return true;
		}
Example #2
0
File: Host.cs Project: jmclain/Nmp
		/////////////////////////////////////////////////////////////////////////////

		protected Tuple<string, string, bool, string> EvaluateFile( string fileName, NmpStringArray defines )
		{
			// ******
			if( null != macroTracer ) {
				macroTracer.BeginSession( Path.GetFileName( fileName ), Path.GetDirectoryName( fileName ) );
			}

			// ******
			try {
				if( ! File.Exists(fileName) ) {
					Die( "input file does not exist: {0}", fileName );
				}

				// ******
				using( var mp = new NmpEvaluator(this) ) {

					foreach( var kvp in defines ) {
						var key = kvp.Key;
						if( !string.IsNullOrEmpty( key ) && '-' == key [ 0 ] ) {
							//
							// v3 have not added undef back to evaluator
							//
							continue;
						}

						// ******
						mp.AddTextMacro( key, kvp.Value, null );
					}

					// ******
					string result = mp.Evaluate( mp.GetFileContext(fileName), true );
					return new Tuple<string,string, bool, string>(result, mp.FileExt, mp.NoOutputFile, mp.OutputEncoding);
				}
			}

	//
	// catch error and report here
	//
#if EXREPORTING
			// ref dll
#endif

			finally {
				// ******
				if( null != macroTracer ) {
					macroTracer.EndSession();
				}

			}
		}
Example #3
0
		/////////////////////////////////////////////////////////////////////////////

		private void AddMacros( NmpEvaluator nmp, IDictionary vsBuildPaths )
		{
			// ******
			foreach( KeyValuePair<string, object> kvp in ObjectMacros ) {
				nmp.AddObjectMacro( kvp.Key, kvp.Value );
			}

			// ******
			foreach( var tmd in TextMacros ) {
				nmp.AddTextMacro( tmd.Name, tmd.Text, new NmpStringList(tmd.ArgNames) );
			}

			// ******
			//nmp.AddObjectMacro( VSBUILD_PATHS_MACRO_NAME, new NmpArray(vsBuildPaths) );
		}