Sun, 06 Jul 2014 20:46:53 +0300
- added make-example-wad.sh
10
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | #!/bin/bash |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | acsdata=$(tempfile) |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | libname=$(basename $acsdata |head -c8) |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | echo -n "wad name: " |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | read name_of_wad |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | if [ -z "$name_of_wad" ] |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | then |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | name_of_wad=$acsdata |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | fi |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | if [ $(echo -n $name_of_wad |tail -c4) = ".pk3" ] |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | then |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | name_of_wad="${name_of_wad}.pk3" |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | fi |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | echo "using $name_of_wad as example WAD name" |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | zipname="${HOME}/Desktop/$name_of_wad" |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | if [ -f "$zipname" ] |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | then |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | echo "$zipname already exists" >/dev/null |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | rm -v $acsdata |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | exit 1 |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | fi |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | vim $acsdata |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | if [ "$(wc -c $acsdata)" = "0" ] |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | then |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | echo "abort: no acs given" >/dev/null |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | fi |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | tmpdir=$(tempfile) |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | rm -f $tmpdir |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | mkdir $tmpdir |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | pushd $tmpdir |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | mkdir acs acs_src |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | echo "#include \"zcommon.acs\"" >>acs_src/scripts.acs |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | echo "#library \"$libname\"" >>acs_src/scripts.acs |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | cat ${acsdata} >>acs_src/scripts.acs |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | built=0 |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | while [ ! -f acs/${libname}.o ] |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | do |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | acc -I ${HOME}/doom/acs acs_src/scripts.acs acs/${libname}.o |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | if [ ! -f acs/${libname}.o ] |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | then |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | echo -n "failed to build, please re-check your source: " |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | read answer |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | vim acs_src/scripts.acs |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | fi |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | done |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | echo "${libname}" >loadacs.txt |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | zip -r9 ${zipname} * |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | popd |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | rm -rv $tmpdir |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | rm -v $acsdata |
f2eb2cd815e4
- added make-example-wad.sh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 |