diff --git a/docs/getting-started/cpp.mdx b/docs/getting-started/cpp.mdx index b36c6d9..2cd1f1f 100644 --- a/docs/getting-started/cpp.mdx +++ b/docs/getting-started/cpp.mdx @@ -1,38 +1,30 @@ -# Getting Started: C++ +# Getting Started: C / C++ -Get started with our cross-platform C++ header library. - -1. Copy [Velopack.hpp](https://github.com/velopack/velopack.fusion/blob/master/for-cpp/Velopack.hpp) and [Velopack.cpp](https://github.com/velopack/velopack.fusion/blob/master/for-cpp/Velopack.cpp) into your project. - -0. Configure Unicode Support: - #### Windows - On Windows, to enable unicode support for this library you ***must*** - [configure the UTF-8 code page](https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page) via your application - manifest. Failure to do so will potentially result in your application ***failing to update*** if there are any unicode characters in your user's - file paths, username, etc. - ```xml - - - - - UTF-8 - - - - ``` - #### Linux & MacOS - - If you are using Qt and `QString` is available, there's nothing further you need to do. - - If you are not using Qt, you'll need to [install ICU4C](https://icu.unicode.org/). Like many other C libraries, - installing the development package with your package manager (`apt`, `brew` etc) *should* be sufficient to make it available to compilers. +Get started with our cross-platform C / C++ library. + +The Velopack C / C++ library is a pre-compiled dynamic library, which you can link into your application to enable auto-updates and installers. +There is a C and a C++ API available in [Velopack.h](https://github.com/velopack/velopack/blob/develop/src/lib-cpp/include/Velopack.h), +so this library is suitable for C / C++ application as well as other programming languages which support calling C functions eg. p/invoke. + +:::tip +All the strings (eg. `char*` or `std::string`) are expected to be UTF-8 encoded. +On Windows, you may need to convert `wchar_t*` and `std::wstring` to UTF-8 before passing it to the library. +::: + +1. Download the latest `velopack_libc_{version}.zip` from [GitHub Releases](https://github.com/velopack/velopack/releases) and include it into your project. -0. Add the `Velopack::startup()` to your entry point (eg. `main()` or `wmain()`) as early as possible, ideally the first statement to run: +0. Add the `include` directory to your include path, and add the appropriate binary from `lib` to your linker options. + +0. Add `VelopackApp` to your entry point (eg. `main()` or `wmain()`) as early as possible, ideally the first statement to run: ```cpp - #include "Velopack.hpp" + #include "Velopack.h" wmain(int argc**, wchar_t *argv[ ], wchar_t *envp[ ]) { - // Velopack may exit / restart your app at this statement - Velopack::startup(argv, argc); + // This should run as early as possible in the main method. + // Velopack may exit / restart the app at this point. + // See VelopackApp class for more options/configuration. + Velopack::VelopackApp::Build().Run(); // ... your other startup code here } @@ -40,21 +32,23 @@ Get started with our cross-platform C++ header library. 0. Add auto-updates somewhere to your app: ```cpp - #include "Velopack.hpp" - #include + #include "Velopack.h" static void update_app() { - Velopack::UpdateManagerSync manager{}; - manager.setUrlOrPath("https://the.place/you-host/updates"); + Velopack::UpdateManager manager("https://the.place/you-host/updates"); - auto updInfo = manager.checkForUpdates(); - if (updInfo == nullptr) { + auto updInfo = manager.CheckForUpdates(); + if (!updInfo.has_value()) { return; // no updates available } - manager.downloadUpdates(updInfo->targetFullRelease.get()); - manager.applyUpdatesAndRestart(updInfo->targetFullRelease.get()); + // download the update, optionally providing progress callbacks + manager.DownloadUpdates(updInfo.value()); + + // prepare the Updater in a new process, and wait 60 seconds for this process to exit + manager.WaitExitThenApplyUpdate(updInfo.value()); + exit(0); // exit the app to apply the update } ``` @@ -69,11 +63,6 @@ Get started with our cross-platform C++ header library. 0. Compile your app to a program using your usual compiler (eg. msvc, cmake, gcc, etc) -0. Copy `Vfusion.exe`, `VfusionMac` or `VfusionNix` to your build output folder. This is a manual step for now, but may be automated in the future. You can compile this yourself, download a [recent build artifact](https://github.com/velopack/velopack.fusion/actions), or grab the latest [npm release](https://www.npmjs.com/package/velopack?activeTab=code) which also bundles the binaries. - :::warning - Until this is automated, failing to copy the fusion binary to your update directory will result in your app being unable to update. - ::: - 0. Package your Velopack release / installers: ```sh vpk pack -u MyAppUniqueId -v 1.0.0 -p /myBuildDir -e myexename.exe diff --git a/docs/index.mdx b/docs/index.mdx index d03c8a8..22f64a1 100644 --- a/docs/index.mdx +++ b/docs/index.mdx @@ -32,16 +32,18 @@ You can host updates anywhere static files can be served, eg. cloud file storage ## Language Support There are libraries planned or supported for the languages below. -| Lang | Status | Runtime Deps | Async | Links | -|:-:|---|---|---|---| -| C# | ✅ Ready | ✅ None | ✅ Yes | [quick start](./getting-started/csharp.mdx), [docs](./reference/cs/Velopack/), [nuget.org](https://nuget.org/packages/velopack) | -| Rust | ✅ Ready | ✅ None | ✅ Yes | [quick start](./getting-started/rust.mdx), [docs](https://docs.rs/velopack), [crates.io](https://crates.io/crates/velopack) | -| JS | ✅ Ready | ✅ None | ✅ Yes | [quick start](./getting-started/electron.mdx), [docs](./reference/js), [npmjs.com](https://www.npmjs.com/package/velopack) | -| C++ | 🔶 Experimental | 🔶 vfusion.exe | ❌ No | [quick start](./getting-started/cpp.mdx), [docs](./reference/cpp/api.md), [velopack.hpp](https://github.com/velopack/velopack.fusion/tree/master/for-cpp) | -| Java | Planned | - | - | - | - | -| Python | Planned | - | - | - | - | -| Swift | Planned | - | - | - | - | -| Go | Planned | - | - | - | - | +| Lang | Status | Links | +|:-:|---|---| +| C# | ✅ Ready | [quick-start](./getting-started/csharp.mdx), [docs](./reference/cs/Velopack/), [nuget.org](https://nuget.org/packages/velopack) | +| Rust | ✅ Ready | [quick-start](./getting-started/rust.mdx), [docs](https://docs.rs/velopack), [crates.io](https://crates.io/crates/velopack) | +| JS | ✅ Ready | [quick-start](./getting-started/electron.mdx), [docs](./reference/js), [npmjs.com](https://www.npmjs.com/package/velopack) | +| C++ | ✅ Ready | [quick-start](./getting-started/cpp.mdx), [docs](./reference/cpp/api.md), [gh-releases](https://github.com/velopack/velopack/releases) | +| Java | Planned | - | - | +| Python | Planned | - | - | +| Swift | Planned | - | - | +| Go | Planned | - | - | + +Don't see your language here? [Open an issue](https://github.com/velopack/velopack/issues/new) to request and tell us how great it is! ## Migrating to Velopack It should be easy to migrate to Velopack from other update frameworks. We do have some guides, but if we're missing one for your case please let us know about it on GitHub or Discord! diff --git a/docs/reference/cpp/api.md b/docs/reference/cpp/api.md index 7c75513..f8ff550 100644 --- a/docs/reference/cpp/api.md +++ b/docs/reference/cpp/api.md @@ -1,3 +1,7 @@ +:::warning +## This page is currently out of date. Please see the [C++ Quick Start](../../getting-started/cpp.mdx) for the most accurate information. +::: + # Velopack C++ Reference Members | Descriptions diff --git a/sidebars.ts b/sidebars.ts index e8445a7..a037883 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -44,7 +44,7 @@ const sidebars: SidebarsConfig = { label: 'Quick Start', items: [ doc("getting-started/csharp", "C# / .NET"), - doc("getting-started/cpp", "C++"), + doc("getting-started/cpp", "C / C++"), doc("getting-started/electron", "JS / Electron"), doc("getting-started/rust", "Rust"), doc("getting-started/uno", "C# / Uno Platform"),