Skip to content

Commit

Permalink
Switch to bare-make (#203)
Browse files Browse the repository at this point in the history
* Switch to `bare-make`

* Fix compiler options

* Also pass compiler options on Windows

* Enable SSE4.1, AES, AVX, and AVX2
  • Loading branch information
kasperisager authored Oct 23, 2024
1 parent ae780e0 commit aaf40d5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 30 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/prebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@ jobs:
- os: ubuntu-22.04
platform: android
arch: x64
flags: --android-ndk 26.1.10909125 --android-api 34
- os: ubuntu-22.04
platform: android
arch: ia32
flags: --android-ndk 26.1.10909125 --android-api 34
- os: ubuntu-22.04
platform: android
arch: arm64
flags: --android-ndk 26.1.10909125 --android-api 34
- os: ubuntu-22.04
platform: android
arch: arm
flags: --android-ndk 26.1.10909125 --android-api 34
- os: macos-12
- os: macos-14
platform: darwin
arch: x64
- os: macos-14
Expand Down Expand Up @@ -62,9 +58,11 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: lts/*
- run: npm install -g bare-dev
- run: npm install -g bare-make
- run: npm install
- run: bare-dev install --bare --node --platform ${{ matrix.platform }} --arch ${{ matrix.arch }} ${{ matrix.flags }}
- run: bare-make generate --platform ${{ matrix.platform }} --arch ${{ matrix.arch }} ${{ matrix.flags }}
- run: bare-make build
- run: bare-make install
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.tags }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install -g bare-runtime bare-dev
- run: npm install -g bare-runtime bare-make
- run: npm install
- run: bare-dev install --bare --node --debug
- run: bare-make generate --debug
- run: bare-make build
- run: bare-make install
- run: npm test
44 changes: 23 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
cmake_minimum_required(VERSION 3.25)

project(sodium_native C ASM)
find_package(cmake-bare REQUIRED PATHS node_modules/cmake-bare)
find_package(cmake-napi REQUIRED PATHS node_modules/cmake-napi)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

include(TestBigEndian)
project(sodium_native C ASM)

include(bare)
include(napi)
include(TestBigEndian)

bare_target(target)

Expand Down Expand Up @@ -285,12 +285,6 @@ if(target MATCHES "darwin|ios")
endif()

if(target MATCHES "linux")
target_compile_options(
sodium
PRIVATE
-fno-strict-overflow
)

target_compile_definitions(
sodium
PRIVATE
Expand Down Expand Up @@ -339,19 +333,27 @@ if(target MATCHES "x64")
sodium
PRIVATE
HAVE_CPUID=1
HAVE_MMINTRIN_H=1
HAVE_EMMINTRIN_H=1
HAVE_PMMINTRIN_H=1
HAVE_TMMINTRIN_H=1
HAVE_EMMINTRIN_H=1 # SSE2
HAVE_PMMINTRIN_H=1 # SSE3
HAVE_TMMINTRIN_H=1 # SSSE3
HAVE_SMMINTRIN_H=1 # SSE4.1
HAVE_WMMINTRIN_H=1 # AES
HAVE_AVXINTRIN_H=1 # AVX
HAVE_AVX2INTRIN_H=1 # AVX2
)

if(NOT target MATCHES "ios")
target_compile_definitions(
sodium
PRIVATE
HAVE_TMMINTRIN_H
)
endif()
target_compile_options(
sodium
PRIVATE
-msse2
-msse3
-mssse3
-msse4.1
-maes
-mpclmul
-mavx
-mavx2
)

if(NOT target MATCHES "win32")
target_compile_definitions(
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
},
"devDependencies": {
"brittle": "^3.5.0",
"cmake-bare": "^1.1.10",
"cmake-napi": "^1.0.5",
"standard": "^17.1.0"
},
"scripts": {
Expand Down

0 comments on commit aaf40d5

Please sign in to comment.