View Javadoc
1   package org.codehaus.mojo.natives.msvc;
2   
3   /*
4    * The MIT License
5    *
6    * Copyright (c) 2004, The Codehaus
7    *
8    * Permission is hereby granted, free of charge, to any person obtaining a copy of
9    * this software and associated documentation files (the "Software"), to deal in
10   * the Software without restriction, including without limitation the rights to
11   * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12   * of the Software, and to permit persons to whom the Software is furnished to do
13   * so, subject to the following conditions:
14   *
15   * The above copyright notice and this permission notice shall be included in all
16   * copies or substantial portions of the Software.
17   *
18   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24   * SOFTWARE.
25   */
26  
27  import java.io.File;
28  import java.util.HashMap;
29  import java.util.Map;
30  
31  import org.codehaus.mojo.natives.NativeBuildException;
32  import org.codehaus.mojo.natives.util.EnvUtil;
33  
34  /**
35   * Equivalent of MSVC2005's vcvarsx86_amd64.bat
36   */
37  
38  public class MSVC2005x86AMD64EnvFactory
39      extends AbstractMSVC2005EnvFactory
40  {
41  
42      protected Map createEnvs()
43          throws NativeBuildException
44      {
45          File vsInstallDir =
46              new File( EnvUtil.getEnv( MSVS2005_INSTALL_ENV_KEY, MSVS2005_INSTALL_ENV_KEY, DEFAULT_MSVS2005_INSTALL_DIR ) );
47  
48          if ( !vsInstallDir.isDirectory() )
49          {
50              throw new NativeBuildException( vsInstallDir.getPath() + " is not a directory." );
51          }
52  
53          Map envs = new HashMap();
54  
55          envs.put( "VSINSTALLDIR", vsInstallDir.getPath() );
56  
57          File vcInstallDir = new File( vsInstallDir.getPath() + "/VC" );
58          envs.put( "VCINSTALLDIR", vcInstallDir.getPath() );
59  
60          // TODO get winhome dir
61          File frameworkDir = new File( getSystemRoot() + "/Microsoft.NET/Framework" );
62          envs.put( "FrameworkDir", frameworkDir.getPath() );
63  
64          String frameworkVersion = "v2.0.50727";
65          envs.put( "FrameworkVersion", frameworkVersion );
66  
67          File frameworkSDKDir = new File( vsInstallDir.getPath() + "/SDK/v2.0" );
68          envs.put( "FrameworkSDKDir", frameworkSDKDir.getPath() );
69  
70          File devEnvDir = new File( vsInstallDir.getPath() + "/Common7/IDE" );
71          envs.put( "DevEnvDir", devEnvDir.getPath() );
72  
73          File platformSDKDir = new File( vcInstallDir.getPath() + "/PlatformSDK" );
74  
75          // setup new PATH
76          String currentPath = System.getProperty( "java.library.path" );
77  
78          String newPath =
79              devEnvDir.getPath() + ";" + vcInstallDir.getPath() + "\\BIN\\x86_amd64;" + vcInstallDir.getPath()
80                  + "\\BIN;" + vcInstallDir.getPath() + "\\Common7\\Tools;" + vcInstallDir.getPath()
81                  + "\\Common7\\Tools\\bin;" + platformSDKDir.getPath() + "\\BIN;" + frameworkSDKDir.getPath() + "\\BIN;"
82                  + frameworkDir.getPath() + "\\" + frameworkVersion + ";" + vcInstallDir.getPath() + "\\VCPackages;"
83                  + currentPath;
84  
85          envs.put( "PATH", newPath );
86  
87          // setup new INCLUDE PATH
88          String currentIncludePath = EnvUtil.getEnv( "INCLUDE" );
89  
90          String newIncludePath =
91              vcInstallDir.getPath() + "\\ATLMFC\\INCLUDE;" + vcInstallDir.getPath() + "\\INCLUDE;"
92                  + platformSDKDir.getPath() + "\\INCLUDE;" + frameworkSDKDir.getPath() + "\\INCLUDE;"
93                  + currentIncludePath;
94  
95          envs.put( "INCLUDE", newIncludePath );
96  
97          //
98          // setup new LIB PATH
99          //
100         String currentLibPath = EnvUtil.getEnv( "LIB" );
101 
102         String newLibPath =
103             vcInstallDir.getPath() + "\\ATLMFC\\LIB\\AMD64;" + vcInstallDir.getPath() + "\\LIB\\AMD64;"
104                 + platformSDKDir.getPath() + "\\LIB\\AMD64;" + frameworkSDKDir.getPath() + "\\LIB\\AMD64;"
105                 + currentLibPath;
106 
107         envs.put( "LIB", newLibPath );
108 
109         //
110         // setup new LIBPATH
111         //
112 
113         String currentLibPathPath = EnvUtil.getEnv( "LIBPATH" );
114 
115         String newLibPathPath = vcInstallDir.getPath() + "\\ATLMFC\\LIB\\AMD64" + currentLibPathPath;
116 
117         envs.put( "LIBPATH", newLibPathPath );
118 
119         return envs;
120 
121     }
122 
123 }