@pkmn/engine 0.1.0-dev.a324c50f → 0.1.0-dev.a77ab8e2
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.
- package/LICENSE +1 -3
- package/README.md +87 -52
- package/build/pkg/addon.js +6 -7
- package/build/pkg/addon.js.map +1 -1
- package/build/pkg/data/ids.json +12 -12
- package/build/pkg/data/layout.json +2 -2
- package/build/pkg/data/protocol.json +69 -12
- package/build/pkg/data.d.ts +4 -4
- package/build/pkg/data.js.map +1 -1
- package/build/pkg/gen1.js +2 -2
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.d.ts +3 -2
- package/build/pkg/index.js.map +1 -1
- package/build/pkg/protocol.js +61 -42
- package/build/pkg/protocol.js.map +1 -1
- package/build/test/display.js +8 -3
- package/build/test/display.js.map +1 -1
- package/build/tools/debug.js +5 -4
- package/build/tools/debug.js.map +1 -1
- package/build.zig +259 -117
- package/package.json +57 -25
- package/src/bin/install-pkmn-engine +31 -21
- package/src/lib/common/array.zig +77 -0
- package/src/lib/common/battle.zig +17 -0
- package/src/lib/common/data.zig +12 -24
- package/src/lib/common/debug.zig +2 -2
- package/src/lib/common/js.zig +120 -0
- package/src/lib/common/optional.zig +71 -0
- package/src/lib/common/options.zig +2 -0
- package/src/lib/common/protocol.zig +810 -327
- package/src/lib/common/rational.zig +447 -0
- package/src/lib/common/rng.zig +22 -13
- package/src/lib/common/util.zig +61 -0
- package/src/lib/gen1/calc.zig +806 -0
- package/src/lib/gen1/chance.zig +1167 -0
- package/src/lib/gen1/data/moves.zig +192 -180
- package/src/lib/gen1/data/species.zig +3 -3
- package/src/lib/gen1/data/types.zig +7 -7
- package/src/lib/gen1/data.zig +58 -64
- package/src/lib/gen1/helpers.zig +95 -397
- package/src/lib/gen1/mechanics.zig +587 -550
- package/src/lib/gen2/calc.zig +161 -0
- package/src/lib/gen2/chance.zig +905 -0
- package/src/lib/gen2/data/items.zig +12 -18
- package/src/lib/gen2/data/moves.zig +663 -569
- package/src/lib/gen2/data/species.zig +1 -1
- package/src/lib/gen2/data/types.zig +134 -31
- package/src/lib/gen2/data.zig +107 -79
- package/src/lib/gen2/generated.zig +806 -0
- package/src/lib/gen2/helpers.zig +49 -21
- package/src/lib/gen2/mechanics.zig +3563 -9
- package/src/lib/{binding/node.zig → node.zig} +10 -13
- package/src/lib/pkmn.zig +32 -15
- package/src/lib/{binding/wasm.zig → wasm.zig} +2 -1
- package/src/test/display/pkmn.html.tmpl +5 -5
- package/src/lib/gen1/README.md +0 -814
- package/src/lib/gen2/README.md +0 -309
package/build/tools/debug.js
CHANGED
|
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.display = display;
|
|
27
|
+
exports.run = run;
|
|
27
28
|
const fs = __importStar(require("fs"));
|
|
28
29
|
const data_1 = require("@pkmn/data");
|
|
29
30
|
const pkg_1 = require("../pkg");
|
|
@@ -60,6 +61,8 @@ function display(gens, data, error, seed) {
|
|
|
60
61
|
let offset = 0;
|
|
61
62
|
const showdown = !!view.getUint8(offset++);
|
|
62
63
|
const gen = gens.get(view.getUint8(offset++));
|
|
64
|
+
const N = view.getUint16(offset, data_2.LE);
|
|
65
|
+
offset += 2;
|
|
63
66
|
const lookup = data_2.Lookup.get(gen);
|
|
64
67
|
const size = data_2.LAYOUT[gen.num - 1].sizes.Battle;
|
|
65
68
|
const deserialize = (buf) => {
|
|
@@ -83,7 +86,7 @@ function display(gens, data, error, seed) {
|
|
|
83
86
|
partial.parsed.push(r.value);
|
|
84
87
|
r = it.next();
|
|
85
88
|
}
|
|
86
|
-
offset += r.value;
|
|
89
|
+
offset += N || r.value;
|
|
87
90
|
if (offset >= view.byteLength)
|
|
88
91
|
break;
|
|
89
92
|
partial.battle = deserialize(data.subarray(offset, offset += size));
|
|
@@ -101,7 +104,6 @@ function display(gens, data, error, seed) {
|
|
|
101
104
|
}
|
|
102
105
|
return (0, display_1.render)(gen, showdown, error, seed, frames, partial);
|
|
103
106
|
}
|
|
104
|
-
exports.display = display;
|
|
105
107
|
async function run(gens) {
|
|
106
108
|
let input;
|
|
107
109
|
if (process.argv.length > 2) {
|
|
@@ -122,7 +124,6 @@ async function run(gens) {
|
|
|
122
124
|
}
|
|
123
125
|
process.stdout.write(display(gens, input));
|
|
124
126
|
}
|
|
125
|
-
exports.run = run;
|
|
126
127
|
if (require.main === module) {
|
|
127
128
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
128
129
|
run(new data_1.Generations(require('@pkmn/sim').Dex)).catch(err => {
|
package/build/tools/debug.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/tools/debug.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/tools/debug.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,0BAuDC;AAED,kBAkBC;AA/GD,uCAAyB;AAEzB,qCAAmD;AAEnD,gCAAmE;AACnE,oDAAsC;AACtC,sCAAqD;AACrD,kDAAoC;AACpC,6CAA8C;AAE9C,MAAM,YAAY;IAChB,GAAG,CAAa;IAChB,MAAM,CAAS;IAEf,YAAY,GAAe,EAAE,MAAc;QACzC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAI,EAAE;QACJ,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;aAChC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,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AC,CAAC,CAAC;AACL,CAAC"}
|
package/build.zig
CHANGED
|
@@ -8,23 +8,40 @@ pub const Options = struct {
|
|
|
8
8
|
calc: ?bool = null,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
const Step = if (@hasDecl(std.Build, "Step")) std.Build.Step else .{
|
|
12
|
+
.Compile = std.Build.CompileStep,
|
|
13
|
+
.Options = std.Build.OptionsStep,
|
|
14
|
+
.Run = std.Build.RunStep,
|
|
15
|
+
};
|
|
16
|
+
const has_path = @hasField(std.Build.LazyPath, "path");
|
|
17
|
+
const root_module = @hasField(Step.Compile, "root_module");
|
|
18
|
+
const force_pic = !@hasField(std.Build.SharedLibraryOptions, "pic");
|
|
19
|
+
const ResolvedTarget =
|
|
20
|
+
if (@hasDecl(std.Build, "ResolvedTarget")) std.Build.ResolvedTarget else std.zig.CrossTarget;
|
|
21
|
+
|
|
11
22
|
pub fn module(b: *std.Build, options: Options) *std.Build.Module {
|
|
23
|
+
if (!has_path) @panic("Use build.zig.zon package management");
|
|
24
|
+
|
|
12
25
|
const dirname = comptime std.fs.path.dirname(@src().file) orelse ".";
|
|
13
26
|
const build_options = b.addOptions();
|
|
14
27
|
build_options.addOption(?bool, "showdown", options.showdown);
|
|
15
28
|
build_options.addOption(?bool, "log", options.log);
|
|
16
29
|
build_options.addOption(?bool, "chance", options.chance);
|
|
17
30
|
build_options.addOption(?bool, "calc", options.calc);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
|
|
32
|
+
const root_source_file = .{ .cwd_relative = dirname ++ "/src/lib/pkmn.zig" };
|
|
33
|
+
const imports = &.{.{ .name = "build_options", .module = build_options.createModule() }};
|
|
34
|
+
return b.createModule(if (@hasDecl(std.Build, "CreateModuleOptions"))
|
|
35
|
+
.{ .source_file = root_source_file, .dependencies = imports }
|
|
36
|
+
else
|
|
37
|
+
.{ .root_source_file = root_source_file, .imports = imports });
|
|
22
38
|
}
|
|
23
39
|
|
|
24
40
|
pub fn build(b: *std.Build) !void {
|
|
25
41
|
const target = b.standardTargetOptions(.{});
|
|
26
42
|
const optimize = b.standardOptimizeOption(.{});
|
|
27
43
|
|
|
44
|
+
const default: ?bool = if (force_pic) false else null;
|
|
28
45
|
const node_headers = b.option([]const u8, "node-headers", "Path to node-headers");
|
|
29
46
|
const node_import_lib =
|
|
30
47
|
b.option([]const u8, "node-import-library", "Path to node import library (Windows)");
|
|
@@ -32,9 +49,10 @@ pub fn build(b: *std.Build) !void {
|
|
|
32
49
|
const wasm_stack_size =
|
|
33
50
|
b.option(u64, "wasm-stack-size", "The size of WASM stack") orelse std.wasm.page_size;
|
|
34
51
|
const dynamic = b.option(bool, "dynamic", "Build a dynamic library") orelse false;
|
|
35
|
-
const strip = b.option(bool, "strip", "Strip debugging symbols from binary") orelse
|
|
36
|
-
const pic = b.option(bool, "pic", "Force position independent code") orelse
|
|
52
|
+
const strip = b.option(bool, "strip", "Strip debugging symbols from binary") orelse default;
|
|
53
|
+
const pic = b.option(bool, "pic", "Force position independent code") orelse default;
|
|
37
54
|
const emit_asm = b.option(bool, "emit-asm", "Output .s (assembly code)") orelse false;
|
|
55
|
+
const emit_ll = b.option(bool, "emit-ll", "Output .ll (LLVM IR)") orelse false;
|
|
38
56
|
|
|
39
57
|
const cmd = b.findProgram(&.{"strip"}, &.{}) catch null;
|
|
40
58
|
|
|
@@ -43,9 +61,15 @@ pub fn build(b: *std.Build) !void {
|
|
|
43
61
|
defer parsed.deinit();
|
|
44
62
|
const version = parsed.value.object.get("version").?.string;
|
|
45
63
|
const description = parsed.value.object.get("description").?.string;
|
|
46
|
-
var repository = std.mem.
|
|
64
|
+
var repository = std.mem.splitSequence(u8, parsed.value.object.get("repository").?.string, ":");
|
|
47
65
|
std.debug.assert(std.mem.eql(u8, repository.first(), "github"));
|
|
48
66
|
|
|
67
|
+
const fast = try std.SemanticVersion.parse("0.12.0-dev.866+3a47bc715");
|
|
68
|
+
if (optimize != .Debug and fast.order(builtin.zig_version) == .lt) {
|
|
69
|
+
std.log.warn("Release builds are ~10-20% slower than before Zig " ++
|
|
70
|
+
"v0.12.0-dev.866+3a47bc715 due to ziglang/zig#17768", .{});
|
|
71
|
+
}
|
|
72
|
+
|
|
49
73
|
const showdown =
|
|
50
74
|
b.option(bool, "showdown", "Enable Pokémon Showdown compatibility mode") orelse false;
|
|
51
75
|
const log = b.option(bool, "log", "Enable protocol message logging") orelse false;
|
|
@@ -60,30 +84,47 @@ pub fn build(b: *std.Build) !void {
|
|
|
60
84
|
|
|
61
85
|
const name = if (showdown) "pkmn-showdown" else "pkmn";
|
|
62
86
|
|
|
87
|
+
const pkmn = if (@hasDecl(std.Build, "CreateModuleOptions")) null else b.addModule("pkmn", .{
|
|
88
|
+
.root_source_file = if (has_path)
|
|
89
|
+
.{ .path = "src/lib/pkmn.zig" }
|
|
90
|
+
else
|
|
91
|
+
b.path("src/lib/pkmn.zig"),
|
|
92
|
+
.optimize = optimize,
|
|
93
|
+
.target = target,
|
|
94
|
+
.imports = &.{.{ .name = "build_options", .module = options.createModule() }},
|
|
95
|
+
});
|
|
96
|
+
|
|
63
97
|
var c = false;
|
|
64
98
|
if (node_headers) |headers| {
|
|
65
99
|
const addon = b.fmt("{s}.node", .{name});
|
|
66
|
-
const
|
|
100
|
+
const path = if (has_path) .{ .path = "src/lib/node.zig" } else b.path("src/lib/node.zig");
|
|
101
|
+
const lib = b.addSharedLibrary(if (force_pic) .{
|
|
102
|
+
.name = addon,
|
|
103
|
+
.root_source_file = path,
|
|
104
|
+
.optimize = optimize,
|
|
105
|
+
.target = target,
|
|
106
|
+
} else .{
|
|
67
107
|
.name = addon,
|
|
68
|
-
.root_source_file =
|
|
108
|
+
.root_source_file = path,
|
|
69
109
|
.optimize = optimize,
|
|
70
110
|
.target = target,
|
|
111
|
+
.strip = strip,
|
|
112
|
+
.pic = pic,
|
|
71
113
|
});
|
|
72
|
-
lib.addOptions("build_options", options);
|
|
73
|
-
lib.
|
|
74
|
-
lib.addSystemIncludePath(headers);
|
|
114
|
+
(if (root_module) lib.root_module else lib).addOptions("build_options", options);
|
|
115
|
+
lib.addSystemIncludePath(if (has_path) .{ .path = headers } else b.path(headers));
|
|
75
116
|
lib.linkLibC();
|
|
76
117
|
if (node_import_lib) |il| {
|
|
77
|
-
lib.addObjectFile(il);
|
|
78
|
-
} else if (
|
|
118
|
+
lib.addObjectFile(if (has_path) .{ .path = il } else b.path(il));
|
|
119
|
+
} else if (detect(target).os.tag == .windows) {
|
|
79
120
|
try std.io.getStdErr().writeAll("Must provide --node-import-library path on Windows\n");
|
|
80
121
|
std.process.exit(1);
|
|
81
122
|
}
|
|
82
123
|
lib.linker_allow_shlib_undefined = true;
|
|
83
124
|
maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
|
|
84
|
-
if (pic) lib.force_pic = pic;
|
|
125
|
+
if (force_pic and pic orelse false) lib.force_pic = pic;
|
|
85
126
|
// Always emit to build/lib because this is where the driver code expects to find it
|
|
86
|
-
// TODO
|
|
127
|
+
// TODO: ziglang/zig#2231 - using the following used to work (though was hacky):
|
|
87
128
|
//
|
|
88
129
|
// lib.emit_bin = .{ .emit_to = b.fmt("build/lib/{s}", .{addon}) };
|
|
89
130
|
// b.getInstallStep().dependOn(&lib.step);
|
|
@@ -92,74 +133,146 @@ pub fn build(b: *std.Build) !void {
|
|
|
92
133
|
// rename the file ourself in install-pkmn-engine
|
|
93
134
|
b.installArtifact(lib);
|
|
94
135
|
} else if (wasm) {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
lib.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
136
|
+
const entry = @hasDecl(Step.Compile, "Entry");
|
|
137
|
+
const mode = switch (optimize) {
|
|
138
|
+
.ReleaseFast, .ReleaseSafe => .ReleaseSmall,
|
|
139
|
+
else => optimize,
|
|
140
|
+
};
|
|
141
|
+
const freestanding = if (@hasDecl(std.Build, "resolveTargetQuery"))
|
|
142
|
+
b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding })
|
|
143
|
+
else
|
|
144
|
+
ResolvedTarget{ .cpu_arch = .wasm32, .os_tag = .freestanding };
|
|
145
|
+
const path = if (has_path) .{ .path = "src/lib/wasm.zig" } else b.path("src/lib/wasm.zig");
|
|
146
|
+
const bin = if (entry) bin: {
|
|
147
|
+
const exe = b.addExecutable(if (force_pic) .{
|
|
148
|
+
.name = name,
|
|
149
|
+
.root_source_file = path,
|
|
150
|
+
.optimize = mode,
|
|
151
|
+
.target = freestanding,
|
|
152
|
+
} else .{
|
|
153
|
+
.name = name,
|
|
154
|
+
.root_source_file = path,
|
|
155
|
+
.optimize = mode,
|
|
156
|
+
.target = freestanding,
|
|
157
|
+
.strip = strip,
|
|
158
|
+
.pic = pic,
|
|
159
|
+
});
|
|
160
|
+
(if (root_module) exe.root_module else exe).export_symbol_names = &[_][]const u8{
|
|
161
|
+
"SHOWDOWN",
|
|
162
|
+
"LOG",
|
|
163
|
+
"CHANCE",
|
|
164
|
+
"CALC",
|
|
165
|
+
"GEN1_CHOICES_SIZE",
|
|
166
|
+
"GEN1_LOGS_SIZE",
|
|
167
|
+
};
|
|
168
|
+
exe.entry = .disabled;
|
|
169
|
+
break :bin exe;
|
|
170
|
+
} else bin: {
|
|
171
|
+
const lib = b.addSharedLibrary(.{
|
|
172
|
+
.name = name,
|
|
173
|
+
.root_source_file = path,
|
|
174
|
+
.optimize = mode,
|
|
175
|
+
.target = freestanding,
|
|
176
|
+
});
|
|
177
|
+
lib.rdynamic = true;
|
|
178
|
+
break :bin lib;
|
|
179
|
+
};
|
|
180
|
+
bin.stack_size = wasm_stack_size;
|
|
181
|
+
if (@hasDecl(@TypeOf(bin.*), "strip")) bin.strip = strip orelse false;
|
|
182
|
+
if (force_pic and pic orelse false) bin.force_pic = pic;
|
|
183
|
+
(if (root_module) bin.root_module else bin).addOptions("build_options", options);
|
|
184
|
+
|
|
110
185
|
const opt = b.findProgram(&.{"wasm-opt"}, &.{"./node_modules/.bin"}) catch null;
|
|
111
186
|
if (optimize != .Debug and opt != null) {
|
|
112
187
|
const out = b.fmt("build/lib/{s}.wasm", .{name});
|
|
113
188
|
const sh = b.addSystemCommand(&.{ opt.?, "-O4" });
|
|
114
|
-
sh.addArtifactArg(
|
|
189
|
+
sh.addArtifactArg(bin);
|
|
115
190
|
sh.addArg("-o");
|
|
116
|
-
sh
|
|
191
|
+
if (@hasDecl(@TypeOf(sh.*), "addFileSourceArg")) {
|
|
192
|
+
sh.addFileSourceArg(if (has_path) .{ .path = out } else b.path(out));
|
|
193
|
+
} else {
|
|
194
|
+
sh.addFileArg(if (has_path) .{ .path = out } else b.path(out));
|
|
195
|
+
}
|
|
117
196
|
b.getInstallStep().dependOn(&sh.step);
|
|
197
|
+
if (!entry) b.installArtifact(bin);
|
|
198
|
+
} else if (entry) {
|
|
199
|
+
b.getInstallStep().dependOn(&b.addInstallArtifact(bin, .{
|
|
200
|
+
.dest_dir = .{ .override = std.Build.InstallDir{ .lib = {} } },
|
|
201
|
+
}).step);
|
|
118
202
|
}
|
|
119
|
-
b.installArtifact(lib);
|
|
120
203
|
} else if (dynamic) {
|
|
121
|
-
const
|
|
204
|
+
const path = if (has_path) .{ .path = "src/lib/c.zig" } else b.path("src/lib/c.zig");
|
|
205
|
+
const lib = b.addSharedLibrary(if (force_pic) .{
|
|
206
|
+
.name = name,
|
|
207
|
+
.root_source_file = path,
|
|
208
|
+
.version = try std.SemanticVersion.parse(version),
|
|
209
|
+
.optimize = optimize,
|
|
210
|
+
.target = target,
|
|
211
|
+
} else .{
|
|
122
212
|
.name = name,
|
|
123
|
-
.root_source_file =
|
|
213
|
+
.root_source_file = path,
|
|
124
214
|
.version = try std.SemanticVersion.parse(version),
|
|
125
215
|
.optimize = optimize,
|
|
126
216
|
.target = target,
|
|
217
|
+
.strip = strip,
|
|
218
|
+
.pic = pic,
|
|
127
219
|
});
|
|
128
|
-
lib.addOptions("build_options", options);
|
|
129
|
-
lib.
|
|
130
|
-
lib.addIncludePath("src/include");
|
|
220
|
+
(if (root_module) lib.root_module else lib).addOptions("build_options", options);
|
|
221
|
+
lib.addIncludePath(if (has_path) .{ .path = "src/include" } else b.path("src/include"));
|
|
131
222
|
maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
|
|
132
|
-
if (pic) lib.force_pic = pic;
|
|
223
|
+
if (force_pic and pic orelse false) lib.force_pic = pic;
|
|
133
224
|
b.installArtifact(lib);
|
|
134
225
|
c = true;
|
|
135
226
|
} else {
|
|
136
|
-
const
|
|
227
|
+
const path = if (has_path) .{ .path = "src/lib/c.zig" } else b.path("src/lib/c.zig");
|
|
228
|
+
const lib = b.addStaticLibrary(if (force_pic) .{
|
|
137
229
|
.name = name,
|
|
138
|
-
.root_source_file =
|
|
230
|
+
.root_source_file = path,
|
|
139
231
|
.optimize = optimize,
|
|
140
232
|
.target = target,
|
|
233
|
+
} else .{
|
|
234
|
+
.name = name,
|
|
235
|
+
.root_source_file = path,
|
|
236
|
+
.optimize = optimize,
|
|
237
|
+
.target = target,
|
|
238
|
+
.strip = strip,
|
|
239
|
+
.pic = pic,
|
|
141
240
|
});
|
|
142
|
-
lib.addOptions("build_options", options);
|
|
143
|
-
lib.
|
|
144
|
-
lib.addIncludePath("src/include");
|
|
241
|
+
(if (root_module) lib.root_module else lib).addOptions("build_options", options);
|
|
242
|
+
lib.addIncludePath(if (has_path) .{ .path = "src/include" } else b.path("src/include"));
|
|
145
243
|
lib.bundle_compiler_rt = true;
|
|
146
244
|
maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
|
|
147
|
-
if (pic) lib.force_pic = pic;
|
|
148
|
-
if (emit_asm)
|
|
245
|
+
if (force_pic and pic orelse false) lib.force_pic = pic;
|
|
246
|
+
if (emit_asm) {
|
|
247
|
+
b.getInstallStep().dependOn(&b.addInstallFileWithDir(
|
|
248
|
+
lib.getEmittedAsm(),
|
|
249
|
+
.prefix,
|
|
250
|
+
b.fmt("{s}.s", .{name}),
|
|
251
|
+
).step);
|
|
252
|
+
}
|
|
253
|
+
if (emit_ll) {
|
|
254
|
+
b.getInstallStep().dependOn(&b.addInstallFileWithDir(
|
|
255
|
+
lib.getEmittedLlvmIr(),
|
|
256
|
+
.prefix,
|
|
257
|
+
b.fmt("{s}.ll", .{name}),
|
|
258
|
+
).step);
|
|
259
|
+
}
|
|
149
260
|
b.installArtifact(lib);
|
|
150
261
|
c = true;
|
|
151
262
|
}
|
|
152
263
|
|
|
153
264
|
if (c) {
|
|
154
|
-
const
|
|
155
|
-
.{ .path = "src/include/pkmn.h" }
|
|
156
|
-
|
|
157
|
-
"pkmn.h",
|
|
158
|
-
);
|
|
265
|
+
const path =
|
|
266
|
+
if (has_path) .{ .path = "src/include/pkmn.h" } else b.path("src/include/pkmn.h");
|
|
267
|
+
const header = b.addInstallFileWithDir(path, .header, "pkmn.h");
|
|
159
268
|
b.getInstallStep().dependOn(&header.step);
|
|
160
269
|
|
|
161
270
|
const pc = b.fmt("lib{s}.pc", .{name});
|
|
162
|
-
const file = try
|
|
271
|
+
const file = try std.fs.path.relative(
|
|
272
|
+
b.allocator,
|
|
273
|
+
try std.process.getCwdAlloc(b.allocator),
|
|
274
|
+
try b.cache_root.join(b.allocator, &.{pc}),
|
|
275
|
+
);
|
|
163
276
|
const pkgconfig_file = try std.fs.cwd().createFile(file, .{});
|
|
164
277
|
|
|
165
278
|
const dirname = comptime std.fs.path.dirname(@src().file) orelse ".";
|
|
@@ -192,7 +305,7 @@ pub fn build(b: *std.Build) !void {
|
|
|
192
305
|
// TODO: tests can be run multiple times due to @imports
|
|
193
306
|
const tests = TestStep.create(b, options, config);
|
|
194
307
|
|
|
195
|
-
var exes = std.ArrayList(*
|
|
308
|
+
var exes = std.ArrayList(*Step.Compile).init(b.allocator);
|
|
196
309
|
const tools: ToolConfig = .{
|
|
197
310
|
.options = .{
|
|
198
311
|
.showdown = showdown,
|
|
@@ -200,6 +313,7 @@ pub fn build(b: *std.Build) !void {
|
|
|
200
313
|
.chance = chance,
|
|
201
314
|
.calc = calc,
|
|
202
315
|
},
|
|
316
|
+
.module = pkmn,
|
|
203
317
|
.general = config,
|
|
204
318
|
.tool = .{
|
|
205
319
|
.tests = if (tests.build) tests else null,
|
|
@@ -210,41 +324,43 @@ pub fn build(b: *std.Build) !void {
|
|
|
210
324
|
var benchmark_config = tools;
|
|
211
325
|
benchmark_config.general.optimize = .ReleaseFast;
|
|
212
326
|
benchmark_config.general.strip = true;
|
|
213
|
-
const benchmark = tool(b, "src/test/benchmark.zig", benchmark_config);
|
|
327
|
+
const benchmark = try tool(b, "src/test/benchmark.zig", benchmark_config);
|
|
214
328
|
|
|
215
329
|
var fuzz_config = tools;
|
|
216
330
|
fuzz_config.general.strip = false;
|
|
217
331
|
fuzz_config.tool.name = "fuzz";
|
|
218
|
-
const fuzz = tool(b, "src/test/fuzz.zig", fuzz_config);
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
const
|
|
222
|
-
const transitions = tool(b, "src/tools/transitions.zig", tools);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
if (
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
b.step("
|
|
230
|
-
b.step("
|
|
231
|
-
b.step("
|
|
232
|
-
b.step("
|
|
233
|
-
b.step("serde", "Run serialization/deserialization tool").dependOn(&
|
|
332
|
+
const fuzz = try tool(b, "src/test/fuzz.zig", fuzz_config);
|
|
333
|
+
|
|
334
|
+
const analyze = try tool(b, "src/tools/analyze.zig", tools);
|
|
335
|
+
const dump = try tool(b, "src/tools/dump.zig", tools);
|
|
336
|
+
const transitions = try tool(b, "src/tools/transitions.zig", tools);
|
|
337
|
+
|
|
338
|
+
// FIXME: serde randomly fails to build in some release configurations
|
|
339
|
+
var hack = tools;
|
|
340
|
+
if (optimize != .Debug) hack.tool.tests = null;
|
|
341
|
+
const serde = try tool(b, "src/tools/serde.zig", hack);
|
|
342
|
+
|
|
343
|
+
if (analyze) |t| b.step("analyze", "Run LLVM analysis tool").dependOn(&t.step);
|
|
344
|
+
if (benchmark) |t| b.step("benchmark", "Run benchmark code").dependOn(&t.step);
|
|
345
|
+
if (dump) |t| b.step("dump", "Run protocol dump tool").dependOn(&t.step);
|
|
346
|
+
if (fuzz) |t| b.step("fuzz", "Run fuzz tester").dependOn(&t.step);
|
|
347
|
+
if (serde) |t| b.step("serde", "Run serialization/deserialization tool").dependOn(&t.step);
|
|
234
348
|
b.step("test", "Run all tests").dependOn(&tests.step);
|
|
235
349
|
b.step("tools", "Install tools").dependOn(&ToolsStep.create(b, &exes).step);
|
|
236
|
-
|
|
350
|
+
if (transitions) |t| {
|
|
351
|
+
b.step("transitions", "Visualize transitions algorithm search").dependOn(&t.step);
|
|
352
|
+
}
|
|
237
353
|
}
|
|
238
354
|
|
|
239
355
|
fn maybeStrip(
|
|
240
356
|
b: *std.Build,
|
|
241
|
-
artifact: *
|
|
357
|
+
artifact: *Step.Compile,
|
|
242
358
|
step: *std.Build.Step,
|
|
243
|
-
strip: bool,
|
|
359
|
+
strip: ?bool,
|
|
244
360
|
cmd: ?[]const u8,
|
|
245
361
|
) void {
|
|
246
|
-
artifact.strip = strip;
|
|
247
|
-
if (!strip or cmd == null) return;
|
|
362
|
+
if (@hasDecl(@TypeOf(artifact.*), "strip")) artifact.strip = strip orelse false;
|
|
363
|
+
if (!(strip orelse false) or cmd == null) return;
|
|
248
364
|
// Using `strip -r -u` for dynamic libraries is supposed to work on macOS but doesn't...
|
|
249
365
|
const mac = builtin.os.tag == .macos;
|
|
250
366
|
if (mac and artifact.isDynamicLibrary()) return;
|
|
@@ -256,83 +372,104 @@ fn maybeStrip(
|
|
|
256
372
|
}
|
|
257
373
|
|
|
258
374
|
const Config = struct {
|
|
259
|
-
target:
|
|
375
|
+
target: ResolvedTarget,
|
|
260
376
|
optimize: std.builtin.OptimizeMode,
|
|
261
|
-
pic: bool,
|
|
262
|
-
strip: bool,
|
|
377
|
+
pic: ?bool,
|
|
378
|
+
strip: ?bool,
|
|
263
379
|
cmd: ?[]const u8,
|
|
264
380
|
};
|
|
265
381
|
|
|
266
|
-
const TESTS = .{
|
|
267
|
-
"src/lib/common/test.zig",
|
|
268
|
-
"src/lib/gen1/test.zig",
|
|
269
|
-
"src/lib/gen2/test.zig",
|
|
270
|
-
};
|
|
271
|
-
|
|
272
382
|
const TestStep = struct {
|
|
273
383
|
step: std.Build.Step,
|
|
274
384
|
build: bool,
|
|
275
385
|
|
|
276
|
-
pub fn create(b: *std.Build, options: *
|
|
386
|
+
pub fn create(b: *std.Build, options: *Step.Options, config: Config) *TestStep {
|
|
277
387
|
const coverage = b.option([]const u8, "test-coverage", "Generate test coverage");
|
|
278
|
-
const test_file = b.option([]const u8, "test-file", "Input file for test");
|
|
279
388
|
const test_filter =
|
|
280
389
|
b.option([]const u8, "test-filter", "Skip tests that do not match filter");
|
|
281
390
|
|
|
282
391
|
const self = b.allocator.create(TestStep) catch @panic("OOM");
|
|
283
392
|
const step = std.Build.Step.init(.{ .id = .custom, .name = "Run all tests", .owner = b });
|
|
284
|
-
self.* =
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
393
|
+
self.* = .{ .step = step, .build = test_filter == null };
|
|
394
|
+
|
|
395
|
+
const path = if (has_path) .{ .path = "src/lib/test.zig" } else b.path("src/lib/test.zig");
|
|
396
|
+
const tests = b.addTest(if (force_pic) .{
|
|
397
|
+
.root_source_file = path,
|
|
398
|
+
.optimize = config.optimize,
|
|
399
|
+
.target = config.target,
|
|
400
|
+
.filter = test_filter,
|
|
401
|
+
} else .{
|
|
402
|
+
.root_source_file = path,
|
|
403
|
+
.optimize = config.optimize,
|
|
404
|
+
.target = config.target,
|
|
405
|
+
.filter = test_filter,
|
|
406
|
+
.single_threaded = true,
|
|
407
|
+
.strip = config.strip,
|
|
408
|
+
.pic = config.pic,
|
|
409
|
+
});
|
|
410
|
+
(if (root_module) tests.root_module else tests).addOptions("build_options", options);
|
|
411
|
+
|
|
412
|
+
maybeStrip(b, tests, &tests.step, config.strip, config.cmd);
|
|
413
|
+
if (force_pic) {
|
|
298
414
|
tests.single_threaded = true;
|
|
299
|
-
|
|
300
|
-
if (config.pic) tests.force_pic = config.pic;
|
|
301
|
-
if (coverage) |c| {
|
|
302
|
-
tests.setExecCmd(&.{ "kcov", "--include-pattern=src/lib", c, null });
|
|
303
|
-
}
|
|
304
|
-
self.step.dependOn(&b.addRunArtifact(tests).step);
|
|
415
|
+
if (config.pic orelse false) tests.force_pic = config.pic;
|
|
305
416
|
}
|
|
417
|
+
if (coverage) |c| {
|
|
418
|
+
tests.setExecCmd(&.{ "kcov", "--include-pattern=src/lib", c, null });
|
|
419
|
+
}
|
|
420
|
+
self.step.dependOn(&b.addRunArtifact(tests).step);
|
|
421
|
+
|
|
306
422
|
return self;
|
|
307
423
|
}
|
|
308
424
|
};
|
|
309
425
|
|
|
310
426
|
const ToolConfig = struct {
|
|
311
427
|
options: Options,
|
|
428
|
+
module: ?*std.Build.Module,
|
|
312
429
|
general: Config,
|
|
313
430
|
tool: struct {
|
|
314
431
|
tests: ?*TestStep,
|
|
315
432
|
name: ?[]const u8 = null,
|
|
316
|
-
exes: *std.ArrayList(*
|
|
433
|
+
exes: *std.ArrayList(*Step.Compile),
|
|
317
434
|
},
|
|
318
435
|
};
|
|
319
436
|
|
|
320
|
-
fn tool(b: *std.Build, path: []const u8, config: ToolConfig)
|
|
437
|
+
fn tool(b: *std.Build, path: []const u8, config: ToolConfig) !?*Step.Run {
|
|
438
|
+
std.fs.cwd().access(path, .{}) catch |err| switch (err) {
|
|
439
|
+
error.FileNotFound => return null,
|
|
440
|
+
else => |e| return e,
|
|
441
|
+
};
|
|
321
442
|
var name = config.tool.name orelse std.fs.path.basename(path);
|
|
322
443
|
const index = std.mem.lastIndexOfScalar(u8, name, '.');
|
|
323
444
|
if (index) |i| name = name[0..i];
|
|
324
445
|
if (config.options.showdown orelse false) name = b.fmt("{s}-showdown", .{name});
|
|
325
446
|
|
|
326
|
-
const exe = b.addExecutable(.{
|
|
447
|
+
const exe = b.addExecutable(if (force_pic) .{
|
|
448
|
+
.name = name,
|
|
449
|
+
.root_source_file = if (has_path) .{ .path = path } else b.path(path),
|
|
450
|
+
.target = config.general.target,
|
|
451
|
+
.optimize = config.general.optimize,
|
|
452
|
+
} else .{
|
|
327
453
|
.name = name,
|
|
328
|
-
.root_source_file = .{ .path = path },
|
|
454
|
+
.root_source_file = if (has_path) .{ .path = path } else b.path(path),
|
|
329
455
|
.target = config.general.target,
|
|
330
456
|
.optimize = config.general.optimize,
|
|
457
|
+
.single_threaded = true,
|
|
458
|
+
.strip = config.general.strip,
|
|
459
|
+
.pic = config.general.pic,
|
|
331
460
|
});
|
|
332
|
-
exe.addModule("pkmn", module(b, config.options));
|
|
333
461
|
|
|
334
|
-
|
|
335
|
-
|
|
462
|
+
if (root_module) {
|
|
463
|
+
const import = if (config.module) |m| m else module(b, config.options);
|
|
464
|
+
exe.root_module.addImport("pkmn", import);
|
|
465
|
+
} else {
|
|
466
|
+
exe.addModule("pkmn", module(b, config.options));
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (force_pic) {
|
|
470
|
+
exe.single_threaded = true;
|
|
471
|
+
if (config.general.pic orelse false) exe.force_pic = config.general.pic;
|
|
472
|
+
}
|
|
336
473
|
if (config.tool.tests) |ts| ts.step.dependOn(&exe.step);
|
|
337
474
|
config.tool.exes.append(exe) catch @panic("OOM");
|
|
338
475
|
|
|
@@ -346,11 +483,16 @@ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) *std.Build.RunStep
|
|
|
346
483
|
const ToolsStep = struct {
|
|
347
484
|
step: std.Build.Step,
|
|
348
485
|
|
|
349
|
-
pub fn create(b: *std.Build, exes: *std.ArrayList(*
|
|
486
|
+
pub fn create(b: *std.Build, exes: *std.ArrayList(*Step.Compile)) *ToolsStep {
|
|
350
487
|
const self = b.allocator.create(ToolsStep) catch @panic("OOM");
|
|
351
488
|
const step = std.Build.Step.init(.{ .id = .custom, .name = "Install tools", .owner = b });
|
|
352
|
-
self.* =
|
|
353
|
-
for (exes.items) |t| self.step.dependOn(&b.addInstallArtifact(t).step);
|
|
489
|
+
self.* = .{ .step = step };
|
|
490
|
+
for (exes.items) |t| self.step.dependOn(&b.addInstallArtifact(t, .{}).step);
|
|
354
491
|
return self;
|
|
355
492
|
}
|
|
356
493
|
};
|
|
494
|
+
|
|
495
|
+
fn detect(target: anytype) std.Target {
|
|
496
|
+
if (@hasField(@TypeOf(target), "result")) return target.result;
|
|
497
|
+
return (std.zig.system.NativeTargetInfo.detect(target) catch unreachable).target;
|
|
498
|
+
}
|