source: buildhelpers/code_generator@ 5b0a862

debian/bullseye
Last change on this file since 5b0a862 was 43fd35c, checked in by Joachim Langenbach <joachim.langenbach@…>, 7 years ago

Refactored code to have one gnuboat python structure

  • Property mode set to 100755
File size: 3.1 KB
Line 
1#!/bin/bash
2
3DIR=`dirname "$0"`
4SRC="${DIR}/../src/gnuboat"
5SRC_GEN="${DIR}/../src/gnuboat/"
6PACKAGE_NAME="mapservice"
7PACKAGE_NAME_GEN="gnuboat.${PACKAGE_NAME}"
8PACKAGE_VERSION="0.5.90"
9TARGET_TMP="${SRC_GEN}/${PACKAGE_NAME}_tmp/"
10#CELERY_WORKER_SCRIPT="${SRC_GEN}/celery_worker"
11
12echo "Cleaning directory"
13if [ -d "${SRC_GEN}/${PACKAGE_NAME}" ]; then
14 rm -R "${SRC_GEN}/${PACKAGE_NAME}"
15fi
16if [ -d "${TARGET_TMP}" ]; then
17 rm -R "${TARGET_TMP}"
18fi
19
20echo "Preparing symlinks"
21mkdir -p "${TARGET_TMP}"
22#cd "${TARGET}"
23#mkdir -p server_impl
24#cp -a ../../server_impl/* server_impl/
25
26#echo "Copying static files"
27#mkdir -p templates
28#cp -a ../../templates/* templates/
29
30echo "Generating backend and client API code"
31#cd ../../
32# backend
33${DIR}/codegen/openapi-generator-cli generate -i "${SRC}/mapservice.yaml" -g python-flask -t "${DIR}/codegen/templates/" --additional-properties=packageVersion=${PACKAGE_VERSION},packageName=${PACKAGE_NAME_GEN} -o "${TARGET_TMP}"
34mv "${TARGET_TMP}/gnuboat/${PACKAGE_NAME}" "${SRC_GEN}/${PACKAGE_NAME}"
35rm -R "${TARGET_TMP}"
36
37# running yapf
38echo "Formatting the generated code accoring to style file"
39yapf --style "python-style.yapf" -r -i "${SRC_GEN}/${PACKAGE_NAME}"
40
41# client
42#codegen/openapi-generator-cli generate -i openapi.yaml -g javascript -o src-gen/openapi_server/static/
43#rm -R src-gen/openapi_server/static/.openapi*
44
45# copying tests into auto generated test directory with test base class
46#cp -a tests/* src-gen/${PACKAGE_NAME}/test/
47
48########
49#
50# Adding additional files to src-gen directory
51#
52########
53# echo "#!/bin/bash" > "${CELERY_WORKER_SCRIPT}"
54# echo 'export FLASK_ENV="development"' >> "${CELERY_WORKER_SCRIPT}"
55# echo "celery -A ${PACKAGE_NAME}_impl.CeleryWorker:celery worker -l info -E -B" >> "${CELERY_WORKER_SCRIPT}"
56# chmod +x "${CELERY_WORKER_SCRIPT}"
57#
58# # bash script to install gnuboat_common from this repository before other dependencies
59# echo "#!/bin/bash" > "${TOX_INSTALL_COMMAND}"
60# echo 'pip install --editable=file:///`pwd`/../../common' >> "${TOX_INSTALL_COMMAND}"
61# echo 'pip install $@' >> "${TOX_INSTALL_COMMAND}"
62# chmod 0755 "${TOX_INSTALL_COMMAND}"
63# # create coverage configuration
64# COVERAGERC_FILE="${SRC_GEN}/.coveragerc"
65# echo "[run]" >> "${COVERAGERC_FILE}"
66# echo "branch = True" >> "${COVERAGERC_FILE}"
67# echo "omit = *test*" >> "${COVERAGERC_FILE}"
68#
69# # create MANIFEST.in to package openapi-spec and templates
70# echo "include gnuboat_mapservice/openapi/*.yaml" > "${SRC_GEN}/MANIFEST.in"
71# echo "graft gnuboat_mapservice/templates" >> "${SRC_GEN}/MANIFEST.in"
72# echo "global-exclude *.pyc" >> "${SRC_GEN}/MANIFEST.in"
73
74########
75#
76# Run tox tests and start mapservice
77#
78########
79# cd src-gen/
80# tox
81# echo "###########################"
82# echo "#"
83# echo "# Do not forget to start the celery worker with"
84# echo "# 1. start RabbitMQ broker with"
85# echo "# sudo service rabbitmq-server start"
86# echo "# 2. start result backend"
87# echo "# sudo service memcached start"
88# echo "# 3. start celery worker with"
89# echo "# cd ${SRC_GEN} && ${CELERY_WORKER_SCRIPT}"
90# echo "#"
91# echo "###########################"
92# export FLASK_ENV="development"
93# python3 -m ${PACKAGE_NAME}
Note: See TracBrowser for help on using the repository browser.