📄 one2all.sh
字号:
#! /bin/sh## $Id: one2all.sh,v 1000.0 2003/10/29 14:25:04 gouriano Exp $# ===========================================================================# # PUBLIC DOMAIN NOTICE# National Center for Biotechnology Information# # This software/database is a "United States Government Work" under the# terms of the United States Copyright Act. It was written as part of# the author's official duties as a United States Government employee and# thus cannot be copyrighted. This software/database is freely available# to the public for use. The National Library of Medicine and the U.S.# Government have not placed any restriction on its use or reproduction.# # Although all reasonable efforts have been taken to ensure the accuracy# and reliability of the software and data, the NLM and the U.S.# Government do not and cannot warrant the performance or results that# may be obtained by using this software or data. The NLM and the U.S.# Government disclaim all warranties, express or implied, including# warranties of performance, merchantability or fitness for any particular# purpose.# # Please cite the author in any work or product based on this material.# # ===========================================================================# # Author: Anton Lavrentiev# # MSVC project file converter. Expand a signle configuration project file# to multi-configuration project file.## ===========================================================================readfirstln() { cat $1 | while read p; do test -z "$p" && continue echo "$p" break done}config() { # Argument checking first. # if [ _$1 = _--without-dizzy ]; then dizzy='no' shift else dizzy='yes' fi if [ _$1 = _ -o \! -f $1 ]; then echo "ERROR: File \"$1\" inexistent. Stop." return 3 fi if [ _$2 != _Debug -a _$2 != _Release ]; then echo "ERROR: Unknown release parameter \"$2\". Stop." return 3 fi DEBUG=$2 if [ _$3 = _ ]; then CFG="/ML" elif [ $3 = MT ]; then CFG="/MT" elif [ $3 = DLL ]; then CFG="/MD" else echo "ERROR: Unknown configuration \"$3\". Stop." return 3 fi SFX="$3" # Our config is ${DEBUG}${SFX}. Compiler switch is ${CFG}. # if [ $DEBUG = Debug ]; then CFG="${CFG}d" fi # Init the sed script, which will make conversion. # cat /dev/null >/tmp/$$_cmd.sed # First replace config name wherever appropriate. # for p in Release Debug ; do for q in DLL MT ; do cat <<-EOF >>/tmp/$$_cmd.sed /^# PROP / !s|$p$q|$p|g /^# PROP .*"[^ ]*$p$q[^ ]*"/ s|$p$q|$p|g EOF done if [ $p != $DEBUG$SFX ]; then cat <<-EOF >>/tmp/$$_cmd.sed /^# PROP / !s|$p|$DEBUG$SFX|g /^# PROP .*"[^ ]*$p[^ ]*"/ s|$p|$DEBUG$SFX|g EOF fi done # Replace debugging macro. # if [ $DEBUG = Debug ]; then echo 's|NDEBUG|_DEBUG|g' >>/tmp/$$_cmd.sed else echo 's|_DEBUG|NDEBUG|g' >>/tmp/$$_cmd.sed fi # Does the project use wxWindows (or is a part of wxWindows)? # if [ `grep -c '^# ADD .*CPP .*__WXDEBUG__' $1` != 0 -o \ `grep -c '^# ADD .*CPP .*__WXMSW__' $1` != 0 -o \ `grep -c '^# ADD .*CPP .*WX.\\{2,3\\}INGDLL' $1` != 0 ]; then GUI="wxwin" # Flag proper macros for DLL mode. # if [ _$SFX = _DLL ]; then if [ `grep -c '^# ADD .*CPP .*/D *["]\\{0,1\\}WXMAKINGDLL=*[0-9]*["]\\{0,1\\}' $1` != 0 ]; then WXDLL='/D "WXMAKINGDLL=1"' else WXDLL='/D "WXUSINGDLL=1"' fi else WXDLL="" fi # Is this an FLTK-dependent project? # elif [ `grep -c '^# ADD .*LINK32 .*fltk[a-z]*[.]lib' $1` != 0 ]; then GUI="fltk" else GUI="" fi # Either replace with hooks, or just remove the compiler switches, # which may be configuration-dependent or inconsistent. # cat <<-EOF >>/tmp/$$_cmd.sed /^# ADD .*CPP / { s| */O[0-9A-Za-z]*| @O| s| */O[0-9A-Za-z]*||g s| */Gm||g s| */GZ||g s| */FR||g s| */Fr||g s| */c| @c| s| */c||g s| */ZI| @Z| s| */ZI||g s| */Zi| @Z| s| */Zi||g s| */Z7| @Z| s| */Z7||g s| */D *"\{0,1\}DEBUG=*[0-9]*"\{0,1\}| @D|g EOF # Remove some wxWindows macros, which are surely configuration-dependent. # if [ "$GUI" = "wxwin" ]; then cat <<-EOF >>/tmp/$$_cmd.sed s| */D *["]\\{0,1\\}__WXDEBUG__=*[0-9]*["]\\{0,1\\}||g s| */D *["]\\{0,1\\}WXUSINGDLL=*[0-9]*["]\\{0,1\\}||g s| */D *["]\\{0,1\\}WXMAKINGDLL=*[0-9]*["]\\{0,1\\}||g EOF fi # Clear the linker debug option. # cat <<-EOF >>/tmp/$$_cmd.sed } /^# ADD .*LINK32 / s| */debug||g EOF # When requested, remove include/library paths, which refer to DIZZY. # if [ "$dizzy" = "no" ]; then cat <<-EOF >>/tmp/$$_cmd.sed /^# ADD .*CPP / s| */I *["]\\{0,1\\}\\\\\\\\[Dd][Ii][Zz][Zz][Yy]\\\\[^ ]*||g /^# ADD .*RSC / s| */i *["]\\{0,1\\}\\\\\\\\[Dd][Ii][Zz][Zz][Yy]\\\\[^ ]*||g /^# ADD .*LINK32 / s| */libpath:["]\\{0,1\\}\\\\\\\\[Dd][Ii][Zz][Zz][Yy]\\\\[^ ]*||g EOF fi # Configuration-dependent changes: replace hooks and # add more compiler options where appropriate. # if [ $DEBUG = Debug ]; then cat <<-EOF >>/tmp/$$_cmd.sed /^# PROP / s| *Use_Debug_Libraries *0| Use_Debug_Libraries 1| /^# ADD .*LINK32 / { s| */pdb:[^ ]*||g s|/mach|/pdb:none /debug &| } /^# ADD .*CPP / { s|@O|/Od| s|@Z|/Z7| s| @Z||g s|/W[^ ]*|& /Gm| s|@c|/GZ /c| s|@D|/D "DEBUG=1"| s| @D||g EOF else cat <<-EOF >>/tmp/$$_cmd.sed /^# PROP / s| *Use_Debug_Libraries *1| Use_Debug_Libraries 0| /^# ADD .*LINK32 / s| */pdbtype[^ ]*||g /^# ADD .*CPP / { s|@O|/O2| s| @Z||g s|@c|/c| s| @D||g EOF fi # Now replace the code generation switch. # for p in "/MD" "/ML" "/MT" ; do cat <<-EOF >>/tmp/$$_cmd.sed s| *${p}d| $p|g s| $p| @C|g EOF done # Finish with code generation switch, and then make sure # that incremental linking is on except for wxWindows DLLs (slow). # cat <<-EOF >>/tmp/$$_cmd.sed t cfgrst :cfgrst s|@C|$CFG| t cfgokay s|/nologo|& $CFG| t cfgokay s| CPP|& $CFG| :cfgokay s| @C||g } /^# ADD .*LINK32 / s| */incremental[:yesno]*||g EOF if [ `grep -c '^# ADD .*LINK32 .*/dll' $1` = 0 ]; then INCRLNK='yes' elif [ -n "$GUI" -a `echo "$WXDLL" | grep -c '^# ADD .*CPP .*WXMAKINGDLL'` != 0 ]; then INCRLNK='no' else INCRLNK="" fi test "$INCRLNK" = "yes" -a $DEBUG != Debug && INCRLNK='no' if [ -n "$INCRLNK" ]; then echo "/^# ADD .*LINK32 / s|/nologo|& /incremental:$INCRLNK|" >>/tmp/$$_cmd.sed fi # wxWindows-specific changes from now on. # if [ "$GUI" = "wxwin" ]; then # Define __WXDEBUG__ for debug configs. # if [ $DEBUG = Debug ]; then WXDEBUG='/D "__WXDEBUG__=1"' else WXDEBUG="" fi # ${WX} is to be added to compiler options. # WX=`echo $WXDEBUG $WXDLL` if [ -n "$WX" ]; then cat <<-EOF >>/tmp/$$_cmd.sed /^# ADD .*CPP / { t reset :reset s|/Y|$WX &| t success s|/D|$WX &| t success s|/c|$WX &| t success s| *\$| $WX| :success } EOF fi # Enforce /subsystem:windows. # cat <<-EOF >>/tmp/$$_cmd.sed /^# ADD .*LINK32 / s|/subsystem:[A-Za-z]*|@s|g /^# ADD LINK32 / { t wxlrst :wxlrst s|@s|/subsystem:windows| t wxlcnt s|/nologo|& /subsystem:windows| t wxlcnt s|\$| /subsystem:windows| :wxlcnt } /^# ADD .*LINK32 / s| *@s||g EOF # Take care of libraries: remove all wxWindows ones # cat <<-EOF >>/tmp/$$_cmd.sed /^# ADD .*LINK32 .*wx[dl]\\{0,1\\}[.]lib/ { s/ *jpegd\\{0,1\\}[.]lib//g s/ *pngd\\{0,1\\}[.]lib//g s/ *tiffd\\{0,1\\}[.]lib//g s/ *xpmd\\{0,1\\}[.]lib//g s/ *zlibd\\{0,1\\}[.]lib//g s/ *wx[dl]\\{0,1\\}[.]lib/ @wx/g EOF # Insert them back but with correct names (which we use). # Note that in DLL mode only one (import) library has to be included. # The note above was true formely; now images libs are all static. # #if [ _$SFX != _DLL ]; then cat <<-EOF >>/tmp/$$_cmd.sed s/@wx/jpeg.lib png.lib tiff.lib zlib.lib wx.lib/ EOF #else # cat <<-EOF >>/tmp/$$_cmd.sed # s/@wx/wx.lib/ # EOF #fi cat <<-EOF >>/tmp/$$_cmd.sed s/ @wx//g } EOF fi # FLTK specific changes from now on # if [ "$GUI" = "fltk" ]; then # Enforce /subsystem:windows. # cat <<-EOF >>/tmp/$$_cmd.sed /^# ADD .*LINK32 / s|/subsystem:[A-Za-z]*|@s|g /^# ADD LINK32 / { t fllrst :fllrst s|@s|/subsystem:windows| t fllcnt s|/nologo|& /subsystem:windows| t fllcnt s|\$| /subsystem:windows| :fllcnt } /^# ADD .*LINK32 / s| *@s||g EOF # Take care of libraries: remove all FLTK ones # cat <<-EOF >>/tmp/$$_cmd.sed /^# ADD .*LINK32 * fltk[a-z]*[.]lib/ { s/ *fltk[a-z]*[.]lib/ @fltk/g EOF # Insert them back but with correct names (which we use). # Note that in DLL mode only one (import) library has to be included. # #if [ _$SFX != _DLL ]; then # cat <<-EOF >>/tmp/$$_cmd.sed # s/@fltk/fltkforms.lib fltkimages.lib fltkgl.lib fltk.lib/ # EOF #else cat <<-EOF >>/tmp/$$_cmd.sed s/@fltk/fltkdll.lib/ EOF #fi cat <<-EOF >>/tmp/$$_cmd.sed s/ @fltk//g } EOF fi # Print name of configuration, which was created, and run the script. # echo "${DEBUG}${SFX}" ${GUI:+"("$GUI")"} sed -f /tmp/$$_cmd.sed $1 >/tmp/$$_new cp -f /tmp/$$_new $1 rm -f /tmp/$$_cmd.sed /tmp/$$_new return 0}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -