Skip to content

Commit

Permalink
First stab at fixing mL vs ml (Brewtarget/brewtarget#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Young committed Mar 7, 2023
1 parent f2e3acc commit 791fe5c
Show file tree
Hide file tree
Showing 32 changed files with 338 additions and 182 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ jobs:
path: |
${{github.workspace}}/build/brewken*.dmg
${{github.workspace}}/build/brewken*.dmg.sha256
${{github.workspace}}/mbuild/packages/darwin/Brewken*.dmg
${{github.workspace}}/mbuild/packages/darwin/Brewken*.dmg.sha256sum
${{github.workspace}}/mbuild/packages/darwin/brewken*.dmg
${{github.workspace}}/mbuild/packages/darwin/brewken*.dmg.sha256sum
retention-days: 7

- name: Post-processing on any core dump
Expand Down
92 changes: 33 additions & 59 deletions bt
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,10 @@ def doSetup(setupOption):
print(' cd ' + os.path.relpath(dir_build))
print(' meson compile')
print(' meson test')
print(' meson install')
if (platform.system() == 'Linux'):
print(' sudo meson install')
else:
print(' meson install')
print(' ' + projectName)


Expand Down Expand Up @@ -2013,7 +2016,7 @@ def doPackage():
abortOnRunFail(subprocess.run(['ls', '-l', xalanDir], capture_output=False))

#
# Strictly speaking, we should look at every /usr/local/opt/.../*.dylib dependency of our executable, and run
# Strictly speaking, we should look at every /usr/local/opt/../*.dylib dependency of our executable, and run
# each of those .dylib files through otool to get its dependencies, then repeat until we find no new
# dependencies. Then we should ensure each dependency is copied into the app bundle and whatever depends on it
# knows where to find it etc. Pretty soon we'd have ended up reimplementing macdeployqt. Fortunately, in
Expand Down Expand Up @@ -2055,9 +2058,9 @@ def doPackage():
# dmgbuild (code at https://github.com/dmgbuild/dmgbuild, docs at
# https://dmgbuild.readthedocs.io/en/latest/index.html). The advantages of this would be that it would make it
# possible to do further fix-up work on the directory tree (if needed) and, potentially, give us more control
# over the disk image (eg to specify an icon for it). However, it's a lot simpler to let macdeployqt create
# the disk image, and we currently don't think we need to do further fix-up work after it's run. A custom icon
# on the disk image would be nice, but is far from essential.
# over the disk image (eg to specify an icon for it). However, it seemed to be fiddly to get it to work. It's
# a lot simpler to let macdeployqt create the disk image, and we currently don't think we need to do further
# fix-up work after it's run. A custom icon on the disk image would be nice, but is far from essential.
#
log.debug('Running macdeployqt')
os.chdir(dir_packages_platform)
Expand All @@ -2082,78 +2085,49 @@ def doPackage():
abortOnRunFail(subprocess.run(['tree', '-sh'], capture_output=False))
dmgFileName = macBundleDirName.replace('.app', '.dmg')

log.debug('Running otool after macdeployqt')
log.debug('Running otool on ' + capitalisedProjectName + ' executable after macdeployqt')
os.chdir(dir_packages_mac_bin)
abortOnRunFail(subprocess.run(['otool', '-L', capitalisedProjectName], capture_output=False))
abortOnRunFail(subprocess.run(['otool', '-l', capitalisedProjectName], capture_output=False))
log.debug('Running otool on ' + xalanLibName + ' library after macdeployqt')
os.chdir(dir_packages_mac_frm)
abortOnRunFail(subprocess.run(['otool', '-L', xalanLibName], capture_output=False))

#
# TBD: This isn't quite working, so going to try letting macdeployqt make the image
#
# Now that we have the app bundle directory structure, we need to compress it into a dmg file using dmgbuild
# (code at https://github.com/dmgbuild/dmgbuild, docs at https://dmgbuild.readthedocs.io/en/latest/index.html).
#
# You can pass parameters in to dmgbuild on the command line, but it gets a bit unwieldy if you have a lot of
# them. We use the alternative method of providing a configuration file (which is actually just a Python
# script). So we generate that first.
#
# It would be neat if we could invoke dmgbuild directly from Python, but I haven't found a way to do this.
#
# log.debug('Creating .dmg file')
# os.chdir(dir_packages_platform)
# settingsFileName = 'dmgSettings.py'
# dmgFileName = capitalisedProjectName + '-' + buildConfig['CONFIG_VERSION_STRING'] + '.dmg'
# with open(settingsFileName, 'wt') as sf:
# sf.write('#------------------------------------------------------------------------------------\n')
# sf.write('# Settings file for dmgbuild to generate ' + dmgFileName + '\n')
# sf.write('#------------------------------------------------------------------------------------\n')
# sf.write('\n')
# sf.write('# Compressed (gzip) format\n')
# sf.write('format = "UDZO"\n')
# sf.write('\n')
# sf.write('# This is the default file system, but no harm to be explicit\n')
# sf.write('filesystem = "HFS+"\n')
# sf.write('\n')
# sf.write('# Disk image holds just one folder\n')
# sf.write('file = "'+ macBundleDirName + '"\n')
# sf.write('\n')
# sf.write('# Icon used to badge the system’s standard external disk icon\n')
# sf.write('# This is a convenient way to construct a suitable icon from your application\’s icon\n')
# # Doco implies path should start with /Applications/, but this does not work
# sf.write('badge_icon = "'+ macBundleDirName + '/Contents/Resources/' + capitalisedProjectName + 'Icon.icns"\n')
# sf.write('\n')
# sf.write('# Expected usage is drag to install, so default view of icons makes most sense\n')
# sf.write('default_view = "icon-view"\n')
# #
# # Confusingly, although the .dmg file name and the volume name can be passed in via the settings file they are
# # nonetheless required parameters on the command line. Specifically, usage is:
# # dmgbuild [-h] [-s SETTINGS] [-D DEFINES] [--no-hidpi] volume-name output.dmg
# #
# abortOnRunFail(
# subprocess.run(
# ['dmgbuild',
# '-s', settingsFileName,
# capitalisedProjectName + ' ' + buildConfig['CONFIG_VERSION_STRING'],
# dmgFileName],
# capture_output=False
# )
# )
# os.chdir(previousWorkingDirectory)
log.info('Created ' + dmgFileName + ' in directory ' + dir_packages_platform.as_posix())
log.debug('Running hdiutil on ' + dmgFileName)

#
# We can now mount the disk image and check its contents. (I don't think we can modify the contents though.)
#
# By default, a disk image called foobar.dmg will get mounted at /Volumes/foobar.
#
log.debug('Running hdiutil to mount ' + dmgFileName)
os.chdir(dir_packages_platform)
abortOnRunFail(
subprocess.run(
['hdiutil', 'attach', '-verbose', dmgFileName]
)
)
mountPoint = '/Volumes/' + dmgFileName.replace('.dmg', '')
log.debug('Directory tree of disk image')
abortOnRunFail(
subprocess.run(['tree', '-sh', mountPoint], capture_output=False)
)
log.debug('Running hdiutil to unmount ' + mountPoint)
os.chdir(dir_packages_platform)
abortOnRunFail(
subprocess.run(
['hdiutil', 'dettach', '-verbose', mountPoint]
)
)

#
# Make the checksum file
#
log.info('Generating checksum file for ' + dmgFileName)
writeSha256sum(dir_packages_platform, dmgFileName)

os.chdir(previousWorkingDirectory)

case _:
log.critical('Unrecognised platform: ' + platform.system())
exit(1)
Expand Down
12 changes: 6 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@
#
# Then to install:
# meson install
# Or, on Linux, you can do:
# sudo meson install
# which avoids the pop-up window
#
# Note that, on Linux, although you can do `sudo meson install` to avoids the pop-up window prompting you for a
# password to allow meson to do sudo itself, this is not a good idea. Aside from the general principle of not
# running-as-root for any longer than we need to, the problem is that some files in the mbuild tree (in particular
# meson-logs/install-log.txt) will be created as, and thus owned by, root, with no write access for other users. If you
# then run meson again without sudo, you'll then get an error if it tries to write to file. This certainly happens if
# you run `bt package` for example.
# Note that, on Linux, using `sudo meson install` sometimes creates problems with file permissions - eg
# mbuild/meson-logs/install-log.txt ends up being writable only by root and that results in an error when you run
# `bt package`, but this should be fixed in Meson 1.1.0.
#
# To build source packages (in the meson-dist subdirectory of the build directory):
# meson dist
Expand Down
2 changes: 1 addition & 1 deletion src/BtLineEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void BtLineEdit::setText(QString amount, int precision) {
Q_FUNC_INFO << "Could not convert" << amount << "(" << this->configSection << ":" << this->editField <<
") to double";
}
this->setWidgetText(displayAmount(amt, precision));
this->setWidgetText(this->displayAmount(amt, precision));
}

