Skip to content

Commit

Permalink
Changed native dependencies install method
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannicalo committed Jan 20, 2024
1 parent 799be31 commit 8b2c0b0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 26 deletions.
1 change: 0 additions & 1 deletion .eslintignore
@@ -1,3 +1,2 @@
build
coverage
libraries
1 change: 0 additions & 1 deletion .gitignore
@@ -1,5 +1,4 @@
.vscode
build
coverage
libraries
node_modules
1 change: 0 additions & 1 deletion .npmignore
Expand Up @@ -11,5 +11,4 @@ build
coverage
jest.config.js
jsconfig.json
libraries
test
30 changes: 25 additions & 5 deletions CMakeLists.txt
Expand Up @@ -6,16 +6,34 @@ set(CMAKE_CXX_STANDARD 23)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(webpLibraries sharpyuv webp)

if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "/MTd /Zi")
set(CMAKE_CXX_FLAGS_RELEASE "/MT")
set(WITH_CRT_DLL FALSE)
set(
webpArguments
-DCMAKE_C_FLAGS_DEBUG="/MTd /Zi"
-DCMAKE_C_FLAGS_RELEASE="/MT"
)
set(webpLibraries libsharpyuv libwebp)
endif()

include_directories(${CMAKE_JS_INC})

add_definitions(-DNAPI_VERSION=8)

include(ExternalProject)

ExternalProject_Add(
webpProject
BUILD_COMMAND cmake --build . --config ${CMAKE_BUILD_TYPE} --target webp
CMAKE_ARGS ${webpArguments} -DCMAKE_POSITION_INDEPENDENT_CODE=ON
GIT_REPOSITORY "https://chromium.googlesource.com/webm/libwebp"
GIT_SHALLOW TRUE
GIT_TAG "v1.3.2"
INSTALL_COMMAND ""
)

file(GLOB_RECURSE source "source/native/*")

add_library(${PROJECT_NAME} SHARED ${source} ${CMAKE_JS_SRC})
Expand All @@ -30,8 +48,10 @@ execute_process(

string(REGEX REPLACE "[\n\r\"]" "" nodeAddonApi ${nodeAddonApi})

add_subdirectory("libraries/libwebp" EXCLUDE_FROM_ALL)
ExternalProject_Get_Property(webpProject BINARY_DIR SOURCE_DIR)

target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_JS_INC} ${nodeAddonApi} ${SOURCE_DIR}/src)

target_include_directories(${PROJECT_NAME} PRIVATE ${nodeAddonApi} "libraries/libwebp/src")
target_link_directories(${PROJECT_NAME} PRIVATE ${BINARY_DIR})

target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} webp)
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} ${webpLibraries})
2 changes: 1 addition & 1 deletion jsconfig.json
Expand Up @@ -5,5 +5,5 @@
"module": "CommonJS",
"target": "ES2022"
},
"exclude": ["build", "coverage", "libraries", "node_modules"]
"exclude": ["build", "coverage", "node_modules"]
}
5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -10,8 +10,7 @@
"dependencies": {
"bindings": "^1.5.0",
"cmake-js": "^7.3.0",
"node-addon-api": "^7.1.0",
"tar": "^6.2.0"
"node-addon-api": "^7.1.0"
},
"description": "WebP",
"devDependencies": {
Expand All @@ -35,7 +34,7 @@
"benchmark": "node scripts/benchmark",
"build": "cmake-js compile",
"build-debug": "cmake-js compile --debug",
"install": "node scripts/install && npm run build",
"install": "npm run build",
"lint": "eslint -f pretty .",
"start": "jest --watch",
"test": "jest"
Expand Down
14 changes: 0 additions & 14 deletions scripts/install.js

This file was deleted.

0 comments on commit 8b2c0b0

Please sign in to comment.