qtcreator: Create *.pro.shared files instead of *.pro.user

Generating *.pro.user files is not ideal; they're
supposed to hold user-specific settings for a project,
and thus also to persist manual changes made by the user
after initial import of the project.

Generate *.pro.shared files instead which are
meant to be used to share project settings. [1]
This just changes the file name of the generated
file for now, but leaves the content the same.

The result for the initial loading of the project from
a '*.pro' file is basically still the same from a user
perspective:
A new kit 'Replacement for "Desktop"' is generated on
the fly which contains the build and run settings
specified in the corresponding '*.pro.shared' file.

By using the '*.pro.shared' files, user-specific settings
made after initial import will no longer
be overwritten by running 'make qtcreator-ide-integration'
again, since the '*.pro.user' files are left as they are.

The '*.pro.shared' files generated here still contain
information specific to the local setup (like file paths).

For some more background on LO's Qt Creator IDE integration,
s. dev mailing list thread "Added some information about
Qt Creator IDE integration to the wiki" [2].

[1] https://doc.qt.io/qtcreator/creator-sharing-project-settings.html
[2] https://lists.freedesktop.org/archives/libreoffice/2021-February/thread.html#86800

Change-Id: Ia187bcbffe5297a1cdf6bfeaaabf7867003195e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111474
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn 2021-02-24 09:51:16 +01:00
parent 61c2fb9a18
commit e827cb144e
2 changed files with 21 additions and 20 deletions

1
.gitignore vendored
View file

@ -142,6 +142,7 @@ LibreOffice.VC.VC.opendb
# QtCreator specific
*.pro
*.pro.shared
*.pro.user
*.pro.user.*

View file

@ -1511,33 +1511,33 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
"""
def generate_pro_user_content(self, lib_folder):
def generate_pro_shared_content(self, lib_folder):
build_configs = self.generate_build_configs(lib_folder)
deploy_configs = self.generate_deploy_configs(lib_folder)
run_configs = self.generate_run_configs(lib_folder)
xml = QtCreatorIntegrationGenerator.pro_user_template % {
xml = QtCreatorIntegrationGenerator.pro_shared_template % {
'build_configs': build_configs,
'deploy_configs': deploy_configs,
'run_configs': run_configs,
}
return xml
def generate_meta_pro_user_content(self):
def generate_meta_pro_shared_content(self):
build_configs = self.generate_meta_build_configs()
deploy_configs = self.generate_deploy_configs("")
run_configs = self.generate_run_configs("")
xml = QtCreatorIntegrationGenerator.pro_user_template % {
xml = QtCreatorIntegrationGenerator.pro_shared_template % {
'build_configs': build_configs,
'deploy_configs': deploy_configs,
'run_configs': run_configs,
}
return xml
pro_user_template = """<?xml version="1.0" encoding="UTF-8"?>
pro_shared_template = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.1.1, 2015-05-14T15:54:34. -->
<qtcreator>
@ -1645,10 +1645,10 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
self._log("unable to remove %s\n" % afile)
do_remove_file(self.base_folder, "lo.pro")
do_remove_file(self.base_folder, "lo.pro.user")
do_remove_file(self.base_folder, "lo.pro.shared")
for location in self.target_by_location:
for f in os.listdir(location):
if f.endswith('.pro') or f.endswith('.pro.user'):
if f.endswith('.pro') or f.endswith('.pro.shared'):
do_remove_file(location, f)
def get_source_extension(self, src_file):
@ -1756,7 +1756,7 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
self.base_folder = self.gbuildparser.builddir
# we remove existing '.pro' and '.pro.user' files
# we remove existing '.pro' and '.pro.shared' files
self.remove_qt_files()
# for .pro files, we must explicitly list all files (.c, .h)
@ -1797,15 +1797,15 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
print(temp, file=sys.stderr)
print("\n\n", file=sys.stderr)
# create .pro.user file
qt_pro_user_file = '%s/%s.pro.user' % (lib_loc, lib_name)
# create .pro.shared file
qt_pro_shared_file = '%s/%s.pro.shared' % (lib_loc, lib_name)
try:
with open(qt_pro_user_file, mode) as fprouser:
fprouser.write(self.generate_pro_user_content(lib_folder))
self._log("created %s\n" % qt_pro_user_file)
with open(qt_pro_shared_file, mode) as fproshared:
fproshared.write(self.generate_pro_shared_content(lib_folder))
self._log("created %s\n" % qt_pro_shared_file)
except Exception as e:
print("ERROR : creating pro.user file=" + qt_pro_user_file, file=sys.stderr)
print("ERROR : creating pro.shared file=" + qt_pro_shared_file, file=sys.stderr)
print(e, file=sys.stderr)
temp = traceback.format_exc()
print(temp, file=sys.stderr)
@ -1826,15 +1826,15 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
print(temp, file=sys.stderr)
print("\n\n", file=sys.stderr)
# create meta .pro.user file
qt_meta_pro_user_file = 'lo.pro.user'
# create meta .pro.shared file
qt_meta_pro_shared_file = 'lo.pro.shared'
try:
with open(qt_meta_pro_user_file, mode) as fmprouser:
fmprouser.write(self.generate_meta_pro_user_content())
self._log("created %s\n" % qt_meta_pro_user_file)
with open(qt_meta_pro_shared_file, mode) as fmproshared:
fmproshared.write(self.generate_meta_pro_shared_content())
self._log("created %s\n" % qt_meta_pro_shared_file)
except Exception as e:
print("ERROR : creating lo.pro.user file=" + qt_meta_pro_user_file, file=sys.stderr)
print("ERROR : creating lo.pro.shared file=" + qt_meta_pro_shared_file, file=sys.stderr)
print(e, file=sys.stderr)
temp = traceback.format_exc()
print(temp, file=sys.stderr)