Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg-artifacts] Fix end to end development. #586

Merged
merged 11 commits into from
Jun 24, 2022
106 changes: 106 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ option(VCPKG_BUILD_TLS12_DOWNLOADER "Enable building the tls12-downloader" OFF)
option(VCPKG_BUILD_FUZZING "Option for enabling vcpkg-fuzz support" OFF)
option(VCPKG_EMBED_GIT_SHA "Option for to fill in the Git SHA version; off by default to avoid privacy concerns out of official builds" OFF)
option(VCPKG_ADD_SOURCELINK "Option for enabling SourceLink in debug information on Windows/MSVC builds" "${VCPKG_EMBED_GIT_SHA}")
option(VCPKG_ARTIFACTS_DEVELOPMENT "Hard code path to artifacts TypeScript. Requires node.js and global install of @microsoft/rush." OFF)
option(VCPKG_OFFICIAL_BUILD "Option to cause immediate failure if variables required for official builds are unset." OFF)
set(VCPKG_PDB_SUFFIX "" CACHE STRING "Append this string to the name of the PDB for shipping vcpkg binaries.")

Expand All @@ -39,6 +40,11 @@ if(VCPKG_DEVELOPMENT_WARNINGS)
set(FMT_PEDANTIC ON CACHE BOOL "")
endif()

if (VCPKG_ARTIFACTS_DEVELOPMENT)
# https://gitlab.kitware.com/cmake/cmake/-/issues/20245
cmake_minimum_required(VERSION 3.17)
endif()

