How to successfully build for Mojave?
Since versions higher than 0.4.5 say 10.14 users need to build it themselves, that's what I tried.
Unfortunately something has a Monterey minimum version requirement, and I'm not sure how to fix it. I initially tried using ./release.sh but then started using the individual commands to try and track the problem down. With a complete clean local directory, running yarn gives:
yarn install v1.22.18
[1/4] 🔍 Resolving packages...
success Already up-to-date.
$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 3.9.12 found at "/usr/local/opt/[email protected]/bin/python3.9"
gyp info spawn /usr/local/opt/[email protected]/bin/python3.9
gyp info spawn args [
gyp info spawn args '/Users/xcaiver/github/razer-macos/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/xcaiver/github/razer-macos/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/xcaiver/github/razer-macos/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/xcaiver/Library/Caches/node-gyp/18.0.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/xcaiver/Library/Caches/node-gyp/18.0.0',
gyp info spawn args '-Dnode_gyp_dir=/Users/xcaiver/github/razer-macos/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/xcaiver/Library/Caches/node-gyp/18.0.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/xcaiver/github/razer-macos',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/addon/src/driver/addon.o
clang: error: invalid version number in '-mmacosx-version-min=12.0.1'
clang: error: invalid version number in '-mmacosx-version-min=12.0.1'
make: *** [Release/obj.target/addon/src/driver/addon.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/xcaiver/github/razer-macos/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (node:events:527:28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/Cellar/node/18.0.0/bin/node" "/Users/xcaiver/github/razer-macos/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/xcaiver/github/razer-macos
gyp ERR! node -v v18.0.0
gyp ERR! node-gyp -v v8.2.0
gyp ERR! not ok
error Command failed with exit code 1.
Node, yarn, npm, Xcode, and other brew-installed things are as up to date as they can be on an os x 10.14.6 machine....
The only "macosx-version-min" line I can find explicitely added is in the librazermacos/Makefile, and that is just set to 10.5 so not the one that is causing the trouble.
Update: In "binding.gyp" I found " MACOSX_DEPLOYMENT_TARGET': '12.0.1'
In binding.gyp replacing the deployment_target with
'MACOSX_DEPLOYMENT_TARGET': '10.14.6',
and removing the three references to arm64 in that same file (since architecture wasn't supported in that old sdk)
And then manually running these two commands to kick it in to getting some older versions of these packages:
yarn add babel/[email protected]
yarn add @babel/preset-env
Allows it to get much further in the build process, but then it just gets to a bunch of electron and openssl errors...
npm install -d node-gyp@latest
and then adding this variable to the top of binding.gyp
{
"variables": {
"openssl_fips" : "0"
},
"targets": [
and removing more arm64 references in package.json and Makefile...
Further, but something is popping an "unsupported architecture" error still...
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/cdefs.h:784:2: error: Unsupported architecture
There was one more reference to 'universal' apps in package.json which I had to change to x64and a reference to 'x64' in the arches which I had to change to x86_64.
It seems to have actually built now... Package signing failed, but all my certs are probably long expired I haven't used my dev account in a couple years. So I'll deal with that later.
Sadly, this isn't working for me, and I think it's a combination of my inexperience and that I think I have a hopeless mishmash of 10.14.6 compatible resources and 11+ compatible resources. At one point, I had XCode for Monterey on an external drive, which led to me trying to upgrade homebrew, then tried to build this with that with bad results, but probably leading to wrong versions of things being installed. For example:
$ brew --version
Homebrew 3.4.10
Homebrew/homebrew-core (git revision b3b46b31c9e; last commit 2022-05-03)
$ node --version
v11.9.0
$ yarn --version
1.22.18
$ npm --version
(node:3208) ExperimentalWarning: The fs.promises API is experimental
7.6.3
Now that I have XCode 10.3 on my internal drive with its CLI package some things are working with this and some things aren't. I'm guessing I need to uninstall a bunch of stuff and start over. And that's probably beyond the scope of this thread, but thanks for listening.
@DPattee if you have it running, would you mind sharing a binary with me? I just don't think I have the skills to get my setup to compile it at this point. I'm on 10.14.6 on a 2021 MBP.
Yea, I'm going to fork and keep the relevant changes in place so I can keep making my own updated versions. Will try to figure out why my signing is failing this weekend then will post something.
Awesome. When I get a chance, I'll wade through resetting my setup so I have everything at the proper versions so I can give it a go, too, since I'd like to actually learn this stuff. :-P