Skip to content

Commit

Permalink
[OTS] Improve GYP build
Browse files Browse the repository at this point in the history
- Added gyp_ots script which fetches gyp and creates build files.
- Cleanup ots-standalone.gyp and added further test program targets.
- Fixed some compile errors of test programs on Mac.
Review URL: https://chromiumcodereview.appspot.com/10314003
  • Loading branch information
bashi@chromium.org committed May 7, 2012
1 parent b4cd4b3 commit 1d2b263
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 24 deletions.
40 changes: 26 additions & 14 deletions INSTALL
@@ -1,25 +1,37 @@
How to build (on Linux):
How to build (using scons, on Linux):

$ cd ots/test/
$ sudo apt-get install scons g++ libfreetype6-dev
$ scons

How to build (on Windows) (experimental):
How to build (using gyp):

1. Download zlib compiled DLL from http://www.zlib.net/ and install them
following the instruction described in the document.
(Note: test programs which require gtest can't build with gyp for now)

2. Install gyp (Generate Your Projects) from http://code.google.com/p/gyp/.
You will need a subversion client to install gyp.
See http://code.google.com/p/gyp/source/checkout to install gyp.
1. If you are building OTS on Windows, download zlib from
http://www.zlib.net/ and put them in appropriate folder.

3. Generate MSVS project file.
2. Run gyp_ots

$ gyp --depth=. -f msvs ots-standalone.gyp
$ ./gyp_ots

4. Open the generated project file (ots-standalone.sln) and build it.
Make sure that zlib.h and zconf.h are located in a directory found in
the INCLUDE path list.
This will fetch gyp and generate build files. By default, following
files will be generated:
- MSVS solution file on Windows
- Xcode project file on Mac
- Makefile on Linux

5. Test binary (only idempotent.exe for now) will be located in Default/
directory.
If you want to generate Makefile on Mac, you can use -f option:

$ ./gyp_ots -f make

3. Build OTS

Using MSVS:
Open ots-standalone.sln and build targets.

Using Xcode:
$ xcodebuild -target ots-standalone.xcodeproj -target all

Using Makefile:
$ make
36 changes: 36 additions & 0 deletions gyp_ots
@@ -0,0 +1,36 @@
#!/usr/bin/env python

# Copyright (c) 2012 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

_GYP_REVISION = '1344'
_GYP_FETCH_URL = 'https://gyp.googlecode.com/svn/trunk@' + _GYP_REVISION

def _fetch_gyp():
gyp_dir = os.path.join('third_party', 'gyp')
if not os.path.exists(gyp_dir):
retcode = subprocess.call(['svn', 'checkout', _GYP_FETCH_URL, gyp_dir])
if retcode < 0:
raise "Couldn't fetch gyp"
# TODO(bashi): Check revision, etc
sys.path.insert(0, os.path.abspath(os.path.join(gyp_dir, 'pylib')))

def main():
script_dir = os.path.abspath(os.path.dirname(__file__))
os.chdir(script_dir)
_fetch_gyp()
import gyp

args = []
args.extend(['--depth', '.'])
args.extend(sys.argv[1:])
args.append(os.path.join(script_dir, 'ots-standalone.gyp'))
sys.exit(gyp.main(args))

if __name__ == '__main__':
main()
80 changes: 76 additions & 4 deletions ots-standalone.gyp
Expand Up @@ -18,8 +18,8 @@
'-ggdb',
'-W',
'-Wall',
'-Werror',
'-Wno-unused-parameter',
'-fno-strict-aliasing',
'-fPIE',
'-fstack-protector',
],
Expand All @@ -34,9 +34,6 @@
'ots-common.gypi',
],
'target_defaults': {
'defines': [
'OTS_DEBUG',
],
'conditions': [
['OS=="linux"', {
'cflags': [
Expand Down Expand Up @@ -100,6 +97,22 @@
],
},
},
{
'target_name': 'freetype2',
'type': 'none',
'conditions': [
['OS=="linux"', {
'direct_dependent_settings': {
'cflags': [
'<!(pkg-config freetype2 --cflags)',
],
'ldflags': [
'<!(pkg-config freetype2 --libs)',
],
},
}],
],
},
{
'target_name': 'idempotent',
'type': 'executable',
Expand All @@ -120,5 +133,64 @@
}],
],
},
{
'target_name': 'ot-sanitise',
'type': 'executable',
'sources': [
'test/ot-sanitise.cc',
'test/file-stream.h',
],
'dependencies': [
'ots',
],
},
],
'conditions': [
['OS=="linux" or OS=="mac"', {
'targets': [
{
'target_name': 'validator_checker',
'type': 'executable',
'sources': [
'test/validator-checker.cc',
],
'dependencies': [
'ots',
],
'conditions': [
['OS=="linux"', {
'dependencies': [
'freetype2',
]
}],
],
},
{
'target_name': 'perf',
'type': 'executable',
'sources': [
'test/perf.cc',
],
'dependencies': [
'ots',
],
},
],
}],
['OS=="linux"', {
'targets': [
{
'target_name': 'side_by_side',
'type': 'executable',
'sources': [
'test/side-by-side.cc',
],
'dependencies': [
'freetype2',
'ots',
],
},
],
}],
],
}
7 changes: 7 additions & 0 deletions test/file-stream.h
Expand Up @@ -28,11 +28,18 @@ class FILEStream : public OTSStream {
}

