Skip to content

Commit 43c7cdf

Browse files
committed
Backported some changes from 4.1 branch
1 parent f89fab6 commit 43c7cdf

File tree

3 files changed

+72
-26
lines changed

3 files changed

+72
-26
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: build
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches: [ master ]
67
pull_request:
@@ -13,7 +14,7 @@ jobs:
1314
matrix:
1415
os:
1516
- ubuntu-20.04
16-
# macos-10.15
17+
- macos-10.15
1718
- windows-2022
1819
runs-on: ${{ matrix.os }}
1920
timeout-minutes: 30
@@ -40,7 +41,27 @@ jobs:
4041
- name: Run tests
4142
timeout-minutes: 10
4243
shell: bash
43-
if: ${{ runner.os != 'Windows' }}
4444
run: |
4545
export KSCRIPT_HOME="$GITHUB_WORKSPACE"
46-
./test/test_suite.sh
46+
47+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
48+
./test/linux_suite.sh
49+
elif [[ "$OSTYPE" == "darwin"* ]]; then
50+
kscript --help
51+
kscript "println(1+1)"
52+
elif [[ "$OSTYPE" == "cygwin" ]]; then
53+
kscript --help
54+
kscript "println(1+1)"
55+
elif [[ "$OSTYPE" == "msys" ]]; then
56+
kscript --help
57+
kscript "println(1+1)"
58+
elif [[ "$OSTYPE" == "win32" ]]; then
59+
kscript --help
60+
kscript "println(1+1)"
61+
elif [[ "$OSTYPE" == "freebsd"* ]]; then
62+
kscript --help
63+
kscript "println(1+1)"
64+
else
65+
echo "Unknown OS"
66+
exit 1
67+
fi

.github/workflows/installer.yml

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: installer
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
kscript_version:
7+
description: 'KScript version to test'
8+
required: true
9+
default: '4.0.2'
510

611
jobs:
712
build:
@@ -14,6 +19,8 @@ jobs:
1419
- windows-2022
1520
runs-on: ${{ matrix.os }}
1621
timeout-minutes: 30
22+
env:
23+
KSCRIPT_VERSION: ${{ github.event.inputs.kscript_version }}
1724

1825
steps:
1926
- uses: actions/checkout@v2
@@ -25,32 +32,45 @@ jobs:
2532
with:
2633
version: 1.6.21
2734

28-
- name: Install dependencies for ${{ runner.os }}
35+
- name: Prerequisites for ${{ runner.os }}
2936
shell: bash
3037
run: |
3138
if [ "$RUNNER_OS" == "Windows" ]; then
3239
choco install zip
3340
# Overwrite the WSL bash.exe
3441
cp /c/msys64/usr/bin/bash.exe /c/Windows/System32/bash.exe
35-
elif [ "$RUNNER_OS" == "Linux" ]; then
36-
# SDK man is enough?
37-
elif [ "$RUNNER_OS" == "macOS" ]; then
38-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
39-
else
40-
echo "Unknown OS"
41-
exit 1
4242
fi
4343
4444
- name: Install sdkman
4545
shell: bash
4646
run: |
4747
bash -c "curl -s "https://get.sdkman.io" | bash"
48-
source "$HOME/.sdkman/bin/sdkman-init.sh"
48+
source "$HOME/.sdkman/bin/sdkman-init.sh"
4949
50-
- name: Run install/uninstall tests
51-
timeout-minutes: 10
50+
- name: Test installers for ${{ runner.os }}
5251
shell: bash
5352
run: |
54-
sdk install kscript 4.0.2
55-
kscript
56-
sdk uninstall kscript 4.0.2
53+
echo "Bash path: $(which bash)"
54+
55+
# sdkman
56+
source "$HOME/.sdkman/bin/sdkman-init.sh"
57+
sdk install kscript ${{ env.KSCRIPT_VERSION }}
58+
kscript --help
59+
kscript -d "println(1+1)"
60+
sdk uninstall kscript ${{ env.KSCRIPT_VERSION }}
61+
62+
if [ "$RUNNER_OS" == "Windows" ]; then
63+
true
64+
elif [ "$RUNNER_OS" == "Linux" ]; then
65+
true
66+
elif [ "$RUNNER_OS" == "macOS" ]; then
67+
# brew
68+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
69+
brew install holgerbrandl/tap/kscript
70+
kscript --help
71+
kscript -d "println(1+1)"
72+
brew uninstall holgerbrandl/tap/kscript
73+
else
74+
echo "Unknown OS"
75+
exit 1
76+
fi

src/main/kotlin/kscript/app/resolver/CommandResolver.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,26 @@ class CommandResolver(private val config: Config, private val script: Script) {
2222

2323
//<command_path>kotlinc -classpath "p1:p2"
2424
//OS Conversion matrix
25-
// command_path command_quoting classpath_path classpath_separator classpath_quoting files_path files_quoting main_class_quoting
26-
//LINUX native no native : " ?
27-
//GIT-BASH shell no native ; " ?
28-
//CYGWIN shell no native ; "
29-
//WINDOWS native no native ; "
30-
//MACOS ? ? ? ? ?
25+
// command_path command_quoting classpath_path classpath_separator classpath_quoting files_path files_quoting main_class_quoting @arg_file
26+
//LINUX native no native : " ? no
27+
//GIT-BASH shell no native ; " ? no
28+
//CYGWIN shell no native ; " no
29+
//WINDOWS native no native ; " yes
30+
//MACOS ? ? ? ? ? no
3131

3232

3333
//Path conversion (Cygwin/mingw): cygpath -u "c:\Users\Admin"; /cygdrive/c/ - Cygwin; /c/ - Mingw
3434
//uname --> CYGWIN_NT-10.0 or MINGW64_NT-10.0-19043
3535
//How to find if mingw/cyg/win (second part): https://stackoverflow.com/questions/40877323/quickly-find-if-java-was-launched-from-windows-cmd-or-cygwin-terminal
3636

3737
fun compileKotlin(jar: Path, dependencies: Set<Path>, filePaths: Set<Path>): String {
38-
val compilerOptsStr = resolveCompilerOpts(script.compilerOpts)
38+
val compilerOpts = resolveCompilerOpts(script.compilerOpts)
3939
val classpath = resolveClasspath(dependencies)
40-
val files = filePaths.joinToString(" ") { "\"${it.absolutePathString()}\"" }
40+
val jarFile = resolveJarFile(jar)
41+
val files = resolveFiles(filePaths)
4142
val kotlinc = resolveKotlinBinary("kotlinc")
4243

43-
return "$kotlinc $compilerOptsStr $classpath -d \"${jar.absolutePathString()}\" $files"
44+
return "$kotlinc $compilerOpts $classpath -d $jarFile $files"
4445
}
4546

4647
fun executeKotlin(jarArtifact: JarArtifact, dependencies: Set<Path>, userArgs: List<String>): String {
@@ -82,6 +83,10 @@ class CommandResolver(private val config: Config, private val script: Script) {
8283

8384
private fun resolveCompilerOpts(compilerOpts: Set<CompilerOpt>) = compilerOpts.joinToString(" ") { it.value }
8485

86+
private fun resolveJarFile(jar: Path): String = "'${jar.absolutePathString()}'"
87+
88+
private fun resolveFiles(filePaths: Set<Path>): String = filePaths.joinToString(" ") { "'${it.absolutePathString()}'" }
89+
8590
private fun resolveUserArgs(userArgs: List<String>) =
8691
userArgs.joinToString(" ") { "\"${it.replace("\"", "\\\"")}\"" }
8792

0 commit comments

Comments
 (0)