Merge "Skip computation of distortion in vp8_pick_inter_mode if active_map is used"
[libvpx.git] / build / make / gen_msvs_proj.sh
blobff9b665fcdea2743d012f1735f7a81a27ec49bb0
1 #!/bin/bash
2 ##
3 ## Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 ##
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=$0
14 self_basename=${self##*/}
15 self_dirname=$(dirname "$0")
16 EOL=$'\n'
18 show_help() {
19 cat <<EOF
20 Usage: ${self_basename} --name=projname [options] file1 [file2 ...]
22 This script generates a Visual Studio project file from a list of source
23 code files.
25 Options:
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 --static-crt Use the static C runtime (/MT)
30 --target=isa-os-cc Target specifier (required)
31 --out=filename Write output to a file [stdout]
32 --name=project_name Name of the project (required)
33 --proj-guid=GUID GUID to use for the project
34 --module-def=filename File containing export definitions (for DLLs)
35 --ver=version Version (7,8,9) of visual studio to generate for
36 --src-path-bare=dir Path to root of source tree
37 -Ipath/to/include Additional include directories
38 -DFLAG[=value] Preprocessor macros to define
39 -Lpath/to/lib Additional library search paths
40 -llibname Library to link against
41 EOF
42 exit 1
45 die() {
46 echo "${self_basename}: $@" >&2
47 exit 1
50 die_unknown(){
51 echo "Unknown option \"$1\"." >&2
52 echo "See ${self_basename} --help for available options." >&2
53 exit 1
56 generate_uuid() {
57 local hex="0123456789ABCDEF"
58 local i
59 local uuid=""
60 local j
61 #93995380-89BD-4b04-88EB-625FBE52EBFB
62 for ((i=0; i<32; i++)); do
63 (( j = $RANDOM % 16 ))
64 uuid="${uuid}${hex:$j:1}"
65 done
66 echo "${uuid:0:8}-${uuid:8:4}-${uuid:12:4}-${uuid:16:4}-${uuid:20:12}"
69 indent1=" "
70 indent=""
71 indent_push() {
72 indent="${indent}${indent1}"
74 indent_pop() {
75 indent="${indent%${indent1}}"
78 tag_attributes() {
79 for opt in "$@"; do
80 optval="${opt#*=}"
81 [ -n "${optval}" ] ||
82 die "Missing attribute value in '$opt' while generating $tag tag"
83 echo "${indent}${opt%%=*}=\"${optval}\""
84 done
87 open_tag() {
88 local tag=$1
89 shift
90 if [ $# -ne 0 ]; then
91 echo "${indent}<${tag}"
92 indent_push
93 tag_attributes "$@"
94 echo "${indent}>"
95 else
96 echo "${indent}<${tag}>"
97 indent_push
101 close_tag() {
102 local tag=$1
103 indent_pop
104 echo "${indent}</${tag}>"
107 tag() {
108 local tag=$1
109 shift
110 if [ $# -ne 0 ]; then
111 echo "${indent}<${tag}"
112 indent_push
113 tag_attributes "$@"
114 indent_pop
115 echo "${indent}/>"
116 else
117 echo "${indent}<${tag}/>"
121 generate_filter() {
122 local var=$1
123 local name=$2
124 local pats=$3
125 local file_list_sz
126 local i
127 local f
128 local saveIFS="$IFS"
129 local pack
130 echo "generating filter '$name' from ${#file_list[@]} files" >&2
131 IFS=*
133 open_tag Filter \
134 Name=$name \
135 Filter=$pats \
136 UniqueIdentifier=`generate_uuid` \
138 file_list_sz=${#file_list[@]}
139 for i in ${!file_list[@]}; do
140 f=${file_list[i]}
141 for pat in ${pats//;/$IFS}; do
142 if [ "${f##*.}" == "$pat" ]; then
143 unset file_list[i]
145 open_tag File RelativePath="./$f"
146 if [ "$pat" == "asm" ] && $asm_use_custom_step; then
147 for plat in "${platforms[@]}"; do
148 for cfg in Debug Release; do
149 open_tag FileConfiguration \
150 Name="${cfg}|${plat}" \
152 tag Tool \
153 Name="VCCustomBuildTool" \
154 Description="Assembling \$(InputFileName)" \
155 CommandLine="$(eval echo \$asm_${cfg}_cmdline)" \
156 Outputs="\$(InputName).obj" \
158 close_tag FileConfiguration
159 done
160 done
163 close_tag File
165 break
167 done
168 done
170 close_tag Filter
171 IFS="$saveIFS"
174 # Process command line
175 unset target
176 for opt in "$@"; do
177 optval="${opt#*=}"
178 case "$opt" in
179 --help|-h) show_help
181 --target=*) target="${optval}"
183 --out=*) outfile="$optval"
185 --name=*) name="${optval}"
187 --proj-guid=*) guid="${optval}"
189 --module-def=*) link_opts="${link_opts} ModuleDefinitionFile=${optval}"
191 --exe) proj_kind="exe"
193 --lib) proj_kind="lib"
195 --src-path-bare=*) src_path_bare="$optval"
197 --static-crt) use_static_runtime=true
199 --ver=*)
200 vs_ver="$optval"
201 case "$optval" in
202 [789])
204 *) die Unrecognized Visual Studio Version in $opt
206 esac
208 -I*)
209 opt="${opt%/}"
210 incs="${incs}${incs:+;}&quot;${opt##-I}&quot;"
211 yasmincs="${yasmincs} ${opt}"
213 -D*) defines="${defines}${defines:+;}${opt##-D}"
215 -L*) # fudge . to $(OutDir)
216 if [ "${opt##-L}" == "." ]; then
217 libdirs="${libdirs}${libdirs:+;}&quot;\$(OutDir)&quot;"
218 else
219 # Also try directories for this platform/configuration
220 libdirs="${libdirs}${libdirs:+;}&quot;${opt##-L}&quot;"
221 libdirs="${libdirs}${libdirs:+;}&quot;${opt##-L}/\$(PlatformName)/\$(ConfigurationName)&quot;"
222 libdirs="${libdirs}${libdirs:+;}&quot;${opt##-L}/\$(PlatformName)&quot;"
225 -l*) libs="${libs}${libs:+ }${opt##-l}.lib"
227 -*) die_unknown $opt
230 file_list[${#file_list[@]}]="$opt"
231 case "$opt" in
232 *.asm) uses_asm=true
234 esac
236 esac
237 done
238 outfile=${outfile:-/dev/stdout}
239 guid=${guid:-`generate_uuid`}
240 asm_use_custom_step=false
241 uses_asm=${uses_asm:-false}
242 case "${vs_ver:-8}" in
243 7) vs_ver_id="7.10"
244 asm_use_custom_step=$uses_asm
246 8) vs_ver_id="8.00"
248 9) vs_ver_id="9.00"
250 esac
252 [ -n "$name" ] || die "Project name (--name) must be specified!"
253 [ -n "$target" ] || die "Target (--target) must be specified!"
255 if ${use_static_runtime:-false}; then
256 release_runtime=0
257 debug_runtime=1
258 lib_sfx=mt
259 else
260 release_runtime=2
261 debug_runtime=3
262 lib_sfx=md
265 # Calculate debug lib names: If a lib ends in ${lib_sfx}.lib, then rename
266 # it to ${lib_sfx}d.lib. This precludes linking to release libs from a
267 # debug exe, so this may need to be refactored later.
268 for lib in ${libs}; do
269 if [ "$lib" != "${lib%${lib_sfx}.lib}" ]; then
270 lib=${lib%.lib}d.lib
272 debug_libs="${debug_libs}${debug_libs:+ }${lib}"
273 done
276 # List Keyword for this target
277 case "$target" in
278 x86*) keyword="ManagedCProj"
280 *) die "Unsupported target $target!"
281 esac
283 # List of all platforms supported for this target
284 case "$target" in
285 x86_64*)
286 platforms[0]="x64"
288 x86*)
289 platforms[0]="Win32"
290 # these are only used by vs7
291 asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;"
292 asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;"
294 *) die "Unsupported target $target!"
296 esac
298 generate_vcproj() {
299 case "$proj_kind" in
300 exe) vs_ConfigurationType=1
302 *) vs_ConfigurationType=4
304 esac
306 echo "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>"
307 open_tag VisualStudioProject \
308 ProjectType="Visual C++" \
309 Version="${vs_ver_id}" \
310 Name="${name}" \
311 ProjectGUID="{${guid}}" \
312 RootNamespace="${name}" \
313 Keyword="${keyword}" \
315 open_tag Platforms
316 for plat in "${platforms[@]}"; do
317 tag Platform Name="$plat"
318 done
319 close_tag Platforms
321 open_tag ToolFiles
322 case "$target" in
323 x86*) $uses_asm && tag ToolFile RelativePath="$self_dirname/../x86-msvs/yasm.rules"
325 esac
326 close_tag ToolFiles
328 open_tag Configurations
329 for plat in "${platforms[@]}"; do
330 plat_no_ws=`echo $plat | sed 's/[^A-Za-z0-9_]/_/g'`
331 open_tag Configuration \
332 Name="Debug|$plat" \
333 OutputDirectory="\$(SolutionDir)$plat_no_ws/\$(ConfigurationName)" \
334 IntermediateDirectory="$plat_no_ws/\$(ConfigurationName)/${name}" \
335 ConfigurationType="$vs_ConfigurationType" \
336 CharacterSet="1" \
338 case "$target" in
339 x86*)
340 case "$name" in
341 obj_int_extract)
342 tag Tool \
343 Name="VCCLCompilerTool" \
344 Optimization="0" \
345 AdditionalIncludeDirectories="$incs" \
346 PreprocessorDefinitions="WIN32;DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" \
347 RuntimeLibrary="$debug_runtime" \
348 WarningLevel="3" \
349 Detect64BitPortabilityProblems="true" \
350 DebugInformationFormat="1" \
352 vpx)
353 tag Tool \
354 Name="VCPreBuildEventTool" \
355 CommandLine="call obj_int_extract.bat $src_path_bare" \
357 tag Tool \
358 Name="VCCLCompilerTool" \
359 Optimization="0" \
360 AdditionalIncludeDirectories="$incs" \
361 PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
362 RuntimeLibrary="$debug_runtime" \
363 UsePrecompiledHeader="0" \
364 WarningLevel="3" \
365 DebugInformationFormat="1" \
366 Detect64BitPortabilityProblems="true" \
368 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs" Debug="true"
371 tag Tool \
372 Name="VCCLCompilerTool" \
373 Optimization="0" \
374 AdditionalIncludeDirectories="$incs" \
375 PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
376 RuntimeLibrary="$debug_runtime" \
377 UsePrecompiledHeader="0" \
378 WarningLevel="3" \
379 DebugInformationFormat="1" \
380 Detect64BitPortabilityProblems="true" \
382 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs" Debug="true"
384 esac
386 esac
388 case "$proj_kind" in
389 exe)
390 case "$target" in
391 x86*)
392 case "$name" in
393 obj_int_extract)
394 tag Tool \
395 Name="VCLinkerTool" \
396 OutputFile="${name}.exe" \
397 GenerateDebugInformation="true" \
400 tag Tool \
401 Name="VCLinkerTool" \
402 AdditionalDependencies="$debug_libs \$(NoInherit)" \
403 AdditionalLibraryDirectories="$libdirs" \
404 GenerateDebugInformation="true" \
405 ProgramDatabaseFile="\$(OutDir)/${name}.pdb" \
407 esac
409 esac
411 lib)
412 case "$target" in
413 x86*)
414 tag Tool \
415 Name="VCLibrarianTool" \
416 OutputFile="\$(OutDir)/${name}${lib_sfx}d.lib" \
419 esac
421 dll)
422 tag Tool \
423 Name="VCLinkerTool" \
424 AdditionalDependencies="\$(NoInherit)" \
425 LinkIncremental="2" \
426 GenerateDebugInformation="true" \
427 AssemblyDebug="1" \
428 TargetMachine="1" \
429 $link_opts \
432 esac
434 close_tag Configuration
436 open_tag Configuration \
437 Name="Release|$plat" \
438 OutputDirectory="\$(SolutionDir)$plat_no_ws/\$(ConfigurationName)" \
439 IntermediateDirectory="$plat_no_ws/\$(ConfigurationName)/${name}" \
440 ConfigurationType="$vs_ConfigurationType" \
441 CharacterSet="1" \
442 WholeProgramOptimization="0" \
444 case "$target" in
445 x86*)
446 case "$name" in
447 obj_int_extract)
448 tag Tool \
449 Name="VCCLCompilerTool" \
450 Optimization="2" \
451 FavorSizeorSpeed="1" \
452 AdditionalIncludeDirectories="$incs" \
453 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" \
454 RuntimeLibrary="$release_runtime" \
455 UsePrecompiledHeader="0" \
456 WarningLevel="3" \
457 Detect64BitPortabilityProblems="true" \
458 DebugInformationFormat="0" \
460 vpx)
461 tag Tool \
462 Name="VCPreBuildEventTool" \
463 CommandLine="call obj_int_extract.bat $src_path_bare" \
465 tag Tool \
466 Name="VCCLCompilerTool" \
467 Optimization="2" \
468 FavorSizeorSpeed="1" \
469 AdditionalIncludeDirectories="$incs" \
470 PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
471 RuntimeLibrary="$release_runtime" \
472 UsePrecompiledHeader="0" \
473 WarningLevel="3" \
474 DebugInformationFormat="0" \
475 Detect64BitPortabilityProblems="true" \
477 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs"
480 tag Tool \
481 Name="VCCLCompilerTool" \
482 AdditionalIncludeDirectories="$incs" \
483 Optimization="2" \
484 FavorSizeorSpeed="1" \
485 PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
486 RuntimeLibrary="$release_runtime" \
487 UsePrecompiledHeader="0" \
488 WarningLevel="3" \
489 DebugInformationFormat="0" \
490 Detect64BitPortabilityProblems="true" \
492 $uses_asm && tag Tool Name="YASM" IncludePaths="$incs"
494 esac
496 esac
498 case "$proj_kind" in
499 exe)
500 case "$target" in
501 x86*)
502 case "$name" in
503 obj_int_extract)
504 tag Tool \
505 Name="VCLinkerTool" \
506 OutputFile="${name}.exe" \
507 GenerateDebugInformation="true" \
510 tag Tool \
511 Name="VCLinkerTool" \
512 AdditionalDependencies="$libs \$(NoInherit)" \
513 AdditionalLibraryDirectories="$libdirs" \
516 esac
518 esac
520 lib)
521 case "$target" in
522 x86*)
523 tag Tool \
524 Name="VCLibrarianTool" \
525 OutputFile="\$(OutDir)/${name}${lib_sfx}.lib" \
528 esac
530 dll) # note differences to debug version: LinkIncremental, AssemblyDebug
531 tag Tool \
532 Name="VCLinkerTool" \
533 AdditionalDependencies="\$(NoInherit)" \
534 LinkIncremental="1" \
535 GenerateDebugInformation="true" \
536 TargetMachine="1" \
537 $link_opts \
540 esac
542 close_tag Configuration
543 done
544 close_tag Configurations
546 open_tag Files
547 generate_filter srcs "Source Files" "c;def;odl;idl;hpj;bat;asm;asmx"
548 generate_filter hdrs "Header Files" "h;hm;inl;inc;xsd"
549 generate_filter resrcs "Resource Files" "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
550 generate_filter resrcs "Build Files" "mk"
551 close_tag Files
553 tag Globals
554 close_tag VisualStudioProject
556 # This must be done from within the {} subshell
557 echo "Ignored files list (${#file_list[@]} items) is:" >&2
558 for f in "${file_list[@]}"; do
559 echo " $f" >&2
560 done
563 generate_vcproj |
564 sed -e '/"/s;\([^ "]\)/;\1\\;g' > ${outfile}
566 exit
567 <!--
568 TODO: Add any files not captured by filters.
569 <File
570 RelativePath=".\ReadMe.txt"
572 </File>