diff --git a/.github/workflows/bundle.yml b/.github/workflows/bundle.yml new file mode 100644 index 0000000..d1b2ffe --- /dev/null +++ b/.github/workflows/bundle.yml @@ -0,0 +1,415 @@ +name: Bundle + +# The bundle's installers, built of a commit per layer: the jobs Resolve revisions to Stage lay every staging +# into this run, Configure and Build pack the installers from them, Push publishes them to +# ghcr.io//bundle/native, identified by the commits they are built from. +# +# The commits are bundle.json's, each replaced by an input that is set (a commit, or a branch or tag taken at its head +# now); a module can be left out (exclude-stagings). The stagings come from the registry, by staging-pull, from +# ghcr.io/openDAQ/staging/ by the commit each was built of; a module's is asked for by the core it was built +# against too, so the modules of one bundle share its core. A staging the registry lacks is staged here by its +# layer's stage.yml, called, never pushed. Then reusable.yml builds each platform as the stagings were built: the +# stagings, artifacts -staging-, unpacked each into its own folder, given to the bundle as +# BUNDLE_PREFIX_ (configure preset bundle-prefixes), the commits as BUNDLE_REVISION_, the installer +# packed (package preset installer), into the artifact package-. On schedule every layer is taken at its main, +# not at bundle.json's. Pushed on schedule and by hand (unless skip-staging-push), in the bundle's own repository; +# called from another repository (a layer's CI), never. + +on: + # Mondays, after the stagings of the layers (core 02:00, modules 05:00) + schedule: + - cron: '0 6 * * 1' + workflow_dispatch: + inputs: + opendaq: + description: "openDAQ: a commit, branch or tag (empty: bundle.json's)" + type: string + default: "" + opcua-modules: + description: "OpcUaModules: a commit, branch or tag (empty: bundle.json's)" + type: string + default: "" + mqtt-module: + description: "MQTTStreamingModule: a commit, branch or tag (empty: bundle.json's)" + type: string + default: "" + lt-streaming-modules: + description: "LTStreamingModulesModern: a commit, branch or tag (empty: bundle.json's)" + type: string + default: "" + asam-cmp-modules: + description: "ASAM-CMP-Modules: a commit, branch or tag (empty: bundle.json's)" + type: string + default: "" + exclude-stagings: + description: "Stagings left out of the bundle, e.g. opcua-modules (;-separated; never opendaq)" + type: string + default: "" + skip-staging-push: + description: "Build only, keep the installers as artifacts of the run" + type: boolean + default: false + + workflow_call: + inputs: + opendaq: + description: "openDAQ: a commit, branch or tag (empty: bundle.json's)" + type: string + default: "" + opcua-modules: + description: "OpcUaModules: a commit, branch or tag (empty: bundle.json's)" + type: string + default: "" + mqtt-module: + description: "MQTTStreamingModule: a commit, branch or tag (empty: bundle.json's)" + type: string + default: "" + lt-streaming-modules: + description: "LTStreamingModulesModern: a commit, branch or tag (empty: bundle.json's)" + type: string + default: "" + asam-cmp-modules: + description: "ASAM-CMP-Modules: a commit, branch or tag (empty: bundle.json's)" + type: string + default: "" + exclude-stagings: + description: "Stagings left out of the bundle, e.g. opcua-modules (;-separated; never opendaq)" + type: string + default: "" + +permissions: + contents: read + packages: read + +jobs: + revisions: + name: Resolve revisions + runs-on: ubuntu-latest + outputs: + revisions: ${{ steps.revisions.outputs.revisions }} + platforms: ${{ steps.revisions.outputs.platforms }} + exclude-jobs: ${{ steps.revisions.outputs.exclude-jobs }} + staging-artifacts: ${{ steps.find.outputs.staging-artifacts }} + missing: ${{ steps.find.outputs.missing }} + steps: + # bundle.json of this workflow's own commit, whoever calls it + - uses: actions/checkout@v4 + with: + repository: ${{ job.workflow_repository }} + ref: ${{ job.workflow_sha }} + + - name: Resolve revisions + id: revisions + shell: python3 {0} + env: + INPUTS: ${{ toJSON(inputs) }} + # the bundle's own schedule, not a caller's: a scheduled workflow calling this one has that event too + SCHEDULED: ${{ github.event_name == 'schedule' && github.repository == 'openDAQ/openDAQ-bundle' }} + run: | + import json, os, re, subprocess, sys + + # one entry per platform the bundle is assembled for: + # key the reusable.yml job that packs it (its name picks the runner, the compiler, the generator) + # triplet the stagings it takes: com.opendaq.package.triplet of the packages pulled from ghcr + # generator the CPack generator of its installer + JOBS = { + # job triplet generator + "ubuntu-22.04-x86_64-ninja-gcc-release": ("x86_64-linux-gcc-11-release", "DEB"), + "ubuntu-22.04-armv8-ninja-gcc-release": ("armv8-linux-gcc-11-release", "DEB"), + "windows-2022-x86_64-msvs-v143-release": ("x86_64-windows-msvc-143-release", "NSIS"), + "macos-26-armv8-ninja-appleclang-21-release": ("armv8-macos-apple-clang-21-release", "productbuild"), + "macos-26-x86_64-ninja-appleclang-21-release": ("x86_64-macos-apple-clang-21-release", "productbuild"), + } + # the jobs of a layer's stage the bundle takes nothing from: not built when a layer is staged here + EXCLUDE_JOBS = ["manylinux*", "windows-*-x86-*"] + # a layer, named as its repository in bundle.json → its staging + STAGINGS = {"openDAQ": "opendaq", "OpcUaModules": "opcua-modules", "MQTTStreamingModule": "mqtt-module", + "LTStreamingModulesModern": "lt-streaming-modules", "ASAM-CMP-Modules": "asam-cmp-modules"} + REPOSITORIES = {staging: layer for layer, staging in STAGINGS.items()} + + inputs = json.loads(os.environ["INPUTS"] or "{}") or {} + + def commit(staging, ref): + """A full sha as it is; a branch or a tag → its commit, as the repository has it now.""" + if re.fullmatch(r"[0-9a-f]{40}", ref): + return ref + url = f"https://github.com/openDAQ/{REPOSITORIES[staging]}.git" + out = subprocess.run(["git", "ls-remote", url, ref], capture_output=True, text=True, check=True).stdout + refs = dict(reversed(line.split("\t")) for line in out.splitlines()) + for name in (f"refs/tags/{ref}^{{}}", f"refs/tags/{ref}", f"refs/heads/{ref}"): + if name in refs: + return refs[name] + sys.exit(f"::error::{REPOSITORIES[staging]} has no branch or tag {ref!r} (a commit is given in full)") + + # the stagings left out; never the core, which the modules are built against + excluded = [s.strip() for s in (inputs.get("exclude-stagings") or "").split(";") if s.strip()] + if unknown := [s for s in excluded if s not in REPOSITORIES]: + sys.exit(f"::error::exclude-stagings names {unknown}, which the bundle has not; it has {list(REPOSITORIES)}") + if "opendaq" in excluded: + sys.exit("::error::exclude-stagings leaves out opendaq, the core: the modules are built against it") + + # bundle.json's revisions, each replaced by an input that is set; on schedule every layer's main instead, as + # a module's schedule stages against the core's main; the stagings left out dropped + scheduled = os.environ["SCHEDULED"] == "true" + revision = {} + for layer, ref in json.load(open("bundle.json"))["layers"].items(): + staging = STAGINGS[layer] + if staging in excluded: + continue + given = (inputs.get(staging) or "").strip() + revision[staging] = commit(staging, given or ("main" if scheduled else ref)) + + platforms = [{"job": job, "triplet": triplet, "generator": generator} + for job, (triplet, generator) in JOBS.items()] + outputs = {"revisions": revision, "platforms": platforms, "exclude-jobs": EXCLUDE_JOBS, + "repositories": {staging: REPOSITORIES[staging] for staging in revision}} + print(json.dumps(outputs, indent=2)) + with open(os.environ["GITHUB_OUTPUT"], "a") as f: + for key, value in outputs.items(): + f.write(f"{key}={json.dumps(value)}\n") + + - name: List wanted stagings + id: wanted + shell: python3 {0} + env: + REVISIONS: ${{ steps.revisions.outputs.revisions }} + PLATFORMS: ${{ steps.revisions.outputs.platforms }} + run: | + import json, os + + revision = json.loads(os.environ["REVISIONS"]) + + # every staging of every platform, by its triplet, into an artifact named as the staging's own stage names + # it; optional: the check tells what is there + wanted = [] + for platform in json.loads(os.environ["PLATFORMS"]): + job, triplet = platform["job"], platform["triplet"] + for staging, sha in revision.items(): + annotations = {"org.opencontainers.image.revision": sha, "com.opendaq.package.triplet": triplet} + if staging != "opendaq": + annotations["com.opendaq.dependencies.opendaq.revision"] = revision["opendaq"] + wanted.append({"artifact": f"{staging}-staging-{job}", + "packages": [{"path": f"ghcr.io/openDAQ/staging/{staging}", + "annotations": annotations, "optional": True}]}) + + with open(os.environ["GITHUB_OUTPUT"], "a") as f: + f.write(f"packages={json.dumps(wanted)}\n") + + - name: Find existing stagings + id: check + uses: openDAQ/openDAQ-CI/.github/actions/staging-check@v4 + with: + packages: ${{ steps.wanted.outputs.packages }} + + # a staging missing on any platform is staged here, on all of them; the rest is pulled + - name: Find missing stagings + id: find + shell: python3 {0} + env: + WANTED: ${{ steps.wanted.outputs.packages }} + RESOLVED: ${{ steps.check.outputs.resolved }} + REVISIONS: ${{ steps.revisions.outputs.revisions }} + REPOSITORIES: ${{ steps.revisions.outputs.repositories }} + run: | + import json, os + + wanted = json.loads(os.environ["WANTED"]) + found = {entry["artifact"] for entry in json.loads(os.environ["RESOLVED"]) if entry["packages"]} + staging_of = lambda entry: entry["packages"][0]["path"].rsplit("/", 1)[1] + missing = sorted({staging_of(entry) for entry in wanted if entry["artifact"] not in found}) + + pull = [{**entry, "packages": [{k: v for k, v in package.items() if k != "optional"} for package in entry["packages"]]} + for entry in wanted if staging_of(entry) not in missing] + print(f"missing, staged here: {missing or 'none'}") + + revision, repository = json.loads(os.environ["REVISIONS"]), json.loads(os.environ["REPOSITORIES"]) + summary = ["| Staging | Revision | From |", "|-|-|-|"] + for staging, sha in revision.items(): + link = f"[`{sha[:12]}`](https://github.com/openDAQ/{repository[staging]}/commit/{sha})" + summary.append(f"| {staging} | {link} | {'staged in this run' if staging in missing else 'registry'} |") + with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f: + f.write("\n".join(summary) + "\n") + + with open(os.environ["GITHUB_OUTPUT"], "a") as f: + f.write(f"staging-artifacts={json.dumps(pull)}\n") + f.write(f"missing={json.dumps(missing)}\n") + + pull: + name: Pull stagings + needs: revisions + if: needs.revisions.outputs.staging-artifacts != '[]' + uses: openDAQ/openDAQ-CI/.github/workflows/staging-pull.yml@v4 + with: + staging-artifacts: ${{ needs.revisions.outputs.staging-artifacts }} + + stage-opendaq: + name: Stage openDAQ + needs: revisions + if: contains(fromJSON(needs.revisions.outputs.missing), 'opendaq') + permissions: + contents: read + packages: write # asked for by the stage.yml's push, which is never run from here + uses: openDAQ/openDAQ/.github/workflows/stage.yml@main + with: + ref: ${{ fromJSON(needs.revisions.outputs.revisions)['opendaq'] }} + exclude-jobs: ${{ needs.revisions.outputs.exclude-jobs }} + + # after the core is in the run, pulled or staged, so the module's stage does not pull it again + stage-opcua-modules: + name: Stage OpcUaModules + needs: [revisions, pull, stage-opendaq] + if: >- + always() && needs.revisions.result == 'success' + && !contains(fromJSON('["failure", "cancelled"]'), needs.pull.result) + && !contains(fromJSON('["failure", "cancelled"]'), needs.stage-opendaq.result) + && contains(fromJSON(needs.revisions.outputs.missing), 'opcua-modules') + permissions: + contents: read + packages: write + uses: openDAQ/OpcUaModules/.github/workflows/stage.yml@main + with: + ref: ${{ fromJSON(needs.revisions.outputs.revisions)['opcua-modules'] }} + opendaq-ref: ${{ fromJSON(needs.revisions.outputs.revisions)['opendaq'] }} + exclude-jobs: ${{ needs.revisions.outputs.exclude-jobs }} + + stage-mqtt-module: + name: Stage MQTTStreamingModule + needs: [revisions, pull, stage-opendaq] + if: >- + always() && needs.revisions.result == 'success' + && !contains(fromJSON('["failure", "cancelled"]'), needs.pull.result) + && !contains(fromJSON('["failure", "cancelled"]'), needs.stage-opendaq.result) + && contains(fromJSON(needs.revisions.outputs.missing), 'mqtt-module') + permissions: + contents: read + packages: write + uses: openDAQ/MQTTStreamingModule/.github/workflows/stage.yml@main + with: + ref: ${{ fromJSON(needs.revisions.outputs.revisions)['mqtt-module'] }} + opendaq-ref: ${{ fromJSON(needs.revisions.outputs.revisions)['opendaq'] }} + exclude-jobs: ${{ needs.revisions.outputs.exclude-jobs }} + + stage-lt-streaming-modules: + name: Stage LTStreamingModulesModern + needs: [revisions, pull, stage-opendaq] + if: >- + always() && needs.revisions.result == 'success' + && !contains(fromJSON('["failure", "cancelled"]'), needs.pull.result) + && !contains(fromJSON('["failure", "cancelled"]'), needs.stage-opendaq.result) + && contains(fromJSON(needs.revisions.outputs.missing), 'lt-streaming-modules') + permissions: + contents: read + packages: write + uses: openDAQ/LTStreamingModulesModern/.github/workflows/stage.yml@main + with: + ref: ${{ fromJSON(needs.revisions.outputs.revisions)['lt-streaming-modules'] }} + opendaq-ref: ${{ fromJSON(needs.revisions.outputs.revisions)['opendaq'] }} + exclude-jobs: ${{ needs.revisions.outputs.exclude-jobs }} + + stage-asam-cmp-modules: + name: Stage ASAM-CMP-Modules + needs: [revisions, pull, stage-opendaq] + if: >- + always() && needs.revisions.result == 'success' + && !contains(fromJSON('["failure", "cancelled"]'), needs.pull.result) + && !contains(fromJSON('["failure", "cancelled"]'), needs.stage-opendaq.result) + && contains(fromJSON(needs.revisions.outputs.missing), 'asam-cmp-modules') + permissions: + contents: read + packages: write + uses: openDAQ/ASAM-CMP-Modules/.github/workflows/stage.yml@main + with: + ref: ${{ fromJSON(needs.revisions.outputs.revisions)['asam-cmp-modules'] }} + opendaq-ref: ${{ fromJSON(needs.revisions.outputs.revisions)['opendaq'] }} + exclude-jobs: ${{ needs.revisions.outputs.exclude-jobs }} + + configure: + name: Configure + needs: revisions + runs-on: ubuntu-latest + outputs: + jobs: ${{ steps.configure.outputs.jobs }} + packages: ${{ steps.configure.outputs.packages }} + cmake-presets: ${{ steps.configure.outputs.cmake-presets }} + cpack-presets: ${{ steps.configure.outputs.cpack-presets }} + staging-push: ${{ steps.configure.outputs.staging-push }} + steps: + - name: Configure + id: configure + shell: python3 {0} + env: + REVISIONS: ${{ needs.revisions.outputs.revisions }} + PLATFORMS: ${{ needs.revisions.outputs.platforms }} + OWNER: ${{ github.repository_owner }} + run: | + import json, os + + # a staging → its layer, named as its repository (BUNDLE_REVISION_) + REPOSITORIES = {"opendaq": "openDAQ", "opcua-modules": "OpcUaModules", "mqtt-module": "MQTTStreamingModule", + "lt-streaming-modules": "LTStreamingModulesModern", "asam-cmp-modules": "ASAM-CMP-Modules"} + revision = json.loads(os.environ["REVISIONS"]) + platforms = json.loads(os.environ["PLATFORMS"]) + + packages, cmake_presets, cpack_presets = [], [], [] + for p in platforms: + job = p["job"] + # the commits resolved there, so configure takes the same ones and resolves no ref again + artifacts = [] + cache_variables = {f"BUNDLE_REVISION_{REPOSITORIES[staging].upper()}": sha for staging, sha in revision.items()} + cache_variables["BUNDLE_STAGINGS"] = ";".join(revision) # the stagings the revisions kept + for staging in revision: + artifacts.append({"name": f"{staging}-staging-{job}", "dir": f"stagings/{staging}"}) + # the core's tarball carries its install prefix, opt/opendaq, except on Windows + inside = "/opt/opendaq" if staging == "opendaq" and not job.startswith("windows-") else "" + cache_variables[f"BUNDLE_PREFIX_{staging.upper()}"] = "${sourceDir}/stagings/" + staging + inside + packages.append({"match-jobs": [job], "artifacts": artifacts}) + cmake_presets.append({"match-jobs": [job], "configure-preset": "bundle-prefixes", "cache-variables": cache_variables}) + cpack_presets.append({"match-jobs": [job], "installers": [{"name": "bundle", "package": p["generator"], "package-preset": "installer"}]}) + + # DEB names the libraries the stagings need in its Depends (dpkg-shlibdeps), so they must be there: ASAM's + # libpcap, ref_fb's renderer's X11, GL, udev and freetype, LT's OpenSSL; on Windows NSIS packs the installer + packages += [{"match-jobs": ["ubuntu-*"], "apt-install": ["dpkg-dev", "file", "libpcap0.8", "libx11-6", + "libxrandr2", "libxcursor1", "libxi6", "libgl1", "libudev1", "libfreetype6", "libssl3"]}, + {"match-jobs": ["windows-*"], "choco-install": ["nsis"]}] + + # the installers in the registry: an index per bundle, idx- of the bundle's commit and its layers'; + # a package per platform, pkg- of those and its triplet (staging-meta.json's dependencies, package) + commits = ["org.opencontainers.image.revision"] + [f"com.opendaq.dependencies.{s}.revision" for s in revision] + staging_push = [{"path": f"ghcr.io/{os.environ['OWNER']}/bundle/native", "artifacts": ["package-*/bundle"], + "idx-identity": commits, "pkg-identity": commits + ["com.opendaq.package.triplet"]}] + + outputs = {"jobs": [p["job"] for p in platforms], "packages": packages, "cmake-presets": cmake_presets, + "cpack-presets": cpack_presets, "staging-push": staging_push} + print(json.dumps(outputs, indent=2)) + with open(os.environ["GITHUB_OUTPUT"], "a") as f: + for key, value in outputs.items(): + f.write(f"{key}={json.dumps(value)}\n") + + # once every staging is in the run, pulled or staged; a staging found in the registry skips its stage job + build: + name: Build + needs: [configure, pull, stage-opendaq, stage-opcua-modules, stage-mqtt-module, stage-lt-streaming-modules, + stage-asam-cmp-modules] + if: >- + always() && needs.configure.result == 'success' + && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: openDAQ/openDAQ-CI/.github/workflows/reusable.yml@v4 + with: + include-jobs: ${{ needs.configure.outputs.jobs }} + packages: ${{ needs.configure.outputs.packages }} + cmake-presets: ${{ needs.configure.outputs.cmake-presets }} + cpack-presets: ${{ needs.configure.outputs.cpack-presets }} + + # always(): a stage job skipped, its staging pulled, would skip this one too + push: + name: Push + needs: [configure, build] + if: >- + always() && needs.build.result == 'success' + && github.repository == 'openDAQ/openDAQ-bundle' && !inputs.skip-staging-push + permissions: + contents: read + packages: write + uses: openDAQ/openDAQ-CI/.github/workflows/staging-push.yml@v4 + with: + staging-packages: ${{ needs.configure.outputs.staging-push }} diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml new file mode 100644 index 0000000..65f86ed --- /dev/null +++ b/.github/workflows/cleanup.yml @@ -0,0 +1,24 @@ +name: Clean up bundles + +on: + schedule: + - cron: '0 6 * * 1' + workflow_dispatch: + inputs: + dry-run: + description: "List what would be pruned without deleting." + type: boolean + default: false + +jobs: + cleanup: + name: Installers + permissions: + packages: write + uses: openDAQ/openDAQ-CI/.github/workflows/staging-cleanup.yml@v4 + with: + dry-run: ${{ inputs.dry-run || false }} + staging-retentions: >- + [ + { "path": "ghcr.io/openDAQ/bundle/native", "retention": { "days": 30 } } + ] diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d16b94..f4bd104 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,162 +1,37 @@ set(CMAKE_POLICY_VERSION_MINIMUM 3.5) cmake_minimum_required(VERSION 3.25) -set(REPO_NAME ReleaseRepo) -set(REPO_OPTION_PREFIX RELEASE_REPO) -set(CMAKE_FOLDER "${CMAKE_FOLDER}/${REPO_NAME}") - - -list(APPEND CMAKE_MESSAGE_CONTEXT ${REPO_NAME}) - -project(${REPO_NAME} VERSION "1.0.0" LANGUAGES CXX) - -option(${REPO_OPTION_PREFIX}_ENABLE_TESTS "Enable testing" OFF) -option(${REPO_OPTION_PREFIX}_ENABLE_OPCUA_MODULE "Enable OPC UA module" ON) -option(${REPO_OPTION_PREFIX}_ENABLE_MQTT_MODULE "Enable MQTT module" ON) -option(${REPO_OPTION_PREFIX}_ENABLE_LT_MODULE "Enable LT streaming module" ON) -option(${REPO_OPTION_PREFIX}_ENABLE_ASAM_CMP_MODULE "Enable ASAM-CMP modules" ON) +# the bundle's version, bundle.json's: the version of its packages and installers +file(READ "${CMAKE_CURRENT_LIST_DIR}/bundle.json" _bundle) +string(JSON _bundle_version GET "${_bundle}" version) +project(openDAQ-bundle VERSION ${_bundle_version} LANGUAGES CXX) + +# The bundle: what it is made of (cmake/Layers.cmake); every layer built from its sources (cmake/Sources.cmake) or +# every staging taken prebuilt (cmake/Stagings.cmake), never a mix; how it is packed (cmake/Packing.cmake). +set(BUNDLE_FROM SOURCES CACHE STRING "Where the layers come from: SOURCES, built here; STAGINGS, prebuilt from BUNDLE_PREFIX_") +set_property(CACHE BUNDLE_FROM PROPERTY STRINGS SOURCES STAGINGS) +if (NOT BUNDLE_FROM MATCHES "^(SOURCES|STAGINGS)$") + message(FATAL_ERROR "BUNDLE_FROM is SOURCES or STAGINGS, not ${BUNDLE_FROM}") +endif() +set(BUNDLE_STAGINGS "opendaq;opcua-modules;mqtt-module;lt-streaming-modules;asam-cmp-modules" + CACHE STRING "The stagings the bundle has") +option(BUNDLE_ENABLE_TESTS "Build the layers' tests, when they are built from sources" OFF) include(FetchContent) -# fetch the cmake utilities first, as they are used by the other modules +# the cmake utilities first: the triplet, Boost, and what the layers built here use; the tag the core takes FetchContent_Declare( opendaq-cmake-utils GIT_REPOSITORY https://github.com/openDAQ/opendaq-cmake-utils.git - GIT_TAG v1.0.1 + GIT_TAG v1.1.4 GIT_PROGRESS ON ) FetchContent_MakeAvailable(opendaq-cmake-utils) -FetchContent_Declare( - opendaq - GIT_REPOSITORY https://github.com/openDAQ/openDAQ.git - GIT_TAG main - GIT_PROGRESS ON - GIT_SHALLOW OFF - SOURCE_SUBDIR "INVALID" - GIT_REMOTE_UPDATE_STRATEGY CHECKOUT -) - -set(OPENDAQ_ENABLE_OPCUA OFF CACHE BOOL "") -set(OPENDAQ_ENABLE_OPCUA_INTEGRATION_TESTS OFF CACHE BOOL "") - -set(OPENDAQ_GENERATE_DELPHI_BINDINGS OFF CACHE BOOL "" FORCE) -set(OPENDAQ_GENERATE_PYTHON_BINDINGS ON CACHE BOOL "") -set(OPENDAQ_GENERATE_CSHARP_BINDINGS ON CACHE BOOL "") -set(OPENDAQ_GENERATE_C_BINDINGS ON CACHE BOOL "") - -set(OPENDAQ_ENABLE_TESTS ${${REPO_OPTION_PREFIX}_ENABLE_TESTS} CACHE BOOL "" FORCE) -set(OPENDAQ_ENABLE_TEST_UTILS ${${REPO_OPTION_PREFIX}_ENABLE_TESTS} CACHE BOOL "" FORCE) -set(OPENDAQ_ENABLE_OPTIONAL_TESTS ${${REPO_OPTION_PREFIX}_ENABLE_TESTS} CACHE BOOL "" FORCE) -set(OPENDAQ_ENABLE_COVERAGE OFF CACHE BOOL "" FORCE) -set(OPENDAQ_ENABLE_REGRESSION_TESTS ${${REPO_OPTION_PREFIX}_ENABLE_TESTS} CACHE BOOL "" FORCE) -set(OPENDAQ_ENABLE_UNSTABLE_TEST_LABELS ${${REPO_OPTION_PREFIX}_ENABLE_TESTS} CACHE BOOL "" FORCE) - -set(DAQMODULES_EMPTY_MODULE ON CACHE BOOL "") -set(DAQMODULES_OPENDAQ_CLIENT_MODULE ON CACHE BOOL "") -set(DAQMODULES_OPENDAQ_SERVER_MODULE ON CACHE BOOL "") -set(DAQMODULES_REF_DEVICE_MODULE ON CACHE BOOL "") -set(DAQMODULES_SIMULATOR_DEVICE_MODULE ON CACHE BOOL "") -set(DAQMODULES_REF_FB_MODULE ON CACHE BOOL "") -set(DAQMODULES_AUDIO_DEVICE_MODULE ON CACHE BOOL "") -set(DAQMODULES_BASIC_CSV_RECORDER_MODULE ON CACHE BOOL "") -set(DAQMODULES_LICENSING_MODULE ON CACHE BOOL "") -set(DAQMODULES_PARQUET_RECORDER_MODULE OFF CACHE BOOL "") - -set(OPENDAQ_ENABLE_NATIVE_STREAMING ON CACHE BOOL "") -set(OPENDAQ_ENABLE_WEBSOCKET_STREAMING OFF CACHE BOOL "") - -set(OPENDAQ_DOCUMENTATION_TESTS OFF CACHE BOOL "" FORCE) -set(OPENDAQ_ENABLE_PYTHON_BINDINGS_TESTS OFF CACHE BOOL "" FORCE) -set(APP_ENABLE_WEBPAGE_EXAMPLES OFF CACHE BOOL "") - -FetchContent_MakeAvailable(opendaq) -include("${opendaq_SOURCE_DIR}/external/boost/Boost.cmake" OPTIONAL) - -if (${REPO_OPTION_PREFIX}_ENABLE_OPCUA_MODULE) -FetchContent_Declare( - opcuamodules - GIT_REPOSITORY https://github.com/openDAQ/OpcUaModules.git - GIT_TAG main - GIT_PROGRESS ON - GIT_SHALLOW OFF - SOURCE_SUBDIR "INVALID" - GIT_REMOTE_UPDATE_STRATEGY CHECKOUT -) - -set(DAQMODULES_OPCUA_ENABLE_EXAMPLE_APP OFF CACHE BOOL "") -set(DAQMODULES_OPCUA_ENABLE_TESTS ${${REPO_OPTION_PREFIX}_ENABLE_TESTS} CACHE BOOL "" FORCE) -set(DAQMODULES_OPCUA_ENABLE_CLIENT ON CACHE BOOL "") -set(DAQMODULES_OPCUA_ENABLE_SERVER ON CACHE BOOL "") -set(DAQMODULES_OPCUA_ENABLE_GENERIC_CLIENT ON CACHE BOOL "") - -FetchContent_MakeAvailable(opcuamodules) -include("${opcuamodules_SOURCE_DIR}/external/boost/Boost.cmake" OPTIONAL) -endif() - -if (${REPO_OPTION_PREFIX}_ENABLE_MQTT_MODULE) -FetchContent_Declare( - mqttmodule - GIT_REPOSITORY https://github.com/openDAQ/MQTTStreamingModule.git - GIT_TAG main - GIT_PROGRESS ON - GIT_SHALLOW OFF - SOURCE_SUBDIR "INVALID" - GIT_REMOTE_UPDATE_STRATEGY CHECKOUT -) - -set(DAQMODULES_MQTT_ENABLE_TESTS ${${REPO_OPTION_PREFIX}_ENABLE_TESTS} CACHE BOOL "" FORCE) -set(DAQMODULES_MQTT_ENABLE_EXAMPLE_APP OFF CACHE BOOL "") -set(DAQMODULES_MQTT_ENABLE_SSL OFF CACHE BOOL "") - -FetchContent_MakeAvailable(mqttmodule) -include("${mqttmodule_SOURCE_DIR}/external/boost/Boost.cmake" OPTIONAL) -endif() - - -if (${REPO_OPTION_PREFIX}_ENABLE_LT_MODULE) -FetchContent_Declare( - ltstreamingmodulesmodern - GIT_REPOSITORY https://github.com/openDAQ/LTStreamingModulesModern.git - GIT_TAG main - GIT_PROGRESS ON - GIT_SHALLOW OFF - SOURCE_SUBDIR "INVALID" - GIT_REMOTE_UPDATE_STRATEGY CHECKOUT -) - -set(DAQMODULES_LT_STREAMING_ENABLE_TESTS ${${REPO_OPTION_PREFIX}_ENABLE_TESTS} CACHE BOOL "" FORCE) -set(DAQMODULES_LT_STREAMING_ENABLE_EXAMPLE_APP OFF CACHE BOOL "") -set(DAQMODULES_LT_STREAMING_ENABLE_CLIENT ON CACHE BOOL "") -set(DAQMODULES_LT_STREAMING_ENABLE_SERVER ON CACHE BOOL "") - -FetchContent_MakeAvailable(ltstreamingmodulesmodern) -include("${ltstreamingmodulesmodern_SOURCE_DIR}/external/boost/Boost.cmake" OPTIONAL) +include(cmake/Layers.cmake) +if (BUNDLE_FROM STREQUAL "SOURCES") + include(cmake/Sources.cmake) +else() + include(cmake/Stagings.cmake) endif() - -if (${REPO_OPTION_PREFIX}_ENABLE_ASAM_CMP_MODULE) -FetchContent_Declare( - asamcmpmodules - GIT_REPOSITORY https://github.com/openDAQ/ASAM-CMP-Modules.git - GIT_TAG main - GIT_PROGRESS ON - GIT_SHALLOW OFF - SOURCE_SUBDIR "INVALID" - GIT_REMOTE_UPDATE_STRATEGY CHECKOUT -) - -set(ASAM_CMP_ENABLE_TESTS ${${REPO_OPTION_PREFIX}_ENABLE_TESTS} CACHE BOOL "" FORCE) -set(ASAM_CMP_ENABLE_EXAMPLE OFF CACHE BOOL "") -set(ASAM_CMP_BUILD_DATA_SINK ON CACHE BOOL "") -set(ASAM_CMP_BUILD_CAPTURE_MODULE ON CACHE BOOL "") - -FetchContent_MakeAvailable(asamcmpmodules) -include("${asamcmpmodules_SOURCE_DIR}/external/boost/Boost.cmake" OPTIONAL) -endif() - -# add the subdirectories for the core and modules -add_subdirectory(${opendaq_SOURCE_DIR} ${opendaq_BINARY_DIR}) -add_subdirectory(${opcuamodules_SOURCE_DIR} ${opcuamodules_BINARY_DIR}) -add_subdirectory(${mqttmodule_SOURCE_DIR} ${mqttmodule_BINARY_DIR}) -add_subdirectory(${ltstreamingmodulesmodern_SOURCE_DIR} ${ltstreamingmodulesmodern_BINARY_DIR}) -add_subdirectory(${asamcmpmodules_SOURCE_DIR} ${asamcmpmodules_BINARY_DIR}) +include(cmake/Packing.cmake) diff --git a/CMakePresets.json b/CMakePresets.json index ac83377..e9baac7 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,5 +1,5 @@ { - "version": 4, + "version": 6, "configurePresets": [ { "name": "debug", @@ -100,6 +100,28 @@ "msvc-x86" ] }, + { + "name": "bundle-prefixes", + "displayName": "Bundle from prebuilt stagings (BUNDLE_PREFIX_), nothing compiled; CI", + "inherits": [ + "release" + ], + "cacheVariables": { + "BUNDLE_STAGINGS": "opendaq;opcua-modules;mqtt-module;lt-streaming-modules;asam-cmp-modules", + "BUNDLE_FROM": "STAGINGS" + } + }, + { + "name": "bundle-native", + "displayName": "Bundle from the layers' sources, this machine's triplet", + "inherits": [ + "release", + "ninja" + ], + "cacheVariables": { + "BUNDLE_STAGINGS": "opendaq;opcua-modules;mqtt-module;lt-streaming-modules;asam-cmp-modules" + } + }, { "name": "x64/msvc-17", "displayName": "[MSVC 17] Release - x64", @@ -163,5 +185,49 @@ "ninja" ] } + ], + "buildPresets": [ + { + "name": "bundle-native", + "configurePreset": "bundle-native" + } + ], + "packagePresets": [ + { + "name": "core", + "displayName": "The core: runtime, C++ API, C", + "configurePreset": "bundle-native", + "generators": [ + "TGZ" + ], + "variables": { + "BUNDLE_PACK_STAGINGS": "opendaq", + "BUNDLE_PACK_COMPONENTS": "Runtime;Development", + "CPACK_OPENDAQ_META_PACKAGE_NAME": "opendaq-core" + } + }, + { + "name": "installer", + "displayName": "The core with the modules, the modules optional where the generator offers choices (-G DEB, NSIS, productbuild)", + "configurePreset": "bundle-native", + "variables": { + "BUNDLE_PACK_STAGINGS": "opendaq;opcua-modules;mqtt-module;lt-streaming-modules;asam-cmp-modules", + "BUNDLE_PACK_COMPONENTS": "Runtime;Development", + "CPACK_OPENDAQ_META_PACKAGE_NAME": "opendaq-bundle" + } + }, + { + "name": "modules", + "displayName": "The modules, without the core", + "configurePreset": "bundle-native", + "generators": [ + "TGZ" + ], + "variables": { + "BUNDLE_PACK_STAGINGS": "opcua-modules;mqtt-module;lt-streaming-modules;asam-cmp-modules", + "BUNDLE_PACK_COMPONENTS": "Runtime", + "CPACK_OPENDAQ_META_PACKAGE_NAME": "opendaq-modules" + } + } ] } diff --git a/README.md b/README.md index 93b91f8..da01190 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,10 @@ All dependencies are fetched automatically via CMake's `FetchContent`. - CMake 3.25 or newer - Git -- **Windows:** Visual Studio 2017 or 2022 (with C++ workload) — used as compiler toolchain only +- **Windows:** Visual Studio 2017 or 2022 (with C++ workload) — used as compiler toolchain only; + [NSIS](https://nsis.sourceforge.io) 3 for the installer - **Linux:** GCC or Clang, Ninja +- **macOS:** Xcode Command Line Tools (Apple Clang, `productbuild`), Ninja ## Configure @@ -29,6 +31,7 @@ Use one of the available CMake presets: | `x64/gcc/debug` | Linux | GCC | x64 | Debug | | `x64/clang/release` | Linux | Clang | x64 | Release | | `x64/clang/debug` | Linux | Clang | x64 | Debug | +| `x64/clang/release` | macOS | Apple Clang | the machine's | Release | ```bash # Windows @@ -36,6 +39,9 @@ cmake --preset="x64/msvc-22" # Linux cmake --preset="x64/gcc/release" + +# macOS +cmake --preset="x64/clang/release" ``` ## Build @@ -46,20 +52,72 @@ cmake --build build\x64\msvc-22 --config Release # Linux cmake --build build/x64/gcc/release + +# macOS +cmake --build build/x64/clang/release +``` + +## Package + +```bash +# Windows +cpack --config build\x64\msvc-22\CPackConfig.cmake -G NSIS -C Release ^ + -D "BUNDLE_PACK_STAGINGS=opendaq;opcua-modules;mqtt-module;lt-streaming-modules;asam-cmp-modules" ^ + -D "BUNDLE_PACK_COMPONENTS=Runtime;Development" ^ + -D CPACK_OPENDAQ_META_PACKAGE_NAME=opendaq-bundle + +# Linux +cpack --config build/x64/gcc/release/CPackConfig.cmake -G DEB \ + -D "BUNDLE_PACK_STAGINGS=opendaq;opcua-modules;mqtt-module;lt-streaming-modules;asam-cmp-modules" \ + -D "BUNDLE_PACK_COMPONENTS=Runtime;Development" \ + -D CPACK_OPENDAQ_META_PACKAGE_NAME=opendaq-bundle + +# macOS +cpack --config build/x64/clang/release/CPackConfig.cmake -G productbuild \ + -D "BUNDLE_PACK_STAGINGS=opendaq;opcua-modules;mqtt-module;lt-streaming-modules;asam-cmp-modules" \ + -D "BUNDLE_PACK_COMPONENTS=Runtime;Development" \ + -D CPACK_OPENDAQ_META_PACKAGE_NAME=opendaq-bundle ``` +The installer lands in `build//packages`; it installs into `/opt/opendaq` (DEB, productbuild) or the folder +chosen (NSIS). + +## bundle.json + +The bundle's version and the revision of each repository, read at every configure: + +```json +{ + "version": "2026.11.0", + "layers": { + "openDAQ": "main", + "OpcUaModules": "main", + "MQTTStreamingModule": "main", + "LTStreamingModulesModern": "main", + "ASAM-CMP-Modules": "main" + } +} +``` + +- `version`: the version of the packages and installers, `YYYY.MM.N`; `-DBUNDLE_VERSION` replaces it. +- `layers`: one revision per repository, a commit, tag or branch; `-DBUNDLE_REVISION_` replaces one. + ## CMake Options | Option | Default | Description | |---|---|---| -| `RELEASE_REPO_ENABLE_TESTS` | `OFF` | Build and enable tests | -| `RELEASE_REPO_ENABLE_OPCUA_MODULE` | `ON` | Include OPC UA module | -| `RELEASE_REPO_ENABLE_MQTT_MODULE` | `ON` | Include MQTT streaming module | -| `RELEASE_REPO_ENABLE_LT_MODULE` | `ON` | Include LT streaming module | -| `RELEASE_REPO_ENABLE_ASAM_CMP_MODULE` | `ON` | Include ASAM-CMP modules | +| `BUNDLE_ENABLE_TESTS` | `OFF` | Build the tests of the layers | +| `BUNDLE_STAGINGS` | all | The parts of the bundle, separated by semicolons: `opendaq;opcua-modules;mqtt-module;lt-streaming-modules;asam-cmp-modules`; leave a module out to build without it, `opendaq` is required | +| `BUNDLE_REVISION_` | `bundle.json`'s | A repository's revision (a commit, tag or branch), e.g. `BUNDLE_REVISION_OPCUAMODULES=v4.0.1` | +| `BUNDLE_VERSION` | `bundle.json`'s | The version of the packages and installers | +| `BUNDLE_TRIPLET` | this machine's | The triplet the packages are named by, `----`:
  • `x86_64-linux-gcc-11-release`
  • `armv8-linux-gcc-11-release`
  • `x86_64-windows-msvc-143-release`
  • `armv8-macos-apple-clang-21-release`
  • `x86_64-macos-apple-clang-21-release`
