1 package org.codehaus.mojo.natives.msvc;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
36
37
38 public class MSVC6EnvFactory
39 extends AbstractMSVCEnvFactory
40 {
41 private static final String MSVS6_INSTALL_ENV_KEY = "MSVS6_INSTALL_DIR";
42
43 private static final String DEFAULT_MSVS6_INSTALL_DIR = getProgramFilesX86() + "/Microsoft Visual Studio";
44
45 protected Map createEnvs()
46 throws NativeBuildException
47 {
48 File vsDir =
49 new File( EnvUtil.getEnv( MSVS6_INSTALL_ENV_KEY, MSVS6_INSTALL_ENV_KEY, DEFAULT_MSVS6_INSTALL_DIR ) );
50
51 if ( !vsDir.isDirectory() )
52 {
53 throw new NativeBuildException( vsDir.getPath() + " is not a directory." );
54 }
55
56 Map envs = new HashMap();
57
58 String vcOsDir = "WINNT";
59
60 String winDir = EnvUtil.getEnv( "windir" );
61
62 File vsCommonDir = new File( vsDir + "/Common" );
63
64 File vsCommonToolDir = new File( vsCommonDir + "/TOOLS" );
65
66 File msDevDir = new File( vsCommonDir + "/msdev98" );
67
68 File msvcDir = new File( vsDir + "/VC98" );
69
70 envs.put( "MSVCDir", msvcDir.getPath() );
71
72
73 String currentPath = System.getProperty( "java.library.path" );
74
75 String newPath =
76 msDevDir.getPath() + "\\BIN;" + msvcDir.getPath() + "\\BIN;" + vsCommonToolDir.getPath() + "\\" + vcOsDir
77 + ";" + vsCommonToolDir.getPath() + ";" + winDir + ";" + currentPath;
78
79 envs.put( "PATH", newPath );
80
81
82 String currentIncludePath = EnvUtil.getEnv( "INCLUDE" );
83
84 String newIncludePath =
85 msvcDir.getPath() + "\\ATL\\INCLUDE;" + msvcDir.getPath() + "\\INCLUDE;" + msvcDir.getPath()
86 + "\\MFC\\INCLUDE;" + vsCommonToolDir.getPath() + vcOsDir + ";" + vsCommonToolDir.getPath() + ";"
87 + currentIncludePath;
88
89 envs.put( "INCLUDE", newIncludePath );
90
91
92
93
94 String currentLibPath = EnvUtil.getEnv( "LIB" );
95
96 String newLibPath = msvcDir.getPath() + "\\LIB;" + msvcDir.getPath() + "\\MFC\\LIB;" + currentLibPath;
97
98 envs.put( "LIB", newLibPath );
99
100 return envs;
101
102 }
103
104 }