@profoundlogic/codermake 2.0.8 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -315,6 +315,26 @@ $(SET_LIBL)
315
315
  system "runsqlstm srcstmf('$(call shell_escape_dollars,$<)') commit(*none) dftrdbcol($(TARGET_LIB))"
316
316
  endef
317
317
 
318
+ # Build SQL procedure as a service program.
319
+ # An SQL procedure whose source uses PROGRAM TYPE SUB is backed by a *SRVPGM.
320
+ # codermake only runs the SQL statement; IBM i creates the *SRVPGM and derives
321
+ # its object name from the routine (name it to match the target where practical).
322
+ define BUILD_SQLPROC_TO_SRVPGM
323
+ $(call SETUP_LOG,$(notdir $@))
324
+ $(SET_LIBL)
325
+ system "runsqlstm srcstmf('$(call shell_escape_dollars,$<)') commit(*none) dftrdbcol($(TARGET_LIB))"
326
+ endef
327
+
328
+ # Build SQL UDF (CREATE FUNCTION ... LANGUAGE SQL) as a service program.
329
+ # SQL UDFs are backed by *SRVPGM objects. codermake only runs the SQL statement;
330
+ # IBM i creates the *SRVPGM and derives its object name from the routine (name it
331
+ # to match the target where practical).
332
+ define BUILD_SQLUDF_TO_SRVPGM
333
+ $(call SETUP_LOG,$(notdir $@))
334
+ $(SET_LIBL)
335
+ system "runsqlstm srcstmf('$(call shell_escape_dollars,$<)') commit(*none) dftrdbcol($(TARGET_LIB))"
336
+ endef
337
+
318
338
  # Build message file from CL commands
319
339
  define BUILD_MSGF
320
340
  $(call SETUP_LOG,$(notdir $@))
