build: switch to the Zig package manager
No more git submodules!
(cherry picked from commit 958f8798b6)
			
			
This commit is contained in:
		
							
								
								
									
										12
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							| @ -1,12 +0,0 @@ | ||||
| [submodule "deps/zig-wayland"] | ||||
| 	path = deps/zig-wayland | ||||
| 	url = https://codeberg.org/ifreund/zig-wayland | ||||
| [submodule "deps/zig-pixman"] | ||||
| 	path = deps/zig-pixman | ||||
| 	url = https://codeberg.org/ifreund/zig-pixman | ||||
| [submodule "deps/zig-xkbcommon"] | ||||
| 	path = deps/zig-xkbcommon | ||||
| 	url = https://codeberg.org/ifreund/zig-xkbcommon | ||||
| [submodule "deps/zig-wlroots"] | ||||
| 	path = deps/zig-wlroots | ||||
| 	url = https://codeberg.org/ifreund/zig-wlroots | ||||
							
								
								
									
										39
									
								
								PACKAGING.md
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								PACKAGING.md
									
									
									
									
									
								
							| @ -26,6 +26,45 @@ and is only compatible with that release and any patch releases. At the time | ||||
| of writing for example river is compatible with Zig 0.9.0 and 0.9.1 but | ||||
| not Zig 0.8.0 or 0.10.0. | ||||
|  | ||||
| ## Zig Package Manager | ||||
|  | ||||
| River uses the built-in Zig package manager for its (few) Zig dependencies. | ||||
| By default, running `zig build` will fetch river's Zig dependencies from the | ||||
| internet and store them in the global zig cache before building river. Since | ||||
| accessing the internet is forbidden or at least frowned upon by most distro | ||||
| packaging infrastructure, there are ways to fetch the Zig dependencies in a | ||||
| separate step before building river: | ||||
|  | ||||
| 1. Fetch step with internet access: | ||||
|  | ||||
|    For each package in the `build.zig.zon` manifest file run the following command | ||||
|    with the tarball URL in the `build.zig.zon`: | ||||
|  | ||||
|    ``` | ||||
|    zig fetch --global-cache-dir /tmp/foobar $URL | ||||
|    ``` | ||||
|  | ||||
|    This command will download and unpack the tarball, hash the contents of the | ||||
|    tarball, and store the contents in the `/tmp/foobar/p/$HASH` directory. This | ||||
|    hash should match the corresponding hash field in the `build.zig.zon`. | ||||
|  | ||||
| 2. Build step with no internet access: | ||||
|  | ||||
|    The `--system` flag for `zig build` takes a path to an arbitrary directory in | ||||
|    which zig packages stored in subdirectories matching their hash can be found. | ||||
|  | ||||
|    ``` | ||||
|    zig build --system /tmp/foobar/p/ ... | ||||
|    ``` | ||||
|  | ||||
|    This flag will disable all internet access and error if a package is not found | ||||
|    in the provided directory. | ||||
|  | ||||
| It is also possible for distros to distribute Zig package manager packages as | ||||
| distro packages, although there are still some rough edges as the support for | ||||
| this is not yet mature. See this patchset for Chimera Linux for an example of | ||||
| how this can work: https://github.com/chimera-linux/cports/pull/1395 | ||||
|  | ||||
| ## Build options | ||||
|  | ||||
| River is built using the Zig build system. To see all available build | ||||
|  | ||||
							
								
								
									
										12
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								README.md
									
									
									
									
									
								
							| @ -51,12 +51,7 @@ commands to set up the user's configuration. | ||||
|  | ||||
| ## Building | ||||
|  | ||||
| On cloning the repository, you must init and update the submodules as well | ||||
| with e.g. | ||||
|  | ||||
| ``` | ||||
| git submodule update --init | ||||
| ``` | ||||
| Note: If you are packaging river for distribution, see [PACKAGING.md](PACKAGING.md). | ||||
|  | ||||
| To compile river first ensure that you have the following dependencies | ||||
| installed. The "development" versions are required if applicable to your | ||||
| @ -76,10 +71,7 @@ Then run, for example: | ||||
| ``` | ||||
| zig build -Doptimize=ReleaseSafe --prefix ~/.local install | ||||
| ``` | ||||
| To enable experimental Xwayland support pass the `-Dxwayland` option as well. | ||||
|  | ||||
| If you are packaging river for distribution, see also | ||||
| [PACKAGING.md](PACKAGING.md). | ||||
| To enable Xwayland support pass the `-Dxwayland` option as well. | ||||
|  | ||||
| ## Usage | ||||
|  | ||||
|  | ||||
							
								
								
									
										40
									
								
								build.zig
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								build.zig
									
									
									
									
									
								
							| @ -4,7 +4,7 @@ const Build = std.Build; | ||||
