This commit is contained in:
Matthias Koefferlein 2018-07-29 01:59:50 +02:00
commit 76db5d1714
7 changed files with 134 additions and 41 deletions

View File

@ -1,19 +1,77 @@
matrix: matrix:
include: include:
- os: osx - os: linux
osx_image: xcode9.3beta dist: trusty # Ubuntu 14.04
env: sudo: false
- MATRIX_EVAL="" language: python
python: '2.6'
env:
- MATRIX_EVAL=""
- os: linux
dist: trusty # Ubuntu 14.04
sudo: false
language: python
python: '2.7'
env:
- MATRIX_EVAL=""
- os: linux
dist: trusty # Ubuntu 14.04
sudo: false
language: python
python: '3.3'
env:
- MATRIX_EVAL=""
- os: linux
dist: trusty # Ubuntu 14.04
sudo: false
language: python
python: '3.4'
env:
- MATRIX_EVAL=""
- os: linux
dist: trusty # Ubuntu 14.04
sudo: false
language: python
python: '3.5'
env:
- MATRIX_EVAL=""
- os: linux
dist: trusty # Ubuntu 14.04
sudo: false
language: python
python: '3.6'
env:
- MATRIX_EVAL=""
- os: osx
osx_image: xcode9.3 # macOS 10.13
env:
- MATRIX_EVAL=""
- os: osx
osx_image: xcode8.3 # macOS 10.12
env:
- MATRIX_EVAL=""
- os: osx
osx_image: xcode8 # macOS 10.11
env:
- MATRIX_EVAL=""
before_install: before_install:
- eval "${MATRIX_EVAL}"
- brew update
- brew bundle
- env - env
- rvm install ruby --latest
- gem install dropbox-deployment
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; fi
- eval "${MATRIX_EVAL}"
- python -c "import distutils.sysconfig as sysconfig; print(sysconfig.__file__)"
install: install:
- python3 setup.py install - python setup.py build
- python setup.py bdist_wheel
- python setup.py install
script: script:
- python3 -c 'import klayout.db as db; print(dir(db))' - python -c 'import klayout.db as db; print(dir(db))'
- python3 -c 'import klayout.rdb as rdb; print(dir(rdb))' - python -c 'import klayout.rdb as rdb; print(dir(rdb))'
- python3 -c 'import klayout.tl as tl; print(dir(tl))' - python -c 'import klayout.tl as tl; print(dir(tl))'
after_success:
- dropbox-deployment

4
dropbox-deployment.yml Normal file
View File

@ -0,0 +1,4 @@
deploy:
dropbox_path: /Builds/klayout-pymod # The path to the folder on Dropbox where the files will go
artifacts_path: dist # can be a single file, or a path
debug: true # if you want to see more logs

View File

@ -58,7 +58,7 @@ from setuptools import setup, Extension, Distribution
import glob import glob
import os import os
import platform import platform
import sysconfig import distutils.sysconfig as sysconfig
# ---------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------
@ -78,6 +78,9 @@ class Config(object):
self.build_platlib = build_cmd.build_platlib self.build_platlib = build_cmd.build_platlib
self.ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") self.ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
if self.ext_suffix is None:
self.ext_suffix = ".so"
self.root = "klayout" self.root = "klayout"
def libname_of(self, mod): def libname_of(self, mod):

View File

