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

wip(uts): compiler

上级 c04bcd87
......@@ -72,12 +72,13 @@ export async function compile(filename: string) {
if (!compilerServer) {
return
}
const { getDefaultJar, compile } = compilerServer
const { getDefaultJar, getKotlincHome, compile } = compilerServer
time = Date.now()
const jarFile = resolveJarPath(kotlinFile)
const options = {
kotlinc: resolveKotlincArgs(
kotlinFile,
getKotlincHome(),
getDefaultJar().concat(resolveLibs(filename))
),
d8: resolveD8Args(jarFile),
......@@ -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 [
filename,
'-cp',
......@@ -108,7 +109,7 @@ function resolveKotlincArgs(filename: string, jars: string[]) {
'-d',
resolveJarPath(filename),
'-kotlin-home',
'/Applications/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/uniAppRun-Extension/kotlinc',
kotlinc,
]
}
......@@ -184,6 +185,7 @@ function resolveClassPath(jars: string[]) {
const getCompilerServer = ():
| {
getKotlincHome(): string
getDefaultJar(): string[]
compile(
options: { kotlinc: string[]; d8: string[] },
......
const fs = require('fs')
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')
let start = Date.now()
......@@ -36,4 +36,13 @@ bundle({
}).then((res) => {
console.log('bundle: ' + (Date.now() - start) + 'ms')
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.
先完成此消息的编辑!
想要评论请 注册