diff options
| author | Joel Linn <jl@conductive.de> | 2020-11-08 22:28:36 +0100 |
|---|---|---|
| committer | Rick Gibbed <rick@gibbed.us> | 2020-11-14 13:30:06 -0600 |
| commit | 171c97c9294460450b93ac635d225c2515e2c7e2 (patch) | |
| tree | 9f2b5ef9b5d98dd5ccb5926ef404e7a94ce3e180 /xenia-build | |
| parent | 9233f85c30231555d016efde7437892139438db5 (diff) | |
Start CLion by invoking `xb devenv` when available
Diffstat (limited to 'xenia-build')
| -rwxr-xr-x | xenia-build | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/xenia-build b/xenia-build index 3b27e656f..89a14c651 100755 --- a/xenia-build +++ b/xenia-build @@ -88,6 +88,16 @@ def main(): sys.exit(return_code) +def print_box(msg): + """Prints an important message inside a box + """ + print( + '┌{0:─^{2}}╖\n' + '│{1: ^{2}}║\n' + '╘{0:═^{2}}╝\n' + .format('', msg, len(msg) + 2)) + + def import_vs_environment(): """Finds the installed Visual Studio version and imports interesting environment variables into os.environ. @@ -153,6 +163,7 @@ def import_subprocess_environment(args): os.environ[var.upper()] = setting break + def has_bin(binary): """Checks whether the given binary is present. @@ -408,6 +419,43 @@ def get_build_bin_path(args): return os.path.join(self_path, 'build', 'bin', platform.capitalize(), args['config'].capitalize()) +def create_clion_workspace(): + """Creates some basic workspace information inside the .idea directory for first start. + """ + if os.path.exists('.idea'): + # No first start + return False + print('Generating CLion workspace files...') + # Might become easier in the future: https://youtrack.jetbrains.com/issue/CPP-7911 + + # Set the location of the CMakeLists.txt + os.mkdir('.idea') + with open(os.path.join('.idea', 'misc.xml'), 'w') as f: + f.write("""<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$/build"> + <contentRoot DIR="$PROJECT_DIR$" /> + </component> +</project> +""") + + # Set available configurations + # TODO Find a way to trigger a cmake reload + with open(os.path.join('.idea', 'workspace.xml'), 'w') as f: + f.write("""<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CMakeSettings"> + <configurations> + <configuration PROFILE_NAME="Checked" CONFIG_NAME="Checked" /> + <configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" /> + <configuration PROFILE_NAME="Release" CONFIG_NAME="Release" /> + </configurations> + </component> +</project>""") + + return True + + def discover_commands(subparsers): """Looks for all commands and returns a dictionary of them. In the future commands could be discovered on disk. @@ -1446,8 +1494,13 @@ class DevenvCommand(Command): def execute(self, args, pass_args, cwd): devenv = None + show_reload_prompt = False if sys.platform == 'win32': print('Launching Visual Studio...') + elif has_bin('clion') or has_bin('clion.sh'): + print('Launching CLion...') + show_reload_prompt = create_clion_workspace() + devenv = 'cmake' else: print('Launching CodeLite...') devenv = 'codelite' @@ -1458,11 +1511,23 @@ class DevenvCommand(Command): print('') print('- launching devenv...') + if show_reload_prompt: + print_box('Please run "File ⇒ ↺ Reload CMake Project" from inside the IDE!') if sys.platform == 'win32': shell_call([ 'devenv', 'build\\xenia.sln', ]) + elif has_bin('clion'): + shell_call([ + 'clion', + '.', + ]) + elif has_bin('clion.sh'): + shell_call([ + 'clion.sh', + '.', + ]) else: shell_call([ 'codelite', |
