IBM / ibmi-bob

A build system for creating IBM i-native objects using GNU Make.
https://ibm.github.io/ibmi-bob
Apache License 2.0
47 stars 20 forks source link

Build creating object in QGPL #318

Closed rogersonra closed 2 months ago

rogersonra commented 3 months ago

I was try to create an SQLRPGLE program on PUB400 and it program gets successfully created but in QGPL. I have tried to find the reason that curlib is being ignored but haven't been able to. Thanks for any help.

Here is my iproj.json

{
    "repository": "git@github.com:rogersonra/cmpf.git",
    "description": "Compare files for Regression testing",
    "includePath": [
      "qrpgleref"
    ],
    "version": "0.0.1",
    "build": {
      "curlib": "&rrogerson1",
      "tgtCcsid": "37"
   } 
}

And a portion of my actions.json

{
  "extensions": [
    "GLOBAL"
  ],
  "name": "Build current",
  "command": "OPT=*EVENTF BUILDLIB=&CURLIB /QOpenSys/pkgs/bin/makei compile -f &BASENAME",
  "environment": "pase",
  "deployFirst": true,
  "postDownload": [
    ".logs",
    ".evfevent"
  ]
}

And joblog.json

[
    {
        "cmd": "CRTSQLRPGI srcstmf('/home/RROGERSON/cmpf/qrpglesrc/PG5002R.PGM.SQLRPGLE') OBJ(QGPL/PG5002R) COMMIT(*NONE ) OBJTYPE(*PGM) OPTION(*EVENTF) OUTPUT(*PRINT) TEXT(' ') TGTRLS() DBGVIEW(*SOURCE) RPGPPOPT(*LVL2) COMPILEOPT('TGTCCSID(*JOB ) OPTIMIZE() INCDIR(''qrpgleref'')')",
        "cmd_time": "2024-06-10-01.10.33.00",
        "msgs": [
            {
                "msgid": "CPF1124",
                "type": "INFORMATIONAL",
                "severity": 0,
                "message_time": "2024-06-10-01.10.33.039610",
                "message_text": "Job 850541/QUSER/QP0ZSPWT started on 06/10/24 at 01:10:33 in subsystem QUSRWRK in QSYS. Job entered system on 06/10/24 at 01:10:33.",
                "second_level": null,
                "from_program": "QWTPIIPP",
                "from_library": "QSYS",
                "from_instruction": "04DC",
                "to_program": "*EXT",
                "to_library": null,
                "to_module": null,
                "to_procedure": null,
                "to_instruction": "*N"
            },
            {
                "msgid": "CPC2198",
                "type": "COMPLETION",
                "severity": 0,
                "message_time": "2024-06-10-01.10.33.273481",
                "message_text": "Current library changed to *CRTDFT.",
                "second_level": "&N Cause . . . . . :   The current library in the library list was changed to *CRTDFT.",
                "from_program": "QLICHLLE",
                "from_library": "QSYS",
                "from_instruction": "01A3",
                "to_program": "QP2USER2",
                "to_library": "QSYS",
                "to_module": "QP2API",
                "to_procedure": "runpase_common__FiPvT2",
                "to_instruction": "4"
            }
        ],
        "object": "PG5002R.PGM",
        "source": "/home/RROGERSON/cmpf/qrpglesrc/PG5002R.PGM.SQLRPGLE",
        "output": "/home/RROGERSON/cmpf/.logs/PG5002R.PGM.splf",
        "failed": false
    }
]

Thanks for any help
irfanshar commented 3 months ago

Hi @rogersonra, so I was able to reproduce your problem.

We recommend specifying your curlib, tgtccsid, etc. at the object level in your iproj.json. If there is no curlib or objlib attribute specified at this level, the behaviour is to build these objects in QGPL.

I suggest updating your iproj.json to the following:

{
    "repository": "git@github.com:rogersonra/cmpf.git",
    "description": "Compare files for Regression testing",
    "includePath": [
      "qrpgleref"
    ],
    "version": "0.0.1",
    "curlib": "&rrogerson1",
    "tgtCcsid": "37"
}

