Build issues

Mar 5, 2013 at 8:35 PM
So, I tried to build the 5.1.2 version, and I got this:

C:\Data\Libraries\ClearScript\5.1.2>v8update release
V8 revision: Latest
Build mode: Release
Removing old build directory ...
Creating build directory ...
Downloading V8 ...
Patching V8 ...
Downloading GYP ...
Downloading Python ...
Downloading Cygwin ...
Building 32-bit V8 ...
*** THE PREVIOUS STEP FAILED ***

There's no error details, so I have no idea where to go from here.
Coordinator
Mar 5, 2013 at 9:27 PM
Hi jamesnw!

Initial questions:
  1. What version of Visual Studio are you using?
  2. Did you run V8Update in a Visual Studio developer command prompt, or a plain Windows command prompt?
BTW, there should be a build log at this location:
  • C:\Data\Libraries\ClearScript\5.1.2\ClearScript\V8\V8\build\v8-ia32\build.log
If you have this file, please let us know if it contains any error messages.

Thanks!
Mar 5, 2013 at 9:47 PM
  1. 2012
  2. The Visual Studio Developer Prompt
Mar 5, 2013 at 9:50 PM
Thanks for the log location. I saw this:

MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere. [C:\Data\Libraries\ClearScript\5.1.2\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.sln]

I'll check if "vcbuild.exe" can be run via the prompt (I have VS2012 install, so not sure why it would be an issue)...
Mar 5, 2013 at 9:52 PM
Apparently, "vcbuild.exe" is replaced by "msbuild" in VS2012 (and I'm guessing 2012 as well):
http://stackoverflow.com/questions/7761395/where-is-vcbuild-in-vs2010
Coordinator
Mar 5, 2013 at 10:21 PM
Edited Mar 5, 2013 at 10:30 PM
V8Update uses msbuild.exe to build V8. Is it possible that on your machine it's somehow picking up an old version of that program? Visual Studio 2010 and 2012 don't ship with vcbuild.exe at all.
Mar 5, 2013 at 10:28 PM
Well, if I type "msbuild" it displays the version details, etc., so it's there; vcbuild.exe is not there. If the batch file is expecting msbuild, then why is the error showing otherwise?
Coordinator
Mar 5, 2013 at 10:47 PM
Hi jamesnw,

We have reproduced this issue by using an old version of msbuild. Would it be possible for you to post your executable path here? We'd like to see the path exactly as it is in the developer command prompt you're using.

Sorry about the problems!
Mar 5, 2013 at 10:56 PM
Sure...

EXE path:
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"

VS2012 CMD Prompt path:
C:\Program Files (x86)\Microsoft Visual Studio 11.0

"Path" env. setting while in the prompt:
C:\Program Files (x86)\Microsoft Visual Studio 11.0>set path
Path=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExten
sions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framewor
k\v4.0\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VSTSDB\Deploy;C:\Pro
gram Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\;C:\Program Files (x86
)\Microsoft Visual Studio 11.0\VC\BIN;C:\Program Files (x86)\Microsoft Visual St
udio 11.0\Common7\Tools;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows
\Microsoft.NET\Framework\v3.5;C:\Program Files (x86)\Microsoft Visual Studio 11.
0\VC\VCPackages;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)
\Microsoft Visual Studio 11.0\Team Tools\Performance Tools;C:\Program Files (x86
)\Windows Kits\8.0\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\b
in\NETFX 4.0 Tools;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\;C:\P
rogram Files (x86)\Windows Resource Kits\Tools\;C:\Program Files (x86)\NVIDIA Co
rporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Li
ve;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\
system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShe
ll\v1.0\;C:\Program Files\Broadcom\Broadcom 802.11\Driver;C:\Program Files (x86)
\Common Files\Acronis\SnapAPI\;C:\Program Files\Microsoft\Web Platform Installer
\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Fi
les (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microso
ft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Prog
ram Files (x86)\Windows Live\Shared;C:\strawberry\c\bin;C:\strawberry\perl\site\
bin;C:\strawberry\perl\bin;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\
Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86
)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Serve
r\90\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell
\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\Priva
teAssemblies\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program File
s (x86)\WinSCP\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\;C:\Program Fil
es\nodejs\;C:\Data\Program Files\Apache-Subversion-1.7.8\bin;C:\Program Files (x
86)\Sikuli X\libs;bin;C:\Users\James\AppData\Roaming\npm\
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Coordinator
Mar 6, 2013 at 2:52 AM
Thanks, jamesnw.

