Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / libvpx / source / libvpx / build / make / gen_msvs_proj.sh
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.
10 ##
11
12 self=$0
13 self_basename=${self##*/}
14 self_dirname=$(dirname "$0")
15
16 . "$self_dirname/msvs_common.sh"|| exit 127
17
18 show_help() {
19     cat <<EOF
20 Usage: ${self_basename} --name=projname [options] file1 [file2 ...]
21
22 This script generates a Visual Studio project file from a list of source
23 code files.
24
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     --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
42 EOF
43     exit 1
44 }
45
46 generate_filter() {
47     local var=$1
48     local name=$2
49     local pats=$3
50     local file_list_sz
51     local i
52     local f
53     local saveIFS="$IFS"
54     local pack
55     echo "generating filter '$name' from ${#file_list[@]} files" >&2
56     IFS=*
57
58     open_tag Filter \
59         Name=$name \
60         Filter=$pats \
61         UniqueIdentifier=`generate_uuid` \
62
63     file_list_sz=${#file_list[@]}
64     for i in ${!file_list[@]}; do
65         f=${file_list[i]}
66         for pat in ${pats//;/$IFS}; do
67             if [ "${f##*.}" == "$pat" ]; then
68                 unset file_list[i]
69
70                 objf=$(echo ${f%.*}.obj | sed -e 's/^[\./]\+//g' -e 's,[:/],_,g')
71                 open_tag File RelativePath="$f"
72
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}" \
78
79                             tag Tool \
80                                 Name="VCCustomBuildTool" \
81                                 Description="Assembling \$(InputFileName)" \
82                                 CommandLine="$(eval echo \$asm_${cfg}_cmdline) -o \$(IntDir)\\$objf" \
83                                 Outputs="\$(IntDir)\\$objf" \
84
85                             close_tag FileConfiguration
86                         done
87                     done
88                 fi
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}" \
95
96                             tag Tool \
97                                 Name="VCCLCompilerTool" \
98                                 ObjectFile="\$(IntDir)\\$objf" \
99
100                             close_tag FileConfiguration
101                         done
102                     done
103                 fi
104                 close_tag File
105
106                 break
107             fi
108         done
109     done
110
111     close_tag Filter
112     IFS="$saveIFS"
113 }
114
115 # Process command line
116 unset target
117 for opt in "$@"; do
118     optval="${opt#*=}"
119     case "$opt" in
120         --help|-h) show_help
121         ;;
122         --target=*) target="${optval}"
123         ;;
124         --out=*) outfile="$optval"
125         ;;
126         --name=*) name="${optval}"
127         ;;
128         --proj-guid=*) guid="${optval}"
129         ;;
130         --module-def=*) link_opts="${link_opts} ModuleDefinitionFile=${optval}"
131         ;;
132         --exe) proj_kind="exe"
133         ;;
134         --dll) proj_kind="dll"
135         ;;
136         --lib) proj_kind="lib"
137         ;;
138         --src-path-bare=*) src_path_bare=$(fix_path "$optval")
139         ;;
140         --static-crt) use_static_runtime=true
141         ;;
142         --ver=*)
143             vs_ver="$optval"
144             case "$optval" in
145                 [789])
146                 ;;
147                 *) die Unrecognized Visual Studio Version in $opt
148                 ;;
149             esac
150         ;;
151         -I*)
152             opt="${opt%/}"
153             opt=${opt##-I}
154             opt=$(fix_path "$opt")
155             incs="${incs}${incs:+;}&quot;${opt}&quot;"
156             yasmincs="${yasmincs} -I${opt}"
157         ;;
158         -D*) defines="${defines}${defines:+;}${opt##-D}"
159         ;;
160         -L*) # fudge . to $(OutDir)
161             if [ "${opt##-L}" == "." ]; then
162                 libdirs="${libdirs}${libdirs:+;}&quot;\$(OutDir)&quot;"
163             else
164                  # Also try directories for this platform/configuration
165                  opt=${opt##-L}
166                  opt=$(fix_path "$opt")
167                  libdirs="${libdirs}${libdirs:+;}&quot;${opt}&quot;"
168                  libdirs="${libdirs}${libdirs:+;}&quot;${opt}/\$(PlatformName)/\$(ConfigurationName)&quot;"
169                  libdirs="${libdirs}${libdirs:+;}&quot;${opt}/\$(PlatformName)&quot;"
170             fi
171         ;;
172         -l*) libs="${libs}${libs:+ }${opt##-l}.lib"
173         ;;
174         -*) die_unknown $opt
175         ;;
176         *)
177             file_list[${#file_list[@]}]="$(fix_path $opt)"
178             case "$opt" in
179                  *.asm) uses_asm=true
180                  ;;
181             esac
182         ;;
183     esac
184 done
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
190     7) vs_ver_id="7.10"
191        asm_use_custom_step=$uses_asm
192        warn_64bit='Detect64BitPortabilityProblems=true'
193     ;;
194     8) vs_ver_id="8.00"
195        asm_use_custom_step=$uses_asm
196        warn_64bit='Detect64BitPortabilityProblems=true'
197     ;;
198     9) vs_ver_id="9.00"
199        asm_use_custom_step=$uses_asm
200        warn_64bit='Detect64BitPortabilityProblems=false'
201     ;;
202 esac
203
204 [ -n "$name" ] || die "Project name (--name) must be specified!"
205 [ -n "$target" ] || die "Target (--target) must be specified!"
206
207 if ${use_static_runtime:-false}; then
208     release_runtime=0
209     debug_runtime=1
210     lib_sfx=mt
211 else
212     release_runtime=2
213     debug_runtime=3
214     lib_sfx=md
215 fi
216
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
222         lib=${lib%.lib}d.lib
223     fi
224     debug_libs="${debug_libs}${debug_libs:+ }${lib}"
225 done
226
227
228 # List Keyword for this target
229 case "$target" in
230     x86*) keyword="ManagedCProj"
231     ;;
232     *) die "Unsupported target $target!"
233 esac
234
235 # List of all platforms supported for this target
236 case "$target" in
237     x86_64*)
238         platforms[0]="x64"
239         asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;"
240         asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;"
241     ;;
242     x86*)
243         platforms[0]="Win32"
244         asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;"
245         asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;"
246     ;;
247     *) die "Unsupported target $target!"
248     ;;
249 esac
250
251 generate_vcproj() {
252     case "$proj_kind" in
253         exe) vs_ConfigurationType=1
254         ;;
255         dll) vs_ConfigurationType=2
256         ;;
257         *)   vs_ConfigurationType=4
258         ;;
259     esac
260
261     echo "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>"
262     open_tag VisualStudioProject \
263         ProjectType="Visual C++" \
264         Version="${vs_ver_id}" \
265         Name="${name}" \
266         ProjectGUID="{${guid}}" \
267         RootNamespace="${name}" \
268         Keyword="${keyword}" \
269
270     open_tag Platforms
271     for plat in "${platforms[@]}"; do
272         tag Platform Name="$plat"
273     done
274     close_tag Platforms
275
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 \
280             Name="Debug|$plat" \
281             OutputDirectory="\$(SolutionDir)$plat_no_ws/\$(ConfigurationName)" \
282             IntermediateDirectory="$plat_no_ws/\$(ConfigurationName)/${name}" \
283             ConfigurationType="$vs_ConfigurationType" \
284             CharacterSet="1" \
285
286         case "$target" in
287             x86*)
288                 case "$name" in
289                     obj_int_extract)
290                         tag Tool \
291                             Name="VCCLCompilerTool" \
292                             Optimization="0" \
293                             AdditionalIncludeDirectories="$incs" \
294                             PreprocessorDefinitions="WIN32;DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" \
295                             RuntimeLibrary="$debug_runtime" \
296                             WarningLevel="3" \
297                             DebugInformationFormat="1" \
298                             $warn_64bit \
299                     ;;
300                     vpx)
301                         tag Tool \
302                             Name="VCPreBuildEventTool" \
303                             CommandLine="call obj_int_extract.bat $src_path_bare $plat_no_ws\\\$(ConfigurationName)" \
304
305                         tag Tool \
306                             Name="VCCLCompilerTool" \
307                             Optimization="0" \
308                             AdditionalIncludeDirectories="$incs" \
309                             PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
310                             RuntimeLibrary="$debug_runtime" \
311                             UsePrecompiledHeader="0" \
312                             WarningLevel="3" \
313                             DebugInformationFormat="2" \
314                             $warn_64bit \
315
316                         $uses_asm && tag Tool Name="YASM"  IncludePaths="$incs" Debug="true"
317                     ;;
318                     *)
319                         tag Tool \
320                             Name="VCCLCompilerTool" \
321                             Optimization="0" \
322                             AdditionalIncludeDirectories="$incs" \
323                             PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
324                             RuntimeLibrary="$debug_runtime" \
325                             UsePrecompiledHeader="0" \
326                             WarningLevel="3" \
327                             DebugInformationFormat="2" \
328                             $warn_64bit \
329
330                         $uses_asm && tag Tool Name="YASM"  IncludePaths="$incs" Debug="true"
331                     ;;
332                 esac
333             ;;
334         esac
335
336         case "$proj_kind" in
337             exe)
338                 case "$target" in
339                     x86*)
340                         case "$name" in
341                             obj_int_extract)
342                                 tag Tool \
343                                     Name="VCLinkerTool" \
344                                     GenerateDebugInformation="true" \
345                             ;;
346                             *)
347                                 tag Tool \
348                                     Name="VCLinkerTool" \
349                                     AdditionalDependencies="$debug_libs \$(NoInherit)" \
350                                     AdditionalLibraryDirectories="$libdirs" \
351                                     GenerateDebugInformation="true" \
352                                     ProgramDatabaseFile="\$(OutDir)/${name}.pdb" \
353                             ;;
354                         esac
355                     ;;
356                  esac
357             ;;
358             lib)
359                 case "$target" in
360                     x86*)
361                         tag Tool \
362                             Name="VCLibrarianTool" \
363                             OutputFile="\$(OutDir)/${name}${lib_sfx}d.lib" \
364
365                     ;;
366                 esac
367             ;;
368             dll)
369                 tag Tool \
370                     Name="VCLinkerTool" \
371                     AdditionalDependencies="\$(NoInherit)" \
372                     LinkIncremental="2" \
373                     GenerateDebugInformation="true" \
374                     AssemblyDebug="1" \
375                     TargetMachine="1" \
376                     $link_opts \
377
378             ;;
379         esac
380
381         close_tag Configuration
382
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" \
388             CharacterSet="1" \
389             WholeProgramOptimization="0" \
390
391         case "$target" in
392             x86*)
393                 case "$name" in
394                     obj_int_extract)
395                         tag Tool \
396                             Name="VCCLCompilerTool" \
397                             Optimization="2" \
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" \
403                             WarningLevel="3" \
404                             DebugInformationFormat="0" \
405                             $warn_64bit \
406                     ;;
407                     vpx)
408                         tag Tool \
409                             Name="VCPreBuildEventTool" \
410                             CommandLine="call obj_int_extract.bat $src_path_bare $plat_no_ws\\\$(ConfigurationName)" \
411
412                         tag Tool \
413                             Name="VCCLCompilerTool" \
414                             Optimization="2" \
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" \
420                             WarningLevel="3" \
421                             DebugInformationFormat="0" \
422                             $warn_64bit \
423
424                         $uses_asm && tag Tool Name="YASM"  IncludePaths="$incs"
425                     ;;
426                     *)
427                         tag Tool \
428                             Name="VCCLCompilerTool" \
429                             AdditionalIncludeDirectories="$incs" \
430                             Optimization="2" \
431                             FavorSizeorSpeed="1" \
432                             PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;$defines" \
433                             RuntimeLibrary="$release_runtime" \
434                             UsePrecompiledHeader="0" \
435                             WarningLevel="3" \
436                             DebugInformationFormat="0" \
437                             $warn_64bit \
438
439                         $uses_asm && tag Tool Name="YASM"  IncludePaths="$incs"
440                     ;;
441                 esac
442             ;;
443         esac
444
445         case "$proj_kind" in
446             exe)
447                 case "$target" in
448                     x86*)
449                         case "$name" in
450                             obj_int_extract)
451                                 tag Tool \
452                                     Name="VCLinkerTool" \
453                                     GenerateDebugInformation="true" \
454                             ;;
455                             *)
456                                 tag Tool \
457                                     Name="VCLinkerTool" \
458                                     AdditionalDependencies="$libs \$(NoInherit)" \
459                                     AdditionalLibraryDirectories="$libdirs" \
460
461                             ;;
462                         esac
463                     ;;
464                  esac
465             ;;
466             lib)
467                 case "$target" in
468                     x86*)
469                         tag Tool \
470                             Name="VCLibrarianTool" \
471                             OutputFile="\$(OutDir)/${name}${lib_sfx}.lib" \
472
473                     ;;
474                 esac
475             ;;
476             dll) # note differences to debug version: LinkIncremental, AssemblyDebug
477                 tag Tool \
478                     Name="VCLinkerTool" \
479                     AdditionalDependencies="\$(NoInherit)" \
480                     LinkIncremental="1" \
481                     GenerateDebugInformation="true" \
482                     TargetMachine="1" \
483                     $link_opts \
484
485             ;;
486         esac
487
488         close_tag Configuration
489     done
490     close_tag Configurations
491
492     open_tag Files
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"
497     close_tag Files
498
499     tag       Globals
500     close_tag VisualStudioProject
501
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
505         echo "    $f" >&2
506     done
507 }
508
509 generate_vcproj |
510     sed  -e '/"/s;\([^ "]\)/;\1\\;g' > ${outfile}
511
512 exit
513 <!--
514 TODO: Add any files not captured by filters.
515                 <File
516                         RelativePath=".\ReadMe.txt"
517                         >
518                 </File>
519 -->