Skip to content
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
21 changes: 17 additions & 4 deletions install.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,24 @@ func InstallKclvm(installRoot string) error {
os.Setenv("PATH", os.Getenv("PATH")+":"+binPath)

// Run KCL CLI to install dependencies.
err = installBin(binPath, "kcl", kclScript, true)
if err != nil {
return err
scripts := map[string][]byte{
"kcl": kclScript,
"kclvm": kclvmScript,
"kcl-doc": kclDocScript,
"kcl-fmt": kclFmtScript,
"kcl-lint": kclLintScript,
"kcl-plugin": kclPluginScript,
"kcl-test": kclTestScript,
"kcl-vet": kclVetScript,
}
err = installBin(binPath, "kclvm", kclvmScript, false)
for n, script := range scripts {
err := installBin(binPath, n, script, false)
if err != nil {
return err
}
}
// Run KCL CLI to install dependencies.
err = installBin(binPath, "kcl", kclScript, true)
if err != nil {
return err
}
Expand Down
18 changes: 18 additions & 0 deletions kclvm_bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,21 @@ var kclScript []byte

//go:embed scripts/kclvm
var kclvmScript []byte

//go:embed scripts/kcl-doc
var kclDocScript []byte

//go:embed scripts/kcl-fmt
var kclFmtScript []byte

//go:embed scripts/kcl-lint
var kclLintScript []byte

//go:embed scripts/kcl-plugin
var kclPluginScript []byte

//go:embed scripts/kcl-test
var kclTestScript []byte

//go:embed scripts/kcl-vet
var kclVetScript []byte
28 changes: 28 additions & 0 deletions scripts/kcl-doc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# Stop on error.
set -e

# python3 path
python3_bin=`which python3`
kclvm_install_dir=$(cd `dirname $0`/..; pwd)
pip_install_done_file="$kclvm_install_dir/lib/site-packages/kclvm.requirements.done.txt"

# check python3
if [ -z "$python3_bin" ]; then
echo "python3 not found!"
exit 1
fi

# once: pip install
if [ ! -f $pip_install_done_file ]; then
# check python3 version
$python3_bin -c "import sys; sys.exit(0) if sys.version_info>=(3,7,3) else (print('please install python 3.7.3+') or sys.exit(1))"
# kclvm pip install all libs
$python3_bin -m pip install kclvm --user
echo 'done' > $pip_install_done_file
fi

export PYTHONPATH=$kclvm_install_dir/lib/site-packages
export KCLVM_CLI_BIN_PATH=$kclvm_install_dir/bin
$python3_bin -m kclvm.tools.docs "$@"
28 changes: 28 additions & 0 deletions scripts/kcl-fmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# Stop on error.
set -e

# python3 path
python3_bin=`which python3`
kclvm_install_dir=$(cd `dirname $0`/..; pwd)
pip_install_done_file="$kclvm_install_dir/lib/site-packages/kclvm.requirements.done.txt"

# check python3
if [ -z "$python3_bin" ]; then
echo "python3 not found!"
exit 1
fi

# once: pip install
if [ ! -f $pip_install_done_file ]; then
# check python3 version
$python3_bin -c "import sys; sys.exit(0) if sys.version_info>=(3,7,3) else (print('please install python 3.7.3+') or sys.exit(1))"
# kclvm pip install all libs
$python3_bin -m pip install kclvm --user
echo 'done' > $pip_install_done_file
fi

export PYTHONPATH=$kclvm_install_dir/lib/site-packages
export KCLVM_CLI_BIN_PATH=$kclvm_install_dir/bin
$python3_bin -m kclvm.tools.format "$@"
29 changes: 29 additions & 0 deletions scripts/kcl-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

# Stop on error.
set -e

# python3 path
python3_bin=`which python3`
kclvm_install_dir=$(cd `dirname $0`/..; pwd)
pip_install_done_file="$kclvm_install_dir/lib/site-packages/kclvm.requirements.done.txt"

# check python3
if [ -z "$python3_bin" ]; then
echo "python3 not found!"
exit 1
fi

# once: pip install
if [ ! -f $pip_install_done_file ]; then
# check python3 version
$python3_bin -c "import sys; sys.exit(0) if sys.version_info>=(3,7,3) else (print('please install python 3.7.3+') or sys.exit(1))"
# kclvm pip install all libs
$python3_bin -m pip install kclvm --user
echo 'done' > $pip_install_done_file
fi

export PYTHONPATH=$kclvm_install_dir/lib/site-packages
export KCLVM_CLI_BIN_PATH=$kclvm_install_dir/bin
$python3_bin -m kclvm.tools.lint "$@"

29 changes: 29 additions & 0 deletions scripts/kcl-plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

# Stop on error.
set -e

# python3 path
python3_bin=`which python3`
kclvm_install_dir=$(cd `dirname $0`/..; pwd)
pip_install_done_file="$kclvm_install_dir/lib/site-packages/kclvm.requirements.done.txt"

# check python3
if [ -z "$python3_bin" ]; then
echo "python3 not found!"
exit 1
fi

# once: pip install
if [ ! -f $pip_install_done_file ]; then
# check python3 version
$python3_bin -c "import sys; sys.exit(0) if sys.version_info>=(3,7,3) else (print('please install python 3.7.3+') or sys.exit(1))"
# kclvm pip install all libs
$python3_bin -m pip install kclvm --user
echo 'done' > $pip_install_done_file
fi

export PYTHONPATH=$kclvm_install_dir/lib/site-packages
export KCLVM_CLI_BIN_PATH=$kclvm_install_dir/bin
$python3_bin -m kclvm.tools.plugin "$@"

9 changes: 9 additions & 0 deletions scripts/kcl-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

kcl_go_path=$(cd `dirname $0`; pwd)/kcl-go
if [[ ! -f $kcl_go_path ]]; then
echo "kcl-go not found, please check the installation"
exit 1
fi
export PYTHONPATH=''
$kcl_go_path test "$@"
28 changes: 28 additions & 0 deletions scripts/kcl-vet
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# Stop on error.
set -e

# python3 path
python3_bin=`which python3`
kclvm_install_dir=$(cd `dirname $0`/..; pwd)
pip_install_done_file="$kclvm_install_dir/lib/site-packages/kclvm.requirements.done.txt"

# check python3
if [ -z "$python3_bin" ]; then
echo "python3 not found!"
exit 1
fi

# once: pip install
if [ ! -f $pip_install_done_file ]; then
# check python3 version
$python3_bin -c "import sys; sys.exit(0) if sys.version_info>=(3,7,3) else (print('please install python 3.7.3+') or sys.exit(1))"
# kclvm pip install all libs
$python3_bin -m pip install kclvm --user
echo 'done' > $pip_install_done_file
fi

export PYTHONPATH=$kclvm_install_dir/lib/site-packages
export KCLVM_CLI_BIN_PATH=$kclvm_install_dir/bin
$python3_bin -m kclvm.tools.validation "$@"