Files
node/src/node_sea.h
T
Joyee Cheung bec9b5fccc src: use dedicated routine to compile function for builtin CJS loader
So that we can use it to handle code caching in a central place.

Drive-by: use per-isolate persistent strings for the parameters
and mark GetHostDefinedOptions() since it's only used in one
compilation unit

PR-URL: https://github.com/nodejs/node/pull/52016
Refs: https://github.com/nodejs/node/issues/47472
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2024-03-11 19:18:53 +00:00

58 lines
1.6 KiB
C++

#ifndef SRC_NODE_SEA_H_
#define SRC_NODE_SEA_H_
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#include <cinttypes>
#include <optional>
#include <string>
#include <string_view>
#include <tuple>
#include <unordered_map>
#include <vector>
#include "node_exit_code.h"
namespace node {
namespace sea {
// A special number that will appear at the beginning of the single executable
// preparation blobs ready to be injected into the binary. We use this to check
// that the data given to us are intended for building single executable
// applications.
const uint32_t kMagic = 0x143da20;
enum class SeaFlags : uint32_t {
kDefault = 0,
kDisableExperimentalSeaWarning = 1 << 0,
kUseSnapshot = 1 << 1,
kUseCodeCache = 1 << 2,
kIncludeAssets = 1 << 3,
};
struct SeaResource {
SeaFlags flags = SeaFlags::kDefault;
std::string_view code_path;
std::string_view main_code_or_snapshot;
std::optional<std::string_view> code_cache;
std::unordered_map<std::string_view, std::string_view> assets;
bool use_snapshot() const;
bool use_code_cache() const;
static constexpr size_t kHeaderSize = sizeof(kMagic) + sizeof(SeaFlags);
};
bool IsSingleExecutable();
SeaResource FindSingleExecutableResource();
std::tuple<int, char**> FixupArgsForSEA(int argc, char** argv);
node::ExitCode BuildSingleExecutableBlob(
const std::string& config_path,
const std::vector<std::string>& args,
const std::vector<std::string>& exec_args);
} // namespace sea
} // namespace node
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#endif // SRC_NODE_SEA_H_