idlize

Форк
0
68 строк · 2.5 Кб
1
/*
2
 * Copyright (c) 2024 Huawei Device Co., Ltd.
3
 * Licensed under the Apache License, Version 2.0 (the "License");
4
 * you may not use this file except in compliance with the License.
5
 * You may obtain a copy of the License at
6
 *
7
 * http://www.apache.org/licenses/LICENSE-2.0
8
 *
9
 * Unless required by applicable law or agreed to in writing, software
10
 * distributed under the License is distributed on an "AS IS" BASIS,
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 * See the License for the specific language governing permissions and
13
 * limitations under the License.
14
 */
15

16
import { IndentedPrinter } from "../../IndentedPrinter"
17
import { makeFileNameFromClassName } from "../FileGenerators"
18
import { MaterializedClass } from "../Materialized"
19
import { PeerClass } from "../PeerClass"
20
import { PeerLibrary } from "../PeerLibrary"
21

22

23
export class MesonVisitor {
24
    printer = new IndentedPrinter()
25

26
    constructor(
27
        protected library: PeerLibrary
28
    ) { }
29

30
    printPeerClassSourcePaths(clazz: PeerClass): void {
31
        const className = makeFileNameFromClassName(clazz.componentName)
32
        // TODO use names from Libace;
33
        this.printer.print(`'implementation/${className}_delegate.cpp',`)
34
        this.printer.print(`'generated/interface/${className}_modifier.cpp',`)
35
    }
36

37
    printMaterializedClassSourcePaths(clazz: MaterializedClass) {
38
        const className = makeFileNameFromClassName(clazz.className)
39
        // TODO use names from Libace;
40
        this.printer.print(`'implementation/${className}_delegate.cpp',`)
41
        this.printer.print(`'generated/interface/${className}_modifier.cpp',`)
42
    }
43

44
    // TODO: have a proper Peer module visitor
45
    printMesonBuildContent() {
46
        this.printer.print("generated_sources = files(")
47
        this.printer.pushIndent()
48
        this.printer.print(`'generated/interface/all_modifiers.cpp',`)
49
        this.library.files.forEach(file => {
50
            file.peers.forEach(clazz => this.printPeerClassSourcePaths(clazz))
51
        })
52
        this.library.materializedClasses.forEach(clazz => {
53
            this.printMaterializedClassSourcePaths(clazz)
54
        })
55
        this.printer.popIndent()
56
        this.printer.print(")")
57
        
58
        this.printer.print("")
59

60
        this.printer.print("generated_include_directories = include_directories('generated/interface')")
61
    }
62
}
63

64
export function printMesonBuild(peerLibrary: PeerLibrary): string {
65
    const visitor = new MesonVisitor(peerLibrary)
66
    visitor.printMesonBuildContent()
67
    return visitor.printer.getOutput().join("\n")
68
}

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.