-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
466 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Zig | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
targets: | ||
- x86_64-linux-gnu | ||
- x86_64-linux-musl | ||
- x86-linux-gnu | ||
- x86-linux-musl | ||
- aarch64-linux-gnu | ||
- aarch64-linux-musl | ||
- riscv64-linux-musl | ||
- powerpc64-linux-musl | ||
- x86_64-macos | ||
- aarch64-macos | ||
- x86-windows | ||
- x86_64-windows | ||
- aarch64-windows | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
- uses: mlugg/setup-zig@v1 | ||
- name: Build Summary ${{ matrix.targets }} | ||
run: zig build --summary all -freference-trace -Dtarget=${{ matrix.targets }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*zig-*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,41 @@ | ||
# boost-libraries-zig | ||
Boost Libraries using build.zig | ||
|
||
Boost Libraries using `build.zig` | ||
|
||
### Requirements | ||
|
||
- [zig](https://ziglang.org/download) v0.13.0 or master | ||
|
||
## How to use | ||
|
||
Make directory and init | ||
|
||
```bash | ||
$ zig init | ||
## add zon file boost-libraries-zig | ||
$ zig fetch --save=boost git+https://github.com/allyourcodebase/boost-libraries-zig | ||
``` | ||
Add in **build.zig** | ||
```zig | ||
const std = @import("std"); | ||
pub fn build(b: *std.Build) !void { | ||
const target = b.standardTargetOptions(.{}); | ||
const optimize = b.standardOptimizeOption(.{}); | ||
const boost_dep = b.dependency("boost", .{ | ||
.target = target, | ||
.optimize = optimize, | ||
.@"headers-only" = true, | ||
}); | ||
const boost_artifact = boost_dep.artifact("boost"); | ||
for(boost_artifact.root_module.include_dirs.items) |include_dir| { | ||
try exe.root_module.include_dirs.append(b.allocator, include_dir); | ||
} | ||
exe.linklibrary(boost_artifact); | ||
} | ||
``` | ||
|
||
## License | ||
|
||
see: [LICENSE](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
const std = @import("std"); | ||
|
||
pub fn build(b: *std.Build) !void { | ||
const target = b.standardTargetOptions(.{}); | ||
const optimize = b.standardOptimizeOption(.{}); | ||
|
||
const boost = boostLibraries(b, .{ | ||
.target = target, | ||
.optimize = optimize, | ||
.header_only = b.option(bool, "headers-only", "Build header-only libraries") orelse false, | ||
}); | ||
b.installArtifact(boost); | ||
} | ||
|
||
const cxxFlags: []const []const u8 = &.{ | ||
"-Wall", | ||
"-Wextra", | ||
"-Wpedantic", | ||
}; | ||
|
||
fn boostLibraries(b: *std.Build, config: Config) *std.Build.Step.Compile { | ||
const lib = b.addStaticLibrary(.{ | ||
.name = "boost", | ||
.target = config.target, | ||
.optimize = config.optimize, | ||
}); | ||
|
||
const boostCore = b.dependency("core", .{}).path(""); | ||
const boostAlg = b.dependency("algorithm", .{}).path(""); | ||
const boostConfig = b.dependency("config", .{}).path(""); | ||
const boostAssert = b.dependency("assert", .{}).path(""); | ||
const boostTraits = b.dependency("type_traits", .{}).path(""); | ||
const boostMP11 = b.dependency("mp11", .{}).path(""); | ||
const boostRange = b.dependency("range", .{}).path(""); | ||
const boostFunctional = b.dependency("functional", .{}).path(""); | ||
const boostPreprocessor = b.dependency("preprocessor", .{}).path(""); | ||
const boostHash = b.dependency("container_hash", .{}).path(""); | ||
const boostDescribe = b.dependency("describe", .{}).path(""); | ||
const boostMpl = b.dependency("mpl", .{}).path(""); | ||
const boostIterator = b.dependency("iterator", .{}).path(""); | ||
const boostStaticAssert = b.dependency("static_assert", .{}).path(""); | ||
const boostMove = b.dependency("move", .{}).path(""); | ||
const boostDetail = b.dependency("detail", .{}).path(""); | ||
const boostThrow = b.dependency("throw_exception", .{}).path(""); | ||
const boostTuple = b.dependency("tuple", .{}).path(""); | ||
const boostPredef = b.dependency("predef", .{}).path(""); | ||
const boostCCheck = b.dependency("concept_check", .{}).path(""); | ||
const boostUtil = b.dependency("utility", .{}).path(""); | ||
const boostEndian = b.dependency("endian", .{}).path(""); | ||
const boostRegex = b.dependency("regex", .{}).path(""); | ||
const boostAsio = b.dependency("asio", .{}).path(""); | ||
const boostAlign = b.dependency("align", .{}).path(""); | ||
const boostSystem = b.dependency("system", .{}).path(""); | ||
const boostIntrusive = b.dependency("intrusive", .{}).path(""); | ||
const boostHana = b.dependency("hana", .{}).path(""); | ||
const boostOutcome = b.dependency("outcome", .{}).path(""); | ||
const boostBind = b.dependency("bind", .{}).path(""); | ||
const boostOptional = b.dependency("optional", .{}).path(""); | ||
const boostDateTime = b.dependency("date_time", .{}).path(""); | ||
const boostSmartPtr = b.dependency("smart_ptr", .{}).path(""); | ||
const boostNumeric = b.dependency("numeric_conversion", .{}).path(""); | ||
const boostLogic = b.dependency("logic", .{}).path(""); | ||
const boostStaticStr = b.dependency("static_string", .{}).path(""); | ||
const boostIO = b.dependency("io", .{}).path(""); | ||
const boostJson = b.dependency("json", .{}).path(""); | ||
const boostContainer = b.dependency("container", .{}).path(""); | ||
const boostVariant2 = b.dependency("variant2", .{}).path(""); | ||
const boostWinApi = b.dependency("winapi", .{}).path(""); | ||
if (config.header_only) { | ||
// zig-pkg bypass (no header-only) | ||
const empty = b.addWriteFile("empty.cc", "// bypass"); | ||
lib.step.dependOn(&empty.step); | ||
lib.addCSourceFiles(.{ | ||
.root = empty.getDirectory(), | ||
.files = &.{"empty.cc"}, | ||
.flags = cxxFlags, | ||
}); | ||
} else { | ||
lib.addCSourceFiles(.{ | ||
.root = boostContainer, | ||
.files = &.{ | ||
"src/pool_resource.cpp", | ||
"src/monotonic_buffer_resource.cpp", | ||
"src/synchronized_pool_resource.cpp", | ||
"src/unsynchronized_pool_resource.cpp", | ||
"src/global_resource.cpp", | ||
}, | ||
.flags = cxxFlags, | ||
}); | ||
lib.addCSourceFiles(.{ | ||
.root = boostJson, | ||
.files = &.{ | ||
"src/src.cpp", | ||
}, | ||
.flags = cxxFlags, | ||
}); | ||
if (lib.rootModuleTarget().abi == .msvc) | ||
lib.linkLibC() | ||
else | ||
lib.linkLibCpp(); | ||
} | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostCore.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostAlg.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostConfig.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostAssert.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostFunctional.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostMP11.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostTraits.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostRange.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostPreprocessor.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostHash.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostDescribe.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostMpl.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostStaticAssert.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostIterator.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostMove.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostDetail.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostThrow.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostTuple.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostPredef.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostCCheck.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostUtil.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostRegex.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostEndian.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostAsio.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostAlign.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostSystem.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostIntrusive.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostHana.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostOutcome.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostBind.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostOptional.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostDateTime.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostSmartPtr.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostNumeric.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostLogic.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostStaticStr.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostIO.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostJson.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostContainer.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostVariant2.getPath(b), "include" }) }); | ||
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostWinApi.getPath(b), "include" }) }); | ||
|
||
return lib; | ||
} | ||
|
||
pub const Config = struct { | ||
header_only: bool, | ||
target: std.Build.ResolvedTarget, | ||
optimize: std.builtin.OptimizeMode, | ||
}; |
Oops, something went wrong.