Skip to content

Commit

Permalink
Bring in all of //mojo/public
Browse files Browse the repository at this point in the history
  • Loading branch information
colinblundell committed Nov 4, 2014
1 parent 4886c94 commit 838e177
Show file tree
Hide file tree
Showing 255 changed files with 15,205 additions and 3 deletions.
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ group("root") {
testonly = true

deps = [
"//mojo/public",
"//sample_apps"
]
}
50 changes: 50 additions & 0 deletions build/download_mojo_shell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import subprocess
import sys
import tempfile
import zipfile

current_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.join(current_path, "..")

if not sys.platform.startswith("linux"):
print "Not supported for your platform"
sys.exit(0)

version_path = os.path.join(root_path, "mojo/public/VERSION")
with open(version_path) as version_file:
version = version_file.read().strip()

mojo_shell_path = os.path.join(root_path, "buildtools")
stamp_path = os.path.join(mojo_shell_path, "MOJO_SHELL_VERSION")

try:
with open(stamp_path) as stamp_file:
current_version = stamp_file.read().strip()
if current_version == version:
sys.exit(0)
except IOError:
pass

platform = "linux-x64" # TODO: configurate
basename = platform + ".zip"

gs_path = "gs://mojo/shell/" + version + "/" + basename

gsutil_exe = os.path.join(root_path, "third_party", "gsutil", "gsutil")

with tempfile.NamedTemporaryFile() as temp_zip_file:
subprocess.check_call([gsutil_exe, "cp", gs_path, temp_zip_file.name])
with zipfile.ZipFile(temp_zip_file.name) as z:
zi = z.getinfo("mojo_shell")
mode = zi.external_attr >> 16L
z.extract(zi, mojo_shell_path)
os.chmod(os.path.join(mojo_shell_path, "mojo_shell"), mode)

with open(stamp_path, 'w') as stamp_file:
stamp_file.write(version + "\n")
48 changes: 48 additions & 0 deletions mojo/public/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

group("public") {
# Meta-target, don't link into production code.
testonly = true
deps = [
":libmojo_sdk",
":sdk",
"//mojo/public/cpp/application:standalone",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/environment:standalone",
"//mojo/public/cpp/utility",
"//mojo/public/interfaces/bindings/tests:test_interfaces",
"//mojo/public/html",
]

if (is_linux) {
deps += [
"//mojo/public/python",
]
}

if (is_android) {
deps += [
"//mojo/public/java:system",
"//mojo/public/java:bindings",
]
}
}

group("sdk") {
deps = [
"//mojo/public/c/system",
"//mojo/public/cpp/application:standalone",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/environment:standalone",
"//mojo/public/cpp/utility",
"//mojo/public/interfaces/application",
"//mojo/public/js/bindings",
]
}

static_library("libmojo_sdk") {
complete_static_lib = true
deps = [ ":sdk" ]
}
6 changes: 6 additions & 0 deletions mojo/public/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include_rules = [
"-base",
"-build",
"-mojo",
"+mojo/public",
]
43 changes: 43 additions & 0 deletions mojo/public/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Mojo Public API
===============

The Mojo Public API is a binary stable API to the Mojo system.

It consists of support for a number of programming languages (with a directory
for each support language), some "build" tools and build-time requirements, and
interface definitions for Mojo services (specified using an IDL).

Note that there are various subdirectories named tests/. These contain tests of
the code in the enclosing directory, and are not meant for use by Mojo
applications.

C/CPP/JS
--------

The c/, cpp/, js/ subdirectories define the API for C, C++, and JavaScript,
respectively.

The basic principle for these directories is that they consist of the source
files that one needs at build/deployment/run time (as appropriate for the
language), organized in a natural way for the particular language.

Interfaces
----------

The interfaces/ subdirectory contains Mojo IDL (a.k.a. .mojom) descriptions of
standard Mojo services.

Platform
--------

The platform/ subdirectory contains any build-time requirements (e.g., static
libraries) that may be needed to produce a Mojo application for certain
platforms, such as a native shared library or as a NaCl binary.

Tools
-----

The tools/ subdirectory contains tools that are useful/necessary at
build/deployment time. These tools may be needed (as a practical necessity) to
use the API in any given language, e.g., to generate bindings from Mojo IDL
files.
1 change: 0 additions & 1 deletion mojo/public/VERSION

This file was deleted.

16 changes: 16 additions & 0 deletions mojo/public/c/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include_rules = [
# Require explicit dependencies in each directory.
"-mojo/public",
# But everyone can depend on the C system headers.
"+mojo/public/c/system",
]

