Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Windows build: support vs2012, fix shared #677

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 45 additions & 0 deletions uv.gyp
Expand Up @@ -353,6 +353,51 @@
'_XOPEN_SOURCE=500',
],
}],
['OS=="win" and library=="shared_library"', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this section necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without that section when building the shared(dll) version of the library you get this error:

test-spawn.obj : error LNK2019: unresolved external symbol _uv_utf8_to_utf16 referenced in function _run_test_environment_creation [C:\Users\Luigi\Documents\GitHub\libuv\run-tests.vcxproj]
test-spawn.obj : error LNK2019: unresolved external symbol _make_program_args referenced in function _run_test_argument_escaping [C:\Users\Luigi\Documents\GitHub\libuv\run-tests.vcxproj]
test-spawn.obj : error LNK2019: unresolved external symbol _quote_cmd_arg referenced in function _run_test_argument_escaping [C:\Users\Luigi\Documents\GitHub\libuv\run-tests.vcxproj]
test-spawn.obj : error LNK2019: unresolved external symbol _make_program_env referenced in function _run_test_environment_creation [C:\Users\Luigi\Documents\GitHub\libuv\run-tests.vcxproj]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that a matter of fixing the sources list in the normal OS=="win" section? This seems like a rather massive duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the cleanest solution I can think of.
This section is only needed when building the dll on windows. Other solution would involve to change multiple sections that don't actually need this change. The change is a single block (that can be easily removed if the future if not needed anymore) so I think it's really clean.
As long as the test program is using library staff that is not exported by the library (because not needed) this change is required to make the build work.

'sources': [
'include/uv-private/uv-win.h',
'src/uv-common.c',
'src/fs-poll.c',
'src/inet.c',
'src/win/async.c',
'src/win/atomicops-inl.h',
'src/win/core.c',
'src/win/dl.c',
'src/win/error.c',
'src/win/fs.c',
'src/win/fs-event.c',
'src/win/getaddrinfo.c',
'src/win/handle.c',
'src/win/handle-inl.h',
'src/win/internal.h',
'src/win/loop-watcher.c',
'src/win/pipe.c',
'src/win/thread.c',
'src/win/poll.c',
'src/win/process.c',
'src/win/process-stdio.c',
'src/win/req.c',
'src/win/req-inl.h',
'src/win/signal.c',
'src/win/stream.c',
'src/win/stream-inl.h',
'src/win/tcp.c',
'src/win/tty.c',
'src/win/threadpool.c',
'src/win/timer.c',
'src/win/udp.c',
'src/win/util.c',
'src/win/winapi.c',
'src/win/winapi.h',
'src/win/winsock.c',
'src/win/winsock.h',
],
'include_dirs': [
'include',
'include/uv-private',
'src/',
],
}],
],
'msvs-settings': {
'VCLinkerTool': {
Expand Down
56 changes: 48 additions & 8 deletions vcbuild.bat
Expand Up @@ -24,6 +24,12 @@ set library=static_library

:next-arg
if "%1"=="" goto args-done

if "%1"=="help" goto help
if "%1"=="/?" goto help
if "%1"=="-h" goto help
if "%1"=="--help" goto help

if /i "%1"=="debug" set config=Debug&goto arg-ok
if /i "%1"=="release" set config=Release&goto arg-ok
if /i "%1"=="test" set run=run-tests.exe&goto arg-ok
Expand All @@ -41,21 +47,42 @@ shift
goto next-arg
:args-done

@rem Find a Visual Studio version
@rem If multiple versions are installed on the system the lookup order is: 2010, 2008, 2012

@rem You can force a specific Visual Studio version uncommenting the following line
@rem and changing the version to the one to force
@rem goto vc-set-2012

:vc-set-2010
@rem Look for Visual Studio 2010
if not defined VS100COMNTOOLS goto vc-set-2008
if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008
call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
echo Visul Studio 2010 found
set GYP_MSVS_VERSION=2010
goto select-target

:vc-set-2008
@rem Look for Visual Studio 2008
if not defined VS90COMNTOOLS goto vc-set-notfound
if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound
if not defined VS90COMNTOOLS goto vc-set-2012
if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2012
call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
echo Visul Studio 2008 found
set GYP_MSVS_VERSION=2008
goto select-target

:vc-set-2012
@rem Look for Visual Studio 2012
if not defined VS110COMNTOOLS goto vc-set-notfound
if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound
call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
@rem Using Visual Studio 2010 project format until the gyp version linked to
@rem the project will support Visual Studio 2012
echo Visul Studio 2012 found
set GYP_MSVS_VERSION=2012
goto select-target

:vc-set-notfound
echo Warning: Visual Studio not found

Expand All @@ -71,8 +98,9 @@ if defined noprojgen goto msbuild

@rem Generate the VS project.
if exist build\gyp goto have_gyp
echo svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp
svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp
@rem used to be 983
echo svn co http://gyp.googlecode.com/svn/trunk@1556 build/gyp
svn co http://gyp.googlecode.com/svn/trunk@1556 build/gyp
if errorlevel 1 goto gyp_install_failed
goto have_gyp

Expand Down Expand Up @@ -117,11 +145,23 @@ echo Failed to create vc project files.
goto exit

:help
echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [x86/x64] [static/shared]
echo Usage: vcbuild [option(s)]
echo.
echo Available options:
echo [debug/release]
echo [test/bench]
echo [clean]
echo [noprojgen]
echo [nobuild]
echo [x86/x64]
echo [static/shared]
echo.
echo Examples:
echo vcbuild.bat : builds debug build
echo vcbuild.bat test : builds debug build and runs tests
echo vcbuild.bat release bench: builds release build and runs benchmarks
echo vcbuild : builds static debug build
echo vcbuild test : builds static debug build and runs tests
echo vcbuild release bench : builds static release build and runs benchmarks
echo vcbuild release shared : builds dll release build

goto exit

:exit