Skip to content

Commit

Permalink
build: teach macdeploy the -translations-dir argument, for use with s…
Browse files Browse the repository at this point in the history
…tatic qt

When QT is linked statically, macdeploy can't infer its paths. While plugins
and frameworks don't need to be packaged, translations still do (for now).
  • Loading branch information
theuni committed Aug 6, 2014
1 parent f8120f7 commit 71941ce
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion contrib/macdeploy/macdeployqtplus
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ ap.add_argument("-sign", dest="sign", action="store_true", default=False, help="
ap.add_argument("-dmg", nargs="?", const="", metavar="basename", help="create a .dmg disk image; if basename is not specified, a camel-cased version of the app name is used")
ap.add_argument("-fancy", nargs=1, metavar="plist", default=[], help="make a fancy looking disk image using the given plist file with instructions; requires -dmg to work")
ap.add_argument("-add-qt-tr", nargs=1, metavar="languages", default=[], help="add Qt translation files to the bundle's ressources; the language list must be separated with commas, not with whitespace")
ap.add_argument("-translations-dir", nargs=1, metavar="path", default=None, help="Path to Qt's translation files")
ap.add_argument("-add-resources", nargs="+", metavar="path", default=[], help="list of additional files or folders to be copied into the bundle's resources; must be the last argument")

config = ap.parse_args()
Expand All @@ -467,6 +468,15 @@ if not os.path.exists(app_bundle):
app_bundle_name = os.path.splitext(os.path.basename(app_bundle))[0]

# ------------------------------------------------
translations_dir = None
if config.translations_dir and config.translations_dir[0]:
if os.path.exists(config.translations_dir[0]):
translations_dir = config.translations_dir[0]
else:
if verbose >= 1:
sys.stderr.write("Error: Could not find translation dir \"%s\"\n" % (translations_dir))
sys.exit(1)
# ------------------------------------------------

for p in config.add_resources:
if verbose >= 3:
Expand Down Expand Up @@ -590,7 +600,14 @@ if config.plugins:
if len(config.add_qt_tr) == 0:
add_qt_tr = []
else:
qt_tr_dir = os.path.join(deploymentInfo.qtPath, "translations")
if translations_dir is not None:
qt_tr_dir = translations_dir
else:
if deploymentInfo.qtPath is not None:
qt_tr_dir = os.path.join(deploymentInfo.qtPath, "translations")
else:
sys.stderr.write("Error: Could not find Qt translation path\n")
sys.exit(1)
add_qt_tr = ["qt_%s.qm" % lng for lng in config.add_qt_tr[0].split(",")]
for lng_file in add_qt_tr:
p = os.path.join(qt_tr_dir, lng_file)
Expand Down

0 comments on commit 71941ce

Please sign in to comment.