specific_include_rules = {
r".*_(unit|perf)test\.cc": [
"+testing",
# Our test harness is C++, so allow the use of C++:
"+mojo/public/cpp/system",
"+mojo/public/cpp/test_support",
"+mojo/public/cpp/utility",
],
}
16 changes: 16 additions & 0 deletions mojo/public/c/PRESUBMIT.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Presubmit script for mojo/public/c.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into depot_tools.
"""

def CheckChangeOnUpload(input_api, output_api):
results = []
results += input_api.canned_checks.CheckChangeHasOnlyOneEol(input_api,
output_api)
results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api)
return results
45 changes: 45 additions & 0 deletions mojo/public/c/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Mojo Public C API
=================

This directory contains C language bindings for the Mojo Public API.

Environment
-----------

The environment/ subdirectory defines some common things that, while not part of
the system API, may be required for GLES2 (for example). These are things that a
Mojo application may be required to provide to the GLES2 (for example) library
in order to use it. (However, the Mojo application may implement these things as
it sees fit.)

GLES2
-----

The gles2/ subdirectory defines the GLES2 C API that's available to Mojo
applications. To use GLES2, Mojo applications must link against a dynamic
library (the exact mechanism being platform-dependent) and use the header files
in this directory as well as the standard Khronos GLES2 header files.

The reason for this, rather than providing GLES2 using the standard Mojo IPC
mechanism, is performance: The protocol (and transport mechanisms) used to
communicate with the Mojo GLES2 service is not stable nor "public" (mainly for
performance reasons), and using the dynamic library shields the application from
changes to the underlying system.

System
------

The system/ subdirectory provides definitions of the basic low-level API used by
all Mojo applications (whether directly or indirectly). These consist primarily
of the IPC primitives used to communicate with Mojo services.

Though the message protocol is stable, the implementation of the transport is
not, and access to the IPC mechanisms must be via the primitives defined in this
directory.

Test Support
------------

This directory contains a C API for running tests. This API is only available
under special, specific test conditions. It is not meant for general use by Mojo
applications.
24 changes: 24 additions & 0 deletions mojo/public/c/test_support/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# GYP version: mojo/public/mojo_public.gyp:mojo_test_support
shared_library("test_support") {
output_name = "mojo_test_support"

defines = [ "MOJO_TEST_SUPPORT_IMPLEMENTATION" ]

sources = [
"test_support.h",
"test_support_export.h",
# TODO(vtl): Convert this to thunks http://crbug.com/386799
"../../tests/test_support_private.cc",
"../../tests/test_support_private.h",
]

if (is_mac) {
# TODO(GYP)
# # Make it a run-path dependent library.
# 'DYLIB_INSTALL_NAME_BASE': '@loader_path',
}
}
48 changes: 48 additions & 0 deletions mojo/public/c/test_support/test_support.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MOJO_PUBLIC_C_TEST_SUPPORT_TEST_SUPPORT_H_
#define MOJO_PUBLIC_C_TEST_SUPPORT_TEST_SUPPORT_H_

// Note: This header should be compilable as C.

#include <stdio.h>

#include "mojo/public/c/test_support/test_support_export.h"

#ifdef __cplusplus
extern "C" {
#endif

MOJO_TEST_SUPPORT_EXPORT void MojoTestSupportLogPerfResult(
const char* test_name,
double value,
const char* units);

// Opens a "/"-delimited file path relative to the source root.
MOJO_TEST_SUPPORT_EXPORT FILE* MojoTestSupportOpenSourceRootRelativeFile(
const char* source_root_relative_path);

// Enumerates a "/"-delimited directory path relative to the source root.
// Returns only regular files. The return value is a heap-allocated array of
// heap-allocated strings. Each must be free'd separately.
//
// The return value is built like so:
//
// char** rv = (char**) calloc(N + 1, sizeof(char*));
// rv[0] = strdup("a");
// rv[1] = strdup("b");
// rv[2] = strdup("c");
// ...
// rv[N] = NULL;
//
MOJO_TEST_SUPPORT_EXPORT
char** MojoTestSupportEnumerateSourceRootRelativeDirectory(
const char* source_root_relative_path);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // MOJO_PUBLIC_C_TEST_SUPPORT_TEST_SUPPORT_H_
26 changes: 26 additions & 0 deletions mojo/public/c/test_support/test_support_export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MOJO_PUBLIC_C_TEST_SUPPORT_TEST_SUPPORT_EXPORT_H_
#define MOJO_PUBLIC_C_TEST_SUPPORT_TEST_SUPPORT_EXPORT_H_

#if defined(WIN32)

#if defined(MOJO_TEST_SUPPORT_IMPLEMENTATION)
#define MOJO_TEST_SUPPORT_EXPORT __declspec(dllexport)
#else
#define MOJO_TEST_SUPPORT_EXPORT __declspec(dllimport)
#endif

#else // !defined(WIN32)

#if defined(MOJO_TEST_SUPPORT_IMPLEMENTATION)
#define MOJO_TEST_SUPPORT_EXPORT __attribute__((visibility("default")))
#else
#define MOJO_TEST_SUPPORT_EXPORT
#endif

#endif // defined(WIN32)

#endif // MOJO_PUBLIC_C_TEST_SUPPORT_TEST_SUPPORT_EXPORT_H_
18 changes: 18 additions & 0 deletions mojo/public/cpp/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
include_rules = [
# Require explicit dependencies in each directory.
"-mojo/public",
# But everyone can depend on the C and C++ system headers.
"+mojo/public/c/system",
"+mojo/public/cpp/system",
# Ditto for the C environment headers (but not the C++ environment, since it
# has dependencies of its own).
"+mojo/public/c/environment",
]

specific_include_rules = {
r".*_(unit|perf)test\.cc": [
"+testing",
"+mojo/public/cpp/test_support",
"+mojo/public/cpp/utility",
],
}
16 changes: 16 additions & 0 deletions mojo/public/cpp/PRESUBMIT.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Presubmit script for mojo/public/cpp.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into depot_tools.
"""

def CheckChangeOnUpload(input_api, output_api):
results = []
results += input_api.canned_checks.CheckChangeHasOnlyOneEol(input_api,
output_api)
results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api)
return results
Loading

0 comments on commit 838e177

Please sign in to comment.