Skip to content

Commit

Permalink
Merge pull request #198 from ehsan/import_shared_properly
Browse files Browse the repository at this point in the history
Import shared.py properly
  • Loading branch information
kripken committed Jan 31, 2012
2 parents ab7dacb + d48cba1 commit 2761fe8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 19 deletions.
5 changes: 3 additions & 2 deletions emcc
Expand Up @@ -41,10 +41,11 @@ Example uses:
* For SCons the shared.py can be imported like so:
__file__ = str(Dir('#/project_path_to_emscripten/dummy/dummy'))
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
sys.path += [path_from_root('')]
from tools.shared import *
For using the Emscripten compilers/linkers/etc. you can do:
env = Environment()
Expand Down
8 changes: 5 additions & 3 deletions tests/runner.py
Expand Up @@ -18,12 +18,12 @@

# Setup

__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
exec(open(path_from_root('tools', 'shared.py'), 'r').read())

sys.path += [path_from_root('')]
import tools.shared
from tools.shared import *

# Sanity check for config

Expand All @@ -41,7 +41,9 @@ class RunnerCore(unittest.TestCase):
# Change this to None to get stderr reporting, for debugging purposes

def setUp(self):
global Settings
Settings.reset()
Settings = tools.shared.Settings
self.banned_js_engines = []
if not self.save_dir:
dirname = tempfile.mkdtemp(prefix='emscripten_test_' + self.__class__.__name__ + '_', dir=TEMP_DIR)
Expand Down
5 changes: 3 additions & 2 deletions third_party/demangler.py
Expand Up @@ -21,10 +21,11 @@

import os, sys, subprocess, re

__rootpath__ = os.path.abspath(os.path.dirname(__file__))
__rootpath__ = os.path.dirname(os.path.abspath(__file__))
def path_from_root(*pathelems):
return os.path.join(os.path.sep, *(__rootpath__.split(os.sep)[:-1] + list(pathelems)))
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
sys.path += [path_from_root('')]
from tools.shared import *

data = open(sys.argv[1], 'r').readlines()

Expand Down
5 changes: 3 additions & 2 deletions tools/bindings_generator.py
Expand Up @@ -50,10 +50,11 @@

import os, sys, glob, re

__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
sys.path += [path_from_root('')]
from tools.shared import *

# Find ply and CppHeaderParser
sys.path = [path_from_root('third_party', 'ply'), path_from_root('third_party', 'CppHeaderParser')] + sys.path
Expand Down
5 changes: 3 additions & 2 deletions tools/emconfiguren.py
Expand Up @@ -9,10 +9,11 @@

import os, sys

__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
sys.path += [path_from_root('')]
from tools.shared import *

Building.configure(sys.argv[1:])

10 changes: 6 additions & 4 deletions tools/emmaken.py
Expand Up @@ -56,10 +56,11 @@
* For SCons the shared.py can be imported like so:
__file__ = str(Dir('#/project_path_to_emscripten/dummy/dummy'))
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
sys.path += [path_from_root('')]
from tools.shared import *
For using the Emscripten compilers/linkers/etc. you can do:
env = Environment()
Expand Down Expand Up @@ -99,10 +100,11 @@ def path_from_root(*pathelems):

print >> sys.stderr, 'emmaken.py: ', ' '.join(sys.argv)

__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
sys.path += [path_from_root('')]
from tools.shared import *

# If this is a configure-type thing, just do that
CONFIGURE_CONFIG = os.environ.get('EMMAKEN_JUST_CONFIGURE')
Expand Down
5 changes: 3 additions & 2 deletions tools/emmakenxx.py
Expand Up @@ -6,10 +6,11 @@

import os, sys

__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
sys.path += [path_from_root('')]
from tools.shared import *

emmaken = path_from_root('tools', 'emmaken.py')
os.environ['EMMAKEN_CXX'] = '1'
Expand Down
5 changes: 3 additions & 2 deletions tools/exec_llvm.py
Expand Up @@ -36,10 +36,11 @@
import os, sys
from subprocess import Popen, PIPE, STDOUT

__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
sys.path += [path_from_root('')]
from tools.shared import *

Popen([LLVM_OPT, sys.argv[1], '-strip-debug', '-o=' + sys.argv[1]+'.clean.bc']).communicate()[0]

Expand Down

0 comments on commit 2761fe8

Please sign in to comment.