# HG changeset patch # User adf88@interia.pl # Date 1498472757 -7200 # Mon Jun 26 12:25:57 2017 +0200 # Branch trunk # Node ID 46c0a06273dcdece8dbd2304a57dded3358cd07e # Parent 0d78b96563c56d72f798bf6767cf6ca5a2ac00c1 Add KDevelop 4 project generator. diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,7 @@ !/config.lib !*.in *.tmp + +.kdev4 +.kdev4/* +*.kdev4 diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -27,3 +27,7 @@ projects/*.vcxproj.user src/rev.cpp src/os/windows/ottdres.rc +.kdev4 +.kdev4/* +*.kdev4 + diff --git a/Makefile.in b/Makefile.in --- a/Makefile.in +++ b/Makefile.in @@ -86,6 +86,12 @@ @echo " bundle_bzip2 create the bzip2 installation bundle" @echo " bundle_lha create the lha installation bundle" @echo " bundle_dmg create the dmg installation bundle" + @echo "Other:" + @echo " kdev generate KDevelop 4 project files" + +kdev: + @echo "Generating KDevelop project files..." + @sh $(ROOT_DIR)/kdevelop/generate config.pwd: $(CONFIG_CACHE_PWD) $(MAKE) reconfigure diff --git a/kdevelop/.kdev4/openttd.kdev4.in b/kdevelop/.kdev4/openttd.kdev4.in new file mode 100644 --- /dev/null +++ b/kdevelop/.kdev4/openttd.kdev4.in @@ -0,0 +1,178 @@ +[CustomDefinesAndIncludes][ProjectPath0] +Defines=!!CUSTOM_DEFINES!! +Includes=!!CUSTOM_INCLUDES!! +Path=. + +[Defines And Includes][Compiler] +Name=GCC +Path=gcc +Type=GCC + +[Filters] +size=29 + +[Filters][0] +inclusive=0 +pattern=.* +targets=3 + +[Filters][1] +inclusive=0 +pattern=.git +targets=2 + +[Filters][10] +inclusive=0 +pattern=*.o +targets=1 + +[Filters][11] +inclusive=0 +pattern=*.a +targets=1 + +[Filters][12] +inclusive=0 +pattern=*.so +targets=1 + +[Filters][13] +inclusive=0 +pattern=*.so.* +targets=1 + +[Filters][14] +inclusive=0 +pattern=moc_*.cpp +targets=1 + +[Filters][15] +inclusive=0 +pattern=*.moc +targets=1 + +[Filters][16] +inclusive=0 +pattern=ui_*.h +targets=1 + +[Filters][17] +inclusive=0 +pattern=qrc_*.cpp +targets=1 + +[Filters][18] +inclusive=0 +pattern=*~ +targets=1 + +[Filters][19] +inclusive=0 +pattern=*.orig +targets=1 + +[Filters][2] +inclusive=0 +pattern=CVS +targets=2 + +[Filters][20] +inclusive=0 +pattern=.*.kate-swp +targets=1 + +[Filters][21] +inclusive=0 +pattern=.*.swp +targets=1 + +[Filters][22] +inclusive=0 +pattern=*.pyc +targets=1 + +[Filters][23] +inclusive=0 +pattern=*.pyo +targets=1 + +[Filters][24] +inclusive=0 +pattern=/objs +targets=2 + +[Filters][25] +inclusive=0 +pattern=*.rej +targets=1 + +[Filters][26] +inclusive=0 +pattern=*.orig +targets=1 + +[Filters][27] +inclusive=0 +pattern=*.porig +targets=1 + +[Filters][28] +inclusive=0 +pattern=*.ansi +targets=3 + +[Filters][3] +inclusive=0 +pattern=.svn +targets=2 + +[Filters][4] +inclusive=0 +pattern=_svn +targets=2 + +[Filters][5] +inclusive=0 +pattern=SCCS +targets=2 + +[Filters][6] +inclusive=0 +pattern=_darcs +targets=2 + +[Filters][7] +inclusive=0 +pattern=.hg +targets=2 + +[Filters][8] +inclusive=0 +pattern=.bzr +targets=2 + +[Filters][9] +inclusive=0 +pattern=__pycache__ +targets=2 + +[Launch] +Launch Configurations=Launch Configuration 0 + +[Launch][Launch Configuration 0] +Configured Launch Modes=execute +Configured Launchers=nativeAppLauncher +Name=Launch OpenTTD\s +Type=Native Application + +[Launch][Launch Configuration 0][Data] +Arguments=-d 1 +Dependencies=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x00) +Dependency Action=Nothing +EnvironmentGroup= +Executable=file://!!PROJECT_DIR!!/bin/openttd +External Terminal=konsole --noclose --workdir %workdir -e %exe +Project Target= +Use External Terminal=false +Working Directory=file://!!PROJECT_DIR!!/bin +isExecutable=true diff --git a/kdevelop/generate b/kdevelop/generate new file mode 100755 --- /dev/null +++ b/kdevelop/generate @@ -0,0 +1,115 @@ +#!/bin/sh + +# $Id$ + +# This file is part of OpenTTD. +# 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. +# 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. +# 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 . + +# echo without interpretation of backslash escapes and without +# adding newline at the end - just the string as it is +rawprint() +{ + printf '%s' "$@" +} + +encode_dword() +{ + printf '\x%02x' \ + `expr $1 / 16777216 % 256` \ + `expr $1 / 65536 % 256` \ + `expr $1 / 256 % 256` \ + `expr $1 % 256` +} + +encode_string() +{ + # turn string into UTF-16 and hexdump it + hex_utf16=`rawprint "$1" | iconv -t UTF-16BE | od -t x1 -A n | tr -d -c '[:xdigit:]'`; + + encode_dword `rawprint "$hex_utf16" | wc -m | xargs -I {} expr {} / 2` # length = num hex digits / 2 + rawprint "$hex_utf16" | sed 's/../\\x&/g' # put '\x' prefix before every pair of digits +} + +encode_single_define() +{ + encode_string `rawprint "$1" | grep -o '^[^=]*'` # everything before '=' + rawprint '\x00\x00\x00\n\x00' + encode_string `rawprint "$1" | sed 's/^[^=]*=\?//'` # everything after '=' +} + +# $1 - newline-separated list of defines +encode_defines() +{ + # add some fixed defines and discard empty lines from the tail + defines=`printf 'va_list\nva_args\n%s' "$1"` + + # count lines (no newline at the end so add one) + encode_dword `printf '%s\n' "$defines" | wc -l` + + while [ -n "$defines" ]; do + encode_single_define `rawprint "$defines" | head -n 1` + defines=`rawprint "$defines" | tail -n +2` + done +} + +encode_includes() +{ + encode_dword 3 # number of custom includes + encode_string "$1/src/stdafx.h" + encode_string "$1/objs/lang" + encode_string "$1/objs/setting" +} + +# escape with a backslash (\) characters special to the sed replace string: \ & +# also escape our custom filed separator that we will be using in sed: @ +escape_sed_special() +{ + sed -e 's/[\&@]/\\&/g' +} + + + +PROJECT_DIR=`pwd` +DIR_NAME=`pwd | xargs -0 basename` +IN_DIR=`readlink -f $0 | xargs -0 dirname` + +USAGE_TEXT='Usage: + + ./kdevelop/generate [PROJECT_NAME|-h|--help] + +PROJECT_NAME is the name of the project that will be displayed in KDevelop. +Before executing, cd into OpenTTD folder and run ./configure script. + +-h, --help + print help and exit' + +case "$# $1" in + '1 -h' | '1 --help') printf 'Generate OpenTTD project files for KDevelop 4.\n\n%s\n' "$USAGE_TEXT"; exit 0;; + 1*) PROJECT_NAME="$1";; + 0*) PROJECT_NAME="$DIR_NAME";; + *) printf 'Wrong arguments given. %s\n' "$USAGE_TEXT" >&2; exit 1;; +esac + +CFLAGS=`grep '^using CFLAGS\.\.\.' config.log 2>/dev/null` +if [ -z "$CFLAGS" ]; then + echo "OpenTTD config.log not found" >&2 + echo "cd into OpenTTD first and run 'configure'" >&2 + exit 1 +fi +DEFINES=`eval "printf '%s\n' $CFLAGS" | grep '^\-D' | cut -c3-` + +PROJECT_NAME_SED=s@!!PROJECT_NAME!!@`rawprint "$PROJECT_NAME" | escape_sed_special`@g +PROJECT_DIR_SED=s@!!PROJECT_DIR!!@`rawprint "$PROJECT_DIR" | escape_sed_special`@g +CUSTOM_DEFINES_SED=s@!!CUSTOM_DEFINES!!@`encode_defines "$DEFINES" | escape_sed_special`@g +CUSTOM_INCLUDES_SED=s@!!CUSTOM_INCLUDES!!@`encode_includes "$PROJECT_DIR" | escape_sed_special`@g + +mkdir -p .kdev4 + +sed -e "$PROJECT_NAME_SED" \ + "$IN_DIR/openttd.kdev4.in" >"$PROJECT_DIR/$DIR_NAME.kdev4" + +sed -e "$PROJECT_DIR_SED" -e "$CUSTOM_DEFINES_SED" -e "$CUSTOM_INCLUDES_SED" \ + "$IN_DIR/.kdev4/openttd.kdev4.in" >"$PROJECT_DIR/.kdev4/$DIR_NAME.kdev4" + diff --git a/kdevelop/openttd.kdev4.in b/kdevelop/openttd.kdev4.in new file mode 100644 --- /dev/null +++ b/kdevelop/openttd.kdev4.in @@ -0,0 +1,3 @@ +[Project] +Manager=KDevCustomMakeManager +Name=!!PROJECT_NAME!!