@@ -439,6 +439,26 @@ $(call REMOTE_BUILD,$(filter-out build/%,$^),system "runsqlstm srcstmf('$(call s
439
439
  touch '$@'
440
440
  endef
441
441
 
442
+ # Build SQL procedure as a service program.
443
+ # An SQL procedure whose source uses PROGRAM TYPE SUB is backed by a *SRVPGM.
444
+ # codermake only runs the SQL statement; IBM i creates the *SRVPGM and derives
445
+ # its object name from the routine (name it to match the target where practical).
446
+ define BUILD_SQLPROC_TO_SRVPGM
447
+ $(call SETUP_LOG,$(notdir $@))
448
+ $(call REMOTE_BUILD,$(filter-out build/%,$^),system "runsqlstm srcstmf('$(call shell_escape_dollars,$<)') commit(*none) dftrdbcol($(TARGET_LIB))")
449
+ touch '$@'
450
+ endef
451
+
452
+ # Build SQL UDF (CREATE FUNCTION ... LANGUAGE SQL) as a service program.
453
+ # SQL UDFs are backed by *SRVPGM objects. codermake only runs the SQL statement;
454
+ # IBM i creates the *SRVPGM and derives its object name from the routine (name it
455
+ # to match the target where practical).
456
+ define BUILD_SQLUDF_TO_SRVPGM
457
+ $(call SETUP_LOG,$(notdir $@))
458
+ $(call REMOTE_BUILD,$(filter-out build/%,$^),system "runsqlstm srcstmf('$(call shell_escape_dollars,$<)') commit(*none) dftrdbcol($(TARGET_LIB))")
459
+ touch '$@'
460
+ endef
461
+
442
462
  # Build message file from CL commands
443
463
  define BUILD_MSGF
444
464
  $(call SETUP_LOG,$(notdir $@))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profoundlogic/codermake",
3
- "version": "2.0.8",
3
+ "version": "2.1.0",
4
4
  "description": "Make wrapper framework for IBM i development that simplifies build rules",
5
5
  "main": "dist/bin/index.js",
6
6
  "type": "module",
@@ -155,6 +155,8 @@ ENDPGMEXP
155
155
  | `.clle` | `.module` | Module (*MODULE) | `CRTCLMOD` |
156
156
  | `.clp` / `.cl` | `.pgm` | Program (*PGM) | `CRTCLPGM` |
157
157
  | `.proc.sql` | `.pgm` | SQL Procedure (*PGM) | `RUNSQLSTM` |
158
+ | `.proc.sql` | `.srvpgm` | SQL Procedure (*SRVPGM, `PROGRAM TYPE SUB`) | `RUNSQLSTM` |
159
+ | `.udf.sql` | `.srvpgm` | SQL Function (*SRVPGM, `LANGUAGE SQL`) | `RUNSQLSTM` |
158
160
  | `.module` (1+) | `.pgm` | Program (*PGM) | `CRTPGM` |
159
161
  | `.module` + `.exports` or `.bnd` | `.srvpgm` | Service Program (*SRVPGM) | `CRTSRVPGM EXPORT(*SRCFILE)` |
160
162
  | `.module` (no exports) | `.srvpgm` | Service Program (*SRVPGM) | `CRTSRVPGM EXPORT(*ALL)` |
@@ -98,7 +98,7 @@ CPD7344 30 Keyword REF not valid for this type of file.
98
98
 
99
99
  DDS errors typically reference a specific record format and line within the source.
100
100
 
101
- ## SQL DDL listings (.table.sql, .index.sql, .view.sql, .proc.sql)
101
+ ## SQL DDL listings (.table.sql, .index.sql, .view.sql, .proc.sql, .udf.sql)
102
102
 
103
103
  SQL DDL statements executed via `RUNSQLSTM` produce SQL messages:
104
104
 
@@ -110,6 +110,7 @@ SQL7905 10 Module *N in *N not found.
110
110
 
111
111
  - Severity 30+ means the statement failed.
112
112
  - Severity 20 warnings (like "already exists") may or may not be a problem depending on context.
113
+ - `.proc.sql` builds a `*PGM` (or a `*SRVPGM` with `PROGRAM TYPE SUB`) and `.udf.sql` builds a `*SRVPGM`; IBM i creates the object from the SQL routine, so the object name comes from the routine rather than the build target.
113
114
 
114
115
  ## Message files and binding directories (.msgf, .bnddir)
115
116
 
@@ -56,7 +56,7 @@ mypgm.pgm: mypgm.clp
56
56
 
57
57
  ### SQL procedure from .proc.sql
58
58
 
59
- Runs a SQL DDL script that creates a stored procedure. The resulting object appears as a program.
59
+ Runs a SQL DDL script that creates a stored procedure. With the default `PROGRAM TYPE MAIN`, the resulting object is a program (`*PGM`).
60
60
 
61
61
  ```makefile
62
62
  getcount.pgm: getcount.proc.sql
@@ -64,6 +64,8 @@ getcount.pgm: getcount.proc.sql
64
64
 
65
65
  **CL command:** `RUNSQLSTM SRCSTMF('src/getcount.proc.sql') COMMIT(*NONE) DFTRDBCOL(LIB)`
66
66
 
67
+ A `.proc.sql` whose routine uses `PROGRAM TYPE SUB`, and a `.udf.sql` SQL function, are backed by `*SRVPGM` objects instead — see [SQL service programs](#sql-service-programs-from-procsql--udfsql) under Service programs.
68
+
67
69
  ### Program from modules
68
70
 
69
71
  Links one or more compiled modules into a program. Prerequisites include `.module` targets, and optionally `.srvpgm` and `.bnddir` (normal or order-only) for automatic binding.
@@ -148,6 +150,22 @@ mysrvpgm.srvpgm: mymod.module mysrvpgm.exports dep.srvpgm
148
150
 
149
151
  This appends `BNDSRVPGM(DEP)` to the CRTSRVPGM command. `.bnddir` prerequisites (normal or order-only) append `BNDDIR(name)`.
150
152
 
153
+ ### SQL service programs from .proc.sql / .udf.sql
154
+
155
+ A service program can also be created from SQL source via `RUNSQLSTM`, with no modules or export list:
156
+
157
+ - **`.proc.sql` → `.srvpgm`** — `CREATE PROCEDURE ... LANGUAGE SQL PROGRAM TYPE SUB` is backed by a `*SRVPGM`.
158
+ - **`.udf.sql` → `.srvpgm`** — `CREATE FUNCTION ... LANGUAGE SQL` (SQL UDF) is backed by a `*SRVPGM`.
159
+
160
+ ```makefile
161
+ getcounts.srvpgm: getcounts.proc.sql employee.file # PROGRAM TYPE SUB
162
+ getname.srvpgm: getname.udf.sql employee.file # SQL UDF
163
+ ```
164
+
165
+ **CL command:** `RUNSQLSTM SRCSTMF('src/getcounts.proc.sql') COMMIT(*NONE) DFTRDBCOL(LIB)`
166
+
167
+ codermake only runs the SQL statement; IBM i creates the `*SRVPGM` and derives its object name from the SQL routine. Name the routine (and its `SPECIFIC` name where applicable) to match the build target so the generated object name lines up with the rule.
168
+
151
169
  ### .exports / .bnd file format
152
170
 
153
171
  The exports file (using either `.exports` or `.bnd` extension) is a plain text file with the following structure: