-
Notifications
You must be signed in to change notification settings - Fork 0
/
prebuild.sh
executable file
·91 lines (82 loc) · 2.17 KB
/
prebuild.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
##
## Renderers
##
crails templates build \
-r html \
-i app/views \
-t Crails::HtmlTemplate \
-z crails/html_template.hpp \
-n BlogPluginHtmlRenderer \
-p \.html$ \
-v
crails templates build \
-r json \
-i app/views \
-t Crails::JsonTemplate \
-z crails/json_template.hpp \
-n BlogPluginJsonRenderer \
-p \.json$ \
-v
crails templates build \
-r rss \
-i app/views \
-t Crails::RssTemplate \
-z crails/rss_template.hpp \
-n BlogPluginRssRenderer \
-p \.rss$ \
-v
##
## JavaScript
##
npm install
node_modules/.bin/webpack
xxd -i -n blog_plugin_application_js lib/application.js lib/application.js.cpp
xxd -i -n blog_plugin_admin_js lib/admin.js lib/admin.js.cpp
exit 0
##
## Database
##
odb \
-I. -I../.. -I$CRAILS_CMS_INCLUDE_DIRS \
--std c++17 \
--default-pointer std::shared_ptr \
-d pgsql \
--table-prefix "blog_" \
--generate-schema --schema-format sql \
--generate-query \
--output-dir lib \
app/models/*.hpp
##
## Fix ODB include paths, and generate plugin-odb.hxx
##
plugin_odb_hxx="`pwd`/lib/plugin-odb.hxx"
cd app/models
if [ -f "$plugin_odb_hxx" ] ; then
rm "$plugin_odb_hxx"
fi
echo "#pragma once" >> "$plugin_odb_hxx"
echo "#include \"lib/odb/application-odb.hxx\"" >> "$plugin_odb_hxx"
for filename in `find . -name "*.h*"` ; do
filename=`echo "$filename" | cut -d/ -f2`
part=`echo "${filename%.*}"`
regex="s/$filename/app\\/models\\/$filename/g"
target="`pwd`/../../lib/$part-odb.hxx"
echo "#include \"$part-odb.hxx\"" >> "$plugin_odb_hxx"
# Fix include path for the model class
sed "$regex" "$target" > .tmp.txt
mv .tmp.txt "$target"
# Removes includes to odb files, unless these files were generated by the compiler
odb_includes=`grep "odb.hxx" "$target" | cut -d' ' -f2 | tr -d '"'`
for odb_include in $odb_includes ; do
if [ ! -f "`pwd`/../../lib/$odb_include" ] ; then
pattern=`echo "$odb_include" | sed -e 's/\//\\\\\//g'`
sed "/$pattern/d" "$target" > .tmp.txt
mv .tmp.txt "$target"
fi
done
# Replace these broken includes with an include to application-odb.hxx
sed '9 a#include "lib/odb/application-odb.hxx"' "$target" > .tmp.txt
mv .tmp.txt "$target"
done
cd -