Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/v2/compiler/emit_host.dag
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ import v2.std.host_transport {
EmittedSource,
EmittedWithSuffix,
FixedText,
HostToolProgram,
InvocationArg,
LiteralArg,
ProcessInvocation,
ProcessProgram,
ProducedArtifact,
ProducedProgram,
WorkspaceContent,
WorkspacePath,
runtime_value_parse_from_row
Expand Down Expand Up @@ -161,11 +164,21 @@ fn emit_host_list_map<T, U>(xs: List<T>, f: fn(T) -> U) -> List<U> {
fn host_tool_program_name(tool: Symbol) -> Outcome<String> {
if tool == ^host_tool_cargo {
Accepted { value: "cargo", diagnostics: None }
} else if tool == ^host_tool_cc {
Accepted { value: "cc", diagnostics: None }
} else {
outcome_rejected(d: emit_host_unknown_host_tool_diagnostic())
}
}

fn process_program_name(program: ProcessProgram) -> Outcome<String> {
match program {
HostToolProgram { tool: t } => host_tool_program_name(tool: t)
ProducedProgram { path: p } =>
Accepted { value: concat("./", p), diagnostics: None }
}
}

fn invocation_arg_text(arg: InvocationArg) -> String {
match arg {
LiteralArg { text: t } => t
Expand All @@ -176,7 +189,7 @@ fn invocation_arg_text(arg: InvocationArg) -> String {

fn invocation_argv(inv: ProcessInvocation) -> Outcome<List<String>> {
bind_outcome(
o: host_tool_program_name(tool: inv.tool),
o: process_program_name(program: inv.program),
f: fn(program) {
Accepted {
value: concat(
Expand Down
58 changes: 56 additions & 2 deletions src/v2/extdeps/languages/cpp.dag
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
module v2.extdeps.languages.cpp
import v2.std.language_model { LanguageModel }

import v2.std.host_transport { target_emit_host_runtime_row_unconfigured }
import v2.std.host_transport {
EmitHostRuntimeRow,
EmittedWithSuffix,
FixedWidthBytes,
HostRuntimeRowPresent,
HostToolProgram,
HostTransportDescriptor,
LiteralArg,
ProcessInvocation,
ProducedProgram,
TargetEmitHostRuntimeRow,
WorkspaceFile
}
import v2.std.grammar {
VoidGrammar,
StampClass,
Expand Down Expand Up @@ -1199,7 +1211,49 @@ fn cpp_target_model_for_profile(target_profile: Node) -> TargetModel {
binding_spellings: cpp_binding_spellings(),
token_class_emit_transforms: target_model_emit_transforms_empty,
authority_source_text: cpp_source_text,
runtime_row: target_emit_host_runtime_row_unconfigured
runtime_row: cpp_runtime_row()
}
}

data c_emit_host_main_suffix: String = "\n\nextern long write(int, const void *, unsigned long);\nint main(void) { int value = add(2, 3); unsigned char b[5] = {0, (unsigned char)(value & 0xff), (unsigned char)((value >> 8) & 0xff), (unsigned char)((value >> 16) & 0xff), (unsigned char)((value >> 24) & 0xff)}; write(1, b, 5); return 0; }\n"

fn cpp_emit_host_runtime_primitive_type_node() -> Node {
Node {
kind: TypeNode { connective: Atom { identity: ^cpp_emit_host_runtime_primitive_symbol } },
children: [],
occurrence_id: SyntheticOccurrence
}
}

fn cpp_host_transport_descriptor() -> HostTransportDescriptor {
HostTransportDescriptor {
identity: ^cpp_host_transport_identity,
workspace: [
WorkspaceFile {
path: "fixture.c",
content: EmittedWithSuffix { suffix: c_emit_host_main_suffix }
}
],
build: [
ProcessInvocation {
program: HostToolProgram { tool: ^host_tool_cc },
args: [LiteralArg { text: "fixture.c" }, LiteralArg { text: "-o" }, LiteralArg { text: "fixture" }]
}
],
run: ProcessInvocation {
program: ProducedProgram { path: "fixture" },
args: []
},
runtime_value_codec: FixedWidthBytes { width: 5 }
}
}

fn cpp_runtime_row() -> TargetEmitHostRuntimeRow {
HostRuntimeRowPresent {
row: EmitHostRuntimeRow {
transport: cpp_host_transport_descriptor(),
runtime_primitive_type: cpp_emit_host_runtime_primitive_type_node()
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/v2/extdeps/languages/go.dag
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import v2.std.host_transport {
HostRuntimeRowPresent,
TargetEmitHostRuntimeRow,
FixedWidthBytes,
HostToolProgram,
HostTransportDescriptor,
LiteralArg,
ProcessInvocation,
Expand Down Expand Up @@ -1802,7 +1803,7 @@ fn go_host_transport_descriptor() -> HostTransportDescriptor {
],
build: Empty,
run: ProcessInvocation {
tool: ^host_tool_go,
program: HostToolProgram { tool: ^host_tool_go },
args: [
LiteralArg { text: "run" },
WorkspacePath { path: "main.go" }
Expand Down
3 changes: 2 additions & 1 deletion src/v2/extdeps/languages/python.dag
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import v2.std.host_transport {
HostRuntimeRowPresent,
TargetEmitHostRuntimeRow,
FixedWidthBytes,
HostToolProgram,
HostTransportDescriptor,
ProcessInvocation,
WorkspaceContent,
Expand Down Expand Up @@ -1149,7 +1150,7 @@ fn python_host_transport_descriptor() -> HostTransportDescriptor {
],
build: Empty,
run: ProcessInvocation {
tool: ^host_tool_python3,
program: HostToolProgram { tool: ^host_tool_python3 },
args: [WorkspacePath { path: "fixture.py" }]
},
runtime_value_codec: FixedWidthBytes { width: 5 }
Expand Down
5 changes: 3 additions & 2 deletions src/v2/extdeps/languages/rust.dag
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ import v2.std.host_transport {
EmittedWithSuffix,
FixedText,
FixedWidthBytes,
HostToolProgram,
HostTransportDescriptor,
LiteralArg,
ProcessInvocation,
Expand Down Expand Up @@ -1858,12 +1859,12 @@ fn rust_host_transport_descriptor() -> HostTransportDescriptor {
],
build: [
ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "build" }, LiteralArg { text: "--quiet" }]
}
],
run: ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "run" }, LiteralArg { text: "--quiet" }]
},
runtime_value_codec: FixedWidthBytes { width: 5 }
Expand Down
37 changes: 19 additions & 18 deletions src/v2/extdeps/languages/rust_test.dag
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import v2.std.host_transport {
EmittedWithSuffix,
FixedText,
FixedWidthBytes,
HostToolProgram,
HostTransportDescriptor,
LiteralArg,
ProcessInvocation,
Expand Down Expand Up @@ -638,12 +639,12 @@ fn rust_call_host_transport_descriptor() -> HostTransportDescriptor {
],
build: [
ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "build" }, LiteralArg { text: "--quiet" }]
}
],
run: ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "run" }, LiteralArg { text: "--quiet" }]
},
runtime_value_codec: FixedWidthBytes { width: 5 }
Expand Down Expand Up @@ -750,12 +751,12 @@ fn rust_match_host_transport_descriptor() -> HostTransportDescriptor {
],
build: [
ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "build" }, LiteralArg { text: "--quiet" }]
}
],
run: ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "run" }, LiteralArg { text: "--quiet" }]
},
runtime_value_codec: FixedWidthBytes { width: 5 }
Expand Down Expand Up @@ -799,12 +800,12 @@ fn rust_classical_not_ingested_host_transport_descriptor() -> HostTransportDescr
],
build: [
ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "build" }, LiteralArg { text: "--quiet" }]
}
],
run: ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "run" }, LiteralArg { text: "--quiet" }]
},
runtime_value_codec: FixedWidthBytes { width: 5 }
Expand Down Expand Up @@ -1164,12 +1165,12 @@ fn rust_field_access_host_transport_descriptor() -> HostTransportDescriptor {
],
build: [
ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "build" }, LiteralArg { text: "--quiet" }]
}
],
run: ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "run" }, LiteralArg { text: "--quiet" }]
},
runtime_value_codec: FixedWidthBytes { width: 5 }
Expand Down Expand Up @@ -1477,12 +1478,12 @@ fn rust_variant_construct_host_transport_descriptor() -> HostTransportDescriptor
],
build: [
ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "build" }, LiteralArg { text: "--quiet" }]
}
],
run: ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "run" }, LiteralArg { text: "--quiet" }]
},
runtime_value_codec: FixedWidthBytes { width: 5 }
Expand Down Expand Up @@ -1778,12 +1779,12 @@ fn rust_logic_complement_host_transport_descriptor() -> HostTransportDescriptor
],
build: [
ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "build" }, LiteralArg { text: "--quiet" }]
}
],
run: ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "run" }, LiteralArg { text: "--quiet" }]
},
runtime_value_codec: FixedWidthBytes { width: 5 }
Expand Down Expand Up @@ -2028,12 +2029,12 @@ fn rust_bool_fn_host_runtime_row(
],
build: [
ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "build" }, LiteralArg { text: "--quiet" }]
}
],
run: ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "run" }, LiteralArg { text: "--quiet" }]
},
runtime_value_codec: FixedWidthBytes { width: 5 }
Expand Down Expand Up @@ -2681,12 +2682,12 @@ fn rust_rec_nine_host_transport_descriptor() -> HostTransportDescriptor {
],
build: [
ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "build" }, LiteralArg { text: "--quiet" }]
}
],
run: ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "run" }, LiteralArg { text: "--quiet" }]
},
runtime_value_codec: FixedWidthBytes { width: 5 }
Expand Down Expand Up @@ -2996,12 +2997,12 @@ fn rust_fold_call_host_transport_descriptor() -> HostTransportDescriptor {
],
build: [
ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "build" }, LiteralArg { text: "--quiet" }]
}
],
run: ProcessInvocation {
tool: ^host_tool_cargo,
program: HostToolProgram { tool: ^host_tool_cargo },
args: [LiteralArg { text: "run" }, LiteralArg { text: "--quiet" }]
},
runtime_value_codec: FixedWidthBytes { width: 5 }
Expand Down
5 changes: 3 additions & 2 deletions src/v2/extdeps/languages/typescript.dag
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ import v2.std.host_transport {
HostRuntimeRowPresent,
TargetEmitHostRuntimeRow,
EmittedWithSuffix,
HostToolProgram,
HostTransportDescriptor,
LiteralArg,
ProcessInvocation,
Expand Down Expand Up @@ -1545,7 +1546,7 @@ fn ts_host_transport_descriptor() -> HostTransportDescriptor {
],
build: [
ProcessInvocation {
tool: ^host_tool_npx,
program: HostToolProgram { tool: ^host_tool_npx },
args: [
LiteralArg { text: "-y" },
LiteralArg { text: "typescript@5.9.2" },
Expand All @@ -1561,7 +1562,7 @@ fn ts_host_transport_descriptor() -> HostTransportDescriptor {
}
],
run: ProcessInvocation {
tool: ^host_tool_node,
program: HostToolProgram { tool: ^host_tool_node },
args: [ProducedArtifact { path: "fixture.js" }]
},
runtime_value_codec: SignedI32Le
Expand Down
6 changes: 5 additions & 1 deletion src/v2/std/host_transport.dag
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ type InvocationArg
| WorkspacePath { path: RelPath }
| ProducedArtifact { path: RelPath }

type ProcessProgram
= HostToolProgram { tool: Symbol }
| ProducedProgram { path: RelPath }

type ProcessInvocation {
tool: Symbol
program: ProcessProgram
args: List<InvocationArg>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ data emit_host_coverage_row_typescript: EmitHostTargetCoverageRow = EmitHostTarg

data emit_host_coverage_row_cpp: EmitHostTargetCoverageRow = EmitHostTargetCoverageRow {
target: cpp_target_model(),
host_smoked: false
host_smoked: true
}

data emit_host_coverage_row_java: EmitHostTargetCoverageRow = EmitHostTargetCoverageRow {
Expand Down Expand Up @@ -77,7 +77,7 @@ fn emit_host_all_targets_consistent() -> Bool {
)
}

data emit_host_gate_declared_smoke_count: Int = 4
data emit_host_gate_declared_smoke_count: Int = 5

fn emit_host_row_is_present(row: EmitHostTargetCoverageRow) -> Bool {
match runtime_row_from_target(target: row.target) {
Expand Down
Loading
Loading