Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
gershnik committed Mar 8, 2022
0 parents commit 0445206
Show file tree
Hide file tree
Showing 43 changed files with 24,495 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG GCC_VERSION=11.2
FROM gcc:${GCC_VERSION}

RUN apt-get update
#RUN apt-get install -y build-essential

RUN apt-get install -y ninja-build
#RUN apt-get install -y curl
#RUN DEBIAN_FRONTEND=noninteractive apt-get install -y cmake

# RUN apt-get remove --purge cmake
# RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.21.5/cmake-3.21.5.tar.gz
# RUN tar -zxf cmake-3.21.5.tar.gz
# RUN cd cmake-3.21.5 && ./bootstrap -- -DCMAKE_USE_OPENSSL=OFF && make install

ARG CMAKE_VERSION=3.21.5
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh \
-q -O /tmp/cmake-install.sh \
&& chmod u+x /tmp/cmake-install.sh \
&& mkdir /usr/bin/cmake \
&& /tmp/cmake-install.sh --skip-license --prefix=/usr/bin/cmake \
&& rm /tmp/cmake-install.sh

RUN apt-get install -y git
RUN DEBIAN_FRONTEND=noninteractive TZ=America/Los_Angeles apt-get install -y gdb

ENV PATH="/usr/bin/cmake/bin:${PATH}"

CMD [ "/bin/bash" ]
38 changes: 38 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.163.0/containers/docker-existing-dockerfile
{
"name": "Linux",

// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",

// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "Dockerfile",

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": null
},

"remoteEnv": {
"VSCODE_OUT_DIR": "linux"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": ["ms-vscode.cmake-tools", "ms-vscode.cpptools"],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line to run commands after the container is created - for example installing curl.
// "postCreateCommand": "apt-get update && apt-get install -y curl",

// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],

// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
}
54 changes: 54 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish

on:
push:
tags:
- 'v*'

jobs:
main:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Amalgamate
shell: bash
working-directory: ${{github.workspace}}/tools
run: |
python3 amalgamate.py -d $GITHUB_WORKSPACE/inc/argum template.txt $GITHUB_WORKSPACE/out/argum.h
python3 amalgamate.py -d $GITHUB_WORKSPACE/inc/argum module-template.txt $GITHUB_WORKSPACE/out/argum-module.ixx
- name: Release
uses: actions/create-release@v1
id: create_release
with:
draft: true
prerelease: false
release_name: ${{ github.ref }}
tag_name: ${{ github.ref }}
body: ...edit me...
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Upload amalgamated header
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{github.workspace}}/out/argum.h
asset_name: argum.h
asset_content_type: text/plain

- name: Upload amalgamated module
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{github.workspace}}/out/argum-module.ixx
asset_name: argum-module.ixx
asset_content_type: text/plain
70 changes: 70 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Test

on:
push:
paths-ignore:
- 'README.md'
- '.gitignore'
- 'LICENSE'
- 'doc/**'

env:
BUILD_TYPE: Release
NDK_VER: 23.1.7779620
NDK_ARCH: x86_64
NDK_API: 29
GCC_VER: 11

jobs:
desktop:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-2022]

steps:
- uses: actions/checkout@v2

- name: Setup dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get install -y g++-$GCC_VER gcc-$GCC_VER
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VER 100 \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-$GCC_VER \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-$GCC_VER \
--slave /usr/bin/gcov gcov /usr/bin/gcov-$GCC_VER
sudo update-alternatives \
--install /usr/bin/g++ g++ /usr/bin/g++-$GCC_VER 100
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build

- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DARGUM_TEST=1

- name: Build and Test
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --build . --config $BUILD_TYPE --target run-test

android:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{env.NDK_API}}
arch: ${{env.NDK_ARCH}}
target: google_apis
ndk: ${{env.NDK_VER}}
script: |
mkdir -p ${{github.workspace}}/build
cmake -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE -DARGUM_TEST=1 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=$ANDROID_SDK_ROOT/ndk/$NDK_VER/build/cmake/android.toolchain.cmake -DANDROID_ABI:STRING=$NDK_ARCH -DANDROID_PLATFORM:STRING=$NDK_API -DANDROID_STL:STRING=c++_static
cmake --build $GITHUB_WORKSPACE/build --config $BUILD_TYPE --target run-test
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store

out/
.vs/

.vscode/launch.json
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cmake.configureOnOpen": true,
"cmake.configureArgs": ["-DARGUM_TEST=1"],
"cmake.buildDirectory": "${workspaceFolder}/out/vscode/${buildKit}",
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"C_Cpp.intelliSenseEngine": "Default",
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.codeFolding": "Enabled",
"C_Cpp.autoAddFileAssociations": false,
"editor.showFoldingControls": "always",
"editor.folding": true,
"editor.foldingStrategy": "auto",
}
45 changes: 45 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2022 Eugene Gershnik
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file or at
# https://github.com/gershnik/argum/blob/master/LICENSE
#
cmake_minimum_required(VERSION "3.20")

project(argum)

add_library(argum INTERFACE)

target_include_directories(argum
INTERFACE
inc
)

target_compile_definitions(argum
INTERFACE
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
)

target_sources(argum
PRIVATE
inc/argum/common.h
inc/argum/char-constants.h
inc/argum/messages.h
inc/argum/formatting.h
inc/argum/partitioner.h
inc/argum/flat-map.h
inc/argum/simple-file.h
inc/argum/data.h
inc/argum/command-line.h
inc/argum/tokenizer.h
inc/argum/parser.h
inc/argum/validators.h
inc/argum/help-formatter.h

)

if (ARGUM_TEST)

include(test/test.cmake)

endif()
27 changes: 27 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DARGUM_TEST=1",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DARGUM_TEST=1",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
}
]
}
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2022, Eugene Gershnik
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit 0445206

Please sign in to comment.