Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows ARM64 prebuild configuration #1957

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
* Clean up inf/nan macros and slightly speed up argument checking.
### Added
* Added `deregisterAllFonts` method to free up memory and reduce font conflicts.
* Added prebuild configuration for Windows ARM64
### Fixed
* Support Apple M1 Homebrew install that puts canvas install library files in `/opt/homebrew/lib`

Expand Down
80 changes: 80 additions & 0 deletions prebuild/Windows-arm64/binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
'targets': [
{
'target_name': 'canvas',
'sources': [
'src/backend/Backend.cc',
'src/backend/ImageBackend.cc',
'src/backend/PdfBackend.cc',
'src/backend/SvgBackend.cc',
'src/bmp/BMPParser.cc',
'src/Backends.cc',
'src/Canvas.cc',
'src/CanvasGradient.cc',
'src/CanvasPattern.cc',
'src/CanvasRenderingContext2d.cc',
'src/closure.cc',
'src/color.cc',
'src/Image.cc',
'src/ImageData.cc',
'src/init.cc',
'src/register_font.cc'
],
'defines': [
'HAVE_GIF',
'HAVE_JPEG',
'HAVE_RSVG',
'HAVE_BOOLEAN', # or jmorecfg.h tries to define it
'_USE_MATH_DEFINES' # for M_PI
],
'libraries': [
'D:/a/_temp/msys/msys64/clangarm64/lib/libcairo-2.lib',
'D:/a/_temp/msys/msys64/clangarm64/lib/libpng16-16.lib',
'D:/a/_temp/msys/msys64/clangarm64/lib/libjpeg-8.lib',
'D:/a/_temp/msys/msys64/clangarm64/lib/libpango-1.0-0.lib',
'D:/a/_temp/msys/msys64/clangarm64/lib/libpangocairo-1.0-0.lib',
'D:/a/_temp/msys/msys64/clangarm64/lib/libgobject-2.0-0.lib',
'D:/a/_temp/msys/msys64/clangarm64/lib/libglib-2.0-0.lib',
'D:/a/_temp/msys/msys64/clangarm64/lib/libturbojpeg.lib',
'D:/a/_temp/msys/msys64/clangarm64/lib/libgif-7.lib',
'D:/a/_temp/msys/msys64/clangarm64/lib/libfreetype-6.lib',
'D:/a/_temp/msys/msys64/clangarm64/lib/librsvg-2-2.lib'
],
'include_dirs': [
'<!(node -e "require(\'nan\')")',
'D:/a/_temp/msys/msys64/clangarm64/include',
'D:/a/_temp/msys/msys64/clangarm64/include/pango-1.0',
'D:/a/_temp/msys/msys64/clangarm64/include/cairo',
'D:/a/_temp/msys/msys64/clangarm64/include/libpng16',
'D:/a/_temp/msys/msys64/clangarm64/include/glib-2.0',
'D:/a/_temp/msys/msys64/clangarm64/lib/glib-2.0/include',
'D:/a/_temp/msys/msys64/clangarm64/include/pixman-1',
'D:/a/_temp/msys/msys64/clangarm64/include/freetype2',
'D:/a/_temp/msys/msys64/clangarm64/include/fontconfig',
'D:/a/_temp/msys/msys64/clangarm64/include/librsvg-2.0',
'D:/a/_temp/msys/msys64/clangarm64/include/gdk-pixbuf-2.0',
'D:/a/_temp/msys/msys64/clangarm64/include/harfbuzz'
],
'configurations': {
'Debug': {
'msvs_settings': {
'VCCLCompilerTool': {
'WarningLevel': 4,
'ExceptionHandling': 1,
'DisableSpecificWarnings': [4100, 4127, 4201, 4244, 4267, 4506, 4611, 4714, 4512]
}
}
},
'Release': {
'msvs_settings': {
'VCCLCompilerTool': {
'WarningLevel': 4,
'ExceptionHandling': 1,
'DisableSpecificWarnings': [4100, 4127, 4201, 4244, 4267, 4506, 4611, 4714, 4512]
}
}
}
}
}
]
}
34 changes: 34 additions & 0 deletions prebuild/Windows-arm64/bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# dependency walker will help us figure out which DLLs
# canvas.node directly and indirectly uses
#wget --no-verbose --no-clobber http://www.dependencywalker.com/depends22_x64.zip
#unzip -u depends22_x64.zip

