Skip to content

Commit

Permalink
Reverting to commit 8294341
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriaconde committed Oct 18, 2022
1 parent 3523503 commit a48a9e0
Show file tree
Hide file tree
Showing 41 changed files with 126 additions and 417 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
cmake_minimum_required(VERSION 3.15...3.24)
cmake_minimum_required(VERSION 3.15..3.24) # 3.15 for MSVC_RUNTIME_LIBRARY, removing default warning flags

cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0092 NEW)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
cmake_policy(SET CMP0135 NEW)
endif()

if(NOT CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
Expand Down
4 changes: 4 additions & 0 deletions ce/ce/cli/command-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export class CommandLine {
return this.switches['z-vcpkg-registries-cache']?.[0];
}

get vcpkgManifestDirectory() {
return this.switches['z-vcpkg-manifest-dir']?.[0];
}

get telemetryEnabled() {
return !!this.switches['z-enable-metrics'];
}
Expand Down
7 changes: 1 addition & 6 deletions ce/ce/cli/commands/acquire-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ import { i } from '../../i18n';
import { session } from '../../main';
import { acquireArtifacts, showArtifacts } from '../artifacts';
import { Command } from '../command';
import { error } from '../styling';
import { Project } from '../switches/project';

export class AcquireProjectCommand extends Command {
readonly command = 'acquire-project';
readonly aliases = [];
seeAlso = [];
argumentsHelp = [];
project: Project = new Project(this);

get summary() {
return i`Acquires everything referenced by a project, without activating`;
}
Expand All @@ -27,9 +23,8 @@ export class AcquireProjectCommand extends Command {
}

override async run() {
const projectManifest = await this.project.manifest;
const projectManifest = await session.loadRequiredProjectProfile();
if (!projectManifest) {
error(i`Unable to find project in folder (or parent folders) for ${session.currentDirectory.fsPath}`);
return false;
}

Expand Down
4 changes: 1 addition & 3 deletions ce/ce/cli/commands/acquire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { acquireArtifacts, selectArtifacts, showArtifacts } from '../artifacts';
import { Command } from '../command';
import { cmdSwitch } from '../format';
import { debug, error, log, warning } from '../styling';
import { Project } from '../switches/project';
import { Version } from '../switches/version';

export class AcquireCommand extends Command {
Expand All @@ -18,7 +17,6 @@ export class AcquireCommand extends Command {
seeAlso = [];
argumentsHelp = [];
version: Version = new Version(this);
project: Project = new Project(this);

get summary() {
return i`Acquire artifacts in the registry`;
Expand All @@ -43,7 +41,7 @@ export class AcquireCommand extends Command {
}

const resolver = session.globalRegistryResolver.with(
await buildRegistryResolver(session, (await this.project.manifest)?.metadata.registries));
await buildRegistryResolver(session, (await session.loadProjectProfile())?.metadata.registries));
const resolved = await selectArtifacts(session, new Map(this.inputs.map((v, i) => [v, versions[i] || '*'])), resolver, 1);
if (!resolved) {
debug('No artifacts selected - stopping');
Expand Down
7 changes: 1 addition & 6 deletions ce/ce/cli/commands/activate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ import { showArtifacts } from '../artifacts';
import { Command } from '../command';
import { projectFile } from '../format';
import { activate } from '../project';
import { error } from '../styling';
import { Json } from '../switches/json';
import { MSBuildProps } from '../switches/msbuild-props';
import { Project } from '../switches/project';

export class ActivateCommand extends Command {
readonly command = 'activate';
readonly aliases = [];
seeAlso = [];
argumentsHelp = [];
project: Project = new Project(this);
msbuildProps: MSBuildProps = new MSBuildProps(this);
json : Json = new Json(this);

Expand All @@ -35,10 +32,8 @@ export class ActivateCommand extends Command {
}

override async run() {
const projectManifest = await this.project.manifest;

const projectManifest = await session.loadRequiredProjectProfile();
if (!projectManifest) {
error(i`Unable to find project in folder (or parent folders) for ${session.currentDirectory.fsPath}`);
return false;
}

Expand Down
6 changes: 1 addition & 5 deletions ce/ce/cli/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { selectArtifacts, showArtifacts } from '../artifacts';
import { Command } from '../command';
import { cmdSwitch } from '../format';
import { error } from '../styling';
import { Project } from '../switches/project';
import { Version } from '../switches/version';

export class AddCommand extends Command {
Expand All @@ -18,7 +17,6 @@ export class AddCommand extends Command {
argumentsHelp = [];

version = new Version(this);
project: Project = new Project(this);

get summary() {
return i`Adds an artifact to the project`;
Expand All @@ -31,10 +29,8 @@ export class AddCommand extends Command {
}

override async run() {
const projectManifest = await this.project.manifest;

const projectManifest = await session.loadRequiredProjectProfile();
if (!projectManifest) {
error(i`Unable to find project in folder (or parent folders) for ${session.currentDirectory.fsPath}`);
return false;
}

Expand Down
10 changes: 3 additions & 7 deletions ce/ce/cli/commands/deactivate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import { session } from '../../main';
import { Command } from '../command';
import { projectFile } from '../format';
import { log } from '../styling';
import { Project } from '../switches/project';

export class DeactivateCommand extends Command {
readonly command = 'deactivate';
readonly aliases = [];
seeAlso = [];
argumentsHelp = [];
project = new Project(this);

get summary() {
return i`Deactivates the current session`;
Expand All @@ -26,14 +24,12 @@ export class DeactivateCommand extends Command {
}

override async run() {
const project = await this.project.resolvedValue;
if (!project) {
return false;
const project = await session.findProjectProfile();
if (project) {
log(i`Deactivating project ${projectFile(project)}`);
}

log(i`Deactivating project ${projectFile(project)}`);
await session.deactivate();

return true;
}
}
4 changes: 1 addition & 3 deletions ce/ce/cli/commands/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { session } from '../../main';
import { Command } from '../command';
import { Table } from '../markdown-table';
import { error, log } from '../styling';
import { Project } from '../switches/project';
import { Version } from '../switches/version';

export class FindCommand extends Command {
Expand All @@ -18,7 +17,6 @@ export class FindCommand extends Command {
seeAlso = [];
argumentsHelp = [];
version = new Version(this);
project = new Project(this);

get summary() {
return i`Find artifacts in the registry`;
Expand All @@ -33,7 +31,7 @@ export class FindCommand extends Command {
override async run() {
// load registries (from the current project too if available)
const resolver = session.globalRegistryResolver.with(
await buildRegistryResolver(session, (await this.project.manifest)?.metadata.registries));
await buildRegistryResolver(session, (await session.loadProjectProfile())?.metadata.registries));
const table = new Table('Artifact', 'Version', 'Summary');

for (const each of this.inputs) {
Expand Down
6 changes: 1 addition & 5 deletions ce/ce/cli/commands/generate-msbuild-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import { showArtifacts } from '../artifacts';
import { Command } from '../command';
import { error } from '../styling';
import { MSBuildProps } from '../switches/msbuild-props';
import { Project } from '../switches/project';

export class GenerateMSBuildPropsCommand extends Command {
readonly command = 'generate-msbuild-props';
readonly aliases = [];
seeAlso = [];
argumentsHelp = [];
project: Project = new Project(this);
msbuildProps: MSBuildProps = new MSBuildProps(this, 'out');

get summary() {
Expand All @@ -31,10 +29,8 @@ export class GenerateMSBuildPropsCommand extends Command {
return false;
}

const projectManifest = await this.project.manifest;

const projectManifest = await session.loadRequiredProjectProfile();
if (!projectManifest) {
error(i`Unable to find project in folder (or parent folders) for ${session.currentDirectory.fsPath}`);
return false;
}

Expand Down
6 changes: 1 addition & 5 deletions ce/ce/cli/commands/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import { i } from '../../i18n';
import { session } from '../../main';
import { Command } from '../command';
import { error, log } from '../styling';
import { Project } from '../switches/project';

export class RemoveCommand extends Command {
readonly command = 'remove';
readonly aliases = [];
seeAlso = [];
argumentsHelp = [];
project: Project = new Project(this);

get summary() {
return i`Removes an artifact from a project`;
Expand All @@ -25,10 +23,8 @@ export class RemoveCommand extends Command {
}

override async run() {
const projectManifest = await this.project.manifest;

const projectManifest = await session.loadRequiredProjectProfile();
if (!projectManifest) {
error(i`Unable to find project in folder (or parent folders) for ${session.currentDirectory.fsPath}`);
return false;
}

Expand Down
4 changes: 1 addition & 3 deletions ce/ce/cli/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ import { Command } from '../command';
import { CommandLine } from '../command-line';
import { count } from '../format';
import { error, log, writeException } from '../styling';
import { Project } from '../switches/project';

export class UpdateCommand extends Command {
readonly command = 'update';
readonly aliases = [];
seeAlso = [];
argumentsHelp = [];
project: Project = new Project(this);

get summary() {
return i`update the registry from the remote`;
Expand All @@ -31,7 +29,7 @@ export class UpdateCommand extends Command {

override async run() {
const resolver = session.globalRegistryResolver.with(
await buildRegistryResolver(session, (await this.project.manifest)?.metadata.registries));
await buildRegistryResolver(session, (await session.loadProjectProfile())?.metadata.registries));
for (const registryName of this.inputs) {
const registry = resolver.getRegistryByName(registryName);
if (registry) {
Expand Down
4 changes: 1 addition & 3 deletions ce/ce/cli/commands/use.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { cmdSwitch } from '../format';
import { activate } from '../project';
import { error, log, warning } from '../styling';
import { MSBuildProps } from '../switches/msbuild-props';
import { Project } from '../switches/project';
import { Version } from '../switches/version';

export class UseCommand extends Command {
Expand All @@ -19,7 +18,6 @@ export class UseCommand extends Command {
seeAlso = [];
argumentsHelp = [];
version = new Version(this);
project = new Project(this);
msbuildProps = new MSBuildProps(this);

get summary() {
Expand All @@ -39,7 +37,7 @@ export class UseCommand extends Command {
}

const resolver = session.globalRegistryResolver.with(
await buildRegistryResolver(session, (await this.project.manifest)?.metadata.registries));
await buildRegistryResolver(session, (await session.loadProjectProfile())?.metadata.registries));
const versions = this.version.values;
if (versions.length && this.inputs.length !== versions.length) {
error(i`Multiple packages specified, but not an equal number of ${cmdSwitch('version')} switches`);
Expand Down
39 changes: 31 additions & 8 deletions ce/ce/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { strict } from 'assert';
import { MetadataFile } from './amf/metadata-file';
import { deactivate } from './artifacts/activation';
import { Artifact, InstalledArtifact } from './artifacts/artifact';
import { Artifact, InstalledArtifact, ProjectManifest } from './artifacts/artifact';
import { configurationName, defaultConfig, globalConfigurationFile, postscriptVariable, undo } from './constants';
import { FileSystem } from './fs/filesystem';
import { HttpsFileSystem } from './fs/http-filesystem';
Expand Down Expand Up @@ -54,6 +54,7 @@ export type SessionSettings = {
readonly vcpkgArtifactsRoot?: string;
readonly vcpkgDownloads?: string;
readonly vcpkgRegistriesCache?: string;
readonly vcpkgManifestDirectory?: string;
readonly telemetryEnabled: boolean;
}

Expand All @@ -73,6 +74,7 @@ export class Session {
readonly tmpFolder: Uri;
readonly installFolder: Uri;
readonly registryFolder: Uri;
readonly manifestFolder: Uri | undefined;
get vcpkgCommand() { return this.settings.vcpkgCommand; }

readonly globalConfig: Uri;
Expand Down Expand Up @@ -116,6 +118,7 @@ export class Session {

this.registryFolder = this.processVcpkgArg(settings.vcpkgRegistriesCache, 'registries').join('artifact');
this.installFolder = this.processVcpkgArg(settings.vcpkgArtifactsRoot, 'artifacts');
this.manifestFolder = settings.vcpkgManifestDirectory ? this.fileSystem.file(settings.vcpkgManifestDirectory) : undefined;

const postscriptFileName = this.environment[postscriptVariable];
this.postscriptFile = postscriptFileName ? this.fileSystem.file(postscriptFileName) : undefined;
Expand Down Expand Up @@ -181,15 +184,35 @@ export class Session {
return this;
}

async findProjectProfile(startLocation = this.currentDirectory): Promise<Uri | undefined> {
let location = startLocation;
const path = location.join(configurationName);
if (await this.fileSystem.isFile(path)) {
return path;
async findProjectProfile(): Promise<Uri | undefined> {
const location = this.manifestFolder;
if (location) {
const path = location.join(configurationName);
if (await this.fileSystem.isFile(path)) {
return path;
}
}

return undefined;
}

async loadProjectProfile(): Promise<ProjectManifest | undefined> {
const path = await this.findProjectProfile();
if (path) {
this.channels.debug(`Loading project manifest ${path.fsPath} `);
return new ProjectManifest(this, await this.openManifest(path.fsPath, path));
}

return undefined;
}

async loadRequiredProjectProfile(): Promise<ProjectManifest | undefined> {
const manifest = await this.loadProjectProfile();
if (!manifest) {
this.channels.error(i`Unable to find project in folder (or parent folders) for ${this.manifestFolder?.fsPath}`);
}

location = location.join('..');
return (location.toString() === startLocation.toString()) ? undefined : this.findProjectProfile(location);
return manifest;
}

async deactivate() {
Expand Down
6 changes: 3 additions & 3 deletions locales/messages.cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
"HelpVersionSemverScheme": "Sémantická verze 2.0 (2.1.0-rc2)",
"HelpVersionStringScheme": "Přesná, nekompatibilní verze (Vista)",
"HelpVersioning": "Správa verzí umožňuje deterministicky řídit přesné revize závislostí používaných vaším projektem ze souboru manifest.",
"IgnoringVcpkgRootEnvironment": "Ignoruje se proměnná prostředí VCPKG_ROOT. Pro použití hodnoty prostředí použijte --vcpkg-root {path} nebo zrušte nastavení proměnné prostředí VCPKG_ROOT pro potlačení této zprávy. Používá se zjištěný kořen vcpkg: {actual}.",
"IgnoringVcpkgRootEnvironment": "Ignoring VCPKG_ROOT environment variable; use --vcpkg-root \"{path}\" to use the environment value or unset the VCPKG_ROOT environment variable to suppress this message. Using detected vcpkg root: \"{actual}\".",
"IllegalFeatures": "Seznam funkcí není v tomto kontextu povolený.",
"IllegalPlatformSpec": "Kvalifikátor platformy není v tomto kontextu povolený.",
"ImproperShaLength": "Algoritmy SHA512 musí mít 128 šestnáctkových znaků: {value}",
Expand Down Expand Up @@ -402,7 +402,7 @@
"SettingEnvVar": "-- Nastavení proměnných prostředí {env_var} na {url}.",
"ShaPassedAsArgAndOption": "Algoritmus SHA512 se předal jako argument i jako možnost. Můžete předat jen jedno z toho.",
"ShaPassedWithConflict": "Algoritmus SHA512 proběhl úspěšně, ale předal se i parametr --skip-sha512; můžete udělat jen jedno nebo druhé.",
"ShallowRepositoryDetected": "Vcpkg se naklonoval jako mělké úložiště v: {path}\nZkuste to znovu s úplným klonem vcpkg.",
"ShallowRepositoryDetected": "vcpkg was cloned as a shallow repository in: {path}\nTry again with a full vcpkg clone.",
"SkipClearingInvalidDir": "Vymazání obsahu cesty {path} se přeskakuje, protože se nejedná o adresář.",
"SourceFieldPortNameMismatch": "Pole Source v souboru CONTROL nebo pole name v souboru vcpkg.json má název {package_name} a neodpovídá adresáři portu {path}.",
"SpecifiedFeatureTurnedOff": "Funkce {command_name} je konkrétně vypnutá, ale zadala se možnost --{option}.",
Expand Down Expand Up @@ -469,7 +469,7 @@
"VSExaminedInstances": "Zvažovaly se následující instance Visual Studio:",
"VSExaminedPaths": "Následující cesty byly zkontrolovány pro Visual Studio instance:",
"VSNoInstances": "Nepovedlo se najít úplnou instanci Visual Studio.",
"VcpkgCeIsExperimental": "vcpkg-artifacts jsou experimentální a můžou se kdykoli změnit.",
"VcpkgCeIsExperimental": "vcpkg-artifacts are experimental and may change at any time.",
"VcpkgCommitTableHeader": "Potvrzení VCPKG",
"VcpkgCompletion": "Dokončení vcpkg {value} je už naimportováno do souboru {path}.\nByly nalezeny následující položky:",
"VcpkgDisallowedClassicMode": "Nad aktuálním pracovním adresářem se nepovedlo najít manifest (vcpkg.json).\nTato distribuce vcpkg nemá instanci klasického režimu.",
Expand Down
Loading

0 comments on commit a48a9e0

Please sign in to comment.