Skip to content

Commit 7b48c35

Browse files
committed
feat: add runtime deprecation warnings
FORM prints deprecation warnings at startup for native Windows, 32-bit (ILP32) and ParFORM (MPI) versions, as well as for the use of the checkpoint mechanism. This encourages users who need support for these deprecated features to leave a comment on the corresponding GitHub issues. The warnings can be suppressed by using the -ignore-deprecation command-line option or by setting the environment variable FORM_IGNORE_DEPRECATION=1.
1 parent 9bb422b commit 7b48c35

File tree

7 files changed

+67
-3
lines changed

7 files changed

+67
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
pull_request:
66
workflow_dispatch:
77

8+
env:
9+
FORM_IGNORE_DEPRECATION: 1
10+
811
jobs:
912
# Generate the tarball distribution, e.g., "form-v4.2.1.tar.gz" for v4.2.1.
1013
# The tarball will be tested in the following "build-bin" job.

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
pull_request:
66
workflow_dispatch:
77

8+
env:
9+
FORM_IGNORE_DEPRECATION: 1
10+
811
jobs:
912
# Simple tests on Linux; except the ParFORM case, they probably pass unless
1013
# the committer has forgotten running "make check".

sources/checkpoint.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ static void print_M()
840840
MesPrint("%d", AM.ggShortStatsMax);
841841
MesPrint("--MARK 11");
842842
MesPrint("%d", AM.FromStdin);
843+
MesPrint("%d", AM.IgnoreDeprecation);
843844
MesPrint("%%%% END M_const");
844845
/* fflush(0); */
845846
}
@@ -1503,6 +1504,7 @@ int DoRecovery(int *moduletype)
15031504
R_COPY_S(AM.Path,UBYTE *);
15041505

15051506
R_SET(AM.FromStdin, BOOL);
1507+
R_SET(AM.IgnoreDeprecation, BOOL);
15061508

15071509
#ifdef PRINTDEBUG
15081510
print_M();
@@ -2574,6 +2576,7 @@ static int DoSnapshot(int moduletype)
25742576
S_WRITE_S(AM.Path);
25752577

25762578
S_WRITE_B(&AM.FromStdin,sizeof(BOOL));
2579+
S_WRITE_B(&AM.IgnoreDeprecation,sizeof(BOOL));
25772580

25782581
/*#] AM :*/
25792582
/*#[ AC :*/

sources/compcomm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ int CoOff(UBYTE *s)
608608
AR.gzipCompress = 0;
609609
}
610610
else if ( StrICont(t,(UBYTE *)"checkpoint") == 0 ) {
611+
PrintDeprecation("the checkpoint mechanism", "issues/626");
611612
AC.CheckpointInterval = 0;
612613
if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
613614
if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }
@@ -706,6 +707,7 @@ int CoOn(UBYTE *s)
706707
}
707708
}
708709
else if ( StrICont(t,(UBYTE *)"checkpoint") == 0 ) {
710+
PrintDeprecation("the checkpoint mechanism", "issues/626");
709711
AC.CheckpointInterval = 0;
710712
if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
711713
if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }

sources/declare.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ extern WORD Processor(VOID);
672672
extern WORD Product(UWORD *,WORD *,WORD);
673673
extern VOID PrtLong(UWORD *,WORD,UBYTE *);
674674
extern VOID PrtTerms(VOID);
675+
extern void PrintDeprecation(const char *,const char *);
675676
extern VOID PrintRunningTime(VOID);
676677
extern LONG GetRunningTime(VOID);
677678
extern WORD PutBracket(PHEAD WORD *);

sources/startup.c

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,18 @@ static void PrintHeader(int with_full_info)
194194
AC.LineLength = oldLineLength;
195195
}
196196
}
197+
#ifdef WINDOWS
198+
PrintDeprecation("the native Windows version", "issues/623");
199+
#endif
200+
#ifdef ILP32
201+
PrintDeprecation("the 32-bit version", "issues/624");
202+
#endif
203+
#ifdef WITHMPI
204+
PrintDeprecation("the MPI version (ParFORM)", "issues/625");
205+
#endif
206+
if ( AC.CheckpointFlag ) {
207+
PrintDeprecation("the checkpoint mechanism", "issues/626");
208+
}
197209
}
198210

