Code Monkey home page Code Monkey logo

applauncher's Introduction

CTKAppLauncher

Overview

CTK Application launcher is a lightweight open-source utility allowing to set environment before starting a real application.

The launcher is available on Linux, Windows and macOS.

Read the wiki for more details.

Build Status

Linux macOS Windows

contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

See CONTRIBUTING.md for more details.

maintainers: how to make a release ?

Follow step below after checking that all tests pass

  1. List all tags sorted by version

    git fetch --tags && \
    git tag -l | sort -V
  2. Choose the next release version number (without

    tag=vX.Y.Z
    
    version_major=$(echo $tag | tr -d v | cut -d. -f1)
    version_minor=$(echo $tag | tr -d v | cut -d. -f2)
    version_patch=$(echo $tag | tr -d v | cut -d. -f3)
    echo "version_major [$version_major] version_minor[$version_minor] version_patch[$version_patch]"
  3. Update CMakeLists.txt setting CTKAppLauncher_VERSION_IS_RELEASE and CTKAppLauncher_*_VERSION variables

    sed -E "s/set\(CTKAppLauncher_VERSION_IS_RELEASE 0\)/set\(CTKAppLauncher_VERSION_IS_RELEASE 1\)/g" -i CMakeLists.txt && \
    sed -E "s/set\(CTKAppLauncher_MAJOR_VERSION [0-9]+\)/set\(CTKAppLauncher_MAJOR_VERSION $version_major\)/g" -i CMakeLists.txt && \
    sed -E "s/set\(CTKAppLauncher_MINOR_VERSION [0-9]+\)/set\(CTKAppLauncher_MINOR_VERSION $version_minor\)/g" -i CMakeLists.txt && \
    sed -E "s/set\(CTKAppLauncher_BUILD_VERSION [0-9]+\)/set\(CTKAppLauncher_BUILD_VERSION $version_patch\)/g" -i CMakeLists.txt && \
    git add CMakeLists.txt && \
    git commit -m "CTKAppLauncher $tag" && \
    git diff HEAD^
  4. Tag the release. Requires a GPG key with signatures:

    git tag -s -m "CTKAppLauncher $tag" $tag main
  5. Publish the tag and main branch to trigger the release build

    git push origin $tag && \
    git push origin main

Important: Until issue scikit-build/scikit-ci-addons/issues/96 is addressed, macOS release package should be manually downloaded from the GitHub Actions artifact and uploaded as a GitHub release asset.

  1. Update CMakeLists.txt setting CTKAppLauncher_VERSION_IS_RELEASE to 0

    sed -E "s/set\(CTKAppLauncher_VERSION_IS_RELEASE 1\)/set\(CTKAppLauncher_VERSION_IS_RELEASE 0\)/g" -i CMakeLists.txt && \
    git add CMakeLists.txt && \
    git commit -m "Begin post-$tag development [ci skip]" && \
    git diff HEAD^
  2. Publish the changes:

    git push origin main

License

It is covered by the Apache License, Version 2.0:

http://www.apache.org/licenses/LICENSE-2.0

applauncher's People

Contributors

acetylsalicyl avatar finetjul avatar ihnorton avatar jamesobutler avatar jcfr avatar lassoan avatar msmolens avatar mwoehlke-kitware avatar pieper avatar saschazelzer avatar thewtex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

applauncher's Issues

Environment variable in additional settings overwrite regular settings

For example, if the regular settings file is similar to:

[EnvironmentVariables]
FOO=bar

.. and the additonal settings file is similar to:

[EnvironmentVariables]
FOO=bie

Assuming the additional settings is passed to the launcher using the --launcher-additional-settings command line option, the environment variable FOO will be set to bie.

This is not always the desired behavior. Indeed, sometimes it makes sens for the additional settings to update the environment variable instead of overwriting it.

To allow environment variable already set by the launcher to be considered, the following mechanism could be implemented. Considering this additional settings file:

FOO=<env:FOO>:bie

... the corresponding environment variable set by the launcher will be bar:bie.

Similarly, if the additional settings file is:

FOO=bie:<env:FOO>

... the corresponding environment variable set by the launcher will be bie:bar.

Related to #17

Create Launcher library

When packaging application on MacOSX (as bundle), no launcher is needed since all the libraries are "fixed up" so that they can be referenced relatively to the location of the executable.

When building a cross platform application, it resumes the path and other environment variables are setup in multiple location:

  • Launcher settings for application distributed on windows/linux
  • main.cpp or Q(Core)Application derived class.

On MacOSX, by creating a launcher library that could be linked (statically) against our application, we could ensure that all paths/environment variables are set a common location for all platform.

Thanks @finetjul for suggesting this approach.

Update README file

From @finetjul:

README in repository is empty, it is not obvious for a new developer to know where 
to find documentation of the launcher. 
Maybe the contents of the following page could be in README:
http://www.commontk.org/index.php/Tools:_Application_launcher

Fix "has different visibility" warnings occurring on MacOSX

See http://my.cdash.org/viewBuildError.php?type=1&buildid=368016

ld: warning: QList<QString>::detach_helper_grow(int, int)has different visibility (default) in bin/libCTKAppLauncherBase.a(ctkAppLauncher.cpp.o) and (hidden) in /path/to/libQtCore.a(qstring.o)
ld: warning: QList<QString>::removeAll(QString const&)has different visibility (hidden) in /path/to/libQtCore.a(qcoreapplication.o) and (default) in bin/libCTKAppLauncherBase.a(ctkAppLauncher.cpp.o)
ld: warning: QList<QString>::~QList() has different visibility (hidden) in /path/to/libQtCore.a(qdir.o) and (default) in bin/libCTKAppLauncherBase.a(ctkAppLauncher.cpp.o)
ld: warning: QList<QString>::append(QString const&)has different visibility (default) in bin/libCTKAppLauncherBase.a(ctkAppArguments.cpp.o) and (hidden) in /path/to/libQtCore.a(qstring.o)

See https://bugreports.qt-project.org/browse/QTBUG-3995 for a possible solution

Launcher isn't copied if deleted from destination dir

Step to reproduce

  1. Configure and build project
  2. Delete launcher
  3. Build

=> The launcher won't be available

Workaround

  • Delete LauncherSettings* files.

Solution:

  • Add an extra dependency to the custom_command configure the launcher

Provide a mechanism to change the icon associated with the launcher

Following my first investigation, it resumes that developing a small tool (ie CTKResEdit) that could be used to change the icon embedded in a window pre-build binary.

It could also be worth doing more research to confirm that can't be done using the tool provided with Visual Studio.

In any case, one (or more) CMake function(s) will have to be developed and should be available after generating the package on windows.

See:

No --help command line argument

Get sources, in build dir, configure and build AppLauncher
from a console, type: ./bin/AppLauncher
errors are output because no --launch is passed -> ok
Then a natural step is to do: ./bin/AppLauncher --help
-> doesn't output the available launcher options or more details on how to use it

After reading documentation, it appears that it should be --launcher-help. Maybe if no application to launch is given --help could print what --launcher-help would

Arguments passed to the application to launch are duplicated

For example:

$ bin/CTKAppLauncher --launcher-verbose --launch /bin/ls -a -l 
info: LauncherDir [/home/jchris/Projects/CTKAppLauncher-Debug/bin]
info: LauncherName [CTKAppLauncher]
[...]
info: ApplicationToLaunch [/bin/ls]
info: ApplicationToLaunchArguments [-a -l]
info: <APPLAUNCHER_DIR> -> [/home/jchris/Projects/CTKAppLauncher-Debug/bin]
info: Starting [/bin/ls]
info: argument [-a]
info: argument [-l]
info: argument [-a]
info: argument [-l]
info: launcher-timeout (ms) [-1000]
[...]

Support for additional settings

When using the launcher associated with ApplicationFoo while testing if some plugin can be loaded within ApplicationFoo, it could be useful to "temporary" associate settings without having to update the main settings.

The concept of additional-settings could be introduced.

Part1 - See #9

The command line argument --launcher-additional-settings could be used to associate one (or more - see part3) setting file(s) that will be merge at run time with the settings read from the "main" settings file.

Part 2 - See #10

The parameter additional-settings could eventually be a parameter read from the "main" settings file.

If both 'additional-settings' is set within the main settings and the command line parameter '--launcher-additional-settings' are passed, all the settings will be "merged" together. This behaviour could be avoided by passing the command line --ignore-additional-settings.

Part3 - See #11

Support mutliple settings file passed using --launcher-additional-settings

Launcher should ignore arguments after an extra application argument

Consider Slicer, which has e.g. an extra application argument --gdb. If I want to read GDB's CLI help, I would run /path/to/Slicer --gdb --help. This works okay, but, the launcher also reads the --help option and shows the help for Slicer as well.

Also, the launcher does not recognize -- to ignore following options.

For extra applications, the launcher should ignore any arguments following the extra application argument, at least when preceded by --.

Transparent splash screen

The splash screen is not transparent even if the provided image is transparent.
I wonder if it is because the Qt::SplashScreen window flag is missing.

Implement mechanism to keep track of original environment

As suggested by @lassoan , a robust way of keeping track of the original environment using the following approach:

We could save the original values of the modified/added/removed environment variables in other environment variables?

For example:

PATH=...new path with additional values...
PYTHONPATH=...modified by this applauncher...
LD_LIBRARY_PATH=...modified by this applauncher...
APPLAUNCHER_LEVEL=0
APPLAUNCHER_0_PATH=...original path before the applauncher modified it...
APPLAUNCHER_0_PYTHONPATH=...original path before the applauncher modified it...
APPLAUNCHER_0_SOME_DELETED_VAR=...stores value of a deleted env var DELETED_VAR...
APPLAUNCHER_0_SOME_ADDED_VAR=

To restore previous level's environment, you would just need to go through all the APPLAUNCHER__* variables and set them. Set to empty value deletes an env var, so this can be used for deleting added env vars as well.

APPLAUNCHER_LEVEL can be used for cleanly managing multiple levels off app launching (applauncher library running an application that uses applauncher). For example:

PATH=...new path with additional values...
PYTHONPATH=...modified by this applauncher...
LD_LIBRARY_PATH=...modified by this applauncher...
APPLAUNCHER_LEVEL=1
APPLAUNCHER_0_PATH=...original path before the applauncher modified it...
APPLAUNCHER_0_SOME_DELETED_VAR=...stores value of a deleted env var DELETED_VAR...
APPLAUNCHER_0_SOME_ADDED_VAR=
APPLAUNCHER_1_PATH=...original path before the applauncher modified it...
APPLAUNCHER_1_SOME_DELETED_VAR=...stores value of a deleted env var DELETED_VAR..
APPLAUNCHER_1_SOME_MORE_DELETED_VAR=...stores value of a deleted env var SOME_MORE_DELETED_VAR...
APPLAUNCHER_1_SOME_ADDED_VAR=
APPLAUNCHER_1_SOME_MORE_ADDED_VAR=

If a launcher did not modify any env vars then it would just increment APPLAUNCHER_LEVEL.

AppLauncher library could be responsible for creating environments from previous levels.

`--ignore-rest` does not work correctly

As far as I understand, it should allow to pass further arguments only to the launched binary, but:

``` sliceruser@8192a65779e5:~/Slicer-4.9.0-2018-10-14-linux-amd64$ ./Slicer --launch ./bin/python-real --ignore-rest -h Usage Slicer [options]

Options
--launcher-help Display help
--launcher-version Show launcher version information
--launcher-verbose Verbose mode
--launch Specify the application to launch
--launcher-detach Launcher will NOT wait for the application to finish
--launcher-no-splash Hide launcher splash
--launcher-timeout Specify the time in second before the launcher kills the application. -1 means no timeout (default: -1)
--launcher-load-environment Specify the saved environment to load.
--launcher-dump-environment Launcher will print environment variables to be set, then exit
--launcher-show-set-environment-commands Launcher will print commands suitable for setting the parent environment (i.e. using 'eval' in a POSIX shell), then exit
--launcher-additional-settings Additional settings file to consider
--launcher-additional-settings-exclude-groups Comma separated list of settings groups that should NOT be overwritten by values in User and Additional settings. For example: General,Application,ExtraApplicationToLaunch
--launcher-ignore-user-additional-settings Ignore additional user settings
--launcher-generate-exec-wrapper-script Generate executable wrapper script allowing to set the environment
--launcher-generate-template Generate an example of setting file
Unknown option: --
usage: ./bin/python-real [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
sliceruser@8192a65779e5:~/Slicer-4.9.0-2018-10-14-linux-amd64$ ./Slicer --launch ./bin/python-real -- -h
Usage
Slicer [options]

Options
--launcher-help Display help
--launcher-version Show launcher version information
--launcher-verbose Verbose mode
--launch Specify the application to launch
--launcher-detach Launcher will NOT wait for the application to finish
--launcher-no-splash Hide launcher splash
--launcher-timeout Specify the time in second before the launcher kills the application. -1 means no timeout (default: -1)
--launcher-load-environment Specify the saved environment to load.
--launcher-dump-environment Launcher will print environment variables to be set, then exit
--launcher-show-set-environment-commands Launcher will print commands suitable for setting the parent environment (i.e. using 'eval' in a POSIX shell), then exit
--launcher-additional-settings Additional settings file to consider
--launcher-additional-settings-exclude-groups Comma separated list of settings groups that should NOT be overwritten by values in User and Additional settings. For example: General,Application,ExtraApplicationToLaunch
--launcher-ignore-user-additional-settings Ignore additional user settings
--launcher-generate-exec-wrapper-script Generate executable wrapper script allowing to set the environment
--launcher-generate-template Generate an example of setting file
./bin/python-real: can't open file '-h': [Errno 2] No such file or directory
sliceruser@8192a65779e5:~/Slicer-4.9.0-2018-10-14-linux-amd64$ ./Slicer --launch ./bin/python-real -h
Usage
Slicer [options]

Options
--launcher-help Display help
--launcher-version Show launcher version information
--launcher-verbose Verbose mode
--launch Specify the application to launch
--launcher-detach Launcher will NOT wait for the application to finish
--launcher-no-splash Hide launcher splash
--launcher-timeout Specify the time in second before the launcher kills the application. -1 means no timeout (default: -1)
--launcher-load-environment Specify the saved environment to load.
--launcher-dump-environment Launcher will print environment variables to be set, then exit
--launcher-show-set-environment-commands Launcher will print commands suitable for setting the parent environment (i.e. using 'eval' in a POSIX shell), then exit
--launcher-additional-settings Additional settings file to consider
--launcher-additional-settings-exclude-groups Comma separated list of settings groups that should NOT be overwritten by values in User and Additional settings. For example: General,Application,ExtraApplicationToLaunch
--launcher-ignore-user-additional-settings Ignore additional user settings
--launcher-generate-exec-wrapper-script Generate executable wrapper script allowing to set the environment
--launcher-generate-template Generate an example of setting file
usage: ./bin/python-real [option] ... [-c cmd | -m mod | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
-c cmd : program passed in as string (terminates option list)
-d : debug output from parser; also PYTHONDEBUG=x
-E : ignore PYTHON* environment variables (such as PYTHONPATH)
-h : print this help message and exit (also --help)
-i : inspect interactively after running script; forces a prompt even
if stdin does not appear to be a terminal; also PYTHONINSPECT=x
-m mod : run library module as a script (terminates option list)
-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x
-OO : remove doc-strings in addition to the -O optimizations
-R : use a pseudo-random salt to make hash() values of various types be
unpredictable between separate invocations of the interpreter, as
a defense against denial-of-service attacks
-Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE
-S : don't imply 'import site' on initialization
-t : issue warnings about inconsistent tab usage (-tt: issue errors)
-u : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x
see man page for details on internal buffering relating to '-u'
-v : verbose (trace import statements); also PYTHONVERBOSE=x
can be supplied multiple times to increase verbosity
-V : print the Python version number and exit (also --version)
-W arg : warning control; arg is action:message:category:module:lineno
also PYTHONWARNINGS=arg
-x : skip first line of source, allowing use of non-Unix forms of #!cmd
-3 : warn about Python 3.x incompatibilities that 2to3 cannot trivially fix
file : program read from script file

  •  : program read from stdin (default; interactive mode if a tty)
    

arg ...: arguments passed to program in sys.argv[1:]

Other environment variables:
PYTHONSTARTUP: file executed on interactive startup (no default)
PYTHONPATH : ':'-separated list of directories prefixed to the
default module search path. The result is sys.path.
PYTHONHOME : alternate directory (or :<exec_prefix>).
The default module search path uses /pythonX.X.
PYTHONCASEOK : ignore case in 'import' statements (Windows).
PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.
PYTHONHASHSEED: if this variable is set to 'random', the effect is the same
as specifying the -R option: a random value is used to seed the hashes of
str, bytes and datetime objects. It can also be set to an integer
in the range [0,4294967295] to get hash values with a predictable seed.

</details>

Add an option '--generate-exec-wrapper-script'

On the different platform, this option could respectively generate a

  • BAT file (windows)
  • Shell script (Mac OSX and Linux)

Later on an option --exec-wrapper-script-format allowing to override the auto-selected wrapper script format could be added.

The generated wrapper script could be used to set the environment without having to use the launcher. It could for example be set as a exec-wrapper in gdb

Generalize <env:VARNAME> to system environment

When setting environment variable in either

(1) the regular

or

(2) the additional settings file,

the special variable <env:VARNAME> should evaluate to either

(1) the associated system environment variable if one is set

or

(2) first the associated variable set in the regular settings if any and then the associated system environment variable if one is set.

Related to #16

Tiny patch to be able to compile on Solaris with cc/CC

Hi developers,

I forked and patched and pushed... so here is the branch I created for ctklauncher to be able to compile it on OpenIndiana (~Solaris) with Solaris's own compilers (unpatched Studio 12.3's cc/CC)
Also changed one .h file that gave warnings about superfluous ";" at the end of four lines - it's only a cosmetic change; cc/CC is more picky than gcc.
Here it is:
https://github.com/acetylsalicyl/AppLauncher/tree/solaris

Could you please consider to merge these changes?
Thanks a lot,
Attila Nagy

--launcher-show-set-environment-commands uses wrong separator

When using the option --launcher-show-set-environment-commands on windows within Git bash, the list of path are separated using ; whereas : is expected.

For example, in a posix shell on either windows or unix, the following is expected:

PATH=/path/thing1:/path/thing2
PYTHONPATH=/path/module1:/path/module2

but on windows, in a posix shell .. the following is returned:

PATH=/path/thing1;/path/thing2
PYTHONPATH=/path/module1;/path/module2

The issue is here in function generateEnvironmentScript.

An internal function named pathSep(bool posix) could be added.

Reported by @vovythevov

Add a mechanism to disable the splashscreen from within the settings

What works

It's currently possible to disable the splash screen by using the command line option --launcher-no-splash

The problem

On the other hand, the use case where the splash screen needs to be disabled from within the settings doesn't seem to work. Indeed, adding the option --launcher-no-splash as illustrated below fails since the option is passed to the called program.

[Application]
path=/usr/bin/python
arguments=--launcher-no-splash

Possible workaround:

  • Add a setting entry additionalLauncherNoSplashArguments to the General group containing the list of command line option that shouldn't be associated with a splash screen.
  • Associate a 1x1 pixel transparent png as a splash screen

Improve versioning process

Two following options could be introduced:
CTKAppLauncher_VERSION_IS_RELEASE and CTKAppLauncher_VERSION_RC

  • If CTKAppLauncher_VERSION_IS_RELEASE is set to 0:
    • the git SHA1 will be appended to the current app launcher version.
  • If CTKAppLauncher_VERSION_IS_RELEASE is set to 1:
    • Nothing will be appended to the version string. The version string would have the following form: X.Y.Z
    • If CTKAppLauncher_VERSION_RC is defined and set to an integer: -rc{CTKAppLauncher_VERSION_RC} will b e appended to the version string.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.