mirror of
https://gitee.com/openharmony/developtools_ace_ets2bundle
synced 2024-11-23 16:39:56 +00:00
adapt SDK on openharmony
Issue: #IAM9CH Signed-off-by: wuhailong <wuhailong22@huawei.com> (cherry picked commit from <gitee.com//openharmony/developtools_ace_ets2bundle/commit/37656f8c3c3e2efe59264cae9915dcddbfbb4ba4>
This commit is contained in:
parent
b55c2437ed
commit
ee89769d35
@ -38,6 +38,7 @@ import {
|
||||
isBranchElimination
|
||||
} from '../utils';
|
||||
import {
|
||||
isHarmonyOs,
|
||||
isLinux,
|
||||
isMac,
|
||||
isWindows,
|
||||
@ -274,6 +275,10 @@ function processPlatformInfo(arkConfig: ArkConfig): void {
|
||||
arkConfig.aotCompilerPath = path.join(arkPlatformPath, 'bin', 'ark_aot_compiler');
|
||||
return;
|
||||
}
|
||||
if (isHarmonyOs()) {
|
||||
arkConfig.es2abcPath = path.join(arkPlatformPath, 'bin', 'es2abc');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function processCompatibleVersion(projectConfig: Object, arkConfig: ArkConfig): void {
|
||||
|
@ -60,6 +60,7 @@ const reset: string = '\u001b[39m';
|
||||
const WINDOWS: string = 'Windows_NT';
|
||||
const LINUX: string = 'Linux';
|
||||
const MAC: string = 'Darwin';
|
||||
const HARMONYOS: string = 'HarmonyOS';
|
||||
|
||||
export interface LogInfo {
|
||||
type: LogType,
|
||||
@ -503,10 +504,14 @@ export function isMac(): boolean {
|
||||
return os.type() === MAC;
|
||||
}
|
||||
|
||||
export function isHarmonyOs(): boolean {
|
||||
return os.type() === HARMONYOS;
|
||||
}
|
||||
|
||||
export function maxFilePathLength(): number {
|
||||
if (isWindows()) {
|
||||
return 32766;
|
||||
} else if (isLinux()) {
|
||||
} else if (isLinux() || isHarmonyOs()) {
|
||||
return 4095;
|
||||
} else if (isMac()) {
|
||||
return 1016;
|
||||
|
@ -18,6 +18,8 @@ import { expect } from 'chai';
|
||||
import mocha from 'mocha';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import sinon from 'sinon';
|
||||
import os from "os";
|
||||
|
||||
import {
|
||||
OBFUSCATION_TOOL,
|
||||
@ -38,6 +40,17 @@ import {
|
||||
MERGERABC_PATH,
|
||||
JS2ABC_PATH,
|
||||
AOTCOMPILER_PATH,
|
||||
WIN_ES2ABC_PATH,
|
||||
WIN_TS2ABC_PATH,
|
||||
WIN_MERGERABC_PATH,
|
||||
WIN_JS2ABC_PATH,
|
||||
WIN_AOTCOMPILER_PATH,
|
||||
MAC_ES2ABC_PATH,
|
||||
MAC_TS2ABC_PATH,
|
||||
MAC_MERGERABC_PATH,
|
||||
MAC_JS2ABC_PATH,
|
||||
MAC_AOTCOMPILER_PATH,
|
||||
ARKROOT_PATH,
|
||||
ARKCONFIG_TS2ABC_PATH
|
||||
} from '../mock/rollup_mock/path_config';
|
||||
import RollUpPluginMock from '../mock/rollup_mock/rollup_plugin_mock';
|
||||
@ -54,6 +67,11 @@ import {
|
||||
import { ArkObfuscator } from 'arkguard';
|
||||
import { UnobfuscationCollections } from 'arkguard/lib/utils/CommonCollections';
|
||||
|
||||
const WINDOWS: string = 'Windows_NT';
|
||||
const LINUX: string = 'Linux';
|
||||
const MAC: string = 'Darwin';
|
||||
const HARMONYOS: string = 'HarmonyOS';
|
||||
|
||||
mocha.describe('test process_ark_config file api', function () {
|
||||
mocha.before(function () {
|
||||
this.rollup = new RollUpPluginMock();
|
||||
@ -451,4 +469,64 @@ mocha.describe('test process_ark_config file api', function () {
|
||||
UnobfuscationCollections.clear();
|
||||
});
|
||||
});
|
||||
|
||||
mocha.it('6-1: test processPlatformInfo on windows', function () {
|
||||
this.rollup.build();
|
||||
const stub = sinon.stub(os, 'type').returns(WINDOWS);
|
||||
const arkConfig = initArkConfig(this.rollup.share.projectConfig);
|
||||
const expectEs2abcPath = path.join(ARKROOT_PATH, WIN_ES2ABC_PATH);
|
||||
const expectTs2abcPath = path.join(ARKROOT_PATH, WIN_TS2ABC_PATH);
|
||||
const expectMergeAbcPath = path.join(ARKROOT_PATH, WIN_MERGERABC_PATH);
|
||||
const expectJs2abcPath = path.join(ARKROOT_PATH, WIN_JS2ABC_PATH);
|
||||
const expectAotCompilerPath = path.join(ARKROOT_PATH, WIN_AOTCOMPILER_PATH);
|
||||
expect(arkConfig.es2abcPath === expectEs2abcPath).to.be.true;
|
||||
expect(arkConfig.ts2abcPath === expectTs2abcPath).to.be.true;
|
||||
expect(arkConfig.mergeAbcPath === expectMergeAbcPath).to.be.true;
|
||||
expect(arkConfig.js2abcPath === expectJs2abcPath).to.be.true;
|
||||
expect(arkConfig.aotCompilerPath === expectAotCompilerPath).to.be.true;
|
||||
stub.restore();
|
||||
});
|
||||
|
||||
mocha.it('6-2: test processPlatformInfo on linux', function () {
|
||||
this.rollup.build();
|
||||
const stub = sinon.stub(os, 'type').returns(LINUX);
|
||||
const arkConfig = initArkConfig(this.rollup.share.projectConfig);
|
||||
const expectEs2abcPath = path.join(ARKROOT_PATH, ES2ABC_PATH);
|
||||
const expectTs2abcPath = path.join(ARKROOT_PATH, TS2ABC_PATH);
|
||||
const expectMergeAbcPath = path.join(ARKROOT_PATH, MERGERABC_PATH);
|
||||
const expectJs2abcPath = path.join(ARKROOT_PATH, JS2ABC_PATH);
|
||||
const expectAotCompilerPath = path.join(ARKROOT_PATH, AOTCOMPILER_PATH);
|
||||
expect(arkConfig.es2abcPath === expectEs2abcPath).to.be.true;
|
||||
expect(arkConfig.ts2abcPath === expectTs2abcPath).to.be.true;
|
||||
expect(arkConfig.mergeAbcPath === expectMergeAbcPath).to.be.true;
|
||||
expect(arkConfig.js2abcPath === expectJs2abcPath).to.be.true;
|
||||
expect(arkConfig.aotCompilerPath === expectAotCompilerPath).to.be.true;
|
||||
stub.restore();
|
||||
});
|
||||
|
||||
mocha.it('6-3: test processPlatformInfo on mac', function () {
|
||||
this.rollup.build();
|
||||
const stub = sinon.stub(os, 'type').returns(MAC);
|
||||
const arkConfig = initArkConfig(this.rollup.share.projectConfig);
|
||||
const expectEs2abcPath = path.join(ARKROOT_PATH, MAC_ES2ABC_PATH);
|
||||
const expectTs2abcPath = path.join(ARKROOT_PATH, MAC_TS2ABC_PATH);
|
||||
const expectMergeAbcPath = path.join(ARKROOT_PATH, MAC_MERGERABC_PATH);
|
||||
const expectJs2abcPath = path.join(ARKROOT_PATH, MAC_JS2ABC_PATH);
|
||||
const expectAotCompilerPath = path.join(ARKROOT_PATH, MAC_AOTCOMPILER_PATH);
|
||||
expect(arkConfig.es2abcPath === expectEs2abcPath).to.be.true;
|
||||
expect(arkConfig.ts2abcPath === expectTs2abcPath).to.be.true;
|
||||
expect(arkConfig.mergeAbcPath === expectMergeAbcPath).to.be.true;
|
||||
expect(arkConfig.js2abcPath === expectJs2abcPath).to.be.true;
|
||||
expect(arkConfig.aotCompilerPath === expectAotCompilerPath).to.be.true;
|
||||
stub.restore();
|
||||
});
|
||||
|
||||
mocha.it('6-4: test processPlatformInfo on harmonyos', function () {
|
||||
this.rollup.build();
|
||||
const stub = sinon.stub(os, 'type').returns(HARMONYOS);
|
||||
const arkConfig = initArkConfig(this.rollup.share.projectConfig);
|
||||
const expectEs2abcPath = path.join(ARKROOT_PATH, ES2ABC_PATH);
|
||||
expect(arkConfig.es2abcPath === expectEs2abcPath).to.be.true;
|
||||
stub.restore();
|
||||
});
|
||||
});
|
@ -35,7 +35,17 @@ export const TS2ABC_PATH: string = '/build/src/index.js';
|
||||
export const MERGERABC_PATH: string = '/build/bin/merge_abc';
|
||||
export const JS2ABC_PATH: string = '/build/bin/js2abc';
|
||||
export const AOTCOMPILER_PATH: string = '/build/bin/ark_aot_compiler';
|
||||
export const ARKROOT_PATH: string = 'bin/ark';
|
||||
export const WIN_ES2ABC_PATH: string = '/build-win/bin/es2abc.exe';
|
||||
export const WIN_TS2ABC_PATH: string = '/build-win/src/index.js';
|
||||
export const WIN_MERGERABC_PATH: string = '/build-win/bin/merge_abc.exe';
|
||||
export const WIN_JS2ABC_PATH: string = '/build-win/bin/js2abc.exe';
|
||||
export const WIN_AOTCOMPILER_PATH: string = '/build-win/bin/ark_aot_compiler.exe';
|
||||
export const MAC_ES2ABC_PATH: string = '/build-mac/bin/es2abc';
|
||||
export const MAC_TS2ABC_PATH: string = '/build-mac/src/index.js';
|
||||
export const MAC_MERGERABC_PATH: string = '/build-mac/bin/merge_abc';
|
||||
export const MAC_JS2ABC_PATH: string = '/build-mac/bin/js2abc';
|
||||
export const MAC_AOTCOMPILER_PATH: string = '/build-mac/bin/ark_aot_compiler';
|
||||
export const ARKROOT_PATH: string = path.resolve(__dirname, '../../../../bin/ark')
|
||||
export const MODULE_TEST_PATH: string = `${PROJECT_ROOT}/testTsModuleRequest/src/main/ets/`;
|
||||
export const TEST_TS: string = 'src/main/ets/pages/test.ts';
|
||||
export const TEST_ETS: string = 'src/main/ets/pages/test.ets';
|
||||
|
Loading…
Reference in New Issue
Block a user