(第五步骤, 我使用的是 create.bat {openjdk解压目录})
本指导只是能生成vc2010工程,方便阅读代码,并不能构建成功。
1. 安装VC2010
2. 安装cygwin,参考http://www.iteye.com/topic/1097344中安装cygwin的部分,记得装在c:/cygwin下
3. 下载OpenJDK 代码,并解压到本地目录。http://download.java.net/openjdk/jdk7/
4.添加环境变量
从开始菜单运行cmd.exe
set path=%path%;C:\cygwin\Cygwin\bin 先用set path=%path%;c:/cygwin/bin把cygwin的程序都加到path中,
set java_home=C:\Progra~1\Java\jdk1.8.0_101 java_home的值不能有空格
set path=%path%;E:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin 将vs的工具路径设置成环境变量
5.修改create.bat文件
修改create.bat文件
删除如下几行代码,即使配置了vs工具运行路径仍然会报找不到cl.exe, Make sure cl.exe is in your PATH before running this script.
cl 2>NUL >NUL
if %errorlevel% == 0 goto nexttest
echo Make sure cl.exe is in your PATH before running this script.
goto end
:nexttest
grep -V 2>NUL >NUL
if %errorlevel% == 0 goto testit
echo Make sure grep.exe is in your PATH before running this script. Either cygwin or MKS should work.
goto end
修改create.bat文件
create.bat文件默认认为cygwin安装在c:/cygwin/bin目录,如果不在这个目录下运行时会报如下HOTSPOTMKSHOME未定义,如下:
Warning: please set variable HOTSPOTMKSHOME to place where
your MKS/Cygwin installation is
修改 if exist C:\cygwin\bin set HOTSPOTMKSHOME=C:\cygwin\bin 为 if exist C:\cygwin\Cygwin\bin set HOTSPOTMKSHOME=C:\cygwin\Cygwin\bin
6.写死MSC_VER版本按照如下方法写死MSC_VER版本 https://github.com/codefollower/OpenJDK-Research/issues/1,方法同下
手动修改 get_msc_ver.sh
if [ "x$FORCE_MSC_VER" != "x" ]; then echo "MSC_VER=$FORCE_MSC_VER" else #MSC_VER_RAW=`cl 2>&1 | "$HEAD" -n 1 | "$SED" 's/.*[\ ]*\([0-9][0-9.]*\).*[\ ]版/\1/'` #MSC_VER_MAJOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f1` #MSC_VER_MINOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f2` #MSC_VER_MICRO=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f3` #if [ "${MSC_VER_MAJOR}" -eq 14 -a "${MSC_VER_MINOR}" -eq 0 -a "${MSC_VER_MICRO}" -eq 30701 ] ; then # This said 1400 but it was really more like VS2003 (VC7) in terms of options # MSC_VER=1399 #else # MSC_VER=`"$EXPR" $MSC_VER_MAJOR \* 100 + $MSC_VER_MINOR` #fi MSC_VER=1600 MSC_VER_RAW=16.00.30319.01 echo "MSC_VER=$MSC_VER" echo "MSC_VER_RAW=$MSC_VER_RAW" fi
7. 在{openjdk解压目录}\hotspot\make\windows目录运行 create.bat {openjdk解压目录}. 运行成功会在{openjdk解压目录}\hotspot\build\vs-i486下产生出一个jvm.vcxproj文件
create.bat E:\code\git\jdk\new2\hotspot-87ee5ee27509