Merge pull request #1 from RandyMcMillan/1690935039/f5fa34d/770cc8b-pedro-vicente/master

CMakeList.txt: make install
This commit is contained in:
Pedro Vicente 2023-08-01 20:44:31 -04:00 committed by GitHub
commit 12eb6de8ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 352 additions and 24 deletions

View File

@ -1,17 +0,0 @@
name: C/C++ CI
on:
push:
branches: [ "master", "**" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: make
run: make

50
.github/workflows/macos-matrix.yml vendored Normal file
View File

@ -0,0 +1,50 @@
name: macos-matrix
# Controls when the action will run.
on:
pull_request:
branches:
- '*'
- '*/*'
- '**'
- 'master'
- 'main'
push:
branches:
- '*'
- '*/*'
- '**'
- 'master'
- 'main'
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
macos-build_and_test:
strategy:
matrix:
os: [macos-latest, macos-11, macos-12]
runs-on: ${{ matrix.os }}
steps:
- uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- name: printenv
run: |
brew install libtool autoconf automake
printenv
- name: make
run: |
make
- name: sudo make install
run: |
sudo make install
- name: man nostril
run: |
man nostril
- name: sudo -su runner nostril
run: |
#pipe handles non-zero return from nostril default help
sudo -su runner nostril | echo "${PIPESTATUS[0]}"

47
.github/workflows/macos-pre-release.yml vendored Normal file
View File

@ -0,0 +1,47 @@
name: macos-pre-release
# Controls when the action will run.
on:
push:
branches:
- 'master'
- '**pre-release**'
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
pre-release:
strategy:
matrix:
os: [macos-11, macos-12, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- name: "printenv"
run: |
brew install libtool autoconf automake
printenv
- name: "Build pre-release"
run: |
make
mv nostril nostril-$RUNNER_OS-$RUNNER_ARCH
shasum -a 256 nostril-$RUNNER_OS-$RUNNER_ARCH > nostril-$RUNNER_OS-$RUNNER_ARCH.sha256.txt
mv nostril-query nostril-query-$RUNNER_OS-$RUNNER_ARCH
shasum -a 256 nostril-query-$RUNNER_OS-$RUNNER_ARCH > nostril-query-$RUNNER_OS-$RUNNER_ARCH.sha256.txt
ls -a
- name: Save state
run: echo "{name}={value}" >> $GITHUB_STATE
- name: Set output
run: echo "{name}={value}" >> $GITHUB_OUTPUT
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ matrix.os }}
prerelease: true
title: "Development Build"
files: |
nostril-*

47
.github/workflows/macos-release.yml vendored Normal file
View File

@ -0,0 +1,47 @@
name: macos-release
# Controls when the action will run.
on:
push:
tags:
- "v*"
- "v*.*.*-rc**"
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
release:
strategy:
matrix:
os: [macos-11, macos-12, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- name: "printenv"
run: |
brew install libtool autoconf automake
printenv
- name: "Build release"
run: |
make
mv nostril nostril-$RUNNER_OS-$RUNNER_ARCH
shasum -a 256 nostril-$RUNNER_OS-$RUNNER_ARCH > nostril-$RUNNER_OS-$RUNNER_ARCH.sha256.txt
mv nostril-query nostril-query-$RUNNER_OS-$RUNNER_ARCH
shasum -a 256 nostril-query-$RUNNER_OS-$RUNNER_ARCH > nostril-query-$RUNNER_OS-$RUNNER_ARCH.sha256.txt
ls -a
- name: Save state
run: echo "{name}={value}" >> $GITHUB_STATE
- name: Set output
run: echo "{name}={value}" >> $GITHUB_OUTPUT
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ matrix.os }}
prerelease: false
title: "Release Build"
files: |
nostril-*

59
.github/workflows/ubuntu-matrix.yml vendored Normal file
View File

@ -0,0 +1,59 @@
name: ubuntu-matrix
# Controls when the action will run.
on:
pull_request:
branches:
- '*'
- '*/*'
- '**'
- 'master'
- 'main'
push:
branches:
- '*'
- '*/*'
- '**'
- 'master'
- 'main'
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
ubuntu-build_and_test:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: styfle/cancel-workflow-action@0.11.0
if: ${{ !env.ACT }}
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: '0'
submodules: 'recursive'
set-safe-directory: 'true'
- name: printenv && sudo apt update && sudo apt install scdoc -y
run: |
printenv && sudo apt update && sudo apt install scdoc -y
- name: rm -rf deps
run: |
rm -rf deps
- name: make
run: |
mkdir -p /usr/local/share/man/man1/nostril.1
make
- name: sudo make install
run: |
sudo make install
- name: man nostril
run: |
man nostril
- name: sudo ./nostril
run: |
#pipe handles non-zero return from nostril default help
file nostril
sudo ./nostril >/dev/null | echo "${PIPESTATUS[0]}"

View File

@ -0,0 +1,53 @@
name: ubuntu-pre-release
# Controls when the action will run.
on:
push:
branches:
- 'master'
- '**pre-release**'
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
pre-release:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: styfle/cancel-workflow-action@0.11.0
if: ${{ !env.ACT }}
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: '0'
submodules: 'recursive'
set-safe-directory: 'true'
- name: printenv && sudo apt update && sudo apt install scdoc -y
run: |
printenv && sudo apt update && sudo apt install scdoc -y
- name: "Build pre-release"
run: |
mkdir -p /usr/local/share/man/man1/nostril.1
make nostril
mv nostril nostril-$RUNNER_OS-$RUNNER_ARCH
shasum -a 256 nostril-$RUNNER_OS-$RUNNER_ARCH > nostril-$RUNNER_OS-$RUNNER_ARCH.sha256.txt
mv nostril-query nostril-query-$RUNNER_OS-$RUNNER_ARCH
shasum -a 256 nostril-query-$RUNNER_OS-$RUNNER_ARCH > nostril-query-$RUNNER_OS-$RUNNER_ARCH.sha256.txt
ls -a
- name: Save state
run: echo "{name}={value}" >> $GITHUB_STATE
- name: Set output
run: echo "{name}={value}" >> $GITHUB_OUTPUT
- uses: "marvinpinto/action-automatic-releases@latest"
if: ${{ !env.ACT }}
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ matrix.os }}
prerelease: true
title: "Development Build"
files: |
nostril-*

