-
Notifications
You must be signed in to change notification settings - Fork 14
Initial support for hwcaps-loader #102
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |
| from .ypkgcontext import YpkgContext | ||
| from .scripts import ScriptGenerator | ||
| from .packages import PackageGenerator, PRIORITY_USER | ||
| from .examine import PackageExaminer | ||
| from .examine import PackageExaminer, is_elf_file | ||
| from . import metadata | ||
| from .dependencies import DependencyResolver | ||
| from . import packager_name, packager_email | ||
|
|
@@ -38,6 +38,7 @@ | |
|
|
||
| from timeit import default_timer as timer | ||
| from datetime import timedelta | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def show_version(): | ||
|
|
@@ -190,6 +191,41 @@ def execute_step(context, step, step_n, work_dir): | |
| return False | ||
| return True | ||
|
|
||
| was_avx2_context = False | ||
|
|
||
| def post_execute_step(context, step, step_n, work_dir): | ||
|
|
||
| hwcaps_v3_bin_dir = os.path.join(context.get_install_dir(), "usr", "hwcaps", "x86-64-v3", "bin") | ||
| hwcaps_v1_bin_dir = os.path.join(context.get_install_dir(), "usr", "hwcaps", "x86-64-v1", "bin") | ||
| bin_dir = os.path.join(context.get_install_dir(), "usr", "bin") | ||
|
|
||
| if context.avx2 and step_n == "install": | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Paired with my other suggestion about moving the step check, could we inverse this check and early return if the context is not |
||
| global was_avx2_context | ||
| was_avx2_context = True | ||
|
|
||
| os.makedirs(hwcaps_v3_bin_dir, exist_ok=True) | ||
| for dirpath, dirnames, filenames in os.walk(bin_dir): | ||
| for file in filenames: | ||
| file_path = os.path.join(dirpath, file) | ||
| if is_elf_file(file_path): | ||
| shutil.move(file_path, hwcaps_v3_bin_dir) | ||
|
|
||
| if context.emul32 is False and context.avx2 is False and step_n == "install" and was_avx2_context is True: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great if we could also inverse all of this for an early return. There are a lot of elements in this check as well that make it a bit hard to read. |
||
| os.makedirs(hwcaps_v1_bin_dir, exist_ok=True) | ||
|
|
||
| dummy_hwcaps_loader = Path(bin_dir, "hwcaps-loader") | ||
| dummy_hwcaps_loader.touch() | ||
|
|
||
| for dirpath, dirnames, filenames in os.walk(bin_dir): | ||
| for file in filenames: | ||
| file_path = os.path.join(dirpath, file) | ||
| if is_elf_file(file_path): | ||
| shutil.move(file_path, hwcaps_v1_bin_dir) | ||
| relative_target = os.path.relpath(dummy_hwcaps_loader, start=os.path.dirname(file_path)) | ||
| os.symlink(relative_target, file_path) | ||
|
|
||
| os.unlink(dummy_hwcaps_loader) | ||
|
|
||
|
|
||
| def build_package(filename, outputDir, buildDir=None): | ||
| """ Will in future be moved to a separate part of the module """ | ||
|
|
@@ -380,6 +416,7 @@ def build_package(filename, outputDir, buildDir=None): | |
| end_time = timer() | ||
| console_ui.emit_success("Build", "{} successful ({})". | ||
| format(step, timedelta(seconds=end_time-start_time))) | ||
| post_execute_step(context, r_step, step, work_dir) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this is run on every step of the build. I think it would make more sense to check if we're on the "install" step before running it here instead of inside the |
||
| continue | ||
| console_ui.emit_error("Build", "{} failed for {}".format(step, spec.pkg_name)) | ||
| sys.exit(1) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use the pretty-printing
console_uifunctions to print? If they were warnings, it would make it easier to see during the build.