3 ## Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
5 ## Use of this source code is governed by a BSD-style license and patent
6 ## grant that can be found in the LICENSE file in the root of the source
7 ## tree. All contributing project authors may be found in the AUTHORS
8 ## file in the root of the source tree.
13 self_basename
=${self##*/}
18 Usage: ${self_basename} --name=projname [options] file1 [file2 ...]
20 This script generates a Visual Studio project file from a list of source
24 --help Print this message
25 --exe Generate a project for building an Application
26 --lib Generate a project for creating a static library
27 --static-crt Use the static C runtime (/MT)
28 --target=isa-os-cc Target specifier (required)
29 --out=filename Write output to a file [stdout]
30 --name=project_name Name of the project (required)
31 --proj-guid=GUID GUID to use for the project
32 --module-def=filename File containing export definitions (for DLLs)
33 --ver=version Version (7,8) of visual studio to generate for
34 -Ipath/to/include Additional include directories
35 -DFLAG[=value] Preprocessor macros to define
36 -Lpath/to/lib Additional library search paths
37 -llibname Library to link against
43 echo "${self_basename}: $@" >&2
48 echo "Unknown option \"$1\"." >&2
49 echo "See ${self_basename} --help for available options." >&2
54 local hex
="0123456789ABCDEF"
58 #93995380-89BD-4b04-88EB-625FBE52EBFB
59 for ((i
=0; i
<32; i
++)); do
60 (( j
= $RANDOM % 16 ))
61 uuid
="${uuid}${hex:$j:1}"
63 echo "${uuid:0:8}-${uuid:8:4}-${uuid:12:4}-${uuid:16:4}-${uuid:20:12}"
69 indent
="${indent}${indent1}"
72 indent
="${indent%${indent1}}"
79 die
"Missing attribute value in '$opt' while generating $tag tag"
80 echo "${indent}${opt%%=*}=\"${optval}\""
88 echo "${indent}<${tag}"
93 echo "${indent}<${tag}>"
101 echo "${indent}</${tag}>"
107 if [ $# -ne 0 ]; then
108 echo "${indent}<${tag}"
114 echo "${indent}<${tag}/>"
127 echo "generating filter '$name' from ${#file_list[@]} files" >&2
133 UniqueIdentifier
=`generate_uuid`
135 file_list_sz
=${#file_list[@]}
136 for i
in ${!file_list[@]}; do
138 for pat
in ${pats//;/$IFS}; do
139 if [ "${f##*.}" == "$pat" ]; then
142 open_tag File RelativePath
="./$f"
143 if [ "$pat" == "asm" ] && $asm_use_custom_step; then
144 for plat
in "${platforms[@]}"; do
145 for cfg
in Debug Release
; do
146 open_tag FileConfiguration \
147 Name
="${cfg}|${plat}"
149 Name
="VCCustomBuildTool" \
150 Description
="Assembling \$(InputFileName)" \
151 CommandLine
="$(eval echo \$asm_${cfg}_cmdline)"\
152 Outputs
="\$(InputName).obj"
153 close_tag FileConfiguration
158 if [ "${f##*.}" == "cpp" ]; then
159 for plat
in "${platforms[@]}"; do
160 for cfg
in Debug Release
; do
161 open_tag FileConfiguration \
162 Name
="${cfg}|${plat}"
164 Name
="VCCLCompilerTool" \
166 close_tag FileConfiguration
181 # Process command line
188 --target=*) target
="${optval}"
190 --out=*) outfile
="$optval"
192 --name=*) name
="${optval}"
194 --proj-guid=*) guid
="${optval}"
197 link_opts
="${link_opts} ModuleDefinitionFile=${optval}"
199 --exe) proj_kind
="exe"
201 --lib) proj_kind
="lib"
203 --static-crt) use_static_runtime
=true
205 --ver=*) vs_ver
="$optval"
209 *) die Unrecognized Visual Studio Version
in $opt
214 incs
="${incs}${incs:+;}"${opt##-I}""
215 yasmincs
="${yasmincs} ${opt}"
217 -D*) defines
="${defines}${defines:+;}${opt##-D}"
219 -L*) # fudge . to $(OutDir)
220 if [ "${opt##-L}" == "." ]; then
221 libdirs
="${libdirs}${libdirs:+;}"\$(OutDir)""
223 # Also try directories for this platform/configuration
224 libdirs
="${libdirs}${libdirs:+;}"${opt##-L}""
225 libdirs
="${libdirs}${libdirs:+;}"${opt##-L}/\$(PlatformName)/\$(ConfigurationName)""
226 libdirs
="${libdirs}${libdirs:+;}"${opt##-L}/\$(PlatformName)""
229 -l*) libs
="${libs}${libs:+ }${opt##-l}.lib"
233 *) file_list
[${#file_list[@]}]="$opt"
235 *.asm
) uses_asm
=true
;;
239 outfile
=${outfile:-/dev/stdout}
240 guid
=${guid:-`generate_uuid`}
241 asm_use_custom_step
=false
242 uses_asm
=${uses_asm:-false}
243 case "${vs_ver:-8}" in
245 asm_use_custom_step
=$uses_asm
251 [ -n "$name" ] || die
"Project name (--name) must be specified!"
252 [ -n "$target" ] || die
"Target (--target) must be specified!"
254 if ${use_static_runtime:-false}; then
264 # Calculate debug lib names: If a lib ends in ${lib_sfx}.lib, then rename
265 # it to ${lib_sfx}d.lib. This precludes linking to release libs from a
266 # debug exe, so this may need to be refactored later.
267 for lib
in ${libs}; do
268 if [ "$lib" != "${lib%${lib_sfx}.lib}" ]; then
271 debug_libs
="${debug_libs}${debug_libs:+ }${lib}"
275 # List Keyword for this target
278 keyword
="ManagedCProj"
283 *) die
"Unsupported target $target!"
286 # List of all platforms supported for this target
293 # these are only used by vs7
294 asm_Debug_cmdline
="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} \$(InputPath)"
295 asm_Release_cmdline
="yasm -Xvc -f \$(PlatformName) ${yasmincs} \$(InputPath)"
299 obj_int_extract
) platforms
[0]="Win32"
301 *) platforms
[0]="Pocket PC 2003 (ARMV4)"
305 *) die
"Unsupported target $target!"
308 # List Command-line Arguments for this target
311 if [ "$name" == "example" ];then
312 ARGU
="--codec vp6 --flipuv --progress _bnd.vp6"
314 if [ "$name" == "xma" ];then
315 ARGU
="--codec vp6 -h 240 -w 320 -v"
322 exe
) vs_ConfigurationType
=1
324 *) vs_ConfigurationType
=4
328 echo "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>"
329 open_tag VisualStudioProject \
330 ProjectType
="Visual C++" \
331 Version
="${vs_ver_id}" \
333 ProjectGUID
="{${guid}}" \
334 RootNamespace
="${name}" \
338 for plat
in "${platforms[@]}"; do
339 tag Platform Name
="$plat"
345 x86
*) $uses_asm && tag DefaultToolFile FileName
="yasm.rules"
348 if [ "$name" == "vpx_decoder" ];then
351 tag DefaultToolFile FileName
="armasmv5.rules"
354 tag DefaultToolFile FileName
="armasmv6.rules"
357 tag DefaultToolFile FileName
="armasmxscale.rules"
365 open_tag Configurations
366 for plat
in "${platforms[@]}"; do
367 plat_no_ws
=`echo $plat | sed 's/[^A-Za-z0-9_]/_/g'`
368 open_tag Configuration \
370 OutputDirectory
="\$(SolutionDir)$plat_no_ws/\$(ConfigurationName)" \
371 IntermediateDirectory
="$plat_no_ws/\$(ConfigurationName)/${name}" \
372 ConfigurationType
="$vs_ConfigurationType" \
375 if [ "$target" == "armv6-wince-vs8" ] ||
[ "$target" == "armv5te-wince-vs8" ] ||
[ "$target" == "iwmmxt-wince-vs8" ] ||
[ "$target" == "iwmmxt2-wince-vs8" ];then
377 vpx_decoder
) tag Tool \
378 Name
="VCPreBuildEventTool" \
379 CommandLine
="call obj_int_extract.bat \$(ConfigurationName)"
382 TargetEnvironment
="1"
384 Name
="VCCLCompilerTool" \
385 ExecutionBucket
="7" \
387 AdditionalIncludeDirectories
="$incs" \
388 PreprocessorDefinitions
="_DEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES);WINCE;DEBUG;_LIB;\$(ARCHFAM);\$(_ARCHFAM_);_UNICODE;UNICODE;" \
389 MinimalRebuild
="true" \
391 BufferSecurityCheck
="false" \
392 UsePrecompiledHeader
="0" \
394 DebugInformationFormat
="1" \
397 Name
="VCResourceCompilerTool" \
398 PreprocessorDefinitions
="_DEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES)" \
400 AdditionalIncludeDirectories
="\$(IntDir)" \
402 example|xma
) tag Tool \
403 Name
="VCCLCompilerTool" \
404 ExecutionBucket
="7" \
406 AdditionalIncludeDirectories
="$incs" \
407 PreprocessorDefinitions
="_DEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES);WINCE;DEBUG;_CONSOLE;\$(ARCHFAM);\$(_ARCHFAM_);_UNICODE;UNICODE;" \
408 MinimalRebuild
="true" \
410 BufferSecurityCheck
="false" \
411 UsePrecompiledHeader
="0" \
413 DebugInformationFormat
="1" \
416 Name
="VCResourceCompilerTool" \
417 PreprocessorDefinitions
="_DEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES)" \
419 AdditionalIncludeDirectories
="\$(IntDir)" \
421 obj_int_extract
) tag Tool \
422 Name
="VCCLCompilerTool" \
424 AdditionalIncludeDirectories
="$incs" \
425 PreprocessorDefinitions
="WIN32;DEBUG;_CONSOLE" \
428 DebugInformationFormat
="1" \
435 Name
="VCCLCompilerTool" \
437 AdditionalIncludeDirectories
="$incs" \
438 PreprocessorDefinitions
="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;$defines" \
439 RuntimeLibrary
="$debug_runtime" \
440 UsePrecompiledHeader
="0" \
442 DebugInformationFormat
="1" \
443 Detect64BitPortabilityProblems
="true" \
445 $uses_asm && tag Tool Name
="YASM" IncludePaths
="$incs" Debug
="1"
453 Name
="VCLinkerTool" \
454 AdditionalDependencies
="$debug_libs \$(NoInherit)" \
455 AdditionalLibraryDirectories
="$libdirs" \
456 GenerateDebugInformation
="true" \
457 ProgramDatabaseFile
="\$(OutDir)/${name}.pdb" \
462 obj_int_extract
) tag Tool \
463 Name
="VCLinkerTool" \
464 OutputFile
="${name}.exe" \
465 GenerateDebugInformation
="true"
468 Name
="VCLinkerTool" \
469 AdditionalDependencies
="$debug_libs" \
470 OutputFile
="\$(OutDir)/${name}.exe" \
471 LinkIncremental
="2" \
472 AdditionalLibraryDirectories
="${libdirs};"..\lib/$plat_no_ws"" \
473 DelayLoadDLLs
="\$(NOINHERIT)" \
474 GenerateDebugInformation
="true" \
475 ProgramDatabaseFile
="\$(OutDir)/${name}.pdb" \
477 StackReserveSize
="65536" \
478 StackCommitSize
="4096" \
479 EntryPointSymbol
="mainWCRTStartup" \
488 arm
*|iwmmx
*) tag Tool \
489 Name
="VCLibrarianTool" \
490 AdditionalOptions
=" /subsystem:windowsce,4.20 /machine:ARM" \
491 OutputFile
="\$(OutDir)/${name}.lib" \
494 Name
="VCLibrarianTool" \
495 OutputFile
="\$(OutDir)/${name}${lib_sfx}d.lib" \
500 Name
="VCLinkerTool" \
501 AdditionalDependencies
="\$(NoInherit)" \
502 LinkIncremental
="2" \
503 GenerateDebugInformation
="true" \
509 if [ "$target" == "armv6-wince-vs8" ] ||
[ "$target" == "armv5te-wince-vs8" ] ||
[ "$target" == "iwmmxt-wince-vs8" ] ||
[ "$target" == "iwmmxt2-wince-vs8" ];then
511 vpx_decoder
) tag DeploymentTool \
515 example|xma
) tag DeploymentTool \
523 close_tag Configuration
525 open_tag Configuration \
526 Name
="Release|$plat" \
527 OutputDirectory
="\$(SolutionDir)$plat_no_ws/\$(ConfigurationName)" \
528 IntermediateDirectory
="$plat_no_ws/\$(ConfigurationName)/${name}" \
529 ConfigurationType
="$vs_ConfigurationType" \
531 WholeProgramOptimization
="0"
533 if [ "$target" == "armv6-wince-vs8" ] ||
[ "$target" == "armv5te-wince-vs8" ] ||
[ "$target" == "iwmmxt-wince-vs8" ] ||
[ "$target" == "iwmmxt2-wince-vs8" ];then
535 vpx_decoder
) tag Tool \
536 Name
="VCPreBuildEventTool" \
537 CommandLine
="call obj_int_extract.bat \$(ConfigurationName)"
540 TargetEnvironment
="1"
542 Name
="VCCLCompilerTool" \
543 ExecutionBucket
="7" \
545 FavorSizeOrSpeed
="1" \
546 AdditionalIncludeDirectories
="$incs" \
547 PreprocessorDefinitions
="NDEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES);WINCE;_LIB;\$(ARCHFAM);\$(_ARCHFAM_);_UNICODE;UNICODE;" \
549 BufferSecurityCheck
="false" \
550 UsePrecompiledHeader
="0" \
552 DebugInformationFormat
="0" \
555 Name
="VCResourceCompilerTool" \
556 PreprocessorDefinitions
="NDEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES)" \
558 AdditionalIncludeDirectories
="\$(IntDir)" \
560 example|xma
) tag Tool \
561 Name
="VCCLCompilerTool" \
562 ExecutionBucket
="7" \
564 FavorSizeOrSpeed
="1" \
565 AdditionalIncludeDirectories
="$incs" \
566 PreprocessorDefinitions
="NDEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES);WINCE;_CONSOLE;\$(ARCHFAM);\$(_ARCHFAM_);_UNICODE;UNICODE;" \
568 BufferSecurityCheck
="false" \
569 UsePrecompiledHeader
="0" \
571 DebugInformationFormat
="0" \
574 Name
="VCResourceCompilerTool" \
575 PreprocessorDefinitions
="NDEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES)" \
577 AdditionalIncludeDirectories
="\$(IntDir)" \
579 obj_int_extract
) tag Tool \
580 Name
="VCCLCompilerTool" \
581 AdditionalIncludeDirectories
="$incs" \
582 PreprocessorDefinitions
="WIN32;NDEBUG;_CONSOLE" \
584 UsePrecompiledHeader
="0" \
586 Detect64BitPortabilityProblems
="true" \
587 DebugInformationFormat
="0" \
594 Name
="VCCLCompilerTool" \
595 AdditionalIncludeDirectories
="$incs" \
596 PreprocessorDefinitions
="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;$defines" \
597 RuntimeLibrary
="$release_runtime" \
598 UsePrecompiledHeader
="0" \
600 DebugInformationFormat
="0" \
601 Detect64BitPortabilityProblems
="true"
603 $uses_asm && tag Tool Name
="YASM" IncludePaths
="$incs"
611 Name
="VCLinkerTool" \
612 AdditionalDependencies
="$libs \$(NoInherit)" \
613 AdditionalLibraryDirectories
="$libdirs" \
617 obj_int_extract
) tag Tool \
618 Name
="VCLinkerTool" \
619 OutputFile
="${name}.exe" \
620 LinkIncremental
="1" \
621 GenerateDebugInformation
="false" \
623 OptimizeReferences
="0" \
624 EnableCOMDATFolding
="0" \
628 Name
="VCLinkerTool" \
629 AdditionalDependencies
="$libs" \
630 OutputFile
="\$(OutDir)/${name}.exe" \
631 LinkIncremental
="1" \
632 AdditionalLibraryDirectories
="${libdirs};"..\lib/$plat_no_ws"" \
633 DelayLoadDLLs
="\$(NOINHERIT)" \
634 GenerateDebugInformation
="true" \
635 ProgramDatabaseFile
="\$(OutDir)/${name}.pdb" \
637 StackReserveSize
="65536" \
638 StackCommitSize
="4096" \
639 OptimizeReferences
="2" \
640 EnableCOMDATFolding
="2" \
641 EntryPointSymbol
="mainWCRTStartup" \
650 arm
*|iwmmx
*) tag Tool \
651 Name
="VCLibrarianTool" \
652 AdditionalOptions
=" /subsystem:windowsce,4.20 /machine:ARM" \
653 OutputFile
="\$(OutDir)/${name}.lib" \
656 Name
="VCLibrarianTool" \
657 OutputFile
="\$(OutDir)/${name}${lib_sfx}.lib" \
661 dll
) # note differences to debug version: LinkIncremental, AssemblyDebug
663 Name
="VCLinkerTool" \
664 AdditionalDependencies
="\$(NoInherit)" \
665 LinkIncremental
="1" \
666 GenerateDebugInformation
="true" \
671 if [ "$target" == "armv6-wince-vs8" ] ||
[ "$target" == "armv5te-wince-vs8" ] ||
[ "$target" == "iwmmxt-wince-vs8" ] ||
[ "$target" == "iwmmxt2-wince-vs8" ];then
673 vpx_decoder
) tag DeploymentTool \
677 example|xma
) tag DeploymentTool \
686 close_tag Configuration
688 close_tag Configurations
691 generate_filter srcs
"Source Files" "cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
692 generate_filter hdrs
"Header Files" "h;hpp;hxx;hm;inl;inc;xsd"
693 generate_filter resrcs
"Resource Files" "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
694 generate_filter resrcs
"Build Files" "mk"
698 close_tag VisualStudioProject
700 # This must be done from within the {} subshell
701 echo "Ignored files list (${#file_list[@]} items) is:" >&2
702 for f
in "${file_list[@]}"; do
708 sed -e '/"/s;\([^ "]\)/;\1\\;g' > ${outfile}
712 TODO
: Add any files not captured by filters.
714 RelativePath
=".\ReadMe.txt"