diff --git a/.github/workflows/build-deno-so.yml b/.github/workflows/build-deno-so.yml deleted file mode 100644 index 7523a80..0000000 --- a/.github/workflows/build-deno-so.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Build Deno Shared Library - -on: - push: - branches: [ main, master ] - pull_request: - -jobs: - build-deno-so: - name: Build shared library for Deno - runs-on: ubuntu-latest - - container: - image: ubuntu:24.04 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install build dependencies - env: - DEBIAN_FRONTEND: noninteractive - run: | - apt-get update - apt-get install -y --no-install-recommends ninja-build g++ git ca-certificates - rm -rf /var/lib/apt/lists/* - - - name: Setup CMake >= 3.30 - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: '3.31.x' - - - name: Configure CMake (Release) - env: - CXX: g++ - run: | - cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release - - - name: Build shared library - run: | - cmake --build build --config Release - - - name: Collect shared library artifact - run: | - mkdir -p deno-lib/linux-x86_64 - cp build/libcpp_bindings_linux.so* deno-lib/linux-x86_64/ - ls -R deno-lib - - - name: Upload .so artifact for Deno - uses: actions/upload-artifact@v4 - with: - name: cpp-bindings-linux-so-linux-x86_64 - path: deno-lib/** - - diff --git a/.github/workflows/build_binary.yml b/.github/workflows/build_binary.yml new file mode 100644 index 0000000..91d975a --- /dev/null +++ b/.github/workflows/build_binary.yml @@ -0,0 +1,68 @@ +name: 'Build Binary' +description: | + This workflow builds the binary files for Linux. The build binaries are stored as artifact + and may be reused by other workflows. + +on: + push: + branches: [ main ] + + pull_request: {} + +jobs: + build-binary: + name: 'Build Binary' + runs-on: ubuntu-latest + steps: + - name: 'Checkout repository' + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up GCC + uses: egor-tensin/setup-gcc@v2 + with: + version: '14' + platform: 'x64' + + - name: 'Setup CMake' + uses: jwlawson/actions-setup-cmake@v2 + with: + cmake-version: '3.31.x' + + - name: 'Configure CMake' + env: + CXX: g++ + + run: | + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release + + - name: 'Build' + id: 'build' + run: | + cmake --build build --config Release + + . build/env.sh + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + + - name: 'Upload artifacts' + uses: actions/upload-artifact@v4 + with: + name: libcpp_bindings_linux_x86_64 + path: build/libcpp_bindings_linux.so* + + outputs: + version: ${{ steps.build.outputs.VERSION }} + + trigger-publish: + name: 'Trigger Publish' + needs: ['build-binary'] + uses: ./.github/workflows/publish_jsr.yml + with: + publish: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + version: ${{ needs.build-binary.outputs.version }} + artifact-name: libcpp_bindings_linux_x86_64 + + permissions: + contents: read + id-token: write diff --git a/.github/workflows/cpp-tests.yml b/.github/workflows/cpp_tests.yml similarity index 100% rename from .github/workflows/cpp-tests.yml rename to .github/workflows/cpp_tests.yml diff --git a/.github/workflows/deno-tests.yml b/.github/workflows/deno_tests.yml similarity index 100% rename from .github/workflows/deno-tests.yml rename to .github/workflows/deno_tests.yml diff --git a/.github/workflows/publish-jsr.yml b/.github/workflows/publish-jsr.yml deleted file mode 100644 index 71bc996..0000000 --- a/.github/workflows/publish-jsr.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Publish to JSR (@serial/cpp-bindings-linux) - -on: - workflow_dispatch: - inputs: {} - - push: - branches: - - '*' - - tags: - - "v*" - -permissions: - contents: read - id-token: write - -jobs: - publish-jsr: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install build dependencies - env: - DEBIAN_FRONTEND: noninteractive - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends ninja-build g++ git ca-certificates - - - name: Setup CMake >= 3.30 - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: "3.31.x" - - - name: Setup Deno - uses: denoland/setup-deno@v2 - with: - deno-version: "2.x" - - - name: Configure CMake (Release) - env: - CXX: g++ - run: | - cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release - - - name: Build shared library - run: | - cmake --build build --config Release - - - name: Embed binary as JSON/base64 for JSR - run: | - ./jsr/scripts/embed_binary.sh \ - ./build/libcpp_bindings_linux.so \ - ./jsr/package/bin \ - linux-x86_64 - cp LICENSE ./jsr/package/LICENSE - - - name: Publish package to JSR (real) - if: github.ref_type == 'tag' - working-directory: jsr/package - run: | - deno publish --allow-dirty - - - name: Publish package to JSR (dry-run) - if: github.ref_type != 'tag' - working-directory: jsr/package - run: | - deno publish --allow-dirty --dry-run diff --git a/.github/workflows/publish_jsr.yml b/.github/workflows/publish_jsr.yml new file mode 100644 index 0000000..9cb933a --- /dev/null +++ b/.github/workflows/publish_jsr.yml @@ -0,0 +1,73 @@ +name: 'Publish JSR' +description: | + This workflow serializes the build binary to Base64 and generates a JSON file with meta data about the file. + The file then gets published to JSR (@serial/cpp-bindings-linux). + +on: + workflow_call: + inputs: + publish: + description: 'Whether to actually publish' + required: true + type: boolean + + version: + description: 'Package version' + required: true + type: string + + artifact-name: + description: 'Name of the artifact' + required: true + type: string + +permissions: + contents: read + id-token: write + +jobs: + publish-jsr: + runs-on: ubuntu-latest + + steps: + - name: 'Checkout repository' + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: 'Setup Deno' + uses: denoland/setup-deno@v2 + with: + deno-version: '2.x' + + - name: 'Download artifact' + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: 'artifacts' + + - name: 'Prepare files for JSR' + run: | + mkdir -p ./jsr/bin + + cp ./artifacts/libcpp_bindings_linux.so ./jsr/bin/x86_64.so + + ./jsr/scripts/set_version.sh jsr/jsr.json "${{ inputs.version }}" + + ./jsr/scripts/binary_to_json.sh \ + ./artifacts/libcpp_bindings_linux.so \ + ./jsr/bin/x86_64.json \ + linux-x86_64 + + - name: 'Publish package to JSR (normal)' + if: inputs.publish + working-directory: jsr + run: | + deno publish --allow-dirty + + - name: 'Publish package to JSR (dry-run)' + if: ${{ !inputs.publish }} + working-directory: jsr + run: | + deno publish --allow-dirty --dry-run + diff --git a/CMakeLists.txt b/CMakeLists.txt index 5046ac8..9fc58ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,13 +23,7 @@ project( LANGUAGES CXX ) -# Generate JSR package metadata from the same git-derived version as the library. -# We generate into the build directory to avoid touching tracked files during normal local builds. -configure_file( - "${CMAKE_SOURCE_DIR}/jsr/package/jsr.json.in" - "${CMAKE_SOURCE_DIR}/jsr/package/jsr.json" - @ONLY -) +file(WRITE "${CMAKE_BINARY_DIR}/env.sh" "export VERSION=${PROJECT_VERSION}") # Set C++ standard set(CMAKE_CXX_STANDARD 23) diff --git a/jsr/.gitignore b/jsr/.gitignore new file mode 100644 index 0000000..0e547b0 --- /dev/null +++ b/jsr/.gitignore @@ -0,0 +1,2 @@ +bin/ +!src/bin/ diff --git a/jsr/LICENSE b/jsr/LICENSE new file mode 100644 index 0000000..fd8cd28 --- /dev/null +++ b/jsr/LICENSE @@ -0,0 +1,298 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version of + the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is necessary + to install and execute a modified version of the Combined Work + produced by recombining or relinking the Application with a modified + version of the Linked Version. (If you use option 4d0, the + Installation Information must accompany the Minimal Corresponding + Source and Corresponding Application Code. If you use option 4d1, you + must provide the Installation Information in the manner specified by + section 6 of the GNU GPL for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + + 7. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 8. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or run +a copy of the Library. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + 11. Patents. + + A contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange to extend the +patent license to downstream recipients. "Knowingly relying" means you +have actual knowledge that, but for the patent license, your conveying +the covered work in a country, or your recipient's use of the covered +work in a country, would infringe one or more identifiable patents in +that country. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + If you convey a covered work, you may not impose any further +restrictions on the exercise of the rights granted or affirmed under +this License. For example, you may not impose a license fee, royalty, +or other charge for exercise of rights granted under this License, and +you may not initiate litigation (including a cross-claim or +counterclaim in a lawsuit) alleging that any patent claim is infringed +by making, using, selling, offering for sale, or importing the Program +or any portion of it. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combined work as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Lesser General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail +to address new problems or concerns. + + Each version is given a distinguishing version number. If the Library as +you received it specifies that a certain numbered version of the GNU Lesser +General Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that published +version or of any later version published by the Free Software Foundation. +If the Library as you received it does not specify a version number of the +GNU Lesser General Public License, you may choose any version of the GNU +Lesser General Public License ever published by the Free Software +Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the Library. + + END OF TERMS AND CONDITIONS + + diff --git a/jsr/package/README.md b/jsr/README.md similarity index 100% rename from jsr/package/README.md rename to jsr/README.md diff --git a/jsr/jsr.json b/jsr/jsr.json new file mode 100644 index 0000000..1cf5fb9 --- /dev/null +++ b/jsr/jsr.json @@ -0,0 +1,23 @@ +{ + "name": "@serial/cpp-bindings-linux", + "version": "0.1.0", + "license": "./LICENSE", + "description": "C++ Linux Bindings for the serial library", + "exports": { + "./bin": "./src/bin/index.ts" + }, + "publish": { + "include": [ + "README.md", + "LICENSE", + "jsr.json", + "src/**", + "bin/**" + ], + "exclude": [ + "!bin/" + ] + } +} + + diff --git a/jsr/package/.gitignore b/jsr/package/.gitignore deleted file mode 100644 index d062c58..0000000 --- a/jsr/package/.gitignore +++ /dev/null @@ -1 +0,0 @@ -jsr.json diff --git a/jsr/package/jsr.json.in b/jsr/package/jsr.json.in deleted file mode 100644 index 0cbcaf8..0000000 --- a/jsr/package/jsr.json.in +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@serial/cpp-bindings-linux", - "version": "@PROJECT_VERSION@", - "license": "LICENSE", - "description": "Linux shared-library bindings for Serial-IO/cpp-core (distributed via JSON/base64 because JSR has limited binary support).", - "exports": { - "./bin/x86_64": "./bin/x86_64.json" - }, - "publish": { - "include": [ - "README.md", - "LICENSE", - "jsr.json", - "bin/**" - ] - } -} - - diff --git a/jsr/scripts/binary_to_json.sh b/jsr/scripts/binary_to_json.sh new file mode 100755 index 0000000..f4240aa --- /dev/null +++ b/jsr/scripts/binary_to_json.sh @@ -0,0 +1,33 @@ +#!/bin/sh +set -eu + +if [ "$#" -ne 3 ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +BINARY_FILE_PATH=$1 +JSON_FILE_PATH=$2 +TARGET=$3 + +if [ ! -f "$BINARY_FILE_PATH" ]; then + echo "Error: Binary path is not a file: $BINARY_FILE_PATH" >&2 + exit 1 +fi + +FILENAME=$(basename "$BINARY_FILE_PATH") + +mkdir -p $(basename "$JSON_FILE_PATH") + +BASE64_DATA=$(base64 "$BINARY_FILE_PATH" | tr -d '\n') + +jq -n \ + --arg target "$TARGET" \ + --arg filename "$FILENAME" \ + --arg data "$BASE64_DATA" \ + '{ + target: $target, + filename: $filename, + encoding: "base64", + data: $data + }' > "$JSON_FILE_PATH" diff --git a/jsr/scripts/embed_binary.sh b/jsr/scripts/embed_binary.sh deleted file mode 100755 index 2f500dd..0000000 --- a/jsr/scripts/embed_binary.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -set -eu - -if [ "$#" -ne 3 ]; then - echo "Usage: $0 " >&2 - exit 1 -fi - -BINARY_PATH=$1 -JSR_BIN_PATH=$2 -TARGET=$3 - -if [ ! -f "$BINARY_PATH" ]; then - echo "Error: Binary path is not a file: $BINARY_PATH" >&2 - exit 1 -fi - -FILENAME=$(basename "$BINARY_PATH") - -mkdir -p "$JSR_BIN_PATH" - -cp "$BINARY_PATH" "$JSR_BIN_PATH/x86_64.so" - -BASE64_DATA=$(base64 "$BINARY_PATH" | tr -d '\n') - -jq -n \ - --arg target "$TARGET" \ - --arg filename "$FILENAME" \ - --arg data "$BASE64_DATA" \ - '{ - target: $target, - filename: $filename, - encoding: "base64", - data: $data - }' > "$JSR_BIN_PATH/x86_64.json" diff --git a/jsr/scripts/set_version.sh b/jsr/scripts/set_version.sh new file mode 100755 index 0000000..837cbf5 --- /dev/null +++ b/jsr/scripts/set_version.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -eu + +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +JSON_FILE_PATH=$1 +VERSION=$2 + +temp_json_file="$(mktemp)" + +sed "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" \ + "$JSON_FILE_PATH" > "$temp_json_file" + +mv "$temp_json_file" "$JSON_FILE_PATH" diff --git a/jsr/src/bin/index.ts b/jsr/src/bin/index.ts new file mode 100644 index 0000000..66555bc --- /dev/null +++ b/jsr/src/bin/index.ts @@ -0,0 +1,17 @@ +/** + * Module that provides exports for serialized binary files. + * + * @example + * Import the corresponding binary and write the file to disk. + * + * ```ts + * import {x86_64} from '@serial/cpp-bindings-linux/bin' + * + * Deno.writeFileSync(`./${x86_64.filename}`, Uint8Array.fromBase64(x86_64.data)) + * ``` + * @module + */ + +import x86_64 from '../../bin/x86_64.json' with { type: "json" } + +export {x86_64}