// basBuild.h -- shared "emit .app resource set" step
//
// Both the DVX BASIC IDE (ideMain.c) and the standalone command-line
// compiler (bascomp.c) need to attach the same group of resources to
// an output .app file after writing the stub DXE.  This header exposes
// a single function that takes the metadata, bytecode, debug info and
// form texts and appends all resources in the canonical order.
//
// Callers are still responsible for:
//   - writing the stub to outPath before calling us
//   - copying the .hlp file next to outPath (if any)
//   - freeing any buffers they passed in via BasBuildSpecT
//
// Resource names use BAS_RES_* from basRes.h so both callers stay in
// sync automatically.

#ifndef BAS_BUILD_H
#define BAS_BUILD_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    // Basic metadata (any NULL/empty is skipped).
    const char *projName;
    const char *author;
    const char *publisher;
    const char *version;
    const char *copyright;
    const char *description;
    const char *helpFile;       // just the filename, not a path

    // Icon: either a file to load and embed, OR pre-loaded bytes.
    // If iconPath is set (non-NULL and non-empty) it is read from disk.
    // Otherwise iconData / iconSize are used (may themselves be NULL/0).
    const char *iconPath;
    const void *iconData;
    int32_t     iconSize;

    // Bytecode module and optional debug info.
    const void *moduleData;
    int32_t     moduleLen;
    const void *debugData;      // may be NULL
    int32_t     debugLen;

    // Forms: parallel arrays of formCount entries, each a text blob.
    // formData[i] points at formLens[i] bytes of (already stripped /
    // possibly obfuscated) form source to embed as resource FORMi.
    int32_t              formCount;
    const uint8_t *const *formData;
    const int32_t        *formLens;
} BasBuildSpecT;

// Append the full resource set to outPath.  Returns 0 on success, non-zero
// on failure.  The stub must already have been written to outPath.
int32_t basBuildEmitResources(const char *outPath, const BasBuildSpecT *spec);

#ifdef __cplusplus
}
#endif

#endif // BAS_BUILD_H
