Skip to content

Commit

Permalink
Merge pull request #26 from brightray/linux
Browse files Browse the repository at this point in the history
Get a basic Linux build working
  • Loading branch information
aroben committed Aug 14, 2013
2 parents 53ac82b + 9638e39 commit 3df8564
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 20 deletions.
22 changes: 22 additions & 0 deletions brightray/brightray.gypi
Expand Up @@ -73,6 +73,13 @@
],
},
},
'conditions': [
['OS not in ["mac", "win"]', {
'defines': [
'USE_X11',
],
}],
],
},
'Debug': {
'inherit_from': [
Expand Down Expand Up @@ -167,9 +174,24 @@
['exclude', '_win\.(cc|h)$'],
],
}],
['OS=="linux"', {
'cflags_cc': [
'-std=gnu++11',
],
}],
],
},
'conditions': [
['OS=="linux"', {
'make_global_settings': [
['CC', '/usr/bin/clang'],
['CXX', '/usr/bin/clang++'],
['LINK', '$(CXX)'],
['CC.host', '$(CC)'],
['CXX.host', '$(CXX)'],
['LINK.host', '$(LINK)'],
],
}],
['OS=="win"', {
'target_defaults': {
'include_dirs': [
Expand Down
13 changes: 13 additions & 0 deletions brightray/browser/browser_context.cc
Expand Up @@ -9,6 +9,7 @@
#include "browser/network_delegate.h"
#include "common/application_info.h"

#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/prefs/json_pref_store.h"
Expand All @@ -20,6 +21,10 @@
#include "content/public/browser/storage_partition.h"
#include "url_request_context_getter.h"

#if defined(OS_LINUX)
#include "base/nix/xdg_util.h"
#endif

namespace brightray {

class BrowserContext::ResourceContext : public content::ResourceContext {
Expand Down Expand Up @@ -83,7 +88,15 @@ base::FilePath BrowserContext::GetPath() {
return path_;

base::FilePath path;
#if defined(OS_LINUX)
scoped_ptr<base::Environment> env(base::Environment::Create());
path = base::nix::GetXDGDirectory(env.get(),
base::nix::kXdgConfigHomeEnvVar,
base::nix::kDotConfigDir);
#else
CHECK(PathService::Get(base::DIR_APP_DATA, &path));
#endif

path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName()));
return path_;
}
Expand Down
14 changes: 7 additions & 7 deletions brightray/script/bootstrap
Expand Up @@ -14,8 +14,8 @@ DOWNLOAD_DIR = os.path.join(VENDOR_DIR, 'download')

def main():
args = parse_args()
update_submodules()
download_libchromiumcontent(args.url)
return (update_submodules() or
download_libchromiumcontent(args.url))


def parse_args():
Expand All @@ -27,17 +27,17 @@ def parse_args():


def update_submodules():
subprocess.check_call(['git', 'submodule', 'sync', '--quiet'])
subprocess.check_call(['git', 'submodule', 'update', '--init',
'--recursive'])
return (subprocess.call(['git', 'submodule', 'sync', '--quiet']) or
subprocess.call(['git', 'submodule', 'update', '--init',
'--recursive']))


def download_libchromiumcontent(url):
mkdir_p(DOWNLOAD_DIR)
download = os.path.join(VENDOR_DIR, 'libchromiumcontent', 'script',
'download')
subprocess.check_call([sys.executable, download, '-f', url,
os.path.join(DOWNLOAD_DIR, 'libchromiumcontent')])
return subprocess.call([sys.executable, download, '-f', url,
os.path.join(DOWNLOAD_DIR, 'libchromiumcontent')])


def mkdir_p(path):
Expand Down
17 changes: 8 additions & 9 deletions brightray/script/build
Expand Up @@ -7,29 +7,28 @@ import sys

SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
GYP = {
'darwin': 'gyp',
'win32': 'gyp.bat',
}[sys.platform]
'win32': 'gyp.bat',
}.get(sys.platform, 'gyp')


def main():
os.chdir(SOURCE_ROOT)
run_gyp()
build()
return (run_gyp() or build())


def run_gyp():
subprocess.check_call([GYP, '--depth', '.', 'brightray.gyp'])
return subprocess.call([GYP, '--depth', '.', 'brightray.gyp'])


def build():
if sys.platform == 'darwin':
subprocess.check_call(['xcodebuild'])
return
return subprocess.call(['xcodebuild'])
if sys.platform == 'linux2':
return subprocess.call(['make'])

assert sys.platform == 'win32', sys.platform
msbuild = os.path.join(os.environ['windir'], 'Microsoft.NET', 'Framework', 'v4.0.30319', 'MSBuild.exe')
subprocess.check_call([msbuild, 'brightray.sln'])
return subprocess.call([msbuild, 'brightray.sln'])


if __name__ == '__main__':
Expand Down
7 changes: 4 additions & 3 deletions brightray/script/cibuild
Expand Up @@ -16,8 +16,9 @@ def main():
return 'Error: Can\'t find {0}'.format(S3_CREDENTIALS_FILE)
copy_to_environment(S3_CREDENTIALS_FILE)

run_script('bootstrap', 'https://{0}.s3.amazonaws.com/libchromiumcontent'.format(os.environ['JANKY_ARTIFACTS_S3_BUCKET']))
run_script('build')
url = 'https://{0}.s3.amazonaws.com/libchromiumcontent'.format(os.environ['JANKY_ARTIFACTS_S3_BUCKET'])
return (run_script('bootstrap', url) or
run_script('build'))


def copy_to_environment(credentials_file):
Expand All @@ -32,7 +33,7 @@ def run_script(script, *args):
script = os.path.join('script', script)
sys.stderr.write('+ {0}\n'.format(script))
sys.stderr.flush()
subprocess.check_call([sys.executable, script] + list(args))
return subprocess.call([sys.executable, script] + list(args))


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion brightray/vendor/libchromiumcontent
Submodule libchromiumcontent updated from 33472d to 5ffcb3

0 comments on commit 3df8564

Please sign in to comment.