• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

Experimental package creation tool for MinGW.org


Commit MetaInfo

修訂892fbd28404eb114116e2b2739f77c8785f4c9ee (tree)
時間2020-08-21 23:28:25
作者Keith Marshall <keith@user...>
CommiterKeith Marshall

Log Message

Implement supplementary "mingw-port" command.

* src/mingw-port.sh src/modules/porthelp.sh: New files; they implement
the command, and its built-in help facility, respectively.

Change Summary

差異

--- /dev/null
+++ b/src/mingw-port.sh
@@ -0,0 +1,163 @@
1+#!/bin/sh
2+# -----------------------------------------------------------------------------
3+#
4+# mingw-port.sh
5+#
6+ APPNAME="%PACKAGE%" APPVERSION="%VERSION%"
7+#
8+# A simple package construction tool for creation of MinGW packages.
9+#
10+# $Id$
11+#
12+# Written by Keith Marshall <keith@users.osdn.me>
13+# Copyright (C) 2020, MinGW.org Project
14+#
15+ COPYRIGHT_YEARS="2020"
16+#
17+# Permission is hereby granted, free of charge, to any person obtaining a copy
18+# of this software and associated documentation files (the "Software"), to deal
19+# in the Software without restriction, including without limitation the rights
20+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21+# copies of the Software, and to permit persons to whom the Software is
22+# furnished to do so, subject to the following conditions:
23+#
24+# The above copyright notice and this permission notice shall be included in
25+# all copies or substantial portions of the Software.
26+#
27+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
33+# THE SOFTWARE.
34+#
35+# -----------------------------------------------------------------------------
36+#
37+# Save the effective command name, for use in diagnostic messages.
38+#
39+ cmd=`basename "$0" .sh` cmd_version=${APPVERSION-"%VERSION%"}
40+ usage() { cat <<-ETX
41+ ${unbold}usage: $cmd [--help[=synopsis | options | description]]
42+
43+ $cmd [-V | --version] | [--licence | --license]
44+
45+ $cmd [--download-only] [-P | --ports=dir]
46+ [-D | --depot=dir] [-R | --repository=URI]
47+ [--in-tree] package-version
48+
49+ ETX
50+ }
51+
52+# Establish the paths for application support files and extensions.
53+#
54+ approotdir=`dirname "$0"`
55+ test "x`basename "$approotdir"`" = xbin && approotdir=`dirname "$approotdir"`
56+ libexecdir=${libexecdir-"$approotdir/libexec"}/$APPNAME/$APPVERSION
57+
58+# Implement the module/plugin loader; (note that the "die" function here
59+# is a simplified fall-back implementation, to handle any failure to load
60+# a required module, before a more comprehensive implementation has been
61+# sourced)...
62+#
63+ require() { load "$@" || die "$1 '$2' not found"; }
64+ load() { test -f "$libexecdir/${1}s/$2.sh" && . "$libexecdir/${1}s/$2.sh"; }
65+ die() { echo >&2 "$error_colour$cmd: *** FATAL *** $@$unbold"; exit 2; }
66+
67+# ...then load that more comprehensive diagnostic message handler, followed
68+# by the options definition handler.
69+#
70+ require module dmh
71+ require module optdefn
72+
73+# Define options, which are specific to the mingw-port command, and implement
74+# their handlers; begin with the standard options, for display of the built-in
75+# help, the program version, and the licence.
76+#
77+ optdefine h help optional_argument
78+ opteval_help() { require module porthelp; }
79+
80+ optdefine V version
81+ opteval_version() { require module licence short; }
82+
83+ optdefine licence; optalias license=licence
84+ opteval_licence() { require module licence full; }
85+
86+# Option -C, --cache=dir, specifies a local directory for persistent storage
87+# of downloaded package files; by default, they are discarded after use.
88+#
89+ optdefine C cache requires_argument
90+ opteval_cache() { APPNAME="$APPNAME DOWNLOAD_CACHE_DIR='$optarg'"; }
91+
92+# Option -D, --depot=dir, specifies a working directory, in which to build
93+# mingw-ports; defaults to current directory, when mingw-port is run.
94+#
95+ optdefine D depot requires_argument
96+ opteval_depot() { APPNAME="$APPNAME PACKAGE_DEPOT='$optarg'"; }
97+
98+# Option -P, --ports=dir, specifies a local directory to store, and search
99+# for, mingw-port specifications; by default, current directory is searched
100+# first, followed by internet repository; specifying "-P dir" causes "dir"
101+# to be searched after current directory, but before any internet search,
102+# and downloaded files to be stored in "dir".
103+#
104+ optdefine P ports requires_argument
105+ opteval_ports() { APPNAME="$APPNAME MINGW_PORT_DIR='$optarg'"; }
106+
107+# Option -R, --repository=URL, specifies the internet "URL", from whence
108+# mingw-port specifications may be downloaded; the default is the standard
109+# MinGW ports repository, at "https://osdn.net/dl/mingw/mingw-ports".
110+#
111+ optdefine R repository requires_argument
112+ opteval_repository() { APPNAME="$APPNAME MINGW_PORT_REPOSITORY='$optarg'"; }
113+
114+# Option --download-only suppresses the normal build phase of mingw-port
115+# execution, terminating after download, and unpacking of the mingw-port
116+# specification, and associated package sources.
117+#
118+ optdefine download-only
119+ opteval_download_only() { download_only=true; }
120+
121+# Option --in-tree forces mingw-port to change directory, to the top of the
122+# package source tree, before proceeding to the build phase of execution,
123+# thus initiating an in-tree (in-source) build; by default, the current
124+# directory, at the time of mingw-port invocation, will become the active
125+# build directory, for an out-of-tree (out-of-source) build.
126+#
127+ optdefine in-tree
128+ opteval_in_tree() { in_tree=true; }
129+
130+# Evaluate processing options and local variable assignments, as specified
131+# by the user, on the command line.
132+#
133+ while optchk "$@"
134+ do shift $argshift; test "x${optmatch}x" = "x--x" && break; done
135+
136+# When all options have been evaluated, there should be exactly one agrument
137+# remaining, (representing the <package-version> ID for the port); if not,
138+# diagnose and abort.
139+#
140+ test $# -eq 1 || {
141+ invalid_usage() { local why
142+ test $1 -gt 1 && why="too many arguments" || why="missing argument"
143+ echo "syntax error: $why"; usage
144+ }
145+ die 1 "`invalid_usage $#`"
146+ }
147+
148+# The download, and unpacking, phase is always executed; it is delegated to
149+# the mingw-pkg application, which, together with any settings to propagate
150+# from mingw-port options, is named in the APPNAME variable.
151+#
152+ $APPNAME --id="$1" import
153+
154+# The build phase is optional; as with download and unpacking, it too is
155+# delegated to mingw-pkg, after first changing directory if necessary.
156+#
157+ ${download_only-false} || { build_actions="patch configure compile"
158+ ${in_tree-false} && { cd "${PACKAGE_DEPOT-.}/$1"; $APPNAME $build_actions
159+ } || $APPNAME --srcdir="${PACKAGE_DEPOT-.}/$1" $build_actions
160+ }
161+#
162+# -----------------------------------------------------------------------------
163+# $RCSfile$: end of file
--- /dev/null
+++ b/src/modules/porthelp.sh
@@ -0,0 +1,106 @@
1+# porthelp.sh
2+# -----------------------------------------------------------------------------
3+#
4+# mingw-pkg module implementing the mingw-port built-in help displays.
5+#
6+# -----------------------------------------------------------------------------
7+#
8+# $Id$
9+#
10+# Written by Keith Marshall <keith@users.osdn.me>
11+# Copyright (C) 2020, MinGW.org Project
12+#
13+# Permission is hereby granted, free of charge, to any person obtaining a copy
14+# of this software and associated documentation files (the "Software"), to deal
15+# in the Software without restriction, including without limitation the rights
16+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17+# copies of the Software, and to permit persons to whom the Software is
18+# furnished to do so, subject to the following conditions:
19+#
20+# The above copyright notice and this permission notice shall be included in
21+# all copies or substantial portions of the Software.
22+#
23+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29+# THE SOFTWARE.
30+#
31+# -----------------------------------------------------------------------------
32+#
33+ for help_class in all synopsis options actions
34+ do case $help_class in ${optarg-"all"}*) optarg=$help_class;; esac
35+ done
36+
37+ help_synopsis() { cat <<-ETX
38+ Usage: ${cmd="mingw-port"} [OPTIONS] package-version
39+
40+ Download and build the <package-version> package, as directed by the
41+ corresponding mingw-port specification.
42+
43+ ETX
44+ }
45+
46+ help_options() { cat <<-ETX
47+ Options:
48+ -h, --help[=class] Display help, and exit; "class" is any one of:--
49+ synopsis Show only the command synopsis.
50+ options Show the synopsis, and summary of options.
51+ all Show the full "help" display; (this is the default).
52+
53+ --licence Display the $cmd licence, and exit.
54+ --license A synonym for "--licence".
55+
56+ -V, --version Display the $cmd version, and exit.
57+
58+ -R, --repository=URL Specify the URL whence mingw-port specification
59+ files may be downloaded; (if unspecified, defaults
60+ to https://osdn.net/dl/mingw/mingw-ports).
61+
62+ -P, --ports=dir Specify a directory for local storage of mingw-port
63+ specification files; mingw-port will always search
64+ in the current working directory, followed by "dir",
65+ if specified, and finally in the internet repository
66+ specified by "-R URL", (or its built-in default); if
67+ the specification is found locally, the search stops
68+ immediately; otherwise, if the file is downloaded
69+ from the internet, and "-P dir" is specified, a copy
70+ will be stored in "dir", for future use.
71+
72+ -C, --cache-dir Specify a local directory for persistent storage of
73+ downloaded packages; (if unspecified, any downloaded
74+ package files will be deleted, after unpacking).
75+
76+ -D, --depot=dir Specify the root of the local mingw-port download
77+ and build directory tree; (if unspecified, defaults
78+ to the current working directory).
79+
80+ --download-only Download, and prepare the specified package source
81+ for building, but do not apply any patches from the
82+ mingw-port, or proceed to build the package.
83+
84+ --in-tree Build the package within its source tree; (if this
85+ is unspecified, mingw-port will attempt to build
86+ the package in the current working directory; if
87+ --download-only is also specified, --in-tree will
88+ be ignored).
89+
90+ Note that mandatory "dir", and "URL", arguments for long-form options are
91+ also required when specifying the corresponding short-form option.
92+
93+ ETX
94+ }
95+
96+ case $optarg in
97+ synopsis) help_$optarg;;
98+ options) help_synopsis; help_$optarg;;
99+ all) help_synopsis; help_options;;
100+ *) die 1 "unknown help category '$optarg'";;
101+ esac
102+
103+ exit 0
104+#
105+# -----------------------------------------------------------------------------
106+# $RCSfile$: end of file