GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — liberator/tools/build_cpu_helper.py at main · nullmoth/liberator

Expand file tree

/

build_cpu_helper.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
33 lines (29 loc) · 1.84 KB
/

build_cpu_helper.py

Copy path

File metadata and controls

33 lines (29 loc) · 1.84 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Compile the reviewed x64 static-CRT helper and write its exact package pin; no runtime or release action."""
import argparse
import hashlib
import json
from pathlib import Path
import re
import shutil
import subprocess
import tempfile
def build(repo, destination):
repo, destination = Path(repo).resolve(), Path(destination).resolve()
destination.mkdir(parents=True, exist_ok=True)
source = repo / 'native/cpu'
exe = destination / 'nm_cpuinfo.exe'
# Compiler intermediates are private build inputs, not runtime package files.
with tempfile.TemporaryDirectory(prefix='1401-cpu-build-') as temporary:
subprocess.run(['cl','/nologo','/std:c11','/O2','/MT','/W4','/WX','/DWIN32_LEAN_AND_MEAN','/D_WIN32_WINNT=0x0602',
str(source/'nm_cpuinfo_core.c'),str(source/'nm_cpuinfo_win.c'),'/Fe:'+str(exe),
'/link','/Brepro','/SUBSYSTEM:CONSOLE','kernel32.lib'],cwd=temporary,check=True,capture_output=True,timeout=45)
output = subprocess.check_output(['dumpbin','/dependents',str(exe)],encoding='utf-8',errors='replace',timeout=15)
dependencies = sorted({value.upper() for value in re.findall(r'^\s+(\S+\.dll)\s*$',output,re.M|re.I)})
if dependencies != ['KERNEL32.DLL']: raise RuntimeError('Static CPU helper dependencies differ from the reviewed list.')
digest = hashlib.sha256(exe.read_bytes()).hexdigest()
pin = {'schema':'nullmoth-cpu-helper/1','sha256':digest,'dependencies':dependencies,'operation':'documented read-only CPUID allow-list'}
(destination/'cpu-helper.json').write_text(json.dumps(pin,indent=2)+'\n',encoding='utf-8')
return pin
if __name__ == '__main__':
parser=argparse.ArgumentParser(); parser.add_argument('--repo',required=True); parser.add_argument('--output',required=True)
args=parser.parse_args(); print(json.dumps(build(args.repo,args.output)))
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.