@ -26,6 +26,7 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h>
#if defined(_WIN32) #if defined(_WIN32)
# include <windows.h> # include <windows.h>
@ -64,13 +65,13 @@ static int default_verbosity ()
static int m_verbosity_level = default_verbosity (); static int m_verbosity_level = default_verbosity ();
void void
verbosity (int level) verbosity (int level)
{ {
m_verbosity_level = level; m_verbosity_level = level;
} }
int int
verbosity () verbosity ()
{ {
return m_verbosity_level; return m_verbosity_level;
@ -79,7 +80,7 @@ verbosity ()
// ------------------------------------------------ // ------------------------------------------------
// Channel implementation // Channel implementation
Channel::Channel () Channel::Channel ()
: m_no_endl (false), m_active (false) : m_no_endl (false), m_active (false)
{ {
// .. nothing else .. // .. nothing else ..
@ -90,7 +91,7 @@ Channel::~Channel ()
// .. nothing yet .. // .. nothing yet ..
} }
ChannelProxy ChannelProxy
Channel::issue_proxy () Channel::issue_proxy ()
{ {
m_no_endl = false; m_no_endl = false;
@ -102,7 +103,7 @@ Channel::issue_proxy ()
return ChannelProxy (this); return ChannelProxy (this);
} }
void void
Channel::release_proxy () Channel::release_proxy ()
{ {
if (! m_no_endl) { if (! m_no_endl) {
@ -130,7 +131,7 @@ LogTee::LogTee (Channel *first, bool owned)
add (first, owned); add (first, owned);
} }
void void
LogTee::add (Channel *other, bool owned) LogTee::add (Channel *other, bool owned)
{ {
m_lock.lock (); m_lock.lock ();
@ -161,7 +162,7 @@ LogTee::clear ()
m_lock.unlock (); m_lock.unlock ();
} }
void void
LogTee::puts (const char *s) LogTee::puts (const char *s)
{ {
try { try {
@ -173,7 +174,7 @@ LogTee::puts (const char *s)
} }
} }
void void
LogTee::endl () LogTee::endl ()
{ {
try { try {
@ -185,7 +186,7 @@ LogTee::endl ()
} }
} }
void void
LogTee::end () LogTee::end ()
{ {
try { try {
@ -197,7 +198,7 @@ LogTee::end ()
} }
} }
void void
LogTee::begin () LogTee::begin ()
{ {
try { try {
@ -292,7 +293,7 @@ InfoChannel::~InfoChannel ()
// .. nothing yet .. // .. nothing yet ..
} }
void void
InfoChannel::puts (const char *s) InfoChannel::puts (const char *s)
{ {
if (verbosity () >= m_verbosity) { if (verbosity () >= m_verbosity) {
@ -300,7 +301,7 @@ InfoChannel::puts (const char *s)
} }
} }
void void
InfoChannel::endl () InfoChannel::endl ()
{ {
if (verbosity () >= m_verbosity) { if (verbosity () >= m_verbosity) {
@ -308,7 +309,7 @@ InfoChannel::endl ()
} }
} }
void void
InfoChannel::end () InfoChannel::end ()
{ {
if (verbosity () >= m_verbosity) { if (verbosity () >= m_verbosity) {
@ -319,7 +320,7 @@ InfoChannel::end ()
} }
} }
void void
InfoChannel::begin () InfoChannel::begin ()
{ {
if (verbosity () >= m_verbosity) { if (verbosity () >= m_verbosity) {
@ -362,19 +363,19 @@ WarningChannel::~WarningChannel ()
// .. nothing yet .. // .. nothing yet ..
} }
void void
WarningChannel::puts (const char *s) WarningChannel::puts (const char *s)
{ {
fputs (s, stdout); fputs (s, stdout);
} }
void void
WarningChannel::endl () WarningChannel::endl ()
{ {
fputs ("\n", stdout); fputs ("\n", stdout);
} }
void void
WarningChannel::end () WarningChannel::end ()
{ {
if (m_colorized) { if (m_colorized) {
@ -383,7 +384,7 @@ WarningChannel::end ()
fflush (stdout); fflush (stdout);
} }
void void
WarningChannel::begin () WarningChannel::begin ()
{ {
if (m_colorized) { if (m_colorized) {
@ -426,19 +427,19 @@ ErrorChannel::~ErrorChannel ()
// .. nothing yet .. // .. nothing yet ..
} }
void void
ErrorChannel::puts (const char *s) ErrorChannel::puts (const char *s)
{ {
fputs (s, stderr); fputs (s, stderr);
} }
void void
ErrorChannel::endl () ErrorChannel::endl ()
{ {
fputs ("\n", stderr); fputs ("\n", stderr);
} }
void void
ErrorChannel::end () ErrorChannel::end ()
{ {
if (m_colorized) { if (m_colorized) {
@ -447,7 +448,7 @@ ErrorChannel::end ()
fflush (stderr); fflush (stderr);
} }
void void
ErrorChannel::begin () ErrorChannel::begin ()
{ {
if (m_colorized) { if (m_colorized) {

View File

@ -23,12 +23,12 @@
#if !defined(HAVE_QT) #if !defined(HAVE_QT)
#include "tlThreads.h" #include "tlThreads.h"
#include "tlUtils.h"
#include "tlLog.h" #include "tlLog.h"
#include "tlInternational.h" #include "tlInternational.h"
#include <map> #include <map>
#include <pthread.h> #include <pthread.h>
#include <time.h>
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#if defined(_WIN32) #if defined(_WIN32)
@ -82,7 +82,7 @@ public:
if (time < std::numeric_limits<unsigned long>::max ()) { if (time < std::numeric_limits<unsigned long>::max ()) {
struct timespec end_time; struct timespec end_time;
clock_gettime (CLOCK_REALTIME, &end_time); current_utc_time (&end_time);
end_time.tv_sec += (time / 1000); end_time.tv_sec += (time / 1000);
end_time.tv_nsec += (time % 1000) * 1000000; end_time.tv_nsec += (time % 1000) * 1000000;
@ -270,7 +270,7 @@ bool Thread::wait (unsigned long time)
if (time < std::numeric_limits<unsigned long>::max ()) { if (time < std::numeric_limits<unsigned long>::max ()) {
struct timespec end_time; struct timespec end_time;
clock_gettime (CLOCK_REALTIME, &end_time); current_utc_time (&end_time);
end_time.tv_sec += (time / 1000); end_time.tv_sec += (time / 1000);
end_time.tv_nsec += (time % 1000) * 1000000; end_time.tv_nsec += (time % 1000) * 1000000;
@ -285,7 +285,7 @@ bool Thread::wait (unsigned long time)
while (isRunning ()) { while (isRunning ()) {
struct timespec current_time; struct timespec current_time;
clock_gettime (CLOCK_REALTIME, &current_time); current_utc_time (&current_time);
if (end_time.tv_sec < current_time.tv_sec || (end_time.tv_sec == current_time.tv_sec && end_time.tv_nsec < current_time.tv_nsec)) { if (end_time.tv_sec < current_time.tv_sec || (end_time.tv_sec == current_time.tv_sec && end_time.tv_nsec < current_time.tv_nsec)) {
return false; return false;
} }

View File

@ -22,6 +22,7 @@
#include "tlTimer.h" #include "tlTimer.h"
#include "tlUtils.h"
#include "tlLog.h" #include "tlLog.h"
#include "tlString.h" #include "tlString.h"
@ -30,7 +31,6 @@
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <time.h>
#ifndef _MSC_VER // not available on MS VC++ #ifndef _MSC_VER // not available on MS VC++
# include <unistd.h> # include <unistd.h>
@ -45,7 +45,7 @@ namespace tl
static int64_t ms_time () static int64_t ms_time ()
{ {
struct timespec spec; struct timespec spec;
clock_gettime (CLOCK_REALTIME, &spec); current_utc_time (&spec);
return int64_t (spec.tv_sec) * 1000 + int64_t (0.5 + spec.tv_nsec / 1.0e6); return int64_t (spec.tv_sec) * 1000 + int64_t (0.5 + spec.tv_nsec / 1.0e6);
} }
@ -77,7 +77,7 @@ Timer::start ()
#endif #endif
struct timespec spec; struct timespec spec;
clock_gettime (CLOCK_REALTIME, &spec); current_utc_time (&spec);
m_wall_ms += ms_time (); m_wall_ms += ms_time ();
} }

View File

@ -27,10 +27,37 @@
#include "tlAssert.h" #include "tlAssert.h"
#include <map> #include <map>
#include <time.h>
#if defined(__MACH__)
#include <mach/clock.h>
#include <mach/mach.h>
#endif
namespace tl namespace tl
{ {
/**
* @brief clock_gettime is not implemented in Mac OS X 10.11 and lower
* From: https://gist.githubusercontent.com/jbenet/1087739/raw/638b37f76cdd9dc46d617443cab27eac297e2ee3/current_utc_time.c
*/
inline void current_utc_time(struct timespec *ts) {
#if defined(__MACH__)
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
ts->tv_sec = mts.tv_sec;
ts->tv_nsec = mts.tv_nsec;
#else
clock_gettime(CLOCK_REALTIME, ts);
#endif
}
/** /**
* @brief A template class mapping a begin .. end iterator pair to the at_end semantics * @brief A template class mapping a begin .. end iterator pair to the at_end semantics
*/ */