# write recurisve dependencies of canvas.node into depends.csv
#./depends -c -oc:depends.csv build/Release/canvas.node;

#[ -f depends.csv ] || {
# echo "error invoking depends.exe";
# exit 1;
#}

# case-insensitive intersection of 2nd column of depends.csv
# and all files ending in .dll in the clangarm64 directory
#copies=$(comm -12 \
# <(cat depends.csv | cut -d ',' -f2 | sed 's/"//g' | tr '[:upper:]' '[:lower:]' | sort) \
# <(find /clangarm64/bin -name '*.dll' -printf "%f\n" | tr '[:upper:]' '[:lower:]' | sort) \
#);

# We temporarily hardcode the dependencies as the dependency walker returns incomplete results on ARM64
copies="libbrotlicommon.dll libbrotlidec.dll libbz2-1.dll libc++.dll libcairo-2.dll
libcroco-0.6-3.dll libdatrie-1.dll libexpat-1.dll libffi-7.dll libfontconfig-1.dll
libfreetype-6.dll libfribidi-0.dll libgdk_pixbuf-2.0-0.dll libgif-7.dll libgio-2.0-0.dll
libglib-2.0-0.dll libgmodule-2.0-0.dll libgobject-2.0-0.dll libgraphite2.dll libharfbuzz-0.dll
libiconv-2.dll libintl-8.dll libjpeg-8.dll liblzma-5.dll libpango-1.0-0.dll libpangocairo-1.0-0.dll
libpangoft2-1.0-0.dll libpangowin32-1.0-0.dll libpcre-1.dll libpixman-1-0.dll libpng16-16.dll
librsvg-2-2.dll libthai-0.dll libunwind.dll libwinpthread-1.dll libxml2-2.dll zlib1.dll"

echo $copies;

for dll in $copies; do
cp /clangarm64/bin/$dll build/Release
done;
38 changes: 38 additions & 0 deletions prebuild/Windows-arm64/preinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# expects node, VS, and MSYS environments to be set up already. does everything else.

deps="cairo-2 png16-16 jpeg-8 pango-1.0-0 pangocairo-1.0-0 gobject-2.0-0 glib-2.0-0 turbojpeg gif-7 freetype-6 rsvg-2-2";

# install cairo and tools to create .lib

pacman --noconfirm -S \
wget \
unzip \
clangarm64/mingw-w64-clang-aarch64-binutils \
clangarm64/mingw-w64-clang-aarch64-tools \
clangarm64/mingw-w64-clang-aarch64-libjpeg-turbo \
clangarm64/mingw-w64-clang-aarch64-pango \
clangarm64/mingw-w64-clang-aarch64-cairo \
clangarm64/mingw-w64-clang-aarch64-giflib \
clangarm64/mingw-w64-clang-aarch64-freetype \
clangarm64/mingw-w64-clang-aarch64-fontconfig \
clangarm64/mingw-w64-clang-aarch64-librsvg \
clangarm64/mingw-w64-clang-aarch64-libxml2

# create .lib files for vc++

echo "generating lib files for the MSYS2 dlls"
for lib in $deps; do
/clangarm64/bin/gendef /clangarm64/bin/lib$lib.dll > /dev/null 2>&1 || {
echo "could not find lib$lib.dll, have to skip ";
continue;
}

/clangarm64/bin/dlltool -d lib$lib.def -l /clangarm64/lib/lib$lib.lib > /dev/null 2>&1 || {
echo "could not create dll for lib$lib.dll";
continue;
}

echo "created lib$lib.lib from lib$lib.dll";

rm lib$lib.def
done