Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support other arch rather than x86, remove x86 spcified arguments for gc... #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/blade/blade_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,13 @@ def set_cpp_str(self, cpp_str):

def get_flags_except_warning(self):
"""Get the flags that are not warning flags. """
flags_except_warning = ['-m%s' % self.options.m, '-mcx16', '-pipe']
linkflags = ['-m%s' % self.options.m]
flags_except_warning = ['-pipe']
linkflags = []

if self.options.arch == 'x86':
flags_except_warning += ['-m%s' % self.options.m, '-mcx16']
linkflags += ['-m%s' % self.options.m]

if self.options.profile == 'debug':
flags_except_warning += ['-ggdb3', '-fstack-protector']
elif self.options.profile == 'release':
Expand Down
7 changes: 4 additions & 3 deletions src/blade/cc_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,10 @@ def _get_as_flags(self):

"""
options = self.blade.get_options()
as_flags = ["--" + options.m]
return as_flags

if options.arch == 'x86':
return ["--" + options.m]
else:
return []

def _dep_is_library(self, dep):
"""_dep_is_library.
Expand Down
13 changes: 11 additions & 2 deletions src/blade/command_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def _check_plat_and_profile_options(self):
self.options.profile != 'release'):
console.error_exit('--profile must be "debug" or "release".')

self.options.arch = self._arch()
if self.options.m is None:
self.options.m = self._arch_bits()
else:
Expand Down Expand Up @@ -377,12 +378,20 @@ def _cmd_parse(self):
return arg_parser.parse_known_args()

def _arch_bits(self):
"""Platform arch."""
if 'x86_64' == platform.machine():
"""Platform arch bit."""
if '64bit' == platform.architecture()[0]:
return '64'
else:
return '32'

def _arch(self):
"""Platform arch name."""
arch = platform.machine()
if arch in ['i386', 'i686', 'x86_64']:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得x86_64应该从i386中独立出来

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里我是这样分的:
arch分x86 arm等, bits分32 64.
所以x86_64是x86 64bit, i386是x86 32bit.
x86上能支持到cmpxchg -32 -64等, 不用再判断等于i386或x86_64,
你觉得怎么样好点?

return 'x86'
else:
return arch

def get_command(self):
"""Return blade command. """
return self.options.command
Expand Down
9 changes: 6 additions & 3 deletions src/blade/load_build_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ def bits(self):

@property
def arch(self):
if self._options.m == '32':
return 'i386'
if self._options.arch == 'x86':
if self._options.m == '32':
return 'i386'
else:
return 'x86_64'
else:
return 'x86_64'
return self._options.arch

def is_debug(self):
return self._options.profile == 'debug'
Expand Down
6 changes: 4 additions & 2 deletions src/blade/rules_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, options, build_dir, gcc_version,
self.version_cpp_compile_template = string.Template("""
env_version = Environment(ENV = os.environ)
env_version.Append(SHCXXCOMSTR = '%s$updateinfo%s' % (colors('cyan'), colors('end')))
env_version.Append(CPPFLAGS = '-m$m')
env_version.Append(CPPFLAGS = '$m')
version_obj = env_version.SharedObject('$filename')
""")
self.blade_config = configparse.blade_config
Expand Down Expand Up @@ -140,9 +140,11 @@ def generate_version_file(self):
version_cpp.close()

self._add_rule('VariantDir("%s", ".", duplicate=0)' % self.build_dir)

# todo - may not work in python 2.4
self._add_rule(self.version_cpp_compile_template.substitute(
updateinfo='Updating version information',
m=self.options.m,
m='-m%s' % self.options.m if self.options.arch == 'x86' else '',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要用这种if语句表达式,python 2.4不支持。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

的确, 加了一个todo, 不知道有什么比较清爽的写法

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有,只能提到前面
m = ''
if ...
else:

self._add_rule(

2014-04-01 10:38 GMT+08:00 Coney Wu [email protected]:

In src/blade/rules_generator.py:

     self._add_rule(self.version_cpp_compile_template.substitute(
         updateinfo='Updating version information',
  •        m=self.options.m,
    
  •        m='-m%s' % self.options.m if self.options.arch == 'x86' else '',
    

的确, 加了一个todo, 不知道有什么比较清爽的写法


Reply to this email directly or view it on GitHubhttps://github.com//pull/98/files#r11145762
.

filename='%s/version.cpp' % self.build_dir))

def generate_imports_functions(self, blade_path):
Expand Down
1 change: 1 addition & 0 deletions src/test/blade_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def doSetUp(self, path, target='...', full_targets=None,
self.current_building_path = 'build64_release'
self.current_source_dir = '.'
options = {
'arch': 'x86',
'm': '64',
'profile': 'release',
'generate_dynamic': True,
Expand Down
6 changes: 4 additions & 2 deletions src/test/java_jar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ def testGenerateRules(self):
self.assertTrue('poppy_client_javawrap.cxx' in com_swig_java)

self.assertTrue('-fno-omit-frame-pointer' in com_swig_python_cxx)
self.assertTrue('-mcx16 -pipe -g' in com_swig_python_cxx)
self.assertTrue('-mcx16 -g' in com_swig_python_cxx)
self.assertTrue('-pipe' in com_swig_python_cxx)
self.assertTrue('-DNDEBUG -D_FILE_OFFSET_BITS' in com_swig_python_cxx)

self.assertTrue('-fno-omit-frame-pointer' in com_swig_java_cxx)
self.assertTrue('-mcx16 -pipe -g' in com_swig_java_cxx)
self.assertTrue('-mcx16 -g' in com_swig_java_cxx)
self.assertTrue('-pipe' in com_swig_java_cxx)
self.assertTrue('-DNDEBUG -D_FILE_OFFSET_BITS' in com_swig_java_cxx)

self.assertTrue(java_com_line)
Expand Down