This commit is contained in:
2025-05-24 16:59:22 -04:00
parent 7bdd323056
commit 2c8043db4f
10 changed files with 22 additions and 4 deletions

14
scripts/example_package.bellos Executable file
View File

@@ -0,0 +1,14 @@
# Example Package for CPP
python3 ../src/brsoa_create_package.py ../example example_package cpp
# Example Package for Python
python3 ../src/brsoa_create_package.py ../example example_package python
# Example Package for Java
python3 ../src/brsoa_create_package.py ../example example_package java
# Example Package for Rust
python3 ../src/brsoa_create_package.py ../example example_package rust
# Example Package for Go
python3 ../src/brsoa_create_package.py ../example example_package go

View File

@@ -138,10 +138,13 @@ func main() {{
}}
"""
def create_package(package_name, language):
package_dir = os.path.join("src", package_name)
def create_package(directory, package_name, language):
package_dir = os.path.join(directory, package_name)
os.makedirs(package_dir, exist_ok=True)
# Make Directory for package if it exits
os.makedirs(package_dir, exist_ok=True)
# Create package.bellande
with open(os.path.join(package_dir, "package.bellande"), "w") as f:
f.write(create_package_bellande(package_name, language, ["common_msgs"]))
@@ -165,7 +168,7 @@ def create_package(package_name, language):
elif language == "java":
source_filename = f"{package_name.capitalize()}.java"
elif language == "rust":
source_filename = "main.rs"
source_filename = f"{package_name}.rust"
os.makedirs(os.path.join(package_dir, "src"), exist_ok=True)
with open(os.path.join(package_dir, "Cargo.toml"), "w") as f:
f.write(f"[package]\nname = \"{package_name}\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\ncommon_msgs = {{ path = \"../../build/common_msgs\" }}\n")
@@ -179,10 +182,11 @@ def create_package(package_name, language):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Create a new package for the robot architecture.")
parser.add_argument("directory", help="Directory where you want to make it")
parser.add_argument("package_name", help="Name of the package to create")
parser.add_argument("language", choices=["cpp", "python", "java", "rust", "go"], help="Programming language for the package")
args = parser.parse_args()
create_package(args.package_name, args.language)
create_package(args.directory, args.package_name, args.language)
print(f"Created package {args.package_name} using {args.language}")