Git Product home page Git Product logo

poac's Introduction

Poac Logo

Important

The information here may vary depending on the version you are using. Please refer to the corresponding README.md by visiting the Git tag corresponding to your version, e.g., https://github.com/poac-dev/poac/blob/0.9.3/README.md. Running poac version will provide you with the current version.

Description

Important

Poac is still under development and may contain a bunch of bugs.

Poac (pronounced as /pəʊək/) is a package manager and build system for C++ users, inspired by Cargo for Rust. Poac is designed as a structure-oriented build system, which means that as long as you follow Poac's designated project structure, you almost do not need configurations, much less a language to build, unlike CMake. If you do not like writing a bunch of configurations to build your project, Poac might be best suited. Currently, the supported project structure can be known by looking at this repository since Poac can build itself.

Please visit poac.dev and Poac Docs for more details.

Demo

By using Poac, you can create a C++ project, build sources, and execute an application:

demo

Hello World

You can get started with just a few commands as the demo shows. Let's create a new Poac project:

you:~$ poac new hello_world
     Created binary (application) `hello_world` package

Now, you can use the poac run command to run your application:

you:~$ cd hello_world
you:~/hello_world$ poac run
 Compiling src/main.cc
   Linking hello_world
  Finished debug target(s) in 0.45386s
   Running poac-out/debug/hello_world
Hello, world!

Supported Operating Systems

Linux macOS
Linux macOS

Installation

3rd Party Installation (recommended)

Since packages through these providers may not be maintained by Poac owners, install them at your own risk.

Packaging status

It is important to verify the package name and copy it accurately to prevent typosquatting attacks. You can check the correct name by following the link in Packaging status (Repology).

Homebrew (macOS & Linux)

brew install poac

AUR (Arch Linux)

Poac is available in the AUR thanks to the poac package.

It can be installed with the AUR helper of your choice.

paru -S poac

Build from source

If your environment is not included in the released packages, you have to build Poac from the source. You will require the following compilers, commands, and libraries:

Compilers (that support C++20)

  • GCC: 12 or later
  • Clang: 15 or later
  • Apple Clang: provided by macOS Monterey (12) or later

Commands

  • GNU Make
  • Git
  • pkg-config
  • find
  • grep
  • mkdir
  • rm

Libraries

  • fmt: >=8.1.1 && <11
    • libfmt-dev on APT
    • fmt on Homebrew
  • libgit2: >=1.1.0 && <2
    • libgit2-dev on APT
    • libgit2 on Homebrew
  • libcurl: >=7.79.1 && <9
    • libcurl4-openssl-dev on APT
    • curl on Homebrew
  • nlohmann_json: >=3.10.5 && <4
    • nlohmann-json3-dev on APT
    • nlohmann-json on Homebrew
  • oneTBB: >=2021.5.0 && <2022
    • libtbb-dev on APT
    • tbb on Homebrew

When running Make, the following libraries will be installed automatically.

Once you have all the necessary requirements in place, you can build Poac by the following commands:

git clone https://github.com/poac-dev/poac.git
cd poac
make RELEASE=1 install

Runtime Requirements

  • C++ compiler
  • GNU Make
  • pkg-config
  • mkdir
  • printf
  • cpplint (for poac lint)
  • clang-format (for poac fmt)
  • clang-tidy (for poac tidy)

Usage

Start a new project with Poac

The poac new command lets you start a new Poac project:

you:~$ poac new hello_world
     Created binary (application) `hello_world` package

Tip

If you want to integrate your existing project with Poac, use the init command:

you:~/your-pj$ poac init
     Created binary (application) `your-pj` package

This command just creates a poac.toml file not to break your project.

Build the project

In most cases, you want to execute the generated binary as well as build the project.

you:~/hello_world$ poac run
 Compiling src/main.cc
   Linking hello_world
  Finished debug target(s) in 0.45386s
   Running poac-out/debug/hello_world
Hello, world!

If you just want to build it, run the build command:

you:~/hello_world$ poac build
  Finished debug target(s) in 0.00866317s

Poac uses a cache since we executed the command with no changes.

Tip

To use a different compiler, you can export a CXX environmental variable:

export CXX=g++-13

Install dependencies

Like Cargo does, Poac installs dependencies at build time. Poac currently supports Git and system dependencies. You can use the poac add command to add dependencies to your project.

The poac add command accepts the following arguments:

poac add <package names ....> --<options>

Options:

  • --sys: Marks the packages as system dependency (requires the --version argument)
  • --version: Specify dependency version. Only used with system dependencies
  • --rev: Specify revision for git dependencies
  • --tag: Specify tag for git dependencies
  • --branch: Specify branch for git dependencies

Example

poac add libgit2 --sys --version "1.1.0"
poac add "ToruNiina/toml11" --rev "846abd9a49082fe51440aa07005c360f13a67bbf"

If tag, branch, or rev is unspecified for git dependencies, Poac will use the latest revision of the default branch. System dependency names must be acceptable by pkg-config. The version requirement syntax is specified in src/VersionReq.hpp.

After adding dependencies, executing the build command will install the package and its dependencies.

