|
| 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