Explicitly set VSNaClSDKRoot in vcxproj rather than
relying on defaults.  VSNaClSDKRoot must be set
before any other properties that depend on it.

In order to make sure the ordering is correct we
unset certain properties and then re-set them back
to their original values following the setting
of VSNaClSDKRoot.

BUG=http://code.google.com/p/chromium/issues/detail?id=148794

Review URL: https://chromiumcodereview.appspot.com/10928194

git-svn-id: https://nativeclient-sdk.googlecode.com/svn/trunk/src@1414 050acbb0-2703-11df-ab0a-9f3f633ae91d
diff --git a/InstallerResources/examples/hello_world_gles/hello_world_gles/hello_world_gles.vcxproj b/InstallerResources/examples/hello_world_gles/hello_world_gles/hello_world_gles.vcxproj
index 4b89c2d..72c2518 100644
--- a/InstallerResources/examples/hello_world_gles/hello_world_gles/hello_world_gles.vcxproj
+++ b/InstallerResources/examples/hello_world_gles/hello_world_gles/hello_world_gles.vcxproj
@@ -67,32 +67,34 @@
     <LinkIncremental>false</LinkIncremental>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|NaCl'">

-    <IncludePath>$(VSNaClSDKRoot)include;</IncludePath>

-    <LibraryPath>$(VSNaClSDKRoot)lib;</LibraryPath>

     <NaClIrtPath>$(VSNaClSDKRoot)\tools\irt_x86_64.nexe</NaClIrtPath>

+    <NaClAddInVersion>1.0.4632.27091</NaClAddInVersion>

+    <VSNaClSDKRoot>$(NACL_SDK_ROOT)\</VSNaClSDKRoot>

     <OutDir>$(ProjectDir)$(ToolchainName)\</OutDir>

     <IntDir>$(ToolchainName)\$(Configuration)\</IntDir>

-    <NaClAddInVersion>1.0.4632.27091</NaClAddInVersion>

+    <IncludePath>$(VSNaClSDKRoot)include;</IncludePath>

+    <LibraryPath>$(VSNaClSDKRoot)lib;</LibraryPath>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|NaCl'">

-    <IncludePath>$(VSNaClSDKRoot)include;</IncludePath>

-    <LibraryPath>$(VSNaClSDKRoot)lib;</LibraryPath>

     <NaClIrtPath>$(VSNaClSDKRoot)\tools\irt_x86_64.nexe</NaClIrtPath>

+    <NaClAddInVersion>1.0.4632.27091</NaClAddInVersion>

+    <VSNaClSDKRoot>$(NACL_SDK_ROOT)\</VSNaClSDKRoot>

     <OutDir>$(ProjectDir)$(ToolchainName)\</OutDir>

     <IntDir>$(ToolchainName)\$(Configuration)\</IntDir>

-    <NaClAddInVersion>1.0.4632.27091</NaClAddInVersion>

+    <IncludePath>$(VSNaClSDKRoot)include;</IncludePath>

+    <LibraryPath>$(VSNaClSDKRoot)lib;</LibraryPath>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PPAPI'">

-    <IncludePath>$(VSNaClSDKRoot)include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;</IncludePath>

-    <LibraryPath>$(VSNaClSDKRoot)lib\win_x86_32_host\$(Configuration);$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>

     <ExecutablePath>$(VCInstallDir)bin;$(WindowsSdkDir)bin\NETFX 4.0 Tools;$(WindowsSdkDir)bin;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(FrameworkSDKDir)\bin;$(MSBuildToolsPath32);$(VSInstallDir);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>

     <NaClAddInVersion>1.0.4632.27091</NaClAddInVersion>

+    <IncludePath>$(VSNaClSDKRoot)include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;</IncludePath>

+    <LibraryPath>$(VSNaClSDKRoot)lib\win_x86_32_host\$(Configuration);$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|PPAPI'">