you:~/hello_world$ poac build
Downloaded ToruNiina/toml11 846abd9a49082fe51440aa07005c360f13a67bbf
 Compiling src/main.cc
   Linking hello_world
  Finished debug target(s) in 0.70s

Warning

Poac currently supports building a project with header-only dependencies. Building with build-required dependencies will be soon supported.

Unit tests

You can write unit tests in any source files within the src directory. Create a new file like:

src/Lib.cc

int add(int a, int b) {
  return a + b;
}

#ifdef POAC_TEST

#  include <cassert>

int main() {
  assert(add(1, 2) == 3);  // ok
  assert(add(1, 2) == 4);  // fail
}

#endif

Now, with the test command, you can run tests defined within POAC_TEST:

you:~/hello_world$ poac test
 Compiling src/Lib.cc
   Linking tests/test_Lib
   Testing Lib
Assertion failed: (add(1, 2) == 4), function main, file Lib.cc, line 13.
make: *** [test] Abort trap: 6

Unit tests with the POAC_TEST macro are useful when testing private functions. Integration testing with the tests directory has not yet been implemented.

Run linter

Linting source code is essential to protect its quality. Poac supports linting your project by the lint command:

you:~/hello_world$ poac lint
   Linting hello_world
src/main.cc:0:  No copyright message found.  You should have a line: "Copyright [year] <Copyright Owner>"  [legal/copyright] [5]
Done processing src/main.cc
Total errors found: 1
Error: `cpplint` exited with status 1

Tip

If you do not have cpplint, install it with the following command:

pip install cpplint

The lint command works without configurations, and Poac would automatically opt out of unwanted lints by adjusting to each project. To customize the lint settings, try adding the [lint.cpplint] key in your poac.toml like this or creating a CPPLINT.cfg file in the repository root.

Run formatter

Poac also supports formatting your source code with clang-format. Ensure having installed clang-format before running this command.

you:~/hello_world$ poac fmt
  Formatting hello_world

Note

This command automatically detects what files we need to format to avoid getting bothered by commands like:

$ # We need to avoid the `build` dir and such dirs ...
$ clang-format ./src/*.cpp -i
$ clang-format ./include/**/*.hpp -i
$ clang-format ./tests/**/*.cpp -i
$ ...

To customize the format settings, try creating a .clang-format file to the repository root.

Run clang-tidy

Poac also supports running clang-tidy on your source code. Ensure having installed clang-tidy before running this command.

you:~/hello_world$ poac tidy
  Running clang-tidy

You can customize the tidy settings by creating a .clang-tidy file to the repository root.

Why Poac?

C++ is often considered a complex language and unconsciously avoided by many. The absence of a definitive package manager and the unfamiliar syntax of build systems like CMake make it seem difficult to set up a C++ environment, leaving people hesitant.

To simplify the process and allow users to develop applications and libraries without worrying about CMake, I created a package manager and build system with an intuitive interface, similar to Cargo. This allows developers to focus on learning C++ without any hindrances. Additionally, I aim to integrate with other build systems and package managers, providing a seamless transition between development environments.

Naming Background

Poac is originated from cpp but designed to prioritize ease of typing and reduce strain on one hand as it will be frequently used as a command. Its name is ergonomically optimized to prevent the development of tenosynovitis.

ergo

Despite C++ often being overlooked for product development, I believe that Poac can help to promote it as a fun language. Amemiya and Mizutani argue that the sound of /p/ is associated with a bright and soft impression among Japanese consonants (157)1. In the same way, I believe that Poac's name can convey a similarly positive impression.

Contributing

Before submitting your PR

Please make sure to follow these steps:

Run linter (cpplint)

poac lint --exclude srcOld --exclude testsOld

Run formatter (clang-format)

poac fmt

Run tests

poac test  # or make test

Run clang-tidy

poac tidy  # or make tidy

This project exists thanks to all the people who contribute.

License

Poac is licensed under the terms of the Apache License version 2.0.

Please see LICENSE for details.

Third-party software

Footnotes

  1. Amemiya, T., & Mizutani, S. (2006). On the Basic Affective Dimensions of Japanese Onomatopoeia and the Basic Level of Japanese Phonesthemes. 関西大学社会学部紀要, 37(2), 139–166. https://hdl.handle.net/10112/12311

poac's People

Contributors

0xflotus avatar 4ge32 avatar biswa96 avatar dependabot[bot] avatar erikwdev avatar fossabot avatar hsjoihs avatar jeromeschmied avatar ken-matsui avatar mattn avatar potsbo avatar sunpodder avatar takagiy avatar thynkon avatar wx257osn2 avatar yaito3014 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poac's Issues

ドキュメントのビルド要件が誤っている; boost

状況

ドキュメントでは boost-1.48 以降でビルド可能な事になっている。

しかし、実際にビルドを試みると Boost.Beast ライブラリーを使用しているため、 boost-1.66 以降でなければビルドできない。

想定される対処

  • ドキュメント・バグとしてビルド要件の表記を boost-1.66 以降へ修正

