servo/support/openharmony/hvigorfile.ts
Mukilan Thiyagarajan 157e28c59b
openharmony: add servoshell for ohos (#33295)
* openharmony: add servoshell for ohos

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* ohos: handle missing signing config on forks

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

---------

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-09-20 08:20:27 +00:00

34 lines
1.6 KiB
TypeScript

import { appTasks, OhosAppContext, OhosPluginId } from '@ohos/hvigor-ohos-plugin';
import { getNode } from '@ohos/hvigor'
import * as fs from 'fs';
import * as path from 'path';
const rootNode = getNode(__filename);
rootNode.afterNodeEvaluate(node => {
const appContext = node.getContext(OhosPluginId.OHOS_APP_PLUGIN) as OhosAppContext;
const buildProfileOpt = appContext.getBuildProfileOpt();
const signingConfigsPath = process.env["SERVO_OHOS_SIGNING_CONFIG"];
if (signingConfigsPath) {
if (!fs.existsSync(signingConfigsPath)) {
console.error("File referenced by SERVO_OHOS_SIGNING_CONFIG does not exist!");
return;
}
const basePath = path.dirname(signingConfigsPath);
const signingConfigs = JSON.parse(fs.readFileSync(signingConfigsPath));
for (const config of signingConfigs) {
config.material.certpath = path.resolve(basePath, config.material.certpath);
config.material.profile = path.resolve(basePath, config.material.profile);
config.material.storeFile = path.resolve(basePath, config.material.storeFile);
}
buildProfileOpt['app']['signingConfigs'] = signingConfigs;
} else {
console.log('Signing config not found in enviroment. hvigor will fallback to build-profile.json5.')
}
// Set the obj object back to the context object to enable the build process and results.
appContext.setBuildProfileOpt(buildProfileOpt);
})
export default {
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}