Skip to content

Commit f6780f5

Browse files
committed
Merge branch 'main' into lhk_dev
2 parents f97c16f + 3847be1 commit f6780f5

File tree

1,051 files changed

+616284
-85
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,051 files changed

+616284
-85
lines changed

BUILD

+34-34
Original file line numberDiff line numberDiff line change
@@ -378,28 +378,28 @@ pkg_files(
378378
)
379379

380380
# Pack ArkTs artifacts
381-
# pkg_files(
382-
# name = "coref-arkts-lib-script-pkg",
383-
# srcs = [
384-
# "//language/arkts:lib",
385-
# ],
386-
# attributes = pkg_attributes(
387-
# mode = "0644",
388-
# ),
389-
# prefix = "lib/coref/arkts",
390-
# strip_prefix = strip_prefix.from_pkg() + "lib",
391-
# )
381+
pkg_files(
382+
name = "coref-arkts-lib-script-pkg",
383+
srcs = [
384+
"//language/arkts:lib",
385+
],
386+
attributes = pkg_attributes(
387+
mode = "0644",
388+
),
389+
prefix = "lib/coref/arkts",
390+
strip_prefix = strip_prefix.from_pkg() + "lib",
391+
)
392392

393-
# pkg_files(
394-
# name = "coref-arkts-src-extractor-pkg",
395-
# srcs = [
396-
# "//language/arkts/extractor:coref-arkts-src-extractor",
397-
# ],
398-
# attributes = pkg_attributes(
399-
# mode = "0755",
400-
# ),
401-
# prefix = "language/arkts/extractor",
402-
# )
393+
pkg_files(
394+
name = "coref-arkts-src-extractor-pkg",
395+
srcs = [
396+
"//language/arkts/extractor:coref-arkts-src-extractor",
397+
],
398+
attributes = pkg_attributes(
399+
mode = "0755",
400+
),
401+
prefix = "language/arkts/extractor",
402+
)
403403

404404
# Current pkg_tar/pkg_files rules can't pack a directory generated from genrule.
405405
# To workaround this, use the deprecated pkg_tar rule instead
@@ -506,7 +506,7 @@ coref_lib_script_pkgs = [
506506
":coref-cfamily-lib-script-pkg",
507507
":coref-properties-lib-script-pkg",
508508
":coref-sql-lib-script-pkg",
509-
# ":coref-arkts-lib-script-pkg",
509+
":coref-arkts-lib-script-pkg",
510510
]
511511