その他のオプション

  • Boost.Beast を使用しないビルドモードを用意し cmake 引数等で設定可能にする

一般性の高いクロスプラットフォーム対応; 例えば Ubuntu の標準的なシステムパッケージ

状況

  • 多くの一般C++erが試しやすい環境想定として ubuntu 現行版や WSL の相当環境でソースコードの改変無しにビルド可能だとユーザーも広がると思う。しかし、現時点ではおそらく OSX の特定パッケージマネージャー等による環境でのビルドしか想定されていないと思われる。

例として ubuntu システムパッケージによるビルド環境での具体的な問題

  • yaml-dev システムパッケージで導入される YAML のヘッダーは /usr/include/yaml.h のように導入される。
    • 現状 poac ソースコードでは複数箇所で YAML のヘッダーの所在に独自のプリフィックス(サブ・ディレクトリー) yaml-cpp/ を想定した #include が定義されているため、この部分のソースコードの改変が必要。
    • この問題への提案としては、 yaml/libyaml の配置 から一般的にはサブディレクトリーなしで配置されている想定で #include を書き、必要に応じて #ifdef 等で yaml-cpp/ を与えるのがよいのではないか、と思う。(私は OSX 開発環境に詳しくないので __APPLE__ とすべきか、あるいは特定パッケージマネージャーを判定する方法があるか、または cmake レベルでヘッダーの所在を探索して変数へ入れるべきかまではわかりません。)

せっかくなので遊んでみよう!と思ったのですが、イケメンC++erだけでなく、一般C++erも手軽にビルドできないとちょっと厳しいかなーと思います。あるいはバイナリーパッケージを提供してしまうというのも手だけど…。

AppVeyor doesn't build the binary in WSL

Currently, README says that the result of AppVeyor building is build status on WSL.
However, the result is build status using MSVC, not on WSL.
The description should be changed.

poac/option/* -> poac/subcmd

helpとversionをサブコマンドとしても使用できるようにする.
optionとしても使用可能に.

poac help
poac --help
poac -h

build failed on cygwin

(サポート予定があるかどうかわからないですが) cygwin 環境でのビルドができない状態です。

ログ : https://gist.github.com/fd00/f589f0c42f3677117d9fc3e8f43474e2

  • resolve 以外のエラーは -D_GNU_SOURCE で解決します。
  • resolve は引数 port の型がきちんと解釈できていないように見えるのですが cygwin gcc 特有のものかはわからないです...。

環境

$ /usr/bin/c++ -v
Using built-in specs.
COLLECT_GCC=/usr/bin/c++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /cygdrive/i/szsz/tmpp/gcc/gcc-7.4.0-1.x86_64/src/gcc-7.4.0/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-7.4.0-1.x86_64/src/gcc-7.4.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libgomp --enable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
gcc version 7.4.0 (GCC) 

Correspond to cmake build using poac build

Write to buildsystem.hpp

bool _cmake_build(
            const std::string& pkgname,
            const std::map<std::string, std::string>& cmake_envs )
    {
        namespace fs     = boost::filesystem;
        namespace except = core::exception;

        const fs::path filepath = io::file::path::poac_cache_dir / pkgname;

        util::command cmd("cd " + filepath.string());
        cmd &= "mkdir build";
        cmd &= "cd build";
        util::command cmake_cmd("cmake ..");
        for (const auto& [key, val] : cmake_envs)
            cmake_cmd.env(key, val);
        cmd &= cmake_cmd.stderr_to_stdout();
        cmd &= util::command("make -j4").stderr_to_stdout();
        cmd &= util::command("make install").env("DESTDIR", "./").stderr_to_stdout();

        if (auto result = cmd.exec()) {
            const std::string filepath_tmp = filepath.string() + "_tmp";
            fs::rename(filepath, filepath_tmp);
            fs::create_directories(filepath);

            const fs::path build_after_dir(fs::path(filepath_tmp) / "build" / "usr" / "local");

            // Write to cache.yml and recurcive copy
            for (const auto& s : std::vector<std::string>({ "bin", "include", "lib" }))
                if (io::file::path::validate_dir(build_after_dir / s))
                    io::file::path::recursive_copy(build_after_dir / s, fs::path(filepath) / s);
            fs::remove_all(filepath_tmp);

            return EXIT_SUCCESS;
        }
        else {
            /* error */
            // datetime-error.log
            return EXIT_FAILURE;
        }
    }

[install] Check cpp_version in poac.yml

./poac.ymlのcpp_versionに書かれたバージョンより古いバージョンのパッケージをinstallする時に,警告を表示する.
GET /api/packages/:name/:version/cpp_version

セルフホストできない

パッケージリポジトリpoac の依存パッケージが存在しないため, poac に対して poac install を行うとコケる.

不足パッケージ

  • boost/property_tree
  • boost/filesystem
  • boost/range
  • boost/algorithm
  • boost/foreach
  • boost/dynamic_bitset
  • boost/beast
  • cpp-shell-cmd

[build] enable_gnu

template<typename Conf>
void enable_gnu(Conf& conf) {
    conf.version_prefix = "-std=gnu++";
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.