Interesting. The relevant portions of our paths are identical. Given that, msbuild.exe should be found here:
  • C:\Windows\Microsoft.NET\Framework\v4.0.30319
Do you see it there? If not, you may need to reinstall / repair Visual Studio.

Also, if you can run msbuild from the developer command line, could you please capture and post its banner text?

Thanks for your help!
Mar 6, 2013 at 4:08 AM
Edited Mar 6, 2013 at 4:10 AM
Yes, it's there. :)

C:\Program Files (x86)\Microsoft Visual Studio 11.0>msbuild
Microsoft (R) Build Engine version 4.0.30319.17929
[Microsoft .NET Framework, version 4.0.30319.17929]
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Windows\Microsoft.NET\Framework\v4.0.30319>msbuild
Microsoft (R) Build Engine version 4.0.30319.17929
[Microsoft .NET Framework, version 4.0.30319.17929]
Copyright (C) Microsoft Corporation. All rights reserved.
(executes C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe)

Same version if run from both locations.
Coordinator
Mar 6, 2013 at 2:30 PM
Thanks, jamesnw. Can you check whether the same banner appears at the top of the build log you examined earlier?

Also, what happens if you launch the generated V8 solution and try to build it manually? The solution file should be:
  • C:\Data\Libraries\ClearScript\5.1.2\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.sln
We can only reproduce the problem by forcing V8Update to run the .NET 3.5 version of msbuild.exe. Later versions work, and earlier versions of .NET didn't ship with msbuild.exe to begin with.
Mar 6, 2013 at 5:14 PM
Here's the first part of the log:

Microsoft (R) Build Engine version 4.0.30319.17929
[Microsoft .NET Framework, version 4.0.30319.17929]
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 05/03/2013 3:26:58 PM.
Project "C:\Data\Libraries\ClearScript\5.1.2\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Release|Win32".
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere. [C:\Data\Libraries\ClearScript\5.1.2\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.sln]
Mar 6, 2013 at 5:18 PM
Edited Mar 7, 2013 at 7:25 AM
I'm taking a wild guess that msbuild wants to use vcbuild.exe because of a project setting (it's using the .exe instead of the vcbuild.dll that is in the same location as the exe). I even installed the .NET 3.5 and 4.0 SDKs as a test, and nothing, still no vcbuild.exe anywhere on the PC. I'm trying to install .NET 2.0 SDK next like the message says (I figured it would at least exist for backwards compatibility in 4.0, but I guess not).
Coordinator
Mar 6, 2013 at 5:27 PM
Our current theory is also that it's a project setting, especially now that you've eliminated the possibility that we're launching an old msbuild.exe. The project settings here are generated by Google's GYP tool, which might be mis-identifying your installed Visual Studio version.

Let's try this: Can you open this file in a text editor...
  • C:\Data\Libraries\ClearScript\5.1.2\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.vcxproj
... and post the contents of the <PlatformToolset> element?
Coordinator
Mar 6, 2013 at 6:48 PM
Edited Mar 6, 2013 at 6:50 PM
OK, we might finally be onto something.

Apparently GYP, by default, enumerates your installed Visual Studio versions and generates project files that target the oldest. We suspect that you have just enough of an old Visual Studio 2008 installation lying around to confuse it.

Please try this and let us know if it works:
C:\Data\Libraries\ClearScript\5.1.2> set GYP_MSVS_VERSION=2012
C:\Data\Libraries\ClearScript\5.1.2> V8Update
Warning: V8Update isn't very sophisticated and will download everything again.
Mar 6, 2013 at 6:55 PM
Edited Mar 6, 2013 at 6:55 PM
The <PlatformToolset> element doesn't exist.
Mar 6, 2013 at 7:07 PM
Edited Mar 6, 2013 at 7:08 PM
Ok, I'll try that.
Mar 7, 2013 at 7:05 AM
Edited Mar 7, 2013 at 7:27 AM
Ok, I figured something out. When I don't use "set GYP_MSVS_VERSION=2012", then I get this error:
The program can't start because mspdb100.dll is missing from your computer. 
Try reinstalling the program to fix this problem.
If I add it to the top of the command script, it builds successfully!!! 8)

