1#!/bin/bash
2#
3# Copyright 2017-2018, Haiku, Inc. All rights reserved.
4# Distributed under the terms of the MIT license.
5#
6
7if [ "$#" -lt 2 ]; then
8	echo "This script creates project files for Qt Creator to develop Haiku with."
9	echo "It should only be used on a per-project basis, as Qt Creator is too slow"
10	echo "when used on all of Haiku at once."
11	echo ""
12	echo "THIS SCRIPT *MUST* BE RUN FROM THE REPOSITORY ROOT."
13	echo ""
14	echo "Usage: <script> <project name> <path 1> <path 2> ..."
15	echo "e.g: create_project_file.sh Tracker src/kits/tracker/ src/apps/tracker/"
16	exit 1
17fi
18
19DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
20NAME=$1
21ROOTDIRS=${@:2}
22
23printf "// Add predefined macros for your project here. For example:\n// #define THE_ANSWER 42\n" \
24	>$DIR/$NAME.config
25printf "[General]\n" >$DIR/$NAME.creator
26
27# Clear the old file lists
28echo >$DIR/$NAME.files
29echo >$DIR/$NAME.includes
30
31# Build file lists
32for rootdir in $ROOTDIRS; do
33	find $rootdir -type f | sed "s@^@../../@" >>$DIR/$NAME.files
34	find $rootdir -type d | sed "s@^@../../@" >>$DIR/$NAME.includes
35done
36find headers -type d | sed "s@^@../../@" >>$DIR/$NAME.includes
37
38echo "Done. Project file: $DIR/$NAME.creator"
39