mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +00:00
Ports: Add zig port :^)
:yakkie: The build process for the Zig compiler is more involved than most of the other ports, because the Zig compiler is mostly self-hosting. In order to build it, the zig-bootstrap build system is used, which does the following: 1) Build LLVM for the host OS; 2) Build Zig for the host OS with the SerenityOS target enabled; 3) Build zlib, zstd and LLVM for SerenityOS using `zig cc` as the C/C++ compiler; 4) Build Zig for SerenityOS using the host Zig. A few hacks are required in order to tell `zig cc` and zig about what Serenity's libc looks like in the build process, but other than that it's fairly straightforward. All of the patches that are included with this commit are Zig-upstream ready once the LLVM patches are upstreamed.
This commit is contained in:
parent
27da878bb7
commit
cda5a530e6
19 changed files with 1533 additions and 0 deletions
193
Ports/zig/scripts/constants.txt
Normal file
193
Ports/zig/scripts/constants.txt
Normal file
|
@ -0,0 +1,193 @@
|
|||
AT_FDCWD
|
||||
AT_REMOVEDIR
|
||||
AT_SYMLINK_NOFOLLOW
|
||||
CLOCK_MONOTONIC
|
||||
CLOCK_MONOTONIC_COARSE
|
||||
CLOCK_MONOTONIC_RAW
|
||||
CLOCK_REALTIME
|
||||
CLOCK_REALTIME_COARSE
|
||||
E2BIG
|
||||
EACCES
|
||||
EADDRINUSE
|
||||
EADDRNOTAVAIL
|
||||
EAFNOSUPPORT
|
||||
EAGAIN
|
||||
EALREADY
|
||||
EBADF
|
||||
EBUSY
|
||||
ECANCELED
|
||||
ECHILD
|
||||
ECONNABORTED
|
||||
ECONNREFUSED
|
||||
ECONNRESET
|
||||
EDEADLK
|
||||
EDESTADDRREQ
|
||||
EDIRINTOSELF
|
||||
EDOM
|
||||
EDQUOT
|
||||
EEXIST
|
||||
EFAULT
|
||||
EFBIG
|
||||
EHOSTDOWN
|
||||
EHOSTUNREACH
|
||||
EILSEQ
|
||||
EINPROGRESS
|
||||
EINTR
|
||||
EINVAL
|
||||
EIO
|
||||
EISCONN
|
||||
EISDIR
|
||||
ELOOP
|
||||
EMFILE
|
||||
EMLINK
|
||||
EMSGSIZE
|
||||
ENAMETOOLONG
|
||||
ENETDOWN
|
||||
ENETRESET
|
||||
ENETUNREACH
|
||||
ENFILE
|
||||
ENOBUFS
|
||||
ENODEV
|
||||
ENOENT
|
||||
ENOEXEC
|
||||
ENOLCK
|
||||
ENOMEM
|
||||
ENOMSG
|
||||
ENOPROTOOPT
|
||||
ENOSPC
|
||||
ENOSYS
|
||||
ENOTBLK
|
||||
ENOTCONN
|
||||
ENOTDIR
|
||||
ENOTEMPTY
|
||||
ENOTHREAD
|
||||
ENOTIMPL
|
||||
ENOTRECOVERABLE
|
||||
ENOTSOCK
|
||||
ENOTSUP
|
||||
ENOTTY
|
||||
ENXIO
|
||||
EOPNOTSUPP
|
||||
EOVERFLOW
|
||||
EPERM
|
||||
EPFNOSUPPORT
|
||||
EPIPE
|
||||
EPROMISEVIOLATION
|
||||
EPROTO
|
||||
EPROTONOSUPPORT
|
||||
EPROTOTYPE
|
||||
ERANGE
|
||||
EROFS
|
||||
ESHUTDOWN
|
||||
ESOCKTNOSUPPORT
|
||||
ESPIPE
|
||||
ESRCH
|
||||
ESTALE
|
||||
ESUCCESS
|
||||
ETIMEDOUT
|
||||
ETOOMANYREFS
|
||||
ETXTBSY
|
||||
EXDEV
|
||||
FD_CLOEXEC
|
||||
F_DUPFD
|
||||
F_GETFD
|
||||
F_GETFL
|
||||
F_GETLK
|
||||
F_ISTTY
|
||||
F_OK
|
||||
F_SETFD
|
||||
F_SETFL
|
||||
F_SETLK
|
||||
F_SETLKW
|
||||
IOV_MAX
|
||||
LOCK_EX
|
||||
LOCK_NB
|
||||
LOCK_SH
|
||||
LOCK_UN
|
||||
MAP_ANON
|
||||
MAP_ANONYMOUS
|
||||
MAP_FILE
|
||||
MAP_FIXED
|
||||
MAP_FIXED_NOREPLACE
|
||||
MAP_NORESERVE
|
||||
MAP_PRIVATE
|
||||
MAP_PURGEABLE
|
||||
MAP_RANDOMIZED
|
||||
MAP_SHARED
|
||||
MAP_STACK
|
||||
MS_ASYNC
|
||||
MS_INVALIDATE
|
||||
MS_SYNC
|
||||
O_ACCMODE
|
||||
O_APPEND
|
||||
O_CLOEXEC
|
||||
O_CREAT
|
||||
O_DIRECT
|
||||
O_DIRECTORY
|
||||
O_EXCL
|
||||
O_EXEC
|
||||
O_NOCTTY
|
||||
O_NOFOLLOW
|
||||
O_NONBLOCK
|
||||
O_RDONLY
|
||||
O_RDWR
|
||||
O_SYNC
|
||||
O_TRUNC
|
||||
O_WRONLY
|
||||
PATH_MAX
|
||||
POLLERR
|
||||
POLLHUP
|
||||
POLLIN
|
||||
POLLNVAL
|
||||
POLLOUT
|
||||
POLLPRI
|
||||
POLLRDHUP
|
||||
POLLRDNORM
|
||||
POLLWRBAND
|
||||
POLLWRNORM
|
||||
PROT_EXEC
|
||||
PROT_NONE
|
||||
PROT_READ
|
||||
PROT_WRITE
|
||||
R_OK
|
||||
SEEK_CUR
|
||||
SEEK_END
|
||||
SEEK_SET
|
||||
STDERR_FILENO
|
||||
STDIN_FILENO
|
||||
STDOUT_FILENO
|
||||
S_IEXEC
|
||||
S_IFBLK
|
||||
S_IFCHR
|
||||
S_IFDIR
|
||||
S_IFIFO
|
||||
S_IFLNK
|
||||
S_IFMT
|
||||
S_IFREG
|
||||
S_IFSOCK
|
||||
S_IREAD
|
||||
S_IRGRP
|
||||
S_IROTH
|
||||
S_IRUSR
|
||||
S_IRWXG
|
||||
S_IRWXO
|
||||
S_IRWXU
|
||||
S_ISGID
|
||||
S_ISUID
|
||||
S_ISVTX
|
||||
S_IWGRP
|
||||
S_IWOTH
|
||||
S_IWRITE
|
||||
S_IWUSR
|
||||
S_IXGRP
|
||||
S_IXOTH
|
||||
S_IXUSR
|
||||
WCONTINUED
|
||||
WEXITED
|
||||
WNOHANG
|
||||
WNOWAIT
|
||||
WSTOPPED
|
||||
WUNTRACED
|
||||
W_OK
|
||||
X_OK
|
||||
_SC_NPROCESSORS_ONLN
|
50
Ports/zig/scripts/generate-serenity-constants.zig
Normal file
50
Ports/zig/scripts/generate-serenity-constants.zig
Normal file
|
@ -0,0 +1,50 @@
|
|||
const std = @import("std");
|
||||
|
||||
const SerenityIncludes = @cImport({
|
||||
@cInclude("bits/pthread_integration.h");
|
||||
@cInclude("dirent.h");
|
||||
@cInclude("errno_codes.h");
|
||||
@cInclude("fcntl.h");
|
||||
@cInclude("limits.h");
|
||||
@cInclude("link.h");
|
||||
@cInclude("poll.h");
|
||||
@cInclude("semaphore.h");
|
||||
@cInclude("stdio.h");
|
||||
@cInclude("sys/file.h");
|
||||
@cInclude("sys/mman.h");
|
||||
@cInclude("sys/stat.h");
|
||||
@cInclude("sys/types.h");
|
||||
@cInclude("sys/uio.h");
|
||||
@cInclude("sys/wait.h");
|
||||
@cInclude("time.h");
|
||||
@cInclude("unistd.h");
|
||||
});
|
||||
|
||||
const constant_file = @embedFile("./constants.txt");
|
||||
const constants = blk: {
|
||||
@setEvalBranchQuota(10000);
|
||||
|
||||
var constant_list: []const []const u8 = &.{};
|
||||
var constant_iterator = std.mem.tokenize(u8, constant_file, "\n");
|
||||
while (constant_iterator.next()) |constant| {
|
||||
constant_list = constant_list ++ &[_][]const u8{constant};
|
||||
}
|
||||
|
||||
break :blk constant_list;
|
||||
};
|
||||
|
||||
pub fn main() !void {
|
||||
const writer = std.io.getStdOut().writer();
|
||||
|
||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena.deinit();
|
||||
const allocator = arena.allocator();
|
||||
|
||||
inline for (constants) |constant| {
|
||||
const value = @field(SerenityIncludes, constant);
|
||||
const decl = try std.fmt.allocPrint(allocator, "pub const " ++ constant ++ " = {d};\n", .{value});
|
||||
defer allocator.free(decl);
|
||||
|
||||
try writer.writeAll(decl);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue