mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
Merge pull request #4546 from thetarnav/correct-parsing-build-tag-newlines
Correct handling newlines between build tags in `core:odin`
This commit is contained in:
@@ -17,6 +17,9 @@ Build_Kind :: struct {
|
|||||||
arch: runtime.Odin_Arch_Types,
|
arch: runtime.Odin_Arch_Types,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// empty build kind acts as a marker for separating multiple lines with build tags
|
||||||
|
BUILD_KIND_NEWLINE_MARKER :: Build_Kind{}
|
||||||
|
|
||||||
File_Tags :: struct {
|
File_Tags :: struct {
|
||||||
build_project_name: [][]string,
|
build_project_name: [][]string,
|
||||||
build: []Build_Kind,
|
build: []Build_Kind,
|
||||||
@@ -147,6 +150,11 @@ parse_file_tags :: proc(file: ast.File, allocator := context.allocator) -> (tags
|
|||||||
append(build_project_names, build_project_name_strings[index_start:])
|
append(build_project_names, build_project_name_strings[index_start:])
|
||||||
}
|
}
|
||||||
case "build":
|
case "build":
|
||||||
|
|
||||||
|
if len(build_kinds) > 0 {
|
||||||
|
append(build_kinds, BUILD_KIND_NEWLINE_MARKER)
|
||||||
|
}
|
||||||
|
|
||||||
kinds_loop: for {
|
kinds_loop: for {
|
||||||
os_positive: runtime.Odin_OS_Types
|
os_positive: runtime.Odin_OS_Types
|
||||||
os_negative: runtime.Odin_OS_Types
|
os_negative: runtime.Odin_OS_Types
|
||||||
@@ -248,10 +256,20 @@ match_build_tags :: proc(file_tags: File_Tags, target: Build_Target) -> bool {
|
|||||||
project_name_correct ||= group_correct
|
project_name_correct ||= group_correct
|
||||||
}
|
}
|
||||||
|
|
||||||
os_and_arch_correct := len(file_tags.build) == 0
|
os_and_arch_correct := true
|
||||||
|
|
||||||
for kind in file_tags.build {
|
if len(file_tags.build) > 0 {
|
||||||
os_and_arch_correct ||= target.os in kind.os && target.arch in kind.arch
|
os_and_arch_correct_line := false
|
||||||
|
|
||||||
|
for kind in file_tags.build {
|
||||||
|
if kind == BUILD_KIND_NEWLINE_MARKER {
|
||||||
|
os_and_arch_correct &&= os_and_arch_correct_line
|
||||||
|
os_and_arch_correct_line = false
|
||||||
|
} else {
|
||||||
|
os_and_arch_correct_line ||= target.os in kind.os && target.arch in kind.arch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os_and_arch_correct &&= os_and_arch_correct_line
|
||||||
}
|
}
|
||||||
|
|
||||||
return !file_tags.ignore && project_name_correct && os_and_arch_correct
|
return !file_tags.ignore && project_name_correct && os_and_arch_correct
|
||||||
|
|||||||
@@ -46,14 +46,16 @@ package main
|
|||||||
{os = {.OpenBSD}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
{os = {.OpenBSD}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
||||||
{os = {.NetBSD}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
{os = {.NetBSD}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
||||||
{os = {.Haiku}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
{os = {.Haiku}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
||||||
|
parser.BUILD_KIND_NEWLINE_MARKER,
|
||||||
{os = runtime.ALL_ODIN_OS_TYPES, arch = {.arm32}},
|
{os = runtime.ALL_ODIN_OS_TYPES, arch = {.arm32}},
|
||||||
{os = runtime.ALL_ODIN_OS_TYPES, arch = {.arm64}},
|
{os = runtime.ALL_ODIN_OS_TYPES, arch = {.arm64}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
matching_targets = {
|
matching_targets = {
|
||||||
{{.Linux, .amd64, "foo"}, true},
|
{{.Linux, .amd64, "foo"}, false},
|
||||||
{{.Windows, .arm64, "foo"}, true},
|
{{.Linux, .arm64, "foo"}, true},
|
||||||
{{.Windows, .amd64, "foo"}, false},
|
{{.Windows, .amd64, "foo"}, false},
|
||||||
|
{{.Windows, .arm64, "foo"}, false},
|
||||||
},
|
},
|
||||||
}, {// [3]
|
}, {// [3]
|
||||||
src = `
|
src = `
|
||||||
@@ -82,17 +84,12 @@ package main
|
|||||||
tags = {
|
tags = {
|
||||||
build_project_name = {{"foo", "!bar"}, {"baz"}},
|
build_project_name = {{"foo", "!bar"}, {"baz"}},
|
||||||
build = {
|
build = {
|
||||||
{
|
{os = {.JS}, arch = {.wasm32}},
|
||||||
os = {.JS},
|
{os = {.JS}, arch = {.wasm64p32}},
|
||||||
arch = {.wasm32},
|
|
||||||
}, {
|
|
||||||
os = {.JS},
|
|
||||||
arch = {.wasm64p32},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
matching_targets = {
|
matching_targets = {
|
||||||
{{.JS, .wasm32, "foo"}, true},
|
{{.JS, .wasm32, "foo"}, true},
|
||||||
{{.JS, .wasm64p32, "baz"}, true},
|
{{.JS, .wasm64p32, "baz"}, true},
|
||||||
{{.JS, .wasm64p32, "bar"}, false},
|
{{.JS, .wasm64p32, "bar"}, false},
|
||||||
},
|
},
|
||||||
@@ -108,9 +105,9 @@ package main`,
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
matching_targets = {
|
matching_targets = {
|
||||||
{{.Freestanding, .wasm32, ""}, true},
|
{{.Freestanding, .wasm32, ""}, true},
|
||||||
{{.Freestanding, .wasm64p32, ""}, true},
|
{{.Freestanding, .wasm64p32, ""}, true},
|
||||||
{{.Freestanding, .arm64, ""}, false},
|
{{.Freestanding, .arm64, ""}, false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user