this->setDisplaySize(force);
Expand Down
6 changes: 3 additions & 3 deletions src/ConverterTool.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*======================================================================================================================
* ConverterTool.cpp is part of Brewken, and is copyright the following authors 2009-2021:
* ConverterTool.cpp is part of Brewken, and is copyright the following authors 2009-2023:
* • Brian Rower <brian.rower@gmail.com>
* • Matt Young <mfsy@yahoo.com>
* • Philip Greggory Lee <rocketman768@gmail.com>
Expand Down Expand Up @@ -27,12 +27,12 @@
ConverterTool::ConverterTool(QWidget* parent) : QDialog(parent) {
this->doLayout();

connect( pushButton_convert, &QAbstractButton::clicked, this, &ConverterTool::convert );
connect(pushButton_convert, &QAbstractButton::clicked, this, &ConverterTool::convert);
return;
}

void ConverterTool::convert() {
this->outputLineEdit->setText(Measurement::Unit::convert(inputLineEdit->text(), outputUnitsLineEdit->text()));
this->outputLineEdit->setText(Measurement::Unit::convertWithoutContext(inputLineEdit->text(), outputUnitsLineEdit->text()));
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/UiAmountWithUnits.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ struct PreviousScaleInfo {
class UiAmountWithUnits {
public:
/**
* \param
* \param
* \param parent
* \param fieldType
* \param units
*/
UiAmountWithUnits(QWidget * parent,
Expand Down
Loading

0 comments on commit 791fe5c

Please sign in to comment.