Skip to content

Initial implementation from node.js #3

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

Merged
merged 18 commits into from
Feb 6, 2025
Merged
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 .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
common --enable_workspace
build --cxxopt="-std=c++20"
8 changes: 6 additions & 2 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ jobs:
fail-fast: false
matrix:
shared: [ON, OFF]
cxx: [g++-12, clang++-14]
include:
- cc: gcc-12
cxx: g++-12
- cc: clang-14
cxx: clang++-14
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand All @@ -50,5 +54,5 @@ jobs:
- name: Build & Test
run: bazel test //...
env:
CC: ${{matrix.cxx}}
CC: ${{matrix.cc}}
CXX: ${{matrix.cxx}}
16 changes: 13 additions & 3 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: macos CI
name: macOS

on:
pull_request:
Expand All @@ -22,12 +22,22 @@ concurrency:

jobs:
ubuntu-build:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
runs-on: [macos-14, macos-15]
runs-on: ${{matrix.runs-on}}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{github.job}}-${{matrix.os}}
- name: Prepare
run: cmake -B build
- name: Build
run: cmake --build build -j=2
# m1 machines have 3 CPU
# Ref: https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners
run: cmake --build build -j=3
- name: Test
run: ctest --output-on-failure --test-dir build
13 changes: 9 additions & 4 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ubuntu 24.04 CI
name: Ubuntu

on:
pull_request:
Expand All @@ -21,21 +21,26 @@ concurrency:
cancel-in-progress: true

jobs:
ubuntu-build:
runs-on: ubuntu-24.04
build:
strategy:
matrix:
runs-on: [ubuntu-24.04]
shared: [ON, OFF]
cxx: [g++-14]
runs-on: ${{matrix.runs-on}}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{github.job}}-${{matrix.os}}-{{matrix.shared}}
- name: Setup Ninja
run: sudo apt-get install ninja-build
- name: Prepare
run: cmake -DBUILD_SHARED_LIBS=${{matrix.shared}} -G Ninja -B build
env:
CXX: ${{matrix.cxx}}
- name: Build
run: cmake --build build -j=2
run: cmake --build build -j=4
- name: Test
run: ctest --output-on-failure --test-dir build
15 changes: 11 additions & 4 deletions .github/workflows/visual-studio.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: VS17 CI
name: Windows

on:
pull_request:
Expand All @@ -21,9 +21,8 @@ concurrency:
cancel-in-progress: true

jobs:
ci:
name: windows-vs17
runs-on: windows-latest
build:
runs-on: windows-2025
strategy:
fail-fast: false
matrix:
Expand All @@ -32,6 +31,14 @@ jobs:
- {gen: Visual Studio 17 2022, arch: x64, config: Debug}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{github.job}}-${{matrix.os}}-${{matrix.config}}
- name: Install Dependencies
run: |
choco install nasm
echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Configure
run: |
cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -B build
Expand Down
3 changes: 3 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ cc_library(
hdrs = glob(["include/*.h"]),
includes = ["include"],
visibility = ["//visibility:public"],
deps = [
"@ssl"
]
)
43 changes: 28 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
cmake_minimum_required(VERSION 3.28)
project(ncrypto)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
include(CTest)
include(GNUInstallDirs)
include(FetchContent)
include(cmake/ncrypto-flags.cmake)

if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()

option(NCRYPTO_DEVELOPMENT_CHECKS "Enable development checks" OFF)

include(GNUInstallDirs)
include(FetchContent)
include(cmake/CPM.cmake)

FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
CPMAddPackage(
NAME boringssl
VERSION 0.20250114.0
GITHUB_REPOSITORY google/boringssl
GIT_TAG 0.20250114.0
OPTIONS "BUILD_SHARED_LIBS OFF" "BUILD_TESTING OFF"
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

add_subdirectory(src)
enable_testing()
add_subdirectory(tests)
add_library(ncrypto::ncrypto ALIAS ncrypto)

include_directories(${boringssl_SOURCE_DIR}/include)

if (NCRYPTO_TESTING)
CPMAddPackage(
NAME GTest
GITHUB_REPOSITORY google/googletest
VERSION 1.15.2
OPTIONS "BUILD_GMOCK OFF" "INSTALL_GTEST OFF"
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
enable_testing()
add_subdirectory(tests)
endif()

install(
FILES include/ncrypto.h
Expand Down
11 changes: 11 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
workspace(name = "ncrypto")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "ssl",
sha256 = "76962c003a298f405d1a5d273a74a94f58b69f65d64b8574a82d4c21c5e407be",
strip_prefix = "google-boringssl-6abe184",
type = "tgz",
urls = ["https://github.com/google/boringssl/tarball/6abe18402eb2a5e9b00158c6459646a948c53060"],
)
Loading