Skip to content
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

Make compiling under Windows possible #19

Merged
merged 5 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ jobs:
echo "MACOS_DEPLOYMENT_TARGET=10.14" >> $GITHUB_ENV

- name: Build and install
run: python -m pip install pytest
pip install --verbose .
run: pip install --verbose .

- name: Test
run: python -m pytest
run: |
python -m pip install pytest h5py
python -m pytest
2 changes: 1 addition & 1 deletion mccode_antlr/libc-registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interoff-lib.h ce347e0fddffc679c653fc152753c034604b4b3e6b4a7f370e759c873fc77c2a
interpolation-lib.c 2c7b84c35305f401873f33b49b7f0c21588dd37a2647d9e08ec6f3412d6eb039
interpolation-lib.h dcafc01739ee3b7bc24bf09536df9c2e34666c61a6f3eeb86f1b39c086bae45e
mccode-r.c 8f2a0b28c7f3602501dd551592516ef9c4cacef85640ae648a7613e700de3aa9
mccode-r.h 827861922d2c9e18a7ab9d8a176b5acb0e950f31afe15bde46daffa359f8ecf3
mccode-r.h 4d90beea77aae9335c0313da6f8d0350056b0746670730818edeab6ccb5a81b1
mccode_main.c a5f6cfe4e5b10af434987eed499b053987b3e1997971afb7146b83c59260bed0
mcstas-d.h 58eabd41cbe02e9a7c2e631eefa2111db176c4a6c9e95dbeb6a14aab4d811591
mcxtrace-d.h 3fbfa9a8148a39457b30cc09c25e006695a7f94aa37152c3c7250c05412f1d8b
Expand Down
2 changes: 1 addition & 1 deletion mccode_antlr/translators/c_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def source_file_contents():
#else
int traceenabled = 0;
#endif
#define {runtime.get("name", "none").upper()} "{include_path}"
#define {runtime.get("name", "none").upper()} "{escape_str_for_c(str(include_path))}"
int defaultmain = {1 if config.get("default_main") else 0};
char instrument_name[] = "{source.name}";
char instrument_source[] = "{escape_str_for_c(source.source)}";
Expand Down
13 changes: 9 additions & 4 deletions test/test_instr.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,21 @@ def test_tas1_c1(self):

class CompiledTest(TestCase):
def setUp(self):
import platform
if platform.system() == 'Windows':
self.skipTest('Skipping test on Windows')
import subprocess
from mccode_antlr.config import config
try:
subprocess.run([config['cc'].get(str), '--version'], check=True)
except FileNotFoundError:
log.info(f'Provide alternate C compiler via MCCODE_ANTLR_CC environment variable')
self.skipTest(f"C compiler {config['cc']} not found")


class CompiledInstr(CompiledTest):
def _compile_and_run(self, instr, parameters, run=True):
from mccode_antlr.compiler.c import compile_instrument, CBinaryTarget, run_compiled_instrument
from mccode_antlr.translators.target import MCSTAS_GENERATOR
from mccode_antlr.loader import read_mccode_dat
from mccode_antlr.config import config as module_config
from tempfile import TemporaryDirectory
from os import R_OK, access
from pathlib import Path
Expand All @@ -430,7 +435,7 @@ def _compile_and_run(self, instr, parameters, run=True):
except RuntimeError as e:
log.error(f'Failed to compile instrument: {e}')
raise e
binary = Path(directory).joinpath(f'{instr.name}.out')
binary = Path(directory).joinpath(f'{instr.name}{module_config["ext"].get(str)}')
self.assertTrue(binary.exists())
self.assertTrue(binary.is_file())
self.assertTrue(access(binary, R_OK))
Expand Down