diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Dockerfile.heroku | 4 | ||||
| -rw-r--r-- | requirements.pip.dev.txt | 2 | ||||
| -rw-r--r-- | src_doit/__init__.py | 11 | ||||
| -rw-r--r-- | src_doit/c.py | 46 |
5 files changed, 42 insertions, 22 deletions
@@ -6,4 +6,5 @@ /node_modules /src_py/opcut/json_schema_repo.json /src_py/opcut/ui +/src_py/opcut/*-opcut-calculate* __pycache__ diff --git a/Dockerfile.heroku b/Dockerfile.heroku index 8dfc3fb..7cddc2f 100644 --- a/Dockerfile.heroku +++ b/Dockerfile.heroku @@ -6,8 +6,10 @@ RUN apt update -qy && \ FROM opcut-base as opcut-build WORKDIR /opcut COPY . . -RUN apt install -qy nodejs yarnpkg git && \ +RUN apt install -qy nodejs yarnpkg git gcc-mingw-w64-x86-64-win32 && \ ln -sT /usr/bin/yarnpkg /usr/bin/yarn && \ + ln -sT /usr/bin/x86_64-w64-mingw32-cpp-win32 /usr/bin/x86_64-w64-mingw32-cpp && \ + ln -sT /usr/bin/x86_64-w64-mingw32-cc-win32 /usr/bin/x86_64-w64-mingw32-cc && \ pip install -qq -r requirements.pip.dev.txt && \ doit diff --git a/requirements.pip.dev.txt b/requirements.pip.dev.txt index d46798e..52b0f43 100644 --- a/requirements.pip.dev.txt +++ b/requirements.pip.dev.txt @@ -4,7 +4,7 @@ build ~= 0.7.0 doit ~= 0.33.1 flake8 ~= 3.9.2 furo >= 2021.10.9 -hat-doit ~= 0.7.4 +hat-doit ~= 0.8.0 peru >= 1.3.0 pytest ~= 6.2.5 pytest-asyncio ~= 0.15.1 diff --git a/src_doit/__init__.py b/src_doit/__init__.py index 524fa53..8c2498d 100644 --- a/src_doit/__init__.py +++ b/src_doit/__init__.py @@ -44,9 +44,11 @@ json_schema_repo_path = src_py_dir / 'opcut/json_schema_repo.json' def task_clean_all(): """Clean all""" - return {'actions': [(common.rm_rf, [build_dir, - ui_dir, - json_schema_repo_path])]} + return {'actions': [(common.rm_rf, [ + build_dir, + ui_dir, + json_schema_repo_path, + *(src_py_dir / 'opcut').glob('*-opcut-calculate*')])]} def task_wheel(): @@ -65,7 +67,8 @@ def task_wheel(): return {'actions': [build], 'task_dep': ['ui', - 'json_schema_repo']} + 'json_schema_repo', + 'c']} def task_check(): diff --git a/src_doit/c.py b/src_doit/c.py index 8318d10..49c794f 100644 --- a/src_doit/c.py +++ b/src_doit/c.py @@ -1,6 +1,8 @@ from pathlib import Path -from hat.doit.c import (exe_suffix, +from hat.doit.c import (local_platform, + get_exe_suffix, + Platform, CBuild) @@ -10,33 +12,45 @@ __all__ = ['task_c', build_dir = Path('build') -src_c_dir = Path('src_c') deps_dir = Path('deps') +src_c_dir = Path('src_c') +src_py_dir = Path('src_py') build_c_dir = build_dir / 'c' -exe_path = build_c_dir / f'opcut-calculate{exe_suffix}' + +platforms = [local_platform] +if local_platform == Platform.LINUX: + platforms.append(Platform.WINDOWS) + +builds = [CBuild(src_paths=[*src_c_dir.rglob('*.c'), + *(deps_dir / 'argparse').rglob('*.c')], + build_dir=build_c_dir / platform.name.lower(), + platform=platform, + cc_flags=['-fPIC', '-O2', + f'-I{deps_dir / "jsmn"}', + f'-I{deps_dir / "argparse"}'], + task_dep=['deps']) + for platform in platforms] + +exe_paths = [src_py_dir / (f'opcut/{platform.name.lower()}-' + f'opcut-calculate' + f'{get_exe_suffix(platform)}') + for platform in platforms] def task_c(): """Build native app""" - return _build.get_task_exe(exe_path) + for build, exe_path in zip(builds, exe_paths): + yield from build.get_task_exe(exe_path) def task_c_obj(): """Build .o files""" - yield from _build.get_task_objs() + for build in builds: + yield from build.get_task_objs() def task_c_dep(): """Build .d files""" - yield from _build.get_task_deps() - - -_build = CBuild( - src_paths=[*src_c_dir.rglob('*.c'), - *(deps_dir / 'argparse').rglob('*.c')], - build_dir=build_c_dir, - cc_flags=['-fPIC', '-O2', - f'-I{deps_dir / "jsmn"}', - f'-I{deps_dir / "argparse"}'], - task_dep=['deps']) + for build in builds: + yield from build.get_task_deps() |
