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

MacOS support #145

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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
30 changes: 30 additions & 0 deletions brix11/lib/brix11/brix/common/cmds/configure/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,36 @@ def platform_os
})
opts[:platform][:bits] = (opts[:platform][:arch] == 'x86_64' ? 64 : 32)
}
platform_helpers[/darwin/i] = ->(_s, opts) {
opts[:platform].merge!({
os: :darwin,
arch: `uname -m`.chomp,
defaults: {
libroot: '/usr',
dll_dir: 'lib',
library_path_var: 'DYLD_LIBRARY_PATH',
test_configs: %w{MACOSX},
prj_type: BRIX11::Project.handler('gnumake').default_prj_type
Copy link
Member

Choose a reason for hiding this comment

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

I think we don’t have a MACOSX test config anywhere

},
project_type: lambda { |opts_, pt = nil, cc = nil|
opts_def = opts_[:platform][:defaults]
prjh = BRIX11::Project.handler(pt || opts_def[:prj_type], cc || opts_def[:prj_cc])
[prjh.class::ID, prjh.compiler]
},
config_include: 'config-macosx.h',
config_prelude: %Q{
#define ACE_HAS_VERSIONED_NAMESPACE 1
#define ACE_MONITOR_FRAMEWORK 0
}.gsub(/^\s+/, ''),
gnumake_include: 'platform_macosx.GNU',
gnumake_prelude: %Q{
debug=0
inline=1
optimize=1
}.gsub(/^\s+/, '')
})
opts[:platform][:bits] = 64
}

def self.determin(opts)
build_target = (opts[:target] || platform_os)
Expand Down
2 changes: 2 additions & 0 deletions brix11/lib/brix11/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def self.get_cpu_cores
unless @cpu_cores
if mswin?
@cpu_cores = (ENV['NUMBER_OF_PROCESSORS'] || 1).to_i
elsif File.exist?('/usr/sbin/sysctl')
@cpu_cores = (`/usr/sbin/sysctl -n hw.ncpu` rescue '1').strip.to_i
Copy link
Member

Choose a reason for hiding this comment

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

/usr/sbin/sysctl does also exist on my OpenSuSE linux system, but fails with sysctl: cannot stat /proc/sys/hw/ncpu: No such file or directory. This change breaks my Linux multi cpu support, maybe check first if you are on a Mac and second if the sysctl exists?

Choose a reason for hiding this comment

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

It also fails inside a docker linux build image!

root@45565f35112e:/axcioma# irb

irb(main):001:0> (`/usr/sbin/sysctl -n hw.ncpux` rescue 1).strip.to_i
sysctl: cannot stat /proc/sys/hw/ncpux: No such file or directory
=> 0
irb(main):002:0> 

This rescue 1 is obscure, or not?

else
@cpu_cores = (`cat /proc/cpuinfo | grep processor | wc -l` rescue '1').strip.to_i
end
Expand Down