-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feat: Automate building of manpages #31
Feat: Automate building of manpages #31
Conversation
a913157
to
105b227
Compare
Signed-off-by: Jack Luar <[email protected]>
Signed-off-by: Jack Luar <[email protected]>
Signed-off-by: Jack Luar <[email protected]>
Signed-off-by: Jack Luar <[email protected]>
d042ec5
to
de5a8e6
Compare
Signed-off-by: Jack Luar <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some breaking down into functions suggestions. This refactor would be good to add CI steps to test these. I will leave it approved, but if you choose to implement some of the features in this PR just request another review.
# clone repo | ||
or_url = 'https://github.com/The-OpenROAD-Project/OpenROAD' | ||
cur_dir = os.path.dirname(os.path.realpath(__file__)) | ||
target_dir = os.path.join(cur_dir, 'OpenROAD') | ||
command = f"git clone {or_url} --depth 1 {target_dir}" | ||
res = subprocess.run(command, shell=True, capture_output=True) | ||
if res.returncode != 0: | ||
print(f"Error in cloning OpenROAD: {res.stderr.decode('utf-8')}") | ||
sys.exit(1) | ||
print('Cloned OpenROAD successfully.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would break this into a function.
# check if pandoc is installed, if not error out. | ||
res = subprocess.run('pandoc --version', shell=True, capture_output=True) | ||
if res.returncode != 0: | ||
print('Pandoc is not installed. Please install it.') | ||
sys.exit(1) | ||
print('Pandoc is installed.') | ||
|
||
# generate manpages | ||
command = '../../etc/find_messages.py > messages.txt' | ||
for module in os.listdir(os.path.join(cur_dir, 'OpenROAD/src')): | ||
path = os.path.join(cur_dir, 'OpenROAD/src', module) | ||
if not os.path.isdir(path): | ||
continue | ||
print('Processing module:', module) | ||
os.chdir(path) | ||
res = subprocess.run(command, shell=True, capture_output=True) | ||
if res.returncode != 0: | ||
print(f"Error in finding messages for {module}: {res.stderr.decode('utf-8')}") | ||
continue | ||
os.chdir(os.path.join(cur_dir, 'OpenROAD/docs')) | ||
num_cores = os.cpu_count() | ||
command = f"make clean && make preprocess && make -j{num_cores}" | ||
res = subprocess.run(command, shell=True, capture_output=True) | ||
print('Finished building manpages.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be another function
# copy folder contents to data/markdown/manpages | ||
src_dir = os.path.join(cur_dir, 'OpenROAD/docs/md') | ||
dest_dir = os.path.join(cur_dir, 'data/markdown/manpages') | ||
shutil.copytree(src_dir, dest_dir, dirs_exist_ok=True) | ||
print('Copied manpages to data/markdown/manpages.') | ||
|
||
# update source_dict | ||
for root, _, files in os.walk(dest_dir): | ||
for file in files: | ||
file_path = os.path.join(root, file) | ||
file_name = os.path.basename(file_path) | ||
source_dict[file_path] = file_name | ||
|
||
# change back to the file directory | ||
os.chdir(cur_dir) | ||
shutil.rmtree('OpenROAD') | ||
print('Removed OpenROAD temp directory.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be another function.
Fixes #7