Skip to content

Commit

Permalink
prelim object builder
Browse files Browse the repository at this point in the history
  • Loading branch information
mainframed committed Apr 26, 2024
1 parent 99e7925 commit 1bc0d5c
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 0 deletions.
11 changes: 11 additions & 0 deletions build/01_asemble.nam
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
RXIKJ441 call_rxikj441
RXABEND call_rxabend
RXINIT call_rxinit
RXTERM call_rxterm
RXVSAM call_rxvsam
RXTSO call_rxtso
RXSVC call_rxsvc
RXCPUTIM cputime
RXCPCMD systemCP
RXSETJMP _setjmp_estae
RXECANC _setjmp_ecanc
135 changes: 135 additions & 0 deletions build/assemble.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import sys
import logging
from string import Formatter
from pathlib import Path
import socket

# This python script assembles the required objects for BREXX/370
logname = 'assemble.log'
logging.basicConfig(filename=logname,
filemode='w',
format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
datefmt='%H:%M:%S',
level=logging.DEBUG)

class assemble:

def __init__(self,system='MVSCE'):
self.system = system
logging.debug("Building")



def jobcard(self, jobname, title, jclass='A', msgclass='A',user='IBMUSER',password='SYS1'):
'''
This function generates the jobcard needed to submit the jobs
'''

if self.system != 'MVSCE':
user = 'HERC01'
password = 'CUL8TR'

with open('templates/jobcard.template', 'r') as template:
jobcard = template.read()

if jobcard[-1] != "\n":
jobcard += "\n"

return jobcard.format(
jobname=jobname.upper(),
title=title,
jclass=jclass,
msgclass=msgclass,
user=user,
password=password
)

def punch_out(self, jes_class='B'):
'''
This function returns the JCL to write &&OBJ to the punchcard writer
jes_class: The class that sends the output to the card writer, usually 'B'
'''
with open('templates/punchcard.template', 'r') as template:
punch_jcl = template.read()

return punch_jcl.format(jes_class=jes_class)

def brexx_maclib(self):
linklib = 'SYSC.LINKLIB'

if self.system != 'MVSCE':
linklib = 'SYS2.LINKLIB'


with open('templates/maclib.template', 'r') as template:
logging.debug("reading: templates/maclib.template")
maclib = template.read()

p = Path("../maclib").glob('**/*.hlasm')
files = [x for x in p if x.is_file()]
dd = ''
for macro in sorted(files):
dd += "./ ADD NAME=" +macro.stem + "\n"
with open(macro,'r') as mfile:
dd += mfile.read()
if dd[-1] != "\n":
dd += "\n"

return(maclib.format(steplib=linklib,maclibs=dd))

def RXMVSEXT_jcl(self):
'''
Generates the rxmvsext object file
'''

logging.debug("Building rxmvsext.obj")

with open('templates/rxmvsext.template', 'r') as template:
logging.debug("reading: templates/rxmvsext.template")
punch_jcl = template.read()

files = [i[1] for i in Formatter().parse(punch_jcl) if i[1] is not None]

fpath = "../asm/"
file_contents = {}
for fname in files:
hlasm_file = fpath + fname + ".hlasm"
logging.debug("reading:" + hlasm_file)
print("reading:",hlasm_file)
with open(hlasm_file, 'r') as infile:
hlasm = infile.read()

# if hlasm[-1] != "\n":
# hlasm += "\n"
file_contents[fname] = hlasm
rxmvsext_jcl = (self.jobcard("rxmvsext",'Builds RXMVSEXT obj') + self.brexx_maclib()
)
# +
#self.brexx_maclib() +
# punch_jcl.format(**file_contents) +
# self.punch_out()
#

print("*" * 100)
with open('test.jcl','w') as outf:
outf.write(rxmvsext_jcl)
self.submit(rxmvsext_jcl,host='192.168.0.102')

def submit(self,jcl, host='127.0.0.1',port=3505):
'''submits a job (in ASCII) to hercules listener'''

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

try:
# Connect to server and send data
sock.connect((host, port))
sock.send(jcl.encode())
finally:
sock.close()

go = assemble(system='MVSCE')
go.RXMVSEXT_jcl()



