Skip to content

Commit

Permalink
Revert "Merge branch 'Localization_Monoceros' into Localization_Libra"
Browse files Browse the repository at this point in the history
This reverts commit e61f05e, reversing
changes made to 3572a99.
  • Loading branch information
JavierMatosD committed Oct 4, 2022
1 parent e61f05e commit 4653a3a
Show file tree
Hide file tree
Showing 62 changed files with 588 additions and 1,076 deletions.
4 changes: 2 additions & 2 deletions azure-pipelines/end-to-end-tests-dir/binarycaching.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Run-Vcpkg -TestArgs ($commonArgs + @("remove", "rapidjson", "vcpkg-cmake", "vcpk
Throw-IfFailed
Require-FileNotExists "$installRoot/$Triplet/include"

if(-Not $IsLinux -and -Not $IsMacOS) {
if(-Not $IsLinux) {
# Test simple nuget installation
Run-Vcpkg -TestArgs ($commonArgs + @("install", "rapidjson", "vcpkg-cmake", "vcpkg-cmake-config", "--binarycaching", "--x-binarysource=clear;nuget,$NuGetRoot,readwrite"))
Throw-IfFailed
Expand Down Expand Up @@ -47,7 +47,7 @@ Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h"
Require-FileExists "$buildtreesRoot/rapidjson/src"
Require-FileNotExists "$buildtreesRoot/detect_compiler"

if(-Not $IsLinux -and -Not $IsMacOS) {
if(-Not $IsLinux) {
# Test restoring from nuget
Remove-Item -Recurse -Force $installRoot
Remove-Item -Recurse -Force $buildtreesRoot
Expand Down
82 changes: 0 additions & 82 deletions azure-pipelines/end-to-end-tests-dir/bundles.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ New-Item -ItemType File -Force $bundle/.vcpkg-root | Out-Null
$a = Run-Vcpkg z-print-config `
--vcpkg-root=$bundle `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--overlay-triplets=$env:VCPKG_ROOT/triplets/community `
--x-scripts-root=$env:VCPKG_ROOT/scripts
$a
Throw-IfFailed
Expand Down Expand Up @@ -53,7 +52,6 @@ New-Item -ItemType File -Force $bundle/.vcpkg-root | Out-Null
$a = Run-Vcpkg z-print-config `
--vcpkg-root=$bundle `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--overlay-triplets=$env:VCPKG_ROOT/triplets/community `
--x-scripts-root=$env:VCPKG_ROOT/scripts
$a
Throw-IfFailed
Expand Down Expand Up @@ -92,7 +90,6 @@ $a = Run-Vcpkg z-print-config `
--vcpkg-root=$bundle `
--x-manifest-root=$manifestdir `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--overlay-triplets=$env:VCPKG_ROOT/triplets/community `
--x-scripts-root=$env:VCPKG_ROOT/scripts
$a
Throw-IfFailed
Expand Down Expand Up @@ -135,7 +132,6 @@ $a = Run-Vcpkg z-print-config `
--vcpkg-root=$bundle `
--x-manifest-root=$manifestdir `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--overlay-triplets=$env:VCPKG_ROOT/triplets/community `
--x-buildtrees-root=$buildtreesRoot `
--x-install-root=$installRoot `
--x-packages-root=$packagesRoot `
Expand All @@ -162,7 +158,6 @@ foreach ($k in $b.keys) {

Run-Vcpkg install zlib --dry-run --vcpkg-root=$bundle `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--overlay-triplets=$env:VCPKG_ROOT/triplets/community `
--x-buildtrees-root=$buildtreesRoot `
--x-builtin-ports-root=$env:VCPKG_ROOT/ports `
--x-install-root=$installRoot `
Expand All @@ -179,7 +174,6 @@ $CurrentTest = "Testing bundle.usegitregistry"
Run-Vcpkg install --dry-run --vcpkg-root=$bundle `
--x-manifest-root=$manifestdir `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--overlay-triplets=$env:VCPKG_ROOT/triplets/community `
--x-buildtrees-root=$buildtreesRoot `
--x-builtin-ports-root=$env:VCPKG_ROOT/ports `
--x-install-root=$installRoot `
Expand All @@ -199,7 +193,6 @@ New-Item -ItemType Directory -Force $manifestdir2 | Out-Null
Run-Vcpkg install --vcpkg-root=$bundle `
--x-manifest-root=$manifestdir2 `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--overlay-triplets=$env:VCPKG_ROOT/triplets/community `
--x-buildtrees-root=$buildtreesRoot `
--x-builtin-ports-root=$env:VCPKG_ROOT/ports `
--x-install-root=$installRoot `
Expand All @@ -210,84 +203,9 @@ Throw-IfFailed
Run-Vcpkg search zlib --vcpkg-root=$bundle `
--x-manifest-root=$manifestdir2 `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--overlay-triplets=$env:VCPKG_ROOT/triplets/community `
--x-buildtrees-root=$buildtreesRoot `
--x-builtin-ports-root=$env:VCPKG_ROOT/ports `
--x-install-root=$installRoot `
--x-packages-root=$packagesRoot `
--x-scripts-root=$env:VCPKG_ROOT/scripts
Throw-IfFailed

# Test CI environment detection
$detected_ci_key = 'detected_ci_environment'
$known_ci_vars = (
"env:VCPKG_NO_CI",
"env:TF_BUILD",
"env:APPVEYOR",
"env:CODEBUILD_BUILD_ID",
"env:CIRCLECI",
"env:GITHUB_ACTIONS",
"env:GITLAB_CI",
"env:HEROKU_TEST_RUN_ID",
"env:JENKINS_URL",
"env:TRAVIS",
"env:CI",
"env:BUILD_ID"
)

foreach ($var in $known_ci_vars) {
if (Test-Path $var) {
Remove-Item $var
}
}

$env:VCPKG_NO_CI="1"
$env:TF_BUILD="1"
$env:CI="1"

$a = Run-Vcpkg z-print-config `
--vcpkg-root=$bundle `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--x-scripts-root=$env:VCPKG_ROOT/scripts
$a
Throw-IfFailed
$a = $($a | ConvertFrom-JSON -AsHashtable)
if ($a[$detected_ci_key] -ne 'VCPKG_NO_CI') {
throw "Expected VCPKG_NO_CI as detected CI environment but found: $($a[$detected_ci_key])"
}

Remove-Item env:VCPKG_NO_CI
$a = Run-Vcpkg z-print-config `
--vcpkg-root=$bundle `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--x-scripts-root=$env:VCPKG_ROOT/scripts
$a
Throw-IfFailed
$a = $($a | ConvertFrom-JSON -AsHashtable)
if ($a[$detected_ci_key] -ne 'Azure_Pipelines') {
throw "Expected Azure_Pipelines as detected CI environment but found: $($a[$detected_ci_key])"
}

Remove-Item env:TF_BUILD
$a = Run-Vcpkg z-print-config `
--vcpkg-root=$bundle `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--x-scripts-root=$env:VCPKG_ROOT/scripts
$a
Throw-IfFailed
$a = $($a | ConvertFrom-JSON -AsHashtable)
if ($a[$detected_ci_key] -ne 'Generic') {
throw "Expected Generic as detected CI environment but found: $($a[$detected_ci_key])"
}

Remove-Item env:CI
$a = Run-Vcpkg z-print-config `
--vcpkg-root=$bundle `
--overlay-triplets=$env:VCPKG_ROOT/triplets `
--x-scripts-root=$env:VCPKG_ROOT/scripts
$a
Throw-IfFailed
$a = $($a | ConvertFrom-JSON -AsHashtable)
if ($a[$detected_ci_key] -ne $null) {
throw "Expected no CI environment but found $($a[$detected_ci_key]))"
}
15 changes: 14 additions & 1 deletion ce/ce/archivers/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

import { UnpackEvents } from '../interfaces/events';
import { Session } from '../session';
import { Credentials } from '../util/credentials';
import { execute } from '../util/exec-cmd';
import { isFilePath, Uri } from '../util/uri';
Expand All @@ -13,12 +14,16 @@ export interface CloneOptions {

/** @internal */
export class Git {
#session: Session;
#toolPath: string;
#targetFolder: Uri;
#environment: NodeJS.ProcessEnv;

constructor(toolPath: string, targetFolder: Uri) {
constructor(session: Session, toolPath: string, environment: NodeJS.ProcessEnv, targetFolder: Uri) {
this.#session = session;
this.#toolPath = toolPath;
this.#targetFolder = targetFolder;
this.#environment = environment;
}

/**
Expand All @@ -40,6 +45,7 @@ export class Git {
options.depth ? `--depth=${options.depth}` : '',
'--progress'
], {
env: this.#environment,
onStdErrData: chunkToHeartbeat(events),
onStdOutData: chunkToHeartbeat(events)
});
Expand All @@ -64,6 +70,7 @@ export class Git {
options.commit ? options.commit : '',
options.depth ? `--depth=${options.depth}` : ''
], {
env: this.#environment,
cwd: this.#targetFolder.fsPath
});

Expand All @@ -85,6 +92,7 @@ export class Git {
'checkout',
options.commit ? options.commit : ''
], {
env: this.#environment,
cwd: this.#targetFolder.fsPath,
onStdErrData: chunkToHeartbeat(events),
onStdOutData: chunkToHeartbeat(events)
Expand All @@ -109,6 +117,7 @@ export class Git {
options.recurse ? '--recurse-submodules' : '',
options.hard ? '--hard' : ''
], {
env: this.#environment,
cwd: this.#targetFolder.fsPath,
onStdErrData: chunkToHeartbeat(events),
onStdOutData: chunkToHeartbeat(events)
Expand All @@ -131,6 +140,7 @@ export class Git {
}

const result = await execute(this.#toolPath, ['init'], {
env: this.#environment,
cwd: this.#targetFolder.fsPath
});

Expand All @@ -152,6 +162,7 @@ export class Git {
name,
location.toString()
], {
env: this.#environment,
cwd: this.#targetFolder.fsPath
});

Expand All @@ -175,6 +186,7 @@ export class Git {
options.depth ? `--depth=${options.depth}` : '',
options.recursive ? '--recursive' : '',
], {
env: this.#environment,
cwd: this.#targetFolder.fsPath,
onStdErrData: chunkToHeartbeat(events),
onStdOutData: chunkToHeartbeat(events)
Expand All @@ -198,6 +210,7 @@ export class Git {
key,
value
], {
env: this.#environment,
cwd: this.#targetFolder.fsPath
});
return result.code === 0;
Expand Down
33 changes: 16 additions & 17 deletions ce/ce/artifacts/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class Activation {

// the folder is relative to the artifact install
for (const folder of values) {
this.addPath(pathName, targetFolder.join(folder).fsPath);
this.addPath(pathName, resolve(targetFolder.fsPath, folder));
}
}

Expand All @@ -78,7 +78,7 @@ export class Activation {
if (!toolName || !toolPath) {
continue;
}
this.addTool(toolName, targetFolder.join(toolPath).fsPath);
this.addTool(toolName, resolve(targetFolder.fsPath, toolPath));
}

// **** locations ****
Expand All @@ -87,7 +87,7 @@ export class Activation {
continue;
}

this.addLocation(name, targetFolder.join(location).fsPath);
this.addLocation(name, resolve(targetFolder.fsPath, location));
}

// **** variables ****
Expand Down Expand Up @@ -547,11 +547,9 @@ export class Activation {
return [env, undo];
}

async activate(undoEnvironmentFile: Uri | undefined, msbuildFile: Uri | undefined, json: Uri | undefined) {
async activate(currentEnvironment: Record<string, string | undefined>, shellScriptFile: Uri | undefined, undoEnvironmentFile: Uri | undefined, msbuildFile: Uri | undefined, json: Uri | undefined) {
let undoDeactivation = '';
const scriptKind = extname(this.#session.postscriptFile?.fsPath || '');

const currentEnvironment = {...this.#session.environment};
const scriptKind = extname(shellScriptFile?.fsPath || '');

// load previous activation undo data
const previous = currentEnvironment[undoVariableName];
Expand All @@ -560,10 +558,9 @@ export class Activation {
const deactivationData = await deactivationDataFile.tryReadUTF8();
if (deactivationData) {
const deactivationParsed = JSON.parse(deactivationData);
const previousEnvironmentValues = deactivationParsed.environment || {};
undoActivation(currentEnvironment, previousEnvironmentValues);
currentEnvironment = undoActivation(currentEnvironment, deactivationParsed.environment || {});
delete currentEnvironment[undoVariableName];
undoDeactivation = generateScriptContent(scriptKind, previousEnvironmentValues, deactivationParsed.aliases || {});
undoDeactivation = generateScriptContent(scriptKind, deactivationParsed.environment || {}, deactivationParsed.aliases || {});
}
}

Expand Down Expand Up @@ -602,11 +599,11 @@ export class Activation {
}

// generate shell script if requested
if (this.#session.postscriptFile) {
if (shellScriptFile) {
const contents = undoDeactivation + generateScriptContent(scriptKind, variables, aliases);

this.#session.channels.verbose(`--------[START SHELL SCRIPT FILE]--------\n${contents}\n--------[END SHELL SCRIPT FILE]---------`);
await this.#session.postscriptFile.writeUTF8(contents);
await shellScriptFile.writeUTF8(contents);
}

// generate msbuild props file if requested
Expand All @@ -624,7 +621,7 @@ export class Activation {
}


/** produces an environment block that can be passed to child processes to leverage dependent artifacts during installation/activation. */
/** produces an environment block that can be passed to child processes to leverage dependent artifacts during installtion/activation. */
async getEnvironmentBlock(): Promise<NodeJS.ProcessEnv> {
const result = { ... this.#session.environment };

Expand Down Expand Up @@ -712,14 +709,16 @@ export async function deactivate(shellScriptFile: Uri, variables: Record<string,
await shellScriptFile.writeUTF8(generateScriptContent(kind, variables, aliases));
}

function undoActivation(targetEnvironment: Record<string, string | undefined>, oldVariableValues: Record<string, string>) {
for (const [key, value] of linq.entries(oldVariableValues)) {
function undoActivation(currentEnvironment: Record<string, string | undefined>, variables: Record<string, string>) {
const result = { ...currentEnvironment };
for (const [key, value] of linq.entries(variables)) {
if (value) {
targetEnvironment[key] = value;
result[key] = value;
} else {
delete targetEnvironment[key];
delete result[key];
}
}
return result;
}

async function toArrayAsync<T>(iterable: AsyncIterable<T>) {
Expand Down
Loading

0 comments on commit 4653a3a

Please sign in to comment.