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 \
71 | sed -e "s,$src_path_bare,," \
72 -e 's/^[\./]\+//g' -e 's,[:/ ],_,g')
73 open_tag File RelativePath="$f"
75 if [ "$pat" == "asm" ] && $asm_use_custom_step; then
76 for plat in "${platforms[@]}"; do
77 for cfg in Debug Release; do
78 open_tag FileConfiguration \
79 Name="${cfg}|${plat}" \
82 Name="VCCustomBuildTool" \
83 Description="Assembling \$(InputFileName)" \
84 CommandLine="$(eval echo \$asm_${cfg}_cmdline) -o \$(IntDir)\\$objf" \
85 Outputs="\$(IntDir)\\$objf" \
87 close_tag FileConfiguration
91 if [ "$pat" == "c" ] || \
92 [ "$pat" == "cc" ] || [ "$pat" == "cpp" ]; then
93 for plat in "${platforms[@]}"; do
94 for cfg in Debug Release; do
95 open_tag FileConfiguration \
96 Name="${cfg}|${plat}" \
99 Name="VCCLCompilerTool" \
100 ObjectFile="\$(IntDir)\\$objf" \
102 close_tag FileConfiguration
117 # Process command line
124 --target=*) target="${optval}"
126 --out=*) outfile="$optval"
128 --name=*) name="${optval}"
130 --proj-guid=*) guid="${optval}"
132 --module-def=*) link_opts="${link_opts} ModuleDefinitionFile=${optval}"
134 --exe) proj_kind="exe"
136 --dll) proj_kind="dll"
138 --lib) proj_kind="lib"
141 src_path_bare=$(fix_path "$optval")
142 src_path_bare=${src_path_bare%/}
144 --static-crt) use_static_runtime=true
151 *) die Unrecognized Visual Studio Version in $opt
157 opt=$(fix_path "$opt")
159 incs="${incs}${incs:+;}"${opt}""
160 yasmincs="${yasmincs} -I"${opt}""
162 -D*) defines="${defines}${defines:+;}${opt##-D}"
164 -L*) # fudge . to $(OutDir)
165 if [ "${opt##-L}" == "." ]; then
166 libdirs="${libdirs}${libdirs:+;}"\$(OutDir)""
168 # Also try directories for this platform/configuration
170 opt=$(fix_path "$opt")
171 libdirs="${libdirs}${libdirs:+;}"${opt}""
172 libdirs="${libdirs}${libdirs:+;}"${opt}/\$(PlatformName)/\$(ConfigurationName)""
173 libdirs="${libdirs}${libdirs:+;}"${opt}/\$(PlatformName)""
176 -l*) libs="${libs}${libs:+ }${opt##-l}.lib"
181 # The paths in file_list are fixed outside of the loop.
182 file_list[${#file_list[@]}]="$opt"
191 # Make one call to fix_path for file_list to improve performance.
194 outfile=${outfile:-/dev/stdout}
195 guid=${guid:-`generate_uuid`}
196 asm_use_custom_step=false
197 uses_asm=${uses_asm:-false}
198 case "${vs_ver:-8}" in
200 asm_use_custom_step=$uses_asm
201 warn_64bit='Detect64BitPortabilityProblems=true'
204 asm_use_custom_step=$uses_asm
205 warn_64bit='Detect64BitPortabilityProblems=true'
208 asm_use_custom_step=$uses_asm
209 warn_64bit='Detect64BitPortabilityProblems=false'
213 [ -n "$name" ] || die "Project name (--name) must be specified!"
214 [ -n "$target" ] || die "Target (--target) must be specified!"
216 if ${use_static_runtime:-false}; then
226 # Calculate debug lib names: If a lib ends in ${lib_sfx}.lib, then rename
227 # it to ${lib_sfx}d.lib. This precludes linking to release libs from a
228 # debug exe, so this may need to be refactored later.
229 for lib in ${libs}; do
230 if [ "$lib" != "${lib%${lib_sfx}.lib}" ]; then
233 debug_libs="${debug_libs}${debug_libs:+ }${lib}"
237 # List Keyword for this target
239 x86*) keyword="ManagedCProj"
241 *) die "Unsupported target $target!"
244 # List of all platforms supported for this target
248 asm_Debug_cmdline="yasm -Xvc -g cv8 -f win64 ${yasmincs} "\$(InputPath)""
249 asm_Release_cmdline="yasm -Xvc -f win64 ${yasmincs} "\$(InputPath)""
253 asm_Debug_cmdline="yasm -Xvc -g cv8 -f win32 ${yasmincs} "\$(InputPath)""
254 asm_Release_cmdline="yasm -Xvc -f win32 ${yasmincs} "\$(InputPath)""
256 *) die "Unsupported target $target!"
262 exe) vs_ConfigurationType=1
264 dll) vs_ConfigurationType=2
266 *) vs_ConfigurationType=4
270 echo "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>"
271 open_tag VisualStudioProject \
272 ProjectType="Visual C++" \
273 Version="${vs_ver_id}" \
275 ProjectGUID="{${guid}}" \
276 RootNamespace="${name}" \
277 Keyword="${keyword}" \
280 for plat in "${platforms[@]}"; do
281 tag Platform Name="$plat"
285 open_tag Configurations
286 for plat in "${platforms[@]}"; do
287 plat_no_ws=`echo $plat | sed 's/[^A-Za-z0-9_]/_/g'`
288 open_tag Configuration \
290 OutputDirectory="\$(SolutionDir)$plat_no_ws/\$(ConfigurationName)" \
291 IntermediateDirectory="$plat_no_ws/\$(ConfigurationName)/${name}" \
292 ConfigurationType="$vs_ConfigurationType" \
300 Name="VCCLCompilerTool" \
302 AdditionalIncludeDirectories="$incs" \
303 PreprocessorDefinitions="WIN32;DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" \
304 RuntimeLibrary="$debug_runtime" \
306 DebugInformationFormat="1" \
311 Name="VCPreBuildEventTool" \
312 CommandLine="call obj_int_extract.bat "$src_path_bare" $plat_no_ws\\\$(ConfigurationName)" \
315 Name="VCCLCompilerTool" \
317 AdditionalIncludeDirectories="$incs" \
318 PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
319 RuntimeLibrary="$debug_runtime" \
320 UsePrecompiledHeader="0" \
322 DebugInformationFormat="2" \
325 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs" Debug="true"
329 Name="VCCLCompilerTool" \
331 AdditionalIncludeDirectories="$incs" \
332 PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
333 RuntimeLibrary="$debug_runtime" \
334 UsePrecompiledHeader="0" \
336 DebugInformationFormat="2" \
339 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs" Debug="true"
352 Name="VCLinkerTool" \
353 GenerateDebugInformation="true" \
357 Name="VCLinkerTool" \
358 AdditionalDependencies="$debug_libs \$(NoInherit)" \
359 AdditionalLibraryDirectories="$libdirs" \
360 GenerateDebugInformation="true" \
361 ProgramDatabaseFile="\$(OutDir)/${name}.pdb" \
371 Name="VCLibrarianTool" \
372 OutputFile="\$(OutDir)/${name}${lib_sfx}d.lib" \
379 Name="VCLinkerTool" \
380 AdditionalDependencies="\$(NoInherit)" \
381 LinkIncremental="2" \
382 GenerateDebugInformation="true" \
390 close_tag Configuration
392 open_tag Configuration \
393 Name="Release|$plat" \
394 OutputDirectory="\$(SolutionDir)$plat_no_ws/\$(ConfigurationName)" \
395 IntermediateDirectory="$plat_no_ws/\$(ConfigurationName)/${name}" \
396 ConfigurationType="$vs_ConfigurationType" \
398 WholeProgramOptimization="0" \
405 Name="VCCLCompilerTool" \
407 FavorSizeorSpeed="1" \
408 AdditionalIncludeDirectories="$incs" \
409 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" \
410 RuntimeLibrary="$release_runtime" \
411 UsePrecompiledHeader="0" \
413 DebugInformationFormat="0" \
418 Name="VCPreBuildEventTool" \
419 CommandLine="call obj_int_extract.bat "$src_path_bare" $plat_no_ws\\\$(ConfigurationName)" \
422 Name="VCCLCompilerTool" \
424 FavorSizeorSpeed="1" \
425 AdditionalIncludeDirectories="$incs" \
426 PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
427 RuntimeLibrary="$release_runtime" \
428 UsePrecompiledHeader="0" \
430 DebugInformationFormat="0" \
433 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs"
437 Name="VCCLCompilerTool" \
438 AdditionalIncludeDirectories="$incs" \
440 FavorSizeorSpeed="1" \
441 PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
442 RuntimeLibrary="$release_runtime" \
443 UsePrecompiledHeader="0" \
445 DebugInformationFormat="0" \
448 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs"
461 Name="VCLinkerTool" \
462 GenerateDebugInformation="true" \
466 Name="VCLinkerTool" \
467 AdditionalDependencies="$libs \$(NoInherit)" \
468 AdditionalLibraryDirectories="$libdirs" \
479 Name="VCLibrarianTool" \
480 OutputFile="\$(OutDir)/${name}${lib_sfx}.lib" \
485 dll) # note differences to debug version: LinkIncremental, AssemblyDebug
487 Name="VCLinkerTool" \
488 AdditionalDependencies="\$(NoInherit)" \
489 LinkIncremental="1" \
490 GenerateDebugInformation="true" \
497 close_tag Configuration
499 close_tag Configurations
502 generate_filter srcs "Source Files" "c;cc;cpp;def;odl;idl;hpj;bat;asm;asmx"
503 generate_filter hdrs "Header Files" "h;hm;inl;inc;xsd"
504 generate_filter resrcs "Resource Files" "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
505 generate_filter resrcs "Build Files" "mk"
509 close_tag VisualStudioProject
511 # This must be done from within the {} subshell
512 echo "Ignored files list (${#file_list[@]} items) is:" >&2
513 for f in "${file_list[@]}"; do
519 sed -e '/"/s;\([^ "]\)/;\1\\;g' > ${outfile}
523 TODO: Add any files not captured by filters.
525 RelativePath=".\ReadMe.txt"