teapot 3.5.4 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bin/teapot +2 -1
- data/context/getting-started.md +139 -0
- data/context/index.yaml +13 -0
- data/lib/teapot/command/build.rb +16 -25
- data/lib/teapot/command/clean.rb +8 -21
- data/lib/teapot/command/clone.rb +17 -25
- data/lib/teapot/command/create.rb +26 -34
- data/lib/teapot/command/fetch.rb +33 -41
- data/lib/teapot/command/list.rb +13 -22
- data/lib/teapot/command/selection.rb +12 -20
- data/lib/teapot/command/status.rb +16 -22
- data/lib/teapot/command/visualize.rb +21 -28
- data/lib/teapot/command.rb +44 -43
- data/lib/teapot/configuration.rb +52 -51
- data/lib/teapot/context.rb +37 -39
- data/lib/teapot/definition.rb +17 -22
- data/lib/teapot/loader.rb +40 -28
- data/lib/teapot/package.rb +38 -32
- data/lib/teapot/project.rb +16 -20
- data/lib/teapot/select.rb +26 -26
- data/lib/teapot/target.rb +17 -24
- data/lib/teapot/version.rb +6 -20
- data/lib/teapot.rb +4 -23
- data/license.md +21 -0
- data/notes.md +74 -0
- data/readme.md +64 -0
- data/releases.md +5 -0
- data.tar.gz.sig +0 -0
- metadata +25 -78
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 742147841aebb1df987a75d2ffefcb764d9d42f6faf5492bdd273c62a8e195ce
|
|
4
|
+
data.tar.gz: 11c7a76cfe57be54d9a5864b2e0d7eb821ab780c4128df78ca09e555599c7dca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '001587e6eca1be37e6697b2b603208afe8d5685b14a8364603325d9aa24af9c2af3a12effec6bf0f9513731cffd05d7ec76125333d3fa3fd9a76e9cf66467749'
|
|
7
|
+
data.tar.gz: 503bd6ed1aba820ce830b5e856468b9d990b179e2f2da32c7d1985a314f1e6ff48a54d8a0883a1352b7dd30380e51c951e2fdbf234d716926033700208f88b3a
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/bin/teapot
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
|
4
5
|
#
|
|
@@ -20,6 +21,6 @@
|
|
|
20
21
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
22
|
# THE SOFTWARE.
|
|
22
23
|
|
|
23
|
-
require_relative
|
|
24
|
+
require_relative "../lib/teapot/command"
|
|
24
25
|
|
|
25
26
|
Teapot::Command::Top.call
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
This guide explains how to use `teapot` to manage cross-platform project dependencies and build systems.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Ensure that you already have a working install of Ruby 2.0.0+ and run the following to install `teapot`:
|
|
8
|
+
|
|
9
|
+
~~~ bash
|
|
10
|
+
$ gem install teapot
|
|
11
|
+
~~~
|
|
12
|
+
|
|
13
|
+
## Create Project
|
|
14
|
+
|
|
15
|
+
Firstly, create your project by running:
|
|
16
|
+
|
|
17
|
+
~~~ bash
|
|
18
|
+
$ teapot create "My Project" https://github.com/kurocha generate-project
|
|
19
|
+
$ cd my-project
|
|
20
|
+
~~~
|
|
21
|
+
|
|
22
|
+
You will be asked to merge the project file. At present, merge tools are not very good and thus you may need to take a moment to review the changes. You want to keep most of the original file, but you would like to add the `define_target` blocks which are being added.
|
|
23
|
+
|
|
24
|
+
In the resulting project directory that has been created, you can see the list of dependencies:
|
|
25
|
+
|
|
26
|
+
~~~ bash
|
|
27
|
+
$ teapot list
|
|
28
|
+
... lots of output ...
|
|
29
|
+
~~~
|
|
30
|
+
|
|
31
|
+
To only see things exported by your current project, you can run:
|
|
32
|
+
|
|
33
|
+
~~~ bash
|
|
34
|
+
$ teapot list root
|
|
35
|
+
Package root (from /private/tmp/my-project):
|
|
36
|
+
#<Teapot::Project "my-project">
|
|
37
|
+
My Project description.
|
|
38
|
+
- Summary: A brief one line summary of the project.
|
|
39
|
+
- License: MIT License
|
|
40
|
+
- Version: 0.1.0
|
|
41
|
+
- Author: Samuel Williams <samuel.williams@oriontransfer.co.nz>
|
|
42
|
+
#<Teapot::Target "my-project-library">
|
|
43
|
+
- depends on "Build/Files"
|
|
44
|
+
- depends on "Build/Clang"
|
|
45
|
+
- depends on :platform
|
|
46
|
+
- depends on "Language/C++14" {:private=>true}
|
|
47
|
+
- provides "Library/MyProject"
|
|
48
|
+
#<Teapot::Target "my-project-test">
|
|
49
|
+
- depends on "Library/UnitTest"
|
|
50
|
+
- depends on "Library/MyProject"
|
|
51
|
+
- provides "Test/MyProject"
|
|
52
|
+
#<Teapot::Target "my-project-executable">
|
|
53
|
+
- depends on "Build/Files"
|
|
54
|
+
- depends on "Build/Clang"
|
|
55
|
+
- depends on :platform
|
|
56
|
+
- depends on "Language/C++14" {:private=>true}
|
|
57
|
+
- depends on "Library/MyProject"
|
|
58
|
+
- provides "Executable/MyProject"
|
|
59
|
+
#<Teapot::Target "my-project-run">
|
|
60
|
+
- depends on "Executable/MyProject"
|
|
61
|
+
- provides "Run/MyProject"
|
|
62
|
+
#<Teapot::Configuration "development" visibility=private>
|
|
63
|
+
- references root from /private/tmp/my-project
|
|
64
|
+
- clones platforms from https://github.com/kurocha/platforms
|
|
65
|
+
- clones unit-test from https://github.com/kurocha/unit-test
|
|
66
|
+
- clones generate-cpp-class from https://github.com/kurocha/generate-cpp-class
|
|
67
|
+
- clones generate-project from https://github.com/kurocha/generate-project
|
|
68
|
+
- clones variants from https://github.com/kurocha/variants
|
|
69
|
+
- clones platform-darwin-osx from https://github.com/kurocha/platform-darwin-osx
|
|
70
|
+
- clones platform-darwin-ios from https://github.com/kurocha/platform-darwin-ios
|
|
71
|
+
- clones build-clang from https://github.com/kurocha/build-clang
|
|
72
|
+
- clones build-darwin from https://github.com/kurocha/build-darwin
|
|
73
|
+
- clones build-files from https://github.com/kurocha/build-files
|
|
74
|
+
- clones streams from https://github.com/kurocha/streams
|
|
75
|
+
- clones generate-template from https://github.com/kurocha/generate-template
|
|
76
|
+
#<Teapot::Configuration "my-project" visibility=public>
|
|
77
|
+
- references root from /private/tmp/my-project
|
|
78
|
+
~~~
|
|
79
|
+
|
|
80
|
+
## Run Tests
|
|
81
|
+
|
|
82
|
+
Testing is a good idea, and teapot supports test driven development.
|
|
83
|
+
|
|
84
|
+
~~~ bash
|
|
85
|
+
$ teapot Test/MyProject
|
|
86
|
+
~~~
|
|
87
|
+
|
|
88
|
+
### Wildcard Targets
|
|
89
|
+
|
|
90
|
+
To run all tests:
|
|
91
|
+
|
|
92
|
+
~~~ bash
|
|
93
|
+
$ teapot "Test/*"
|
|
94
|
+
~~~
|
|
95
|
+
|
|
96
|
+
Provided you are using an environment that supports sanitizers, you can test more thoroughly using:
|
|
97
|
+
|
|
98
|
+
~~~ bash
|
|
99
|
+
$ teapot "Test/*" variant-sanitize
|
|
100
|
+
~~~
|
|
101
|
+
|
|
102
|
+
## Run Project
|
|
103
|
+
|
|
104
|
+
We can now build and run the project executable:
|
|
105
|
+
|
|
106
|
+
~~~ bash
|
|
107
|
+
$ teapot Run/MyProject
|
|
108
|
+
I'm a little teapot,
|
|
109
|
+
Short and stout,
|
|
110
|
+
Here is my handle (one hand on hip),
|
|
111
|
+
Here is my spout (other arm out with elbow and wrist bent).
|
|
112
|
+
When I get all steamed up,
|
|
113
|
+
Hear me shout,
|
|
114
|
+
Tip me over and pour me out! (lean over toward spout)
|
|
115
|
+
|
|
116
|
+
~
|
|
117
|
+
___^___ __
|
|
118
|
+
.- / \./ /
|
|
119
|
+
/ / _/
|
|
120
|
+
\__| |
|
|
121
|
+
\_______/
|
|
122
|
+
~~~
|
|
123
|
+
|
|
124
|
+
The resulting executables and libraries will be framework dependent, but are typically located in:
|
|
125
|
+
|
|
126
|
+
~~~ bash
|
|
127
|
+
$ cd teapot/platforms/development/$PLATFORM-debug/bin
|
|
128
|
+
$ ./$PROJECT_NAME
|
|
129
|
+
~~~
|
|
130
|
+
|
|
131
|
+
## Cloning Project
|
|
132
|
+
|
|
133
|
+
You can clone another project which will fetch all dependencies:
|
|
134
|
+
|
|
135
|
+
~~~ bash
|
|
136
|
+
$ teapot clone https://github.com/kurocha/tagged-format
|
|
137
|
+
$ cd tagged-format
|
|
138
|
+
$ teapot build Executable/TaggedFormat
|
|
139
|
+
~~~
|
data/context/index.yaml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Automatically generated context index for Utopia::Project guides.
|
|
2
|
+
# Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
|
|
3
|
+
---
|
|
4
|
+
description: Teapot is a tool for managing cross-platform builds.
|
|
5
|
+
metadata:
|
|
6
|
+
documentation_uri: https://ioquatix.github.io/teapot/
|
|
7
|
+
funding_uri: https://github.com/sponsors/ioquatix
|
|
8
|
+
source_code_uri: https://github.com/ioquatix/teapot
|
|
9
|
+
files:
|
|
10
|
+
- path: getting-started.md
|
|
11
|
+
title: Getting Started
|
|
12
|
+
description: This guide explains how to use `teapot` to manage cross-platform project
|
|
13
|
+
dependencies and build systems.
|
data/lib/teapot/command/build.rb
CHANGED
|
@@ -1,43 +1,32 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
20
2
|
|
|
21
|
-
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2017-2026, by Samuel Williams.
|
|
22
5
|
|
|
23
|
-
|
|
6
|
+
require_relative "selection"
|
|
7
|
+
|
|
8
|
+
require "build/controller"
|
|
24
9
|
|
|
25
10
|
module Teapot
|
|
26
11
|
module Command
|
|
12
|
+
# Raised when the build fails.
|
|
27
13
|
class BuildFailedError < StandardError
|
|
28
14
|
end
|
|
29
15
|
|
|
16
|
+
# A command to build targets in the project.
|
|
30
17
|
class Build < Selection
|
|
31
18
|
self.description = "Build the specified target."
|
|
32
19
|
|
|
33
20
|
options do
|
|
34
|
-
option
|
|
35
|
-
option
|
|
21
|
+
option "-j/-l/--limit <n>", "Limit the build to <n> concurrent processes.", type: Integer
|
|
22
|
+
option "-c/--continuous", "Run the build graph continually (experimental)."
|
|
36
23
|
end
|
|
37
24
|
|
|
38
25
|
many :targets, "Build these targets, or use them to help the dependency resolution process."
|
|
39
26
|
split :argv, "Arguments passed to child process(es) of build if any."
|
|
40
27
|
|
|
28
|
+
# Build the selected targets or default build targets, resolving dependencies and executing the build controller.
|
|
29
|
+
# @returns [Build::Dependency::Chain] The dependency chain.
|
|
41
30
|
def call
|
|
42
31
|
context = parent.context
|
|
43
32
|
|
|
@@ -51,7 +40,7 @@ module Teapot
|
|
|
51
40
|
chain = selection.chain
|
|
52
41
|
environment = context.configuration.environment
|
|
53
42
|
|
|
54
|
-
controller = ::Build::Controller.new(
|
|
43
|
+
controller = ::Build::Controller.new(limit: @options[:limit]) do |controller|
|
|
55
44
|
controller.add_chain(chain, self.argv, environment)
|
|
56
45
|
end
|
|
57
46
|
|
|
@@ -67,7 +56,7 @@ module Teapot
|
|
|
67
56
|
if walker.failed?
|
|
68
57
|
raise BuildFailedError.new("Failed to build all nodes successfully!")
|
|
69
58
|
end
|
|
70
|
-
|
|
59
|
+
|
|
71
60
|
break
|
|
72
61
|
end
|
|
73
62
|
end
|
|
@@ -80,6 +69,8 @@ module Teapot
|
|
|
80
69
|
return chain
|
|
81
70
|
end
|
|
82
71
|
|
|
72
|
+
# Display task dependencies for debugging, showing which tasks generate which outputs.
|
|
73
|
+
# @parameter walker [Build::Walker] The build walker.
|
|
83
74
|
def show_dependencies(walker)
|
|
84
75
|
outputs = {}
|
|
85
76
|
|
data/lib/teapot/command/clean.rb
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
20
2
|
|
|
21
|
-
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2017-2026, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require "samovar"
|
|
22
7
|
|
|
23
8
|
module Teapot
|
|
24
9
|
module Command
|
|
10
|
+
# A command to clean build artifacts.
|
|
25
11
|
class Clean < Samovar::Command
|
|
26
12
|
self.description = "Delete everything in the teapot directory."
|
|
27
13
|
|
|
14
|
+
# Delete build output directories for the specified targets or all targets.
|
|
28
15
|
def call
|
|
29
16
|
context = parent.context
|
|
30
17
|
logger = parent.logger
|
|
@@ -32,7 +19,7 @@ module Teapot
|
|
|
32
19
|
|
|
33
20
|
logger.info "Removing #{configuration.build_path}..."
|
|
34
21
|
FileUtils.rm_rf configuration.build_path
|
|
35
|
-
|
|
22
|
+
|
|
36
23
|
logger.info "Removing #{configuration.packages_path}..."
|
|
37
24
|
FileUtils.rm_rf configuration.packages_path
|
|
38
25
|
end
|
data/lib/teapot/command/clone.rb
CHANGED
|
@@ -1,44 +1,31 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
20
2
|
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2017-2026, by Samuel Williams.
|
|
23
5
|
|
|
24
|
-
|
|
25
|
-
require
|
|
6
|
+
require "samovar"
|
|
7
|
+
require "build/name"
|
|
26
8
|
|
|
27
|
-
|
|
9
|
+
require_relative "fetch"
|
|
10
|
+
require "rugged"
|
|
11
|
+
|
|
12
|
+
require "build/uri"
|
|
28
13
|
|
|
29
14
|
module Teapot
|
|
30
15
|
module Command
|
|
16
|
+
# A command to clone a remote repository and fetch all dependencies.
|
|
31
17
|
class Clone < Samovar::Command
|
|
32
18
|
self.description = "Clone a remote repository and fetch all dependencies."
|
|
33
19
|
|
|
34
20
|
one :source, "The source repository to clone.", required: true
|
|
35
21
|
|
|
22
|
+
# Clone packages from their remote repositories using git, parallelizing the operations.
|
|
36
23
|
def call
|
|
37
24
|
logger = parent.logger
|
|
38
25
|
|
|
39
26
|
name = File.basename(::Build::URI[@source].path, ".git")
|
|
40
27
|
|
|
41
|
-
nested = parent[
|
|
28
|
+
nested = parent["--root", parent.options[:root] || name]
|
|
42
29
|
root = nested.root
|
|
43
30
|
|
|
44
31
|
if root.exist?
|
|
@@ -52,6 +39,11 @@ module Teapot
|
|
|
52
39
|
Fetch[parent: nested].call
|
|
53
40
|
end
|
|
54
41
|
|
|
42
|
+
# Provide credentials for repository authentication.
|
|
43
|
+
# @parameter url [String] The repository URL.
|
|
44
|
+
# @parameter username [String] The username.
|
|
45
|
+
# @parameter types [Array] The credential types allowed.
|
|
46
|
+
# @returns [Rugged::Credentials] The credentials object.
|
|
55
47
|
def credentials(url, username, types)
|
|
56
48
|
# We should prompt for username/password if required...
|
|
57
49
|
return Rugged::Credentials::SshKeyFromAgent.new(username: username)
|
|
@@ -1,31 +1,17 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
20
2
|
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2017-2026, by Samuel Williams.
|
|
23
5
|
|
|
24
|
-
|
|
25
|
-
require
|
|
6
|
+
require "samovar"
|
|
7
|
+
require "build/name"
|
|
8
|
+
|
|
9
|
+
require_relative "fetch"
|
|
10
|
+
require "rugged"
|
|
26
11
|
|
|
27
12
|
module Teapot
|
|
28
13
|
module Command
|
|
14
|
+
# A command to create a new teapot project.
|
|
29
15
|
class Create < Samovar::Command
|
|
30
16
|
self.description = "Create a new teapot package using the specified repository."
|
|
31
17
|
|
|
@@ -33,10 +19,11 @@ module Teapot
|
|
|
33
19
|
one :source, "The source repository to use for fetching packages, e.g. https://github.com/kurocha.", required: true
|
|
34
20
|
many :packages, "Any packages you'd like to include in the project.", default: ["generate-project"]
|
|
35
21
|
|
|
22
|
+
# Create a new project directory structure with default teapot.rb configuration.
|
|
36
23
|
def call
|
|
37
24
|
logger = parent.logger
|
|
38
25
|
|
|
39
|
-
nested = parent[
|
|
26
|
+
nested = parent["--root", parent.options[:root] || name.gsub(/\s+/, "-").downcase]
|
|
40
27
|
root = nested.root
|
|
41
28
|
|
|
42
29
|
if root.exist?
|
|
@@ -75,10 +62,15 @@ module Teapot
|
|
|
75
62
|
tree: index.write_tree(repository),
|
|
76
63
|
message: "Initial project files.",
|
|
77
64
|
parents: repository.empty? ? [] : [repository.head.target].compact,
|
|
78
|
-
update_ref:
|
|
65
|
+
update_ref: "HEAD"
|
|
79
66
|
)
|
|
80
67
|
end
|
|
81
68
|
|
|
69
|
+
# Generate the initial project files.
|
|
70
|
+
# @parameter root [Build::Files::Path] The project root path.
|
|
71
|
+
# @parameter name [String] The project name.
|
|
72
|
+
# @parameter source [String] The source repository URL.
|
|
73
|
+
# @parameter packages [Array(String)] The packages to include.
|
|
82
74
|
def generate_project(root, name, source, packages)
|
|
83
75
|
name = ::Build::Name.new(name)
|
|
84
76
|
|
|
@@ -89,17 +81,17 @@ module Teapot
|
|
|
89
81
|
|
|
90
82
|
# A very basic teapot file to pull in the initial dependencies.
|
|
91
83
|
File.open(root + TEAPOT_FILE, "w") do |output|
|
|
92
|
-
output.puts "\# Teapot v#{VERSION} configuration generated at #{Time.now.to_s}",
|
|
93
|
-
|
|
94
|
-
output.puts "required_version #{LOADER_VERSION.dump}",
|
|
84
|
+
output.puts "\# Teapot v#{VERSION} configuration generated at #{Time.now.to_s}", ""
|
|
85
|
+
|
|
86
|
+
output.puts "required_version #{LOADER_VERSION.dump}", ""
|
|
95
87
|
|
|
96
88
|
output.puts "define_project #{name.target.dump} do |project|"
|
|
97
89
|
output.puts "\tproject.title = #{name.text.dump}"
|
|
98
|
-
output.puts "end",
|
|
99
|
-
|
|
100
|
-
output.puts "\# Build Targets",
|
|
101
|
-
|
|
102
|
-
output.puts "\# Configurations",
|
|
90
|
+
output.puts "end", ""
|
|
91
|
+
|
|
92
|
+
output.puts "\# Build Targets", ""
|
|
93
|
+
|
|
94
|
+
output.puts "\# Configurations", ""
|
|
103
95
|
|
|
104
96
|
output.puts "define_configuration 'development' do |configuration|"
|
|
105
97
|
output.puts "\tconfiguration[:source] = #{source.dump}"
|
|
@@ -107,7 +99,7 @@ module Teapot
|
|
|
107
99
|
packages.each do |name|
|
|
108
100
|
output.puts "\tconfiguration.require #{name.dump}"
|
|
109
101
|
end
|
|
110
|
-
output.puts "end",
|
|
102
|
+
output.puts "end", ""
|
|
111
103
|
|
|
112
104
|
output.puts "define_configuration #{name.target.dump} do |configuration|"
|
|
113
105
|
output.puts "\tconfiguration.public!"
|
data/lib/teapot/command/fetch.rb
CHANGED
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
20
2
|
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2017-2026, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require_relative "selection"
|
|
7
|
+
require "rugged"
|
|
23
8
|
|
|
24
9
|
module Teapot
|
|
25
10
|
module Command
|
|
11
|
+
# Raised when a fetch operation fails.
|
|
26
12
|
class FetchError < StandardError
|
|
13
|
+
# @parameter package [Package] The package that caused the error.
|
|
14
|
+
# @parameter message [String] The error message.
|
|
27
15
|
def initialize(package, message)
|
|
28
16
|
super(message)
|
|
29
17
|
@package = package
|
|
@@ -32,6 +20,7 @@ module Teapot
|
|
|
32
20
|
attr :package
|
|
33
21
|
end
|
|
34
22
|
|
|
23
|
+
# A command to fetch remote packages and dependencies.
|
|
35
24
|
class Fetch < Samovar::Command
|
|
36
25
|
self.description = "Fetch remote packages according to the specified configuration."
|
|
37
26
|
|
|
@@ -41,16 +30,19 @@ module Teapot
|
|
|
41
30
|
# - update packages and update lockfile
|
|
42
31
|
|
|
43
32
|
options do
|
|
44
|
-
option
|
|
45
|
-
option
|
|
33
|
+
option "--update", "Update dependencies to the latest versions."
|
|
34
|
+
option "--local", "Don't update from source, assume updated local packages."
|
|
46
35
|
end
|
|
47
36
|
|
|
48
37
|
many :packages, "Only update the specified packages, or all packages if none specified."
|
|
49
38
|
|
|
39
|
+
# Get the context for this command.
|
|
40
|
+
# @returns [Context] The current context.
|
|
50
41
|
def context
|
|
51
42
|
parent.context
|
|
52
43
|
end
|
|
53
44
|
|
|
45
|
+
# Update packages by pulling latest changes from their git remotes, subject to lock file constraints.
|
|
54
46
|
def call
|
|
55
47
|
selection = context.select
|
|
56
48
|
|
|
@@ -77,7 +69,7 @@ module Teapot
|
|
|
77
69
|
|
|
78
70
|
packages = selection.unresolved
|
|
79
71
|
end
|
|
80
|
-
|
|
72
|
+
|
|
81
73
|
if selection.unresolved.count > 0
|
|
82
74
|
logger.error(self) do |buffer|
|
|
83
75
|
buffer.puts "Could not fetch all packages!"
|
|
@@ -98,21 +90,21 @@ module Teapot
|
|
|
98
90
|
|
|
99
91
|
return {
|
|
100
92
|
commit: repository.head.target.oid,
|
|
101
|
-
branch: repository.head.name.sub(/^refs\/heads\//,
|
|
93
|
+
branch: repository.head.name.sub(/^refs\/heads\//, "")
|
|
102
94
|
}
|
|
103
95
|
end
|
|
104
96
|
|
|
105
97
|
def link_local_package(context, configuration, package, logger)
|
|
106
98
|
logger.info "Linking local #{package}..." #.color(:cyan)
|
|
107
|
-
|
|
99
|
+
|
|
108
100
|
local_path = context.root + package.options[:local]
|
|
109
|
-
|
|
101
|
+
|
|
110
102
|
# Where we are going to put the package:
|
|
111
103
|
destination_path = package.path
|
|
112
|
-
|
|
104
|
+
|
|
113
105
|
# Make the top level directory if required:
|
|
114
106
|
destination_path.dirname.create
|
|
115
|
-
|
|
107
|
+
|
|
116
108
|
unless destination_path.exist?
|
|
117
109
|
destination_path.make_symlink(local_path)
|
|
118
110
|
end
|
|
@@ -133,36 +125,36 @@ module Teapot
|
|
|
133
125
|
|
|
134
126
|
def clone_or_pull_package(context, configuration, package, package_lock, logger)
|
|
135
127
|
logger.info "Processing #{package}..." #.color(:cyan)
|
|
136
|
-
|
|
128
|
+
|
|
137
129
|
# Where we are going to put the package:
|
|
138
130
|
destination_path = package.path
|
|
139
|
-
|
|
131
|
+
|
|
140
132
|
base_uri = URI(package.options[:source].to_s)
|
|
141
|
-
|
|
142
|
-
if base_uri.scheme == nil || base_uri.scheme ==
|
|
133
|
+
|
|
134
|
+
if base_uri.scheme == nil || base_uri.scheme == "file"
|
|
143
135
|
base_uri = URI "file://" + File.expand_path(base_uri.path, context.root) + "/"
|
|
144
136
|
end
|
|
145
|
-
|
|
137
|
+
|
|
146
138
|
branch_name = package.options[:branch]
|
|
147
|
-
|
|
139
|
+
|
|
148
140
|
if package_lock
|
|
149
141
|
logger.info "Package locked to commit: #{package_lock[:branch]}/#{package_lock[:commit]}"
|
|
150
|
-
|
|
142
|
+
|
|
151
143
|
branch_name = package_lock[:branch]
|
|
152
144
|
commit_id = package_lock[:commit]
|
|
153
145
|
end
|
|
154
|
-
|
|
146
|
+
|
|
155
147
|
if destination_path.exist?
|
|
156
148
|
logger.info "Updating package at path #{destination_path}..."
|
|
157
|
-
|
|
149
|
+
|
|
158
150
|
repository = Rugged::Repository.new(destination_path.to_s)
|
|
159
|
-
|
|
151
|
+
|
|
160
152
|
# Are there uncommitted changes in the work tree?
|
|
161
153
|
if modified?(repository)
|
|
162
154
|
raise FetchError.new(package, "Uncommited local modifications")
|
|
163
155
|
end
|
|
164
156
|
|
|
165
|
-
repository.fetch(
|
|
157
|
+
repository.fetch("origin", credentials: self.method(:credentials))
|
|
166
158
|
repository.checkout(branch_name) if branch_name
|
|
167
159
|
|
|
168
160
|
# Essentially implement git pull:
|
|
@@ -194,7 +186,7 @@ module Teapot
|
|
|
194
186
|
system("git", "submodule", "update", "--init", "--recursive", chdir: package.path)
|
|
195
187
|
end
|
|
196
188
|
end
|
|
197
|
-
|
|
189
|
+
|
|
198
190
|
def fetch_package(context, configuration, package, logger, update: false, local: false)
|
|
199
191
|
if package.local?
|
|
200
192
|
link_local_package(context, configuration, package, logger)
|