Skip to content

Commit 383f84b

Browse files
authored
Merge pull request #102 from yzhangem/dev
feat: add support for ArkTS
2 parents aa79262 + 7fcc894 commit 383f84b

File tree

1,045 files changed

+616175
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,045 files changed

+616175
-0
lines changed

language/arkts/BUILD

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load("//:visibility.bzl", "PUBLIC_VISIBILITY")
2+
3+
# Using filegroup is encouraged instead of referencing directories directly. The latter is unsound.
4+
# When combined with glob, filegroup can ensure that all files are explicitly known to the build system.
5+
6+
# Only one level of depth is matched, and the templates in the resource directory under lib-gen will not be matched.
7+
filegroup(
8+
name = "lib",
9+
srcs = glob(["lib/*"]),
10+
visibility = ["//visibility:public"],
11+
)

language/arkts/extractor/.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# IDEs
2+
.vscode
3+
.idea
4+
5+
# Dependency directory
6+
node_modules/
7+
8+
# Build
9+
dist/
10+
out/
11+
12+
# Bazel
13+
bazel-*
14+
15+
# SQLite
16+
*.db
17+
*.db-journal
18+
19+
# Coverage reports
20+
coverage
21+
22+
# API keys and secrets
23+
.env
24+
25+
# OS metadata
26+
.DS_Store

language/arkts/extractor/BUILD

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
load("//:visibility.bzl", "PUBLIC_VISIBILITY")
2+
3+
genrule(
4+
name = "ohos_typescript_compile",
5+
srcs = [],
6+
tools = [
7+
"@ohos_typescript_src//:compile_typescript"
8+
],
9+
outs = ["ohos-typescript"],
10+
cmd = """
11+
export OHOS_TYPESCRIPT_SRC=$$(dirname $$(pwd)/$(execpath @ohos_typescript_src//:compile_typescript))
12+
export OUTPUT_DIR=$$(dirname $$(pwd)/$@)
13+
export OHOS_TYPESCRIPT_SRC_CP=$$OUTPUT_DIR/ohos_typescript_src
14+
cp -r $$OHOS_TYPESCRIPT_SRC $$OUTPUT_DIR
15+
mkdir $(OUTS)
16+
# must change dir to src, then execute compile script
17+
cd $$OHOS_TYPESCRIPT_SRC_CP
18+
python3 compile_typescript.py . $$OUTPUT_DIR/ohos-typescript
19+
echo ohos_typescript build success: $$OUTPUT_DIR/ohos-typescript
20+
""",
21+
)
22+
23+
genrule(
24+
name = "build-coref-arkts-src-extractor",
25+
srcs = glob(["src/**/*.ts"]) + glob(["sdk/**/*"]) + [
26+
"schema.prisma",
27+
"package.json",
28+
"package-lock.json",
29+
"paths.json",
30+
"tsconfig.json",
31+
"@pkg_cache//:node-bin",
32+
] + [":ohos_typescript_compile"],
33+
tools = [
34+
"@nodejs_host//:npm_bin",
35+
],
36+
outs = [
37+
"coref-arkts-src-extractor",
38+
],
39+
cmd = """
40+
NPM_PATH="$$(pwd)/$(execpath @nodejs_host//:npm_bin)"
41+
echo NPM_PATH: $$NPM_PATH
42+
43+
export PKG_CACHE_PATH=$$(dirname $$(dirname $$(pwd)/$(execpath @pkg_cache//:node-bin)))
44+
echo PKG_CACHE_PATH: $$PKG_CACHE_PATH
45+
46+
OUT_PATH="$$(pwd)/$@"
47+
echo OUT_PATH: $$OUT_PATH
48+
49+
# 注意在下面cd前对需要拷贝的typescript进行路径确认
50+
export THIRD_TYPESCIRPT_PATH=$$(pwd)/$(location :ohos_typescript_compile)
51+
echo THIRD_TYPESCIRPT_PATH: $$THIRD_TYPESCIRPT_PATH
52+
53+
cd language/arkts/extractor
54+
55+
$$NPM_PATH i --registry https://registry.antgroup-inc.cn
56+
cp -rf $$THIRD_TYPESCIRPT_PATH ./node_modules/
57+
$$NPM_PATH run pkg
58+
mv coref-arkts-src-extractor $$OUT_PATH
59+
""",
60+
executable = 1,
61+
visibility = ["//visibility:public"],
62+
)

0 commit comments

Comments
 (0)