Skip to content

Commit

Permalink
Fix up chpl-env-gen.h and test of it
Browse files Browse the repository at this point in the history
Use a more comprehensive solution to get to characters
that can be in a #define and use the same strategy
in the test code as well as the Makefile generating it.

---
Signed-off-by: Michael Ferguson <[email protected]>
  • Loading branch information
mppf committed Aug 11, 2022
1 parent 6f15dd9 commit c33c5a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
10 changes: 3 additions & 7 deletions runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ $(CHPL_ENV_HEADER): $(CHPL_MAKE_HOME)/util/printchplenv $(CHPL_MAKE_HOME)/util/c
@echo "#ifndef _CHPL_ENV_GEN_H_" >> $(CHPL_ENV_HEADER)
@echo "#define _CHPL_ENV_GEN_H_" >> $(CHPL_ENV_HEADER)
@$(CHPL_MAKE_HOME)/util/printchplenv --runtime --no-tidy --anonymize --simple | \
grep -v CHPL_HOST_CC | \
grep -v CHPL_HOST_CXX | \
grep -v CHPL_TARGET_CC | \
grep -v CHPL_TARGET_CXX | \
sed s/[-+.\/]/_/g | \
sed s/\=/' '/ | \
awk '{ print "#define " $$1 "_" toupper($$2) }' >> $(CHPL_ENV_HEADER)
sed 's/^[ \t]*//;s/[ \t]*$$//' | \
sed 's/[^0-9A-Za-z]/_/g' | \
awk '{ print "#define " toupper($$1) }' >> $(CHPL_ENV_HEADER)
@echo "#endif /* _CHPL_ENV_GEN_H_ */" >> $(CHPL_ENV_HEADER)

THIRD_PARTY_PKGS = $(shell $(CHPL_MAKE_PYTHON) $(CHPL_MAKE_HOME)/util/chplenv/third-party-pkgs)
Expand Down
12 changes: 7 additions & 5 deletions test/runtime/sungeun/chpl-env-gen.precomp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import os
import re
import shutil
import subprocess
import sys
Expand All @@ -19,11 +20,12 @@ testname = sys.argv[1]
genfile = testname+'.test.gen.c'
with open(genfile, 'w') as f:
for key,val in chpl_env.items():
if (key == 'CHPL_HOST_CC' or key == 'CHPL_HOST_CXX' or
key == 'CHPL_TARGET_CC' or key == 'CHPL_TARGET_CXX'):
continue

key_val = key+'_'+val.replace('-', '_').replace('/', '_').upper()
key = key.strip()
val = val.strip()
# munge characters similarly to Makefile generating them
key_val = key+'_'+val
key_val = re.sub(r'[^0-9A-Za-z]', '_', key_val)
key_val = key_val.upper()
f.write('#ifndef %s\n'%(key_val))
f.write('#error "%s undefined or does not match runtime definition"\n'%(val))
f.write('#endif\n')
Expand Down

0 comments on commit c33c5a0

Please sign in to comment.