| -Pass options at configure time: +## CPack Options -```bash -cmake --preset="x64/gcc/release" -DRELEASE_REPO_ENABLE_TESTS=ON -``` +What goes into a package, passed to cpack with `-D`: + +| Option | Description | +|---|---| +| `BUNDLE_PACK_STAGINGS` | The parts packed, by the names `BUNDLE_STAGINGS` takes; a part the build left out is left out | +| `BUNDLE_PACK_COMPONENTS` | `Runtime` (libraries, modules, executables), `Development` (headers, CMake configs) or both | +| `CPACK_OPENDAQ_META_PACKAGE_NAME` | The package's name, e.g. `opendaq-bundle` | diff --git a/bundle.json b/bundle.json new file mode 100644 index 0000000..9aaeeef --- /dev/null +++ b/bundle.json @@ -0,0 +1,10 @@ +{ + "version": "2026.11.0", + "layers": { + "openDAQ": "main", + "OpcUaModules": "main", + "MQTTStreamingModule": "main", + "LTStreamingModulesModern": "main", + "ASAM-CMP-Modules": "main" + } +} diff --git a/cmake/CPackOptions.cmake b/cmake/CPackOptions.cmake new file mode 100644 index 0000000..0bc6970 --- /dev/null +++ b/cmake/CPackOptions.cmake @@ -0,0 +1,48 @@ +## +## Read by cpack for every generator (CPACK_PROJECT_CONFIG_FILE): an installer puts the bundle +## under /opt/opendaq, where the core installs itself; an archive holds the tree as it is. +## +## The package preset picks the stagings, BUNDLE_PACK_STAGINGS, and their components, BUNDLE_PACK_COMPONENTS +## (Runtime, Development): the install components Packing.cmake recorded for each, CPACK_BUNDLE__, +## the staging's name made a C identifier. A staging the build left out (BUNDLE_STAGINGS) is left out of the package. The utils' config then names the package by CPACK_OPENDAQ_META_PACKAGE_NAME and writes its +## staging-meta.json. +## + +if (CPACK_GENERATOR MATCHES "^(DEB|RPM|productbuild)$") + set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/opendaq") +else() + set(CPACK_PACKAGING_INSTALL_PREFIX "/") +endif() + +if (NOT BUNDLE_PACK_STAGINGS OR NOT BUNDLE_PACK_COMPONENTS) + message(FATAL_ERROR "cpack: pick what to pack, -D BUNDLE_PACK_STAGINGS=… -D BUNDLE_PACK_COMPONENTS=Runtime… " + "(a package preset does); the build has: ${CPACK_COMPONENTS_ALL}") +endif() +set(_picked) +foreach(_staging IN LISTS BUNDLE_PACK_STAGINGS) + if (NOT _staging IN_LIST CPACK_BUNDLE_STAGINGS) + message(STATUS "cpack: ${_staging} is not in this build (BUNDLE_STAGINGS), left out") + continue() + endif() + string(MAKE_C_IDENTIFIER "${_staging}" _c) + set(_found FALSE) + foreach(_component IN LISTS BUNDLE_PACK_COMPONENTS) + if (CPACK_BUNDLE_${_c}_${_component}) + list(APPEND _picked ${CPACK_BUNDLE_${_c}_${_component}}) + set(_found TRUE) + endif() + endforeach() + if (NOT _found) + message(FATAL_ERROR "cpack: nothing of ${_staging} to pack (${BUNDLE_PACK_COMPONENTS}); the build has: ${CPACK_COMPONENTS_ALL}") + endif() +endforeach() +if (NOT _picked) + message(FATAL_ERROR "cpack: none of ${BUNDLE_PACK_STAGINGS} is in this build (${CPACK_BUNDLE_STAGINGS})") +endif() +# every package carries the bundle's own component: its metadata and, on macOS, the uninstall script (Packing.cmake) +list(APPEND _picked bundle_Runtime) +set(CPACK_COMPONENTS_ALL ${_picked}) + +include("${CPACK_OPENDAQ_PROJECT_CONFIG}") +set(CPACK_PACKAGE_NAME "${CPACK_OPENDAQ_META_PACKAGE_NAME}") +set(CPACK_DEBIAN_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.deb") diff --git a/cmake/Layers.cmake b/cmake/Layers.cmake new file mode 100644 index 0000000..efeb322 --- /dev/null +++ b/cmake/Layers.cmake @@ -0,0 +1,57 @@ +## +## What the bundle is made of: its layers — repositories, named as in bundle.json — each with its staging, in the +## order they are taken, the core first (BUNDLE_LAYERS, =). How they are built is Sources.cmake's; +## how they are taken prebuilt, Stagings.cmake's. +## +## The revisions, one per layer — a full sha, a tag or a branch — from bundle.json; BUNDLE_REVISION_, the +## name upper-cased, in place of one (a preset or -D). BUNDLE_STAGINGS leaves layers out. +## + +include_guard(GLOBAL) + + +# === the layers ============================================================================================== + +# a layer's revision: BUNDLE_REVISION_ when given, else bundle.json's — read at every configure, so an edit +# of it is taken without clearing the cache +set(_bundle_json "${CMAKE_CURRENT_LIST_DIR}/../bundle.json") +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_bundle_json}") +file(READ "${_bundle_json}" _bundle) +foreach(_layer openDAQ OpcUaModules MQTTStreamingModule LTStreamingModulesModern ASAM-CMP-Modules) + string(TOUPPER "${_layer}" _upper) + set(BUNDLE_REVISION_${_upper} "" CACHE STRING "The revision of ${_layer}: a full sha, a tag or a branch; empty: bundle.json's") + if (NOT BUNDLE_REVISION_${_upper}) + string(JSON BUNDLE_REVISION_${_upper} ERROR_VARIABLE _error GET "${_bundle}" layers "${_layer}") + if (_error) + message(FATAL_ERROR "bundle.json names no revision of ${_layer}: ${_error}") + endif() + endif() +endforeach() + + +# the layers, the core first, each with its staging; those BUNDLE_STAGINGS names. The core is always there: the +# modules are built against it, and every package has it +set(BUNDLE_LAYERS) +set(_known) +foreach(_entry + openDAQ=opendaq + OpcUaModules=opcua-modules + MQTTStreamingModule=mqtt-module + LTStreamingModulesModern=lt-streaming-modules + ASAM-CMP-Modules=asam-cmp-modules) + string(REPLACE "=" ";" _pair "${_entry}") + list(GET _pair 1 _staging) + list(APPEND _known ${_staging}) + if (_staging IN_LIST BUNDLE_STAGINGS) + list(APPEND BUNDLE_LAYERS "${_entry}") + endif() +endforeach() +if (NOT "opendaq" IN_LIST BUNDLE_STAGINGS) + message(FATAL_ERROR "BUNDLE_STAGINGS leaves out opendaq, the core: the modules are built against it") +endif() +foreach(_staging IN LISTS BUNDLE_STAGINGS) + if (NOT _staging IN_LIST _known) + list(JOIN _known ", " _known) + message(FATAL_ERROR "BUNDLE_STAGINGS names ${_staging}, which the bundle has not; it has ${_known}") + endif() +endforeach() diff --git a/cmake/Packing.cmake b/cmake/Packing.cmake new file mode 100644 index 0000000..64cacce --- /dev/null +++ b/cmake/Packing.cmake @@ -0,0 +1,222 @@ +## +## The bundle's targets as packages. A package preset picks what goes in — stagings × components — and the +## generator and the name; see CPackOptions.cmake. The utils name the package --, +## as the core's and the modules', and write staging-meta.json next to it. +## +## cpack --preset core opendaq × Runtime, Development +## cpack --preset modules the four module stagings × Runtime +## + +include_guard(GLOBAL) + +set(BUNDLE_VERSION "" CACHE STRING "Version of the bundle, the version of its packages; empty: bundle.json's") +if (NOT BUNDLE_VERSION) + set(BUNDLE_VERSION "${PROJECT_VERSION}") +endif() + +set(BUNDLE_TRIPLET "" CACHE STRING "The triplet the packages are named by; empty: the one the utils compose") + +# the stagings this build has, so a package preset's others are left out at cpack time +set(CPACK_BUNDLE_STAGINGS ${BUNDLE_STAGINGS}) + +# each staging's install components by what they are for: Runtime when the name says so, Development else — +# prebuilt, _Runtime/_Development and _Runtime; from sources, the names the layer gave +# (openDAQ_opcua_client_module_Runtime, External); for CPackOptions.cmake to pick from at cpack time +foreach(_staging IN LISTS BUNDLE_STAGINGS) + string(MAKE_C_IDENTIFIER "${_staging}" _c) + get_property(BUNDLE_COMPONENTS_${_c} GLOBAL PROPERTY BUNDLE_COMPONENTS_${_c}) + get_property(BUNDLE_PREBUILT_${_c} GLOBAL PROPERTY BUNDLE_PREBUILT_${_c}) + set(CPACK_BUNDLE_${_c}_Runtime) + set(CPACK_BUNDLE_${_c}_Development) + foreach(_component IN LISTS BUNDLE_COMPONENTS_${_c}) + if (_component MATCHES "_Runtime$") + list(APPEND CPACK_BUNDLE_${_c}_Runtime ${_component}) + else() + list(APPEND CPACK_BUNDLE_${_c}_Development ${_component}) + endif() + endforeach() +endforeach() + +opendaq_detect_settings() + +# what the packages are built from, each layer's commit, dependencies..revision in staging-meta.json: the +# bundle's identity when published. Built here, the commit its sources are at, a branch or tag taken at its head +# resolved; prebuilt, the revision given (CI gives commits) +find_package(Git QUIET) +foreach(_entry IN LISTS BUNDLE_LAYERS) + string(REPLACE "=" ";" _pair "${_entry}") + list(GET _pair 0 _layer) + list(GET _pair 1 _staging) + string(TOUPPER "${_layer}" _upper) + string(TOLOWER "${_layer}" _lower) + set(_revision "${BUNDLE_REVISION_${_upper}}") + if (BUNDLE_FROM STREQUAL "SOURCES" AND GIT_EXECUTABLE) + execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD + WORKING_DIRECTORY "${${_lower}_SOURCE_DIR}" + OUTPUT_VARIABLE _head OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE _result ERROR_QUIET) + if (_result EQUAL 0) + set(_revision "${_head}") + endif() + endif() + opendaq_set_metadata_field(dependencies ${_staging} revision VALUE "${_revision}") +endforeach() + +# installed with the bundle, share/opendaq-bundle/build-meta.json, as the core's share/opendaq/build-meta.json: what +# the build is, the settings and the commit of every layer. No package section: one build yields several packages, +# and a copy sealed inside all of them could name only one +opendaq_write_metadata(OUTPUT "${CMAKE_BINARY_DIR}/bundle/build-meta.json") +install(FILES "${CMAKE_BINARY_DIR}/bundle/build-meta.json" DESTINATION share/opendaq-bundle COMPONENT bundle_Runtime) + +# the name, the version and the triplet, by the utils; a package preset renames it +set(CPACK_OPENDAQ_META_PACKAGE_NAME "opendaq-bundle") +set(CPACK_OPENDAQ_META_PACKAGE_VERSION "${BUNDLE_VERSION}") +opendaq_detect_package() +opendaq_compose_package_triplet() +if (BUNDLE_TRIPLET) + set(CPACK_OPENDAQ_META_PACKAGE_TRIPLET "${BUNDLE_TRIPLET}") +endif() +opendaq_compose_package_file_name() + +set(CPACK_PACKAGE_NAME "${CPACK_OPENDAQ_META_PACKAGE_NAME}") +set(CPACK_PACKAGE_VENDOR "openDAQ d.o.o.") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "openDAQ SDK with its modules") +set(CPACK_PACKAGE_HOMEPAGE_URL "https://opendaq.io/") +set(CPACK_PACKAGE_CONTACT "info@opendaq.io") +set(CPACK_PACKAGE_VERSION "${BUNDLE_VERSION}") +set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/packages") +# a macOS package's receipts, io.opendaq.bundle.; by default from the vendor, with its spaces and dots +set(CPACK_PRODUCTBUILD_IDENTIFIER "io.opendaq.bundle") + +set(CPACK_GENERATOR TGZ) +set(CPACK_VERBATIM_VARIABLES ON) +set(CPACK_THREADS 0) + +# the components picked go into one package +set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE) + +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR} <${CPACK_PACKAGE_CONTACT}>") +set(CPACK_DEBIAN_PACKAGE_SECTION "devel") +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS "opt/opendaq/lib") + +# NSIS: the core's installer as it is (its images, the PATH page, the old version removed first), under a name and a +# registry key of the bundle's own, so it neither replaces nor uninstalls the core's +set(CPACK_PACKAGE_INSTALL_DIRECTORY "openDAQ") +set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "openDAQ bundle") +set(CPACK_NSIS_PACKAGE_NAME "openDAQ bundle") +set(CPACK_NSIS_DISPLAY_NAME "openDAQ bundle ${BUNDLE_VERSION}") +set(CPACK_NSIS_WELCOME_TITLE "Welcome to openDAQ Setup") +set(CPACK_NSIS_BRANDING_TEXT "${CPACK_PACKAGE_VENDOR}") +set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/packaging/nsis/opendaq.ico") +set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/packaging/nsis/opendaq.ico") +file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/packaging/nsis/nsis_header.bmp" CPACK_NSIS_MUI_HEADERIMAGE) # NSIS wants \ +file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/packaging/nsis/nsis_welcome.bmp" CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP) +set(CPACK_NSIS_MANIFEST_DPI_AWARE ON) +set(CPACK_NSIS_MODIFY_PATH ON) +set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) + +# A silent install (/S) shows no page, so it never adds to PATH; /PATH=AllUsers|CurrentUser|No chooses it on the +# command line, as the page would, and records it for the uninstaller: +# opendaq-bundle--.exe /S /PATH=AllUsers /D=C:\openDAQ (/D last, unquoted) +# (CPack sets CPACK_NSIS_DEFINES itself, so no FileFunc.nsh: the option is looked for in $CMDLINE by hand) +# +# PATH is then written by the EnVar plugin (packaging/nsis/EnVar, zlib licence), not by the template: the template +# reads PATH into an NSIS string, 1024 characters, finds it empty when PATH is longer, and shows a message box, +# which a silent install waits on forever (a CI runner's PATH is longer). $DO_NOT_ADD_TO_PATH is set to 1 in the +# installer once the registry holds the choice, so the template's AddToPath is skipped; its RemoveFromPath at +# uninstall then finds nothing left to remove. +file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/packaging/nsis/EnVar" _envar) +string(CONFIGURE [=[ + !addplugindir /x86-ansi "@_envar@\x86-ansi" + !addplugindir /x86-unicode "@_envar@\x86-unicode" + StrCpy $R1 "" + StrCpy $R2 0 + bundle_path_scan: + StrCpy $R3 $CMDLINE 14 $R2 + StrCmp $R3 "/PATH=AllUsers" 0 +3 + StrCpy $R1 "AllUsers" + Goto bundle_path_found + StrCpy $R3 $CMDLINE 17 $R2 + StrCmp $R3 "/PATH=CurrentUser" 0 +3 + StrCpy $R1 "CurrentUser" + Goto bundle_path_found + StrCpy $R3 $CMDLINE 8 $R2 + StrCmp $R3 "/PATH=No" 0 +3 + StrCpy $R1 "No" + Goto bundle_path_found + IntOp $R2 $R2 + 1 + StrCpy $R3 $CMDLINE 1 $R2 + StrCmp $R3 "" bundle_path_done bundle_path_scan + bundle_path_found: + StrCpy $DO_NOT_ADD_TO_PATH 1 + StrCpy $ADD_TO_PATH_ALL_USERS 0 + StrCpy $ADD_TO_PATH_CURRENT_USER 0 + StrCmp $R1 "AllUsers" 0 +3 + StrCpy $DO_NOT_ADD_TO_PATH 0 + StrCpy $ADD_TO_PATH_ALL_USERS 1 + StrCmp $R1 "CurrentUser" 0 +3 + StrCpy $DO_NOT_ADD_TO_PATH 0 + StrCpy $ADD_TO_PATH_CURRENT_USER 1 + Push "DoNotAddToPath" + Push "$DO_NOT_ADD_TO_PATH" + Call ConditionalAddToRegistry + Push "AddToPathAllUsers" + Push "$ADD_TO_PATH_ALL_USERS" + Call ConditionalAddToRegistry + Push "AddToPathCurrentUser" + Push "$ADD_TO_PATH_CURRENT_USER" + Call ConditionalAddToRegistry + bundle_path_done: + StrCmp $DO_NOT_ADD_TO_PATH "1" bundle_path_added + StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 bundle_path_add + EnVar::SetHKLM + bundle_path_add: + EnVar::AddValue "Path" "$INSTDIR\bin" + Pop $R0 + StrCmp $R0 "0" bundle_path_template + DetailPrint "$INSTDIR\bin not added to PATH: EnVar error $R0" + bundle_path_template: + StrCpy $DO_NOT_ADD_TO_PATH 1 + bundle_path_added: +]=] CPACK_NSIS_EXTRA_INSTALL_COMMANDS @ONLY) +set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS [=[ + StrCmp $DO_NOT_ADD_TO_PATH "1" bundle_path_removed + StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 bundle_path_remove + EnVar::SetHKLM + bundle_path_remove: + EnVar::DeleteValue "Path" "$INSTDIR\bin" + Pop $R0 + bundle_path_removed: +]=]) + +# the layers and components, the name and the install prefix, at cpack time +set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_LIST_DIR}/CPackOptions.cmake") + +include(CPack) + +# the bundle's own component, in every package (CPackOptions.cmake): its metadata and, as macOS has no uninstall, +# a script that removes the package's files by its receipts +if (APPLE) + install(PROGRAMS "${PROJECT_SOURCE_DIR}/packaging/productbuild/uninstall-opendaq-bundle.sh" DESTINATION bin COMPONENT bundle_Runtime) +endif() +cpack_add_component(bundle_Runtime DISPLAY_NAME "bundle" REQUIRED) + +# an installer's choices (NSIS, productbuild): each module a choice of its own in the group Modules, selected; +# the rest required. A prebuilt staging has _Runtime, _Development and a _Runtime per +# module (Stagings.cmake); a layer built here has no choices of its own, all its components required +cpack_add_component_group(modules DISPLAY_NAME "Modules" DESCRIPTION "openDAQ modules" EXPANDED) +foreach(_staging IN LISTS BUNDLE_STAGINGS) + string(MAKE_C_IDENTIFIER "${_staging}" _c) + foreach(_component IN LISTS BUNDLE_COMPONENTS_${_c}) + if (BUNDLE_PREBUILT_${_c} AND _component MATCHES "^(.+)_Runtime$" AND NOT _component STREQUAL "${_c}_Runtime") + cpack_add_component(${_component} DISPLAY_NAME "${CMAKE_MATCH_1}" GROUP modules) + elseif (_component MATCHES "_Runtime$") + cpack_add_component(${_component} DISPLAY_NAME "${_staging} runtime" REQUIRED) + else() + cpack_add_component(${_component} DISPLAY_NAME "${_staging} development" REQUIRED) + endif() + endforeach() +endforeach() diff --git a/cmake/Sources.cmake b/cmake/Sources.cmake new file mode 100644 index 0000000..a67fd93 --- /dev/null +++ b/cmake/Sources.cmake @@ -0,0 +1,112 @@ +## +## Every layer built here from its sources (BUNDLE_FROM=SOURCES), in the order BUNDLE_LAYERS gives, the core first: +## where each layer's sources are (FetchContent_Declare, at its revision), its settings, and how it is added. +## +## FetchContent_MakeAvailable downloads them only (they are declared with a SOURCE_SUBDIR that does not exist). Then +## each layer's external/boost/Boost.cmake is included: Boost is built once, by the core, with the components every +## layer has asked for by then, so all of them ask before the core is added. Then each layer is added, SYSTEM, so its +## headers do not turn its warnings into the consumers' errors. +## +## A layer's install components are those that appear while it is added; what it installs with no COMPONENT goes to +## _Development. They are kept for Packing.cmake as BUNDLE_COMPONENTS_, the staging's name made a C +## identifier. +## + +include_guard(GLOBAL) + + +# === the sources ============================================================================================= + +# each layer's sources, downloaded only by FetchContent_MakeAvailable: a SOURCE_SUBDIR that does not exist, so they +# are added below, after every layer's Boost.cmake +FetchContent_Declare(openDAQ GIT_REPOSITORY https://github.com/openDAQ/openDAQ.git GIT_TAG ${BUNDLE_REVISION_OPENDAQ} SOURCE_SUBDIR _download_only_) +FetchContent_Declare(OpcUaModules GIT_REPOSITORY https://github.com/openDAQ/OpcUaModules.git GIT_TAG ${BUNDLE_REVISION_OPCUAMODULES} SOURCE_SUBDIR _download_only_) +FetchContent_Declare(MQTTStreamingModule GIT_REPOSITORY https://github.com/openDAQ/MQTTStreamingModule.git GIT_TAG ${BUNDLE_REVISION_MQTTSTREAMINGMODULE} SOURCE_SUBDIR _download_only_) +FetchContent_Declare(LTStreamingModulesModern GIT_REPOSITORY https://github.com/openDAQ/LTStreamingModulesModern.git GIT_TAG ${BUNDLE_REVISION_LTSTREAMINGMODULESMODERN} SOURCE_SUBDIR _download_only_) +FetchContent_Declare(ASAM-CMP-Modules GIT_REPOSITORY https://github.com/openDAQ/ASAM-CMP-Modules.git GIT_TAG ${BUNDLE_REVISION_ASAM-CMP-MODULES} SOURCE_SUBDIR _download_only_) + + +# === the core ================================================================================================ + +set(OPENDAQ_ENABLE_OPCUA OFF CACHE BOOL "") +set(OPENDAQ_GENERATE_DELPHI_BINDINGS OFF CACHE BOOL "") +set(OPENDAQ_GENERATE_PYTHON_BINDINGS ON CACHE BOOL "") +set(OPENDAQ_GENERATE_CSHARP_BINDINGS ON CACHE BOOL "") +set(OPENDAQ_GENERATE_C_BINDINGS ON CACHE BOOL "") +set(OPENDAQ_ENABLE_NATIVE_STREAMING ON CACHE BOOL "") +set(OPENDAQ_ENABLE_WEBSOCKET_STREAMING OFF CACHE BOOL "") +set(OPENDAQ_ENABLE_TESTS ${BUNDLE_ENABLE_TESTS} CACHE BOOL "") +set(OPENDAQ_DOCUMENTATION_TESTS OFF CACHE BOOL "") +set(APP_ENABLE_WEBPAGE_EXAMPLES OFF CACHE BOOL "") +# the core's own modules, as its staging has them; built only when the core comes from sources +set(DAQMODULES_EMPTY_MODULE ON CACHE BOOL "") +set(DAQMODULES_OPENDAQ_CLIENT_MODULE ON CACHE BOOL "") +set(DAQMODULES_OPENDAQ_SERVER_MODULE ON CACHE BOOL "") +set(DAQMODULES_REF_DEVICE_MODULE ON CACHE BOOL "") +set(DAQMODULES_SIMULATOR_DEVICE_MODULE ON CACHE BOOL "") +set(DAQMODULES_REF_FB_MODULE ON CACHE BOOL "") +set(DAQMODULES_AUDIO_DEVICE_MODULE ON CACHE BOOL "") +set(DAQMODULES_BASIC_CSV_RECORDER_MODULE ON CACHE BOOL "") +set(DAQMODULES_LICENSING_MODULE ON CACHE BOOL "") +set(DAQMODULES_PARQUET_RECORDER_MODULE OFF CACHE BOOL "") + + +# === the modules ============================================================================================= + +# OpcUaModules +set(DAQMODULES_OPCUA_ENABLE_TESTS ${BUNDLE_ENABLE_TESTS} CACHE BOOL "") +set(DAQMODULES_OPCUA_ENABLE_EXAMPLE_APP OFF CACHE BOOL "") +set(DAQMODULES_OPCUA_ENABLE_CLIENT ON CACHE BOOL "") +set(DAQMODULES_OPCUA_ENABLE_SERVER ON CACHE BOOL "") +set(DAQMODULES_OPCUA_ENABLE_GENERIC_CLIENT ON CACHE BOOL "") + +# MQTTStreamingModule +set(DAQMODULES_MQTT_ENABLE_TESTS ${BUNDLE_ENABLE_TESTS} CACHE BOOL "") +set(DAQMODULES_MQTT_ENABLE_EXAMPLE_APP OFF CACHE BOOL "") +set(DAQMODULES_MQTT_ENABLE_SSL OFF CACHE BOOL "") + +# LTStreamingModulesModern +set(DAQMODULES_LT_STREAMING_ENABLE_TESTS ${BUNDLE_ENABLE_TESTS} CACHE BOOL "") +set(DAQMODULES_LT_STREAMING_ENABLE_EXAMPLE_APP OFF CACHE BOOL "") +set(DAQMODULES_LT_STREAMING_ENABLE_CLIENT ON CACHE BOOL "") +set(DAQMODULES_LT_STREAMING_ENABLE_SERVER ON CACHE BOOL "") + +# ASAM-CMP-Modules +set(ASAM_CMP_ENABLE_TESTS ${BUNDLE_ENABLE_TESTS} CACHE BOOL "") +set(ASAM_CMP_ENABLE_EXAMPLE OFF CACHE BOOL "") +set(ASAM_CMP_BUILD_DATA_SINK ON CACHE BOOL "") +set(ASAM_CMP_BUILD_CAPTURE_MODULE ON CACHE BOOL "") + + +# === built here ============================================================================================== + +set(_layers) +foreach(_entry IN LISTS BUNDLE_LAYERS) + string(REPLACE "=" ";" _pair "${_entry}") + list(GET _pair 0 _layer) + list(APPEND _layers ${_layer}) +endforeach() +FetchContent_MakeAvailable(${_layers}) + +foreach(_layer IN LISTS _layers) + string(TOLOWER "${_layer}" _lower) + include("${${_lower}_SOURCE_DIR}/external/boost/Boost.cmake" OPTIONAL) +endforeach() + +foreach(_entry IN LISTS BUNDLE_LAYERS) + string(REPLACE "=" ";" _pair "${_entry}") + list(GET _pair 0 _layer) + list(GET _pair 1 _staging) + string(TOLOWER "${_layer}" _lower) + string(MAKE_C_IDENTIFIER "${_staging}" _c) + + get_cmake_property(_before COMPONENTS) + set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "${_c}_Development") + add_subdirectory("${${_lower}_SOURCE_DIR}" "${${_lower}_BINARY_DIR}" SYSTEM) + get_cmake_property(_components COMPONENTS) + if (_before) + list(REMOVE_ITEM _components ${_before}) + endif() + set_property(GLOBAL PROPERTY BUNDLE_COMPONENTS_${_c} "${_components}") +endforeach() +unset(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME) diff --git a/cmake/Stagings.cmake b/cmake/Stagings.cmake new file mode 100644 index 0000000..57a9e9e --- /dev/null +++ b/cmake/Stagings.cmake @@ -0,0 +1,88 @@ +## +## Every staging taken prebuilt (BUNDLE_FROM=STAGINGS): unpacked into the directory BUNDLE_PREFIX_ gives +## (the name upper-cased), one for every staging BUNDLE_LAYERS has, else an error. Nothing is fetched or compiled: +## a staging's files are installed under its install components. +## +## A staging's install components are kept for Packing.cmake as BUNDLE_COMPONENTS_, and BUNDLE_PREBUILT_, +## the staging's name made a C identifier. +## + +include_guard(GLOBAL) + +set(_BUNDLE_RUNTIME_PATTERNS "*.so" "*.so.*" "*.dylib" "*.dll") + +# bundle_install_prefix( ) +# The prefix's files under the staging's install components: a module (a *.module.* file in lib/modules or +# bin/modules) under one of its own, _Runtime, so an installer can offer it apart (no staging in the name: +# NSIS makes variables of component names, 60 characters at most); other shared libraries under _Runtime; the +# rest — headers, CMake configs, static and import libraries — under _Development. File by file, so no empty +# directory lands in a component. +function(bundle_install_prefix STAGING PREFIX) + string(MAKE_C_IDENTIFIER "${STAGING}" _c) + file(GLOB_RECURSE _files LIST_DIRECTORIES false RELATIVE "${PREFIX}" "${PREFIX}/*") + set(_places) + foreach(_f IN LISTS _files) + get_filename_component(_n "${_f}" NAME) + get_filename_component(_d "${_f}" DIRECTORY) + set(_component ${_c}_Development) + foreach(_p IN LISTS _BUNDLE_RUNTIME_PATTERNS) + string(REPLACE "." "\\." _rx "${_p}") + string(REPLACE "*" ".*" _rx "${_rx}") + if (_n MATCHES "^${_rx}$") + set(_component ${_c}_Runtime) + endif() + endforeach() + if (_d MATCHES "^(lib|bin)/modules$" AND _n MATCHES "\\.module\\.") # not an import library beside it + # a module's name from its file: libref_fb_module-64-3.module.so → ref_fb_module + string(REGEX REPLACE "^lib" "" _stem "${_n}") + string(REGEX REPLACE "(-[0-9]+-[0-9]+)?\\.module\\..*$" "" _stem "${_stem}") + set(_component ${_stem}_Runtime) + endif() + string(MAKE_C_IDENTIFIER "${_component}_${_d}" _key) + list(APPEND _files_${_key} "${PREFIX}/${_f}") + list(APPEND _places "${_component}|${_d}") + endforeach() + + set(_components) + list(REMOVE_DUPLICATES _places) + foreach(_e IN LISTS _places) + string(REPLACE "|" ";" _e "${_e}") + list(GET _e 0 _component) + list(LENGTH _e _len) + set(_d "") + if (_len GREATER 1) + list(GET _e 1 _d) + endif() + string(MAKE_C_IDENTIFIER "${_component}_${_d}" _key) + if (_d STREQUAL "") + set(_d .) + endif() + install(FILES ${_files_${_key}} DESTINATION "${_d}" COMPONENT ${_component}) + list(APPEND _components ${_component}) + endforeach() + list(REMOVE_DUPLICATES _components) + set_property(GLOBAL PROPERTY BUNDLE_COMPONENTS_${_c} "${_components}") + set_property(GLOBAL PROPERTY BUNDLE_PREBUILT_${_c} TRUE) +endfunction() + +set(_missing) +foreach(_entry IN LISTS BUNDLE_LAYERS) + string(REPLACE "=" ";" _pair "${_entry}") + list(GET _pair 1 _staging) + string(TOUPPER "${_staging}" _upper) + set(BUNDLE_PREFIX_${_upper} "" CACHE PATH "The prebuilt staging ${_staging}, unpacked") + if (NOT IS_DIRECTORY "${BUNDLE_PREFIX_${_upper}}") + list(APPEND _missing "BUNDLE_PREFIX_${_upper}") + endif() +endforeach() +if (_missing) + list(JOIN _missing ", " _missing) + message(FATAL_ERROR "BUNDLE_FROM=STAGINGS takes every staging prebuilt; no directory given as ${_missing}") +endif() + +foreach(_entry IN LISTS BUNDLE_LAYERS) + string(REPLACE "=" ";" _pair "${_entry}") + list(GET _pair 1 _staging) + string(TOUPPER "${_staging}" _upper) + bundle_install_prefix("${_staging}" "${BUNDLE_PREFIX_${_upper}}") +endforeach() diff --git a/packaging/nsis/EnVar/license.txt b/packaging/nsis/EnVar/license.txt new file mode 100644 index 0000000..3225934 --- /dev/null +++ b/packaging/nsis/EnVar/license.txt @@ -0,0 +1,18 @@ +EnVar plugin for NSIS + +Coded by Jason Ross aka JasonFriday13 on the forums. + +Copyright (C) 2014-2016, 2018, 2020-2021, 2026 MouseHelmet Software + + +EULA - End User License Agreement + +This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff --git a/packaging/nsis/EnVar/x86-ansi/EnVar.dll b/packaging/nsis/EnVar/x86-ansi/EnVar.dll new file mode 100644 index 0000000..10d2e67 Binary files /dev/null and b/packaging/nsis/EnVar/x86-ansi/EnVar.dll differ diff --git a/packaging/nsis/EnVar/x86-unicode/EnVar.dll b/packaging/nsis/EnVar/x86-unicode/EnVar.dll new file mode 100644 index 0000000..7b4b146 Binary files /dev/null and b/packaging/nsis/EnVar/x86-unicode/EnVar.dll differ diff --git a/packaging/nsis/nsis_header.bmp b/packaging/nsis/nsis_header.bmp new file mode 100644 index 0000000..e1ef408 Binary files /dev/null and b/packaging/nsis/nsis_header.bmp differ diff --git a/packaging/nsis/nsis_welcome.bmp b/packaging/nsis/nsis_welcome.bmp new file mode 100644 index 0000000..1fd8327 Binary files /dev/null and b/packaging/nsis/nsis_welcome.bmp differ diff --git a/packaging/nsis/opendaq.ico b/packaging/nsis/opendaq.ico new file mode 100644 index 0000000..6723681 Binary files /dev/null and b/packaging/nsis/opendaq.ico differ diff --git a/packaging/productbuild/uninstall-opendaq-bundle.sh b/packaging/productbuild/uninstall-opendaq-bundle.sh new file mode 100755 index 0000000..b25721f --- /dev/null +++ b/packaging/productbuild/uninstall-opendaq-bundle.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Removes what the openDAQ bundle's macOS package installed, and the package's receipts: macOS has no uninstall +# of its own. Only the bundle's files go, by the receipts, so a core installed beside it stays. +# +# sudo /opt/opendaq/bin/uninstall-opendaq-bundle.sh + +if [ "$(id -u)" -ne 0 ]; then + echo "run it as root: sudo $0" >&2 + exit 1 +fi + +ids=$(pkgutil --pkgs='io\.opendaq\.bundle\..*') +if [ -z "$ids" ]; then + echo "the openDAQ bundle is not installed" + exit 0 +fi + +for id in $ids; do + pkgutil --only-files --files "$id" | while IFS= read -r f; do + rm -f "/$f" + done + pkgutil --forget "$id" >/dev/null + echo "removed $id" +done + +# the directories the files leave empty +find /opt/opendaq -depth -type d -empty -delete 2>/dev/null +exit 0