Skip to content

Commit

Permalink
Merge pull request #9 from KusionStack/dev/peefy/feat_add_plugin_subm…
Browse files Browse the repository at this point in the history
…odule

feat: add plugins submodule.
  • Loading branch information
zong-zhe committed May 13, 2022
2 parents f6b831b + a20df19 commit 6479545
Show file tree
Hide file tree
Showing 12 changed files with 1,141 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/github-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v3
# with:
# submodules: 'true'
with:
submodules: 'true'
- name: Build KCLVM
run: make build
shell: bash
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ _a.out.*
_a.out_*.*
# KCLVM cache
.kclvm
__main__.*
__main__.dylib
__main__.so
__main__.dll
__main__.lock
__main__.ll
__main__.ll.lock
5 changes: 5 additions & 0 deletions internal/kclvm_py/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2021 The KCL Authors. All rights reserved.

import kclvm.internal.kclvm_internal.main as main

main.Main()
27 changes: 27 additions & 0 deletions internal/kclvm_py/api/version/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2021 The KCL Authors. All rights reserved.

import sys

import kclvm.api.version as version

USAGE = """\
usage: kclvm -m kclvm.api.version
kclvm -m kclvm.api.version -checksum
kclvm -m kclvm.api.version -h
"""

if __name__ == "__main__":
if len(sys.argv) == 2 and (sys.argv[1] == "-h" or sys.argv[1] == "-help"):
print(USAGE)
sys.exit(0)

if len(sys.argv) == 2 and sys.argv[1] == "-checksum":
print(version.CHECKSUM)
sys.exit(0)

if len(sys.argv) > 1:
print(USAGE)
sys.exit(1)

print(version.VERSION)
sys.exit(0)
52 changes: 52 additions & 0 deletions internal/kclvm_py/internal/kclx/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2021 The KCL Authors. All rights reserved.

import sys
from dataclasses import dataclass

import kclvm.compiler.parser as parser
import kclvm.compiler.build.compiler as compiler

from .transformer import transform_ast_to_kclx_ast_json_str

USAGE = """\
usage: kclvm -m kclvm.internal.kclx -f=<file>
usage: kclvm -m kclvm.internal.kclx -h
"""


@dataclass
class CmdFlags:
help: bool = False
file: str = ""


def parse_flags(args: list) -> CmdFlags:
m = CmdFlags()
for s in args:
if s == "-h" or s == "-help":
m.help = True
continue

if s.startswith("-f="):
value = s[len("-f=") :]
m.file = value
continue

return m


def main():
flags = parse_flags(sys.argv[1:])

if flags.help:
print(USAGE)
sys.exit(0)

if flags.file:
ast_prog = parser.LoadProgram(*flags.file.split(","))
compiler.FixAndResolveProgram(ast_prog)
print(transform_ast_to_kclx_ast_json_str(ast_prog))


if __name__ == "__main__":
main()
Loading

0 comments on commit 6479545

Please sign in to comment.