mirror of https://github.com/CGAL/cgal
129 lines
3.6 KiB
Bash
Executable File
129 lines
3.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if [[ $C2VCPROJ_SCRIPT_DIR = "" ]] ; then
|
|
C2VCPROJ_SCRIPT_DIR="../../developer_scripts/examples"
|
|
echo "Setting C2VCPROJ_SCRIPT_DIR to $C2VCPROJ_SCRIPT_DIR"
|
|
else
|
|
echo "C2VCPROJ_SCRIPT_DIR already defined as $C2VCPROJ_SCRIPT_DIR"
|
|
fi
|
|
|
|
echo "Creating VC7.1 solution & project files..."
|
|
|
|
# Creates a VC7.1 .vcproj file corresponding to a source file
|
|
# $1 is the source file
|
|
# $2 is the extension of the source file
|
|
# $3 is the parent solution file
|
|
#
|
|
create_project_file()
|
|
{
|
|
srcfile=${1};
|
|
ext=${2};
|
|
slnfile=${3};
|
|
|
|
# $srcname is a string of the form "source" were "source.some_extension" is the of the source file
|
|
srcname=`echo $srcfile|sed -e "s/\.$ext//"`;
|
|
|
|
# $projfile is a filename of the form "source.vcproj" were "source" is the basename of the source file
|
|
projfile=`echo $srcfile|sed -e "s/\.$ext/\.vcproj/"`;
|
|
|
|
# Creates a vcroj IFF it doesn't exist
|
|
if [[ ! -e ./VC/$projfile ]]; then
|
|
|
|
GUID=`printf "%012d" $RANDOM`
|
|
|
|
echo "Creating $projfile under VC7.1 folder with GUID={00000000-0000-0000-0000-$GUID}"
|
|
|
|
#
|
|
# Takes a master .vcproj file, replaces the keywords
|
|
# SOURCE for $srcname
|
|
# EXT for $ext
|
|
# And moves the generated project file into the final folder
|
|
#
|
|
sed -e"s/SOURCE/$srcname/g" $C2VCPROJ_SCRIPT_DIR/master.vcproj > ./src2sln_/temp.txt;
|
|
sed -e"s/EXT/$ext/g" ./src2sln_/temp.txt > ./src2sln_/temp2.txt;
|
|
sed -e"s/ZZZZZZZZZZZZ/$GUID/g" ./src2sln_/temp2.txt > ./src2sln_/$projfile;
|
|
mv ./src2sln_/$projfile ./VC;
|
|
|
|
|
|
#
|
|
# Takes a master .sln entry line, replaces the keywords
|
|
# TARGET for $srcname
|
|
# PROJECT for $projfile
|
|
# And adds the line to parent solution file
|
|
#
|
|
echo "Adding $projfile to $slnfile"
|
|
sed -e"s/TARGET/$srcname/g" $C2VCPROJ_SCRIPT_DIR/master_proj_line.sln > ./src2sln_/temp.txt;
|
|
sed -e"s/ZZZZZZZZZZZZ/$GUID/g" ./src2sln_/temp.txt > ./src2sln_/temp2.txt;
|
|
sed -e"s,PROJECT,VC/$projfile,g" ./src2sln_/temp2.txt > ./src2sln_/temp3.txt;
|
|
|
|
mv ./src2sln_/$slnfile ./src2sln_/$slnfile.tmp
|
|
cat ./src2sln_/$slnfile.tmp ./src2sln_/temp3.txt > ./src2sln_/$slnfile
|
|
rm ./src2sln_/$slnfile.tmp
|
|
|
|
rm -rf ./src2sln_/temp.txt
|
|
rm -rf ./src2sln_/temp2.txt
|
|
rm -rf ./src2sln_/temp3.txt
|
|
fi
|
|
}
|
|
|
|
|
|
#
|
|
# Create a .vcproj Visual C++ makefile for each .C and .cpp file
|
|
# Usage: C2vcproj folder1 ...
|
|
#
|
|
|
|
# For each folder in parameters list
|
|
for h in $@ ; do
|
|
if [[ -d $h ]]; then
|
|
cd $h;
|
|
echo "In " $h;
|
|
|
|
# Creates a vcroj IFF it doesn't exist
|
|
if [[ ! -e "skip_vcproj_auto_generation" ]]; then
|
|
pkg=`basename $h`
|
|
|
|
# Create a VC subdirectory IFF it doesn't already exists
|
|
if [[ ! -e "VC" ]]; then
|
|
mkdir VC
|
|
fi
|
|
|
|
# ALWAYS create temporary subdirectory "src2sln_"
|
|
if [[ -e src2sln_ ]]; then
|
|
rm -r src2sln_;
|
|
fi
|
|
mkdir src2sln_;
|
|
|
|
# $sp is the filename of the solution for for VC71
|
|
sp=$pkg".sln"
|
|
|
|
|
|
echo "Creating $sp"
|
|
cat $C2VCPROJ_SCRIPT_DIR/master_head.sln > ./src2sln_/$sp
|
|
|
|
# For each .C and .cpp file file
|
|
for ext in C cpp ; do
|
|
for i in *.$ext ; do
|
|
if [[ ! $i = "*.$ext" ]]; then
|
|
# if $i contains a function "main()"
|
|
zgrep main $i >/dev/null 2>&1
|
|
if [[ $? == 0 ]]; then
|
|
|
|
create_project_file $i $ext $sp
|
|
|
|
fi
|
|
fi
|
|
done
|
|
done
|
|
|
|
mv ./src2sln_/$sp ./$sp;
|
|
|
|
# Remove temporary subdirectory "src2sln_"
|
|
rm -r src2sln_
|
|
else
|
|
echo " This folder already has solution and project files, skipping"
|
|
fi
|
|
|
|
cd ..;
|
|
fi
|
|
done
|