Skip to content

How to pass arguments to hermes/shermes? #1591

Answered by tmikov
guest271314 asked this question in Q&A
Discussion options

You must be logged in to vote

We will make this easier, but for now the recommended way to do this is to compile to a named SHUnit and manually link that unit into your own main app.

$ shermes -c --exported-unit=hello  hello.js
# This produced an object file, hello.o, exporting the unit by name
$ nm hello.o
...
0000000000000000 T _sh_export_hello
...

Example main app that filters and saves CLI args:

#include "hermes/VM/static_h.h"

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

void init_console_bindings(SHRuntime *shr);

SHUnit *sh_export_hello(void);

static int s_argc;
static char ** s_argv;

// Make the args available to the FFI.
int get_argc(void) { return s_argc; }
char ** get_argv(void) { return s_…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@guest271314
Comment options

@tmikov
Comment options

tmikov Jan 12, 2025
Collaborator

@guest271314
Comment options

@guest271314
Comment options

@guest271314
Comment options

Answer selected by tmikov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants