Skip to content

Commit

Permalink
Initial project
Browse files Browse the repository at this point in the history
  • Loading branch information
chai2010 committed May 13, 2022
1 parent 68d5103 commit f6b831b
Show file tree
Hide file tree
Showing 4,349 changed files with 220,140 additions and 1 deletion.
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[antflake8]
max-line-length = 120
select = C,E,F,W,B,B950
extend-ignore = F403, F405, E203, E501, W503
exclude = *_pb2.py, lark_token.py
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
- With issues:
- Use the search tool before opening a new issue.
- Please provide source code and commit sha if you found a bug.
- Review existing issues and provide feedback or react to them.

## Description

<!-- Description of a problem -->

## How to reproduce

<!-- The smallest possible code example to show the problem that can be compiled, like -->

TODO

## Expectations

<!-- Your expectation result of 'curl' command, like -->

TODO

## Actual result

<!-- Actual result showing the problem -->

TODO

## Environment

- KCLVM version:
- Operating system:
6 changes: 6 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- With pull requests:
- Open your pull request against `main`
- Your pull request should have no more than two commits, if not you should squash them.
- It should pass all tests in the available continuous integration systems such as GitHub Actions.
- You should add/modify tests to cover your proposed code changes.
- If your pull request contains a new feature, please document it on the README.
34 changes: 34 additions & 0 deletions .github/workflows/github-actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: KCLVM-actions
on: [push]
jobs:
test-unit:
name: Test
runs-on: ubuntu-latest
container:
image: kusionstack/kclvm-builder
steps:
- name: Check out code
uses: actions/checkout@v3
# with:
# submodules: 'true'
- name: Build KCLVM
run: make build
shell: bash
- name: Grammar test
run: |
chmod +x ./internal/kclvm_py/scripts/test_grammar.sh
topdir=$(realpath $(dirname $0)) ./internal/kclvm_py/scripts/test_grammar.sh
shell: bash
- name: Internal python unit test
run: |
chmod +x ./internal/kclvm_py/scripts/test_unit.sh
./internal/kclvm_py/scripts/test_unit.sh
shell: bash
# - name: Rust unit test
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# override: true
# components: rustfmt, clippy
# run: cd kclvm && make test
# shell: bash
81 changes: 81 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/build/
.vs/
.vscode/
.idea/

# kcl files
.pytest_cache
__pycache__
__kclcache__/
build-result/
dist/
kclvm.egg-info/
.eggs/

# Mac OS X files
.DS_Store

_python37_home_
_site-packages

__kcl_test_main.k

# kclvm bundles
/kclvm-*.zip
/kcl-go*
/_build_dist
.kusion

/venv/

# Coverage
.coverage
.coverage.*
/cover
/scripts/cover

/result

coverage.xml
TEST-kclvm.xml

/go-test-coverprofile.*

# Benchmark
.benchmarks

# Code check
.code_check

/_output

# Lark parser cache
lark_parser.pickle

/vendor
/_build*
/__build*
/_3rdparty


# Rust
*.o
*.a
*.so
*.orig
/target
/*/target
/*/*/target
/**/target

/kclvm/vendor
/scripts/docker/kclvm-builder/vendor*
/scripts/docker/kclvm-builder/crates.io-index
/scripts/docker/kclvm-builder-centos7/crates.io-index
/scripts/docker/kclvm-builder-ubuntu/crates.io-index
*.tar.gz
_a.out.*
_a.out_*.*
# KCLVM cache
.kclvm
__main__.*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "plugins"]
path = plugins
url = https://github.com/KusionStack/kcl-plugin
134 changes: 134 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# KCLVM Developing Guide

KCLVM follows a very standard Github development process, using Github tracker for issues and merging pull requests into master. If you would like to contribute something, or simply want to hack on the code this document should help you get started.

Before we accept a non-trivial patch or pull request we will need you to sign the Contributor License Agreement. Signing the contributor’s agreement does not grant anyone commits rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do. Active contributors might be asked to join the core team and given the ability to merge pull requests.

## Install Dependencies

### macOS and OS X

+ `Python3.7+`
+ `Go 1.16+`
+ `Rust 2021 edition`
+ `[email protected]`

```
brew install [email protected]
```

### Linux

+ `Go 1.16+`
+ `Rust 2021 edition`
+ `Python3 Building Dependencies`

For UNIX based systems, you can run:

```
yum groupinstall -y "Development Tools"
yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel ncurses-devel sqlite-devel
yum install -y libpcap-devel xz-devel readline-devel tk-devel gdbm-devel db4-deve
yum -y install yum-utils
yum-builddep -y python3
yum install -y zlib*
yum install -y openssl-devel
yum install -y glibc-static
```

On Debian, Ubuntu, and other apt based systems, you can run:

```
apt-get update
apt-get install -y git wget curl
apt-get install -y make gcc patch
apt-get install -y python-dev libffi-dev
apt-get install -y zlib1g-dev ncurses-dev build-essential libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev
```

### Docker

Use the image `kusionstack/kclvm-builder`, run:

```
make sh-in-docker
```

## Building and Testing

### Scripting

We provide a simple `run.sh` script to build and package with.

To build everything, run:

```
./run.sh -a build
```

Building includes two steps, which are `build-cpython` and `build-kclvm`. Alternatively, these steps can be invoked separately:

```
./run.sh -a build-cpython
./run.sh -a build-kclvm
```

Building KCL requires local ssl module. Use -s $yourLocalSSL to specify custom ssl path:

```
./run.sh -a build -s $your-local-ssl
./run.sh -a build-cpython -s $your-local-ssl
```

If -s option unset, default ssl path will be used:
Darwin: `$(brew --prefix [email protected])`
Linux: `/usr/lib64`

To use KCL, add the path `_build/dist/{os}/kclvm/bin` to the `PATH` environment variable. Here, `{os}` stands for the operating system, which can be `Darwin`, `centos`, `ubuntu` or other types.

Then, you can run:

```
kcl hello.k
```

To perform testing, run:

```
./run.sh -a test
```

Next, we can refer to [KCLVM README](./kclvm/README.md) for the next step of environment configuration and build the KCLVM rust code.

If we have changed any codes in the program, we can update kclvm binaries, run:

```
./run.sh -a update-kclvm
```

To build a tar file, run:

```
./run.sh -a release
```

## Using KCL

The specific user manual is as follows: [KCLVM User Manual](docs/cmd/README_KCLVM_USE.md)

## Code Structure

KCL has added the following files and directories:

+ `kclvm` - The KCL compiler code.
+ `test` - All KCL test cases include regression tests and unit tests.
+ `scripts` - The directory where additional scripts to build and test KCL resist.
+ `run.sh` - The script to perform operations such as building and testing.
+ `internal/kclvm_py` - KCLVM Python implementation, will be abandoned soon, please do not submit any code to it, it will be reorganized in the way of KCLVM Python SDK in the future.
+ `docs` - KCL command line Documentation.
+ `spec` - KCL model and API Specification.

During building and testing, the following directories can be generated:

+ `_build` - The directory to save building results including distributions.
Loading

0 comments on commit f6b831b

Please sign in to comment.