Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add plugins submodule. #9

Merged
merged 3 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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