-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[vcpkg] Implement versions db generator #13777
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
Merged
vicroms
merged 34 commits into
microsoft:master
from
vicroms:versioning/get-versions-from-history
Oct 26, 2020
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
2c310bb
[vcpkg] Add script to generate ports versions history
vicroms 5e40036
[vcpkg] Fix formatting
vicroms 59926f1
Fetch port versions from commit ID
vicroms 394dccf
Use global --x-json switch
vicroms 9fabe51
Use --no-checkout when cloning secondary instance
vicroms baa05ef
Clone from local repository instead of from GitHub
vicroms 037471c
Use CmdLineBuilder to build git commands
vicroms 9a7f298
Use CmdLineBuilder and reduce repeated code
vicroms c0117eb
Merge branch 'master' of github.com:microsoft/vcpkg into versioning/g…
vicroms b07099c
Fetch version at baseline and code cleanup
vicroms 87fc6af
Guess version scheme from old CONTROL files
vicroms 5ed80e0
Rename version db generator script
vicroms 61043f5
Merge branch 'master' of github.com:microsoft/vcpkg into versioning/g…
vicroms 2fe2a61
Simplify x-history json output
vicroms b98c92a
Merge branch 'master' of github.com:microsoft/vcpkg into versioning/g…
vicroms 5c02c5b
Use CONTROL/manifest parsers on x-history
vicroms ee191eb
Use git-tree instaed of commit-id
vicroms 7248364
Remove 'ports' field from root object
vicroms 8b5245e
Clean up code
vicroms 8c56121
More code cleanup
vicroms bca840d
Merge branch 'master' of github.com:microsoft/vcpkg into versioning/g…
vicroms 91cb16b
Improve port version detection
vicroms 42105e1
Improve generator logging
vicroms 52559f4
Merge branch 'master' of https://github.com/microsoft/vcpkg into HEAD
ras0219-msft 8ca07da
Do not ignore parsing errors in CONTROL files
vicroms e400b5a
Merge branch 'master' of github.com:microsoft/vcpkg into versioning/g…
vicroms 08c5685
PR review comments in Python script
vicroms 38504e7
Fix subprocess.run() calls
vicroms d27f294
Make `canonicalize()` return error instead of terminating
vicroms d664855
[vcpkg] Add tests for new test_parse_control_file paths
ras0219-msft 0d077e3
Remove unnecessary std::move() calls
vicroms 8a9115c
Merge branch 'dev/roschuma/cr' of https://github.com/ras0219/vcpkg in…
vicroms c312541
Fix formatting
vicroms 0c7079e
Python formatting
vicroms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import os | ||
| import os.path | ||
| import sys | ||
| import subprocess | ||
| import json | ||
| import time | ||
|
|
||
| from subprocess import CalledProcessError | ||
| from json.decoder import JSONDecodeError | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| SCRIPT_DIRECTORY = os.path.dirname(os.path.abspath(__file__)) | ||
|
|
||
|
|
||
| def get_current_git_ref(): | ||
| output = subprocess.run(['git.exe', '-C', SCRIPT_DIRECTORY, 'rev-parse', '--verify', 'HEAD'], | ||
| capture_output=True, | ||
| encoding='utf-8') | ||
| if output.returncode == 0: | ||
| return output.stdout.strip() | ||
| print(f"Failed to get git ref:", output.stderr.strip(), file=sys.stderr) | ||
| return None | ||
|
|
||
|
|
||
| def generate_port_versions_db(ports_path, db_path, revision): | ||
| start_time = time.time() | ||
| port_names = [item for item in os.listdir(ports_path) if os.path.isdir(os.path.join(ports_path, item))] | ||
| total_count = len(port_names) | ||
| for counter, port_name in enumerate(port_names): | ||
| containing_dir = os.path.join(db_path, f'{port_name[0]}-') | ||
| os.makedirs(containing_dir, exist_ok=True) | ||
| output_filepath = os.path.join(containing_dir, f'{port_name}.json') | ||
| if not os.path.exists(output_filepath): | ||
| output = subprocess.run( | ||
| [os.path.join(SCRIPT_DIRECTORY, '../vcpkg'), 'x-history', port_name, '--x-json'], | ||
| capture_output=True, encoding='utf-8') | ||
| if output.returncode == 0: | ||
| try: | ||
| versions_object = json.loads(output.stdout) | ||
| with open(output_filepath, 'w') as output_file: | ||
| json.dump(versions_object, output_file) | ||
| except JSONDecodeError: | ||
| print(f'Maformed JSON from vcpkg x-history {port_name}: ', output.stdout.strip(), file=sys.stderr) | ||
| else: | ||
| print(f'x-history {port_name} failed: ', output.stdout.strip(), file=sys.stderr) | ||
| # This should be replaced by a progress bar | ||
| if counter > 0 and counter % 100 == 0: | ||
| elapsed_time = time.time() - start_time | ||
| print(f'Processed {counter} out of {total_count}. Elapsed time: {elapsed_time:.2f} seconds') | ||
| rev_file = os.path.join(db_path, revision) | ||
| Path(rev_file).touch() | ||
| elapsed_time = time.time() - start_time | ||
| print(f'Processed {total_count} total ports. Elapsed time: {elapsed_time:.2f} seconds') | ||
|
|
||
|
|
||
| def main(ports_path, db_path): | ||
| revision = get_current_git_ref() | ||
| if not revision: | ||
| print('Couldn\'t fetch current Git revision', file=sys.stderr) | ||
| sys.exit(1) | ||
| rev_file = os.path.join(db_path, revision) | ||
| if os.path.exists(rev_file): | ||
| print(f'Database files already exist for commit {revision}') | ||
| sys.exit(0) | ||
| generate_port_versions_db(ports_path=ports_path, db_path=db_path, revision=revision) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main(ports_path=os.path.join(SCRIPT_DIRECTORY, '../ports'), | ||
| db_path=os.path.join(SCRIPT_DIRECTORY, '../port_versions')) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,12 @@ | ||
| #pragma once | ||
|
|
||
| #include <vcpkg/fwd/vcpkgpaths.h> | ||
|
|
||
| namespace vcpkg::Versions | ||
| { | ||
| enum class Scheme | ||
| { | ||
| String, | ||
| Relaxed, | ||
| Semver, | ||
| Date | ||
| Date, | ||
| String | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.