To learn more about how we have our iproj.json set up here's a link to the documentation https://ibm.github.io/ibmi-bob/#/prepare-the-project/iproj-json?id=tgtccsid.

If this solution doesn't work, please reach out again and I'd love to look into it in more depth with you. If it does, kindly close the issue, thank you.

edmundreinhardt commented 3 months ago

@rogersonra The iproj.json should have the curlib attribute.

{
    "repository": "git@github.com:rogersonra/cmpf.git",
    "description": "Compare files for Regression testing",
    "includePath": [
      "qrpgleref"
    ],
    "version": "0.0.1",
    "curlib": "&rrogerson1"
}

The build attribute is appropriate for a .ibmi.json file which you could use to override the library you want to build into for a particular subdirectory

edmundreinhardt commented 3 months ago

@rogersonra let me know if that resolves it for you

rogersonra commented 2 months ago

@edmundreinhardt @irfanshar

Sorry for the delay.

I added the following iproj.json to the qrpglesrc folder but the program is still built in QGPL

{
    "repository": "git@github.com:rogersonra/cmpf.git",
    "description": "Compare files for Regression testing",
    "includePath": [
      "qrpgleref"
    ],
    "version": "0.0.1",
    "build": {
      "objlib": "&rrogerson1",
      "curlib": "&rrogerson1",
      "tgtCcsid": "37"
   } 
}

I tried adding the "objlib" but that had no effect either.

irfanshar commented 2 months ago

@rogersonra

If you notice in the examples @edmundreinhardt and I provided, the "objlib" and "curlib" keys are at the object level for the iproj.json.

I believe updating your iproj.json to the following will resolve your issue

{
    "repository": "git@github.com:rogersonra/cmpf.git",
    "description": "Compare files for Regression testing",
    "includePath": [
      "qrpgleref"
    ],
    "version": "0.0.1",
    "objlib": "&rrogerson1",
    "curlib": "&rrogerson1"
}
edmundreinhardt commented 2 months ago

@rogersonra Robert, Irfan has given you the solution.
If you ever want to overwrite the target library for building objects or the CCSID for a particular subdirectory use a .ibmi.json. There is only one .iproj.json for the whole project and it is at the root of the project.

This is all documented here https://ibm.github.io/ibmi-bob/#/prepare-the-project/iproj-json https://ibm.github.io/ibmi-bob/#/prepare-the-project/ibmi-json

rogersonra commented 2 months ago

@edmundreinhardt @irfanshar

Sorry to be such a pain. Edmund's last post mentioned the .ibmi.json file at the folder level. So the way I understand it there is one iproj.jon per project and there may be one .ibmi.son per folder. So potentially multiple ibmi.json may exist if there are multiple folders. Just for clarity, If there are no ibmi.json files at the folder level then the iproj.json should be used. Correct?

So I added an .ibm.json to qrpglesrc (folder level).
image But it still builds PG5002R in QGPL.

I looked at the Output tab and selected Code for IBM i: PUB400 and everything looks good (as far as I can see) until the CRTSQLRPGI command is issued in the make

