-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add another level of indirection for projects.
This is a step towards project dependencies... I hope. I realized that I don't want a separate build directory for every project; just for the one that is being built. if my package depends on gleam_stdlib, I need the files in that package to be in the build directory for this one. I think I'm still doing it wrong, though because gleam_stdlib is the package name and right now if you tried to build something like that you'd need to import from gleam_stdlib. But e.g. gleam/io is not in a gleam_stdlib namespace.
- Loading branch information
1 parent
87fde3a
commit 3984586
Showing
8 changed files
with
228 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//// A project encompasses everything needed to build a package | ||
//// and all its dependencies (which are other packages). | ||
//// | ||
//// For the most part, a project is just a wrapper of a package | ||
//// and a build directory for that package. | ||
//// | ||
//// Note that any one project can have multiple packages in it, | ||
//// with one main package and any number of dependency packages. | ||
//// Each of those dependency packages is probably the main package | ||
//// of its own project from the point of view of the person developing | ||
//// that project, but the current developer only cares about the current | ||
//// package. | ||
//// | ||
//// I really hope that makes sense cause it took we a while to puzzle | ||
//// it out. | ||
|
||
import compiler/package | ||
import errors | ||
import filepath | ||
import gleam/option | ||
import gleam/result | ||
|
||
pub type GleamProject { | ||
GleamProject( | ||
base_directory: String, | ||
main_package: package.GleamPackage, | ||
main_module: option.Option(String), | ||
) | ||
} | ||
|
||
pub type CompiledProject { | ||
CompiledProject( | ||
base_directory: String, | ||
build_directory: String, | ||
main_package: package.CompiledPackage, | ||
main_module: option.Option(String), | ||
) | ||
} | ||
|
||
pub fn load_project( | ||
base_directory: String, | ||
) -> Result(GleamProject, errors.Error) { | ||
use main_package <- result.try(package.load_package(base_directory)) | ||
let main_module = | ||
main_package |> package.has_main_function |> option.from_result | ||
// TODO: dependencies need to come from gleam.toml | ||
Ok(GleamProject(base_directory, main_package, main_module)) | ||
} | ||
|
||
pub fn build_directory(base_directory: String) -> String { | ||
filepath.join(base_directory, "build") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.