3 ## Copyright (c) 2010 The WebM project authors. All Rights Reserved.
5 ## Use of this source code is governed by a BSD-style license
6 ## that can be found in the LICENSE file in the root of the source
7 ## tree. An additional intellectual property rights grant can be found
8 ## in the file PATENTS. All contributing project authors may
9 ## be found in the AUTHORS file in the root of the source tree.
13 self_basename=${self##*/}
14 self_dirname=$(dirname "$0")
16 . "$self_dirname/msvs_common.sh"|| exit 127
20 Usage: ${self_basename} --name=projname [options] file1 [file2 ...]
22 This script generates a Visual Studio project file from a list of source
26 --help Print this message
27 --exe Generate a project for building an Application
28 --lib Generate a project for creating a static library
29 --dll Generate a project for creating a dll
30 --static-crt Use the static C runtime (/MT)
31 --target=isa-os-cc Target specifier (required)
32 --out=filename Write output to a file [stdout]
33 --name=project_name Name of the project (required)
34 --proj-guid=GUID GUID to use for the project
35 --module-def=filename File containing export definitions (for DLLs)
36 --ver=version Version (7,8,9) of visual studio to generate for
37 --src-path-bare=dir Path to root of source tree
38 -Ipath/to/include Additional include directories
39 -DFLAG[=value] Preprocessor macros to define
40 -Lpath/to/lib Additional library search paths
41 -llibname Library to link against
55 echo "generating filter '$name' from ${#file_list[@]} files" >&2
61 UniqueIdentifier=`generate_uuid` \
63 file_list_sz=${#file_list[@]}
64 for i in ${!file_list[@]}; do
66 for pat in ${pats//;/$IFS}; do
67 if [ "${f##*.}" == "$pat" ]; then
70 objf=$(echo ${f%.*}.obj | sed -e 's/^[\./]\+//g' -e 's,[:/],_,g')
71 open_tag File RelativePath="$f"
73 if [ "$pat" == "asm" ] && $asm_use_custom_step; then
74 for plat in "${platforms[@]}"; do
75 for cfg in Debug Release; do
76 open_tag FileConfiguration \
77 Name="${cfg}|${plat}" \
80 Name="VCCustomBuildTool" \
81 Description="Assembling \$(InputFileName)" \
82 CommandLine="$(eval echo \$asm_${cfg}_cmdline) -o \$(IntDir)\\$objf" \
83 Outputs="\$(IntDir)\\$objf" \
85 close_tag FileConfiguration
89 if [ "$pat" == "c" ] || \
90 [ "$pat" == "cc" ] || [ "$pat" == "cpp" ]; then
91 for plat in "${platforms[@]}"; do
92 for cfg in Debug Release; do
93 open_tag FileConfiguration \
94 Name="${cfg}|${plat}" \
97 Name="VCCLCompilerTool" \
98 ObjectFile="\$(IntDir)\\$objf" \
100 close_tag FileConfiguration
115 # Process command line
122 --target=*) target="${optval}"
124 --out=*) outfile="$optval"
126 --name=*) name="${optval}"
128 --proj-guid=*) guid="${optval}"
130 --module-def=*) link_opts="${link_opts} ModuleDefinitionFile=${optval}"
132 --exe) proj_kind="exe"
134 --dll) proj_kind="dll"
136 --lib) proj_kind="lib"
138 --src-path-bare=*) src_path_bare=$(fix_path "$optval")
140 --static-crt) use_static_runtime=true
147 *) die Unrecognized Visual Studio Version in $opt
154 opt=$(fix_path "$opt")
155 incs="${incs}${incs:+;}"${opt}""
156 yasmincs="${yasmincs} -I${opt}"
158 -D*) defines="${defines}${defines:+;}${opt##-D}"
160 -L*) # fudge . to $(OutDir)
161 if [ "${opt##-L}" == "." ]; then
162 libdirs="${libdirs}${libdirs:+;}"\$(OutDir)""
164 # Also try directories for this platform/configuration
166 opt=$(fix_path "$opt")
167 libdirs="${libdirs}${libdirs:+;}"${opt}""
168 libdirs="${libdirs}${libdirs:+;}"${opt}/\$(PlatformName)/\$(ConfigurationName)""
169 libdirs="${libdirs}${libdirs:+;}"${opt}/\$(PlatformName)""
172 -l*) libs="${libs}${libs:+ }${opt##-l}.lib"
177 file_list[${#file_list[@]}]="$(fix_path $opt)"
185 outfile=${outfile:-/dev/stdout}
186 guid=${guid:-`generate_uuid`}
187 asm_use_custom_step=false
188 uses_asm=${uses_asm:-false}
189 case "${vs_ver:-8}" in
191 asm_use_custom_step=$uses_asm
192 warn_64bit='Detect64BitPortabilityProblems=true'
195 asm_use_custom_step=$uses_asm
196 warn_64bit='Detect64BitPortabilityProblems=true'
199 asm_use_custom_step=$uses_asm
200 warn_64bit='Detect64BitPortabilityProblems=false'
204 [ -n "$name" ] || die "Project name (--name) must be specified!"
205 [ -n "$target" ] || die "Target (--target) must be specified!"
207 if ${use_static_runtime:-false}; then
217 # Calculate debug lib names: If a lib ends in ${lib_sfx}.lib, then rename
218 # it to ${lib_sfx}d.lib. This precludes linking to release libs from a
219 # debug exe, so this may need to be refactored later.
220 for lib in ${libs}; do
221 if [ "$lib" != "${lib%${lib_sfx}.lib}" ]; then
224 debug_libs="${debug_libs}${debug_libs:+ }${lib}"
228 # List Keyword for this target
230 x86*) keyword="ManagedCProj"
232 *) die "Unsupported target $target!"
235 # List of all platforms supported for this target
239 asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
240 asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
244 asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
245 asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
247 *) die "Unsupported target $target!"
253 exe) vs_ConfigurationType=1
255 dll) vs_ConfigurationType=2
257 *) vs_ConfigurationType=4
261 echo "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>"
262 open_tag VisualStudioProject \
263 ProjectType="Visual C++" \
264 Version="${vs_ver_id}" \
266 ProjectGUID="{${guid}}" \
267 RootNamespace="${name}" \
268 Keyword="${keyword}" \
271 for plat in "${platforms[@]}"; do
272 tag Platform Name="$plat"
276 open_tag Configurations
277 for plat in "${platforms[@]}"; do
278 plat_no_ws=`echo $plat | sed 's/[^A-Za-z0-9_]/_/g'`
279 open_tag Configuration \
281 OutputDirectory="\$(SolutionDir)$plat_no_ws/\$(ConfigurationName)" \
282 IntermediateDirectory="$plat_no_ws/\$(ConfigurationName)/${name}" \
283 ConfigurationType="$vs_ConfigurationType" \
291 Name="VCCLCompilerTool" \
293 AdditionalIncludeDirectories="$incs" \
294 PreprocessorDefinitions="WIN32;DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" \
295 RuntimeLibrary="$debug_runtime" \
297 DebugInformationFormat="1" \
302 Name="VCPreBuildEventTool" \
303 CommandLine="call obj_int_extract.bat $src_path_bare $plat_no_ws\\\$(ConfigurationName)" \
306 Name="VCCLCompilerTool" \
308 AdditionalIncludeDirectories="$incs" \
309 PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
310 RuntimeLibrary="$debug_runtime" \
311 UsePrecompiledHeader="0" \
313 DebugInformationFormat="2" \
316 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs" Debug="true"
320 Name="VCCLCompilerTool" \
322 AdditionalIncludeDirectories="$incs" \
323 PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
324 RuntimeLibrary="$debug_runtime" \
325 UsePrecompiledHeader="0" \
327 DebugInformationFormat="2" \
330 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs" Debug="true"
343 Name="VCLinkerTool" \
344 GenerateDebugInformation="true" \
348 Name="VCLinkerTool" \
349 AdditionalDependencies="$debug_libs \$(NoInherit)" \
350 AdditionalLibraryDirectories="$libdirs" \
351 GenerateDebugInformation="true" \
352 ProgramDatabaseFile="\$(OutDir)/${name}.pdb" \
362 Name="VCLibrarianTool" \
363 OutputFile="\$(OutDir)/${name}${lib_sfx}d.lib" \
370 Name="VCLinkerTool" \
371 AdditionalDependencies="\$(NoInherit)" \
372 LinkIncremental="2" \
373 GenerateDebugInformation="true" \
381 close_tag Configuration
383 open_tag Configuration \
384 Name="Release|$plat" \
385 OutputDirectory="\$(SolutionDir)$plat_no_ws/\$(ConfigurationName)" \
386 IntermediateDirectory="$plat_no_ws/\$(ConfigurationName)/${name}" \
387 ConfigurationType="$vs_ConfigurationType" \
389 WholeProgramOptimization="0" \
396 Name="VCCLCompilerTool" \
398 FavorSizeorSpeed="1" \
399 AdditionalIncludeDirectories="$incs" \
400 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" \
401 RuntimeLibrary="$release_runtime" \
402 UsePrecompiledHeader="0" \
404 DebugInformationFormat="0" \
409 Name="VCPreBuildEventTool" \
410 CommandLine="call obj_int_extract.bat $src_path_bare $plat_no_ws\\\$(ConfigurationName)" \
413 Name="VCCLCompilerTool" \
415 FavorSizeorSpeed="1" \
416 AdditionalIncludeDirectories="$incs" \
417 PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
418 RuntimeLibrary="$release_runtime" \
419 UsePrecompiledHeader="0" \
421 DebugInformationFormat="0" \
424 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs"
428 Name="VCCLCompilerTool" \
429 AdditionalIncludeDirectories="$incs" \
431 FavorSizeorSpeed="1" \
432 PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
433 RuntimeLibrary="$release_runtime" \
434 UsePrecompiledHeader="0" \
436 DebugInformationFormat="0" \
439 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs"
452 Name="VCLinkerTool" \
453 GenerateDebugInformation="true" \
457 Name="VCLinkerTool" \
458 AdditionalDependencies="$libs \$(NoInherit)" \
459 AdditionalLibraryDirectories="$libdirs" \
470 Name="VCLibrarianTool" \
471 OutputFile="\$(OutDir)/${name}${lib_sfx}.lib" \
476 dll) # note differences to debug version: LinkIncremental, AssemblyDebug
478 Name="VCLinkerTool" \
479 AdditionalDependencies="\$(NoInherit)" \
480 LinkIncremental="1" \
481 GenerateDebugInformation="true" \
488 close_tag Configuration
490 close_tag Configurations
493 generate_filter srcs "Source Files" "c;cc;cpp;def;odl;idl;hpj;bat;asm;asmx"
494 generate_filter hdrs "Header Files" "h;hm;inl;inc;xsd"
495 generate_filter resrcs "Resource Files" "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
496 generate_filter resrcs "Build Files" "mk"
500 close_tag VisualStudioProject
502 # This must be done from within the {} subshell
503 echo "Ignored files list (${#file_list[@]} items) is:" >&2
504 for f in "${file_list[@]}"; do
510 sed -e '/"/s;\([^ "]\)/;\1\\;g' > ${outfile}
514 TODO: Add any files not captured by filters.
516 RelativePath=".\ReadMe.txt"