53
.github/workflows/ubuntu-release.yml vendored Normal file
View File

@ -0,0 +1,53 @@
name: ubuntu-release
# Controls when the action will run.
on:
push:
tags:
- "v*"
- "v*.*.*-rc**"
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
release:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: styfle/cancel-workflow-action@0.11.0
if: ${{ !env.ACT }}
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: '0'
submodules: 'recursive'
set-safe-directory: 'true'
- name: printenv && sudo apt update && sudo apt install scdoc -y
run: |
printenv && sudo apt update && sudo apt install scdoc -y
- name: "Build release"
run: |
mkdir -p /usr/local/share/man/man1/nostril.1
make nostril
mv nostril nostril-$RUNNER_OS-$RUNNER_ARCH
shasum -a 256 nostril-$RUNNER_OS-$RUNNER_ARCH > nostril-$RUNNER_OS-$RUNNER_ARCH.sha256.txt
mv nostril-query nostril-query-$RUNNER_OS-$RUNNER_ARCH
shasum -a 256 nostril-query-$RUNNER_OS-$RUNNER_ARCH > nostril-query-$RUNNER_OS-$RUNNER_ARCH.sha256.txt
ls -a
- name: Save state
run: echo "{name}={value}" >> $GITHUB_STATE
- name: Set output
run: echo "{name}={value}" >> $GITHUB_OUTPUT
- uses: "marvinpinto/action-automatic-releases@latest"
if: ${{ !env.ACT }}
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ matrix.os }}
prerelease: false
title: "Release Build"
files: |
nostril-*

3
.gitignore vendored
View File

@ -21,3 +21,6 @@ scripts/nostr-req
scripts/subnote
/dist
/version
.DS_Store
deps/.DS_Store

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "deps/secp256k1"]
path = deps/secp256k1
url = https://github.com/bitcoin-core/secp256k1
ignore = dirty
branch = master
depth = shallow

View File

@ -4,6 +4,11 @@ else()
cmake_minimum_required(VERSION 3.15)
endif()
set(CMAKE_BUILD_TYPE Debug)
option(BUILD_RELEASE "BUILD_RELEASE" ON)
if(BUILD_RELEASE)
set(CMAKE_BUILD_TYPE Release)
endif()
project (nostril C)
include_directories(${CMAKE_SOURCE_DIR}/ext/secp256k1/include)
@ -71,8 +76,18 @@ target_link_libraries (nostril ${lib_dep})
add_custom_command(
TARGET configurator
POST_BUILD
COMMAND configurator > config.h
COMMAND configurator > config.h
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/config.h" ${CMAKE_SOURCE_DIR}
COMMENT "generating config.h"
)
#//////////////////////////
# Install
#//////////////////////////
install(TARGETS nostril
CONFIGURATIONS Debug
RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin)
install(TARGETS nostril
CONFIGURATIONS Release
RUNTIME DESTINATION /usr/local/bin)

View File

@ -7,7 +7,19 @@ ARS = libsecp256k1.a
SUBMODULES = deps/secp256k1
all: nostril docs
default:
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?##/ {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
help:## print verbose help
@echo ''
@echo 'Usage: make [TARGET] [EXTRA_ARGUMENTS]'
@echo ''
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ': ' | sed -e 's/^/ /' ## verbose help ideas
@sed -n 's/^## //p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
@echo ""
@echo "Useful Commands:"
@echo ""
all: nostril docs## nostril docs
docs: doc/nostril.1
@ -34,6 +46,8 @@ deps/secp256k1/include/secp256k1.h: deps/secp256k1/.git
deps/secp256k1/configure: deps/secp256k1/.git
cd deps/secp256k1; \
automake --add-missing; \
autoreconf; \
./autogen.sh
deps/secp256k1/config.log: deps/secp256k1/configure
@ -55,9 +69,10 @@ nostril: $(HEADERS) $(OBJS) $(ARS)
$(CC) $(CFLAGS) $(OBJS) $(ARS) -o $@
install: all
install -Dm644 doc/nostril.1 $(PREFIX)/share/man/man1/nostril.1
install -Dm755 nostril $(PREFIX)/bin/nostril
install -Dm755 nostril-query $(PREFIX)/bin/nostril-query
mkdir -p $(PREFIX)/bin
install -m644 doc/nostril.1 $(PREFIX)/share/man/man1/nostril.1
install -m755 nostril $(PREFIX)/bin/nostril
install -m755 nostril-query $(PREFIX)/bin/nostril-query
config.h: configurator
./configurator > $@
@ -72,4 +87,4 @@ clean:
tags: fake
ctags *.c *.h
.PHONY: fake
.PHONY: fake nostril

View File

@ -97,7 +97,7 @@ void usage()
printf(" -e <event_id> shorthand for --tag e <event_id>\n");
printf(" -p <pubkey> shorthand for --tag p <pubkey>\n");
printf(" -t <hashtag> shorthand for --tag t <hashtag>\n");
exit(1);
exit(0);
}