| author | |
| committer | |
| log | 84b4b6bffa126f1491f6029286ddecb5d6aec74b |
| tree | 336476d4fb7f17ab08651fde88b5116b70c70d62 |
| parent | 3dd439030ccc6cc9424ac03b70eab53b03f28356 |
| parent | 583914126fd61a19a9ed97a2e8aa4eec422c06ca |
| signature |
build: do not emit `-iwithsysroot`/`-iframeworkwithsysroot` implicitly9 files changed, 196 insertions(+), 43 deletions(-)
build.zig+4-2| ... | @@ -128,7 +128,8 @@ pub fn build(b: *std.Build) !void { | ... | @@ -128,7 +128,8 @@ pub fn build(b: *std.Build) !void { |
| 128 | "llvm-has-xtensa", | 128 | "llvm-has-xtensa", |
| 129 | "Whether LLVM has the experimental target xtensa enabled", | 129 | "Whether LLVM has the experimental target xtensa enabled", |
| 130 | ) orelse false; | 130 | ) orelse false; |
| 131 | const enable_macos_sdk = b.option(bool, "enable-macos-sdk", "Run tests requiring presence of macOS SDK and frameworks") orelse false; | 131 | const enable_ios_sdk = b.option(bool, "enable-ios-sdk", "Run tests requiring presence of iOS SDK and frameworks") orelse false; |
| 132 | const enable_macos_sdk = b.option(bool, "enable-macos-sdk", "Run tests requiring presence of macOS SDK and frameworks") orelse enable_ios_sdk; | ||
| 132 | const enable_symlinks_windows = b.option(bool, "enable-symlinks-windows", "Run tests requiring presence of symlinks on Windows") orelse false; | 133 | const enable_symlinks_windows = b.option(bool, "enable-symlinks-windows", "Run tests requiring presence of symlinks on Windows") orelse false; |
| 133 | const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h"); | 134 | const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h"); |
| 134 | 135 | ||
| ... | @@ -485,11 +486,12 @@ pub fn build(b: *std.Build) !void { | ... | @@ -485,11 +486,12 @@ pub fn build(b: *std.Build) !void { |
| 485 | b, | 486 | b, |
| 486 | optimization_modes, | 487 | optimization_modes, |
| 487 | enable_macos_sdk, | 488 | enable_macos_sdk, |
| 489 | enable_ios_sdk, | ||
| 488 | false, | 490 | false, |
| 489 | enable_symlinks_windows, | 491 | enable_symlinks_windows, |
| 490 | )); | 492 | )); |
| 491 | test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release)); | 493 | test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release)); |
| 492 | test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, false, enable_symlinks_windows)); | 494 | test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, false, enable_symlinks_windows)); |
| 493 | test_step.dependOn(tests.addStackTraceTests(b, test_filter, optimization_modes)); | 495 | test_step.dependOn(tests.addStackTraceTests(b, test_filter, optimization_modes)); |
| 494 | test_step.dependOn(tests.addCliTests(b)); | 496 | test_step.dependOn(tests.addCliTests(b)); |
| 495 | test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, optimization_modes)); | 497 | test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, optimization_modes)); |
lib/std/Build/Step/CheckObject.zig+54| ... | @@ -766,6 +766,60 @@ const MachODumper = struct { | ... | @@ -766,6 +766,60 @@ const MachODumper = struct { |
| 766 | }); | 766 | }); |
| 767 | }, | 767 | }, |
| 768 | 768 | ||
| 769 | .BUILD_VERSION => { | ||
| 770 | const blc = lc.cast(macho.build_version_command).?; | ||
| 771 | try writer.writeByte('\n'); | ||
| 772 | try writer.print( | ||
| 773 | \\platform {s} | ||
| 774 | \\minos {d}.{d}.{d} | ||
| 775 | \\sdk {d}.{d}.{d} | ||
| 776 | \\ntools {d} | ||
| 777 | , .{ | ||
| 778 | @tagName(blc.platform), | ||
| 779 | blc.minos >> 16, | ||
| 780 | @as(u8, @truncate(blc.minos >> 8)), | ||
| 781 | @as(u8, @truncate(blc.minos)), | ||
| 782 | blc.sdk >> 16, | ||
| 783 | @as(u8, @truncate(blc.sdk >> 8)), | ||
| 784 | @as(u8, @truncate(blc.sdk)), | ||
| 785 | blc.ntools, | ||
| 786 | }); | ||
| 787 | for (lc.getBuildVersionTools()) |tool| { | ||
| 788 | try writer.writeByte('\n'); | ||
| 789 | switch (tool.tool) { | ||
| 790 | .CLANG, .SWIFT, .LD, .LLD, .ZIG => try writer.print("tool {s}\n", .{@tagName(tool.tool)}), | ||
| 791 | else => |x| try writer.print("tool {d}\n", .{@intFromEnum(x)}), | ||
| 792 | } | ||
| 793 | try writer.print( | ||
| 794 | \\version {d}.{d}.{d} | ||
| 795 | , .{ | ||
| 796 | tool.version >> 16, | ||
| 797 | @as(u8, @truncate(tool.version >> 8)), | ||
| 798 | @as(u8, @truncate(tool.version)), | ||
| 799 | }); | ||
| 800 | } | ||
| 801 | }, | ||
| 802 | |||
| 803 | .VERSION_MIN_MACOSX, | ||
| 804 | .VERSION_MIN_IPHONEOS, | ||
| 805 | .VERSION_MIN_WATCHOS, | ||
| 806 | .VERSION_MIN_TVOS, | ||
| 807 | => { | ||
| 808 | const vlc = lc.cast(macho.version_min_command).?; | ||
| 809 | try writer.writeByte('\n'); | ||
| 810 | try writer.print( | ||
| 811 | \\version {d}.{d}.{d} | ||
| 812 | \\sdk {d}.{d}.{d} | ||
| 813 | , .{ | ||
| 814 | vlc.version >> 16, | ||
| 815 | @as(u8, @truncate(vlc.version >> 8)), | ||
| 816 | @as(u8, @truncate(vlc.version)), | ||
| 817 | vlc.sdk >> 16, | ||
| 818 | @as(u8, @truncate(vlc.sdk >> 8)), | ||
| 819 | @as(u8, @truncate(vlc.sdk)), | ||
| 820 | }); | ||
| 821 | }, | ||
| 822 | |||
| 769 | else => {}, | 823 | else => {}, |
| 770 | } | 824 | } |
| 771 | } | 825 | } |
lib/std/Build/Step/Compile.zig+19-35| ... | @@ -42,7 +42,6 @@ unwind_tables: ?bool, | ... | @@ -42,7 +42,6 @@ unwind_tables: ?bool, |
| 42 | compress_debug_sections: enum { none, zlib } = .none, | 42 | compress_debug_sections: enum { none, zlib } = .none, |
| 43 | lib_paths: ArrayList(LazyPath), | 43 | lib_paths: ArrayList(LazyPath), |
| 44 | rpaths: ArrayList(LazyPath), | 44 | rpaths: ArrayList(LazyPath), |
| 45 | framework_dirs: ArrayList(LazyPath), | ||
| 46 | frameworks: StringHashMap(FrameworkLinkInfo), | 45 | frameworks: StringHashMap(FrameworkLinkInfo), |
| 47 | verbose_link: bool, | 46 | verbose_link: bool, |
| 48 | verbose_cc: bool, | 47 | verbose_cc: bool, |
| ... | @@ -261,6 +260,8 @@ const FrameworkLinkInfo = struct { | ... | @@ -261,6 +260,8 @@ const FrameworkLinkInfo = struct { |
| 261 | pub const IncludeDir = union(enum) { | 260 | pub const IncludeDir = union(enum) { |
| 262 | path: LazyPath, | 261 | path: LazyPath, |
| 263 | path_system: LazyPath, | 262 | path_system: LazyPath, |
| 263 | framework_path: LazyPath, | ||
| 264 | framework_path_system: LazyPath, | ||
| 264 | other_step: *Compile, | 265 | other_step: *Compile, |
| 265 | config_header_step: *Step.ConfigHeader, | 266 | config_header_step: *Step.ConfigHeader, |
| 266 | }; | 267 | }; |
| ... | @@ -442,7 +443,6 @@ pub fn create(owner: *std.Build, options: Options) *Compile { | ... | @@ -442,7 +443,6 @@ pub fn create(owner: *std.Build, options: Options) *Compile { |
| 442 | .c_macros = ArrayList([]const u8).init(owner.allocator), | 443 | .c_macros = ArrayList([]const u8).init(owner.allocator), |
| 443 | .lib_paths = ArrayList(LazyPath).init(owner.allocator), | 444 | .lib_paths = ArrayList(LazyPath).init(owner.allocator), |
| 444 | .rpaths = ArrayList(LazyPath).init(owner.allocator), | 445 | .rpaths = ArrayList(LazyPath).init(owner.allocator), |
| 445 | .framework_dirs = ArrayList(LazyPath).init(owner.allocator), | ||
| 446 | .installed_headers = ArrayList(*Step).init(owner.allocator), | 446 | .installed_headers = ArrayList(*Step).init(owner.allocator), |
| 447 | .c_std = std.Build.CStd.C99, | 447 | .c_std = std.Build.CStd.C99, |
| 448 | .zig_lib_dir = null, | 448 | .zig_lib_dir = null, |
| ... | @@ -1050,9 +1050,15 @@ pub fn addRPath(self: *Compile, directory_source: LazyPath) void { | ... | @@ -1050,9 +1050,15 @@ pub fn addRPath(self: *Compile, directory_source: LazyPath) void { |
| 1050 | directory_source.addStepDependencies(&self.step); | 1050 | directory_source.addStepDependencies(&self.step); |
| 1051 | } | 1051 | } |
| 1052 | 1052 | ||
| 1053 | pub fn addSystemFrameworkPath(self: *Compile, directory_source: LazyPath) void { | ||
| 1054 | const b = self.step.owner; | ||
| 1055 | self.include_dirs.append(IncludeDir{ .framework_path_system = directory_source.dupe(b) }) catch @panic("OOM"); | ||
| 1056 | directory_source.addStepDependencies(&self.step); | ||
| 1057 | } | ||
| 1058 | |||
| 1053 | pub fn addFrameworkPath(self: *Compile, directory_source: LazyPath) void { | 1059 | pub fn addFrameworkPath(self: *Compile, directory_source: LazyPath) void { |
| 1054 | const b = self.step.owner; | 1060 | const b = self.step.owner; |
| 1055 | self.framework_dirs.append(directory_source.dupe(b)) catch @panic("OOM"); | 1061 | self.include_dirs.append(IncludeDir{ .framework_path = directory_source.dupe(b) }) catch @panic("OOM"); |
| 1056 | directory_source.addStepDependencies(&self.step); | 1062 | directory_source.addStepDependencies(&self.step); |
| 1057 | } | 1063 | } |
| 1058 | 1064 | ||
| ... | @@ -1772,27 +1778,16 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { | ... | @@ -1772,27 +1778,16 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1772 | try zig_args.append(include_path.getPath(b)); | 1778 | try zig_args.append(include_path.getPath(b)); |
| 1773 | }, | 1779 | }, |
| 1774 | .path_system => |include_path| { | 1780 | .path_system => |include_path| { |
| 1775 | if (b.sysroot != null) { | 1781 | try zig_args.append("-isystem"); |
| 1776 | try zig_args.append("-iwithsysroot"); | 1782 | try zig_args.append(include_path.getPath(b)); |
| 1777 | } else { | 1783 | }, |
| 1778 | try zig_args.append("-isystem"); | 1784 | .framework_path => |include_path| { |
| 1779 | } | 1785 | try zig_args.append("-F"); |
| 1780 | 1786 | try zig_args.append(include_path.getPath2(b, step)); | |
| 1781 | const resolved_include_path = include_path.getPath(b); | 1787 | }, |
| 1782 | 1788 | .framework_path_system => |include_path| { | |
| 1783 | const common_include_path = if (builtin.os.tag == .windows and b.sysroot != null and fs.path.isAbsolute(resolved_include_path)) blk: { | 1789 | try zig_args.append("-iframework"); |
| 1784 | // We need to check for disk designator and strip it out from dir path so | 1790 | try zig_args.append(include_path.getPath2(b, step)); |
| 1785 | // that zig/clang can concat resolved_include_path with sysroot. | ||
| 1786 | const disk_designator = fs.path.diskDesignatorWindows(resolved_include_path); | ||
| 1787 | |||
| 1788 | if (mem.indexOf(u8, resolved_include_path, disk_designator)) |where| { | ||
| 1789 | break :blk resolved_include_path[where + disk_designator.len ..]; | ||
| 1790 | } | ||
| 1791 | |||
| 1792 | break :blk resolved_include_path; | ||
| 1793 | } else resolved_include_path; | ||
| 1794 | |||
| 1795 | try zig_args.append(common_include_path); | ||
| 1796 | }, | 1791 | }, |
| 1797 | .other_step => |other| { | 1792 | .other_step => |other| { |
| 1798 | if (other.generated_h) |header| { | 1793 | if (other.generated_h) |header| { |
| ... | @@ -1847,17 +1842,6 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { | ... | @@ -1847,17 +1842,6 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1847 | zig_args.appendAssumeCapacity(rpath.getPath2(b, step)); | 1842 | zig_args.appendAssumeCapacity(rpath.getPath2(b, step)); |
| 1848 | } | 1843 | } |
| 1849 | 1844 | ||
| 1850 | for (self.framework_dirs.items) |directory_source| { | ||
| 1851 | if (b.sysroot != null) { | ||
| 1852 | try zig_args.append("-iframeworkwithsysroot"); | ||
| 1853 | } else { | ||
| 1854 | try zig_args.append("-iframework"); | ||
| 1855 | } | ||
| 1856 | try zig_args.append(directory_source.getPath2(b, step)); | ||
| 1857 | try zig_args.append("-F"); | ||
| 1858 | try zig_args.append(directory_source.getPath2(b, step)); | ||
| 1859 | } | ||
| 1860 | |||
| 1861 | { | 1845 | { |
| 1862 | var it = self.frameworks.iterator(); | 1846 | var it = self.frameworks.iterator(); |
| 1863 | while (it.next()) |entry| { | 1847 | while (it.next()) |entry| { |
lib/std/macho.zig+10| ... | @@ -1898,6 +1898,16 @@ pub const LoadCommandIterator = struct { | ... | @@ -1898,6 +1898,16 @@ pub const LoadCommandIterator = struct { |
| 1898 | const data = lc.data[rpath_lc.path..]; | 1898 | const data = lc.data[rpath_lc.path..]; |
| 1899 | return mem.sliceTo(data, 0); | 1899 | return mem.sliceTo(data, 0); |
| 1900 | } | 1900 | } |
| 1901 | |||
| 1902 | /// Asserts LoadCommand is of type build_version_command. | ||
| 1903 | pub fn getBuildVersionTools(lc: LoadCommand) []const build_tool_version { | ||
| 1904 | const build_lc = lc.cast(build_version_command).?; | ||
| 1905 | const ntools = build_lc.ntools; | ||
| 1906 | if (ntools == 0) return &[0]build_tool_version{}; | ||
| 1907 | const data = lc.data[@sizeOf(build_version_command)..]; | ||
| 1908 | const tools = @as([*]const build_tool_version, @ptrCast(@alignCast(&data[0])))[0..ntools]; | ||
| 1909 | return tools; | ||
| 1910 | } | ||
| 1901 | }; | 1911 | }; |
| 1902 | 1912 | ||
| 1903 | pub fn next(it: *LoadCommandIterator) ?LoadCommand { | 1913 | pub fn next(it: *LoadCommandIterator) ?LoadCommand { |
src/main.zig+24-4| ... | @@ -1156,12 +1156,20 @@ fn buildOutputType( | ... | @@ -1156,12 +1156,20 @@ fn buildOutputType( |
| 1156 | try clang_argv.append(args_iter.nextOrFatal()); | 1156 | try clang_argv.append(args_iter.nextOrFatal()); |
| 1157 | } else if (mem.eql(u8, arg, "-I")) { | 1157 | } else if (mem.eql(u8, arg, "-I")) { |
| 1158 | try cssan.addIncludePath(.I, arg, args_iter.nextOrFatal(), false); | 1158 | try cssan.addIncludePath(.I, arg, args_iter.nextOrFatal(), false); |
| 1159 | } else if (mem.eql(u8, arg, "-isystem") or mem.eql(u8, arg, "-iwithsysroot")) { | 1159 | } else if (mem.eql(u8, arg, "-isystem")) { |
| 1160 | try cssan.addIncludePath(.isystem, arg, args_iter.nextOrFatal(), false); | 1160 | try cssan.addIncludePath(.isystem, arg, args_iter.nextOrFatal(), false); |
| 1161 | } else if (mem.eql(u8, arg, "-iwithsysroot")) { | ||
| 1162 | try cssan.addIncludePath(.iwithsysroot, arg, args_iter.nextOrFatal(), false); | ||
| 1161 | } else if (mem.eql(u8, arg, "-idirafter")) { | 1163 | } else if (mem.eql(u8, arg, "-idirafter")) { |
| 1162 | try cssan.addIncludePath(.idirafter, arg, args_iter.nextOrFatal(), false); | 1164 | try cssan.addIncludePath(.idirafter, arg, args_iter.nextOrFatal(), false); |
| 1163 | } else if (mem.eql(u8, arg, "-iframework") or mem.eql(u8, arg, "-iframeworkwithsysroot")) { | 1165 | } else if (mem.eql(u8, arg, "-iframework")) { |
| 1164 | try cssan.addIncludePath(.iframework, arg, args_iter.nextOrFatal(), false); | 1166 | const path = args_iter.nextOrFatal(); |
| 1167 | try cssan.addIncludePath(.iframework, arg, path, false); | ||
| 1168 | try framework_dirs.append(path); // Forward to the backend as -F | ||
| 1169 | } else if (mem.eql(u8, arg, "-iframeworkwithsysroot")) { | ||
| 1170 | const path = args_iter.nextOrFatal(); | ||
| 1171 | try cssan.addIncludePath(.iframeworkwithsysroot, arg, path, false); | ||
| 1172 | try framework_dirs.append(path); // Forward to the backend as -F | ||
| 1165 | } else if (mem.eql(u8, arg, "--version")) { | 1173 | } else if (mem.eql(u8, arg, "--version")) { |
| 1166 | const next_arg = args_iter.nextOrFatal(); | 1174 | const next_arg = args_iter.nextOrFatal(); |
| 1167 | version = std.SemanticVersion.parse(next_arg) catch |err| { | 1175 | version = std.SemanticVersion.parse(next_arg) catch |err| { |
| ... | @@ -6191,6 +6199,11 @@ const ClangSearchSanitizer = struct { | ... | @@ -6191,6 +6199,11 @@ const ClangSearchSanitizer = struct { |
| 6191 | if (m.idirafter) std.log.warn(wtxt, .{ dir, "isystem", "idirafter" }); | 6199 | if (m.idirafter) std.log.warn(wtxt, .{ dir, "isystem", "idirafter" }); |
| 6192 | if (m.iframework) std.log.warn(wtxt, .{ dir, "isystem", "iframework" }); | 6200 | if (m.iframework) std.log.warn(wtxt, .{ dir, "isystem", "iframework" }); |
| 6193 | }, | 6201 | }, |
| 6202 | .iwithsysroot => { | ||
| 6203 | if (m.iwithsysroot) return; | ||
| 6204 | m.iwithsysroot = true; | ||
| 6205 | if (m.iframeworkwithsysroot) std.log.warn(wtxt, .{ dir, "iwithsysroot", "iframeworkwithsysroot" }); | ||
| 6206 | }, | ||
| 6194 | .idirafter => { | 6207 | .idirafter => { |
| 6195 | if (m.idirafter) return; | 6208 | if (m.idirafter) return; |
| 6196 | m.idirafter = true; | 6209 | m.idirafter = true; |
| ... | @@ -6205,18 +6218,25 @@ const ClangSearchSanitizer = struct { | ... | @@ -6205,18 +6218,25 @@ const ClangSearchSanitizer = struct { |
| 6205 | if (m.isystem) std.log.warn(wtxt, .{ dir, "iframework", "isystem" }); | 6218 | if (m.isystem) std.log.warn(wtxt, .{ dir, "iframework", "isystem" }); |
| 6206 | if (m.idirafter) std.log.warn(wtxt, .{ dir, "iframework", "idirafter" }); | 6219 | if (m.idirafter) std.log.warn(wtxt, .{ dir, "iframework", "idirafter" }); |
| 6207 | }, | 6220 | }, |
| 6221 | .iframeworkwithsysroot => { | ||
| 6222 | if (m.iframeworkwithsysroot) return; | ||
| 6223 | m.iframeworkwithsysroot = true; | ||
| 6224 | if (m.iwithsysroot) std.log.warn(wtxt, .{ dir, "iframeworkwithsysroot", "iwithsysroot" }); | ||
| 6225 | }, | ||
| 6208 | } | 6226 | } |
| 6209 | try self.argv.append(arg); | 6227 | try self.argv.append(arg); |
| 6210 | if (!joined) try self.argv.append(dir); | 6228 | if (!joined) try self.argv.append(dir); |
| 6211 | } | 6229 | } |
| 6212 | 6230 | ||
| 6213 | const Group = enum { I, isystem, idirafter, iframework }; | 6231 | const Group = enum { I, isystem, iwithsysroot, idirafter, iframework, iframeworkwithsysroot }; |
| 6214 | 6232 | ||
| 6215 | const Membership = packed struct { | 6233 | const Membership = packed struct { |
| 6216 | I: bool = false, | 6234 | I: bool = false, |
| 6217 | isystem: bool = false, | 6235 | isystem: bool = false, |
| 6236 | iwithsysroot: bool = false, | ||
| 6218 | idirafter: bool = false, | 6237 | idirafter: bool = false, |
| 6219 | iframework: bool = false, | 6238 | iframework: bool = false, |
| 6239 | iframeworkwithsysroot: bool = false, | ||
| 6220 | }; | 6240 | }; |
| 6221 | }; | 6241 | }; |
| 6222 | 6242 |
test/standalone.zig+4| ... | @@ -245,6 +245,10 @@ pub const build_cases = [_]BuildCase{ | ... | @@ -245,6 +245,10 @@ pub const build_cases = [_]BuildCase{ |
| 245 | .build_root = "test/standalone/compiler_rt_panic", | 245 | .build_root = "test/standalone/compiler_rt_panic", |
| 246 | .import = @import("standalone/compiler_rt_panic/build.zig"), | 246 | .import = @import("standalone/compiler_rt_panic/build.zig"), |
| 247 | }, | 247 | }, |
| 248 | .{ | ||
| 249 | .build_root = "test/standalone/ios", | ||
| 250 | .import = @import("standalone/ios/build.zig"), | ||
| 251 | }, | ||
| 248 | }; | 252 | }; |
| 249 | 253 | ||
| 250 | const std = @import("std"); | 254 | const std = @import("std"); |
test/standalone/ios/build.zig created+37| ... | @@ -0,0 +1,37 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | pub const requires_symlinks = true; | ||
| 4 | pub const requires_ios_sdk = true; | ||
| 5 | |||
| 6 | pub fn build(b: *std.Build) void { | ||
| 7 | const test_step = b.step("test", "Test it"); | ||
| 8 | b.default_step = test_step; | ||
| 9 | |||
| 10 | const optimize: std.builtin.OptimizeMode = .Debug; | ||
| 11 | const target: std.zig.CrossTarget = .{ | ||
| 12 | .cpu_arch = .aarch64, | ||
| 13 | .os_tag = .ios, | ||
| 14 | }; | ||
| 15 | const target_info = std.zig.system.NativeTargetInfo.detect(target) catch @panic("couldn't detect native target"); | ||
| 16 | const sdk = std.zig.system.darwin.getSdk(b.allocator, target_info.target) orelse @panic("no iOS SDK found"); | ||
| 17 | b.sysroot = sdk.path; | ||
| 18 | |||
| 19 | const exe = b.addExecutable(.{ | ||
| 20 | .name = "main", | ||
| 21 | .optimize = optimize, | ||
| 22 | .target = target, | ||
| 23 | }); | ||
| 24 | exe.addCSourceFile(.{ .file = .{ .path = "main.m" }, .flags = &.{} }); | ||
| 25 | exe.addSystemIncludePath(.{ .path = b.pathJoin(&.{ sdk.path, "/usr/include" }) }); | ||
| 26 | exe.addSystemFrameworkPath(.{ .path = b.pathJoin(&.{ sdk.path, "/System/Library/Frameworks" }) }); | ||
| 27 | exe.addLibraryPath(.{ .path = b.pathJoin(&.{ sdk.path, "/usr/lib" }) }); | ||
| 28 | exe.linkFramework("Foundation"); | ||
| 29 | exe.linkFramework("UIKit"); | ||
| 30 | exe.linkLibC(); | ||
| 31 | |||
| 32 | const check = exe.checkObject(); | ||
| 33 | check.checkStart(); | ||
| 34 | check.checkExact("cmd BUILD_VERSION"); | ||
| 35 | check.checkExact("platform IOS"); | ||
| 36 | test_step.dependOn(&check.step); | ||
| 37 | } | ||
test/standalone/ios/main.m created+34| ... | @@ -0,0 +1,34 @@ | ||
| 1 | #import <UIKit/UIKit.h> | ||
| 2 | |||
| 3 | @interface AppDelegate : UIResponder <UIApplicationDelegate> | ||
| 4 | @property (strong, nonatomic) UIWindow *window; | ||
| 5 | @end | ||
| 6 | |||
| 7 | int main() { | ||
| 8 | @autoreleasepool { | ||
| 9 | return UIApplicationMain(0, nil, nil, NSStringFromClass([AppDelegate class])); | ||
| 10 | } | ||
| 11 | } | ||
| 12 | |||
| 13 | @implementation AppDelegate | ||
| 14 | |||
| 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(id)options { | ||
| 16 | CGRect mainScreenBounds = [[UIScreen mainScreen] bounds]; | ||
| 17 | self.window = [[UIWindow alloc] initWithFrame:mainScreenBounds]; | ||
| 18 | UIViewController *viewController = [[UIViewController alloc] init]; | ||
| 19 | viewController.view.frame = mainScreenBounds; | ||
| 20 | |||
| 21 | NSString* msg = @"Hello world"; | ||
| 22 | |||
| 23 | UILabel *label = [[UILabel alloc] initWithFrame:mainScreenBounds]; | ||
| 24 | [label setText:msg]; | ||
| 25 | [viewController.view addSubview: label]; | ||
| 26 | |||
| 27 | self.window.rootViewController = viewController; | ||
| 28 | |||
| 29 | [self.window makeKeyAndVisible]; | ||
| 30 | |||
| 31 | return YES; | ||
| 32 | } | ||
| 33 | |||
| 34 | @end | ||
test/tests.zig+10-2| ... | @@ -566,6 +566,7 @@ pub fn addStandaloneTests( | ... | @@ -566,6 +566,7 @@ pub fn addStandaloneTests( |
| 566 | b: *std.Build, | 566 | b: *std.Build, |
| 567 | optimize_modes: []const OptimizeMode, | 567 | optimize_modes: []const OptimizeMode, |
| 568 | enable_macos_sdk: bool, | 568 | enable_macos_sdk: bool, |
| 569 | enable_ios_sdk: bool, | ||
| 569 | omit_stage2: bool, | 570 | omit_stage2: bool, |
| 570 | enable_symlinks_windows: bool, | 571 | enable_symlinks_windows: bool, |
| 571 | ) *Step { | 572 | ) *Step { |
| ... | @@ -615,10 +616,13 @@ pub fn addStandaloneTests( | ... | @@ -615,10 +616,13 @@ pub fn addStandaloneTests( |
| 615 | case.import.requires_symlinks; | 616 | case.import.requires_symlinks; |
| 616 | const requires_macos_sdk = @hasDecl(case.import, "requires_macos_sdk") and | 617 | const requires_macos_sdk = @hasDecl(case.import, "requires_macos_sdk") and |
| 617 | case.import.requires_macos_sdk; | 618 | case.import.requires_macos_sdk; |
| 619 | const requires_ios_sdk = @hasDecl(case.import, "requires_ios_sdk") and | ||
| 620 | case.import.requires_ios_sdk; | ||
| 618 | const bad = | 621 | const bad = |
| 619 | (requires_stage2 and omit_stage2) or | 622 | (requires_stage2 and omit_stage2) or |
| 620 | (requires_symlinks and omit_symlinks) or | 623 | (requires_symlinks and omit_symlinks) or |
| 621 | (requires_macos_sdk and !enable_macos_sdk); | 624 | (requires_macos_sdk and !enable_macos_sdk) or |
| 625 | (requires_ios_sdk and !enable_ios_sdk); | ||
| 622 | if (!bad) { | 626 | if (!bad) { |
| 623 | const dep = b.anonymousDependency(case.build_root, case.import, .{}); | 627 | const dep = b.anonymousDependency(case.build_root, case.import, .{}); |
| 624 | const dep_step = dep.builder.default_step; | 628 | const dep_step = dep.builder.default_step; |
| ... | @@ -635,6 +639,7 @@ pub fn addStandaloneTests( | ... | @@ -635,6 +639,7 @@ pub fn addStandaloneTests( |
| 635 | pub fn addLinkTests( | 639 | pub fn addLinkTests( |
| 636 | b: *std.Build, | 640 | b: *std.Build, |
| 637 | enable_macos_sdk: bool, | 641 | enable_macos_sdk: bool, |
| 642 | enable_ios_sdk: bool, | ||
| 638 | omit_stage2: bool, | 643 | omit_stage2: bool, |
| 639 | enable_symlinks_windows: bool, | 644 | enable_symlinks_windows: bool, |
| 640 | ) *Step { | 645 | ) *Step { |
| ... | @@ -648,10 +653,13 @@ pub fn addLinkTests( | ... | @@ -648,10 +653,13 @@ pub fn addLinkTests( |
| 648 | case.import.requires_symlinks; | 653 | case.import.requires_symlinks; |
| 649 | const requires_macos_sdk = @hasDecl(case.import, "requires_macos_sdk") and | 654 | const requires_macos_sdk = @hasDecl(case.import, "requires_macos_sdk") and |
| 650 | case.import.requires_macos_sdk; | 655 | case.import.requires_macos_sdk; |
| 656 | const requires_ios_sdk = @hasDecl(case.import, "requires_ios_sdk") and | ||
| 657 | case.import.requires_ios_sdk; | ||
| 651 | const bad = | 658 | const bad = |
| 652 | (requires_stage2 and omit_stage2) or | 659 | (requires_stage2 and omit_stage2) or |
| 653 | (requires_symlinks and omit_symlinks) or | 660 | (requires_symlinks and omit_symlinks) or |
| 654 | (requires_macos_sdk and !enable_macos_sdk); | 661 | (requires_macos_sdk and !enable_macos_sdk) or |
| 662 | (requires_ios_sdk and !enable_ios_sdk); | ||
| 655 | if (!bad) { | 663 | if (!bad) { |
| 656 | const dep = b.anonymousDependency(case.build_root, case.import, .{}); | 664 | const dep = b.anonymousDependency(case.build_root, case.import, .{}); |
| 657 | const dep_step = dep.builder.default_step; | 665 | const dep_step = dep.builder.default_step; |