Ignore:
Timestamp:
Jul 9, 2020, 8:51:43 AM (4 years ago)
Author:
coas-nagasima
Message:

mrubyを2.1.1に更新

Location:
EcnlProtoTool/trunk/mruby-2.1.1
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/mruby-2.1.1/tasks/toolchains/android.rake

    r331 r439  
    88    /usr/local/opt/android-sdk/ndk-bundle
    99    /usr/local/opt/android-ndk
     10    ~/Android/Sdk/ndk-bundle
    1011    %LOCALAPPDATA%/Android/android-sdk/ndk-bundle
    1112    %LOCALAPPDATA%/Android/android-ndk
     13    %LOCALAPPDATA%/Android/Sdk/ndk/*
    1214    ~/Library/Android/sdk/ndk-bundle
    1315    ~/Library/Android/ndk
     
    3739Set ANDROID_PLATFORM environment variable or set :platform parameter
    3840        EOM
     41    end
     42  end
     43
     44  class SysrootNotReady < StandardError
     45    def message
     46      <<-EOM
     47Couldn't find standard header files
     48Please Move/Copy important file inside
     49  <NDK_HOME>/sysroot/usr/include/
     50to
     51  <NDK_HOME>/platforms/<ANDROID_VERSION>/<ARCH>/usr/include/
     52Higher NDK version will be use.
     53      EOM
    3954    end
    4055  end
     
    6782
    6883  def home_path
    69     @home_path ||= Pathname(
     84    @home_path ||= Pathname.new(
    7085      params[:ndk_home] ||
    7186      ENV['ANDROID_NDK_HOME'] ||
     
    7489        path.gsub! '\\', '/'
    7590        path.gsub! '~', Dir.home || '~'
     91        path.gsub!('*') do
     92          next nil unless path[-1] == "*"
     93          dirs = Dir.glob(path).collect do |d|
     94            m = d.match(/(\d+)\.(\d+)\.(\d+)$/)
     95            m ? [m[1], m[2], m[3]].collect { |v| v.to_i } : nil
     96          end
     97          dirs.compact!
     98          dirs.sort! do |before, after|
     99            f = 0
     100            if (f = (after.first <=> before.first)) != 0
     101              next f
     102            elsif (f = (after[1] <=> before[1])) != 0
     103              next f
     104            else
     105              next after.last <=> before.last
     106            end
     107          end
     108          dirs.empty? ? nil.to_s : dirs.first.join(".")
     109        end
    76110        File.directory?(path)
    77111      } || raise(AndroidNDKHomeNotFound)
     
    124158        Dir.glob(path.to_s){ |item|
    125159          next if File.file?(item)
    126           path = Pathname(item)
     160          path = Pathname.new(item)
    127161          break
    128162        }
     
    146180
    147181  def sysroot
    148     @sysroot ||= home_path.join('platforms', platform,
     182    return @sysroot if @sysroot
     183    sysroot_path = home_path.join('platforms', platform,
    149184        case arch
    150185        when /armeabi/    then 'arch-arm'
     
    156191        end
    157192      ).to_s
     193    if Dir.exist?(File.join(sysroot_path, "usr", "include"))
     194      return @sysroot = sysroot_path
     195    else
     196      raise(SysrootNotReady)
     197    end
    158198  end
    159199
     
    259299    flags = []
    260300
     301    case RUBY_PLATFORM
     302    when /mswin|mingw|win32/
     303      # Build for Android dont need window flag
     304      flags += %W(-U_WIN32 -U_WIN64)
     305    end
     306
    261307    flags += %W(-MMD -MP -D__android__ -DANDROID --sysroot="#{sysroot}")
    262308    flags += ctarget
     
    264310    when :gcc
    265311    when :clang
    266       flags += %W(-gcc-toolchain "#{gcc_toolchain_path.to_s}" -Wno-invalid-command-line-argument -Wno-unused-command-line-argument)
     312      flags += %W(-gcc-toolchain "#{gcc_toolchain_path}" -Wno-invalid-command-line-argument -Wno-unused-command-line-argument)
    267313    end
    268314    flags += %W(-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes)
Note: See TracChangeset for help on using the changeset viewer.