Skip to content

Commit 79f6691

Browse files
committed
Removed unnecessary files from our packaged ASAR file.
1 parent f64c4f3 commit 79f6691

File tree

8 files changed

+37
-12
lines changed

8 files changed

+37
-12
lines changed

CMakeLists.txt

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,36 @@ endif()
129129

130130
# Link cmake-js and libOpenCOR to our Node.js add-on.
131131

132+
if(WIN32)
133+
set(LIBOPENCOR_DIR bin)
134+
set(FULL_LIBOPENCOR_FILENAME ${CMAKE_PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
135+
elseif(APPLE)
136+
set(LIBOPENCOR_DIR lib)
137+
set(FULL_LIBOPENCOR_FILENAME ${CMAKE_PROJECT_NAME}.${CMAKE_PROJECT_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX})
138+
else()
139+
set(LIBOPENCOR_DIR lib)
140+
set(FULL_LIBOPENCOR_FILENAME ${CMAKE_PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}.${CMAKE_PROJECT_VERSION})
141+
endif()
142+
143+
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/Shared/${LIBOPENCOR_DIR}/${FULL_LIBOPENCOR_FILENAME}
144+
${CMAKE_BINARY_DIR}/../${FULL_LIBOPENCOR_FILENAME})
145+
132146
if(WIN32)
133147
set(LIBOPENCOR_FILENAME ${CMAKE_PROJECT_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX})
148+
149+
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/Shared/lib/${LIBOPENCOR_FILENAME}
150+
${CMAKE_BINARY_DIR}/../${LIBOPENCOR_FILENAME})
134151
else()
135-
set(LIBOPENCOR_FILENAME ${CMAKE_PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
152+
set(LIBOPENCOR_FILENAME ${FULL_LIBOPENCOR_FILENAME})
136153
endif()
137154

138155
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
139156
${CMAKE_JS_LIB}
140-
${CMAKE_BINARY_DIR}/Shared/lib/${LIBOPENCOR_FILENAME})
157+
${CMAKE_BINARY_DIR}/../${LIBOPENCOR_FILENAME})
158+
159+
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
160+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${CMAKE_PROJECT_NAME}>
161+
${CMAKE_BINARY_DIR}/../${CMAKE_PROJECT_NAME}.node)
141162

142163
# Configure our splash screen.
143164

@@ -152,4 +173,4 @@ endif()
152173
set(VERSION ${PROJECT_VERSION})
153174

154175
configure_file(src/main/assets/splashscreen.html.in
155-
${CMAKE_BINARY_DIR}/splashscreen.html)
176+
${CMAKE_BINARY_DIR}/../splashscreen.html)

electron-builder.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ productName: OpenCOR
33
win:
44
artifactName: ${productName}-${version}-Windows.${ext}
55
extraFiles:
6-
- from: 'out/libOpenCOR/Shared/bin/libOpenCOR.dll'
6+
- from: 'out/libOpenCOR.dll'
77
to: 'libOpenCOR.dll'
88
target:
99
- nsis
@@ -15,7 +15,7 @@ linux:
1515
category: Utility
1616
executableName: OpenCOR
1717
extraFiles:
18-
- from: 'out/libOpenCOR/Shared/lib/libOpenCOR.so.0.0.0'
18+
- from: 'out/libOpenCOR.so.0.0.0'
1919
to: 'libOpenCOR.so.0.0.0'
2020
target:
2121
- AppImage
@@ -32,7 +32,7 @@ mac:
3232
# - APPLE_TEAM_ID: an id that can be found in the top right corner of https://developer.apple.com/account/resources/certificates/list.
3333
artifactName: ${productName}-${version}-macOS-${arch}.${ext}
3434
extraFiles:
35-
- from: 'out/libOpenCOR/Shared/lib/libOpenCOR.0.0.0.dylib'
35+
- from: 'out/libOpenCOR.0.0.0.dylib'
3636
to: 'Frameworks/libOpenCOR.0.0.0.dylib'
3737
target:
3838
- dmg

electron.vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default defineConfig({
2525
viteStaticCopy({
2626
targets: [
2727
{
28-
src: normalizePath(path.resolve(import.meta.dirname, 'out/libOpenCOR/Shared/bin/libOpenCOR.dll')),
28+
src: normalizePath(path.resolve(import.meta.dirname, 'out/libOpenCOR.dll')),
2929
dest: 'chunks'
3030
}
3131
]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"format": "prettier --log-level silent --write . && clang-format -i src/libopencor/src/*",
4141
"format:check": "prettier --log-level silent --check . && clang-format --dry-run -Werror src/libopencor/src/*",
4242
"lint": "eslint --fix .",
43-
"package": "pnpm build && electron-builder",
43+
"package": "pnpm build && node res/prepare-for-packaging.js && electron-builder",
4444
"publish:web": "pnpm publish ./src/renderer",
4545
"start": "pnpm build:libopencor && electron-vite preview",
4646
"start:web": "pnpm build:web && cd ./src/renderer && vite preview"

res/prepare-for-packaging.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import * as fs from 'fs'
2+
3+
fs.rmSync('out/libOpenCOR', { recursive: true, force: true })
4+
fs.rmSync('out/libOpenCOR.node', { force: true })

src/main/SplashScreenWindow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class SplashScreenWindow extends ApplicationWindow {
2222
alwaysOnTop: true
2323
})
2424

25-
this.loadFile('./out/libOpenCOR/splashscreen.html').catch((err: unknown) => {
25+
this.loadFile('./out/splashscreen.html').catch((err: unknown) => {
2626
console.error('Failed to load splash screen:', err)
2727
})
2828
}

src/main/assets/splashscreen.html.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
http-equiv="Content-Security-Policy"
99
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
1010
/>
11-
<link rel="stylesheet" href="../../src/main/assets/splashscreen.css" />
11+
<link rel="stylesheet" href="../src/main/assets/splashscreen.css" />
1212
</head>
1313
<body>
1414
<table class="contents">
1515
<tr>
1616
<td class="logo" colspan="2">
17-
<img class="logo" src="../../src/renderer/src/assets/logo.svg" />
17+
<img class="logo" src="../src/renderer/src/assets/logo.svg" />
1818
</td>
1919
</tr>
2020
<tr>

src/preload/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { contextBridge, ipcRenderer } from 'electron'
2-
import loc from '../../out/libOpenCOR/Release/libOpenCOR.node'
2+
import loc from '../../out/libOpenCOR.node'
33
import * as si from 'systeminformation'
44

55
// Some bridging between our main process and renderer process.

0 commit comments

Comments
 (0)