From 3fdc575f99e52478857099e0217f6c1adc4539ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20C=2E=20Fran=C3=A7a?= Date: Fri, 10 Mar 2023 10:36:20 -0300 Subject: [PATCH] zig-pkg build --- .github/workflows/ci.yml | 405 +++------------------------------------ .gitignore | 2 + LICENSE | 23 +++ README.md | 39 ++++ build.zig | 234 ++++++++++++++++++++++ build.zig.zon | 4 + 6 files changed, 332 insertions(+), 375 deletions(-) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 build.zig create mode 100644 build.zig.zon diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acda82acf1..7363a69cd0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,383 +1,38 @@ -name: asio CI +name: Zig Build -on: - push: - branches: [ master, citest-* ] +on: [push] jobs: build: strategy: fail-fast: false matrix: - build-type: ['sanity'] - runs-on: [ubuntu-20.04, ubuntu-22.04, macos-latest] - compiler: [g++-7, g++-8, g++-9, g++-10, g++-11, g++-12, clang++-10, clang++-14, g++] - cxx-std: ['c++03', 'c++11', 'c++14', 'c++17', 'c++2a', 'c++20'] - separate-compilation: ['', '--enable-separate-compilation'] - optim-level: ['-O0'] - no-deprecated: [''] - select-reactor: ['', '-DASIO_DISABLE_EPOLL', '-DASIO_DISABLE_KQUEUE'] - handler-tracking: [''] - boost: [''] - boost-url: [''] - exclude: - # New compilers don't run on ubuntu 20.04 - - runs-on: ubuntu-20.04 - compiler: g++-12 - - runs-on: ubuntu-20.04 - compiler: clang++-14 - # Older compilers don't run on ubuntu 22.04 - - runs-on: ubuntu-22.04 - compiler: g++-7 - - runs-on: ubuntu-22.04 - compiler: g++-8 - - runs-on: ubuntu-22.04 - compiler: clang++-10 - # Unversioned g++ doesn't run on ubuntu - - runs-on: ubuntu-20.04 - compiler: g++ - - runs-on: ubuntu-22.04 - compiler: g++ - # Versioned g++ and clang++ don't run on macOS - - runs-on: macos-latest - compiler: g++-7 - - runs-on: macos-latest - compiler: g++-8 - - runs-on: macos-latest - compiler: g++-9 - - runs-on: macos-latest - compiler: g++-10 - - runs-on: macos-latest - compiler: g++-11 - - runs-on: macos-latest - compiler: g++-12 - - runs-on: macos-latest - compiler: clang++-10 - - runs-on: macos-latest - compiler: clang++-14 - # Older compilers don't support newer std variants - - compiler: g++-7 - cxx-std: c++2a - - compiler: g++-7 - cxx-std: c++20 - - compiler: g++-8 - cxx-std: c++20 - - compiler: g++-9 - cxx-std: c++20 - - compiler: g++-10 - cxx-std: c++2a - - compiler: g++-11 - cxx-std: c++2a - - compiler: g++-12 - cxx-std: c++2a - - compiler: clang++-10 - cxx-std: c++20 - - compiler: clang++-14 - cxx-std: c++2a - - runs-on: macos-latest - cxx-std: c++20 - # Specifying the select reactor is OS-specific - - runs-on: ubuntu-20.04 - select-reactor: -DASIO_DISABLE_KQUEUE - - runs-on: ubuntu-22.04 - select-reactor: -DASIO_DISABLE_KQUEUE - - runs-on: macos-latest - select-reactor: -DASIO_DISABLE_EPOLL - # Trim builds that use separate compilation - - compiler: g++-7 - separate-compilation: --enable-separate-compilation - - compiler: g++-8 - separate-compilation: --enable-separate-compilation - - compiler: g++-9 - separate-compilation: --enable-separate-compilation - - compiler: g++-10 - separate-compilation: --enable-separate-compilation - - compiler: g++-11 - separate-compilation: --enable-separate-compilation - - runs-on: macos-latest - cxx-std: c++14 - separate-compilation: --enable-separate-compilation - - runs-on: macos-latest - cxx-std: c++17 - separate-compilation: --enable-separate-compilation - # Trim builds that use select reactor - - compiler: g++-7 - select-reactor: -DASIO_DISABLE_EPOLL - - compiler: g++-8 - select-reactor: -DASIO_DISABLE_EPOLL - - compiler: g++-9 - select-reactor: -DASIO_DISABLE_EPOLL - - compiler: g++-10 - select-reactor: -DASIO_DISABLE_EPOLL - - compiler: g++-11 - select-reactor: -DASIO_DISABLE_EPOLL - # C++03 builds are always explicitly included - - cxx-std: c++03 - include: - # - # Linux / g++-12 -std=c++20 -fcoroutines / -O2 / standalone - # - - build-type: full - runs-on: ubuntu-22.04 - compiler: g++-12 - cxx-std: c++20 -fcoroutines - optim-level: -O2 - # - # Linux / g++-12 -std=c++17 / -O2 / boost 1.73 - # - - build-type: full - runs-on: ubuntu-22.04 - compiler: g++-12 - cxx-std: c++17 - optim-level: -O2 - with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_73_0 - boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.73.0/source/boost_1_73_0.tar.bz2 - # - # Linux / g++-11 -std=c++14 / -O0 / standalone / separate compilation - # - - build-type: full - runs-on: ubuntu-22.04 - compiler: g++-11 - cxx-std: c++14 - separate-compilation: --enable-separate-compilation - optim-level: -O0 - # - # Linux / g++-10 / -O2 / standalone - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-10 - cxx-std: c++14 - optim-level: -O2 - # - # Linux / g++-10 / -O0 / standalone / handler tracking - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-10 - cxx-std: c++14 - optim-level: -O0 - handler-tracking: -DASIO_ENABLE_HANDLER_TRACKING - # - # Linux / g++-10 / -O0 / standalone / epoll disabled - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-10 - cxx-std: c++14 - optim-level: -O0 - select-reactor: -DASIO_DISABLE_EPOLL - # - # Linux / g++-10 / -O0 / standalone / separate compilation / handler tracking - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-10 - cxx-std: c++14 - separate-compilation: --enable-separate-compilation - optim-level: -O0 - handler-tracking: -DASIO_ENABLE_HANDLER_TRACKING - # - # Linux / g++-10 / -O0 / standalone / separate compilation / epoll disabled - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-10 - cxx-std: c++14 - separate-compilation: --enable-separate-compilation - optim-level: -O0 - select-reactor: -DASIO_DISABLE_EPOLL - # - # Linux / g++-10 / -O2 / boost 1.80 - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-10 - cxx-std: c++14 - optim-level: -O2 - with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 - boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 - # - # Linux / g++-10 / -O0 / boost 1.80 / epoll disabled - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-10 - cxx-std: c++14 - optim-level: -O0 - with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 - boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 - select-reactor: -DASIO_DISABLE_EPOLL - # - # Linux / g++-10 / -O0 / boost 1.80 / separate compilation - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-10 - cxx-std: c++14 - separate-compilation: --enable-separate-compilation - optim-level: -O0 - with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 - boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 - # - # Linux / g++-7 / -O2 / standalone - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-7 - cxx-std: c++11 - optim-level: -O2 - # - # Linux / g++-7 / -O0 / standalone / separate compilation - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-7 - cxx-std: c++11 - separate-compilation: --enable-separate-compilation - optim-level: -O0 - # - # Linux / g++-7 / -O2 / boost 1.80 - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-7 - cxx-std: c++03 - separate-compilation: --enable-separate-compilation - optim-level: -O2 - with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 - boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 - # - # Linux / g++-7 -std=c++11 / -O2 / boost 1.80 - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-7 - cxx-std: c++11 - separate-compilation: --enable-separate-compilation - optim-level: -O2 - with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 - boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 - # - # Linux / clang++-14 -std=c++2a / -O2 / standalone - # - - build-type: full - runs-on: ubuntu-22.04 - compiler: clang++-14 - cxx-std: c++2a - optim-level: -O2 - # - # Linux / clang++-14 -std=c++11 / -O0 / standalone / separate compilation - # - - build-type: full - runs-on: ubuntu-22.04 - compiler: clang++-14 - cxx-std: c++11 - separate-compilation: --enable-separate-compilation - optim-level: -O0 - # - # Linux / clang++-10 -std=c++11 / -O2 / standalone - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: clang++-10 - cxx-std: c++11 - optim-level: -O2 - # - # Linux / clang++-10 -std=c++11 / -O0 / boost 1.80 / separate compilation - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: clang++-10 - cxx-std: c++03 - separate-compilation: --enable-separate-compilation - optim-level: -O0 - with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 - boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 - # - # macOS / c++2a -fcoroutines-ts / -O2 / standalone - # - - build-type: full - runs-on: macos-latest - compiler: g++ - cxx-std: c++2a -fcoroutines-ts - optim-level: -O2 - # - # macOS / c++11 / -O2 / standalone - # - - build-type: full - runs-on: macos-latest - compiler: g++ - cxx-std: c++11 - optim-level: -O2 - # - # macOS / c++11 / -O0 / standalone / kqueue disabled - # - - build-type: full - runs-on: macos-latest - compiler: g++ - cxx-std: c++11 - optim-level: -O0 - select-reactor: -DASIO_DISABLE_KQUEUE - # - # macOS / c++11 / -O0 / standalone / separate compilation - # - - build-type: full - runs-on: macos-latest - compiler: g++ - cxx-std: c++11 - separate-compilation: --enable-separate-compilation - optim-level: -O0 - # - # macOS / c++03 / -O2 / boost 1.80 - # - - build-type: full - runs-on: macos-latest - compiler: g++ - cxx-std: c++03 - optim-level: -O2 - with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 - boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 - # - # macOS / c++03 / -O2 / boost 1.80 / separate compilation - # - - build-type: full - runs-on: macos-latest - compiler: g++ - cxx-std: c++03 - separate-compilation: --enable-separate-compilation - optim-level: -O0 - with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 - boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 - runs-on: ${{ matrix.runs-on }} - env: - CXX: ${{ matrix.compiler }} - CXXFLAGS: -std=${{ matrix.cxx-std }} ${{ matrix.optim-level }} -Wall -Wextra ${{ matrix.no-deprecated }} ${{ matrix.select-reactor }} ${{ matrix.handler-tracking }} + targets: + - x86_64-linux-gnu + - x86-linux-gnu + - x86_64-linux-musl + - x86-linux-musl + - aarch64-linux-gnu + - aarch64-linux-musl + - riscv64-linux-musl + - mipsel-linux-musl + - mips-linux-musl + - powerpc64-linux-musl + - x86_64-macos + - aarch64-macos + - x86_64-windows + - x86-windows + - aarch64-windows + + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Install autotools - if: startsWith(matrix.runs-on, 'macos') - run: brew install automake - - name: Install compiler - if: startsWith(matrix.runs-on, 'ubuntu') - run: sudo apt-get install -y ${{ matrix.compiler }} - - name: Install boost - if: startsWith(matrix.with-boost, '--with-boost=$GITHUB_WORKSPACE') - run: | - wget --quiet -O - ${{ matrix.boost-url }} | tar -xj - - name: Configure - working-directory: asio - run: | - ./autogen.sh - ./configure ${{ matrix.separate-compilation }} ${{ matrix.with-boost }} - - name: Line length check - working-directory: asio - run: perl ./boostify.pl --includes-only - - name: Sanity check - if: startsWith(matrix.build-type, 'sanity') - working-directory: asio/src/tests - run: make unit/io_context.log unit/ip/tcp.log unit/ts/net.log - - name: Build - if: startsWith(matrix.build-type, 'full') - working-directory: asio - run: make && make check + - uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - uses: goto-bus-stop/setup-zig@v2 + with: + version: master + + - name: Build Summary ${{ matrix.targets }} + run: zig build -DTests --summary all -freference-trace -Dtarget=${{ matrix.targets }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index e6c8ff1c2f..6b4905b913 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /*.cpp /*.hpp /boost +zig-cache/ +zig-out/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..36b7cd93cd --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000000..e9d5bc1c73 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +## Asio Standalone for Zig Package Manager (MVP) + +* Original source: https://github.com/chriskohlhoff/asio + +### How to use + +* Download [Zig v0.11 or higher](https://ziglang.org/download) +* Make on your project `build.zig` & `build.zig.zon` file + +e.g: + +* **build.zig** +```zig + const asio_dep = b.dependency("libasio", .{ // <== as declared in build.zig.zon + .target = target, // the same as passing `-Dtarget=<...>` to the library's build.zig script + .optimize = optimize, // ditto for `-Doptimize=<...>` + }); + const libasio = asio_dep.artifact("asio"); // <== has the location of the dependency files (asio) + /// your executable config + exe.linkLibrary(libasio); // <== link libasio + exe.installLibraryHeaders(libasio); // <== get copy asio headers to zig-out/include +``` +* **build.zig.zon** +```zig +.{ + .name = "example", + .version = "0.1.0", + .dependencies = .{ + .libasio = .{ + .url = "https://github.com/kassane/asio/archive/[tag/commit-hash].tar.gz", + .hash = "[multihash - sha256-2]", + }, + }, +} +``` + +### More info about zig-pkg +- https://github.com/ziglang/zig/pull/14265 +- https://github.com/ziglang/zig/issues/14307 diff --git a/build.zig b/build.zig new file mode 100644 index 0000000000..e00dfac986 --- /dev/null +++ b/build.zig @@ -0,0 +1,234 @@ +//! Requires zig version: 0.11 or higher +//! build: zig build -Doptimize=ReleaseFast -DShared (or -DShared=true/false) + +const std = @import("std"); +const Path = std.Build.LazyPath; + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + // Options + const shared = b.option(bool, "Shared", "Build the Shared Library [default: false]") orelse false; + const ssl = b.option(bool, "Ssl", "Build Asio with OpenSSL support [default: false]") orelse false; + const tests = b.option(bool, "Tests", "Build tests [default: false]") orelse false; + + const libasio = if (!shared) b.addStaticLibrary(.{ + .name = "asio", + .target = target, + .optimize = optimize, + }) else b.addSharedLibrary(.{ + .name = "asio", + .target = target, + .version = .{ + .major = 1, + .minor = 28, + .patch = 1, + }, + .optimize = optimize, + }); + libasio.defineCMacro("ASIO_STANDALONE", null); + libasio.defineCMacro("ASIO_SEPARATE_COMPILATION", null); + if (optimize == .Debug or optimize == .ReleaseSafe) + libasio.bundle_compiler_rt = true + else + libasio.strip = true; + libasio.addIncludePath(Path.relative("asio/include")); + libasio.addCSourceFiles(switch (ssl) { + true => &.{ + "asio/src/asio_ssl.cpp", + }, + else => &.{ + "asio/src/asio.cpp", + }, + }, cxxFlags); + + if (target.isWindows()) { + if (libasio.linkage == .dynamic) { + // no pkg-config + libasio.linkSystemLibrary("ws2_32"); + if (ssl) { + libasio.linkSystemLibraryName("crypto"); + libasio.linkSystemLibraryName("ssl"); + } + libasio.want_lto = false; + } + } + // TODO: MSVC support libC++ (need: ucrt/msvcrt/vcruntime) + // https://github.com/ziglang/zig/issues/4785 - drop replacement for MSVC + if (target.getAbi() == .msvc) { + libasio.linkLibC(); + } else { + libasio.linkLibCpp(); // LLVM libc++ (builtin) + } + libasio.installHeadersDirectoryOptions(.{ + .source_dir = Path.relative("asio/include"), + .install_dir = .header, + .install_subdir = "", + .exclude_extensions = &.{ + "am", + "gitignore", + }, + }); + b.installArtifact(libasio); + + if (tests) { + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/coroutine.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/awaitable.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/async_result.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/associator.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/co_spawn.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/compose.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/connect.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/defer.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/executor.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/error.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/strand.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/thread_pool.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/this_coro.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/socket_base.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/serial_port.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/signal_set.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/post.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/prepend.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/cancellation_type.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/as_tuple.cpp", + }); + + if (target.isWindows()) { + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/windows/object_handle.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/windows/overlapped_handle.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/windows/stream_handle.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/windows/overlapped_ptr.cpp", + }); + buildTest(b, .{ + .lib = libasio, + .path = "asio/src/tests/unit/windows/random_access_handle.cpp", + }); + } + } +} + +fn buildTest(b: *std.Build, info: BuildInfo) void { + const test_exe = b.addExecutable(.{ + .name = info.filename(), + .optimize = info.lib.optimize, + .target = info.lib.target, + }); + if (info.lib.optimize == .Debug) + test_exe.defineCMacro("ASIO_ENABLE_HANDLER_TRACKING", null); + test_exe.linkLibrary(info.lib); + for (info.lib.include_dirs.items) |include| { + test_exe.include_dirs.append(include) catch {}; + } + test_exe.addIncludePath(Path.relative("asio/src/tests/unit")); // unit_test.hpp + test_exe.addCSourceFile(.{ .file = .{ .path = info.path }, .flags = cxxFlags }); + if (info.lib.target.isWindows()) { + test_exe.linkSystemLibrary("ws2_32"); + } + if (test_exe.target.getAbi() == .msvc) + test_exe.linkLibC() + else + test_exe.linkLibCpp(); + b.installArtifact(test_exe); + + const run_cmd = b.addRunArtifact(test_exe); + run_cmd.step.dependOn(b.getInstallStep()); + if (b.args) |args| { + run_cmd.addArgs(args); + } + + const run_step = b.step( + b.fmt("{s}", .{info.filename()}), + b.fmt("Run the {s} test", .{info.filename()}), + ); + run_step.dependOn(&run_cmd.step); +} + +const cxxFlags: []const []const u8 = &.{ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Werror", + "-Wno-deprecated-declarations", +}; + +const BuildInfo = struct { + lib: *std.Build.CompileStep, + path: []const u8, + + fn filename(self: BuildInfo) []const u8 { + var split = std.mem.split(u8, std.fs.path.basename(self.path), "."); + return split.first(); + } +}; diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000000..62c8a47041 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,4 @@ +.{ + .name = "libasio", + .version = "1.28.1", +}