Skip to content

Commit

Permalink
develop DepsConfig and its use
Browse files Browse the repository at this point in the history
  • Loading branch information
gfngfn committed Jan 1, 2024
1 parent d4aebf3 commit 91aa482
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
12 changes: 10 additions & 2 deletions bin-saphe/depsConfig.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

open MyUtil
open ConfigError


type envelope_name = string

type envelope_dependency = {
Expand All @@ -13,6 +17,10 @@ type envelope_spec = {
}

type t = {
envelopes : envelope_spec list;
direct_dependencies : envelope_dependency list;
envelopes : envelope_spec list;
explicit_dependencies : envelope_dependency list;
}


let write (_abspath_deps_config : abs_path) (_deps_config : t) : (unit, config_error) result =
failwith "TODO: DepsConfig.write"
1 change: 1 addition & 0 deletions bin-saphe/lockConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type lock_dependency = {
used_as : string;
}

(* TODO: make `locked_package` keep registry, package name, and version *)
type locked_package = {
lock_name : lock_name;
lock_contents : lock_contents;
Expand Down
41 changes: 34 additions & 7 deletions bin-saphe/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -735,13 +735,35 @@ type build_input =
}


let make_deps_config (_lock_config : LockConfig.t) : DepsConfig.t =
let make_envelope_dependency (lock_dep : LockConfig.lock_dependency) : DepsConfig.envelope_dependency =
DepsConfig.{
envelopes = failwith "TODO: DepsConfig";
direct_dependencies = [];
dependency_name = lock_dep.depended_lock_name;
dependency_used_as = lock_dep.used_as;
}


let make_envelope_spec (locked_package : LockConfig.locked_package) : DepsConfig.envelope_spec =
let envelope_dependencies =
locked_package.lock_dependencies |> List.map make_envelope_dependency
in
DepsConfig.{
envelope_name = locked_package.lock_name;
envelope_path = failwith "TODO: make_envelope_spec, envelope_path";
envelope_dependencies;
}


let make_deps_config (lock_config : LockConfig.t) : DepsConfig.t =
let envelopes =
lock_config.LockConfig.locked_packages |> List.map make_envelope_spec
in
let explicit_dependencies =
lock_config.LockConfig.explicit_dependencies
|> List.map make_envelope_dependency
in
DepsConfig.{ envelopes; explicit_dependencies }


let build
~(fpath_in : string)
~(fpath_out_opt : string option)
Expand Down Expand Up @@ -813,22 +835,27 @@ let build
| PackageBuildInput{
root = _absdir_package;
lock = abspath_lock_config;
deps = _abspath_deps_config;
deps = abspath_deps_config;
envelope = _abspath_envelope_config;
options = _build_option;
} ->
let* lock_config = LockConfig.load abspath_lock_config in
let _deps_config = make_deps_config lock_config in
let deps_config = make_deps_config lock_config in

let* () = DepsConfig.write abspath_deps_config deps_config in
failwith "TODO: PackageBuildInput"

| DocumentBuildInput{
lock = abspath_lock_config;
deps = _abspath_deps_config;
deps = abspath_deps_config;
out = _abspath_out;
dump = _abspath_dump;
options = _build_option;
} ->
let* _lock_config = LockConfig.load abspath_lock_config in
let* lock_config = LockConfig.load abspath_lock_config in
let deps_config = make_deps_config lock_config in

let* () = DepsConfig.write abspath_deps_config deps_config in
failwith "TODO: DocumentBuildInput"
in
match res with
Expand Down

0 comments on commit 91aa482

Please sign in to comment.