diff options
| author | J08nY | 2024-05-15 17:54:42 +0200 |
|---|---|---|
| committer | J08nY | 2024-05-15 17:54:42 +0200 |
| commit | 2db18fc281222099ffaf69c94682706752791cd4 (patch) | |
| tree | c23c34bff5851beefee2822e6be57f7c3b35cac8 | |
| parent | e2a400650cbc2639d44e2761c265191de1f69842 (diff) | |
| download | pyecsca-codegen-2db18fc281222099ffaf69c94682706752791cd4.tar.gz pyecsca-codegen-2db18fc281222099ffaf69c94682706752791cd4.tar.zst pyecsca-codegen-2db18fc281222099ffaf69c94682706752791cd4.zip | |
Add tommath build as part of build.
Fixes #8.
| -rw-r--r-- | MANIFEST.in | 3 | ||||
| -rw-r--r-- | setup.py | 29 |
2 files changed, 31 insertions, 1 deletions
diff --git a/MANIFEST.in b/MANIFEST.in index b47afac..6a07a95 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,4 +7,5 @@ graft pyecsca/codegen/prng graft pyecsca/codegen/simpleserial graft pyecsca/codegen/templates graft pyecsca/codegen/tommath -recursive-include pyecsca/codegen *.h *.inc
\ No newline at end of file +graft ext/ +recursive-include pyecsca/codegen *.h *.inc diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ac4958e --- /dev/null +++ b/setup.py @@ -0,0 +1,29 @@ +from contextlib import suppress +from pathlib import Path +from setuptools import Command, setup +from setuptools.command.build import build +import subprocess +import shutil + + +class CustomTommath(Command): + def initialize_options(self) -> None: + self.build_lib = None + + def finalize_options(self) -> None: + with suppress(Exception): + self.build_lib = Path(self.get_finalized_command("build").build_lib) + + def run(self) -> None: + if self.build_lib: + subprocess.run(["make", "host", "nano", "stm32f0", "stm32f3"], cwd="ext") + tommath_dir = Path("pyecsca/codegen/tommath") + shutil.copytree(tommath_dir, self.build_lib / tommath_dir) + + + +class CustomBuild(build): + sub_commands = build.sub_commands + [('build_tommath', None)] + + +setup(cmdclass={'build': CustomBuild, 'build_tommath': CustomTommath}) |
