windows: build system improvements
* Add shared/static library option * Add x86/x64 target option * Improve Visual Studio detection * Set GYP_MSVS_VERSION to pick VS2010 over VS2008 Closes GH-504 Closes GH-514
This commit is contained in:
parent
45931f8b2b
commit
5bfb7c917b
@ -117,6 +117,11 @@
|
||||
# POSIX names
|
||||
'_CRT_NONSTDC_NO_DEPRECATE',
|
||||
],
|
||||
'target_conditions': [
|
||||
['target_arch=="x64"', {
|
||||
'msvs_configuration_platform': 'x64'
|
||||
}]
|
||||
]
|
||||
}],
|
||||
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
|
||||
'cflags': [ '-Wall' ],
|
||||
|
||||
12
gyp_uv
12
gyp_uv
@ -45,6 +45,9 @@ if __name__ == '__main__':
|
||||
args.append(os.path.join(uv_root, 'uv.gyp'))
|
||||
common_fn = os.path.join(uv_root, 'common.gypi')
|
||||
options_fn = os.path.join(uv_root, 'options.gypi')
|
||||
# we force vs 2010 over 2008 which would otherwise be the default for gyp
|
||||
if not os.environ.get('GYP_MSVS_VERSION'):
|
||||
os.environ['GYP_MSVS_VERSION'] = '2010'
|
||||
else:
|
||||
args.append(os.path.join(os.path.abspath(uv_root), 'uv.gyp'))
|
||||
common_fn = os.path.join(os.path.abspath(uv_root), 'common.gypi')
|
||||
@ -69,9 +72,14 @@ if __name__ == '__main__':
|
||||
args.append('-Dgcc_version=%d' % (10 * major + minor))
|
||||
args.append('-Dclang=%d' % int(is_clang))
|
||||
|
||||
args.append('-Dtarget_arch=ia32')
|
||||
if not any(a.startswith('-Dtarget_arch') for a in args):
|
||||
args.append('-Dtarget_arch=ia32')
|
||||
|
||||
if not any(a.startswith('-Dlibrary') for a in args):
|
||||
args.append('-Dlibrary=static_library')
|
||||
|
||||
args.append('-Dcomponent=static_library')
|
||||
args.append('-Dlibrary=static_library')
|
||||
|
||||
gyp_args = list(args)
|
||||
print gyp_args
|
||||
run_gyp(gyp_args)
|
||||
|
||||
3
uv.gyp
3
uv.gyp
@ -239,6 +239,9 @@
|
||||
[ 'OS=="mac" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', {
|
||||
'sources': [ 'src/unix/kqueue.c' ],
|
||||
}],
|
||||
['library=="shared_library"', {
|
||||
'defines': [ 'BUILDING_UV_SHARED=1' ]
|
||||
}]
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
42
vcbuild.bat
42
vcbuild.bat
@ -17,6 +17,9 @@ set target=Build
|
||||
set noprojgen=
|
||||
set nobuild=
|
||||
set run=
|
||||
set target_arch=ia32
|
||||
set vs_toolset=x86
|
||||
set platform=WIN32
|
||||
|
||||
:next-arg
|
||||
if "%1"=="" goto args-done
|
||||
@ -27,11 +30,36 @@ if /i "%1"=="bench" set run=run-benchmarks.exe&goto arg-ok
|
||||
if /i "%1"=="clean" set target=Clean&goto arg-ok
|
||||
if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
|
||||
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
|
||||
if /i "%1"=="x86" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
|
||||
if /i "%1"=="ia32" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
|
||||
if /i "%1"=="x64" set target_arch=x64&set platform=amd64&set vs_toolset=x64&goto arg-ok
|
||||
if /i "%1"=="shared" set library=shared_library&goto arg-ok
|
||||
if /i "%1"=="static" set library=static_library&goto arg-ok
|
||||
:arg-ok
|
||||
shift
|
||||
goto next-arg
|
||||
:args-done
|
||||
|
||||
@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%
|
||||
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
|
||||
call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
|
||||
echo Warning: building with Visual Studio 2008 is currently not supported.
|
||||
set GYP_MSVS_VERSION=2008
|
||||
goto select-target
|
||||
|
||||
:vc-set-notfound
|
||||
echo Warning: Visual Studio not found
|
||||
|
||||
:select-target
|
||||
if not "%config%"=="" goto project-gen
|
||||
if "%run%"=="run-tests.exe" set config=Debug& goto project-gen
|
||||
if "%run%"=="run-benchmarks.exe" set config=Release& goto project-gen
|
||||
@ -42,7 +70,6 @@ set config=Debug
|
||||
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
|
||||
@ -55,7 +82,7 @@ echo manually install gyp into %~dp0build\gyp.
|
||||
goto exit
|
||||
|
||||
:have_gyp
|
||||
python gyp_uv
|
||||
python gyp_uv -Dtarget_arch=%target_arch% -Dlibrary=%library%
|
||||
if errorlevel 1 goto create-msvs-files-failed
|
||||
if not exist uv.sln goto create-msvs-files-failed
|
||||
echo Project files generated.
|
||||
@ -64,12 +91,7 @@ echo Project files generated.
|
||||
@rem Skip project generation if requested.
|
||||
if defined nobuild goto run
|
||||
|
||||
@rem If not running in the VS build env, try to start it. If that fails, bail
|
||||
@rem out.
|
||||
if defined VCINSTALLDIR goto msbuild-found
|
||||
if not defined VS100COMNTOOLS goto msbuild-not-found
|
||||
if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found
|
||||
call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat"
|
||||
@rem Check if VS build env is available
|
||||
if not defined VCINSTALLDIR goto msbuild-not-found
|
||||
goto msbuild-found
|
||||
|
||||
@ -79,7 +101,7 @@ goto run
|
||||
|
||||
@rem Build the sln with msbuild.
|
||||
:msbuild-found
|
||||
msbuild uv.sln /t:%target% /p:Configuration=%config% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
|
||||
msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
|
||||
if errorlevel 1 goto exit
|
||||
|
||||
:run
|
||||
@ -95,7 +117,7 @@ echo Failed to create vc project files.
|
||||
goto exit
|
||||
|
||||
:help
|
||||
echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild]
|
||||
echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [x86/x64] [static/shared]
|
||||
echo Examples:
|
||||
echo vcbuild.bat : builds debug build
|
||||
echo vcbuild.bat test : builds debug build and runs tests
|
||||
|
||||
Loading…
Reference in New Issue
Block a user