File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ usage () {
4+ echo " Use case 1:"
5+ echo " ./scripts/mergeModels release"
6+ echo " "
7+ echo " Use case 2: merge all in single directory if it has swift files"
8+ echo " ./scripts/mergeModels codegen/sdk-codegen/build/smithyprojections/sdk-codegen/iam.2010-05-08/swift-codegen/IAM/models"
9+ }
10+
11+ if [ $# -ne 1 ]; then
12+ usage
13+ exit 1
14+ fi
15+
16+ RELDIR=$1
17+ if [ ! -d ${RELDIR} ]; then
18+ echo " Not a directory: ${RELDIR} "
19+ exit 1
20+ fi
21+
22+ MODELS=" Models.swift"
23+
24+ mergeFiles () {
25+ TEMP=` mktemp`
26+ cat * .swift | grep -e " //\ Code\ generated" | sort | uniq >> ${TEMP}
27+ cat * .swift | grep -e " ^import\ " | sort | uniq >> ${TEMP}
28+ cat * .swift | grep -ve " ^import\ " | grep -ve " //\ Code\ generated" >> ${TEMP}
29+ rm -f * .swift
30+ cat ${TEMP} | sed ' /^$/N;/^\n$/D' > ${MODELS}
31+ }
32+
33+ mergeFilesInReleaseDir () {
34+ for sdk in ` ls ${RELDIR} ` ; do
35+ MODELDIR=${RELDIR} /${sdk} /models
36+ if [ ! -d ${MODELDIR} ]; then
37+ echo " Bail, this directory does not seem right: ${MODELDIR} "
38+ exit 1
39+ fi
40+ pushd ${MODELDIR}
41+ if [ -f ${MODELS} ]; then
42+ echo " ${sdk} has ${MODELS} already generated"
43+ else
44+ mergeFiles
45+ fi
46+ popd
47+ done
48+ }
49+
50+ ls ${RELDIR} | grep -e " \.swift$" > /dev/null
51+ if [ $? -eq 0 ]; then
52+ pushd ${RELDIR}
53+ mergeFiles
54+ popd
55+ else
56+ mergeFilesInReleaseDir
57+ fi
You can’t perform that action at this time.
0 commit comments