Initial import (rhbz#1968139)
This commit is contained in:
parent
51cbd5f5a3
commit
89a4b3568c
5 changed files with 289 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/zig-0.8.0.tar.gz
|
||||
122
0001-specify-the-output-lib-exe-and-include-paths-with-fl.patch
Normal file
122
0001-specify-the-output-lib-exe-and-include-paths-with-fl.patch
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
From 4f59e6c80f5ef17ed216dc0b9033ed811197ec33 Mon Sep 17 00:00:00 2001
|
||||
From: Jan200101 <sentrycraft123@gmail.com>
|
||||
Date: Mon, 7 Jun 2021 01:14:05 +0200
|
||||
Subject: [PATCH] specify the output lib, exe and include paths with flags
|
||||
|
||||
Signed-off-by: Jan200101 <sentrycraft123@gmail.com>
|
||||
---
|
||||
lib/std/build.zig | 26 +++++++++++++++++++++-----
|
||||
lib/std/special/build_runner.zig | 25 +++++++++++++++++++++++--
|
||||
2 files changed, 44 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/lib/std/build.zig b/lib/std/build.zig
|
||||
index 572f2b2be..f7f90fb51 100644
|
||||
--- a/lib/std/build.zig
|
||||
+++ b/lib/std/build.zig
|
||||
@@ -190,8 +190,12 @@ pub const Builder = struct {
|
||||
}
|
||||
|
||||
/// This function is intended to be called by std/special/build_runner.zig, not a build.zig file.
|
||||
- pub fn resolveInstallPrefix(self: *Builder, install_prefix: ?[]const u8) void {
|
||||
- if (self.dest_dir) |dest_dir| {
|
||||
+ pub fn resolveInstallPrefix(self: *Builder, install_prefix: ?[]const u8, lib_dir: ?[]const u8, exe_dir: ?[]const u8, h_dir: ?[]const u8) void {
|
||||
+ var dest_dir: []const u8 = "";
|
||||
+
|
||||
+ if (self.dest_dir) |self_dest_dir| {
|
||||
+ dest_dir = self_dest_dir;
|
||||
+
|
||||
self.install_prefix = install_prefix orelse "/usr";
|
||||
self.install_path = fs.path.join(self.allocator, &[_][]const u8{ dest_dir, self.install_prefix }) catch unreachable;
|
||||
} else {
|
||||
@@ -199,9 +203,21 @@ pub const Builder = struct {
|
||||
(fs.path.join(self.allocator, &[_][]const u8{ self.build_root, "zig-out" }) catch unreachable);
|
||||
self.install_path = self.install_prefix;
|
||||
}
|
||||
- self.lib_dir = fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "lib" }) catch unreachable;
|
||||
- self.exe_dir = fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "bin" }) catch unreachable;
|
||||
- self.h_dir = fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "include" }) catch unreachable;
|
||||
+
|
||||
+ self.lib_dir = if (lib_dir != null)
|
||||
+ (fs.path.join(self.allocator, &[_][]const u8{ dest_dir, lib_dir.? }) catch unreachable)
|
||||
+ else
|
||||
+ (fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "lib" }) catch unreachable);
|
||||
+
|
||||
+ self.exe_dir = if (exe_dir != null)
|
||||
+ (fs.path.join(self.allocator, &[_][]const u8{ dest_dir, exe_dir.? }) catch unreachable)
|
||||
+ else
|
||||
+ (fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "bin" }) catch unreachable);
|
||||
+
|
||||
+ self.h_dir = if (h_dir != null)
|
||||
+ (fs.path.join(self.allocator, &[_][]const u8{ dest_dir, h_dir.? }) catch unreachable)
|
||||
+ else
|
||||
+ (fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "include" }) catch unreachable);
|
||||
}
|
||||
|
||||
pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {
|
||||
diff --git a/lib/std/special/build_runner.zig b/lib/std/special/build_runner.zig
|
||||
index c6185ef09..883bb053e 100644
|
||||
--- a/lib/std/special/build_runner.zig
|
||||
+++ b/lib/std/special/build_runner.zig
|
||||
@@ -61,6 +61,9 @@ pub fn main() !void {
|
||||
const stdout_stream = io.getStdOut().writer();
|
||||
|
||||
var install_prefix: ?[]const u8 = null;
|
||||
+ var lib_dir: ?[]const u8 = null;
|
||||
+ var exe_dir: ?[]const u8 = null;
|
||||
+ var h_dir: ?[]const u8 = null;
|
||||
while (nextArg(args, &arg_idx)) |arg| {
|
||||
if (mem.startsWith(u8, arg, "-D")) {
|
||||
const option_contents = arg[2..];
|
||||
@@ -87,6 +90,21 @@ pub fn main() !void {
|
||||
warn("Expected argument after {s}\n\n", .{arg});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
+ } else if (mem.eql(u8, arg, "--output-lib-dir")) {
|
||||
+ lib_dir = nextArg(args, &arg_idx) orelse {
|
||||
+ warn("Expected argument after {s}\n\n", .{arg});
|
||||
+ return usageAndErr(builder, false, stderr_stream);
|
||||
+ };
|
||||
+ } else if (mem.eql(u8, arg, "--output-exe-dir")) {
|
||||
+ exe_dir = nextArg(args, &arg_idx) orelse {
|
||||
+ warn("Expected argument after {s}\n\n", .{arg});
|
||||
+ return usageAndErr(builder, false, stderr_stream);
|
||||
+ };
|
||||
+ } else if (mem.eql(u8, arg, "--output-include-dir")) {
|
||||
+ h_dir = nextArg(args, &arg_idx) orelse {
|
||||
+ warn("Expected argument after {s}\n\n", .{arg});
|
||||
+ return usageAndErr(builder, false, stderr_stream);
|
||||
+ };
|
||||
} else if (mem.eql(u8, arg, "--search-prefix")) {
|
||||
const search_prefix = nextArg(args, &arg_idx) orelse {
|
||||
warn("Expected argument after --search-prefix\n\n", .{});
|
||||
@@ -135,7 +153,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
- builder.resolveInstallPrefix(install_prefix);
|
||||
+ builder.resolveInstallPrefix(install_prefix, lib_dir, exe_dir, h_dir);
|
||||
try runBuild(builder);
|
||||
|
||||
if (builder.validateUserInputDidItFail())
|
||||
@@ -163,7 +181,7 @@ fn runBuild(builder: *Builder) anyerror!void {
|
||||
fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void {
|
||||
// run the build script to collect the options
|
||||
if (!already_ran_build) {
|
||||
- builder.resolveInstallPrefix(null);
|
||||
+ builder.resolveInstallPrefix(null, null, null, null);
|
||||
try runBuild(builder);
|
||||
}
|
||||
|
||||
@@ -189,6 +207,9 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
|
||||
\\ -h, --help Print this help and exit
|
||||
\\ --verbose Print commands before executing them
|
||||
\\ -p, --prefix [path] Override default install prefix
|
||||
+ \\ --output-lib-dir [path] Override default library directory path
|
||||
+ \\ --output-exe-dir [path] Override default executable directory path
|
||||
+ \\ --output-include-dir [path] Override default include directory path
|
||||
\\ --search-prefix [path] Add a path to look for binaries, libraries, headers
|
||||
\\ --color [auto|off|on] Enable or disable colored error messages
|
||||
\\
|
||||
--
|
||||
2.31.1
|
||||
|
||||
21
macros.zig
Normal file
21
macros.zig
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
%zig_arches x86_64 %{ix86} armv7hl aarch64 riscv64 %{mips}
|
||||
|
||||
%_zig_version @@ZIG_VERSION@@
|
||||
%__zig /usr/bin/zig
|
||||
|
||||
%zig_build \
|
||||
%__zig \\\
|
||||
--verbose \\\
|
||||
--cache-dir zig-cache
|
||||
|
||||
%zig_install \
|
||||
DESTDIR="%{buildroot}" %zig_build \\\
|
||||
--prefix "%{_prefix}" \\
|
||||
--output-lib-dir "%{_libdir}" \\\
|
||||
--output-exe-dir "%{_bindir}" \\\
|
||||
--output-include-dir "%{_includedir}" \\\
|
||||
install
|
||||
|
||||
%zig_test \
|
||||
%zig_build \\\
|
||||
test
|
||||
1
sources
Normal file
1
sources
Normal file
|
|
@ -0,0 +1 @@
|
|||
SHA512 (zig-0.8.0.tar.gz) = 2082810d5ab0560167766e80f0853e5ff99e32b1935836a6a0029b8e1c88061c55dd0c285cbcc506f4c38aac8477ec7162b771537699be9b3d387de94e3baa57
|
||||
144
zig.spec
Normal file
144
zig.spec
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
# https://ziglang.org/download/0.8.0/release-notes.html#Support-Table
|
||||
%global zig_arches x86_64 %{ix86} armv7hl aarch64 riscv64 %{mips}
|
||||
|
||||
Name: zig
|
||||
Version: 0.8.0
|
||||
Release: 1%{?dist}
|
||||
Summary: Programming language for maintaining robust, optimal, and reusable software
|
||||
|
||||
License: MIT and NCSA and LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net and ISC and Public Domain and GFDL and ZPLv2.1
|
||||
URL: https://ziglang.org
|
||||
Source0: https://github.com/ziglang/zig/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
||||
Source1: macros.%{name}
|
||||
|
||||
# https://github.com/ziglang/zig/pull/9020
|
||||
Patch0: 0001-specify-the-output-lib-exe-and-include-paths-with-fl.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: gcc-c++
|
||||
BuildRequires: cmake
|
||||
BuildRequires: llvm-devel
|
||||
BuildRequires: clang-devel
|
||||
BuildRequires: lld-devel
|
||||
# for man page generation
|
||||
BuildRequires: help2man
|
||||
# for testing
|
||||
#BuildRequires: elfutils-libelf-devel
|
||||
#BuildRequires: libstdc++-static
|
||||
|
||||
Requires: %{name}-libs = %{version}
|
||||
|
||||
# These packages are bundled as source
|
||||
|
||||
# NCSA
|
||||
Provides: bundled(compiler-rt) = 12.0.0
|
||||
# LGPLv2+, LGPLv2+ with exceptions, GPLv2+, GPLv2+ with exceptions, BSD, Inner-Net, ISC, Public Domain and GFDL
|
||||
Provides: bundled(glibc) = 2.33
|
||||
# NCSA
|
||||
Provides: bundled(libcxx) = 12.0.0
|
||||
# NCSA
|
||||
Provides: bundled(libcxxabi) = 12.0.0
|
||||
# NCSA
|
||||
Provides: bundled(libunwind) = 12.0.0
|
||||
# BSD, LGPG, ZPL
|
||||
Provides: bundled(mingw) = 8.0.0
|
||||
# MIT
|
||||
Provides: bundled(musl) = 1.2.2
|
||||
|
||||
ExclusiveArch: %{zig_arches}
|
||||
|
||||
%description
|
||||
Zig is an open-source programming language designed for robustness, optimality,
|
||||
and clarity. This package provides the zig compiler and the associated runtime.
|
||||
|
||||
# the standard library contains only plain text
|
||||
%package libs
|
||||
Summary: zig standard library
|
||||
BuildArch: noarch
|
||||
|
||||
%description libs
|
||||
Standard Zig library
|
||||
|
||||
%package doc
|
||||
Summary: Documentation for %{name}
|
||||
BuildArch: noarch
|
||||
Requires: %{name} = %{version}
|
||||
|
||||
%description doc
|
||||
Documentation for %{name}. For more information, visit %{url}
|
||||
|
||||
%package rpm-macros
|
||||
Summary: Common RPM macros for %{name}
|
||||
Requires: rpm
|
||||
BuildArch: noarch
|
||||
|
||||
%description rpm-macros
|
||||
This package contains common RPM macros for %{name}.
|
||||
|
||||
%prep
|
||||
%autosetup -p1
|
||||
|
||||
%build
|
||||
|
||||
%cmake \
|
||||
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
|
||||
-DZIG_PREFER_CLANG_CPP_DYLIB=true \
|
||||
-DZIG_VERSION:STRING="%{version}"
|
||||
%cmake_build
|
||||
|
||||
# Zig has no official manpage
|
||||
# https://github.com/ziglang/zig/issues/715
|
||||
help2man --no-discard-stderr "%{__cmake_builddir}/zig" --version-option=version --output=%{name}.1
|
||||
|
||||
ln -s lib "%{__cmake_builddir}/"
|
||||
|
||||
# buildings docs fails on rawhide due to the libc version
|
||||
%{__cmake_builddir}/zig build docs -Dversion-string="%{version}" || true
|
||||
touch zig-cache/langref.html
|
||||
|
||||
%install
|
||||
%cmake_install
|
||||
|
||||
mkdir -p %{buildroot}/%{_mandir}/man1
|
||||
install -m 0644 %{name}.1 %{buildroot}%{_mandir}/man1/
|
||||
|
||||
mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d/
|
||||
|
||||
install -p -m644 %{SOURCE1} %{buildroot}%{_rpmconfigdir}/macros.d/
|
||||
sed -i -e "s|@@ZIG_VERSION@@|%{version}|" %{buildroot}%{_rpmconfigdir}/macros.d/macros.%{name}
|
||||
|
||||
%check
|
||||
|
||||
# tests are affected by an LLVM regression
|
||||
# https://bugs.llvm.org/show_bug.cgi?id=49401
|
||||
# https://github.com/ziglang/zig/issues/8130
|
||||
# %%{__cmake_builddir}/zig build test
|
||||
|
||||
%files
|
||||
%license LICENSE
|
||||
%{_bindir}/zig
|
||||
%{_mandir}/man1/%{name}.1.*
|
||||
|
||||
%files libs
|
||||
%{_prefix}/lib/%{name}
|
||||
|
||||
%files doc
|
||||
%doc README.md
|
||||
%doc zig-cache/langref.html
|
||||
|
||||
%files rpm-macros
|
||||
%{_rpmconfigdir}/macros.d/macros.%{name}
|
||||
|
||||
%changelog
|
||||
* Sat Jun 05 2021 Jan Drögehoff <sentrycraft123@gmail.com> - 0.8.0-1
|
||||
- Update to Zig 0.8.0
|
||||
|
||||
* Sun Dec 13 23:18:24 CET 2020 Jan Drögehoff <sentrycraft123@gmail.com> - 0.7.1-1
|
||||
- Update to Zig 0.7.1
|
||||
|
||||
* Wed Nov 11 17:18:27 CET 2020 Jan Drögehoff <sentrycraft123@gmail.com> - 0.7.0-1
|
||||
- Update to Zig 0.7.0
|
||||
|
||||
* Tue Aug 18 2020 Jan Drögehoff <sentrycraft123@gmail.com> - 0.6.0-1
|
||||
- Initial zig spec
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue