1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00
cde/src/cmd/builtin/features/pty
Martijn Dekker b6bd9815a4 **/Mamfile: Use IFFEFLAGS variable to add iffe flags like -d1
It was unreasonably hard to debug problems with iffe tests that
fail to compile where they should (particularly output{ ... }end
blocks that write esserntial headers).

In e72543a9 the problem was already somewhat mitigated by making
some of the failing output{ ... }end blocks emit #error directives
so that invalid/incomplete headers would cause an error at a
sensible point, and not a much harder to track error later.

This commit further mitigates the problem by making the Mamfiles
respect an IFFEFLAGS environmenet variable that is prefixed to
every iffe command's arguments. The typical use would be to export
IFFEFLAGS=-d1 to enable debug level 1: show compiler output for all
iffe tests. This now makes it reasonably feasible to detect
problems in the feature tests themselves.

src/**/Mamfile:
- Import IFFEFLAGS environment variable using setv.
- Prefix ${IFFEFLAGS} to every iffe command.

src/**/features/*:
- Amend the new fail error messages to recommend exporting
  IFFEFLAGS=-d1 to show the cause of the failure.

README.md, TODO:
- Updates.
2021-01-26 17:21:20 +00:00

63 lines
1.4 KiB
Text
Executable file

set prototyped
header sys/types.h
header pty.h
header libutil.h
header sys/pty.h
header sys/ptyio.h
header sys/vty.h
header sys/ioctl.h
header stropts.h
lib openpty,_getpty,ptsname -lutil
lib grantpt,unlockpt,posix_openpt stdlib.h
tst - output{
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#if _lib_ptsname && _npt_ptsname
_BEGIN_EXTERNS_
#if _STD_
extern char* ptsname(int);
#else
extern char* ptsname();
#endif
#endif
_END_EXTERNS_
int main()
{
int i;
struct stat statb;
static char* pty[] = { "/dev/ptyp0000", "/dev/ptym/ptyp0", "/dev/ptyp0" };
#if _lib_ptsname
int fd;
static char* ptc[] = { "/dev/ptmx", "/dev/ptc", "/dev/ptmx_bsd" };
for (i = 0; i < sizeof(ptc) / sizeof(ptc[0]); i++)
if((fd = open(ptc[i], 2))>=0)
{
if (ptsname(fd))
{
printf("#define _pty_clone\t\"%s\"\n", ptc[i]);
close(fd);
break;
}
close(fd);
}
#endif
for (i = 0;; i++)
if(i >= (sizeof(pty) / sizeof(pty[0]) - 1) || stat(pty[i], &statb)>=0)
{
printf("#define _pty_first\t\"%s\"\n", pty[i]);
break;
}
return 0;
}
}end fail{
echo '#error The output block in src/cmd/builtin/features/pty failed to compile. Rebuild with IFFEFLAGS=-d1 to debug.'
}end
extern _getpty char* (int*, int, mode_t, int)
extern openpty int (int*, int*, char*, struct termios*, struct winsize*)
extern ptsname char* (int)