Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxou44 committed Mar 6, 2024
1 parent de9b796 commit 06429ff
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 29 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,24 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 16
node-version: 20

- name: Download EDSDK
run: |
curl ${{ secrets.SDK_WINDOWS_DOWNLOAD_URL }} -o third_party/edsdkw.zip
cd third_party/
7z x edsdkw.zip
- name: Patch EDSDKTypes.h file
run: node helpers/patch-headers.js
- name: Patch EDSDKTypes.h and binding.gyp files
run: node helpers/patch-files.js
env:
EDSDK_VERSION: ${{ secrets.EDSDK_VERSION }}

- name: Install dependencies
run: |
npm ci
- name: Package
- name: Package module
run: npm run package
env:
CI: true
Expand Down
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ Request LiveView stop, triggers event on success
* ["Error"](#CameraBrowser+event_Error)
* _static_
* [.EventName](#CameraBrowser.EventName) : <code>enum</code>
brick-a-brack

<a name="new_CameraBrowser_new"></a>

## new CameraBrowser()
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ to build a TGZ.
2. Make sure the variable `edsdk_version` in `binding.gyp` matches the EDSDK version. (The numeric part of the
package name)
3. Run `npm run package`
4. Look for `../node_packages/@brick-a-brack/napi-canon-cameras.tgz`
4. Look for `./dist/napi-canon-cameras.tgz`
5. `cd ../YourProject` (Switch to your project directory)
6. `npm i ../node_packages/@brick-a-brack/napi-canon-cameras.tgz`
6. `npm i ../path/to/folder/napi-canon-cameras.tgz`

The current EDSDK versions have a bug in `EDSDKTypes.h`. The keys are missing
their prefixes. This will result in a conflict at compile time.
Expand Down
42 changes: 42 additions & 0 deletions helpers/patch-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fs = require('fs');

const EDSDK_VERSION = process.env.EDSDK_VERSION || 131712;

for (const file of [
`third_party/EDSDKv${EDSDK_VERSION}L/Linux/EDSDK/Header/EDSDKTypes.h`,
`third_party/EDSDKv${EDSDK_VERSION}W/Windows/EDSDK/Header/EDSDKTypes.h`,
]) {
let originalData = '';
try {
originalData = fs.readFileSync(file, 'utf8');
} catch (e) {
continue;
}
const patchedData = originalData
.replace(' UNKNOWN = 0x00000000,', ' kEdsObjectFormat_Unknown = 0x00000000,')
.replace(' Jpeg = 0x3801,', ' kEdsObjectFormat_Jpeg = 0x3801,')
.replace(' CR2 = 0xB103,', ' kEdsObjectFormat_CR2 = 0xB103,')
.replace(' MP4 = 0xB982,', ' kEdsObjectFormat_MP4 = 0xB982,')
.replace(' CR3 = 0xB108,', ' kEdsObjectFormat_CR3 = 0xB108,')
.replace(' HEIF_CODE = 0xB10B,', ' kEdsObjectFormat_HEIF_CODE = 0xB10B,')
if (originalData !== patchedData) {
fs.rmSync(file);
fs.writeFileSync(file, patchedData);
console.log("Patched file", file);
} else {
console.log("File not patched", file)
}
}

const file = 'binding.gyp';
const originalData = fs.readFileSync(file, 'utf8');
const regex = /"edsdk_version": "([0-9]+)"/gm;
const patchedData = originalData.replace(regex, `"edsdk_version": "${EDSDK_VERSION}"`)

if (originalData !== patchedData) {
fs.rmSync(file);
fs.writeFileSync(file, patchedData);
console.log("Patched file", file);
} else {
console.log("File not patched", file)
}
21 changes: 0 additions & 21 deletions helpers/patch-headers.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@brick-a-brack/napi-canon-cameras",
"version": "0.1.3",
"version": "0.1.4",
"private": false,
"description": "Node AddOn Api module for Canon cameras. Wrapper for the Canon EDSDK.",
"keywords": [
Expand Down

0 comments on commit 06429ff

Please sign in to comment.