512512
coref_libscript_languages = [
@@ -519,7 +519,7 @@ coref_libscript_languages = [
519519
"properties",
520520
"sql",
521521
# "swift",
522-
# "arkts",
522+
"arkts",
523523
]
524524

525525
copy_to_directory(
@@ -626,15 +626,15 @@ copy_to_directory(
626626
# visibility = ["//visibility:public"],
627627
# )
628628

629-
# copy_to_directory(
630-
# name = "copy-arkts-lib-script",
631-
# srcs = [
632-
# "//language/arkts:lib",
633-
# ],
634-
# out = "lib/coref/arkts",
635-
# replace_prefixes = {"language/arkts/lib": ""},
636-
# visibility = ["//visibility:public"],
637-
# )
629+
copy_to_directory(
630+
name = "copy-arkts-lib-script",
631+
srcs = [
632+
"//language/arkts:lib",
633+
],
634+
out = "lib/coref/arkts",
635+
replace_prefixes = {"language/arkts/lib": ""},
636+
visibility = ["//visibility:public"],
637+
)
638638

639639
genrule(
640640
name = "coref-lib-script-gen",
@@ -650,7 +650,7 @@ genrule(
650650
":copy-sql-lib-script",
651651
":copy-cfamily-lib-script",
652652
# ":copy-swift-lib-script",
653-
# ":copy-arkts-lib-script",
653+
":copy-arkts-lib-script",
654654
],
655655
outs = ["lib/coref/%s.gdl" % language for language in coref_libscript_languages],
656656
cmd = """
@@ -680,7 +680,7 @@ pkg_tar(
680680
name = "sparrow-cli",
681681
srcs = [
682682
":coref-lib-pkg",
683-
# ":coref-arkts-src-extractor-pkg",
683+
":coref-arkts-src-extractor-pkg",
684684
# ":coref-go-src-extractor-pkg",
685685
":coref-sql-src-extractor-pkg",
686686
":coref-java-src-extractor-pkg",

README.md

+22-22
Original file line numberDiff line numberDiff line change
@@ -92,28 +92,28 @@ Note: The maturity level of the language status is determined based on the types
9292
## Tutorial
9393
- [Online Tutorial](./tutorial/README.en.md)
9494

95-
## Directory Structure Description
96-
- `cli`: The entry point for the command-line tool, providing a unified command-line interface, calling other modules to complete specific functions
97-
- `language`: Core data and data modeling (lib) for various languages. Regarding the degree of openness, please refer to the section "Some Notes on the Scope of Open Source"
98-
- `doc`: Reference documents
99-
- `examples`: Gödel query language examples
100-
- `tutorial`CodeFuse-Query Development Container Usage Tutorial
101-
102-
## Some Notes on the Scope of Open Source
103-
As of now, it is **not possible** to build an executable program from the source code because not all modules have been made open-source in this release, and missing modules will be released over the next year. Nevertheless, to ensure a complete experience, we have released **complete installation packages** for download, please see the Release page.
104-
Regarding the openness of languages, you can refer to the table below:
105-
106-
| Language | Data Modeling Open Source | Data Core Open Source | Maturity |
107-
| --- | --- | --- | --- |
108-
| Python | Y | Y | RELEASE |
109-
| Java | Y | Y | RELEASE |
110-
| JavaScript | Y | Y | RELEASE |
111-
| Go | Y | Y | RELEASE |
112-
| XML | Y | Y | RELEASE |
113-
| Cfamily | Y | Y | BETA |
114-
| SQL | Y | Y | BETA |
115-
| Swift | N | N | BETA |
116-
| Properties | Y | Y | BETA |
95+
96+
## Related Paper
97+
98+
Our work is described in the following paper:
99+
100+
[**CodeFuse-Query: A Data-Centric Static Code Analysis System for Large-Scale Organizations**](https://arxiv.org/abs/2401.01571)
101+
102+
## Citation
103+
104+
If you find **CodeFuse-Query** useful in your research, please cite our paper:
105+
106+
```bibtex
107+
@misc{xie2024codefusequerydatacentricstaticcode,
108+
title={CodeFuse-Query: A Data-Centric Static Code Analysis System for Large-Scale Organizations},
109+
author={Xiaoheng Xie and Gang Fan and Xiaojun Lin and Ang Zhou and Shijie Li and Xunjin Zheng and Yinan Liang and Yu Zhang and Na Yu and Haokun Li and Xinyu Chen and Yingzhuang Chen and Yi Zhen and Dejun Dong and Xianjin Fu and Jinzhou Su and Fuxiong Pan and Pengshuai Luo and Youzheng Feng and Ruoxiang Hu and Jing Fan and Jinguo Zhou and Xiao Xiao and Peng Di},
110+
year={2024},
111+
eprint={2401.01571},
112+
archivePrefix={arXiv},
113+
primaryClass={cs.SE},
114+
url={https://arxiv.org/abs/2401.01571},
115+
}
116+
```
117117

118118
## Contact Us
119119
![WeChat User Group Image](./assets/wechat_qrcode.JPG)

README_cn.md

-22
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,6 @@ CodeFuse-Query 包括**Sparrow CLI **和CodeFuse-Query**在线服务Query中心*
8484
## 教程 (tutorial)
8585
- [在线教程](./tutorial/README.md)
8686

87-
## 目录结构说明
88-
- `cli`:命令行工具的入口,提供统一的命令行接口,调用其他模块完成具体功能
89-
- `language`:各语言的数据化核心(extractor)和数据建模(lib)。关于开放度的问题,请参见《关于开源范围的一些说明》章节
90-
- `doc`:参考文档
91-
- `examples`:Gödel 查询语言示例
92-
- `tutorial`:CodeFuse-Query 开发容器使用教程
93-
94-
## 关于开源范围的一些说明
95-
截止目前,从源码**不能**构建出可执行的程序,原因在于本次开源并没有开放所有的模块,缺少的模块会在之后的一年陆续开源。尽管如此,为保障完整的体验,我们开放了**完整的安装包**下载,请见Release页面。
96-
关于语言的开放程度,可以查看下表:
97-
98-
| 语言 | 数据建模开源 | 数据化核心开源 | 成熟度 |
99-
| --- | --- | --- | --- |
100-
| Python | Y | Y | RELEASE |
101-
| Java | Y | Y | RELEASE |
102-
| JavaScript | Y | Y | RELEASE |
103-
| Go | Y | Y | RELEASE |
104-
| XML | Y | Y | RELEASE |
105-
| Cfamily | Y | Y | BETA |
106-
| SQL | Y | Y | BETA |
107-
| Swift | N | N | BETA |
108-
| Properties | Y | Y | BETA |
10987

11088
## 联系我们
11189
![微信用户群图片](./assets/wechat_qrcode.JPG)

WORKSPACE

+17
Original file line numberDiff line numberDiff line change
@@ -560,3 +560,20 @@ aspect_bazel_lib_dependencies()
560560
# sha256 = "d4292d9b898a9d264c3e8ea58c83074a63d0c8d84602f4a85b9dbb1b4dcd52ad",
561561
# urls = ["https://antsys-sparrow-data.cn-shanghai-alipay-office.oss-alipay.aliyuncs.com/sparrow/public/tools/swift/lib_InternalSwiftSyntaxParser/5.5.3-alios7/lib_InternalSwiftSyntaxParser.zip"],
562562
# )
563+
564+
565+
# third_party_typescript 4.9.5-raw Release
566+
# Replace with the third_party_typescript commit you want to use.
567+
third_party_typescript_commit = "5bef9c4ec07035be8167d8190f6df47275b81058"
568+
third_party_typescript_SHA256 = "e703a2ccb546e7fa78f0a0681cbc9569991b807247ff903bf6f0fe5304ec0fe9"
569+
570+
http_archive(
571+
name = "ohos_typescript_src",
572+
sha256 = third_party_typescript_SHA256,
573+
strip_prefix = "third_party_typescript-" + third_party_typescript_commit,
574+
build_file = "//:external/rules_ohos_typescript/ohos_typescript.BUILD",
575+
urls = [
576+
"https://gitee.com/openharmony/third_party_typescript/repository/archive/{commit}.zip".format(commit = third_party_typescript_commit),
577+
"https://antsys-sparrow-data.cn-shanghai-alipay-office.oss-alipay.aliyuncs.com/sparrow/public/tools/ohos-typescript/third_party_typescript-{commit}.zip".format(commit = third_party_typescript_commit),
578+
],
579+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
filegroup(
2+
name = "ohos_typescript",
3+
srcs = glob(["**/*"]),
4+
visibility = ["//visibility:public"],
5+
)
6+
7+
filegroup(
8+
name = "compile_typescript",
9+
srcs = [
10+
"compile_typescript.py",
11+
],
12+
visibility = ["//visibility:public"],
13+
)

godel-script/README.md

+23-7
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,39 @@ Structure of this project:
5252
+-- src godel-frontend source code
5353
```
5454

55+
### Environment
56+
5557
Need C++ standard at least `-std=c++17`.
5658

59+
On Ubuntu, you are expected to install the following packages before compiling.
60+
61+
```bash
62+
sudo apt install -y git build-essential libffi-dev m4 cmake libsqlite3-dev zlib1g-dev
63+
```
64+
65+
For convenience, we recommend directly using the [Dev Container plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) of VSCode. The configuration files are in `godel-script/.devcontainer/`.
66+
67+
5768
### Apply Patch On Soufflé Submodule
5869

59-
GödelScript uses a self-modified soufflé from a much older branch of public soufflé,
60-
now we use patch to make sure it could be built successfully.
70+
GödelScript uses a self-modified soufflé from a much older branch of public soufflé. Use these commands to clone.
71+
72+
```bash
73+
git submodule init
74+
git submodule update --recursive
75+
```
6176

62-
Use this command to apply patch:
77+
Now we use patch to make sure it could be built successfully. Use these commands to apply patch:
6378

6479
```bash
65-
cd souffle
80+
cd godel-backend/souffle
6681
git am ../0001-init-self-used-souffle-from-public-souffle.patch
6782
```
6883

6984
Use these commands to revert:
7085

7186
```bash
72-
cd souffle
87+
cd godel-backend/souffle
7388
git apply -R ../0001-init-self-used-souffle-from-public-souffle.patch
7489
git reset HEAD~
7590
```
@@ -79,8 +94,9 @@ git reset HEAD~
7994
Use command below:
8095

8196
```bash
82-
mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release
83-
make -j6
97+
mkdir build && cd build
98+
cmake .. -DCMAKE_BUILD_TYPE:STRING=Release
99+
cmake --build .
84100
```
85101

86102
After building, you'll find `build/godel` in the `build` folder.

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)