Compilation fails when directory is not a git repository
Summary
Compilation fails when trying to generate build_info.h
when the openCARP source directory is not a git repository:
[ 13%] Generate a C header file defining some information about the build
fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
File "${OPENCARP_DIR}/simulator/build_info.py", line 204, in <module>
print_build_info(filename)
File "${OPENCARP_DIR}/simulator/build_info.py", line 184, in print_build_info
git_info = generate()
^^^^^^^^^^
File "${OPENCARP_DIR}/simulator/build_info.py", line 161, in generate
info = git(os.path.dirname(os.path.abspath(__file__)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "${OPENCARP_DIR}/simulator/build_info.py", line 108, in git
result = run(['git', 'rev-list', '--all', '--count'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "${OPENCARP_DIR}/simulator/build_info.py", line 39, in run
raise Exception(tpl.format(' '.join(cmd)))
Exception: execution of command "git rev-list --all --count" failed
This typically happens when compiling openCARP from the release tarball.
What version of openCARP are you using?
Commit: 5649e7b4
What operating system and processor architecture are you using?
macOS Monterey 12.5.1, arm64.
Steps to reproduce
- Download source code from the release page: https://git.opencarp.org/openCARP/openCARP/-/archive/v14.0/openCARP-v14.0.tar.gz
- go to
openCARP/simulator
and runbuild_info.py
What is the current bug behavior?
fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
File "${OPENCARP_DIR}/simulator/build_info.py", line 204, in <module>
print_build_info(filename)
File "${OPENCARP_DIR}/simulator/build_info.py", line 184, in print_build_info
git_info = generate()
^^^^^^^^^^
File "${OPENCARP_DIR}/simulator/build_info.py", line 161, in generate
info = git(os.path.dirname(os.path.abspath(__file__)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "${OPENCARP_DIR}/simulator/build_info.py", line 108, in git
result = run(['git', 'rev-list', '--all', '--count'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "${OPENCARP_DIR}/simulator/build_info.py", line 39, in run
raise Exception(tpl.format(' '.join(cmd)))
Exception: execution of command "git rev-list --all --count" failed
What is the expected correct behavior?
No error (nor output) appears, the file build_info.h
is generated in the current working directory.
Possible fixes
- Make it possible to run build_info.py even outside of a git repository