usResourceCompiler3

See also Framework for a high-level description.

Command-Line Reference

The following options are supported by the usResourceCompiler3 program:

--help, -h

Print usage and exit.

--verbose, -V

Run in verbose mode.

--bundle-name, -n

The bundle name as specified in the US_BUNDLE_NAME compile definition.

--compression-level, -c

Compression level used for zip. Value range is 0 to 9. Default value is 6.

--out-file, -o

Path to output zip file. If the file exists it will be overwritten. If this option is not provided, a temporary zip fie will be created.

--res-add, -r

Path to a resource file, relative to the current working directory.

--zip-add, -z

Path to a file containing a zip archive to be merged into the output zip file.

--manifest-add, -m

Path to the bundle’s manifest file. If multiple –manifest-add options are specified, all manifest files will be concatenated into one.

--bundle-file, -b

Path to the bundle binary. The resources zip file will be appended to this binary.

Note

  1. Only options --res-add, --zip-add and --manifest-add can be specified multiple times.
  2. If option --manifest-add or --res-add is specified, option --bundle-name must be provided.
  3. At-least one of --bundle-file or --out-file options must be provided.

Hint

If you are using CMake, consider using the provided usFunctionEmbedResources CMake macro which handles the invocation of the usResourceCompiler3 executable and sets up the correct file dependencies. Otherwise, you also need to make sure that the set of static bundles linked into a shared bundle or executable is also in the input file list of your usResourceCompiler3 call for that shared bundle or executable.

Here is a full example creating a bundle and embedding resource data:

set(bundle_name "org_me_mybundle")
set(srcs mybundle.cpp)

usFunctionGenerateBundleInit(TARGET mybundle OUT srcs)
usFunctionGetResourceSource(TARGET mybundle OUT srcs)

add_library(mybundle ${srcs})
target_link_libraries(mybundle CppMicroServices)

set_property(TARGET mybundle APPEND PROPERTY COMPILE_DEFINITIONS US_BUNDLE_NAME=${bundle_name})
set_property(TARGET mybundle PROPERTY US_BUNDLE_NAME ${bundle_name})

usFunctionEmbedResources(TARGET mybundle
  FILES hello.txt
)

If you are not using CMake, you can run the resource compiler from the command line yourself.

Example usage

Construct a zip blob with contents mybundle/manifest.json, merge the contents of zip file filetomerge.zip into it and write the resulting blob into Example.zip:

usResourceCompiler3 --compression-level 9 --verbose --bundle-name mybundle
  --out-file Example.zip --manifest-add manifest.json --zip-add filetomerge.zip

Construct a zip blob with contents mybundle/manifest.json, merge the contents of zip file archivetomerge.zip into it and append the resulting zip blob to mybundle.dylib:

usResourceCompiler3 -V -n mybundle -b mybundle.dylib -m manifest.json
  -z archivetomerge.zip

Append the contents of archivetoembed.zip to mybundle.dll:

usResourceCompiler3.exe -b mybundle.dll -z archivetoembed.zip

Construct a zip blob with the contents of manifest_part1.json and auto_generated_manifest.json concatenated into mybundle/manifest.json and embed it into mybundle.dll:

usResourceCompiler3 -n mybundle -b mybundle.dll -m manifest_part1.json
  -m auto_generated_manifest.json