Skip to content
Open
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
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BasedOnStyle: Chromium
IndentWidth: 2
TabWidth: 2
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ dkms.conf
*.dwo

build/
wnpkg-build/
lnpkg-build/
67 changes: 39 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,48 +1,59 @@
CC = gcc

FLAGS = -Iinclude/
FLAGS = -Iinclude/ -fsanitize=address -Wall

BUILD_DIR = build
WNPKG_EXECUTABLE = wnpkg
WNPKG_EXECUTABLE_DIR = $(BUILD_DIR)/$(WNPKG_EXECUTABLE)
LNPKG_EXECUTABLE = lnpkg
LNPKG_EXECUTABLE_DIR = $(BUILD_DIR)/$(LNPKG_EXECUTABLE)

# For termux
WNPKG_TEMP = $(HOME)/temp/c/wnpkg
WNPKG_BUILD_DIR = wnpkg-build
LNPKG_TEMP = $(HOME)/temp/c/lnpkg
LNPKG_BUILD_DIR = lnpkg-build

MAIN_SRC = src/main.c
FILE_SRC = src/file.c
MAIN_SRC = src/main.c
FILE_SRC = src/file.c
BUILDER_SRC = src/builder.c

FILE_O = $(BUILD_DIR)/file.o
FILE_O = $(BUILD_DIR)/file.o
BUILDER_O = $(BUILD_DIR)/builder.o

all: setup $(WNPKG_EXECUTABLE_DIR)
OBJS = $(FILE_O) $(NODE_O) $(BUILDER_O)

all: setup $(LNPKG_EXECUTABLE_DIR)

.PHONY: setup clean

$(FILE_O): $(FILE_SRC)
$(CC) -c $(FILE_SRC) -o $(FILE_O) $(FLAGS)

$(WNPKG_EXECUTABLE_DIR): $(MAIN_SRC) $(FILE_O)
$(CC) $(MAIN_SRC) $(FILE_O) -o $(WNPKG_EXECUTABLE_DIR) $(FLAGS)
$(BUILDER_O): $(BUILDER_SRC)
$(CC) -c $(BUILDER_SRC) -o $(BUILDER_O) $(FLAGS)

$(LNPKG_EXECUTABLE_DIR): setup $(MAIN_SRC) $(OBJS)
$(CC) $(MAIN_SRC) $(OBJS) -o $(LNPKG_EXECUTABLE_DIR) $(FLAGS)

setup:
mkdir -p build

clean:
rm -rf $(WNPKG_EXECUTABLE_DIR)

run: $(WNPKG_EXECUTABLE_DIR)
rm -rf $(WNPKG_BUILD_DIR)
chmod +x $(WNPKG_EXECUTABLE_DIR)
./$(WNPKG_EXECUTABLE_DIR) basic_nodejs_proj
cd $(WNPKG_BUILD_DIR) && chmod +x basic_nodejs_proj && ./basic_nodejs_proj

termux_run: $(WNPKG_EXECUTABLE_DIR)
rm -rf $(WNPKG_BUILD_DIR)
mkdir -p $(WNPKG_TEMP)
cp $(WNPKG_EXECUTABLE_DIR) $(WNPKG_TEMP)/$(WNPKG_EXECUTABLE)
chmod +x $(WNPKG_TEMP)/$(WNPKG_EXECUTABLE)
$(WNPKG_TEMP)/$(WNPKG_EXECUTABLE) basic_nodejs_proj
rm -rf $(WNPKG_TEMP)/$(WNPKG_BUILD_DIR)
cp -rf $(WNPKG_BUILD_DIR) $(WNPKG_TEMP)/$(WNPKG_BUILD_DIR)
cd $(WNPKG_TEMP)/$(WNPKG_BUILD_DIR) && chmod +x basic_nodejs_proj && ./basic_nodejs_proj
rm -rf $(LNPKG_EXECUTABLE_DIR)

runtest:
cd $(LNPKG_BUILD_DIR) && chmod +x basic_nodejs_proj && ./basic_nodejs_proj

run: $(LNPKG_EXECUTABLE_DIR)
chmod +x $(LNPKG_EXECUTABLE_DIR)
./$(LNPKG_EXECUTABLE_DIR) basic_nodejs_proj
$(MAKE) runtest

termux_runtest:
rm -rf $(LNPKG_TEMP)/$(LNPKG_BUILD_DIR)
cp -rf $(LNPKG_BUILD_DIR) $(LNPKG_TEMP)/$(LNPKG_BUILD_DIR)
cd $(LNPKG_TEMP)/$(LNPKG_BUILD_DIR) && chmod +x basic_nodejs_proj && ./basic_nodejs_proj

termux_run: $(LNPKG_EXECUTABLE_DIR)
mkdir -p $(LNPKG_TEMP)
cp $(LNPKG_EXECUTABLE_DIR) $(LNPKG_TEMP)/$(LNPKG_EXECUTABLE)
chmod +x $(LNPKG_TEMP)/$(LNPKG_EXECUTABLE)
$(LNPKG_TEMP)/$(LNPKG_EXECUTABLE) basic_nodejs_proj
$(MAKE) termux_runtest
63 changes: 29 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,45 @@
# 📦 wnpkg
# 📦 lnpkg