bool Seek(off_t position) {
#if defined(_WIN32)
if (!::_fseeki64(file_, position, SEEK_SET)) {
position_ = position;
return true;
}
#else
if (!::fseeko(file_, position, SEEK_SET)) {
position_ = position;
return true;
}
return false;
#endif // defined(_WIN32)
}

off_t Tell() const {
Expand Down
6 changes: 4 additions & 2 deletions test/idempotent.cc
Expand Up @@ -16,6 +16,7 @@
#else
// Windows
#include <io.h>
#include <Windows.h>
#endif // !defiend(_WIN32)

#include <fcntl.h>
Expand Down Expand Up @@ -130,8 +131,9 @@ bool VerifyTranscodedFont(uint8_t *result, const size_t len) {
return false;
}

CGFontRef cg_font_ref = CGFontCreateWithPlatformFont(&ats_font_ref);
if (!CGFontGetNumberOfGlyphs(cg_font_ref)) {
CTFontRef ct_font_ref = CTFontCreateWithPlatformFont(ats_font_ref, 12,
NULL, NULL);
if (!CTFontGetGlyphCount(ct_font_ref)) {
return false;
}
return true;
Expand Down
4 changes: 4 additions & 0 deletions test/ot-sanitise.cc
Expand Up @@ -7,7 +7,11 @@

#include <fcntl.h>
#include <sys/stat.h>
#if defined(_WIN32)
#include <io.h>
#else
#include <unistd.h>
#endif // defined(_WIN32)

#include <cstdio>
#include <cstdlib>
Expand Down
5 changes: 3 additions & 2 deletions test/perf.cc
Expand Up @@ -73,8 +73,9 @@ int main(int argc, char **argv) {

long long unsigned us
= ((elapsed.tv_sec * 1000 * 1000) + elapsed.tv_usec) / num_repeat;
std::fprintf(stderr, "%llu [us] %s (%lu bytes, %llu [byte/us])\n",
us, argv[1], st.st_size, (us ? st.st_size / us : 0));
std::fprintf(stderr, "%llu [us] %s (%llu bytes, %llu [byte/us])\n",
us, argv[1], static_cast<long long>(st.st_size),
(us ? st.st_size / us : 0));

return 0;
}
5 changes: 3 additions & 2 deletions test/validator-checker.cc
Expand Up @@ -122,8 +122,9 @@ int OpenAndLoadChars(
return 0;
}

CGFontRef cg_font_ref = CGFontCreateWithPlatformFont(&ats_font_ref);
if (!CGFontGetNumberOfGlyphs(cg_font_ref)) {
CTFontRef ct_font_ref = CTFontCreateWithPlatformFont(ats_font_ref, 12,
NULL, NULL);
if (!CTFontGetGlyphCount(ct_font_ref)) {
std::fprintf(stderr,
"OK: font renderer couldn't open the transcoded font: %s\n",
file_name);
Expand Down

0 comments on commit 1d2b263

Please sign in to comment.