pcurl-file (proc)
public {pcurl-file
source-url:Url,
object-url:Url = {source-url.set-extension curl-binary-file-extension },
root-manifest-url:#Url = null,
manifest-url:#Url = null,
debug?:bool = false,
component-config:String = "",
create?:bool = true,
create-mode:int = 0o666,
error-if-exists?:bool = false
}:ComponentID
Package: CURL.LANGUAGE.COMPILER

Convert a package from Curl source to a compact representation (pcurl)

source-url: The Url of the package
object-url: The Url of the output. Defaults to the source-url with the extension .pcurl. Must differ from source-url or an error will be produced.
manifest-url: The Url of the manifest, if any, to be used when compiling the package from its source files.
root-manifest-url: The Url of the root manifest, if any, to be used when loading the manifest specified by manifest-url. See import-manifest for more information.
debug?: If set, includes debugging information, which includes human-readable source code, in the output. This will make the output file significantly larger, and makes source code available to human examination. Defaults to false, which yields a compact representation, and in particular will replace if-debuggable clauses with their else clauses when possible.
component-config: A String representing the component-config header expression for the package. This information will be prepended to the package code. Defaults to the empty string, in which case no component-config is written.
create?: Passed to write-open-byte when opening object-url.
create-mode: Passed to write-open-byte when opening object-url.
error-if-exists?: Passed to write-open-byte when opening object-url.

Returns

The ComponentID of the pcurled file.

Notes

The source package may list more than one API version in its herald, as in {curl 1.0, 1.1 package}, but the generated pcurl file will only work with the API under which the file was generated.

The following code is an example of how to use pcurl-file to create the .pcurl files for the packages in a project.

{curl 8.0 applet}

{let constant files:UrlArray =
    {UrlArray
        {url "load.scurl"},
        {url "common/load.scurl"},
        {url "screens/Projects/load.scurl"},
        {url "screens/Risk/load.scurl"},
        {url "pages/bar-chart-3d/load.scurl"},
        {url "pages/simple-graph/load.scurl"}
    }
}

{let status:VBox = {VBox}}

{let total-pcurl-size:int64 = 0}

{define-proc package {pcurl-file-by-index index:int}:void

    {if not {files.in-bounds? index} then
        {status.add
            "Total pcurled size = " & total-pcurl-size & " bytes."
        }
        {return}
    }

    let u:Url = files[index]
    {status.add "Beginning to pcurl '" & u & "'"}

    {try
        {pcurl-file u}
        let u2:Url = {u.set-extension ".pcurl"}
        let size:int64 = {{u2.resolve}.info}.size
        {status.add
            "Created '" & u2 & "', size = " & size & " bytes."
        }
        {inc total-pcurl-size, size}
     catch ex:Exception do
        {status.add
            {text color = "red", Error: {value ex}}
        }
    }

    {status.add {Fill height = 5pt}}

    {after 0s do
        {pcurl-file-by-index index + 1}
    }
}

{if not {process-privileged?} then
    {center
        color = "red",
        This page requires trusted access to your system 
        in order to translate packages to single pcurl files.
        Please use the Curl Control Panel to give privilege
        to this applet.
    }
 else
    {status.add "Starting to pcurl all the packages..."}
    {status.add {Fill height = 5pt}}
    {after 0s do
        {pcurl-file-by-index 0}
    }
    {value status}
}

Revisions

The root-manifest-url keyword was introduced in Curl 7.0.