-    <IncludePath>$(VSNaClSDKRoot)include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;</IncludePath>

-    <LibraryPath>$(VSNaClSDKRoot)lib\win_x86_32_host\$(Configuration);$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>

     <ExecutablePath>$(VCInstallDir)bin;$(WindowsSdkDir)bin\NETFX 4.0 Tools;$(WindowsSdkDir)bin;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(FrameworkSDKDir)\bin;$(MSBuildToolsPath32);$(VSInstallDir);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>

     <NaClAddInVersion>1.0.4632.27091</NaClAddInVersion>

+    <IncludePath>$(VSNaClSDKRoot)include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;</IncludePath>

+    <LibraryPath>$(VSNaClSDKRoot)lib\win_x86_32_host\$(Configuration);$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>

   </PropertyGroup>

   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

     <ClCompile>

@@ -168,4 +170,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

   <ImportGroup Label="ExtensionTargets">

   </ImportGroup>

-</Project>

+</Project>
\ No newline at end of file
diff --git a/NativeClientVSAddIn/Connect.cs b/NativeClientVSAddIn/Connect.cs
index 91ed9aa..5262b03 100644
--- a/NativeClientVSAddIn/Connect.cs
+++ b/NativeClientVSAddIn/Connect.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.

+// Copyright (c) 2012 The Chromium Authors. All rights reserved.

 // Use of this source code is governed by a BSD-style license that can be

 // found in the LICENSE file.

 

@@ -11,7 +11,9 @@
   using Extensibility;

   using Microsoft.VisualStudio;

   using Microsoft.VisualStudio.VCProjectEngine;

-  

+  using System.Collections.Generic;

+  using System.Diagnostics;

+

   /// <summary>The object for implementing an Add-in.</summary>

   /// <seealso class='IDTExtensibility2' />

   public class Connect : IDTExtensibility2

@@ -175,11 +177,13 @@
       foreach (VCConfiguration config in configs)

       {

         properties.SetTarget(config);

-        if (string.IsNullOrEmpty(properties.NaClAddInVersion))

+        if (properties.NaClAddInVersion != naclAddInVersion)

         {

+          Debug.WriteLine("Modifying Config: " + config.Name);

+

           // Set the NaCl add-in version so that it is stored in the project file.

           properties.SetProperty("ConfigurationGeneral", "NaClAddInVersion", naclAddInVersion);

-          

+

           // Expand the CHROME_PATH variable to its full path.

           string expandedChrome = properties.GetProperty(

               "WindowsLocalDebugger", "LocalDebuggerCommand");

@@ -224,9 +228,29 @@
       string arguments = debugger.GetUnevaluatedPropertyValue("LocalDebuggerCommandArguments");

       debugger.SetPropertyValue("LocalDebuggerCommandArguments", arguments);

 

+      // NaCl Platform Specific:

+      if (config.Platform.Name == Strings.NaClPlatformName)

+      {

+        IVCRulePropertyStorage general = config.Rules.Item("ConfigurationGeneral");

+        string[] keys = {"VSNaClSDKRoot", "OutDir", "IntDir"};

+        Dictionary<string, string> values = new Dictionary<string, string>();

+        foreach (var key in keys)

+        {

+          values[key] = general.GetUnevaluatedPropertyValue(key);

+          general.DeleteProperty(key);

+        }

+

+        foreach (var key in keys)

+        {

+          general.SetPropertyValue(key, values[key]);

+        }

+      }

+

       IVCRulePropertyStorage directories = config.Rules.Item("ConfigurationDirectories");

       string includePath = directories.GetUnevaluatedPropertyValue("IncludePath");

       string libraryPath = directories.GetUnevaluatedPropertyValue("LibraryPath");

+      directories.DeleteProperty("IncludePath");

+      directories.DeleteProperty("LibraryPath");

       directories.SetPropertyValue("IncludePath", includePath);

       directories.SetPropertyValue("LibraryPath", libraryPath);