Skip to content

Commit

Permalink
Fixup embed script
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Feb 10, 2023
1 parent b2affc0 commit f9be158
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
26 changes: 19 additions & 7 deletions sdf/embedSdf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
import inspect
import sys
from pathlib import Path, PurePosixPath

""""Script for generating a C++ file that contains the content from all SDF files"""
Expand Down Expand Up @@ -130,15 +131,26 @@ def get_file_header_epilog() -> str:
if __name__ == "__main__":
copyright = get_copyright_notice()
prolog = get_file_header_prolog()

map_str = ""
for sdf_version in SUPPORTED_SDF_VERSIONS:
pathlist = Path(sdf_version).glob('*.sdf')
map_str += get_map_content(pathlist)

for sdf_conversion in SUPPORTED_SDF_CONVERSIONS:
pathlist = Path(sdf_conversion).glob('*.convert')
map_str += get_map_content(pathlist)
if len(sys.argv) > 1:
# Sources are passed in as arguments (Bazel)
for filename in sorted(sys.argv[1:]):
_, relative_path = filename.split('/sdf/')

with open(filename, 'r', encoding='utf-8') as data:
content = data.read()
map_str += embed_sdf_content(relative_path, content)

else:
# Assume we are in current working directory
for sdf_version in SUPPORTED_SDF_VERSIONS:
pathlist = Path(sdf_version).glob('*.sdf')
map_str += get_map_content(pathlist)

for sdf_conversion in SUPPORTED_SDF_CONVERSIONS:
pathlist = Path(sdf_conversion).glob('*.convert')
map_str += get_map_content(pathlist)

# remove the last comma
map_str = map_str[:-2]
Expand Down
1 change: 0 additions & 1 deletion src/SDF_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <gz/utils/Environment.hh>
#include <gz/utils/SuppressWarning.hh>

#include "test_config.hh"
#include "test_utils.hh"

#include "sdf/sdf.hh"
Expand Down

0 comments on commit f9be158

Please sign in to comment.