Skip to content

Commit 4838dce

Browse files
committed
wip
1 parent 6ee50fe commit 4838dce

File tree

11 files changed

+60
-17
lines changed

11 files changed

+60
-17
lines changed

packages/cli/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ pub struct Build {
202202
#[serde(default, skip_serializing_if = "Option::is_none")]
203203
pub max_depth: Option<u64>,
204204

205+
/// Configure if path and tag are set for builds.
206+
#[serde(default, skip_serializing_if = "Option::is_none")]
207+
pub set_path_and_tag: Option<bool>,
208+
205209
/// The remotes to build for.
206210
#[serde(default, skip_serializing_if = "Option::is_none")]
207211
pub remotes: Option<Vec<String>>,

packages/cli/src/target/build.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ impl Cli {
193193
};
194194

195195
// Get the source map.
196-
let source_map = if let Some(lockfile) = lockfile {
196+
let (source_map, lock) = if let Some(lockfile) = lockfile {
197197
let lockfile = tg::Lockfile::try_read(&lockfile)
198198
.await?
199199
.ok_or_else(|| tg::error!(%path = lockfile.display(), "failed to read lockfile"))?;
200200
let source_map = tg::SourceMap::new(&handle, &lockfile, object.clone()).await?;
201-
Some(source_map)
201+
(Some(source_map), Some(lockfile))
202202
} else {
203-
None
203+
(None, None)
204204
};
205205

206206
// Create the target.
@@ -352,6 +352,7 @@ impl Cli {
352352
let id = target.id(&handle).await?;
353353
let arg = tg::target::build::Arg {
354354
create: args.create,
355+
lock,
355356
parent: None,
356357
remote: remote.clone(),
357358
retry,

packages/cli/src/view.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::Cli;
2-
use tangram_client as tg;
2+
use tangram_client::{self as tg, handle::Ext as _};
33
use tangram_either::Either;
44
use tangram_futures::task::Task;
55

@@ -58,7 +58,23 @@ impl Cli {
5858
},
5959
};
6060
let (item, source_map) = match item {
61-
Either::Left(build) => (crate::viewer::Item::Build(build), None),
61+
Either::Left(build) => {
62+
let source_map = if let Some(lockfile) = handle.get_build(build.id()).await?.lock {
63+
// Only attempt to load the target if the lock is set.
64+
if let Some(executable) =
65+
&*build.target(&handle).await?.executable(&handle).await?
66+
{
67+
let object = executable.object()[0].clone();
68+
let source_map = tg::SourceMap::new(&handle, &lockfile, object).await?;
69+
Some(source_map)
70+
} else {
71+
None
72+
}
73+
} else {
74+
None
75+
};
76+
(crate::viewer::Item::Build(build), source_map)
77+
},
6278
Either::Right(object) => {
6379
// Get the source map.
6480
let source_map = if let Some(lockfile) = lockfile {

packages/client/src/build/get.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ pub struct Output {
1818

1919
pub host: String,
2020

21+
#[serde(default, skip_serializing_if = "Option::is_none")]
22+
pub lock: Option<tg::Lockfile>,
23+
2124
#[serde(default, skip_serializing_if = "Option::is_none")]
2225
pub log: Option<tg::blob::Id>,
2326

packages/client/src/reference/get.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::path::PathBuf;
2-
31
use crate as tg;
2+
use std::path::PathBuf;
43
use tangram_either::Either;
54
use tangram_http::{incoming::response::Ext as _, outgoing::request::Ext as _};
65

packages/client/src/target/build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ pub struct Arg {
1010
#[serde(default = "return_true", skip_serializing_if = "is_true")]
1111
pub create: bool,
1212

13+
#[serde(default, skip_serializing_if = "Option::is_none")]
14+
pub lock: Option<tg::Lockfile>,
15+
1316
#[serde(default, skip_serializing_if = "Option::is_none")]
1417
pub parent: Option<tg::build::Id>,
1518

@@ -76,6 +79,7 @@ impl Default for Arg {
7679
fn default() -> Self {
7780
Self {
7881
create: true,
82+
lock: None,
7983
parent: None,
8084
remote: None,
8185
retry: tg::build::Retry::default(),

packages/server/src/artifact/checkin/object.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ pub struct Edge {
3838
#[derive(Clone, Debug)]
3939
struct RemappedEdge {
4040
pub id: Either<usize, tg::object::Id>,
41-
pub _path: Option<PathBuf>,
41+
pub path: Option<PathBuf>,
4242
pub reference: tg::Reference,
4343
pub subpath: Option<PathBuf>,
44-
pub _tag: Option<tg::Tag>,
44+
pub tag: Option<tg::Tag>,
4545
}
4646

4747
impl Server {
@@ -114,12 +114,13 @@ impl Server {
114114
paths,
115115
))
116116
.await;
117+
let tag = unify.nodes.get(&edge.referent).unwrap().tag.clone();
117118
let edge = Edge {
118119
index: dependency_index,
119-
path: None,
120+
path: edge.path.clone(),
120121
reference: reference.clone(),
121122
subpath: edge.subpath.clone(),
122-
tag: None,
123+
tag,
123124
};
124125
nodes[index].edges.push(edge);
125126
}
@@ -309,10 +310,10 @@ impl Server {
309310
};
310311
RemappedEdge {
311312
id,
312-
_path: edge.path.clone(),
313+
path: edge.path.clone(),
313314
reference: edge.reference.clone(),
314315
subpath: edge.subpath.clone(),
315-
_tag: edge.tag.clone(),
316+
tag: edge.tag.clone(),
316317
}
317318
})
318319
.collect::<Vec<_>>();
@@ -398,10 +399,10 @@ impl Server {
398399
};
399400
RemappedEdge {
400401
id,
401-
_path: edge.path.clone(),
402+
path: edge.path.clone(),
402403
reference: edge.reference.clone(),
403404
subpath: edge.subpath.clone(),
404-
_tag: edge.tag.clone(),
405+
tag: edge.tag.clone(),
405406
}
406407
})
407408
.collect::<Vec<_>>();
@@ -454,14 +455,21 @@ impl Server {
454455
} => (contents, executable),
455456
};
456457
// Compute the dependencies, which will be shared in all cases.
458+
let set_path_and_tag = self
459+
.config()
460+
.build
461+
.as_ref()
462+
.map_or(false, |build| build.set_path_and_tag);
457463
let dependencies = edges
458464
.into_iter()
459465
.map(|edge| {
466+
let path = set_path_and_tag.then(|| edge.path.clone()).flatten();
467+
let tag = set_path_and_tag.then(|| edge.tag.clone()).flatten();
460468
let dependency = tg::Referent {
461469
item: edge.id,
462-
path: None,
470+
path,
463471
subpath: edge.subpath,
464-
tag: None,
472+
tag,
465473
};
466474
(edge.reference, dependency)
467475
})

packages/server/src/build/get.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ impl Server {
4444
pub error: Option<db::value::Json<tg::Error>>,
4545
pub host: String,
4646
#[serde(default)]
47+
pub lock: Option<tg::Lockfile>,
48+
#[serde(default)]
4749
pub log: Option<tg::blob::Id>,
4850
#[serde(default)]
4951
pub logs_count: Option<u64>,
@@ -92,6 +94,7 @@ impl Server {
9294
depth,
9395
error,
9496
host,
97+
lock,
9598
log,
9699
logs_complete,
97100
logs_count,
@@ -126,6 +129,7 @@ impl Server {
126129
depth: row.depth,
127130
error: row.error.map(|error| error.0),
128131
host: row.host,
132+
lock: row.lock,
129133
log: row.log,
130134
logs_count: row.logs_count,
131135
logs_depth: row.logs_depth,

packages/server/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub struct Build {
5858
pub concurrency: usize,
5959
pub heartbeat_interval: Duration,
6060
pub max_depth: u64,
61+
pub set_path_and_tag: bool,
6162
pub remotes: Vec<String>,
6263
}
6364

@@ -194,6 +195,7 @@ impl Default for Build {
194195
concurrency: n.into(),
195196
heartbeat_interval: Duration::from_secs(1),
196197
max_depth: 4096,
198+
set_path_and_tag: false,
197199
remotes: Vec::new(),
198200
}
199201
}

packages/server/src/database.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ async fn migration_0000(database: &Database) -> tg::Result<()> {
9797
host text not null,
9898
index_status text,
9999
index_started_at text,
100+
lock text,
100101
log text,
101102
logs_complete integer not null default 0,
102103
logs_count integer,

0 commit comments

Comments
 (0)