Skip to content

Commit 3684ef0

Browse files
authored
Merge branch 'russo-2025:master' into master
2 parents 2e2be0b + 4d9dc95 commit 3684ef0

13 files changed

Lines changed: 127 additions & 47 deletions

File tree

.github/workflows/manual-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
version: weekly.2025.48
5252

5353
- name: Build Project
54-
run: v -prod -g -gc none -o "bin/papyrus" compiler.v
54+
run: v -prod -g -gc none -o "bin/papyrus-compiler" compiler.v
5555

5656
- name: Get the date
5757
id: date

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ The compiler processes files through these stages in order:
101101
### Build
102102
```bash
103103
# Debug build
104-
v -o "bin\papyrus.exe" compiler.v
104+
v -o "bin\papyrus-compiler.exe" compiler.v
105105

106106
# Production build (optimized, no GC)
107-
v -o "bin\papyrus.exe" -prod -g -gc none compiler.v
107+
v -o "bin\papyrus-compiler.exe" -prod -g -gc none compiler.v
108108

109109
# Debug with symbols
110-
v -g -gc none -o "bin\papyrus.exe" compiler.v
110+
v -g -gc none -o "bin\papyrus-compiler.exe" compiler.v
111111
```
112112

113113
### Run Tests

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Next Release
22

3+
### New Features
4+
5+
- Added support for multiple output directories - you can now specify multiple `-o` flags to copy compiled .pex files to multiple locations. #18
6+
37
...
48

59
## V 0.0.4

README.RU.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
3. Используйте следующий синтаксис для работы с компилятором:
3030

3131
```
32-
papyrus <command> [arguments]
32+
papyrus-compiler <command> [arguments]
3333
```
3434

3535
### Команды:
@@ -58,30 +58,30 @@ papyrus <command> [arguments]
5858

5959
#### Компиляция всех скриптов в директории с игнорированием кэша:
6060
```bash
61-
papyrus compile -nocache -i "D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source" -o "../test-files/compiled/skyrimSources"
61+
papyrus-compiler compile -nocache -i "D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source" -o "../test-files/compiled/skyrimSources"
6262
```
6363
Эта команда компилирует все скрипты (кэш игнорируется), расположенные в `D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source`, и помещает скомпилированные `.pex` файлы в каталог `../test-files/compiled/skyrimSources`.
6464

6565
#### Компиляция всех скриптов в директории:
6666
```bash
67-
papyrus compile -i "../../RH-workspace/scripts" -o "../../RH-workspace/compiled"
67+
papyrus-compiler compile -i "../../RH-workspace/scripts" -o "../../RH-workspace/compiled"
6868
```
6969
Эта команда компилирует все скрипты, расположенные в `../../RH-workspace/scripts`, и помещает скомпилированные `.pex` файлы в каталог `../../RH-workspace/compiled`.
7070

7171
#### Компиляция скриптов с использованием файлов заголовков/импортов:
7272
```bash
73-
papyrus compile -nocache -h "D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source" -i "../test-files/compiler" -o "../test-files/compiled"
73+
papyrus-compiler compile -nocache -h "D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source" -i "../test-files/compiler" -o "../test-files/compiled"
7474
```
7575
Эта команда скомпилирует все скрипты из каталога `../test-files/compiler` в каталог `../test-files/compiled`, а недостающая информация об объектах (`Form`, `ObjectReference`, `Actor` и т.д.) будет взята из `.psc` файлов в каталоге `D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source`.
7676

7777
#### Чтение скомпилированного `.pex` файла:
7878
```bash
79-
papyrus read "../test-files/compiled/ABCD.pex"
79+
papyrus-compiler read "../test-files/compiled/ABCD.pex"
8080
```
8181