/home/RROGERSON/cmpf: export LOCALPATH="c:\Users\Robert\git\cmpf\qrpglesrc\pg5002r.pgm.sqlrpgle" && export RELATIVEPATH="qrpglesrc/pg5002r.
pgm.sqlrpgle" && export FULLPATH="/home/RROGERSON/cmpf/qrpglesrc/pg5002r.pgm.sqlrpgle" && export WORKDIR="/home/RROGERSON" && export 
FILEDIR="/home/RROGERSON/cmpf/qrpglesrc" && export BRANCHLIB="VSCBB9BD47" && export BRANCH="Initial-Compile" && export 
PARENT="qrpglesrc" && export BASENAME="pg5002r.pgm.sqlrpgle" && export NAMEL="pg5002r" && export NAME="pg5002r" && export 
EXTL="sqlrpgle" && export EXT="SQLRPGLE" && export BUILDLIB="RROGERSON1" && export CURLIB="RROGERSON1" && export USERNAME="rrogerson" && 
export HOST="pub400.com" && export HOME="/home/RROGERSON" && export LIBLS="GAMES400 QTEMP QGPL RROGERSON2 RROGERSON1" && OPT=*EVENTF 
BUILDLIB=RROGERSON1 /QOpenSys/pkgs/bin/makei compile -f pg5002r.pgm.sqlrpgle
{
    "code": 0,
    "signal": null,
    "stdout": "targets: PG5002R.PGM\n> /QOpenSys/pkgs/bin/make -k BUILDVARSMKPATH=\"/tmp/tmpgkpvs11z\" -k BOB=\"/QOpenSys/pkgs/lib/bob\" -f
\"/QOpenSys/pkgs/lib/bob/src/mk/Makefile\" PG5002R.PGM\n=== Create Bound SQLRPGLE Program [PG5002R] in QGPL\nCRTSQLRPGI srcstmf('/home/
RROGERSON/cmpf/qrpglesrc/PG5002R.PGM.SQLRPGLE') OBJ(QGPL/PG5002R) COMMIT(*NONE ) OBJTYPE(*PGM) OPTION(*EVENTF) OUTPUT(*PRINT) TEXT(' ')
TGTRLS() DBGVIEW(*SOURCE) RPGPPOPT(*LVL2) COMPILEOPT('TGTCCSID(37 ) OPTIMIZE() INCDIR(''qrpgleref'')')\n✓ PG5002R.PGM was created 
successfully!\n\nObjects:             0 failed 1 succeed 1 total\nBuild Completed!",
    "stderr": ""
}
edmundreinhardt commented 2 months ago

Yes there is only 1 iproj.json in the root of the project and if there is no .ibmi.json overriding its values, the curlib in the iproj.json is in effect.

So specifying curlib in the iproj.json is sufficient unless you want to the objects in a particular directory to be build in a different library (for databases for example).

So the .ibmi.json you specified was redundant and unnecessary but did no harm.

Looking at the log file, I see that you are building in QGPL while you really want to build in RROGERSON1

I did not see what you set the environment variable rrogerson1 to. Perhaps it would be simplest if you just set the 'curlib' to &CURLIB in iproj.json, and did not have an .ibmi.json

I.e.

{
    "repository": "git@github.com:rogersonra/cmpf.git",
    "description": "Compare files for Regression testing",
    "includePath": [
      "qrpgleref"
    ],
    "version": "0.0.1",
    "curlib": "&CURLIB"
}

This is simplest because if "objlib" is not specified, it will default to "curlib". By setting "curlib" to "&CURLIB" we are saying to take the current value of the "CURLIB" environment variable, which I can see is correctly set in your environment.

So in the iproj.json and .ibmil.json, if a value is preceded with a "&" it means to look up the value from an environment variable. This allows the same project to be used by different developers and during official builds etc.

edmundreinhardt commented 2 months ago

@rogersonra Alternatively you could also do

{
    "repository": "git@github.com:rogersonra/cmpf.git",
    "description": "Compare files for Regression testing",
    "includePath": [
      "qrpgleref"
    ],
    "version": "0.0.1",
    "curlib": "&BUILDLIB"
}

I highly recommend using the vscode-ibmi-projectexplorer extension because then you can see the library list and target libraries that BOB is using. It is specifically designed to support IFS build of IBM i objects and enables git as well. https://marketplace.visualstudio.com/items?itemName=IBM.vscode-ibmi-projectexplorer

I wonder if you are getting confused between Code for IBM i settings and the project explorer settings. This extension will help keep them all in sync.

rogersonra commented 2 months ago

@edmundreinhardt @irfanshar

Finally!!!

I don't know if you guys were trying to explain it to me and I could see the tree for the forest. It finally registered that both of you were showing methat "curlib" didn't belong inside build but I couldn't see it. I had the "curlib" inside "build" (see above). I don't know where I got the "build" from but that was the problem. My new iproj.json is:

{
    "repository": "git@github.com:rogersonra/cmpf.git",
    "description": "Compare files for Regression testing",
    "includePath": [
      "qrpgleref"
    ],
    "version": "0.0.1",
    "curlib": "&BUILDLIB"
}

and it works like a charm. Thanks for all the help.

Now I got that figured out I'll look at the project\explorer.

Thanks again

edmundreinhardt commented 2 months ago

Glad you figured it out