2010-05-18 17:58:33 +02:00
|
|
|
#!/bin/bash
|
|
|
|
##
|
2010-09-09 14:16:39 +02:00
|
|
|
## Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
##
|
2010-06-18 18:39:21 +02:00
|
|
|
## Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
## that can be found in the LICENSE file in the root of the source
|
|
|
|
## tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
## in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
## be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
self=$0
|
|
|
|
self_basename=${self##*/}
|
|
|
|
EOL=$'\n'
|
|
|
|
EOLDOS=$'\r'
|
|
|
|
|
|
|
|
show_help() {
|
|
|
|
cat <<EOF
|
|
|
|
Usage: ${self_basename} [options] file1 [file2 ...]
|
|
|
|
|
|
|
|
This script generates a Visual Studio 2005 solution file from a list of project
|
|
|
|
files.
|
|
|
|
|
|
|
|
Options:
|
|
|
|
--help Print this message
|
|
|
|
--out=outfile Redirect output to a file
|
2013-05-16 23:59:20 +02:00
|
|
|
--ver=version Version (7,8,9,10,11) of visual studio to generate for
|
2010-05-18 17:58:33 +02:00
|
|
|
--target=isa-os-cc Target specifier
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
die() {
|
|
|
|
echo "${self_basename}: $@" >&2
|
|
|
|
[ -f "${outfile}" ] && rm -f ${outfile}{,.mk}
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
die_unknown(){
|
|
|
|
echo "Unknown option \"$1\"." >&2
|
|
|
|
echo "See ${self_basename} --help for available options." >&2
|
|
|
|
[ -f "${outfile}" ] && rm -f ${outfile}{,.mk}
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
indent1=$'\t'
|
|
|
|
indent=""
|
|
|
|
indent_push() {
|
|
|
|
indent="${indent}${indent1}"
|
|
|
|
}
|
|
|
|
indent_pop() {
|
|
|
|
indent="${indent%${indent1}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
parse_project() {
|
|
|
|
local file=$1
|
2013-05-16 23:59:20 +02:00
|
|
|
if [ "$sfx" = "vcproj" ]; then
|
|
|
|
local name=`grep Name "$file" | awk 'BEGIN {FS="\""}{if (NR==1) print $2}'`
|
|
|
|
local guid=`grep ProjectGUID "$file" | awk 'BEGIN {FS="\""}{if (NR==1) print $2}'`
|
|
|
|
else
|
|
|
|
local name=`grep RootNamespace "$file" | sed 's,.*<.*>\(.*\)</.*>.*,\1,'`
|
|
|
|
local guid=`grep ProjectGuid "$file" | sed 's,.*<.*>\(.*\)</.*>.*,\1,'`
|
|
|
|
fi
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
# save the project GUID to a varaible, normalizing to the basename of the
|
|
|
|
# vcproj file without the extension
|
|
|
|
local var
|
|
|
|
var=${file##*/}
|
2013-05-16 23:59:20 +02:00
|
|
|
var=${var%%.${sfx}}
|
2010-05-18 17:58:33 +02:00
|
|
|
eval "${var}_file=\"$1\""
|
|
|
|
eval "${var}_name=$name"
|
|
|
|
eval "${var}_guid=$guid"
|
|
|
|
|
2013-04-06 04:30:15 +02:00
|
|
|
if [ "$sfx" = "vcproj" ]; then
|
2013-07-24 15:06:49 +02:00
|
|
|
cur_config_list=`grep -A1 '<Configuration' $file |
|
2013-04-06 04:30:15 +02:00
|
|
|
grep Name | cut -d\" -f2`
|
|
|
|
else
|
2013-07-24 15:06:49 +02:00
|
|
|
cur_config_list=`grep -B1 'Label="Configuration"' $file |
|
2013-04-06 04:30:15 +02:00
|
|
|
grep Condition | cut -d\' -f4`
|
|
|
|
fi
|
2013-07-24 15:06:49 +02:00
|
|
|
new_config_list=$(for i in $config_list $cur_config_list; do
|
|
|
|
echo $i
|
|
|
|
done | sort | uniq)
|
|
|
|
if [ "$config_list" != "" ] && [ "$config_list" != "$new_config_list" ]; then
|
|
|
|
mixed_platforms=1
|
|
|
|
fi
|
|
|
|
config_list="$new_config_list"
|
|
|
|
eval "${var}_config_list=\"$cur_config_list\""
|
2010-05-18 17:58:33 +02:00
|
|
|
proj_list="${proj_list} ${var}"
|
|
|
|
}
|
|
|
|
|
|
|
|
process_project() {
|
|
|
|
eval "local file=\${$1_file}"
|
|
|
|
eval "local name=\${$1_name}"
|
|
|
|
eval "local guid=\${$1_guid}"
|
|
|
|
|
|
|
|
# save the project GUID to a varaible, normalizing to the basename of the
|
|
|
|
# vcproj file without the extension
|
|
|
|
local var
|
|
|
|
var=${file##*/}
|
2013-05-16 23:59:20 +02:00
|
|
|
var=${var%%.${sfx}}
|
2010-05-18 17:58:33 +02:00
|
|
|
eval "${var}_guid=$guid"
|
|
|
|
|
|
|
|
echo "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"$name\", \"$file\", \"$guid\""
|
|
|
|
indent_push
|
|
|
|
|
|
|
|
eval "local deps=\"\${${var}_deps}\""
|
2013-05-16 23:59:20 +02:00
|
|
|
if [ -n "$deps" ] && [ "$sfx" = "vcproj" ]; then
|
2010-05-18 17:58:33 +02:00
|
|
|
echo "${indent}ProjectSection(ProjectDependencies) = postProject"
|
|
|
|
indent_push
|
|
|
|
|
|
|
|
for dep in $deps; do
|
|
|
|
eval "local dep_guid=\${${dep}_guid}"
|
|
|
|
[ -z "${dep_guid}" ] && die "Unknown GUID for $dep (dependency of $var)"
|
|
|
|
echo "${indent}$dep_guid = $dep_guid"
|
|
|
|
done
|
|
|
|
|
|
|
|
indent_pop
|
|
|
|
echo "${indent}EndProjectSection"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
indent_pop
|
|
|
|
echo "EndProject"
|
|
|
|
}
|
|
|
|
|
|
|
|
process_global() {
|
|
|
|
echo "Global"
|
|
|
|
indent_push
|
|
|
|
|
|
|
|
#
|
|
|
|
# Solution Configuration Platforms
|
|
|
|
#
|
|
|
|
echo "${indent}GlobalSection(SolutionConfigurationPlatforms) = preSolution"
|
|
|
|
indent_push
|
|
|
|
IFS_bak=${IFS}
|
|
|
|
IFS=$'\r'$'\n'
|
2013-07-24 15:06:49 +02:00
|
|
|
if [ "$mixed_platforms" != "" ]; then
|
|
|
|
config_list="
|
|
|
|
Release|Mixed Platforms
|
|
|
|
Debug|Mixed Platforms"
|
|
|
|
fi
|
2010-05-18 17:58:33 +02:00
|
|
|
for config in ${config_list}; do
|
|
|
|
echo "${indent}$config = $config"
|
|
|
|
done
|
|
|
|
IFS=${IFS_bak}
|
|
|
|
indent_pop
|
|
|
|
echo "${indent}EndGlobalSection"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Project Configuration Platforms
|
|
|
|
#
|
|
|
|
echo "${indent}GlobalSection(ProjectConfigurationPlatforms) = postSolution"
|
|
|
|
indent_push
|
|
|
|
for proj in ${proj_list}; do
|
|
|
|
eval "local proj_guid=\${${proj}_guid}"
|
2013-07-24 15:06:49 +02:00
|
|
|
eval "local proj_config_list=\${${proj}_config_list}"
|
2010-05-18 17:58:33 +02:00
|
|
|
IFS=$'\r'$'\n'
|
2013-07-24 15:06:49 +02:00
|
|
|
for config in ${proj_config_list}; do
|
|
|
|
if [ "$mixed_platforms" != "" ]; then
|
|
|
|
local c=${config%%|*}
|
|
|
|
echo "${indent}${proj_guid}.${c}|Mixed Platforms.ActiveCfg = ${config}"
|
|
|
|
echo "${indent}${proj_guid}.${c}|Mixed Platforms.Build.0 = ${config}"
|
|
|
|
else
|
|
|
|
echo "${indent}${proj_guid}.${config}.ActiveCfg = ${config}"
|
|
|
|
echo "${indent}${proj_guid}.${config}.Build.0 = ${config}"
|
|
|
|
fi
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
done
|
|
|
|
IFS=${IFS_bak}
|
|
|
|
done
|
|
|
|
indent_pop
|
|
|
|
echo "${indent}EndGlobalSection"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Solution Properties
|
|
|
|
#
|
|
|
|
echo "${indent}GlobalSection(SolutionProperties) = preSolution"
|
|
|
|
indent_push
|
|
|
|
echo "${indent}HideSolutionNode = FALSE"
|
|
|
|
indent_pop
|
|
|
|
echo "${indent}EndGlobalSection"
|
|
|
|
|
|
|
|
indent_pop
|
|
|
|
echo "EndGlobal"
|
|
|
|
}
|
|
|
|
|
|
|
|
process_makefile() {
|
|
|
|
IFS_bak=${IFS}
|
|
|
|
IFS=$'\r'$'\n'
|
|
|
|
local TAB=$'\t'
|
|
|
|
cat <<EOF
|
2013-04-06 04:30:15 +02:00
|
|
|
ifeq (\$(CONFIG_VS_VERSION),7)
|
|
|
|
MSBUILD_TOOL := devenv.com
|
|
|
|
else
|
|
|
|
MSBUILD_TOOL := msbuild.exe
|
|
|
|
endif
|
|
|
|
found_devenv := \$(shell which \$(MSBUILD_TOOL) >/dev/null 2>&1 && echo yes)
|
2010-05-18 17:58:33 +02:00
|
|
|
.nodevenv.once:
|
2013-04-06 04:30:15 +02:00
|
|
|
${TAB}@echo " * \$(MSBUILD_TOOL) not found in path."
|
2010-05-18 17:58:33 +02:00
|
|
|
${TAB}@echo " * "
|
|
|
|
${TAB}@echo " * You will have to build all configurations manually using the"
|
|
|
|
${TAB}@echo " * Visual Studio IDE. To allow make to build them automatically,"
|
|
|
|
${TAB}@echo " * add the Common7/IDE directory of your Visual Studio"
|
|
|
|
${TAB}@echo " * installation to your path, eg:"
|
|
|
|
${TAB}@echo " * C:\Program Files\Microsoft Visual Studio 8\Common7\IDE"
|
|
|
|
${TAB}@echo " * "
|
|
|
|
${TAB}@touch \$@
|
|
|
|
CLEAN-OBJS += \$(if \$(found_devenv),,.nodevenv.once)
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
for sln_config in ${config_list}; do
|
|
|
|
local config=${sln_config%%|*}
|
|
|
|
local platform=${sln_config##*|}
|
|
|
|
local nows_sln_config=`echo $sln_config | sed -e 's/[^a-zA-Z0-9]/_/g'`
|
|
|
|
cat <<EOF
|
|
|
|
BUILD_TARGETS += \$(if \$(NO_LAUNCH_DEVENV),,$nows_sln_config)
|
|
|
|
clean::
|
|
|
|
${TAB}rm -rf "$platform"/"$config"
|
|
|
|
.PHONY: $nows_sln_config
|
|
|
|
ifneq (\$(found_devenv),)
|
|
|
|
ifeq (\$(CONFIG_VS_VERSION),7)
|
|
|
|
$nows_sln_config: $outfile
|
2013-04-06 04:30:15 +02:00
|
|
|
${TAB}\$(MSBUILD_TOOL) $outfile -build "$config"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
$nows_sln_config: $outfile
|
2013-04-06 04:30:15 +02:00
|
|
|
${TAB}\$(MSBUILD_TOOL) $outfile -m -t:Build \\
|
|
|
|
${TAB}${TAB}-p:Configuration="$config" -p:Platform="$platform"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
$nows_sln_config: $outfile .nodevenv.once
|
2013-04-06 04:30:15 +02:00
|
|
|
${TAB}@echo " * Skipping build of $sln_config (\$(MSBUILD_TOOL) not in path)."
|
2010-05-18 17:58:33 +02:00
|
|
|
${TAB}@echo " * "
|
|
|
|
endif
|
|
|
|
|
|
|
|
EOF
|
|
|
|
done
|
|
|
|
IFS=${IFS_bak}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Process command line
|
|
|
|
outfile=/dev/stdout
|
|
|
|
for opt in "$@"; do
|
|
|
|
optval="${opt#*=}"
|
|
|
|
case "$opt" in
|
|
|
|
--help|-h) show_help
|
|
|
|
;;
|
|
|
|
--out=*) outfile="${optval}"; mkoutfile="${optval}".mk
|
|
|
|
;;
|
|
|
|
--dep=*) eval "${optval%%:*}_deps=\"\${${optval%%:*}_deps} ${optval##*:}\""
|
|
|
|
;;
|
|
|
|
--ver=*) vs_ver="$optval"
|
|
|
|
case $optval in
|
2013-05-16 23:59:20 +02:00
|
|
|
[789]|10|11)
|
2010-05-18 17:58:33 +02:00
|
|
|
;;
|
|
|
|
*) die Unrecognized Visual Studio Version in $opt
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
--ver=*) vs_ver="$optval"
|
|
|
|
case $optval in
|
|
|
|
7) sln_vers="8.00"
|
|
|
|
sln_vers_str="Visual Studio .NET 2003"
|
|
|
|
;;
|
2010-07-22 19:34:25 +02:00
|
|
|
[89])
|
2010-05-18 17:58:33 +02:00
|
|
|
;;
|
|
|
|
*) die "Unrecognized Visual Studio Version '$optval' in $opt"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
--target=*) target="${optval}"
|
|
|
|
;;
|
|
|
|
-*) die_unknown $opt
|
|
|
|
;;
|
|
|
|
*) file_list[${#file_list[@]}]="$opt"
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
outfile=${outfile:-/dev/stdout}
|
|
|
|
mkoutfile=${mkoutfile:-/dev/stdout}
|
|
|
|
case "${vs_ver:-8}" in
|
|
|
|
7) sln_vers="8.00"
|
|
|
|
sln_vers_str="Visual Studio .NET 2003"
|
|
|
|
;;
|
|
|
|
8) sln_vers="9.00"
|
|
|
|
sln_vers_str="Visual Studio 2005"
|
|
|
|
;;
|
2010-07-22 19:34:25 +02:00
|
|
|
9) sln_vers="10.00"
|
|
|
|
sln_vers_str="Visual Studio 2008"
|
|
|
|
;;
|
2013-05-16 23:59:20 +02:00
|
|
|
10) sln_vers="11.00"
|
|
|
|
sln_vers_str="Visual Studio 2010"
|
|
|
|
;;
|
|
|
|
11) sln_vers="12.00"
|
|
|
|
sln_vers_str="Visual Studio 2012"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
case "${vs_ver:-8}" in
|
|
|
|
[789])
|
|
|
|
sfx=vcproj
|
|
|
|
;;
|
|
|
|
10|11)
|
|
|
|
sfx=vcxproj
|
|
|
|
;;
|
2010-05-18 17:58:33 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
for f in "${file_list[@]}"; do
|
|
|
|
parse_project $f
|
|
|
|
done
|
|
|
|
cat >${outfile} <<EOF
|
|
|
|
Microsoft Visual Studio Solution File, Format Version $sln_vers${EOLDOS}
|
|
|
|
# $sln_vers_str${EOLDOS}
|
|
|
|
EOF
|
|
|
|
for proj in ${proj_list}; do
|
|
|
|
process_project $proj >>${outfile}
|
|
|
|
done
|
|
|
|
process_global >>${outfile}
|
|
|
|
process_makefile >${mkoutfile}
|