Skip to content

Commit

Permalink
feat: add runtime deprecation warnings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tueda committed Jan 28, 2025
1 parent 1d5e40b commit 33a8f45
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
pull_request:
workflow_dispatch:

env:
FORM_IGNORE_DEPRECATION: 1

jobs:
# Generate the tarball distribution, e.g., "form-v4.2.1.tar.gz" for v4.2.1.
# The tarball will be tested in the following "build-bin" job.
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
pull_request:
workflow_dispatch:

env:
FORM_IGNORE_DEPRECATION: 1

jobs:
# Simple tests on Linux; except the ParFORM case, they probably pass unless
# the committer has forgotten running "make check".
Expand Down
3 changes: 3 additions & 0 deletions sources/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ static void print_M()
MesPrint("%d", AM.ggShortStatsMax);
MesPrint("--MARK 11");
MesPrint("%d", AM.FromStdin);
MesPrint("%d", AM.IgnoreDeprecation);
MesPrint("%%%% END M_const");
/* fflush(0); */
}
Expand Down Expand Up @@ -1503,6 +1504,7 @@ int DoRecovery(int *moduletype)
R_COPY_S(AM.Path,UBYTE *);

R_SET(AM.FromStdin, BOOL);
R_SET(AM.IgnoreDeprecation, BOOL);

#ifdef PRINTDEBUG
print_M();
Expand Down Expand Up @@ -2574,6 +2576,7 @@ static int DoSnapshot(int moduletype)
S_WRITE_S(AM.Path);

S_WRITE_B(&AM.FromStdin,sizeof(BOOL));
S_WRITE_B(&AM.IgnoreDeprecation,sizeof(BOOL));

/*#] AM :*/
/*#[ AC :*/
Expand Down
4 changes: 4 additions & 0 deletions sources/compcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,8 @@ int CoOff(UBYTE *s)
AR.gzipCompress = 0;
}
else if ( StrICont(t,(UBYTE *)"checkpoint") == 0 ) {
// TODO: set issue number
PrintDeprecation("checkpoint mechanism", "issues/xxxxx4");
AC.CheckpointInterval = 0;
if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }
Expand Down Expand Up @@ -706,6 +708,8 @@ int CoOn(UBYTE *s)
}
}
else if ( StrICont(t,(UBYTE *)"checkpoint") == 0 ) {
// TODO: set issue number
PrintDeprecation("checkpoint mechanism", "issues/xxxxx4");
AC.CheckpointInterval = 0;
if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }
Expand Down
1 change: 1 addition & 0 deletions sources/declare.h
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ extern WORD Processor(VOID);
extern WORD Product(UWORD *,WORD *,WORD);
extern VOID PrtLong(UWORD *,WORD,UBYTE *);
extern VOID PrtTerms(VOID);
extern void PrintDeprecation(const char *,const char *);
extern VOID PrintRunningTime(VOID);
extern LONG GetRunningTime(VOID);
extern WORD PutBracket(PHEAD WORD *);
Expand Down
56 changes: 54 additions & 2 deletions sources/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ static void PrintHeader(int with_full_info)
AC.LineLength = oldLineLength;
}
}
// TODO: set issue numbers
#ifdef WINDOWS
PrintDeprecation("native Windows version", "issues/xxxxx1");
#endif
#ifdef ILP32
PrintDeprecation("32-bit version", "issues/xxxxx2");
#endif
#ifdef WITHMPI
PrintDeprecation("MPI version (ParFORM)", "issues/xxxxx3");
#endif
if ( AC.CheckpointFlag ) {
PrintDeprecation("checkpoint mechanism", "issues/xxxxx4");
}
}

/*
Expand Down Expand Up @@ -261,9 +274,17 @@ int DoTail(int argc, UBYTE **argv)
AM.FileOnlyFlag = 1; AM.LogType = 1; break;
case 'h': /* For old systems: wait for key before exit */
AM.HoldFlag = 1; break;
case 'i':
if ( StrCmp(s, (UBYTE *)"ignore-deprecation") == 0 ) {
AM.IgnoreDeprecation = 1;
break;
}
#ifdef WITHINTERACTION
case 'i': /* Interactive session (not used yet) */
AM.Interact = 1; break;
/* Interactive session (not used yet) */
AM.Interact = 1;
break;
#else
goto IllegalOption;
#endif
case 'I': /* Next arg is dir for inc/prc/sub files */
TAKEPATH(AM.IncDir) break;
Expand Down Expand Up @@ -426,6 +447,7 @@ printversion:;
}
}
else {
IllegalOption:
#ifdef WITHMPI
if ( PF.me == MASTER )
#endif
Expand Down Expand Up @@ -1890,6 +1912,36 @@ VOID Terminate(int errorcode)

/*
#] Terminate :
#[ PrintDeprecation :
*/

/**
* Prints a deprecation warning for a given feature.
*
* @param feature The name of the deprecated feature.
* @param issue The associated issue, e.g., "issues/700".
*/
void PrintDeprecation(const char *feature, const char *issue) {
#ifdef WITHMPI
if ( PF.me != MASTER ) return;
#endif
if ( AM.IgnoreDeprecation ) return;

UBYTE *e = (UBYTE *)getenv("FORM_IGNORE_DEPRECATION");
if ( e && e[0] && StrCmp(e, (UBYTE *)"0") && StrICmp(e, (UBYTE *)"false") && StrICmp(e, (UBYTE *)"no") ) return;

MesPrint("DeprecationWarning: We are considering deprecating the %s.", feature);
MesPrint("If you want this support to continue, leave a comment at:");
MesPrint("");
MesPrint(" https://github.com/vermaseren/form/%s", issue);
MesPrint("");
MesPrint("Otherwise, it will be discontinued in the future.");
MesPrint("To suppress this warning, use the -ignore-deprecation command line option or");
MesPrint("set the environment variable FORM_IGNORE_DEPRECATION=1.");
}

/*
#] PrintDeprecation :
#[ PrintRunningTime :
*/

Expand Down
3 changes: 2 additions & 1 deletion sources/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1600,11 +1600,12 @@ struct M_const {
WORD numpi;
WORD BracketFactors[8];
BOOL FromStdin; /* read the input from STDIN */
BOOL IgnoreDeprecation; /* ignore deprecation warning */
#ifdef WITHFLOAT
#ifdef WITHPTHREADS
PADPOSITION(17,30,62,84,(sizeof(pthread_rwlock_t)+sizeof(pthread_mutex_t)*2)+1);
#else
PADPOSITION(17,28,62,84,1);
PADPOSITION(17,28,62,84,2);
#endif
#else
#ifdef WITHPTHREADS
Expand Down

0 comments on commit 33a8f45

Please sign in to comment.