| const fs = std.fs; | ||||
| const mem = std.mem; | ||||
|  | ||||
| const Scanner = @import("deps/zig-wayland/build.zig").Scanner; | ||||
| const Scanner = @import("zig-wayland").Scanner; | ||||
|  | ||||
| /// While a river release is in development, this string should contain the version in development | ||||
| /// with the "-dev" suffix. | ||||
| @ -132,32 +132,20 @@ pub fn build(b: *Build) !void { | ||||
|     scanner.generate("zwlr_layer_shell_v1", 4); | ||||
|     scanner.generate("zwlr_output_power_manager_v1", 1); | ||||
|  | ||||
|     const wayland = b.createModule(.{ | ||||
|         .root_source_file = scanner.result, | ||||
|         .target = target, | ||||
|     }); | ||||
|     const wayland = b.createModule(.{ .root_source_file = scanner.result }); | ||||
|  | ||||
|     const xkbcommon = b.createModule(.{ | ||||
|         .root_source_file = .{ .path = "deps/zig-xkbcommon/src/xkbcommon.zig" }, | ||||
|         .target = target, | ||||
|     }); | ||||
|     xkbcommon.linkSystemLibrary("xkbcommon", .{}); | ||||
|     const xkbcommon = b.dependency("zig-xkbcommon", .{}).module("xkbcommon"); | ||||
|     const pixman = b.dependency("zig-pixman", .{}).module("pixman"); | ||||
|  | ||||
|     const pixman = b.createModule(.{ | ||||
|         .root_source_file = .{ .path = "deps/zig-pixman/pixman.zig" }, | ||||
|         .target = target, | ||||
|     }); | ||||
|     pixman.linkSystemLibrary("pixman-1", .{}); | ||||
|     const wlroots = b.dependency("zig-wlroots", .{}).module("wlroots"); | ||||
|     wlroots.addImport("wayland", wayland); | ||||
|     wlroots.addImport("xkbcommon", xkbcommon); | ||||
|     wlroots.addImport("pixman", pixman); | ||||
|  | ||||
|     const wlroots = b.createModule(.{ | ||||
|         .root_source_file = .{ .path = "deps/zig-wlroots/src/wlroots.zig" }, | ||||
|         .imports = &.{ | ||||
|             .{ .name = "wayland", .module = wayland }, | ||||
|             .{ .name = "xkbcommon", .module = xkbcommon }, | ||||
|             .{ .name = "pixman", .module = pixman }, | ||||
|         }, | ||||
|         .target = target, | ||||
|     }); | ||||
|     // We need to ensure the wlroots include path obtained from pkg-config is | ||||
|     // exposed to the wlroots module for @cImport() to work. This seems to be | ||||
|     // the best way to do so with the current std.Build API. | ||||
|     wlroots.resolved_target = target; | ||||
|     wlroots.linkSystemLibrary("wlroots", .{}); | ||||
|  | ||||
|     const flags = b.createModule(.{ .root_source_file = .{ .path = "common/flags.zig" } }); | ||||
| @ -179,6 +167,9 @@ pub fn build(b: *Build) !void { | ||||
|         river.linkSystemLibrary("libevdev"); | ||||
|         river.linkSystemLibrary("libinput"); | ||||
|         river.linkSystemLibrary("wayland-server"); | ||||
|         river.linkSystemLibrary("wlroots"); | ||||
|         river.linkSystemLibrary("xkbcommon"); | ||||
|         river.linkSystemLibrary("pixman-1"); | ||||
|  | ||||
|         river.root_module.addImport("wayland", wayland); | ||||
|         river.root_module.addImport("xkbcommon", xkbcommon); | ||||
| @ -191,7 +182,6 @@ pub fn build(b: *Build) !void { | ||||
|             .file = .{ .path = "river/wlroots_log_wrapper.c" }, | ||||
|             .flags = &.{ "-std=c99", "-O2" }, | ||||
|         }); | ||||
|         river.linkSystemLibrary("wlroots"); | ||||
|  | ||||
|         // TODO: remove when zig issue #131 is implemented | ||||
|         scanner.addCSource(river); | ||||
|  | ||||
							
								
								
									
										23
									
								
								build.zig.zon
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								build.zig.zon
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| .{ | ||||
|     .name = "river", | ||||
|     .version = "0.3.2-dev", | ||||
|     .paths = .{""}, | ||||
|     .dependencies = .{ | ||||
|         .@"zig-pixman" = .{ | ||||
|             .url = "https://codeberg.org/ifreund/zig-pixman/archive/v0.1.0.tar.gz", | ||||
|             .hash = "122014eeb4600a059bdcfe1c864862f17e6d5e4237e3bb7d6818f2a5583f6f4eb843", | ||||
|         }, | ||||
|         .@"zig-wayland" = .{ | ||||
|             .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.1.0.tar.gz", | ||||
|             .hash = "1220b0f8f822c1625af7aae4cb3ab2c4ec1a4c0e99ef32867b2a8d88bb070b3e7f6d", | ||||
|         }, | ||||
|         .@"zig-wlroots" = .{ | ||||
|             .url = "https://codeberg.org/ifreund/zig-wlroots/archive/v0.17.0.tar.gz", | ||||
|             .hash = "1220714d1cc39c3abb1d9c22a0b838d847ead099cb7d9931821490483f30c022e827", | ||||
|         }, | ||||
|         .@"zig-xkbcommon" = .{ | ||||
|             .url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.1.0.tar.gz", | ||||
|             .hash = "1220840390382c88caf9b0887f6cebbba3a7d05960b8b2ee6d80567b2950b71e5017", | ||||
|         }, | ||||
|     }, | ||||
| } | ||||
							
								
								
									
										1
									
								
								deps/zig-pixman
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								deps/zig-pixman
									
									
									
									
										vendored
									
									
								
							 Submodule deps/zig-pixman deleted from 70bff91bee
									
								
							
							
								
								
									
										1
									
								
								deps/zig-wayland
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								deps/zig-wayland
									
									
									
									
										vendored
									
									
								
							 Submodule deps/zig-wayland deleted from 6be3eb9bff
									
								
							
							
								
								
									
										1
									
								
								deps/zig-wlroots
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								deps/zig-wlroots
									
									
									
									
										vendored
									
									
								
							 Submodule deps/zig-wlroots deleted from 941859cd84
									
								
							
							
								
								
									
										1
									
								
								deps/zig-xkbcommon
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								deps/zig-xkbcommon
									
									
									
									
										vendored
									
									
								
							 Submodule deps/zig-xkbcommon deleted from 3a2eefdad6
									
								
							
		Reference in New Issue
	
	Block a user