Updated gewf source code to allow custom settings,

and in particular the location of the templates.
Fixed compilation of application launcher, and make it more flexible.
This commit is contained in:
2013-11-08 16:16:45 +01:00
parent 026f8ae608
commit e20dd076c3
8 changed files with 262 additions and 91 deletions

View File

@@ -1,3 +1,4 @@
The gewf tool, is an experimentation to generate EWF project from template. The gewf tool, is an experimentation to generate EWF project from template.
status: experimental, POC, in-progress, draft status: experimental, POC, in-progress, draft

View File

@@ -10,6 +10,7 @@
</file_rule> </file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="transitional" syntax="standard"> <option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="transitional" syntax="standard">
</option> </option>
<setting name="console_application" value="true"/>
<setting name="executable_name" value="gewf"/> <setting name="executable_name" value="gewf"/>
<setting name="concurrency" value="none"/> <setting name="concurrency" value="none"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>

View File

@@ -18,6 +18,8 @@ feature {NONE} -- Initialization
args: ARGUMENTS_32 args: ARGUMENTS_32
cfg: detachable READABLE_STRING_32 cfg: detachable READABLE_STRING_32
do do
create setup.make
create args create args
if args.argument_count > 0 then if args.argument_count > 0 then
cfg := args.argument (1) cfg := args.argument (1)
@@ -28,13 +30,11 @@ feature {NONE} -- Initialization
execute execute
end end
feature -- Status setup: GEWF_SETUP
feature -- Access feature -- Access
config (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_32 config (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
local
l_keys: LIST [READABLE_STRING_GENERAL]
do do
if attached {JSON_STRING} json_item (json, k) as js then if attached {JSON_STRING} json_item (json, k) as js then
Result := js.unescaped_string_32 Result := js.unescaped_string_32
@@ -95,6 +95,9 @@ feature -- Access
create p.make_parser (s) create p.make_parser (s)
json := p.parse json := p.parse
if attached config ("gewf.template_dir") as d then
setup.set_template_dir_from_string (d)
end
end end
json: detachable JSON_VALUE json: detachable JSON_VALUE
@@ -141,8 +144,7 @@ feature -- Execution
p: PATH p: PATH
appname: detachable READABLE_STRING_GENERAL appname: detachable READABLE_STRING_GENERAL
do do
create p.make_from_string ("template") p := setup.template_dir.extended (tpl)
p := p.extended (tpl)
appname := vals.item ("APPNAME") appname := vals.item ("APPNAME")
if appname = Void then if appname = Void then
appname := "_generated" appname := "_generated"

View File

@@ -0,0 +1,109 @@
note
description: "[
Configuration of GEWF tool.
]"
date: "$Date$"
revision: "$Revision$"
class
GEWF_SETUP
inherit
SHARED_EXECUTION_ENVIRONMENT
create
make
feature -- Initialization
make
do
--| root_dir
get_root_dir
--| template_dir
get_template_dir
end
get_root_dir
local
ut: FILE_UTILITIES
p: detachable PATH
do
--| either $GEWF, or $HOME/.gewf or cwd/.gewf or cwd
if attached execution_environment.item ("GEWF") as s then
create p.make_from_string (s)
elseif attached execution_environment.item ("HOME") as s then
create p.make_from_string (s)
p := p.extended (".gewf")
create ut
if not ut.directory_path_exists (p) then
p := Void
end
end
if p = Void then
p := execution_environment.current_working_path
if ut.directory_path_exists (p.extended (".gewf")) then
p := p.extended (".gewf")
end
end
root_dir := p
end
get_template_dir
do
if attached execution_environment.item ("GEWF_TEMPLATE_DIR") as tpl_dir then
create template_dir.make_from_string (tpl_dir)
else
template_dir := root_dir.extended ("template")
end
end
feature -- Access
root_dir: PATH
template_dir: PATH
feature -- Status report
is_custom_template_dir: BOOLEAN
is_custom_root_dir: BOOLEAN
feature -- Change
set_root_dir (p: PATH)
do
is_custom_root_dir := True
root_dir := p
if not is_custom_template_dir then
-- update template_dir
get_template_dir
end
end
set_template_dir_from_string (dn: READABLE_STRING_GENERAL)
do
set_template_dir (create {PATH} .make_from_string (dn))
end
set_template_dir (p: PATH)
do
is_custom_template_dir := True
template_dir := p
end
;note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,85 +1,18 @@
note note
description: "Summary description for {APPLICATION_LAUNCHER}." description: "[
author: "" Effective class for APPLICATION_LAUNCHER_I
You can put modification in this class
]"
date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $" date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $"
revision: "$Revision: 36 $" revision: "$Revision: 36 $"
deferred class class
APPLICATION_LAUNCHER APPLICATION_LAUNCHER
feature {NONE} -- Initialization inherit
APPLICATION_LAUNCHER_I
launcher_nature: detachable READABLE_STRING_8 feature -- Custom
-- Initialize the launcher nature
-- either cgi, libfcgi, or nino.
--| We could extend with more connector if needed.
--| and we could use WSF_DEFAULT_SERVICE_LAUNCHER to configure this at compilation time.
local
p: PATH
l_entry_name: READABLE_STRING_32
ext: detachable READABLE_STRING_32
do
create p.make_from_string (execution_environment.arguments.command_name)
if attached p.entry as l_entry then
ext := l_entry.extension
end
if ext /= Void then
if ext.same_string (nature_nino) then
Result := nature_nino
end
if ext.same_string (nature_cgi) then
Result := nature_cgi
end
if ext.same_string (nature_libfcgi) or else ext.same_string ("fcgi") then
Result := nature_libfcgi
end
end
end
feature {NONE} -- nino
nature_nino: STRING = "nino"
launch_nino (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
do
create {WSF_NINO_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
end
feature {NONE} -- cgi
nature_cgi: STRING = "cgi"
launch_cgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
do
create {WSF_CGI_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
end
feature {NONE} -- libfcgi
nature_libfcgi: STRING = "libfcgi"
launch_libfcgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
do
create {WSF_LIBFCGI_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
end
feature {NONE} -- Launcher
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
nature: like launcher_nature
do
nature := launcher_nature
if nature = Void or else nature = nature_nino then
launch_nino (a_service, opts)
elseif nature = nature_cgi then
launch_cgi (a_service, opts)
elseif nature = nature_libfcgi then
launch_libfcgi (a_service, opts)
else
-- bye bye
(create {EXCEPTIONS}).die (-1)
end
end
end end

View File

@@ -0,0 +1,101 @@
note
description: "[
Specific application launcher
DO NOT EDIT THIS CLASS
you can customize APPLICATION_LAUNCHER
]"
date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $"
revision: "$Revision: 36 $"
deferred class
APPLICATION_LAUNCHER_I
inherit
SHARED_EXECUTION_ENVIRONMENT
feature -- Execution
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
nature: like launcher_nature
do
nature := launcher_nature
if nature = Void or else nature = nature_nino then
launch_nino (a_service, opts)
elseif nature = nature_cgi then
launch_cgi (a_service, opts)
elseif nature = nature_libfcgi then
launch_libfcgi (a_service, opts)
else
-- bye bye
(create {EXCEPTIONS}).die (-1)
end
end
feature {NONE} -- Access
launcher_nature: detachable READABLE_STRING_8
-- Initialize the launcher nature
-- either cgi, libfcgi, or nino.
--| We could extend with more connector if needed.
--| and we could use WSF_DEFAULT_SERVICE_LAUNCHER to configure this at compilation time.
local
p: PATH
l_entry_name: READABLE_STRING_32
ext: detachable READABLE_STRING_32
do
create p.make_from_string (execution_environment.arguments.command_name)
if attached p.entry as l_entry then
ext := l_entry.extension
end
if ext /= Void then
if ext.same_string (nature_nino) then
Result := nature_nino
end
if ext.same_string (nature_cgi) then
Result := nature_cgi
end
if ext.same_string (nature_libfcgi) or else ext.same_string ("fcgi") then
Result := nature_libfcgi
end
end
end
feature {NONE} -- nino
nature_nino: STRING = "nino"
launch_nino (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
launcher: WSF_NINO_SERVICE_LAUNCHER
do
create launcher.make_and_launch (a_service, opts)
end
feature {NONE} -- cgi
nature_cgi: STRING = "cgi"
launch_cgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
launcher: WSF_CGI_SERVICE_LAUNCHER
do
create launcher.make_and_launch (a_service, opts)
end
feature {NONE} -- libfcgi
nature_libfcgi: STRING = "libfcgi"
launch_libfcgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
launcher: WSF_LIBFCGI_SERVICE_LAUNCHER
do
create launcher.make_and_launch (a_service, opts)
end
end

View File

@@ -1,19 +1,18 @@
note note
description: "Summary description for {APPLICATION}." description: "[
author: "" Effective class for APPLICATION_LAUNCHER_I
You can put modification in this class
]"
date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $" date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $"
revision: "$Revision: 36 $" revision: "$Revision: 36 $"
deferred class class
APPLICATION_LAUNCHER APPLICATION_LAUNCHER
feature {NONE} -- Launcher inherit
APPLICATION_LAUNCHER_I
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) feature -- Custom
local
launcher: WSF_SERVICE_LAUNCHER
do
create {WSF_DEFAULT_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
end
end end

View File

@@ -0,0 +1,25 @@
note
description: "[
Specific application launcher
DO NOT EDIT THIS CLASS
you can customize APPLICATION_LAUNCHER
]"
date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $"
revision: "$Revision: 36 $"
deferred class
APPLICATION_LAUNCHER_I
feature -- Execution
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
launcher: WSF_SERVICE_LAUNCHER
do
create {WSF_DEFAULT_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
end
end