New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
next: add package subcommand #2551
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
202bc88
package: implement locate_ancestor
seliopou 78c6deb
package: allow reuse of build_package
seliopou 6e11257
package: implement package subcommands
seliopou 98cbe5f
package: expose package subcommand
seliopou 7fd2c4f
package: Remove use of Option module
seliopou d79aaf3
local-next: move locate_ancestor to OpamFile, rename it
seliopou 0206e17
package: update uses of locate_ancestor to find_ancestor_dir
seliopou 9293793
package: change error message when OPAM file is not found
seliopou File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
(*---------------------------------------------------------------------------- | ||
Copyright (c) 2016 Inhabited Type LLC <spiros@inhabitedtype.com> | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the author nor the names of his contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS | ||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
----------------------------------------------------------------------------*) | ||
|
||
let default_nv = | ||
match OpamPackage.of_string_opt "local-package.dev" with | ||
| Some nv -> nv | ||
| None -> assert false | ||
|
||
let build t ?build_test ?build_doc dir = | ||
let name = OpamPackage.name default_nv in | ||
let pred dir = None <> OpamPinned.find_opam_file_in_source name dir in | ||
let dir = | ||
match OpamFilename.find_ancestor_dir pred dir with | ||
| Some dir -> dir | ||
| None -> | ||
OpamConsole.error "No valid package description found."; | ||
OpamStd.Sys.exit 1 | ||
in | ||
(* XXX(seliopou): This whole dance is necessary because | ||
* OpamAction.build_package reads global state, rather than explicitly taking | ||
* the build_test and build_doc arguments *) | ||
let old_r = OpamStateConfig.(!r) in | ||
try | ||
OpamStateConfig.update ?build_test ?build_doc (); | ||
OpamAction.build_package t (`In_place dir) default_nv; | ||
OpamStateConfig.r := old_r | ||
with exn -> OpamStateConfig.r := old_r; raise exn |
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,38 @@ | ||
(*---------------------------------------------------------------------------- | ||
Copyright (c) 2016 Inhabited Type LLC <spiros@inhabitedtype.com> | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the author nor the names of his contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS | ||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
----------------------------------------------------------------------------*) | ||
|
||
open OpamTypes | ||
open OpamStateTypes | ||
|
||
val build : | ||
rw switch_state -> ?build_test:bool -> ?build_doc:bool -> dirname -> unit |
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 |
---|---|---|
|
@@ -512,9 +512,19 @@ let remove_package t ?keep_build ?silent nv = | |
(* Compiles a package. | ||
Assumes the package has already been downloaded to [source]. | ||
*) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would have written one core function and two exported functions for the two modes, rather than a mode argument; but it's just a a matter of taste, this is fine. |
||
let build_package t source nv = | ||
extract_package t source nv; | ||
let opam = OpamSwitchState.opam t nv in | ||
let build_package t mode nv = | ||
let dir, opam = | ||
match mode with | ||
| `Extract source -> | ||
extract_package t source nv; | ||
OpamPath.Switch.build t.switch_global.root t.switch nv, | ||
OpamSwitchState.opam t nv | ||
| `In_place dir -> | ||
let name = OpamPackage.name nv in | ||
match OpamPinned.find_opam_file_in_source name dir with | ||
| None -> raise Not_found | ||
| Some file -> dir, OpamFile.OPAM.read file | ||
in | ||
let commands = | ||
OpamFile.OPAM.build opam @ | ||
(if OpamStateConfig.(!r.build_test) | ||
|
@@ -527,7 +537,6 @@ let build_package t source nv = | |
in | ||
let env = OpamTypesBase.env_array (compilation_env t opam) in | ||
let name = OpamPackage.name_to_string nv in | ||
let dir = OpamPath.Switch.build t.switch_global.root t.switch nv in | ||
let rec run_commands = function | ||
| (cmd::args)::commands -> | ||
let text = OpamProcess.make_command_text name ~args cmd in | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. It would be best to add them as arguments troughout. Meanwhile, it may be more consistent to remove the argument here and relying on the options being set in
OpamMain
.Note that since we would like to be able to set these options for specific packages (#2506), this will need to be changed anyway at that point.