Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bare.simulator #33

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ The identifier of the operating system for which Bare was compiled. The possible

The identifier of the processor architecture for which Bare was compiled. The possible values are `arm`, `arm64`, `ia32`, and `x64`.

#### `Bare.simulator`

Whether or not Bare was compiled for a simulator.

#### `Bare.argv`

The command line arguments passed to the process when launched.
Expand Down
20 changes: 18 additions & 2 deletions include/bare/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#if TARGET_OS_IOS
#define BARE_PLATFORM "ios"
#define BARE_PLATFORM_IOS
#else
#elif TARGET_OS_MAC
#define BARE_PLATFORM "darwin"
#define BARE_PLATFORM_DARWIN
#else
#error Unsupported platform
#endif
#elif defined(__linux__)
#if defined(__ANDROID__)
Expand Down Expand Up @@ -41,6 +43,20 @@
#error Unsupported architecture
#endif

#define BARE_TARGET BARE_PLATFORM "-" BARE_ARCH
#if defined(__APPLE__)
#define BARE_SIMULATOR TARGET_OS_SIMULATOR
#else
#define BARE_SIMULATOR 0
#endif

#define BARE_TARGET_SYSTEM BARE_PLATFORM "-" BARE_ARCH

#if BARE_SIMULATOR
#define BARE_TARGET_SIMULATOR "-simulator"
#else
#define BARE_TARGET_SIMULATOR
#endif

#define BARE_TARGET BARE_TARGET_SYSTEM BARE_TARGET_SIMULATOR

#endif // BARE_TARGET_H
2 changes: 1 addition & 1 deletion src/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Addon = module.exports = exports = class Addon {
}

static get host () {
return `${bare.platform}-${bare.arch}`
return `${bare.platform}-${bare.arch}${bare.simulator ? '-simulator' : ''}`
}

static load (url) {
Expand Down
5 changes: 5 additions & 0 deletions src/bare.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class Bare extends EventEmitter {
return bare.arch
}

get simulator () {
return bare.simulator
}

get argv () {
return bare.argv
}
Expand Down Expand Up @@ -195,6 +199,7 @@ class Bare extends EventEmitter {

platform: this.platform,
arch: this.arch,
simulator: this.simulator,
argv: this.argv,
pid: this.pid,
exitCode: this.exitCode,
Expand Down
7 changes: 7 additions & 0 deletions src/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,13 @@ bare_runtime_setup (uv_loop_t *loop, bare_process_t *process, bare_runtime_t *ru
V("arch", BARE_ARCH);
#undef V

js_value_t *simulator;
err = js_get_boolean(env, BARE_SIMULATOR, &simulator);
assert(err == 0);

err = js_set_named_property(env, exports, "simulator", simulator);
assert(err == 0);

js_value_t *pid;
err = js_create_int32(env, uv_os_getpid(), &pid);
assert(err == 0);
Expand Down