Other findings: Installing other .NET SDK versions did nothing (it seems only the vcbuild.dll will be installed [and not the exe; though all functionality is actually in the DLL itself]). Reisntalling VS2012 also did nothing. The project files dictate how to build the files, so setting "GYP_MSVS_VERSION=2012" is the only thing that works for running the command file. That said, I WAS able to convert the solution (ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.sln) into VS2012, THEN build it using Visual Studio, which works as well. :)
Mar 7, 2013 at 7:09 AM
Edited Mar 9, 2013 at 5:40 AM
I created a much better script for others to use, which DOES NOT required the developer prompt! (though it does run the same batch file to set it up). There's a lot more control over the process, because I hated to continually download the V8 source EVERY TIME I wanted to simply rebuild it. ;) This script does some detection to help the process, makes it easier to select debug/release modes, and allows to inspect the environment and log file on error. It also includes the GYP fix mentioned above, and provides a heck of a lot more details on what the !@# is going on. ;)

Anyone wishing to use this, just create a file called "V8Update-Interactive.cmd" where the existing "V8Update.cmd" is located (source root), copy & paste the following code, and double click it.

(updated 2013-03-09 00:38)

@echo off
setlocal

REM (in order for "%errorlevel%" to expand correctly, we need to make sure there's no matching environment variable set with the same name)
set errorlevel=

set WorkingDir=%CD%

:Restart

cls

echo This command file is used to download the V8 source and build it.
echo The 'svn' command line program is required, and can be found at
echo 'http://subversion.apache.org/packages.html' (see ReadMe.txt).
choice /C 123 /M "Press 1 to open ReadMe.txt, 2 to continue, and 3 to cancel."
echo.
if errorlevel 3 goto :EOF
if errorlevel 2 goto CheckEnv
notepad "%cd%\ReadMe.txt"
goto restart

:CheckEnv
REM Check if we are running in the correct environment (supports VS2010 and VS2012) ...
REM (note: more than one version of Visual Studio may be installed, so start from highest version, to least)
if not "%DevEnvDir%"=="" set VSTools=%DevEnvDir%..\Tools\ & goto BeginV8Update
echo This command file should be run via the Visual Studio developer prompt.
echo Attempting to do so now ...
if not "%VS110COMNTOOLS%"=="" set VSTools=%VS110COMNTOOLS%& set VSVer=2012& goto SetVSEnv
if not "%VS100COMNTOOLS%"=="" set VSTools=%VS100COMNTOOLS%& set VSVer=2010& goto SetVSEnv
echo Failed to detect correct version of Visual Studio.  Please open the developer prompt and run the command file there.
goto Exit
:SetVSEnv
Echo Visual Studio %VSVer% detected ...
set GYP_MSVS_VERSION=%VSVer%
call "%VSTools%VsDevCmd.bat"
echo Visual Studio developer prompt environment was setup successfully!
echo.

:BeginV8Update
cd %WorkingDir%
echo Visual Studio environment being used: %DevEnvDir%
echo.

if "%v8rev%"=="" goto LatestRev
echo V8 revision: %v8rev%
goto SetMode
:LatestRev
echo V8 revision: Latest
set v8rev=HEAD

:SetMode
set mode=%1
if "%mode%"=="" goto PromptReleaseMode
if /i "%mode%"=="debug" goto DebugMode
if /i "%mode%"=="release" goto ReleaseMode
echo %mode%: Invalid build mode; please specify "Debug" or "Release"
goto PromptReleaseMode
:DebugMode
set mode=Debug
goto Start
:ReleaseMode
set mode=Release
goto Start
:PromptReleaseMode
choice /C DR /M "Please choose a build mode: [D]ebug, or [R]elease"
echo.
if errorlevel 2 goto ReleaseMode
if errorlevel 1 goto DebugMode

:Start
echo Build mode: %mode%
cd v8
if errorlevel 1 goto Exit

if not exist build\ goto CreateBuildDir
echo The V8 source files already exist. Would you like to build it as is?
echo (select no to delete and redownload the V8 source, including all dependencies)
choice
echo.
if errorlevel 1 cd build & goto BuildV8
echo Removing old build directory ...
rd /s /q build
:CreateBuildDir
echo Creating build directory ...
md build
if errorlevel 1 goto Error
cd build

echo Downloading V8 ...
svn checkout http://v8.googlecode.com/svn/trunk/@%v8rev% v8 >getV8.log
if errorlevel 1 goto Error1
cd v8

echo Patching V8 ...
svn patch ..\..\V8Patch.txt >patchV8.log
if errorlevel 1 goto Error2
svn diff -x --ignore-eol-style >V8Patch.txt

echo Downloading GYP ...
svn checkout http://gyp.googlecode.com/svn/trunk build/gyp >getGYP.log
if errorlevel 1 goto Error2

echo Downloading Python ...
svn checkout http://src.chromium.org/svn/trunk/tools/third_party/python_26 third_party/python_26 >getPython.log
if errorlevel 1 goto Error2

echo Downloading Cygwin ...
svn checkout http://src.chromium.org/svn/trunk/deps/third_party/cygwin third_party/cygwin >getCygwin.log
if errorlevel 1 goto Error2
cd ..

:BuildV8

echo Building 32-bit V8 ...
if not exist "v8-ia32" goto CopyV832Bit
choice /M "Do a clean build of the V8 source for the 32-bit libraries?"
if errorlevel 2 cd v8-ia32 & goto BuildV832Bit
echo Cleaning the V8 source for the 32-bit libraries...
:CopyV832Bit
set ERRORLEVEL=0
if exist "v8-ia32" echo Removing old files ... & rd /s /q v8-ia32
if not errorlevel 0 goto Error1
md v8-ia32
if errorlevel 1 goto Error1
echo Copying needed files ...
xcopy v8\*.* v8-ia32\ /e /y >nul
if errorlevel 1 goto Error1
cd v8-ia32
echo Generating Visual Studio project files for the 32-bit libraries...
third_party\python_26\python build\gyp_v8 -Dtarget_arch=ia32 -Dcomponent=shared_library -Dv8_use_snapshot=false >gyp.log
if errorlevel 1 goto Error2
:BuildV832Bit
echo Building v8-ia32\tools\gyp\v8.sln ...
set LogFile=%CD%\build.log
msbuild /p:Configuration=%mode% /p:Platform=Win32 tools\gyp\v8.sln >"%LogFile%"
if errorlevel 1 goto Error2
set LogFile=
cd ..

echo Building 64-bit V8 ...
if not exist "v8-x64" goto CopyV864Bit
choice /M "Do a clean build of the V8 source for the 64-bit libraries?"
if errorlevel 2 cd v8-x64 & goto BuildV864Bit
echo Cleaning the V8 source for the 64-bit libraries...
:CopyV864Bit
set ERRORLEVEL=0
if exist "v8-x64" echo Removing old files ... & rd /s /q v8-x64
if not errorlevel 0 goto Error1
md v8-x64
if errorlevel 1 goto Error1
echo Copying needed files ...
xcopy v8\*.* v8-x64\ /e /y >nul
if errorlevel 1 goto Error1
cd v8-x64
echo Generating Visual Studio project files for the 64-bit libraries...
third_party\python_26\python build\gyp_v8 -Dtarget_arch=x64 -Dcomponent=shared_library -Dv8_use_snapshot=false >gyp.log
if errorlevel 1 goto Error2
:BuildV864Bit
echo Building v8-x64\tools\gyp\v8.sln ...
set LogFile=%CD%\build.log
msbuild /p:Configuration=%mode% /p:Platform=x64 tools\gyp\v8.sln >"%LogFile%"
if errorlevel 1 goto Error2
set LogFile=
cd ..

goto success

if not exist lib\ goto CreateLibDir
echo Removing old lib directory ...
rd /s /q lib
:CreateLibDir
echo Creating lib directory ...
md lib
if errorlevel 1 goto Error

echo Importing V8 libraries ...
copy build\v8-ia32\build\%mode%\v8-ia32.dll lib\ >nul
if errorlevel 1 goto Error
copy build\v8-ia32\build\%mode%\v8-ia32.pdb lib\ >nul
if errorlevel 1 goto Error
copy build\v8-ia32\build\%mode%\lib\v8-ia32.lib lib\ >nul
if errorlevel 1 goto Error
copy build\v8-x64\build\%mode%\v8-x64.dll lib\ >nul
if errorlevel 1 goto Error
copy build\v8-x64\build\%mode%\v8-x64.pdb lib\ >nul
if errorlevel 1 goto Error
copy build\v8-x64\build\%mode%\lib\v8-x64.lib lib\ >nul
if errorlevel 1 goto Error

if not exist include\ goto CreateIncludeDir
echo Removing old include directory ...
rd /s /q include
:CreateIncludeDir
echo Creating include directory ...
md include
if errorlevel 1 goto Error

echo Importing V8 header files ...
copy build\v8\include\*.* include\ >nul
if errorlevel 1 goto Error

echo Updating patch file ...
copy build\v8\V8Patch.txt .\ >nul
if errorlevel 1 goto Error

:success
echo Succeeded!
pause
goto End

:Error2
cd ..
:Error1
cd ..
:Error
echo *** THE PREVIOUS STEP FAILED ***

:ErrorOptions
REM (in order for "%errorlevel%" to expand correctly, we need to make sure there's no matching environment variable set with the same name)
set errorlevel=
echo.
echo Options:
if not "%LogFile%"=="" echo   [L]og: Open the log file (%LogFile%)
echo   [C]md: Open the command prompt with the existing environment
echo   [R]estart
echo   [E]xit
echo.
if "%LogFile%"=="" choice /C ERCL & goto ErrOptResponse
if not "%LogFile%"=="" choice /C ERCL & goto ErrOptResponse
:ErrOptResponse
if "%errorlevel%"=="1" goto End
if "%errorlevel%"=="2" goto Restart
if "%errorlevel%"=="3" cmd
if "%errorlevel%"=="4" notepad "%LogFile%"
goto ErrorOptions

:End
cd ..\..\..

:Exit
endlocal

Mar 7, 2013 at 8:08 AM
Edited Mar 7, 2013 at 8:10 AM
Now I have a new issue.

Code: V8Engine = new V8ScriptEngine("Server", flags);

Error: Cannot load V8 proxy implementation type

In debugging it, it is trying to load the 32-bit version, but the type cannot be found.

I tried adding v8-ia32.dll as a reference, but I get this error: '[dll file]' could not be added. Please make sure that the file is accessible, and that is is a valid assembly or COM component.

???
Mar 7, 2013 at 9:00 AM
Edited Mar 7, 2013 at 9:01 AM
Hmmm, false alarm I guess. Even though I cannot reference the V8 DLLs (probably because it's not managed) the type can still be dynamically loaded. Anyhow, I had referenced the ClearScript project, which copied the .DLL, but it did not copy all the other libraries. I manually copied ALL the dependent DLLs, and it works! ;) I have a test server console now I can execute commands in; pretty nifty, good work. :)
Coordinator
Mar 7, 2013 at 2:23 PM
Edited Aug 3, 2013 at 3:32 AM
Hi jamesnw,

Wow, you've been busy! Great work on that script!

Installing other .NET SDK versions did nothing (it seems only the vcbuild.dll will be installed [and not the exe; though all functionality is actually in the DLL itself]). Reisntalling VS2012 also did nothing.

That was our experience as well. We found vcbuild.exe only after installing VS2008 side-by-side with VS2012. V8Update then successfully used VS2008 to build v8-ia32, but it failed to build v8-x64.

We're investigating ways to improve the V8 acquisition process. In the meantime we're going to do the following:
  • Force V8Update to use VS2012.
  • Add an option to rebuild V8 without re-downloading everything.
  • Ping the GYP developers. Targeting the oldest available VS version seems wrong, especially since only the latest versions (VS2010/2012) appear to be capable of building 64-bit V8.
Anyhow, I had referenced the ClearScript project, which copied the .DLL, but it did not copy all the other libraries. I manually copied ALL the dependent DLLs, and it works!

We definitely need to make it clear that V8 support requires that v8-*.dll and ClearScriptV8-*.dll be copied to the target directory. We're adding a new section in the ReadMe about integrating ClearScript.

Thanks again for helping sort this all out!