summaryrefslogtreecommitdiff
path: root/BUILD_SCRIPTS.md
blob: 013f5a58ae9f017c7c67d02506d732bf6b6168f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# Build Scripts Documentation

ReiLua includes automated build scripts for easy development and release builds.

## Available Scripts

### Development Build Scripts
- **Windows**: `build_dev.bat`
- **Linux/Unix**: `build_dev.sh`

### Release Build Scripts  
- **Windows**: `build_release.bat`
- **Linux/Unix**: `build_release.sh`

## Development Build

### Purpose
Fast iteration during game development with external Lua files and assets.

### Usage

**Windows:**
```cmd
build_dev.bat
```

**Linux/Unix:**
```bash
chmod +x build_dev.sh
./build_dev.sh
```

### Features
- ✅ No embedding - loads Lua and assets from file system
- ✅ Fast build times
- ✅ Edit code and assets without rebuilding
- ✅ Automatic cleanup of embedded files
- ✅ Warns if Lua files or assets are in build directory
- ✅ Optional clean build: `build_dev.bat clean` or `./build_dev.sh clean`

### Output
- Development executable: `build/ReiLua.exe`
- Run your game: `cd your_game && path/to/build/ReiLua.exe`
- Debug mode: `path/to/build/ReiLua.exe --log`

## Release Build

### Purpose
Create a single-file executable for distribution with all code and assets embedded.

### Preparation

Before running the release build, prepare your files:

```bash
cd build

# Copy all Lua files
copy ..\your_game\*.lua .
# Or: cp ../your_game/*.lua .

# Copy assets
mkdir assets
copy ..\your_game\assets\* assets\
# Or: cp -r ../your_game/assets/* assets/
```

### Usage

**Windows:**
```cmd
build_release.bat
```

**Linux/Unix:**
```bash
chmod +x build_release.sh
./build_release.sh
```

### Features
- ✅ Embeds all Lua files from `build/` directory
- ✅ Embeds all assets from `build/assets/` folder
- ✅ Creates single-file executable
- ✅ Release optimization enabled
- ✅ Verifies Lua files and assets before building
- ✅ Shows summary of embedded files after build
- ✅ Interactive confirmation before building

### Output
- Release executable: `build/ReiLua.exe`
- Ready for distribution - no external dependencies
- Can be renamed to your game name

### Build Configuration

The release build automatically configures:
- `EMBED_MAIN=ON` - Embeds all Lua files
- `EMBED_ASSETS=ON` - Embeds all assets (if assets folder exists)
- `CMAKE_BUILD_TYPE=Release` - Optimized build

## Customizing Your Executable

### Adding Custom Icon

1. Replace `icon.ico` with your own icon file
2. Keep the same filename or update `resources.rc`
3. Rebuild

### Changing Executable Properties

Edit `resources.rc` to customize:

```rc
VALUE "CompanyName", "Your Studio Name"
VALUE "FileDescription", "Your Game Description"
VALUE "ProductName", "Your Game Name"
VALUE "LegalCopyright", "Copyright (C) Your Name, 2025"
```

### Renaming the Executable

Edit `CMakeLists.txt`:
```cmake
project( YourGameName )  # Line 6
```

After building, the executable will be named `YourGameName.exe`.

## Workflow Examples

### Development Workflow

```bash
# Initial setup
build_dev.bat

# Edit your Lua files in your game directory
# ... make changes ...

# Just run - no rebuild needed!
cd your_game
path\to\build\ReiLua.exe

# If you modify C code, rebuild
build_dev.bat
```

### Release Workflow

```bash
# 1. Prepare files
cd build
copy ..\your_game\*.lua .
mkdir assets
copy ..\your_game\assets\* assets\

# 2. Build release
cd ..
build_release.bat

# 3. Test
cd build
ReiLua.exe --log

# 4. Distribute
# Copy build\ReiLua.exe to your distribution folder
```

## Troubleshooting

### "CMake configuration failed"
- Ensure CMake is installed and in PATH
- Ensure MinGW is installed and in PATH
- Check `CMakeLists.txt` exists in parent directory

### "No Lua files found"
- Copy your Lua files to `build/` directory before release build
- Ensure `main.lua` exists (required entry point)

### "Build failed"
- Check compiler errors in output
- Ensure all dependencies are installed
- Try clean build: `build_dev.bat clean`

### Development build embedding warning
- The dev build script warns if it finds Lua files or assets in build/
- These should be removed for development builds
- The script offers to remove them automatically

## Script Features

### Safety Features
- Checks for correct directory before running
- Validates required files exist
- Warns about potential issues
- Interactive confirmations for release builds
- Automatic cleanup of old embedded files

### User Friendly
- Clear progress messages
- Colored output (where supported)
- Helpful error messages
- Pause at end to review results
- Quick reference commands shown after build

## Notes

- Development builds are **much faster** than release builds
- Release builds may take longer due to embedding and optimization
- Always test your release build before distribution
- The scripts work on both Windows (CMD/PowerShell) and Unix shells
- On Unix, make scripts executable: `chmod +x build_*.sh`