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
7
* http://www.apache.org/licenses/LICENSE-2.0
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.
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'
22
mkdir(path: string): string {
23
fs.mkdirSync(path, { recursive: true })
28
export class ArkoalaInstall extends Install {
29
constructor (private outDir: string, private lang: Language, private test: boolean) {
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")
40
createDirs(dirs: string[]) {
41
for (const dir of dirs) {
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)
54
component(targetFile: TargetFile): string {
55
return path.join(this.langDir(), targetFile.path ?? "", targetFile.name)
57
builderClass(targetFile: TargetFile): string {
58
return path.join(this.langDir(), targetFile.path ?? "", targetFile.name)
60
materialized(targetFile: TargetFile): string {
61
return path.join(this.langDir(), targetFile.path ?? "", targetFile.name)
63
interface(targetFile: TargetFile): string {
64
return path.join(this.langDir(), targetFile.path ?? "", targetFile.name)
66
langLib(targetFile: TargetFile) {
67
return path.join(this.langDir(), targetFile.path ?? "", targetFile.name + this.lang.extension)
69
tsLib(targetFile: TargetFile) {
70
return path.join(this.tsDir, targetFile.path ?? "", targetFile.name + this.lang.extension)
72
tsArkoalaLib(targetFile: TargetFile) {
73
return path.join(this.tsArkoalaDir, targetFile.path ?? "", targetFile.name + this.lang.extension)
75
arktsLib(targetFile: TargetFile) {
76
return path.join(this.arktsDir, targetFile.path ?? "", targetFile.name + this.lang.extension)
78
javaLib(targetFile: TargetFile) {
79
return path.join(this.javaDir, targetFile.path ?? "", targetFile.name + this.lang.extension)
81
native(targetFile: TargetFile) {
82
return path.join(this.nativeDir, targetFile.path ?? "", targetFile.name)
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")
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")
102
interface(name: string) {
103
return path.join(this.generatedInterface, name)
105
implementation(name: string) {
106
return path.join(this.implementationDir, name)
108
modifierHeader(component: string) {
109
return this.interface(`${component}_modifier.h`)
111
modifierCpp(component: string) {
112
return this.implementation(`${component}_modifier.cpp`)
114
delegateHeader(component: string) {
115
return this.interface(`${component}_delegate.h`)
117
delegateCpp(component: string) {
118
return this.implementation(`${component}_delegate.cpp`)