Skip to content

Commit

Permalink
fix coding codegen for gitlab ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbusch committed Dec 9, 2024
1 parent ff4192e commit e5c7920
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions utils/codegen/asn1ToC/asn1ToC.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,24 @@ def main():
if args.temp_dir is None:
container_input_dir = temp_input_dir
container_output_dir = temp_output_dir
asn1c_cmd_file = tempfile.NamedTemporaryFile(delete=False).name
else:
container_input_dir = os.path.join(args.temp_dir, "input")
container_output_dir = os.path.join(args.temp_dir, "output")
os.makedirs(container_input_dir, exist_ok=True)
os.makedirs(container_output_dir, exist_ok=True)
asn1c_cmd_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "asn1c.sh")

# copy input asn1 files to temporary directory
for f in args.files:
shutil.copy(f, container_input_dir)

# run asn1c docker container to generate header and source files
asn1c_cmd_file = tempfile.NamedTemporaryFile(delete=False)
with open(asn1c_cmd_file.name, "w") as f:
with open(asn1c_cmd_file, "w") as f:
f.write(f"asn1c $(find /input -name '*.asn' | sort) -fcompound-names -fprefix={args.type}_ -no-gen-BER -no-gen-XER -no-gen-JER -no-gen-OER -no-gen-example -gen-UPER")

subprocess.run(["docker", "run", "--rm", "-u", f"{os.getuid()}:{os.getgid()}", "-v", f"{container_input_dir}:/input:ro", "-v", f"{container_output_dir}:/output", "-v", f"{asn1c_cmd_file.name}:/asn1c.sh", args.docker_image], check=True)
os.remove(asn1c_cmd_file.name)
subprocess.run(["docker", "run", "--rm", "-u", f"{os.getuid()}:{os.getgid()}", "-v", f"{container_input_dir}:/input:ro", "-v", f"{container_output_dir}:/output", "-v", f"{asn1c_cmd_file}:/asn1c.sh", args.docker_image], check=True)
os.remove(asn1c_cmd_file)

# move generated header and source files to output directories
for f in glob.glob(os.path.join(container_output_dir, "*.h")):
Expand Down

0 comments on commit e5c7920

Please sign in to comment.