199211
/*
@@ -261,9 +273,17 @@ int DoTail(int argc, UBYTE **argv)
261273
AM.FileOnlyFlag = 1; AM.LogType = 1; break;
262274
case 'h': /* For old systems: wait for key before exit */
263275
AM.HoldFlag = 1; break;
276+
case 'i':
277+
if ( StrCmp(s, (UBYTE *)"ignore-deprecation") == 0 ) {
278+
AM.IgnoreDeprecation = 1;
279+
break;
280+
}
264281
#ifdef WITHINTERACTION
265-
case 'i': /* Interactive session (not used yet) */
266-
AM.Interact = 1; break;
282+
/* Interactive session (not used yet) */
283+
AM.Interact = 1;
284+
break;
285+
#else
286+
goto IllegalOption;
267287
#endif
268288
case 'I': /* Next arg is dir for inc/prc/sub files */
269289
TAKEPATH(AM.IncDir) break;
@@ -426,6 +446,7 @@ printversion:;
426446
}
427447
}
428448
else {
449+
IllegalOption:
429450
#ifdef WITHMPI
430451
if ( PF.me == MASTER )
431452
#endif
@@ -1890,6 +1911,36 @@ VOID Terminate(int errorcode)
18901911

18911912
/*
18921913
#] Terminate :
1914+
#[ PrintDeprecation :
1915+
*/
1916+
1917+
/**
1918+
* Prints a deprecation warning for a given feature.
1919+
*
1920+
* @param feature The name of the deprecated feature.
1921+
* @param issue The associated issue, e.g., "issues/700".
1922+
*/
1923+
void PrintDeprecation(const char *feature, const char *issue) {
1924+
#ifdef WITHMPI
1925+
if ( PF.me != MASTER ) return;
1926+
#endif
1927+
if ( AM.IgnoreDeprecation ) return;
1928+
1929+
UBYTE *e = (UBYTE *)getenv("FORM_IGNORE_DEPRECATION");
1930+
if ( e && e[0] && StrCmp(e, (UBYTE *)"0") && StrICmp(e, (UBYTE *)"false") && StrICmp(e, (UBYTE *)"no") ) return;
1931+
1932+
MesPrint("DeprecationWarning: We are considering deprecating %s.", feature);
1933+
MesPrint("If you want this support to continue, leave a comment at:");
1934+
MesPrint("");
1935+
MesPrint(" https://github.com/vermaseren/form/%s", issue);
1936+
MesPrint("");
1937+
MesPrint("Otherwise, it will be discontinued in the future.");
1938+
MesPrint("To suppress this warning, use the -ignore-deprecation command line option or");
1939+
MesPrint("set the environment variable FORM_IGNORE_DEPRECATION=1.");
1940+
}
1941+
1942+
/*
1943+
#] PrintDeprecation :
18931944
#[ PrintRunningTime :
18941945
*/
18951946

sources/structs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,11 +1600,12 @@ struct M_const {
16001600
WORD numpi;
16011601
WORD BracketFactors[8];
16021602
BOOL FromStdin; /* read the input from STDIN */
1603+
BOOL IgnoreDeprecation; /* ignore deprecation warning */
16031604
#ifdef WITHFLOAT
16041605
#ifdef WITHPTHREADS
16051606
PADPOSITION(17,30,62,84,(sizeof(pthread_rwlock_t)+sizeof(pthread_mutex_t)*2)+1);
16061607
#else
1607-
PADPOSITION(17,28,62,84,1);
1608+
PADPOSITION(17,28,62,84,2);
16081609
#endif
16091610
#else
16101611
#ifdef WITHPTHREADS

0 commit comments

Comments
 (0)