Skip to content

Commit 3f8101e

Browse files
authored
Merge branch 'Tencent:master' into test/1029
2 parents 0f81d69 + b801c8e commit 3f8101e

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

unity/cli/make.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,10 @@ async function runPuertsMake(cwd, options) {
406406
for(let opt in BackendConfig?.cmake_options){
407407
CmakeDArgs = CmakeDArgs.concat(` ${BackendConfig?.cmake_options[opt]}`)
408408
}
409+
410+
if (options.cmake_args) {
411+
CmakeDArgs += ` ${options.cmake_args}`;
412+
}
409413

410414
var outputFile = BuildConfig.hook(
411415
CMAKE_BUILD_PATH,

unity/cli/test.mjs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { cp, exec, mkdir, rm } from "@puerts/shell-util";
22
import assert from "assert";
33
import { existsSync, readFileSync, writeFileSync } from "fs";
44
import glob from "glob";
5-
import { basename, extname, join, relative } from "path";
5+
import { basename, extname, join, relative, dirname } from "path";
66
import runPuertsMake from "./make.mjs";
7+
import { execFileSync, spawnSync } from "child_process";
78

89
////////////// dotnet-test
910
function collectCSFilesAndMakeCompileConfig(dir, workdir, excludeGenerator) {
@@ -209,6 +210,14 @@ function getExeSuffix() {
209210
return "";
210211
}
211212

213+
function tryGetPythonFromPath() {
214+
try {
215+
const out = execFileSync('python', ['-c', 'import sys; print(sys.executable)'], { encoding: 'utf8' }).trim();
216+
if (out && existsSync(out)) return { exe: out, home: dirname(out) };
217+
} catch {}
218+
return null;
219+
}
220+
212221
export async function dotnetTest(cwd, backend, filter = '', thread_safe = false) {
213222
// 编译binary
214223
let dlls = await runPuertsMake(join(cwd, '../../native/puerts'), {
@@ -250,11 +259,14 @@ export async function dotnetTest(cwd, backend, filter = '', thread_safe = false)
250259
});
251260
dlls = dlls.concat(nodedlls);
252261

262+
const pyInfo = tryGetPythonFromPath();
263+
253264
const pydlls = await runPuertsMake(join(cwd, '../../native/papi-python'), {
254265
platform: getPlatform(),
255266
config: "Debug",
256267
arch: process.arch,
257-
thread_safe: thread_safe
268+
thread_safe: thread_safe,
269+
cmake_args: (pyInfo && pyInfo.exe) ? `-DPython3_EXECUTABLE="${pyInfo.exe}"` : undefined
258270
});
259271
dlls = dlls.concat(pydlls);
260272

0 commit comments

Comments
 (0)