bare-build 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CMakeLists.txt +27 -15
  2. package/README.md +2 -0
  3. package/bin.js +3 -0
  4. package/index.js +5 -5
  5. package/lib/assets/apple/icon.png +0 -0
  6. package/lib/assets/linux/icon.png +0 -0
  7. package/lib/assets/windows/icon.png +0 -0
  8. package/lib/assets.js +13 -0
  9. package/lib/builtins.json +7 -0
  10. package/lib/fs.js +2 -2
  11. package/lib/platform/apple/create-app.js +6 -8
  12. package/lib/platform/apple/create-executable.js +60 -0
  13. package/lib/platform/apple/create-package-component.js +2 -2
  14. package/lib/platform/apple/create-package.js +2 -2
  15. package/lib/platform/apple/sign.js +3 -3
  16. package/lib/platform/apple.js +24 -11
  17. package/lib/platform/linux/create-app-dir.js +2 -1
  18. package/lib/platform/linux/create-app-image.js +1 -1
  19. package/lib/platform/linux/create-executable.js +50 -0
  20. package/lib/platform/linux.js +24 -11
  21. package/lib/platform/windows/create-executable.js +50 -0
  22. package/lib/platform/windows/create-msix-content-directory.js +11 -5
  23. package/lib/platform/windows/create-msix.js +1 -1
  24. package/lib/platform/windows.js +24 -11
  25. package/lib/runtime/apple.h +22 -0
  26. package/lib/runtime/linux.h +17 -0
  27. package/lib/runtime/windows.h +45 -0
  28. package/lib/runtime.bundle.h +16696 -0
  29. package/lib/runtime.bundle.h.d +1 -0
  30. package/lib/runtime.c +81 -33
  31. package/lib/runtime.js +36 -0
  32. package/package.json +6 -3
  33. package/prebuilds/darwin-arm64/bare +0 -0
  34. package/prebuilds/darwin-x64/bare +0 -0
  35. package/prebuilds/ios-arm64/bare +0 -0
  36. package/prebuilds/ios-arm64-simulator/bare +0 -0
  37. package/prebuilds/ios-x64-simulator/bare +0 -0
  38. package/prebuilds/linux-arm64/bare +0 -0
  39. package/prebuilds/linux-x64/bare +0 -0
  40. package/prebuilds/win32-arm64/bare.exe +0 -0
  41. package/prebuilds/win32-x64/bare.exe +0 -0
@@ -2,9 +2,10 @@ const path = require('path')
2
2
  const fs = require('../fs')
3
3
  const createMSIX = require('./windows/create-msix')
4
4
  const createMSIXContentDirectory = require('./windows/create-msix-content-directory')
5
+ const createExecutable = require('./windows/create-executable')
5
6
 
6
7
  module.exports = async function* windows(base, pkg, bundle, opts = {}) {
7
- const { hosts = [], package = false, out = '.' } = opts
8
+ const { hosts = [], standalone = false, package = false, out = '.' } = opts
8
9
 
9
10
  const archs = new Map()
10
11
 
@@ -39,16 +40,28 @@ module.exports = async function* windows(base, pkg, bundle, opts = {}) {
39
40
 
40
41
  contentDirectory = yield* createMSIXContentDirectory(base, pkg, bundle, host, out, opts)
41
42
  } else {
42
- contentDirectory = yield* createMSIXContentDirectory(
43
- base,
44
- pkg,
45
- bundle,
46
- host,
47
- archs.size === 1 ? path.resolve(out) : path.resolve(out, arch),
48
- opts
49
- )
50
-
51
- result.push(contentDirectory)
43
+ if (standalone) {
44
+ result.push(
45
+ yield* createExecutable(
46
+ pkg,
47
+ bundle,
48
+ host,
49
+ archs.size === 1 ? path.resolve(out) : path.resolve(out, arch),
50
+ opts
51
+ )
52
+ )
53
+ } else {
54
+ result.push(
55
+ yield* createMSIXContentDirectory(
56
+ base,
57
+ pkg,
58
+ bundle,
59
+ host,
60
+ archs.size === 1 ? path.resolve(out) : path.resolve(out, arch),
61
+ opts
62
+ )
63
+ )
64
+ }
52
65
 
53
66
  continue
54
67
  }
@@ -0,0 +1,22 @@
1
+ #include <mach-o/getsect.h>
2
+ #include <mach-o/loader.h>
3
+ #include <stddef.h>
4
+ #include <stdint.h>
5
+ #include <uv.h>
6
+
7
+ extern const struct mach_header_64 _mh_execute_header;
8
+
9
+ static inline void
10
+ bare__prepare_main(void) {}
11
+
12
+ static inline int
13
+ bare__get_embedded_bundle(uv_buf_t *result) {
14
+ size_t len;
15
+ uint8_t *bundle = getsectiondata(&_mh_execute_header, "__BARE", "__bundle", &len);
16
+
17
+ if (bundle == NULL) return -1;
18
+
19
+ *result = uv_buf_init((char *) bundle, len);
20
+
21
+ return 0;
22
+ }
@@ -0,0 +1,17 @@
1
+ #include <stddef.h>
2
+ #include <uv.h>
3
+
4
+ extern char __bare_bundle_begin[] __attribute__((weak));
5
+ extern char __bare_bundle_end[] __attribute__((weak));
6
+
7
+ static inline void
8
+ bare__prepare_main(void) {}
9
+
10
+ static inline int
11
+ bare__get_embedded_bundle(uv_buf_t *result) {
12
+ if (__bare_bundle_begin == NULL || __bare_bundle_end == NULL) return -1;
13
+
14
+ *result = uv_buf_init(__bare_bundle_begin, __bare_bundle_end - __bare_bundle_begin);
15
+
16
+ return 0;
17
+ }
@@ -0,0 +1,45 @@
1
+ #include <string.h>
2
+ #include <uv.h>
3
+ #include <windows.h>
4
+
5
+ static inline void
6
+ bare__prepare_main(void) {
7
+ if (GetConsoleWindow() == NULL) {
8
+ freopen("NUL", "r", stdin);
9
+ freopen("NUL", "w", stdout);
10
+ freopen("NUL", "w", stderr);
11
+ }
12
+ }
13
+
14
+ static inline int
15
+ bare__get_embedded_bundle(uv_buf_t *result) {
16
+ HMODULE module = GetModuleHandle(NULL);
17
+
18
+ PIMAGE_DOS_HEADER dos = (PIMAGE_DOS_HEADER) module;
19
+ if (dos->e_magic != IMAGE_DOS_SIGNATURE) {
20
+ return -1;
21
+ }
22
+
23
+ PIMAGE_NT_HEADERS nt = (PIMAGE_NT_HEADERS) ((BYTE *) module + dos->e_lfanew);
24
+ if (nt->Signature != IMAGE_NT_SIGNATURE) {
25
+ return -1;
26
+ }
27
+
28
+ PIMAGE_SECTION_HEADER sections = IMAGE_FIRST_SECTION(nt);
29
+
30
+ for (int i = 0, n = nt->FileHeader.NumberOfSections; i < n; i++) {
31
+ PIMAGE_SECTION_HEADER section = &sections[i];
32
+
33
+ char name[9];
34
+ name[8] = '\0';
35
+ memcpy(name, section->Name, 8);
36
+
37
+ if (strcmp(name, ".bare") == 0) {
38
+ *result = uv_buf_init((char *) ((BYTE *) module + section->VirtualAddress), sections->Misc.VirtualSize);
39
+
40
+ return 0;
41
+ }
42
+ }
43
+
44
+ return -1;
45
+ }