提交 66e14eff 编写于 作者: fxy060608's avatar fxy060608

wip(uts): compiler

上级 c04bcd87
...@@ -72,12 +72,13 @@ export async function compile(filename: string) { ...@@ -72,12 +72,13 @@ export async function compile(filename: string) {
if (!compilerServer) { if (!compilerServer) {
return return
} }
const { getDefaultJar, compile } = compilerServer const { getDefaultJar, getKotlincHome, compile } = compilerServer
time = Date.now() time = Date.now()
const jarFile = resolveJarPath(kotlinFile) const jarFile = resolveJarPath(kotlinFile)
const options = { const options = {
kotlinc: resolveKotlincArgs( kotlinc: resolveKotlincArgs(
kotlinFile, kotlinFile,
getKotlincHome(),
getDefaultJar().concat(resolveLibs(filename)) getDefaultJar().concat(resolveLibs(filename))
), ),
d8: resolveD8Args(jarFile), d8: resolveD8Args(jarFile),
...@@ -100,7 +101,7 @@ export async function compile(filename: string) { ...@@ -100,7 +101,7 @@ export async function compile(filename: string) {
} }
} }
function resolveKotlincArgs(filename: string, jars: string[]) { function resolveKotlincArgs(filename: string, kotlinc: string, jars: string[]) {
return [ return [
filename, filename,
'-cp', '-cp',
...@@ -108,7 +109,7 @@ function resolveKotlincArgs(filename: string, jars: string[]) { ...@@ -108,7 +109,7 @@ function resolveKotlincArgs(filename: string, jars: string[]) {
'-d', '-d',
resolveJarPath(filename), resolveJarPath(filename),
'-kotlin-home', '-kotlin-home',
'/Applications/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/uniAppRun-Extension/kotlinc', kotlinc,
] ]
} }
...@@ -184,6 +185,7 @@ function resolveClassPath(jars: string[]) { ...@@ -184,6 +185,7 @@ function resolveClassPath(jars: string[]) {
const getCompilerServer = (): const getCompilerServer = ():
| { | {
getKotlincHome(): string
getDefaultJar(): string[] getDefaultJar(): string[]
compile( compile(
options: { kotlinc: string[]; d8: string[] }, options: { kotlinc: string[]; d8: string[] },
......
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const { parse, runBuild, bundle, UtsTarget } = require('../packages/uts/dist') const { parse, bundle } = require('../packages/uts/dist')
const projectDir = path.resolve(__dirname, '../packages/playground/uts') const projectDir = path.resolve(__dirname, '../packages/playground/uts')
let start = Date.now() let start = Date.now()
...@@ -36,4 +36,13 @@ bundle({ ...@@ -36,4 +36,13 @@ bundle({
}).then((res) => { }).then((res) => {
console.log('bundle: ' + (Date.now() - start) + 'ms') console.log('bundle: ' + (Date.now() - start) + 'ms')
console.log(JSON.stringify(res)) console.log(JSON.stringify(res))
console.log(
fs.readFileSync(
path.resolve(
projectDir,
'unpackage/dist/app/uni_modules/test-uniplugin/app-android/index.kt'
),
'utf8'
)
)
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册