project(vcpkg
DESCRIPTION "vcpkg helps you manage C and C++ libraries on Windows, Linux and MacOS."
HOMEPAGE_URL "https://github.com/microsoft/vcpkg"
Expand Down Expand Up @@ -170,7 +176,95 @@ if(NOT DEFINED VCPKG_CE_SHA OR VCPKG_CE_SHA STREQUAL "")
if(VCPKG_OFFICIAL_BUILD)
message(FATAL_ERROR "VCPKG_CE_SHA is required for official builds.")
endif()
if (VCPKG_ARTIFACTS_DEVELOPMENT)
file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ce/ce" VCPKG_ARTIFACTS_PATH)
target_compile_definitions(vcpkglib PUBLIC "VCPKG_ARTIFACTS_PATH=${VCPKG_ARTIFACTS_PATH}")
mark_as_advanced(VCPKG_ARTIFACTS_PATH)

if (WIN32)
set(RUSH_SUFFIX ".cmd")
else()
set(RUSH_SUFFIX "")
endif()

find_program(NODEJS "node")
if (NOT NODEJS)
message(FATAL_ERROR "node.js and @microsoft/rush must be installed when VCPKG_ARTIFACTS_DEVELOPMENT is set")
endif()

find_program(RUSH "rush${RUSH_SUFFIX}")
if (NOT RUSH)
message(FATAL_ERROR "@microsoft/rush is required when VCPKG_ARTIFACTS_DEVELOPMENT is set; use `npm install -g @microsoft/rush`")
endif()

add_custom_command(
OUTPUT
"${CMAKE_CURRENT_SOURCE_DIR}/ce/ce/node_modules"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an imperfect output connection; if the packages.json is modified it won't be regenerated. I'm not sure what the right definition would be at this time; maybe just having a "stamp" file that we create after running the rush commands.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything related to the ecmascript dependency detection is imperfect unfortunately. This is "good enough" to do development work; unfortunately there doesn't seem to be a way to make it conclusively correct as long as Rush is involved.

"${CMAKE_CURRENT_SOURCE_DIR}/ce/test/node_modules"
COMMAND "${RUSH}" ARGS "update"
COMMAND "${RUSH}" ARGS "rebuild"
WORKING_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/ce"
COMMENT
"Running rush update..."
VERBATIM
)

add_custom_target(rush-update
ALL
DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/ce/ce/node_modules"
"${CMAKE_CURRENT_SOURCE_DIR}/ce/test/node_modules"
)

# === Target: vcpkg-artifacts ===
file(GLOB_RECURSE VCPKG_ARTIFACTS_SOURCES CONFIGURE_DEPENDS "ce/ce/*.ts")
add_custom_command(
OUTPUT
"${CMAKE_CURRENT_LIST_DIR}/ce/ce/dist/tsconfig.tsbuildinfo"
COMMAND
"${NODEJS}" "${CMAKE_CURRENT_LIST_DIR}/ce/ce/node_modules/typescript/bin/tsc"
-p "${CMAKE_CURRENT_LIST_DIR}/ce/ce"
DEPENDS
BillyONeal marked this conversation as resolved.
Show resolved Hide resolved
${VCPKG_ARTIFACTS_SOURCES}
"${CMAKE_CURRENT_SOURCE_DIR}/ce/ce/node_modules"
COMMENT
"Building vcpkg-ce..."
VERBATIM
)

add_custom_target(vcpkg-artifacts
ALL
DEPENDS
"${CMAKE_CURRENT_LIST_DIR}/ce/ce/dist/tsconfig.tsbuildinfo"
)

# === Target: vcpkg-artifacts-test ===
file(GLOB_RECURSE VCPKG_ARTIFACTS_TEST_SOURCES CONFIGURE_DEPENDS "ce/test/*.ts")
add_custom_command(
OUTPUT
"${CMAKE_CURRENT_LIST_DIR}/ce/test/dist/tsconfig.tsbuildinfo"
COMMAND
"${NODEJS}" "${CMAKE_CURRENT_LIST_DIR}/ce/test/node_modules/typescript/bin/tsc"
-p "${CMAKE_CURRENT_LIST_DIR}/ce/test"
DEPENDS
${VCPKG_ARTIFACTS_TEST_SOURCES}
BillyONeal marked this conversation as resolved.
Show resolved Hide resolved
"${CMAKE_CURRENT_SOURCE_DIR}/ce/test/node_modules"
COMMENT
"Building vcpkg-ce-test..."
VERBATIM
)

add_custom_target(vcpkg-artifacts-test
ALL
DEPENDS
"${CMAKE_CURRENT_LIST_DIR}/ce/test/dist/tsconfig.tsbuildinfo"
)
endif()
else()
if (VCPKG_ARTIFACTS_DEVELOPMENT)
message(WARNING "VCPKG_CE_SHA overrides VCPKG_ARTIFACTS_DEVELOPMENT")
endif()
target_compile_definitions(vcpkglib PUBLIC
VCPKG_CE_SHA=${VCPKG_CE_SHA}
)
Expand Down Expand Up @@ -240,9 +334,21 @@ if(MINGW)
endif()

# === Target: vcpkg ===
add_custom_command(
OUTPUT
"${CMAKE_CURRENT_BINARY_DIR}/vcpkg.ps1"
COMMAND
"${CMAKE_COMMAND}" ARGS -E copy "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg-in-development.ps1" "${CMAKE_CURRENT_BINARY_DIR}/vcpkg.ps1"
DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg-in-development.ps1"
VERBATIM
)

add_custom_target(vcpkg-ps1 ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/vcpkg.ps1")

add_executable(vcpkg ${VCPKG_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
target_link_libraries(vcpkg PRIVATE vcpkglib)

vcpkg_target_add_warning_options(vcpkg)
if(VCPKG_ADD_SOURCELINK)
if(VCPKG_VERSION STREQUAL "unknownhash")
Expand Down
136 changes: 136 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [
{
"name": "VCPKG_ARTIFACTS_DEVELOPMENT",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_TLS12_DOWNLOADER",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_BENCHMARKING",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_FUZZING",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": [
{
"name": "VCPKG_ARTIFACTS_DEVELOPMENT",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_TLS12_DOWNLOADER",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_BENCHMARKING",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_FUZZING",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x86-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x86_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [
{
"name": "VCPKG_ARTIFACTS_DEVELOPMENT",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_TLS12_DOWNLOADER",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_BENCHMARKING",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_FUZZING",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x86-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x86_x64" ],
"variables": [
{
"name": "VCPKG_ARTIFACTS_DEVELOPMENT",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_TLS12_DOWNLOADER",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_BENCHMARKING",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_BUILD_FUZZING",
"value": "True",
"type": "BOOL"
}
]
}
]
}
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ This repository contains the contents formerly at https://github.com/microsoft/v
# Vcpkg-ce: "Configure Environment" / artifacts

Parts of vcpkg powered by "ce" are currently in 'preview' -- there will most certainly be changes between now
and when the tool is 'released' based on feedback.
and when the tool is 'released' based on feedback.

You can use it, but be forewarned that we may change formats, commands, etc.
You can use it, but be forewarned that we may change formats, commands, etc.

Think of it as a manifest-driven desired state configuration for C/C++ projects.
Think of it as a manifest-driven desired state configuration for C/C++ projects.

It
It
- integrates itself into your shell (PowerShell, CMD, bash/zsh)
- can restore artifacts according to a manifest that follows one’s code
- can restore artifacts according to a manifest that follows one’s code
- provides discoverability interfaces

## Installation
Expand All @@ -54,7 +54,7 @@ While the usage of `ce` is the same on all platforms, the installation/loading/r
| `artifact metadata` | A description of the locations one or more artifacts describing rules for which ones are deployed given selection of a host architecture, target architecture, or other properties|
| `artifact identity` | A short string that uniquely describes a moniker that a given artifact (and its metadata) can be referenced by. They can have one of the following forms:<br> `full/identity/path` - the full identity of an artifact that is in the built-in artifact source<br>`sourcename:full/identity/path` - the full identity of an artifact that is in the artifact source specified by the sourcename prefix<br>`shortname` - the shortened unique name of an artifact that is in the built-in artifact source<br>`sourcename:shortname` - the shortened unique name of an artifact that is in the artifact source specified by the sourcename prefix<br>Shortened names are generated based off the shortest unique identity path in the given source. |
| `artifact source` | Also known as a “feed”. An Artifact Source is a location that hosts metadata to locate artifacts. (_There is only one source currently_) |
| `project profile` | The per-project configuration file (`environment.yaml` or `environment.json`)
| `project profile` | The per-project configuration file (`environment.yaml` or `environment.json`)
| `AMF`&nbsp;or&nbsp;`Metadata`&nbsp;`Format` | The schema / format of the YAML/JSON files for project profiles, global settings, and artifacts metadata. |
| `activation` | The process by which a particular set of artifacts are acquired and enabled for use in a calling command program.|
| `versions` | Version numbers are specified using the Semver format. If a version for a particular operation isn't specified, a range for the latest version ( `*` ) is assumed. A version or version range can be specified using the npm semver matching syntax. When a version is stored, it can be stored using the version range specified, a space and then the version found. (ie, the first version is what was asked for, the second is what was installed. No need for a separate lock file.) |
Expand All @@ -75,15 +75,30 @@ with any additional questions or comments.
[contributing:coc]: https://opensource.microsoft.com/codeofconduct/
[contributing:coc-faq]: https://opensource.microsoft.com/codeofconduct/

## Windows Contributing Prerequisites

* Install Visual Studio and the C++ workload
* Install Node.JS by downloading a 16.x copy from https://nodejs.org/en/
* `npm install -g @microsoft/rush`

## Ubuntu 22.04 Contributing Prerequisites

```
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt update
sudo apt install nodejs cmake ninja-build gcc build-essential git zip unzip
sudo npm install -g @microsoft/rush
```

# License

The product code in this repository is licensed under the [MIT License](LICENSE.txt). The tests
contain 3rd party code as documented in `NOTICE.txt`.

# Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.
Expand Down
6 changes: 1 addition & 5 deletions ce/ce/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
"extends": "../common/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": ".",
"types": [
"node"
],
"inlineSourceMap": true
"rootDir": "."
},
"include": [
"./**/*.ts"
Expand Down
3 changes: 2 additions & 1 deletion ce/common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"newLine": "LF"
"newLine": "LF",
"incremental": true
},
"exclude": [
"../**/dist/**",
Expand Down
4 changes: 1 addition & 3 deletions ce/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"extends": "../common/tsconfig.json",
"compilerOptions": {
"experimentalDecorators": true,
"outDir": "./dist",
"rootDir": ".",
"types": [
"node",
"mocha"
],
"inlineSourceMap": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was inlineSourceMap causing a problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was inlineSourceMap causing a problem?

No, but it's already specified in the common one here:

"inlineSourceMap": true,

(I deduplicated any such settings I noticed)

]
},
"include": [
"./**/*.ts"
Expand Down
Loading