-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildpgm.sh
More file actions
140 lines (126 loc) · 5.18 KB
/
buildpgm.sh
File metadata and controls
140 lines (126 loc) · 5.18 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/QOpenSys/usr/bin/sh
# ------------------------------------------------------------------------- #
# Program : buildpgm.sh
# Author : www.anandk.dev
# Date Written : 27th October 2020
# Inspired from : https://github.com/barrettotte/RPGLE-Twilio/blob/master/build.sh
# ------------------------------------------------------------------------- #
# This program reads current folder from IFS and takes below steps.
# 1. It assumes these sources i.e. dspf, rpgle, sqlrpgle, clle.
# 2. It copies .rpgle, .sqlrpgle, .clle and .dspf to respective _SRC.
# 3. It compiles the DSPF first, then RPGLE, SQLRPGLE and finally CLLE.
# After coping this program to IFS folder where your sources are, use below command
# to make this file executable.
# chmod +x buildpgm.sh
# Set the CUR_LIB to your library.
# Check if the SRCPFs are correct for you.
# Set the application name which will be applied to all the memebers.
# ------------------------------------------------------------------------- #
# Set the IFS directory, if not given, set current
IFS_DIR="${1:-$(pwd)}"
# Set the current library where the programs will be compiled.
CUR_LIB="ANANDK1"
# Set source physical files
DDS_SRC="QDDSSRC"
RPGLE_SRC="QRPGLESRC"
CL_SRC="QCLSRC"
# Set application name
APPLICATION="Weather Application"
# Execute the command by setting the library first
exec_cmd(){
echo $1
output=$(qsh -c "liblist -a $CUR_LIB ; system \"$1\"")
if [ -n "$2" ]; then
echo -e "$1\n\n$output" > "$IFS_DIR/$2.log"
fi
}
# Copy DSPF to source PF and compile
crt_dspf(){
echo -e '\n... executing commands... '
filename=$(basename "$1")
member="${filename%.*}"
exec_cmd "CHGATR OBJ('$1') ATR(*CCSID) VALUE(819)"
exec_cmd "CPYFRMSTMF FROMSTMF('$1') TOMBR('/QSYS.lib/$CUR_LIB.lib/$DDS_SRC.file/$member.mbr') MBROPT(*REPLACE)"
exec_cmd "CHGPFM FILE($CUR_LIB/$DDS_SRC) MBR($member) SRCTYPE(DSPF) TEXT('$APPLICATION')"
exec_cmd "CRTDSPF FILE($CUR_LIB/$member) SRCFILE($CUR_LIB/$DDS_SRC)" $member
}
# Copy RPGLE to SRCPF and compile
crt_rpgle(){
echo -e '\n... executing commands... '
filename=$(basename "$1")
member="${filename%.*}"
exec_cmd "CHGATR OBJ('$1') ATR(*CCSID) VALUE(819)"
exec_cmd "CPYFRMSTMF FROMSTMF('$1') TOMBR('/QSYS.lib/$CUR_LIB.lib/$RPGLE_SRC.file/$member.mbr') MBROPT(*REPLACE)"
exec_cmd "CHGPFM FILE($CUR_LIB/$RPGLE_SRC) MBR($member) SRCTYPE(RPGLE) TEXT('$APPLICATION')"
exec_cmd "CRTBNDRPG PGM($CUR_LIB/$member) DFTACTGRP(*NO) DBGVIEW(*SOURCE)" $member
}
# Copy SQLRPGLE to SRCPF and compile
crt_sqlrpgle(){
echo -e '\n... executing commands... '
filename=$(basename "$1")
member="${filename%.*}"
exec_cmd "CHGATR OBJ('$1') ATR(*CCSID) VALUE(819)"
exec_cmd "CPYFRMSTMF FROMSTMF('$1') TOMBR('/QSYS.lib/$CUR_LIB.lib/$RPGLE_SRC.file/$member.mbr') MBROPT(*REPLACE)"
exec_cmd "CHGPFM FILE($CUR_LIB/$RPGLE_SRC) MBR($member) SRCTYPE(SQLRPGLE) TEXT('$APPLICATION')"
exec_cmd "CRTSQLRPGI OBJ($CUR_LIB/$member) SRCFILE($CUR_LIB/$RPGLE_SRC) COMMIT(*NONE) DBGVIEW(*SOURCE)" $member
}
# Copy CLLE to SRCPF and compile
crt_clle(){
echo -e '\n... executing commands... '
filename=$(basename "$1")
member="${filename%.*}"
exec_cmd "CHGATR OBJ('$1') ATR(*CCSID) VALUE(819)"
exec_cmd "CPYFRMSTMF FROMSTMF('$1') TOMBR('/QSYS.lib/$CUR_LIB.lib/$CL_SRC.file/$member.mbr') MBROPT(*REPLACE)"
exec_cmd "CHGPFM FILE($CUR_LIB/$CL_SRC) MBR($member) SRCTYPE(CLLE) TEXT('$APPLICATION')"
exec_cmd "CRTBNDCL PGM($CUR_LIB/$member) SRCFILE($CUR_LIB/$CL_SRC) DFTACTGRP(*NO) ACTGRP(*CALLER) DBGVIEW(*SOURCE)" $member
}
search_dspf(){
for FILE in "$IFS_DIR"/*
do
ext="${FILE##*.}"
if [[ $ext == 'dspf' ]]; then
echo -e "\n=========== Building DSPF - $FILE ============="
crt_dspf $FILE
fi
done
}
search_rpgle(){
for FILE in "$IFS_DIR"/*
do
ext="${FILE##*.}"
if [[ $ext == 'rpgle' ]]; then
echo -e "\n=========== Building RPGLE - $FILE ============="
crt_rpgle $FILE
fi
done
}
search_sqlrpgle(){
for FILE in "$IFS_DIR"/*
do
ext="${FILE##*.}"
if [[ $ext == 'sqlrpgle' ]]; then
echo -e "\n=========== Building SQLRPGLE - $FILE ============="
crt_sqlrpgle $FILE
fi
done
}
search_clle(){
for FILE in "$IFS_DIR"/*
do
ext="${FILE##*.}"
if [[ $ext == 'clle' ]]; then
echo -e "\n=========== Building CLLE - $FILE ============="
crt_clle $FILE
fi
done
}
echo -e "|=== Starting to build the programs for $APPLICATION ===|"
search_dspf
search_rpgle
search_sqlrpgle
search_clle
echo -e '|=================================================================================|'
echo -e '| Program build completed, please check if you encountered any errors. |'
echo -e '| Check the log files created in the below folder. |'
echo -e "| $IFS_DIR |"
echo -e '|=================================================================================|'