1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677openCoreopenPpxlibopenAst_builder.Defaultletfile_path_to_absolute_string~loccompile_time_file_path=letopen(valAst_builder.makeloc)inletentire_file=In_channel.with_filecompile_time_file_path~f:In_channel.input_allinestringentire_file;;letfile_path_to_absolute_string_with_filename~loccompile_time_file_path=letentire_file=In_channel.with_filecompile_time_file_path~f:In_channel.input_allin[%expr[%eestring~loc:{locwithloc_ghost=true}compile_time_file_path],[%eestring~locentire_file]];;letdecompress_tar_file~locarchivefilename=lettempdir=Core_unix.mkdtemp"./ppx-embed-tmp"inlet()=Shell.run"tar"["-C";tempdir;"-xf";archive;filename]inletresult=file_path_to_absolute_string~loc(sprintf"%s/%s"tempdirfilename)inlet()=Shell.run"rm"["-rf";tempdir]inresult;;letembed_file_as_string=Extension.V3.declare"embed_file_as_string"Extension.Context.expressionAst_pattern.(single_expr_payload(estring__))(fun~ctxtrelative_file_path->file_path_to_absolute_string~loc:(Expansion_context.Extension.extension_point_locctxt)relative_file_path)|>Ppxlib.Context_free.Rule.extension;;letembed_file_as_string_with_filename=Extension.V3.declare"embed_file_as_string_with_filename"Extension.Context.expressionAst_pattern.(single_expr_payload(estring__))(fun~ctxtrelative_file_path->file_path_to_absolute_string_with_filename~loc:(Expansion_context.Extension.extension_point_locctxt)relative_file_path)|>Ppxlib.Context_free.Rule.extension;;letembed_file_in_tar_archive_as_string=Extension.V3.declare"embed_file_in_tar_archive_as_string"Extension.Context.expressionAst_pattern.(single_expr_payload(estring__))(fun~ctxtarchive_and_file_path->letarchive_and_file_path=String.split~on:':'archive_and_file_pathinmatcharchive_and_file_pathwith|[archive;file_path]->decompress_tar_file~loc:(Expansion_context.Extension.extension_point_locctxt)archivefile_path|_->raise_s[%message"Archive file paths should be in the form archive_path:file_path"])|>Ppxlib.Context_free.Rule.extension;;let()=Driver.register_transformation~rules:[embed_file_as_string;embed_file_as_string_with_filename;embed_file_in_tar_archive_as_string]"ppx_embed_file";;