Skip to content

Commit

Permalink
fix windows build fail
Browse files Browse the repository at this point in the history
And some wrong typo errors

Signed-off-by: Jerry Yu <[email protected]>
  • Loading branch information
yuhaoth committed Sep 23, 2021
1 parent 1d181d1 commit 56f9b87
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 8 additions & 1 deletion library/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ endif

PERL ?= perl

ifdef WINDOWS
PYTHON ?= python
else
PYTHON ?= $(shell if type python3 >/dev/null 2>/dev/null; then echo python3; else echo python; fi)
endif

# if were running on Windows build for Windows
ifdef WINDOWS
WINDOWS_BUILD=1
Expand Down Expand Up @@ -287,7 +293,8 @@ state.c: ../scripts/generate_states.py
state.c: $(filter-out %config%,$(wildcard ../include/mbedtls/*.h))
state.c:
echo " Gen $@"
$(PYTHON) ../scripts/generate_states.py >$@
echo $(PYTHON) ../scripts/generate_states.py
$(PYTHON) ../scripts/generate_states.py

version_features.c: ../scripts/generate_features.pl
version_features.c: ../scripts/data_files/version_features.fmt
Expand Down
8 changes: 5 additions & 3 deletions scripts/generate_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
}}
#endif /* MBEDTLS_DEBUG_C */
/* End of automatically generated file. */
'''

def generate_states(target_dir):
Expand All @@ -63,11 +64,11 @@ def generate_states(target_dir):
compiler = os.getenv('CC', 'cc')
proc = subprocess.Popen("{compiler} -E -P -xc -Iinclude -".format(compiler=compiler),
stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
stdout, stderr = proc.communicate(b'#include "mbedtls/ssl.h"')
stdout, _ = proc.communicate(b'#include "mbedtls/ssl.h"')
print_flag = False
_temp = ''

for no, line in zip(range(2**32), stdout.decode().splitlines()):
for line in stdout.decode().splitlines():
if 'typedef enum' in line:
print_flag = True
_temp = ''
Expand All @@ -82,7 +83,8 @@ def generate_states(target_dir):
_temp = ['[{state}] = "{state}"'.format(state=i) for i in _temp if i]
break
split_str = ',\n' + ' '*8
print(OUTPUT_TEMPLATE.format(state_list=split_str.join(_temp)))
with open(os.path.join(target_dir, 'state.c'), 'w') as f:
f.write(OUTPUT_TEMPLATE.format(state_list=split_str.join(_temp)))

if __name__ == '__main__':
build_tree.chdir_to_root()
Expand Down
1 change: 1 addition & 0 deletions scripts/make_generated_files.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ perl scripts\generate_features.pl || exit /b 1
perl scripts\generate_visualc_files.pl || exit /b 1
python scripts\generate_psa_constants.py || exit /b 1
python tests\scripts\generate_psa_tests.py || exit /b 1
python scripts\generate_states.py || exit /b 1

0 comments on commit 56f9b87

Please sign in to comment.