IBM / vscode-ibmi-projectexplorer

IBM i Project Explorer for VS Code
https://ibm.github.io/vscode-ibmi-projectexplorer/
Apache License 2.0
22 stars 7 forks source link

IBMi-bob custom build #578

Closed cosentino-smeup closed 1 month ago

cosentino-smeup commented 2 months ago

Hello, in our IBMi environment we execute a custom procedure to build programs.

It's a CLP program which execute some custom check on source files before to launch the real IBM build command.

Is it possible to override the build command with IBMi-bob or add a validation entry point where we can execute our custom operations and possibly cancel the build process in case the source code doesn't comply with our rules?

cosentino-smeup commented 2 months ago

Peeking at you repository, I saw the environment variable "precmd". Could it be my case?

edmundreinhardt commented 2 months ago

It is also possible to set up custom rules. i.e.

MYOBJ.PGM: myobj.pgm.rpgle "system -i MYCUSTOM STMF(myobj.pgm.rpgle)"

edmundreinhardt commented 2 months ago

See

TMPDETORD.FILE: DETORD.FILE
    cl "CPYF FROMFILE($(OBJLIB)/DETORD) TOFILE($(OBJLIB)/TMPDETORD) CRTFILE(*YES) MBROPT(*ADD)"

in https://github.com/IBM/bob-recursive-example/blob/master/QDDSSRC/Rules.mk for an example

cosentino-smeup commented 2 months ago

Hello, I tried this inside the "rules.mk" but it doesn't work:

COSANT1.PGM: cosant1.pgm.rpgle cl "CALL PGM(BOBMIN/B£UT24CL) PARM('CON' 'RPGLE' 'N' 'SRC       BOBMIN    ' 'COSANT1   ' '£UI_SRC   BOBMIN    ' 'COSANT1   ' 'COSANT1   BOBMIN    ' '*DFT    ' '*SOURCE')"
COSANT2.PGM: cosant2.pgm.rpgle cl "CALL PGM(BOBMIN/B£UT24CL) PARM('CON' 'RPGLE' 'N' 'SRC       BOBMIN    ' 'COSANT2   ' '£UI_SRC   BOBMIN    ' 'COSANT2   ' 'COSANT2   BOBMIN    ' '*DFT    ' '*SOURCE')"

I get this errors when I build the project:

 *  Executing task: IBM i: /QOpenSys/pkgs/bin/makei build 

Running Action: /QOpenSys/pkgs/bin/makei build (21:30:16)
Working directory: /SMEDOC/BOB/MINIMAL
Commands:
                /QOpenSys/pkgs/bin/makei build

> /QOpenSys/pkgs/bin/make -k BUILDVARSMKPATH="/tmp/tmpfhnw5o0t" -k BOB="/QOpenSys/pkgs/lib/bob" -f "/QOpenSys/pkgs/lib/bob/src/mk/Makefile" all
make: *** No rule to make target 'cl', needed by 'COSANT1.PGM'.
make: *** No rule to make target '"CALL', needed by 'COSANT1.PGM'.
make: *** No rule to make target 'PGM(BOBMIN/B£UT24CL)', needed by 'COSANT1.PGM'.
make: *** No rule to make target 'PARM('CON'', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''RPGLE'', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''N'', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''SRC', needed by 'COSANT1.PGM'.
make: *** No rule to make target 'BOBMIN', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''COSANT1', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''£UI_SRC', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''*DFT', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''*SOURCE')"', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''COSANT2', needed by 'COSANT2.PGM'.
make: Target 'all' not remade because of errors.
Objects:             0 failed 0 succeed 0 total
Build Completed!

Fetching errors from .evfevent.
Downloaded files as part of Action: .logs, .evfevent *  Executing task: IBM i: /QOpenSys/pkgs/bin/makei build 

Running Action: /QOpenSys/pkgs/bin/makei build (21:30:16)
Working directory: /SMEDOC/BOB/MINIMAL
Commands:
                /QOpenSys/pkgs/bin/makei build

> /QOpenSys/pkgs/bin/make -k BUILDVARSMKPATH="/tmp/tmpfhnw5o0t" -k BOB="/QOpenSys/pkgs/lib/bob" -f "/QOpenSys/pkgs/lib/bob/src/mk/Makefile" all
make: *** No rule to make target 'cl', needed by 'COSANT1.PGM'.
make: *** No rule to make target '"CALL', needed by 'COSANT1.PGM'.
make: *** No rule to make target 'PGM(BOBMIN/B£UT24CL)', needed by 'COSANT1.PGM'.
make: *** No rule to make target 'PARM('CON'', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''RPGLE'', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''N'', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''SRC', needed by 'COSANT1.PGM'.
make: *** No rule to make target 'BOBMIN', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''COSANT1', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''£UI_SRC', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''*DFT', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''*SOURCE')"', needed by 'COSANT1.PGM'.
make: *** No rule to make target ''COSANT2', needed by 'COSANT2.PGM'.
make: Target 'all' not remade because of errors.
Objects:             0 failed 0 succeed 0 total
Build Completed!

Fetching errors from .evfevent.
Downloaded files as part of Action: .logs, .evfevent
                                                     *  Terminal will be reused by tasks, press any key to close it. 

                                                     *  Terminal will be reused by tasks, press any key to close it. 
edmundreinhardt commented 2 months ago

@cosentino-smeup Be aware that the Rules.mk uses Makefile syntax https://opensource.com/article/18/8/what-how-makefile

and each rule is of the form:

target: prerequisites
<TAB> recipe

So in your case it is important that the cl ... line is on the following line and preceded by the tab character. As specified you are telling make that in order to build CONSANT1.PGM it first needs to build cl and it doesn't know how to do that.

Instead say:

COSANT1.PGM: cosant1.pgm.rpgle
    cl "CALL PGM(BOBMIN/B£UT24CL) PARM('CON' 'RPGLE' 'N' 'SRC       BOBMIN    ' 'COSANT1   ' '£UI_SRC   BOBMIN    ' 'COSANT1   ' 'COSANT1   BOBMIN    ' '*DFT    ' '*SOURCE')"

It is importnat that the character preceding 'cl' is a \t character