8282
#### Создание JSON-дампа `.pex` файлов:
8383
```bash
84-
papyrus create-dump "../folder_with_pex_files"
84+
papyrus-compiler create-dump "../folder_with_pex_files"
8585
```
8686
Создает JSON-файл `dump.json`, содержащий некоторую информацию обо всех `.pex` файлах, расположенных в каталоге `../folder_with_pex_files`. Вот как это будет выглядеть:
8787
```json
@@ -133,7 +133,7 @@ Function EquipItem(Form akItem, bool abPreventRemoval = false, bool abSilent = f
133133
- [V compiler d0dc13e (weekly.2025.48)](https://github.com/vlang/v/releases/tag/weekly.2025.48)
134134

135135
```bash
136-
v -o "bin\papyrus.exe" -prod -g -gc none compiler.v
136+
v -o "bin\papyrus-compiler.exe" -prod -g -gc none compiler.v
137137
```
138138

139139
## Тестирование

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The compiler was created for the following purposes:
2929
3. Use the following syntax to work with the compiler:
3030

3131
```
32-
papyrus <command> [arguments]
32+
papyrus-compiler <command> [arguments]
3333
```
3434

3535
### Commands:
@@ -57,30 +57,30 @@ Below are several examples demonstrating the use of various compiler commands an
5757

5858
#### Compile all scripts in a directory, ignoring the cache:
5959
```bash
60-
papyrus compile -nocache -i "D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source" -o "../test-files/compiled/skyrimSources"
60+
papyrus-compiler compile -nocache -i "D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source" -o "../test-files/compiled/skyrimSources"
6161
```
6262
This command compiles all scripts (ignoring the cache) located in `D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source` and places the compiled `.pex` files in the `../test-files/compiled/skyrimSources` directory.
6363

6464
#### Compile all scripts in a directory:
6565
```bash
66-
papyrus compile -i "../../RH-workspace/scripts" -o "../../RH-workspace/compiled"
66+
papyrus-compiler compile -i "../../RH-workspace/scripts" -o "../../RH-workspace/compiled"
6767
```
6868
This command compiles all scripts located in `../../RH-workspace/scripts` and places the compiled `.pex` files in the `../../RH-workspace/compiled` directory.
6969

7070
#### Compile scripts using header/import files:
7171
```bash
72-
papyrus compile -nocache -h "D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source" -i "../test-files/compiler" -o "../test-files/compiled"
72+
papyrus-compiler compile -nocache -h "D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source" -i "../test-files/compiler" -o "../test-files/compiled"
7373
```
7474
This command will compile all scripts from the `../test-files/compiler` directory to the `../test-files/compiled` directory, and missing information about objects (`Form`, `ObjectReference`, `Actor`, etc.) will be taken from `.psc` files in the `D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source` directory.
7575

7676
#### Reading a compiled `.pex` file:
7777
```bash
78-
papyrus read "../test-files/compiled/ABCD.pex"
78+
papyrus-compiler read "../test-files/compiled/ABCD.pex"
7979
```
8080

8181
#### Creating a JSON dump of `.pex` files:
8282
```bash
83-
papyrus create-dump "../folder_with_pex_files"
83+
papyrus-compiler create-dump "../folder_with_pex_files"
8484
```
8585
Creates a JSON file `dump.json` containing some information about all `.pex` files located in the `../folder_with_pex_files` directory. Here's what it will look like:
8686
```json
@@ -132,7 +132,7 @@ Scripts from the directory specified by the `-h "..."` argument will NOT be comp
132132
- [V compiler d0dc13e (weekly.2025.48)](https://github.com/vlang/v/releases/tag/weekly.2025.48)
133133

134134
```bash
135-
v -o "bin\papyrus.exe" -prod -g -gc none compiler.v
135+
v -o "bin\papyrus-compiler.exe" -prod -g -gc none compiler.v
136136
```
137137

138138
## Testing

modules/builder/builder.v

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ pub fn (mut b Builder) run() bool {
6868
b.print("used header dirs ${b.pref.header_dirs}")
6969

7070
b.files, b.files_names = find_all_src_files(b.pref.paths)
71-
71+
72+
// Warn if using multiple output directories with -original flag
73+
if b.pref.output_dirs.len > 1 && b.pref.backend == .original {
74+
b.print("Warning: Using multiple output directories with -original flag is not fully supported. Files will only be compiled to the first directory.")
75+
}
76+
7277
match b.pref.backend {
7378
.check,
7479
.pex {

modules/builder/original.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn (mut b Builder) compile_original() {
1515
header_dirs = header_dirs[..header_dirs.len-1]
1616

1717
for file in b.files {
18-
cmd := '"${compiler_exe_path}" "${file}" -quiet -i="${header_dirs}" -o="${b.pref.output_dir}" -f="${compiler_flags_path}"'
18+
cmd := '"${compiler_exe_path}" "${file}" -quiet -i="${header_dirs}" -o="${b.pref.output_dirs[0]}" -f="${compiler_flags_path}"'
1919

2020
b.print("executing: `${cmd}`")
2121

modules/builder/pex.v

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ fn (mut b Builder) compile_pex() {
9999
fn (mut b Builder) gen_to_pex_file(mut parsed_file ast.File, mut buff_bytes pex.Buffer) {
100100
if is_outdated(parsed_file, b.pref) {
101101
output_file_name := parsed_file.file_name + ".pex"
102-
output_file_path := os.join_path(b.pref.output_dir, output_file_name)
102+
// Use first output directory for writing
103+
output_file_path := os.join_path(b.pref.output_dirs[0], output_file_name)
103104

104105
mut pex_file := b.generator.gen(mut parsed_file)
105106

@@ -114,6 +115,16 @@ fn (mut b Builder) gen_to_pex_file(mut parsed_file ast.File, mut buff_bytes pex.
114115
util.fatal_error("failed to write file: ${err}")
115116
}
116117
file.close()
118+
119+
// Copy to additional output directories
120+
if b.pref.output_dirs.len > 1 {
121+
for j in 1 .. b.pref.output_dirs.len {
122+
copy_path := os.join_path(b.pref.output_dirs[j], output_file_name)
123+
os.cp(output_file_path, copy_path) or {
124+
util.fatal_error("failed to copy file to ${copy_path}: ${err}")
125+
}
126+
}
127+
}
117128
}
118129
}
119130

modules/papyrus/errors/errors.v

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,20 @@ pub:
3535
reporter Reporter
3636
}
3737

38-
pub const msg_invalid_output_path = "Error: Invalid path specified for the -o flag. Please provide a valid directory path where compiled files should be saved.";
39-
pub const msg_invalid_input_path = "Error: Invalid path specified for the -i flag. Please provide a valid directory or file path containing the .psc scripts to compile.";
40-
pub const msg_invalid_headers_path = "Error: Invalid path specified for the -h flag. Please provide a valid directory path containing header/import .psc files.";
38+
pub const msg_invalid_output_path = "Error: Invalid path specified for the -o flag. Please provide a valid directory path where compiled files should be saved."
39+
pub const msg_invalid_input_path = "Error: Invalid path specified for the -i flag. Please provide a valid directory or file path containing the .psc scripts to compile."
40+
pub const msg_invalid_headers_path = "Error: Invalid path specified for the -h flag. Please provide a valid directory path containing header/import .psc files."
4141
pub const msg_duplicate_input_flag = "Error: Duplicate -i flag detected with the same path. Please ensure each -i flag points to a unique directory or file."
42-
pub const msg_duplicate_output_flag = "Error: The -o flag has already been specified. Please provide only one output directory.";
43-
pub const msg_missing_input = "Error: Missing mandatory -i flag. Please specify the directory or file containing .psc scripts to compile.";
44-
pub const msg_missing_output = "Error: Missing mandatory -o flag. Please specify the directory where compiled .pex files should be saved.";
42+
pub const msg_duplicate_output_flag = "Error: The -o flag has already been specified. Please provide only one output directory."
43+
pub const msg_missing_input = "Error: Missing mandatory -i flag. Please specify the directory or file containing .psc scripts to compile."
44+
pub const msg_missing_output = "Error: Missing mandatory -o flag. Please specify the directory where compiled .pex files should be saved."
45+
pub const msg_warning_multiple_output_with_original = "Warning: Using multiple output directories with -original flag is not fully supported. Files will only be compiled to the first directory."
4546
//TODO
46-
pub const msg_wrong_number_of_arguments = "Error: Incorrect number of arguments for the command. Please refer to the documentation for the correct usage.";
47+
pub const msg_wrong_number_of_arguments = "Error: Incorrect number of arguments for the command. Please refer to the documentation for the correct usage."
4748
//TODO
48-
pub const msg_missing_or_incorrect_argument = "Error: Missing or incorrect argument. Please check the syntax of your command.";
49-
pub const msg_missing_or_incorrect_command = "Error: Invalid command. Please use one of the following commands: compile, read, disassembly, create-dump, help.";
50-
pub const msg_invalid_path_disassembly = "Error: Invalid path specified for the disassembly command. Please provide a valid file path for the .pex file.";
51-
pub const msg_invalid_path_read = "Error: Invalid path specified for the read command. Please provide a valid file path for the .pex file.";
52-
pub const msg_invalid_path_create_dump = "Error: Invalid path specified for create-dump. Please provide a valid directory path containing .pex files.";
49+
pub const msg_missing_or_incorrect_argument = "Error: Missing or incorrect argument. Please check the syntax of your command."
50+
pub const msg_missing_or_incorrect_command = "Error: Invalid command. Please use one of the following commands: compile, read, disassembly, create-dump, help."
51+
pub const msg_invalid_path_disassembly = "Error: Invalid path specified for the disassembly command. Please provide a valid file path for the .pex file."
52+
pub const msg_invalid_path_read = "Error: Invalid path specified for the read command. Please provide a valid file path for the .pex file."
53+
pub const msg_invalid_path_create_dump = "Error: Invalid path specified for create-dump. Please provide a valid directory path containing .pex files."
5354

modules/pref/pref.v

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn (m RunMode) str() string {
4747
pub struct Preferences {
4848
pub mut:
4949
paths []string // folders with files to compile
50-
output_dir string // folder for output files
50+
output_dirs []string // folders for output files
5151
mode RunMode = .compile
5252
backend Backend = .pex
5353
no_cache bool
@@ -71,7 +71,9 @@ pub fn (p Preferences) cmd_str() string {
7171
b.write_string("-i \"${path}\" ")
7272
}
7373

74-
b.write_string("-o \"${p.output_dir}\" ")
74+
for dir in p.output_dirs {
75+
b.write_string("-o \"${dir}\" ")
76+
}
7577

7678
for dir in p.header_dirs {
7779
b.write_string("-h \"${dir}\" ")
@@ -124,17 +126,13 @@ fn (mut p Preferences) parse_compile_args(args []string) {
124126
"-output" {
125127
i++
126128

127-
if p.output_dir != "" {
128-
error(errors.msg_duplicate_output_flag) // path
129-
}
130-
131129
path := os.real_path(args[i])
132130

133131
if !os.is_dir(path) {
134132
error(errors.msg_invalid_output_path) // path
135133
}
136134

137-
p.output_dir = path
135+
p.output_dirs << path
138136
i++
139137
}
140138
"-h",
@@ -192,7 +190,7 @@ fn (mut p Preferences) parse_compile_args(args []string) {
192190
error(errors.msg_missing_input)
193191
}
194192

195-
if p.output_dir == "" {
193+
if p.output_dirs.len == 0 {
196194
error(errors.msg_missing_output)
197195
}
198196
}

0 commit comments

Comments
 (0)