mirror of https://git.wuffs.org/MWCC
448 lines
17 KiB
C
448 lines
17 KiB
C
#pragma once
|
|
|
|
#include "cw_common.h"
|
|
#include "pref_structs.h"
|
|
#include "option_system.h"
|
|
|
|
enum {
|
|
PRAGMA_FLAGS_0,
|
|
PRAGMA_FLAGS_1
|
|
};
|
|
enum {
|
|
PR_UNSET = 0, // this is the only one we know the name of (from asserts)
|
|
PR_ON = 1,
|
|
PR_OFF = 2,
|
|
PR_AUTO = 3,
|
|
PR_RESET = 4
|
|
};
|
|
|
|
typedef struct {
|
|
void *value;
|
|
const char *pragma;
|
|
int flags;
|
|
} Pragma; // assumed name
|
|
|
|
enum {
|
|
// "Option missing"
|
|
CLPStr1 = 1,
|
|
// "Command-line argument '%.15s...%.15s' is much too long, maximum accepted length is %d characters"
|
|
CLPStr2 = 2,
|
|
// "Parameter for '%s' missing"
|
|
CLPStr3 = 3,
|
|
// "Numeric constant '%s' overflowed 32-bit range"
|
|
CLPStr4 = 4,
|
|
// "Invalid %sconstant '%s'"
|
|
CLPStr5 = 5,
|
|
// "Numeric constant %lu is out of the legal range %lu - %lu"
|
|
CLPStr6 = 6,
|
|
// "Numeric constant %lu is out of the legal range %lu - %lu; clipping to %lu"
|
|
CLPStr7 = 7,
|
|
// "Four-char type '%s' is too long, expected maximum four characters"
|
|
CLPStr8 = 8,
|
|
// "String constant '%.16s...%.16s' too long, expected maximum %ld characters"
|
|
CLPStr9 = 9,
|
|
// "Identifier '%s' cannot start with a digit"
|
|
CLPStr10 = 10,
|
|
// "Identifier '%s' cannot contain the character '%c'"
|
|
CLPStr11 = 11,
|
|
// "Expected 'on' or 'off', but got '%s'"
|
|
CLPStr12 = 12,
|
|
// "Filename or directory '...%32s' is too long, expected maximum %ld characters"
|
|
CLPStr13 = 13,
|
|
// "Directory '...%32s' combined with filename '...%32s' is too long, maximum path is %ld characters"
|
|
CLPStr14 = 14,
|
|
// "File '%s' does not exist"
|
|
CLPStr15 = 15,
|
|
// "'%s' is a directory or volume, filename expected"
|
|
CLPStr16 = 16,
|
|
// "'%s' does not refer to a directory"
|
|
CLPStr17 = 17,
|
|
// "File path '%s' not accepted\n(%s)"
|
|
CLPStr18 = 18,
|
|
// "Unknown option '%s'"
|
|
CLPStr19_UnknownOptionX = 19,
|
|
// "Unknown option '%s'; expected one of '%s'"
|
|
CLPStr20_UnknownOptionX_ExpectedOneOfX = 20,
|
|
// "Option is obsolete"
|
|
CLPStr21_OptionObsolete = 21,
|
|
// "Option is obsolete; %s"
|
|
CLPStr22_OptionObsoleteWithHelp = 22,
|
|
// "Option '%s' substituted with %s"
|
|
CLPStr23_OptionXSubstitutedWithX = 23,
|
|
// "Option deprecated; accepted this time"
|
|
CLPStr24_OptionDeprecated = 24,
|
|
// "Option deprecated, accepted this time; use '%s' instead"
|
|
CLPStr25_OptionDeprecatedWithHelp = 25,
|
|
// "Option ignored"
|
|
CLPStr26_OptionIgnored = 26,
|
|
// "Option ignored;\n%s"
|
|
CLPStr27_OptionIgnoredWithText = 27,
|
|
// "%s"
|
|
CLPStr28_WarningText = 28,
|
|
// "Option has no effect on this target"
|
|
CLPStr29_OptionHasNoEffect = 29,
|
|
// "Option should not be specified multiple times"
|
|
CLPStr30_OptionShouldNotBeSpecifiedMultipleTimes = 30,
|
|
// "Option overrides the effect of '%s'; only one of '%s' should be specified"
|
|
CLPStr31_OptionOverridesEffect = 31,
|
|
// "Option overrides the effect of '%s'; only one of '%s' should be specified;\n%s"
|
|
CLPStr32_OptionOverridesEffectWithHelp = 32,
|
|
// "No default handler set up for '%s', ignoring"
|
|
CLPStr33_NoDefaultHandlerSetUpForX_Ignoring = 33,
|
|
// "Argument(s) expected"
|
|
CLPStr34_ArgumentsExpected = 34,
|
|
// "Token '%s' not expected"
|
|
CLPStr35_TokenXNotExpected = 35,
|
|
// "Unexpected additional argument '%s'"
|
|
CLPStr36_UnexpectedAdditionalArgumentX = 36,
|
|
// "Encountered extraneous arguments"
|
|
CLPStr37 = 37,
|
|
// "No help available for option '%s'"
|
|
CLPStr38_NoHelpAvailableForOptionX = 38,
|
|
// "Empty (zero-length) argument not accepted"
|
|
CLPStr39 = 39,
|
|
// "Variable name missing"
|
|
CLPStr40 = 40,
|
|
// "Only one output filename allowed; '%s' not accepted"
|
|
CLPStr41 = 41,
|
|
// "Output filenames found without source; '%s' not accepted"
|
|
CLPStr42 = 42,
|
|
// "Multiple outputs expected, output is ambiguous; '%s' not accepted"
|
|
CLPStr43 = 43,
|
|
// "Specified file '%s' not found"
|
|
CLPStr44 = 44,
|
|
// "Specified directory '%s' not found"
|
|
CLPStr45 = 45,
|
|
// "'%s' is a filename, not a directory; not accepted"
|
|
CLPStr46 = 46,
|
|
// "'%s' is a directory, not a filename; not accepted"
|
|
CLPStr47 = 47,
|
|
// "Library search found shared library '%s' instead of export library '%s.LIB'"
|
|
CLPStr48 = 48,
|
|
// "No library file found matching 'lib%s{%s}' or '%s'"
|
|
CLPStr49 = 49,
|
|
// "Redudant use of '%c%s%s'; linker always searches library paths;\ntypically one finds, e.g., libXXX.a with '%c%sXXX'"
|
|
CLPStr50 = 50,
|
|
// "Empty filename in library list ignored"
|
|
CLPStr51 = 51,
|
|
// "Environment variable '%s' not found"
|
|
CLPStr52 = 52,
|
|
// "In environment variable '%s':"
|
|
CLPStr53 = 53,
|
|
// "Option name expected for 'opt'"
|
|
CLPStr54 = 54,
|
|
// "Token '%s' ignored"
|
|
CLPStr55 = 55,
|
|
// "Token '%s[...%s]' was truncated to %d characters"
|
|
CLPStr56 = 56,
|
|
// "Expected %s, but got %s"
|
|
CLPStr57 = 57,
|
|
// "No output expected from this process, ignoring output name '%s'"
|
|
CLPStr58 = 58,
|
|
// "Only one output directory allowed, '%s' not accepted"
|
|
CLPStr59 = 59,
|
|
// "Storing browse info for '%s' in '%s'"
|
|
CLPStr60 = 60,
|
|
// "All linker output will be created in the same directory; ignoring path for '%s'"
|
|
CLPStr61 = 61,
|
|
// "Option overrides previously specified optimizations"
|
|
CLPStr62 = 62,
|
|
// "Could not initialize command line parser"
|
|
CLPStr63 = 63,
|
|
// "Output filename '%s' is invalid"
|
|
CLPStr64 = 64,
|
|
// "Truncated output filename '%s' to %d characters"
|
|
CLPStr65 = 65,
|
|
// "Output directory '%s' cannot be found"
|
|
CLPStr66 = 66,
|
|
// "Cannot add access path '%s'"
|
|
CLPStr67 = 67,
|
|
// "Cannot set preferences for '%s'"
|
|
CLPStr68 = 68,
|
|
// "Some of the files specified could not be found; build aborted"
|
|
CLPStr69 = 69,
|
|
// "Nothing to do: no source or object files specified"
|
|
CLPStr70 = 70,
|
|
// "Contents of %s:"
|
|
CLPStr71 = 71,
|
|
// "Overlays not supported on this target"
|
|
CLPStr72 = 72,
|
|
// "Segments not supported on this target"
|
|
CLPStr73 = 73,
|
|
// "Cannot open %s file '%s'"
|
|
CLPStr74 = 74,
|
|
// ""
|
|
CLPStr75 = 75,
|
|
// "The file \"%s\" may be ignored unless it has one of the following\nextensions: \"%s\""
|
|
CLPStr76 = 76,
|
|
// "Not using non-text file '%s' as optional argument"
|
|
CLPStr77 = 77,
|
|
// "Cannot redirect stream to '%s' (%s)"
|
|
CLPStr78 = 78
|
|
};
|
|
|
|
// State
|
|
|
|
typedef struct {
|
|
char *name;
|
|
void *ptr;
|
|
SInt32 size;
|
|
} PrefDataPanel; // assumed name
|
|
|
|
typedef struct {
|
|
OSType TYPE;
|
|
OSType LANG;
|
|
OSType CPU;
|
|
OSType OS;
|
|
int numPrefPanels;
|
|
char **prefPanels;
|
|
char *toolInfo;
|
|
char *copyright;
|
|
int numOptionLists;
|
|
OptionList **optionLists;
|
|
int numPrefDataPanels;
|
|
PrefDataPanel *prefDataPanels;
|
|
int (*PreParse)(void);
|
|
int (*MidParse)(void);
|
|
int (*PostParse)(void);
|
|
} ParserTool; // assumed name
|
|
|
|
typedef struct {
|
|
struct CWPluginPrivateContext *context;
|
|
char helpKey[64];
|
|
SInt32 helpFlags;
|
|
UInt16 ioCols;
|
|
UInt16 ioRows;
|
|
CWCommandLineArgs *args;
|
|
const ToolVersionInfo *toolVersion;
|
|
int numPlugins;
|
|
const CLPluginInfo *plugins;
|
|
int numPanels;
|
|
const char **panelNames;
|
|
OSType cpu;
|
|
OSType os;
|
|
char lastoutputname[256];
|
|
SInt32 currentSegment;
|
|
SInt32 currentOverlayGroup;
|
|
SInt32 currentOverlay;
|
|
int possibleFiles;
|
|
int userSpecifiedFiles;
|
|
int unusedFiles;
|
|
Boolean hadAnyOutput;
|
|
Boolean hadErrors;
|
|
Boolean showHelp;
|
|
Boolean underIDE;
|
|
Boolean alwaysUsePaths;
|
|
Boolean noOptions;
|
|
Boolean printedVersion;
|
|
Boolean passingArgs;
|
|
Boolean disToFile;
|
|
Boolean ppToFile;
|
|
Boolean initBefore;
|
|
Boolean weakImport;
|
|
Boolean mergeIntoOutput;
|
|
Boolean success;
|
|
Boolean ignoreUnknown;
|
|
UInt8 unused[2];
|
|
} ParseOptsType; // assumed name
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/********************************/
|
|
/* IO.c */
|
|
extern void ShowTextHandle(const char *description, Handle text);
|
|
extern void ShowVersion(Boolean decorate);
|
|
|
|
/********************************/
|
|
/* OptimizerHelpers.c */
|
|
extern Pragma irPragmas[];
|
|
|
|
extern int SetPragmaOptimizationsToUnspecified(const char *opt, void *, const char *, int);
|
|
extern int SetOptFlags(const char *opt, void *str, const char *, int flags);
|
|
extern int DisplayOptimizationOptions(const char *, void *, const char *, int);
|
|
|
|
/********************************/
|
|
/* ParserErrors.c */
|
|
extern void CLPReportError_V(const char *format, va_list ap);
|
|
extern void CLPReportWarning_V(const char *format, va_list ap);
|
|
extern void CLPReport_V(const char *format, va_list ap);
|
|
extern void CLPStatus_V(const char *format, va_list ap);
|
|
extern void CLPAlert_V(const char *format, va_list ap);
|
|
extern void CLPOSAlert_V(const char *format, SInt32 err, va_list ap);
|
|
extern char *CLPGetErrorString(SInt16 errid, char *buffer);
|
|
extern void CLPReportError(SInt16 errid, ...);
|
|
extern void CLPReportWarning(SInt16 errid, ...);
|
|
extern void CLPReport(SInt16 errid, ...);
|
|
extern void CLPAlert(SInt16 errid, ...);
|
|
extern void CLPOSAlert(SInt16 errid, SInt16 err, ...);
|
|
extern void CLPProgress(SInt16 errid, ...);
|
|
extern void CLPStatus(SInt16 errid, ...);
|
|
extern void CLPFatalError(const char *format, ...);
|
|
|
|
/********************************/
|
|
/* ParserFace.c */
|
|
extern const char *failedCallback;
|
|
extern jmp_buf exit_plugin;
|
|
extern ParseOptsType parseopts;
|
|
|
|
extern Handle Parser_FindPrefPanel(const char *name);
|
|
extern SInt32 Parser_StorePanels(struct CWPluginPrivateContext *context);
|
|
extern CWPLUGIN_ENTRY (CWParser_GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize);
|
|
extern CWPLUGIN_ENTRY (CWParser_GetDropInName)(const char **dropinName);
|
|
extern CWPLUGIN_ENTRY (CWParser_GetDisplayName)(const char **displayName);
|
|
extern CWPLUGIN_ENTRY (CWParser_GetPanelList)(const CWPanelList **panelList);
|
|
extern CWPLUGIN_ENTRY (CWParser_GetTargetList)(const CWTargetList **targetList);
|
|
extern CWPLUGIN_ENTRY (CWParser_GetVersionInfo)(const VersionInfo **versioninfo);
|
|
extern CWPLUGIN_ENTRY (Parser_SupportsPlugin)(const struct CLPluginInfo *pluginfo, OSType cpu, OSType os, Boolean *isSupported);
|
|
extern CWPLUGIN_ENTRY (Parser_SupportsPanels)(int numPanels, const char **panelNames, Boolean *isSupported);
|
|
extern CWPLUGIN_ENTRY (parser_main)(struct CWPluginPrivateContext *context);
|
|
|
|
/********************************/
|
|
/* ParserGlue-mach-ppc-c.c */
|
|
extern PCmdLine pCmdLine;
|
|
extern PCmdLineCompiler pCmdLineCompiler;
|
|
extern PCmdLineLinker pCmdLineLinker;
|
|
extern PFrontEndC pFrontEndC;
|
|
extern PWarningC pWarningC;
|
|
extern PGlobalOptimizer pGlobalOptimizer;
|
|
extern PBackEnd pBackEnd;
|
|
extern PDisassembler pDisassembler;
|
|
extern PMachOLinker pLinker;
|
|
extern PMachOProject pMachOProject;
|
|
extern PCLTExtras pCLTExtras;
|
|
|
|
/********************************/
|
|
/* ParserHelpers.c */
|
|
extern SInt16 lastStage;
|
|
extern Boolean dashIMinusMovesPaths;
|
|
extern Boolean usedDashIMinus;
|
|
extern Boolean namingSysPaths;
|
|
|
|
extern int FindFileInPath(const char *filename, OSSpec *fss);
|
|
extern char *GetEnvVar(const char *name, Boolean warn, const char **match);
|
|
extern int Opt_AddAccessPath(const char *opt, void *var, const char *arg, int flags);
|
|
extern int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg, int flags);
|
|
extern int Opt_AddFramework(const char *opt, void *var, const char *arg, int flags);
|
|
extern void ListParseMessage(void (*errprint)(const char *, va_list), const char *envvar, SInt16 id, ...);
|
|
extern int AddAccessPathList(const char *list, char sep1, char sep2, int source, char *text, Boolean system, SInt32 position, Boolean recursive);
|
|
extern int Opt_FindAndAddFile(const char *opt, void *var, const char *arg, int flags);
|
|
extern int Opt_FindAndAddFileRef(const char *opt, void *var, const char *arg);
|
|
extern int Opt_AddUnixLibraryFile(const char *opt, void *var, const char *arg);
|
|
extern int AddFileList(const char *list, char sep1, char sep2, int source, char *text, SInt32 position);
|
|
extern int IsFileInOutputDirectory(const OSSpec *file);
|
|
extern void GetCFileNameInOutputDirectory(const char *input, char *name, int maxlen);
|
|
extern void GetPFileNameInOutputDirectory(const char *input, unsigned char *name, int len);
|
|
extern void AddStringLenToHandle(Handle *h, const char *str, int len);
|
|
extern void AddStringToHandle(Handle *h, const char *str);
|
|
extern int Opt_PrintVersion(const char *opt, void *var, const char *arg, int flags);
|
|
extern void GetFirstSourceFilenameBase(char *buffer, char *defaul);
|
|
extern int Opt_SavePrefs(const char *opt, void *var, const char *arg, int flags);
|
|
extern int ParseNumber(const char *arg, Boolean emit_error, SInt32 *ret, const char **endptr);
|
|
extern int Opt_MaybeMoveAccessPaths(const char *opt, void *var, const char *arg, int flags);
|
|
|
|
/********************************/
|
|
/* ParserHelpers-cc.c */
|
|
extern Handle definesHandle;
|
|
|
|
extern int Opt_AddStringToDefines(const char *opt, void *str, const char *param, int flags);
|
|
extern int Opt_DefineSymbol(const char *var, const char *value);
|
|
extern int Opt_UndefineSymbol(const char *opt, void *, const char *arg, int flags);
|
|
extern int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename, int flags);
|
|
extern int Opt_PragmaTrueFalse(const char *, void *flag, const char *, int flags);
|
|
extern int Opt_PragmaFalseTrue(const char *, void *flag, const char *, int flags);
|
|
extern int Opt_PragmaOnOff(const char *, void *flag, const char *arg);
|
|
extern int Opt_PragmaOffOn(const char *, void *flag, const char *arg);
|
|
extern int SetupPragmas(const Pragma *pragmas);
|
|
|
|
/********************************/
|
|
/* Projects.c */
|
|
extern int GetFileCount(void);
|
|
extern void SetFileOutputName(SInt32 position, SInt16 which, char *outfilename);
|
|
extern int AddFileToProject(OSSpec *oss, SInt16 which, char *outfilename, Boolean exists, SInt32 position);
|
|
extern Boolean GetFileInfo(SInt32 position, OSSpec *spec, char *plugin);
|
|
extern int AddAccessPath(OSPathSpec *oss, SInt16 type, SInt32 position, Boolean recursive);
|
|
extern int MoveSystemPathsIntoUserList(void);
|
|
extern void AddVirtualFile(const char *filename, Handle *text);
|
|
extern void GetOutputFileDirectory(OSPathSpec *dir);
|
|
extern void SetOutputFileDirectory(OSPathSpec *dir);
|
|
extern void AddOverlayGroup(const char *name, CWAddr64 *addr, SInt32 *groupnum, SInt32 *overlaynum);
|
|
extern void AddOverlay(SInt32 groupnum, const char *name, SInt32 *overlaynum);
|
|
extern void AddSegment(const char *name, SInt16 attrs, SInt32 *segmentnum);
|
|
extern void ChangeSegment(SInt32 segmentnum, const char *name, SInt16 attrs);
|
|
extern int GetSegment(SInt32 segmentnum, char *name, SInt16 *attrs);
|
|
|
|
/********************************/
|
|
/* TargetOptimizer-ppc-mach.c */
|
|
extern char schedule_ppc_default;
|
|
|
|
extern int TargetSetOptFlags(short val, Boolean set);
|
|
extern void TargetDisplayOptimizationOptions(Handle txt);
|
|
extern void TargetSetPragmaOptimizationsToUnspecified(void);
|
|
|
|
/********************************/
|
|
/* TargetWarningHelpers-ppc-cc.c */
|
|
extern Pragma warningPragmas[];
|
|
|
|
extern int TargetSetWarningFlags(short val, Boolean set);
|
|
extern void TargetDisplayWarningOptions(Handle txt);
|
|
|
|
/********************************/
|
|
/* Targets.c */
|
|
extern ParserTool *pTool;
|
|
|
|
extern int SetParserToolInfo(ParserTool *tool);
|
|
extern Boolean ParserToolMatchesPlugin(OSType type, OSType lang, OSType cpu, OSType os);
|
|
extern Boolean ParserToolHandlesPanels(int numPanels, const char **panelNames);
|
|
extern Boolean SetupParserToolOptions(void);
|
|
|
|
/********************************/
|
|
/* ToolHelpers.c */
|
|
enum {
|
|
OutputOrdering0 = 0,
|
|
OutputOrdering1 = 1,
|
|
OutputOrdering2 = 2
|
|
};
|
|
extern char linkerOutputFilename[256];
|
|
extern Boolean setLinkerOutputFilename;
|
|
extern Boolean setOutputDirectory;
|
|
extern SInt16 outputOrdering;
|
|
|
|
extern int Opt_HandleOutputName(const char *opt, void *, const char *filename, int flags);
|
|
extern int ValidateToolState(Boolean mustHaveFiles);
|
|
extern void ToolReportMessage(SInt16 errid, SInt16 type, va_list va);
|
|
extern void ToolReportWarning(SInt16 id, ...);
|
|
extern void ToolReportError(SInt16 id, ...);
|
|
extern void ToolReportOSError(SInt16 id, int err, ...);
|
|
extern void ToolReportInfo(SInt16 id, ...);
|
|
extern int Opt_DoNotLink(const char *opt, void *var, const char *arg);
|
|
extern int Opt_IncreaseVerbosity(const char *opt, void *var, const char *arg, int flags);
|
|
extern int Opt_SetStage(const char *opt, void *str, const char *arg, int flags);
|
|
extern int Opt_RedirectStream(const char *opt, void *file, const char *filename);
|
|
|
|
/********************************/
|
|
/* ToolHelpers-cc.c */
|
|
extern int Opt_DummyLinkerRoutine(const char *opt, void *, const char *, int);
|
|
extern int Opt_DummyLinkerSettingRoutine(const char *var, const char *val);
|
|
extern void FinishCompilerTool(void);
|
|
|
|
/********************************/
|
|
/* Utils.c */
|
|
extern int my_tolower(char c);
|
|
extern int my_isdigit(char c);
|
|
extern int my_isalpha(char c);
|
|
extern int my_isalnum(char c);
|
|
extern int my_isxdigit(char c);
|
|
extern char *Utils_SpellList(char *list, char *buffer, char opts);
|
|
extern int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky);
|
|
|
|
/********************************/
|
|
/* WarningHelpers.c */
|
|
extern int SetWarningFlags(const char *opt, void *str, const char *, int flags);
|
|
extern int DisplayWarningOptions(const char *, void *, const char *, int);
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" }
|
|
#endif
|