5 # This file is part of OpenTTD.
6 # OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
7 # OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8 # See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 # echo without interpretation of backslash escapes and without
11 # adding newline at the end - just the string as it is
20 `expr $1 / 16777216 % 256` \
21 `expr $1 / 65536 % 256` \
22 `expr $1 / 256 % 256` \
28 # turn string into UTF-16 and hexdump it
29 hex_utf16
=`rawprint "$1" | iconv -t UTF-16BE | od -t x1 -A n | tr -d -c '[:xdigit:]'`;
31 encode_dword
`rawprint "$hex_utf16" | wc -m | xargs -I {} expr {} / 2` # length = num hex digits / 2
32 rawprint
"$hex_utf16" |
sed 's/../\\x&/g' # put '\x' prefix before every pair of digits
35 encode_single_define
()
37 encode_string
`rawprint "$1" | grep -o '^[^=]*'` # everything before '='
38 rawprint
'\x00\x00\x00\n\x00'
39 encode_string
`rawprint "$1" | sed 's/^[^=]*=\?//'` # everything after '='
42 # $1 - newline-separated list of defines
45 # add some fixed defines and discard empty lines from the tail
46 defines
=`printf 'va_list\nva_args\n%s' "$1"`
48 # count lines (no newline at the end so add one)
49 encode_dword
`printf '%s\n' "$defines" | wc -l`
51 while [ -n "$defines" ]; do
52 encode_single_define
`rawprint "$defines" | head -n 1`
53 defines
=`rawprint "$defines" | tail -n +2`
59 encode_dword
3 # number of custom includes
60 encode_string
"$1/src/stdafx.h"
61 encode_string
"$1/objs/lang"
62 encode_string
"$1/objs/setting"
65 # escape with a backslash (\) characters special to the sed replace string: \ &
66 # also escape our custom filed separator that we will be using in sed: @
69 sed -e 's/[\&@]/\\&/g'
75 DIR_NAME
=`pwd | xargs -0 basename`
79 projects/gen-kdev4 [PROJECT_NAME|-h|--help]
81 PROJECT_NAME is the name of the project that will be displayed in KDevelop.
82 Before executing, cd into OpenTTD folder and run ./configure script.
88 '1 -h' |
'1 --help') printf 'Generate OpenTTD project files for KDevelop 4+\n\n%s\n' "$USAGE_TEXT"; exit 0;;
89 1*) PROJECT_NAME
="$1";;
90 0*) PROJECT_NAME
="$DIR_NAME";;
91 *) printf 'Wrong arguments given. %s\n' "$USAGE_TEXT" >&2; exit 1;;
94 CFLAGS
=`grep '^using CFLAGS\.\.\.' config.log 2>/dev/null`
95 if [ -z "$CFLAGS" ]; then
96 echo "OpenTTD config.log not found" >&2
97 echo "cd into OpenTTD first and run 'configure'" >&2
100 DEFINES
=`eval "printf '%s\n' $CFLAGS" | grep '^\-D' | cut -c3-`
102 PROJECT_NAME_SED
=s@
!!PROJECT_NAME
!!@
`rawprint "$PROJECT_NAME" | escape_sed_special`@g
103 PROJECT_DIR_SED
=s@
!!PROJECT_DIR
!!@
`rawprint "$PROJECT_DIR" | escape_sed_special`@g
104 CUSTOM_DEFINES_SED
=s@
!!CUSTOM_DEFINES
!!@
`encode_defines "$DEFINES" | escape_sed_special`@g
105 CUSTOM_INCLUDES_SED
=s@
!!CUSTOM_INCLUDES
!!@
`encode_includes "$PROJECT_DIR" | escape_sed_special`@g
109 sed -e "$PROJECT_NAME_SED" \
110 >"$PROJECT_DIR/$DIR_NAME.kdev4" \
113 Manager
=KDevCustomMakeManager
114 Name
=!!PROJECT_NAME
!!
117 sed -e "$PROJECT_DIR_SED" -e "$CUSTOM_DEFINES_SED" -e "$CUSTOM_INCLUDES_SED" \
118 >"$PROJECT_DIR/.kdev4/$DIR_NAME.kdev4" \
120 [CustomDefinesAndIncludes
][ProjectPath0
]
121 Defines
=!!CUSTOM_DEFINES
!!
122 Includes
=!!CUSTOM_INCLUDES
!!
125 [Defines And Includes
][Compiler
]
184 Launch Configurations
=Launch Configuration
0
186 [Launch
][Launch Configuration
0]
187 Configured Launch Modes
=execute
188 Configured Launchers
=nativeAppLauncher
189 Name
=Launch OpenTTD\s
190 Type
=Native Application
192 [Launch
][Launch Configuration
0][Data
]
194 Dependencies
=@Variant
(\x00\x00\x00\t\x00\x00\x00\x00\x00)
195 Dependency Action
=Nothing
197 Executable
=file://!!PROJECT_DIR
!!/bin
/openttd
198 External Terminal
=konsole
--noclose --workdir %workdir
-e %exe
200 Use External Terminal
=false
201 Working Directory
=file://!!PROJECT_DIR
!!/bin