3 changes: 3 additions & 0 deletions build/templates/jobcard.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//{jobname} JOB (BREXX),'{title}',CLASS={jclass},MSGCLASS={msgclass},
// REGION=8M,MSGLEVEL=(1,1),USER={user},PASSWORD={password}
//********************************************************************
12 changes: 12 additions & 0 deletions build/templates/maclib.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//MACLIB EXEC PGM=PDSLOAD
//*
//* Either SYSC.LINKLIB for MVS/CE or SYS2.LINKLIB for TK4-/TK5
//*
//STEPLIB DD DSN={steplib},DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSUT2 DD DSN=&&MACLIB,DISP=(,PASS),
// UNIT=VIO,SPACE=(TRK,(44,14,17)),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=19040)
//SYSUT1 DD DATA,DLM=@@
{maclibs}
@@
8 changes: 8 additions & 0 deletions build/templates/punchcard.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//********************************************************************
//* Now to output the temp dataset &&OBJ to Class B which is the
//* punch out (pch00d.txt)
//PUNCHOUT EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSUT1 DD DSN=&&OBJ,DISP=SHR
//SYSUT2 DD SYSOUT={jes_class}
//SYSPRINT DD SYSOUT=*
84 changes: 84 additions & 0 deletions build/templates/rxmvsext.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//********************************************************************
//*
//* BUILDING BREXX INTERNAL ASSEMBLER MODULES
//*
//********************************************************************
//RXSVC EXEC ASMFC,PARM.ASM=(OBJ,NODECK),MAC1='SYS2.MACLIB',
// MAC2='SYS1.AMODGEN',MAC3=&&MACLIB
//ASM.SYSIN DD DATA,DLM=@@
{rxsvc}
@@
//ASM.SYSGO DD DSN=&&OBJ,DISP=(,PASS),SPACE=(TRK,3),UNIT=VIO,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=3200)
//********************************************************************
//RXABEND EXEC ASMFC,PARM.ASM=(OBJ,NODECK),MAC1='SYS2.MACLIB',
// MAC2='SYS1.AMODGEN',MAC3=&&MACLIB
//ASM.SYSIN DD DSN=BRXBLD.ASM.SRC(RXABEND),DISP=SHR
//ASM.SYSGO DD DSN=&&OBJ,DISP=(MOD,PASS)
//********************************************************************
//RXIKJ441 EXEC ASMFC,PARM.ASM=(OBJ,NODECK),MAC='SYS2.MACLIB',
// MAC1='SYS1.MACLIB',MAC2='SYS1.AMODGEN',
// MAC3=&&MACLIB
//ASM.SYSIN DD DATA,DLM=@@
{rxikj441}
@@
//ASM.SYSGO DD DSN=&&OBJ,DISP=(MOD,PASS)
//********************************************************************
//RXINIT EXEC ASMFC,PARM.ASM=(OBJ,NODECK)
//ASM.SYSLIB DD DSN=SYS2.MACLIB,DISP=SHR
// DD DSN=SYS1.MACLIB,DISP=SHR
// DD DSN=SYS1.AMODGEN,DISP=SHR
// DD DSN=SYS1.APVTMACS,DISP=SHR
// DD DSN=BRXBLD.ASM.MACLIB,DISP=SHR
//ASM.SYSIN DD DATA,DLM=@@
{rxinit}
@@
//ASM.SYSGO DD DSN=&&OBJ,DISP=(MOD,PASS)
//********************************************************************
//RXTERM EXEC ASMFC,PARM.ASM=(OBJ,NODECK),MAC='SYS2.MACLIB',
// MAC1='SYS1.MACLIB',MAC2='SYS1.AMODGEN',
// MAC3=&&MACLIB
//ASM.SYSIN DD DATA,DLM=@@
{rxterm}
@@
//ASM.SYSGO DD DSN=&&OBJ,DISP=(MOD,PASS)
//********************************************************************
//RXTSO EXEC ASMFC,PARM.ASM=(OBJ,NODECK),MAC='SYS2.MACLIB',
// MAC1='SYS1.MACLIB',MAC2='SYS1.AMODGEN',
// MAC3=&&MACLIB
//ASM.SYSIN DD DATA,DLM=@@
{rxtso}
@@
//ASM.SYSGO DD DSN=&&OBJ,DISP=(MOD,PASS)
//********************************************************************
//RXVSAM EXEC ASMFC,PARM.ASM=(OBJ,NODECK),MAC='SYS2.MACLIB',
// MAC1='SYS1.MACLIB',MAC2='SYS1.AMODGEN',
// MAC3=&&MACLIB
//ASM.SYSIN DD DATA,DLM=@@
{rxvsam}
@@
//ASM.SYSGO DD DSN=&&OBJ,DISP=(MOD,PASS)
//********************************************************************
//RXCPUTIM EXEC ASMFC,PARM.ASM=(OBJ,NODECK),MAC='SYS2.MACLIB',
// MAC1='SYS1.MACLIB',MAC2='SYS1.AMODGEN',
// MAC3=&&MACLIB
//ASM.SYSIN DD DATA,DLM=@@
{rxcputim}
@@
//ASM.SYSGO DD DSN=&&OBJ,DISP=(MOD,PASS)
//********************************************************************
//RXCPCMD EXEC ASMFC,PARM.ASM=(OBJ,NODECK),MAC='SYS2.MACLIB',
// MAC1='SYS1.MACLIB',MAC2='SYS1.AMODGEN',
// MAC3=&&MACLIB
//ASM.SYSIN DD DATA,DLM=@@
{rxcpcmd}
@@
//ASM.SYSGO DD DSN=&&OBJ,DISP=(MOD,PASS)
//********************************************************************
//RXESTAE EXEC ASMFC,PARM.ASM=(OBJ,NODECK),MAC='SYS2.MACLIB',
// MAC1='SYS1.MACLIB',MAC2='SYS1.AMODGEN',
// MAC3=&&MACLIB
//ASM.SYSIN DD DATA,DLM=@@
{rxestae}
@@
//ASM.SYSGO DD DSN=&&OBJ,DISP=(MOD,PASS)

0 comments on commit 1bc0d5c

Please sign in to comment.