Skip to content

Commit 1435386

Browse files
author
Richard Pospesel
committed
build: added homebrew formula package format to build
1 parent 6f4db2e commit 1435386

File tree

7 files changed

+72
-2
lines changed

7 files changed

+72
-2
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
run: |
125125
mkdir -p build/debug
126126
cd build/debug
127-
cmake ../.. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../dist/debug -DBUILD_PYTHON_BINDINGS=ON -DBUILD_JAVA_BINDINGS=ON -DBUILD_EXAMPLES=ON
127+
cmake ../.. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../dist/debug -DBUILD_PYTHON_BINDINGS=ON -DBUILD_JAVA_BINDINGS=ON -DBUILD_EXAMPLES=ON -DBUILD_HOMEBREW_FORMULA=ON
128128
make
129129
make install
130130
- name: Archive Debug
@@ -140,7 +140,7 @@ jobs:
140140
run: |
141141
mkdir -p build/release
142142
cd build/release
143-
cmake ../.. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../dist/release -DBUILD_PYTHON_BINDINGS=ON -DBUILD_JAVA_BINDINGS=ON -DBUILD_EXAMPLES=ON
143+
cmake ../.. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../dist/release -DBUILD_PYTHON_BINDINGS=ON -DBUILD_JAVA_BINDINGS=ON -DBUILD_EXAMPLES=ON -DBUILD_HOMEBREW_FORMULA=ON
144144
make
145145
make install
146146
- name: Archive Release

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ option(BUILD_EXAMPLES "Build example targets" OFF)
7676

7777
# Packages options
7878
option(BUILD_DEBIAN_SOURCE_PACKAGE "Build debian cgosling source package" OFF)
79+
option(BUILD_HOMEBREW_FORMULA "Build homebrew flask formula" OFF)
7980

8081
# Documentation options
8182
option(BUILD_PAGES "Build webpages" OFF)

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ The following additional dependencies are required for this configure option:
191191

192192
See [source/packages/debian-source/README.md](source/packages/debian-source/README.md) for additional information.
193193

194+
### BUILD_HOMEBREW_FORMULA
195+
196+
```shell
197+
cmake -DBUILD_HOMEBREW_FORMULA=ON
198+
```
199+
200+
Builds a homebrew flask formula which installs libcgosling static libs, shared libs, and developemnt headers.
201+
202+
See [source/packages/homebrew-formula/README.md](source/packages/homebrew-formula/README.md) for more additional information.
203+
194204
### BUILD_PAGES
195205

196206
```shell

source/packages/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
add_subdirectory(debian-source)
2+
add_subdirectory(homebrew-formula)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if (BUILD_HOMEBREW_FORMULA)
2+
# generate homebrew formula .rb file
3+
set(LIBCGOSLING_RB_IN ${CMAKE_CURRENT_SOURCE_DIR}/libcgosling.rb.in)
4+
set(LIBCGOSLING_RB_OUT ${CMAKE_CURRENT_BINARY_DIR}/libcgosling.rb)
5+
configure_file(${LIBCGOSLING_RB_IN} ${LIBCGOSLING_RB_OUT} @ONLY)
6+
7+
install(FILES ${LIBCGOSLING_RB_OUT}
8+
DESTINATION ${CMAKE_INSTALL_DATADIR}/gosling/packages/homebrew-formula)
9+
endif()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# homebrew-formula
2+
3+
This buillds a homebrew formula for the cgosling crate which can be used to install the libcgosling shared libs, static libs, and development headers.
4+
5+
## Building flask
6+
7+
```bash
8+
brew install --build-from-source --formula /path/to/libcgosling.rb
9+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
class Libcgosling < Formula
2+
desc ""
3+
homepage "https://gosling.technology"
4+
url "https://github.com/blueprint-freespeech/gosling.git", tag: "cgosling-v@CGOSLING_VERSION@"
5+
license "BSD-3-Clause"
6+
7+
depends_on "rust" => :build
8+
depends_on "cmake" => :build
9+
depends_on "tor"
10+
11+
def install
12+
system "cmake",
13+
"-S", ".",
14+
"-B", "build",
15+
"-DCMAKE_BUILD_TYPE=Release",
16+
*std_cmake_args
17+
system "cmake", "--build", "build"
18+
system "cmake", "--install", "build"
19+
end
20+
21+
test do
22+
(testpath/"test.cpp").write <<~EOS
23+
#include <cgosling.hpp>
24+
25+
int main() {
26+
gosling_library* library = nullptr;
27+
gosling_error* error = nullptr;
28+
::gosling_library_init(&library, &error);
29+
if (library != nullptr && error == nullptr) {
30+
gosling_library_free(library);
31+
} else {
32+
return -1;
33+
}
34+
return 0;
35+
}
36+
EOS
37+
system ENV.cxx, "-std=c++17", "test.cpp", "-I#{include}", "-L#{lib}", "-lcgosling", "-o", "test"
38+
system "./test"
39+
end
40+
end

0 commit comments

Comments
 (0)