aboutsummaryrefslogtreecommitdiff
path: root/3rdparty/link_gumbo_parser.nim
blob: 1cd69bce6fae6d819fd16b40c0ed0fe3f43af8d9 (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
import json
import os
import osproc
import strutils
import sequtils

# TODO: Does not support spaces in paths yet!

let
    jsonFilename = joinPath(getAppDir(), "nimcache", "compile_gumbo_parser.json")
    jsonNode = parseJson(readFile(jsonFilename))
    linkCmdOrig = getStr(jsonNode["linkcmd"])
    linkCmdPartsOrig = splitWhitespace(linkCmdOrig)
    linkCmdParts = filter(linkCmdPartsOrig) do (x: string) -> bool:
        let (_, base, ext) = splitFile(x)
        not(ext == ".o" and (startsWith(base, "stdlib_") or
                             endsWith(base, "compile_gumbo_parser")))
    command = linkCmdParts[0]
    args = linkCmdParts[1..^1]

removeFile("libcompile_gumbo_parser.a")

discard execProcess(command, args, nil, {poEchoCmd, poUsePath})

moveFile("libcompile_gumbo_parser.a", "libgumbo_parser.a")