|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +import argparse |
| 4 | +import datetime |
| 5 | +import tempfile |
| 6 | +from pathlib import Path |
| 7 | +import os |
| 8 | +import subprocess |
| 9 | + |
| 10 | +package_version = "0.1.1" # todo |
| 11 | + |
| 12 | +project_root_path = os.path.dirname(os.path.realpath(__file__)) |
| 13 | +parser = argparse.ArgumentParser(description='Create release artifacts.') |
| 14 | +parser.add_argument( |
| 15 | + 'destination', help='Destination folder for the package.', type=Path) |
| 16 | + |
| 17 | +args = parser.parse_args() |
| 18 | + |
| 19 | +package_path = Path(args.destination) |
| 20 | + |
| 21 | +Path(package_path).mkdir(parents=True, exist_ok=True) |
| 22 | + |
| 23 | +subprocess.run(["cmake", "--install", ".", "--prefix", str(package_path)]) |
| 24 | + |
| 25 | + |
| 26 | +def get_artifact(config: str): |
| 27 | + path = Path(tmpdirname + "/" + config) |
| 28 | + path.mkdir() |
| 29 | + |
| 30 | + subprocess.run(["cmake", "-DCMAKE_BUILD_TYPE=" + config, |
| 31 | + "-S", project_root_path, "-B", str(path)]) |
| 32 | + subprocess.run(["cmake", "--build", str(path)]) |
| 33 | + subprocess.run(["cmake", "--install", str(path), |
| 34 | + "--prefix", str(path) + "/install"]) |
| 35 | + subprocess.run(["tar", "-czvf", str(package_path / ("oclhelpers-v" + |
| 36 | + package_version + "-" + config + ".tar.gz")), "-C", str(path) + "/install", "."]) |
| 37 | + |
| 38 | + |
| 39 | +with tempfile.TemporaryDirectory() as tmpdirname: |
| 40 | + get_artifact("Debug") |
| 41 | + get_artifact("Release") |
0 commit comments