idlize

Форк
0
/
Install.ts 
120 строк · 4.9 Кб
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 * as fs from 'fs'
17
import * as path from 'path'
18
import { Language } from './util'
19
import { TargetFile } from './peer-generation/printers/TargetFile'
20

21
class Install {
22
    mkdir(path: string): string {
23
        fs.mkdirSync(path, { recursive: true })
24
        return path
25
    }
26
}
27

28
export class ArkoalaInstall extends Install {
29
    constructor (private outDir: string, private lang: Language, private test: boolean) {
30
        super()
31
    }
32
    langDir(): string {
33
        switch (this.lang) {
34
            case Language.TS: return this.tsDir
35
            case Language.ARKTS: return this.arktsDir
36
            case Language.JAVA: return this.javaDir
37
            default: throw new Error("unsupported")
38
        }
39
    }
40
    createDirs(dirs: string[]) {
41
        for (const dir of dirs) {
42
            this.mkdir(dir)
43
        }
44
    }
45
    koala = this.mkdir(this.test ? path.join(this.outDir, "koalaui") : this.outDir)
46
    tsDir = this.mkdir(path.join(this.koala, "arkoala-arkui/src/"))
47
    tsArkoalaDir = this.mkdir(path.join(this.koala, "arkoala/src/generated/"))
48
    arktsDir = this.mkdir(path.join(this.koala, "arkoala-arkui/arkts/src/"))
49
    nativeDir = this.mkdir(path.join(this.koala, "arkoala/native/src/generated/"))
50
    javaDir = this.mkdir(path.join(this.koala, "arkoala/java/src/"))
51
    peer(targetFile: TargetFile): string {
52
        return path.join(this.langDir(), targetFile.path ?? "", targetFile.name)
53
    }
54
    component(targetFile: TargetFile): string {
55
        return path.join(this.langDir(), targetFile.path ?? "", targetFile.name)
56
    }
57
    builderClass(targetFile: TargetFile): string {
58
        return path.join(this.langDir(), targetFile.path ?? "", targetFile.name)
59
    }
60
    materialized(targetFile: TargetFile): string {
61
        return path.join(this.langDir(), targetFile.path ?? "", targetFile.name)
62
    }
63
    interface(targetFile: TargetFile): string {
64
        return path.join(this.langDir(), targetFile.path ?? "", targetFile.name)
65
    }
66
    langLib(targetFile: TargetFile) {
67
        return path.join(this.langDir(), targetFile.path ?? "", targetFile.name + this.lang.extension)
68
    }
69
    tsLib(targetFile: TargetFile) {
70
        return path.join(this.tsDir, targetFile.path ?? "", targetFile.name + this.lang.extension)
71
    }
72
    tsArkoalaLib(targetFile: TargetFile) {
73
        return path.join(this.tsArkoalaDir, targetFile.path ?? "", targetFile.name + this.lang.extension)
74
    }
75
    arktsLib(targetFile: TargetFile) {
76
        return path.join(this.arktsDir, targetFile.path ?? "", targetFile.name + this.lang.extension)
77
    }
78
    javaLib(targetFile: TargetFile) {
79
        return path.join(this.javaDir, targetFile.path ?? "", targetFile.name + this.lang.extension)
80
    }
81
    native(targetFile: TargetFile) {
82
        return path.join(this.nativeDir, targetFile.path ?? "", targetFile.name)
83
    }
84
}
85

86
export class LibaceInstall extends Install {
87
    constructor(private outDir: string, private test: boolean) { super() }
88
    libace = this.mkdir(this.test ? path.join(this.outDir, "libace") : this.outDir)
89
    implementationDir = this.mkdir(path.join(this.libace, "implementation"))
90
    generatedInterface = this.mkdir(path.join(this.libace, "generated", "interface"))
91
    generatedUtility = this.mkdir(path.join(this.libace, "utility", "generated"))
92
    userConverterHeader = path.join(this.generatedUtility, "converter_generated.h")
93
    mesonBuild = path.join(this.libace, "meson.build")
94

95
    arkoalaMacros = this.interface("arkoala-macros.h")
96
    generatedArkoalaApi = this.interface("arkoala_api_generated.h")
97
    gniComponents = this.interface("node_interface.gni")
98
    viewModelBridge = this.implementation("view_model_bridge.cpp")
99
    allModifiers = this.implementation("all_modifiers.cpp")
100
    allEvents = this.implementation("all_events.cpp")
101

102
    interface(name: string) {
103
        return path.join(this.generatedInterface, name)
104
    }
105
    implementation(name: string) {
106
        return path.join(this.implementationDir, name)
107
    }
108
    modifierHeader(component: string) {
109
        return this.interface(`${component}_modifier.h`)
110
    }
111
    modifierCpp(component: string) {
112
        return this.implementation(`${component}_modifier.cpp`)
113
    }
114
    delegateHeader(component: string) {
115
        return this.interface(`${component}_delegate.h`)
116
    }
117
    delegateCpp(component: string) {
118
        return this.implementation(`${component}_delegate.cpp`)
119
    }
120
}
121

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

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

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

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