fix honey compiler blockers
This commit is contained in:
+25
-23
@@ -66,10 +66,10 @@ load_build_config :: proc(project_root: string) -> (BuildConfig, bool) {
|
||||
return {}, false
|
||||
}
|
||||
// check needs no `main`: it synthesizes a trap main and emits one benign
|
||||
// "missing main" diagnostic, which is expected for build.bro. Suppress that
|
||||
// one but surface any real errors in build.bro (and fail on them).
|
||||
// "missing main" diagnostic, which is expected for a build config. Suppress
|
||||
// that one but surface any real errors in the build config (and fail on them).
|
||||
hir_module := checker.check(&ast_module, &diagnostics, &symbols, target.DEFAULT, a)
|
||||
if build_bro_has_errors(&diagnostics) {
|
||||
if build_config_has_errors(&diagnostics) {
|
||||
source.print_all(&diagnostics)
|
||||
return {}, false
|
||||
}
|
||||
@@ -82,14 +82,14 @@ project_root_for_command :: proc(root, command: string) -> (string, bool, bool)
|
||||
}
|
||||
project_root, found := find_build_root()
|
||||
if !found {
|
||||
fmt.eprintfln("brolang %s: could not find build.bro in the current directory or any parent", command)
|
||||
fmt.eprintfln("brolang %s: could not find build.bro or build.hon in the current directory or any parent", command)
|
||||
return "", false, false
|
||||
}
|
||||
return project_root, true, true
|
||||
}
|
||||
|
||||
// run_build implements `brolang build [root]`: it reads build.bro and compiles
|
||||
// the configured program package.
|
||||
// run_build implements `brolang build [root]`: it reads the build config and
|
||||
// compiles the configured program package.
|
||||
run_build :: proc(root: string) -> int {
|
||||
project_root, owned, found := project_root_for_command(root, "build")
|
||||
if !found {
|
||||
@@ -161,7 +161,7 @@ valid_output_name :: proc(name: string) -> bool {
|
||||
|
||||
build_output_path :: proc(project_root, name: string, allocator := context.allocator) -> (string, bool) {
|
||||
if !valid_output_name(name) {
|
||||
fmt.eprintfln("build.bro: config 'name' must be a plain executable name, got '%s'", name)
|
||||
fmt.eprintfln("build config: config 'name' must be a plain executable name, got '%s'", name)
|
||||
return "", false
|
||||
}
|
||||
build_dir, dir_error := filepath.join({project_root, "build"}, allocator)
|
||||
@@ -202,15 +202,17 @@ find_build_root_from :: proc(start: string, allocator := context.allocator) -> (
|
||||
current = strings.clone(start, allocator)
|
||||
}
|
||||
for {
|
||||
build_path, build_error := filepath.join({current, "build.bro"}, allocator)
|
||||
if build_error != nil {
|
||||
delete(current, allocator)
|
||||
return "", false
|
||||
}
|
||||
found := os.exists(build_path)
|
||||
delete(build_path, allocator)
|
||||
if found {
|
||||
return current, true
|
||||
for build_file in ([?]string{"build.bro", "build.hon"}) {
|
||||
build_path, build_error := filepath.join({current, build_file}, allocator)
|
||||
if build_error != nil {
|
||||
delete(current, allocator)
|
||||
return "", false
|
||||
}
|
||||
found := os.exists(build_path)
|
||||
delete(build_path, allocator)
|
||||
if found {
|
||||
return current, true
|
||||
}
|
||||
}
|
||||
if current == "/" {
|
||||
delete(current, allocator)
|
||||
@@ -227,10 +229,10 @@ find_build_root_from :: proc(start: string, allocator := context.allocator) -> (
|
||||
}
|
||||
}
|
||||
|
||||
// build_bro_has_errors reports whether checking build.bro produced any diagnostic
|
||||
// other than the benign "missing or unusable main function" (build.bro has no
|
||||
// main by design; that one is emitted with an empty span).
|
||||
build_bro_has_errors :: proc(diagnostics: ^source.Diagnostics) -> bool {
|
||||
// build_config_has_errors reports whether checking a build config produced any
|
||||
// diagnostic other than the benign "missing or unusable main function" (build
|
||||
// configs have no main by design; that one is emitted with an empty span).
|
||||
build_config_has_errors :: proc(diagnostics: ^source.Diagnostics) -> bool {
|
||||
for item in diagnostics.items {
|
||||
if item.span == (source.Span{}) && item.message == "missing or unusable main function" {
|
||||
continue
|
||||
@@ -255,12 +257,12 @@ extract_build_config :: proc(m: ^hir.Module, symbols: ^symbol.Table) -> (BuildCo
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
fmt.eprintln("build.bro: missing top-level 'config' constant")
|
||||
fmt.eprintln("build config: missing top-level 'config' constant")
|
||||
return {}, false
|
||||
}
|
||||
root := unwrap_coercions(m, config_expr)
|
||||
if root == hir.INVALID_EXPR || m.exprs[root].kind != .Struct {
|
||||
fmt.eprintln("build.bro: 'config' must be a BuildConfig{...} literal")
|
||||
fmt.eprintln("build config: 'config' must be a BuildConfig{...} literal")
|
||||
return {}, false
|
||||
}
|
||||
args := m.exprs[root].args
|
||||
@@ -322,7 +324,7 @@ extract_build_config :: proc(m: ^hir.Module, symbols: ^symbol.Table) -> (BuildCo
|
||||
cfg.c_options.defines = defines[:]
|
||||
|
||||
if len(cfg.output_name) == 0 || len(cfg.source_dir) == 0 {
|
||||
fmt.eprintln("build.bro: config requires non-empty 'name' and 'source'")
|
||||
fmt.eprintln("build config: config requires non-empty 'name' and 'source'")
|
||||
destroy_build_config(&cfg)
|
||||
return {}, false
|
||||
}
|
||||
|
||||
@@ -1677,7 +1677,7 @@ is_opaque_struct :: proc(value: Type, store: ^Store) -> bool {
|
||||
size :: proc(value: Type, store: ^Store, selected := target.DEFAULT) -> u64 {
|
||||
#partial switch kind(value, store) {
|
||||
case .Scalar:
|
||||
return u64(bits(value, selected)/8)
|
||||
return u64((bits(value, selected)+7)/8)
|
||||
case .Pointer:
|
||||
return u64(target.pointer_bits(selected)/8)
|
||||
case .Slice:
|
||||
|
||||
Reference in New Issue
Block a user