Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mac build #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions bitbar-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ TEMPLATE = app
TARGET = bitbar-qt
VERSION = 0.7.4
INCLUDEPATH += src src/json src/qt
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
CONFIG += no_include_pwd
CONFIG += thread
Expand All @@ -22,8 +24,9 @@ UI_DIR = build

# use: qmake "RELEASE=1"
contains(RELEASE, 1) {
# Mac: compile for maximum compatibility (10.5, 32-bit)
macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.5 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk
macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.5 -arch x86_64
macx:QMAKE_CFLAGS += -mmacosx-version-min=10.5 -arch x86_64
macx:QMAKE_OBJECTIVE_CFLAGS += -mmacosx-version-min=10.5 -arch x86_64

!windows:!macx {
# Linux: static link
Expand Down Expand Up @@ -180,7 +183,8 @@ HEADERS += src/qt/bitcoingui.h \
src/qt/rpcconsole.h \
src/version.h \
src/netbase.h \
src/clientversion.h
src/clientversion.h \
src/qt/macnotificationhandler.h

SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/transactiontablemodel.cpp \
Expand Down Expand Up @@ -351,11 +355,11 @@ windows:!contains(MINGW_THREAD_BUGFIX, 0) {
LIBS += -lrt
}

macx:HEADERS += src/qt/macdockiconhandler.h
macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm
macx:HEADERS += src/qt/macdockiconhandler.h src/qt/macnotificationhandler.h
macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm src/qt/macnotificationhandler.mm
macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
macx:ICON = src/qt/res/icons/bitcoin.icns
macx:ICON = src/qt/res/icons/bitbar.icns
macx:TARGET = "BitBar-Qt"
macx:QMAKE_CFLAGS_THREAD += -pthread
macx:QMAKE_LFLAGS_THREAD += -pthread
Expand Down
113 changes: 87 additions & 26 deletions contrib/macdeploy/macdeployqtplus
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#

import subprocess, sys, re, os, shutil, stat, os.path
from string import Template
from time import sleep
from argparse import ArgumentParser

Expand Down Expand Up @@ -169,7 +170,12 @@ class DeploymentInfo(object):
elif os.path.exists(os.path.join(parentDir, "share", "qt4", "translations")):
# MacPorts layout, e.g. "/opt/local/share/qt4"
self.qtPath = os.path.join(parentDir, "share", "qt4")

elif os.path.exists(os.path.join(os.path.dirname(parentDir), "share", "qt4", "translations")):
# Newer Macports layout
self.qtPath = os.path.join(os.path.dirname(parentDir), "share", "qt4")
else:
self.qtPath = os.getenv("QTDIR", None)

if self.qtPath is not None:
pluginPath = os.path.join(self.qtPath, "plugins")
if os.path.exists(pluginPath):
Expand Down Expand Up @@ -239,7 +245,11 @@ def runStrip(binaryPath, verbose):
subprocess.check_call(["strip", "-x", binaryPath])

def copyFramework(framework, path, verbose):
fromPath = framework.sourceFilePath
if framework.sourceFilePath.startswith("Qt"):
#standard place for Nokia Qt installer's frameworks
fromPath = "/Library/Frameworks/" + framework.sourceFilePath
else:
fromPath = framework.sourceFilePath
toDir = os.path.join(path, framework.destinationDirectory)
toPath = os.path.join(toDir, framework.binaryName)

Expand Down Expand Up @@ -342,7 +352,7 @@ def deployPlugins(appBundleInfo, deploymentInfo, strip, verbose):
if pluginDirectory == "designer":
# Skip designer plugins
continue
elif pluginDirectory == "phonon":
elif pluginDirectory == "phonon" or pluginDirectory == "phonon_backend":
# Deploy the phonon plugins only if phonon is in use
if not deploymentInfo.usesFramework("phonon"):
continue
Expand Down Expand Up @@ -420,12 +430,17 @@ ap = ArgumentParser(description="""Improved version of macdeployqt.
Outputs a ready-to-deploy app in a folder "dist" and optionally wraps it in a .dmg file.
Note, that the "dist" folder will be deleted before deploying on each run.

Optionally, Qt translation files (.qm) and additional resources can be added to the bundle.""")
Optionally, Qt translation files (.qm) and additional resources can be added to the bundle.

Also optionally signs the .app bundle; set the CODESIGNARGS environment variable to pass arguments
to the codesign tool.
E.g. CODESIGNARGS='--sign "Developer ID Application: ..." --keychain /encrypted/foo.keychain'""")

ap.add_argument("app_bundle", nargs=1, metavar="app-bundle", help="application bundle to be deployed")
ap.add_argument("-verbose", type=int, nargs=1, default=[1], metavar="<0-3>", help="0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug")
ap.add_argument("-no-plugins", dest="plugins", action="store_false", default=True, help="skip plugin deployment")
ap.add_argument("-no-strip", dest="strip", action="store_false", default=True, help="don't run 'strip' on the binaries")
ap.add_argument("-sign", dest="sign", action="store_true", default=False, help="sign .app bundle with codesign tool")
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")
Expand Down Expand Up @@ -626,6 +641,15 @@ for p in config.add_resources:

# ------------------------------------------------

if config.sign and 'CODESIGNARGS' not in os.environ:
print "You must set the CODESIGNARGS environment variable. Skipping signing."
elif config.sign:
if verbose >= 1:
print "Code-signing app bundle %s"%(target,)
subprocess.check_call("codesign --force %s %s"%(os.environ['CODESIGNARGS'], target), shell=True)

# ------------------------------------------------

if config.dmg is not None:
def runHDIUtil(verb, image_basename, **kwargs):
hdiutil_args = ["hdiutil", verb, image_basename + ".dmg"]
Expand Down Expand Up @@ -704,31 +728,68 @@ if config.dmg is not None:
if fancy.get("applications_symlink", False):
os.symlink("/Applications", os.path.join(disk_root, "Applications"))

finder = appscript.app("Finder")
disk = finder.disks[disk_name]
disk.open()
window = disk.container_window
window.current_view.set(appscript.k.icon_view)
window.toolbar_visible.set(False)
window.statusbar_visible.set(False)
if fancy.has_key("window_bounds"):
window.bounds.set(fancy["window_bounds"])
view_options = window.icon_view_options
view_options.arrangement.set(appscript.k.not_arranged)
if fancy.has_key("icon_size"):
view_options.icon_size.set(fancy["icon_size"])
if bg_path is not None:
view_options.background_picture.set(disk.files[os.path.basename(bg_path)])
# The Python appscript package broke with OSX 10.8 and isn't being fixed.
# So we now build up an AppleScript string and use the osascript command
# to make the .dmg file pretty:
appscript = Template( """
on run argv
tell application "Finder"
tell disk "$disk"
open
set current view of container window to icon view
set toolbar visible of container window to false
set statusbar visible of container window to false
set the bounds of container window to {$window_bounds}
set theViewOptions to the icon view options of container window
set arrangement of theViewOptions to not arranged
set icon size of theViewOptions to $icon_size
$background_commands
$items_positions
close -- close/reopen works around a bug...
open
update without registering applications
delay 5
eject
end tell
end tell
end run
""")

itemscript = Template('set position of item "${item}" of container window to {${position}}')
items_positions = []
if fancy.has_key("items_position"):
for name, position in fancy["items_position"].iteritems():
window.items[name].position.set(position)
disk.close()
params = { "item" : name, "position" : ",".join([str(p) for p in position]) }
items_positions.append(itemscript.substitute(params))

params = {
"disk" : "BitBar-Qt",
"window_bounds" : "300,300,800,620",
"icon_size" : "96",
"background_commands" : "",
"items_positions" : "\n ".join(items_positions)
}
if fancy.has_key("window_bounds"):
params["window.bounds"] = ",".join([str(p) for p in fancy["window_bounds"]])
if fancy.has_key("icon_size"):
params["icon_size"] = str(fancy["icon_size"])
if bg_path is not None:
subprocess.call(["SetFile", "-a", "V", bg_path])
disk.update(registering_applications=False)
sleep(2)
disk.eject()

# Set background file, then call SetFile to make it invisible.
# (note: making it invisible first makes set background picture fail)
bgscript = Template("""set background picture of theViewOptions to file "$bgpic"
do shell script "SetFile -a V /Volumes/$disk/$bgpic" """)
params["background_commands"] = bgscript.substitute({"bgpic" : os.path.basename(bg_path), "disk" : params["disk"]})

s = appscript.substitute(params)
if verbose >= 2:
print("Running AppleScript:")
print(s)

p = subprocess.Popen(['osascript', '-'], stdin=subprocess.PIPE)
p.communicate(input=s)
if p.returncode:
print("Error running osascript.")

if verbose >= 2:
print "+ Finalizing .dmg disk image +"

Expand Down
26 changes: 15 additions & 11 deletions doc/build-osx.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2009-2012 Bitcoin Developers
Copyright (c) 2009-2012 Bitbar Developers
Distributed under the MIT/X11 software license, see the accompanying file
license.txt or http://www.opensource.org/licenses/mit-license.php. This
product includes software developed by the OpenSSL Project for use in the
Expand All @@ -7,12 +7,12 @@ software written by Eric Young ([email protected]) and UPnP software written by
Thomas Bernard.


Mac OS X bitcoind build instructions
Mac OS X bitbard build instructions
Laszlo Hanyecz <[email protected]>
Douglas Huff <[email protected]>


See readme-qt.rst for instructions on building Bitcoin QT, the
See readme-qt.rst for instructions on building Bitbar QT, the
graphical user interface.

Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian.
Expand All @@ -27,12 +27,16 @@ but you can get the current version from http://developer.apple.com

1. Clone the github tree to get the source code:

git clone [email protected]:bitcoin/bitcoin.git bitcoin
git clone [email protected]:aLQ/bitbar.git bitbar

2. Download and install MacPorts from http://www.macports.org/

2a. (for 10.7 Lion)
Edit /opt/local/etc/macports/macports.conf and uncomment "build_arch i386"
2a. (for 10.7 Lion and up)
Edit /opt/local/etc/macports/macports.conf and insert lines:

build_arch x86_64
macosx_deployment_target 10.5
buildfromsource always

3. Install dependencies from MacPorts

Expand All @@ -41,14 +45,14 @@ sudo port install boost db48 openssl miniupnpc
Optionally install qrencode (and set USE_QRCODE=1):
sudo port install qrencode

4. Now you should be able to build bitcoind:
4. Now you should be able to build bitbard:

cd bitcoin/src
cd bitbar/src
make -f makefile.osx

Run:
./bitcoind --help # for a list of command-line options.
./bitbard --help # for a list of command-line options.
Run
./bitcoind -daemon # to start the bitcoin daemon.
./bitbard -daemon # to start the bitbar daemon.
Run
./bitcoind help # When the daemon is running, to get a list of RPC commands
./bitbard help # When the daemon is running, to get a list of RPC commands
4 changes: 2 additions & 2 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ int ReadHTTPStatus(std::basic_istream<char>& stream, int &proto)
int ReadHTTPHeader(std::basic_istream<char>& stream, map<string, string>& mapHeadersRet)
{
int nLen = 0;
loop
for(;;)
{
string str;
std::getline(stream, str);
Expand Down Expand Up @@ -938,7 +938,7 @@ void ThreadRPCServer3(void* parg)
AcceptedConnection *conn = (AcceptedConnection *) parg;

bool fRun = true;
loop {
for(;;) {
if (fShutdown || !fRun)
{
conn->close();
Expand Down
2 changes: 1 addition & 1 deletion src/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ bool CTxDB::LoadBlockIndexGuts()

// Load mapBlockIndex
unsigned int fFlags = DB_SET_RANGE;
loop
for(;;)
{
// Read next record
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
Expand Down
6 changes: 3 additions & 3 deletions src/irc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static bool Send(SOCKET hSocket, const char* pszSend)

bool RecvLineIRC(SOCKET hSocket, string& strLine)
{
loop
for(;;)
{
bool fRet = RecvLine(hSocket, strLine);
if (fRet)
Expand All @@ -100,7 +100,7 @@ bool RecvLineIRC(SOCKET hSocket, string& strLine)

int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL, const char* psz4=NULL)
{
loop
for(;;)
{
string strLine;
strLine.reserve(10000);
Expand Down Expand Up @@ -135,7 +135,7 @@ bool Wait(int nSeconds)
bool RecvCodeLine(SOCKET hSocket, const char* psz1, string& strRet)
{
strRet.clear();
loop
for(;;)
{
string strLine;
if (!RecvLineIRC(hSocket, strLine))
Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2431,7 +2431,7 @@ static unsigned int nCurrentBlockFile = 1;
FILE* AppendBlockFile(unsigned int& nFileRet)
{
nFileRet = 0;
loop
for(;;)
{
FILE* file = OpenBlockFile(nCurrentBlockFile, 0, "ab");
if (!file)
Expand Down Expand Up @@ -3482,7 +3482,7 @@ bool ProcessMessages(CNode* pfrom)
// (x) data
//

loop
for(;;)
{
// Don't bother if send buffer is too full to respond anyway
if (pfrom->vSend.size() >= SendBufferSize())
Expand Down Expand Up @@ -4337,7 +4337,7 @@ void BitcoinMiner(CWallet *pwallet, bool fProofOfStake)
block_header res_header;
uint256 result;

loop
for(;;)
{
unsigned int nHashesDone = 0;
unsigned int nNonceFound;
Expand Down
10 changes: 5 additions & 5 deletions src/makefile.osx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

# Mac OS X makefile for bitcoin
# Mac OS X makefile for bitbar
# Originally by Laszlo Hanyecz ([email protected])

CXX=llvm-g++
Expand Down Expand Up @@ -60,9 +60,9 @@ ifdef RELEASE
# Compile for maximum compatibility and smallest size.
# This requires that dependencies are compiled
# the same way.
CFLAGS = -mmacosx-version-min=10.5 -arch i386 -O3 -msse2
CFLAGS = -mmacosx-version-min=10.5 -arch x86_64 -O3 -msse2
else
CFLAGS = -g -msse2
CFLAGS = -g -msse2 -mmacosx-version-min=10.5 -arch x86_64
endif

# ppc doesn't work because we don't support big-endian
Expand Down Expand Up @@ -141,10 +141,10 @@ obj/%.o: %.cpp
rm -f $(@:%.o=%.d)

obj/scrypt-x86.o: scrypt-x86.S
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
$(CXX) -c $(CFLAGS) -MMD -o $@ $<

obj/scrypt-x86_64.o: scrypt-x86_64.S
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
$(CXX) -c $(CFLAGS) -MMD -o $@ $<

bitbard: $(OBJS:obj/%=obj/%)
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
Expand Down
Loading