**wnpkg** is a tiny utility that packages a Node.js application into a portable executable — works on **Windows** and **Linux**.
**lnpkg** is a tiny linux utility that packages a Node.js application into a linux executable.

## 🚀 Features

- Automatically wraps your Node.js script into a standalone executable
- Includes the Node.js runtime (`node.exe` on Windows, `node` on Linux)
- Optional custom icon support (`icon.ico`)
- Generates a clean build structure in `wnpkg-build/`
- Includes the Node.js runtime `node`
- Generates a clean build structure in `lnpkg-build/`
- Super lightweight — written in pure C using `gcc`

---

## 🛠️ Usage

```
wnpkg <project-folder>
lnpkg <project-folder>
```

This command will:

1. Copy `node` (or `node.exe` on Windows) and your `index.js` into a build folder.
1. Copy `node` and your `index.js` into a build folder.
2. Compile a small C launcher using `gcc`.
3. Output a single executable:
- On **Windows**: `my-app.exe`
- On **Linux**: `my-app` (ELF binary without file extension)

### Example

```
wnpkg my-app
lnpkg my-app
```

This will create the following structure:

```
wnpkg-build/
lnpkg-build/
├── source/
│ ├── index.js <-- Your Node.js app
│ └── node(.exe) <-- Node.js runtime
├── my-app(.exe) <-- Final executable
│ └── node <-- Node.js runtime
├── my-app <-- Final executable
```

- On **Windows**, just double-click `my-app.exe` to run your app.
- On **Linux**, run it with:

```
Expand All @@ -51,38 +48,22 @@ wnpkg-build/

---

## 🎨 Optional: Custom Icon
## ⚙️ Optional: Configuration File (`lnpkg_config`)

To embed a custom icon in the Windows executable:

1. Place your `icon.ico` file in the project folder.
2. `wnpkg` will automatically detect and include it in the `.exe`.

---

## ⚙️ Optional: Configuration File (`wnpkg_config`)

You can customize the app name and icon by creating a file named `wnpkg_config` in your project folder. This file should contain:

```
app-name;
icon.ico;
```

- Replace `app-name` with the desired output name.
- If you don't want to use an icon, simply use a `*` instead:

```
my-app;
*;
```

---

## 📄 Requirements

- Windows or Linux (32 or 64 bit)
- [GCC / MinGW](https://www.mingw-w64.org/) installed and available in PATH
- Linux (32 or 64 bit)
- [Node](https://nodejs.org/pt) installed and available in PATH
- [GCC](https://gcc.gnu.org/) installed and available in PATH

---

Expand All @@ -92,4 +73,18 @@ This project was built for fun and utility — feel free to hack it, improve it

---

## 🐧 Created by Leonardo Pinezi (a.k.a. Shinpi)
## 🐧 Created by Leonardo Pinezi (a.k.a. Shinpi) & Aquiles Trindade (a.k.a TrindadeDev13)

#### Leonardo Pinezi :
- Make the original base code and created the project
- Started the project organization
- Windows 32/64bit port
- Fixed bugs

#### Aquiles Trindade :
- Organized all the entire code
- Added makefile
- Added colours and file functions
- Linux 32/64bits port
- ELF export
- Fixed bugs
1 change: 1 addition & 0 deletions basic_nodejs_proj/lnpkg_config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
basic_nodejs_proj;
2 changes: 0 additions & 2 deletions basic_nodejs_proj/wnpkg_config

This file was deleted.

Binary file removed default_icon.ico
Binary file not shown.
9 changes: 9 additions & 0 deletions include/lnpkg/builder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef __BUILDER_H__
#define __BUILDER_H__

void lnpkg_write_main();
void lnpkg_write_node_s();
void lnpkg_write_node();
void lnpkg_write_lnpkg_h();

#endif
2 changes: 1 addition & 1 deletion include/wnpkg/color.h → include/lnpkg/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define RED_PRINT(fmt, ...) printf("%s" fmt "%s", RED, ##__VA_ARGS__, RESET)
#define GREEN_PRINT(fmt, ...) printf("%s" fmt "%s", GREEN, ##__VA_ARGS__, RESET)
#define YELLOW_PRINT(fmt, ...) \
#define YELLOW_PRINT(fmt, ...) \
printf("%s" fmt "%s", YELLOW, ##__VA_ARGS__, RESET)

#endif
33 changes: 33 additions & 0 deletions include/lnpkg/file.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef __FILE_H__
#define __FILE_H__

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

#include <dirent.h>

#define LNPKG_FILE_LIST_DIR_INITIAL_CAPACITY 1

enum lnpkg_type { LNPKG_FILE, LNPKG_DIR };

struct lnpkg_file {
struct dirent* rawdir;
char* name;
enum lnpkg_type filetype;
};

struct lnpkg_listdir_data {
struct lnpkg_file* dirs;
size_t len;
size_t capacity;
};

int lnpkg_mkdir(char*);
int lnpkg_rmdir(char*);
int lnpkg_havedir(char*);
void lnpkg_rmr(char*);

struct lnpkg_listdir_data* lnpkg_listdir(char*);
void lnpkg_listdir_close(struct lnpkg_listdir_data*);

#endif
8 changes: 0 additions & 8 deletions include/wnpkg/file.h

This file was deleted.

8 changes: 0 additions & 8 deletions include/wnpkg/plat.h

This file was deleted.

Loading