summaryrefslogtreecommitdiff
path: root/codegen.php
blob: a842b32d41978c11ea8143b84caddf8f3d8e5a36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

require_once __DIR__ . "/common.php";
$cg_dir = SRCDIR . "/codegen";
foreach (scandir($cg_dir) as $cg_ent) {
    $cg_path = $cg_dir . "/" . $cg_ent;
    if (
        $cg_ent[0] === "." ||
        !is_file($cg_path) ||
        strtolower(pathinfo($cg_ent, PATHINFO_EXTENSION)) !== "php"
    ) continue;
    echo "[codegen] $cg_ent ";
    $data = include $cg_path;
    if (!is_array($data) || count($data) !== 2) {
        trigger_error(
            "Invalid data returned from codegen script '$cg_ent'",
            E_USER_WARNING,
        );
        continue;
    }
    echo "-> $data[0]\n";
    file_put_contents(__DIR__ . "/build/" . $data[0], $data[1]);
}