changeset 25:342726584be2

[Bun] Fixed how bun would be ran within bazel.
author June Park <parkjune1995@gmail.com>
date Thu, 09 Oct 2025 06:41:02 -0700
parents 7d3fa1a7a854
children a58a663dae68
files gui_ze/gui_ze.bzl playground/BUILD playground/june.tsx playground/main.c
diffstat 4 files changed, 25 insertions(+), 97 deletions(-) [+]
line wrap: on
line diff
--- a/gui_ze/gui_ze.bzl	Tue Oct 07 09:13:29 2025 -0700
+++ b/gui_ze/gui_ze.bzl	Thu Oct 09 06:41:02 2025 -0700
@@ -75,7 +75,6 @@
         mkdir -p {outdir}
         unzip -j {src} {inner} -d {outdir}
         chmod +x {outdir}/bun
-        mv {outdir}/bun {out}
       """.format(
         outdir = out.dirname,
         src = ctx.files.srcs[0].path,
@@ -91,8 +90,8 @@
 bun_binary = rule(
     implementation = _bun_binary_impl,
     attrs = {
-        "srcs": attr.label_list(allow_files=True),
-        "src_folder": attr.string(),
+      "srcs": attr.label_list(allow_files=True),
+      "src_folder": attr.string(),
     },
     executable = True,
 )
@@ -104,8 +103,8 @@
   This sucks because you need to either copy node module into the root folder where main.ts file
   exists or copy everything outwards. I chose to do it in this way.
 
-  TODO: If possible, maybe create a node_module inside of the main target path and create a symlink,
-  but I couldn't get it to work lol.
+  TODO: If possible, maybe create a node_module inside of the main target path and create a symlink
+  TODO: Add a specific path for node_modules
   """
   out = ctx.actions.declare_file(ctx.label.name + ".js")
   inputs = [ctx.file.src] + ctx.files.data
@@ -116,12 +115,13 @@
     tools = [ctx.executable._bun] + inputs, 
     command = """
       cp -r third_party/bun/** . \
-      && cp -r playground/** .  \
-      && {} build {} --outfile {}
+      && cp -r {src_folder}/** .  \
+      && export NODE_PATH=./node_modules && {bun_path} build {input_path} --outfile {output_path}
       """.format(
-      ctx.executable._bun.path,
-      ctx.file.src.path.split("/")[-1],
-      out.path,
+      bun_path = ctx.executable._bun.path,
+      src_folder = ctx.attr.src_folder,
+      input_path = ctx.file.src.path.split("/")[-1],
+      output_path = out.path,
     ),
     progress_message = "Bundling {} with Bun!\n\n".format(ctx.file.src.path),
   )
@@ -138,6 +138,7 @@
         cfg = "exec",
     ),
     "data": attr.label_list(allow_files=True),
+    "src_folder": attr.string(),
   },
 )
 
--- a/playground/BUILD	Tue Oct 07 09:13:29 2025 -0700
+++ b/playground/BUILD	Thu Oct 09 06:41:02 2025 -0700
@@ -29,6 +29,7 @@
 bun_build(
   name = "hello",
   src = "main.ts",
+  src_folder = "playground",
   data = ["//third_party/bun:node_modules", ":all_ts_files"],
   visibility = ["//visibility:public"],
 )
--- a/playground/june.tsx	Tue Oct 07 09:13:29 2025 -0700
+++ b/playground/june.tsx	Thu Oct 09 06:41:02 2025 -0700
@@ -2,7 +2,7 @@
 
 const Foo = () => {
   return (
-    <> Test </>
+    <> hehexd </>
   );
 }
 
--- a/playground/main.c	Tue Oct 07 09:13:29 2025 -0700
+++ b/playground/main.c	Thu Oct 09 06:41:02 2025 -0700
@@ -1,94 +1,20 @@
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <openssl/ssl.h>
-#include <openssl/err.h>
 
-#define INITIAL_BUFFER_CAPACITY 8192
+struct Node {
+  char *value;
+  struct Node *left;
+  struct Node *right;
+};
 
-void init_openssl()
+void *recurr(struct Node *root, int depth)
 {
-    SSL_load_error_strings();
-    OpenSSL_add_ssl_algorithms();
+  if (depth)
+    return;
+  root.left = 
 }
 
-int main(void)
+int main()
 {
-    const char *host = "www.google.com";
-    const char *port = "443";
-
-    struct addrinfo hints = {0}, *res;
-    hints.ai_family   = AF_UNSPEC;
-    hints.ai_socktype = SOCK_STREAM;
-
-    if (getaddrinfo(host, port, &hints, &res) != 0)
-    {
-        perror("getaddrinfo");
-        return 1;
-    }
-
-    int sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
-    if (sockfd < 0)
-    {
-        perror("socket");
-        return 1;
-    }
-
-    if (connect(sockfd, res->ai_addr, res->ai_addrlen) != 0)
-    {
-        perror("connect");
-        return 1;
-    }
-
-    freeaddrinfo(res);
-
-    init_openssl();
-    SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
-    SSL_CTX_set_default_verify_paths(ctx);
-
-    SSL *ssl = SSL_new(ctx);
-    SSL_set_fd(ssl, sockfd);
-
-    // ✅ use real hostname for SNI
-    SSL_set_tlsext_host_name(ssl, host);
-
-    // ✅ perform blocking handshake for simplicity
-    fcntl(sockfd, F_SETFL, 0);
-
-    if (SSL_connect(ssl) != 1)
-    {
-      fprintf(stderr, "SSL_connect failed\n");
-      ERR_print_errors_fp(stderr);
-      return 1;
-    }
-
-    printf("✅ SSL handshake successful!\n");
-
-    // send a basic HTTP request
-    const char *req =
-        "GET / HTTP/1.1\r\n"
-        "Host: www.google.com\r\n"
-        "Connection: close\r\n\r\n";
-    SSL_write(ssl, req, strlen(req));
-
-    char buf[INITIAL_BUFFER_CAPACITY];
-    int bytes;
-
-    while ((bytes = SSL_read(ssl, buf, sizeof(buf) - 1)) > 0)
-    {
-        buf[bytes] = '\0';
-        printf("%s", buf);
-    }
-
-    SSL_shutdown(ssl);
-    SSL_free(ssl);
-    SSL_CTX_free(ctx);
-    close(sockfd);
-    EVP_cleanup();
-    return 0;
+  struct Node root = {}
+  struct Node **queue = {}
 }