Permalink
Browse files

Merge branch 'master' into mrbgems

Conflicts:
	Rakefile
	mrbgems/GEMS.active
	mrbgems/build_tasks.rb
	mrblib/Makefile
	src/Makefile
  • Loading branch information...
akiray03 committed Jan 3, 2013
2 parents ad6a17a + 65901c3 commit abb869b15eb1c5967b77c7ea3ef37dfe15dae4c0
Showing with 862 additions and 1,787 deletions.
  1. +1 −0 .gitignore
  2. +0 −110 CMakeLists.txt
  3. +36 −93 Rakefile
  4. 0 build/.gitkeep
  5. +53 −0 build_config.rb
  6. +0 −30 cmake/Toolchain-Arch-mingw32.cmake.sample
  7. +0 −37 cmake/Toolchain-OSX-GenericShElf.cmake.sample
  8. +0 −32 cmake/Toolchain-OSX-mingw32.cmake.sample
  9. +0 −13 cmake/Toolchain-OpenWRT-ANY.cmake
  10. +0 −29 cmake/Toolchain-Ubuntu-gnueabi.cmake.sample
  11. +0 −29 cmake/Toolchain-Ubuntu-gnueabihf.cmake.sample
  12. +0 −30 cmake/Toolchain-Ubuntu-mingw32.cmake.sample
  13. +0 −54 cmake/modules/IntrospectSystem.cmake
  14. +3 −6 doc/mrbgems/c_and_ruby_extension_example/.gitignore
  15. +0 −18 doc/mrbgems/c_and_ruby_extension_example/Makefile
  16. +17 −0 doc/mrbgems/c_and_ruby_extension_example/mrbgem.rake
  17. +1 −1 doc/mrbgems/c_and_ruby_extension_example/mrblib/example.rb
  18. +3 −6 doc/mrbgems/c_extension_example/.gitignore
  19. +0 −16 doc/mrbgems/c_extension_example/Makefile
  20. +17 −0 doc/mrbgems/c_extension_example/mrbgem.rake
  21. +2 −4 doc/mrbgems/c_extension_example/test/example.c
  22. +3 −7 doc/mrbgems/ruby_extension_example/.gitignore
  23. +0 −15 doc/mrbgems/ruby_extension_example/Makefile
  24. +17 −0 doc/mrbgems/ruby_extension_example/mrbgem.rake
  25. 0 ext/.gitkeep
  26. 0 lib/.gitkeep
  27. +97 −45 minirake
  28. +0 −5 mrbgems/GEMS.active
  29. +0 −5 mrbgems/GEMS.db
  30. +0 −138 mrbgems/Makefile4gem
  31. +0 −162 mrbgems/build_tasks.rb
  32. +0 −1 mrbgems/g/.gitignore
  33. +0 −18 mrbgems/generate_gem_mixlib.rb
  34. +0 −15 mrbgems/generate_gem_mrblib.rb
  35. +0 −18 mrbgems/generate_gem_mrblib_header.rb
  36. +0 −23 mrbgems/generate_gem_srclib.rb
  37. +0 −60 mrblib/CMakeLists.txt
  38. +0 −85 mrblib/Makefile
  39. +15 −0 mrblib/mrblib.rake
  40. +0 −11 src/CMakeLists.txt
  41. +0 −72 src/Makefile
  42. +49 −51 src/lex.def
  43. +25 −0 src/mruby_core.rake
  44. +5 −0 tasks/libmruby.rake
  45. +33 −0 tasks/mrbgems.rake
  46. +175 −0 tasks/mruby_build.rake
  47. +183 −0 tasks/mruby_gem_spec.rake
  48. +24 −0 tasks/ruby_ext.rake
  49. +41 −0 tasks/rules.rake
  50. +0 −42 test/CMakeLists.txt
  51. +0 −129 test/Makefile
  52. +32 −0 test/mrbtest.rake
  53. +0 −8 tools/CMakeLists.txt
  54. +0 −9 tools/mirb/CMakeLists.txt
  55. +0 −94 tools/mirb/Makefile
  56. +10 −0 tools/mirb/mirb.rake
  57. +0 −9 tools/mrbc/CMakeLists.txt
  58. +0 −72 tools/mrbc/Makefile
  59. +10 −0 tools/mrbc/mrbc.rake
  60. +0 −9 tools/mruby/CMakeLists.txt
  61. +0 −99 tools/mruby/Makefile
  62. +10 −0 tools/mruby/mruby.rake
  63. +0 −5 tools/xpcat/CMakeLists.txt
  64. +0 −72 tools/xpcat/xpcat.c
View
@@ -20,6 +20,7 @@
cscope.out
/src/y.tab.c
/bin
+/build
/mrblib/mrblib.c
/mrblib/*.*tmp
/mrblib/mrblib.mrb
View
@@ -1,110 +0,0 @@
-# CMake build system for mruby
-# License: released under the same license as mruby
-# Author: jonforums@gmail.com
-# Author: beoran@gmail.com
-#
-# Usage example:
-# 1. Ensure CMake, Bison, and a build toolchain are on `PATH`
-# 2. Change to a build directory outside source tree, eg - `build` subdir
-# 3. Create build Makefiles or project files.
-# `cmake ..` (UNIX-like system)
-# `cmake -G "MSYS Makefiles" ..`
-# `cmake -G "Visual Studio 10" ..`
-# `cmake -G "NMake Makefiles" ..`
-# ** to cross-compile: add -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain/file
-# ** to set install dir: add -DCMAKE_INSTALL_PREFIX=/path/to/installdir
-# 4a. Build: `make` (to make noisy, add `VERBOSE=1`)
-# 4b. Build and test: `make all test`
-# 4c. Build, test, and install: `make all test install`
-# 4d. Build, test, and package: `make all test package`
-
-cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
-
-# Default build mode is Release With Debug Info unless specified
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
- "Choose build type: empty Debug Release RelWithDebInfo MinSizeRel"
- FORCE)
- message(STATUS "Build type not set, defaulting to 'RelWithDebInfo'")
-endif()
-
-project(mruby C)
-
-# TODO stop polluting source tree with CMakeFiles/ and CMakeCache.txt
-# on build location check failure
-# Make sure we are not trying to generate in in-tree build unless building
-# with an MSVC or Xcode IDE where it's OK.
-if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT (MSVC_IDE OR XCODE))
- message(FATAL_ERROR
- "\nIn-source builds are not allowed as CMake would overwrite the "
- "Makefiles distributed with mruby. Delete any created 'CMakeFiles' "
- "subdirectory and 'CMakeCache.txt' file from the current directory, "
- "change to the 'build' subdirectory, and re-run CMake from there.")
-endif()
-
-if(COMMAND cmake_policy)
- cmake_policy(SET CMP0003 NEW) # don't split absolute link paths
- cmake_policy(SET CMP0012 NEW) # recognize number & boolean literals
- cmake_policy(SET CMP0015 NEW) # convert relative link paths to absolute
-endif(COMMAND cmake_policy)
-
-# Match original Makefile's default in-tree install.
-if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
- set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} CACHE PATH
- "Install path prefix prepended to install directories."
- FORCE
- )
-endif()
-
-# TODO refactor to use an option when adding shared lib support
-set(BUILD_SHARED_LIBS OFF)
-
-# Version of mruby, useful for versoning .so and .dll files.
-# TODO automate by parsing src/version.h -or- extract git info?
-set(MRUBY_VERSION 1.0.0dev)
-string(REGEX MATCH "^[0-9]+[.][0-9]+" MRUBY_SOVERSION ${MRUBY_VERSION})
-string(REPLACE "." "" MRUBY_DLL_SHORTVER ${MRUBY_SOVERSION})
-
-# Search in the `cmake` directory for custom CMake helper modules.
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
-include(IntrospectSystem)
-
-# Search for C header files in these directories.
-include_directories("${CMAKE_SOURCE_DIR}/include" "${CMAKE_SOURCE_DIR}/src")
-
-# TODO re-enable (and implement) if needed
-# On some 64-bit platforms, libraries should be installed into `lib64'
-# instead of `lib'. Set this to 64 to do that.
-#set(LIB_SUFFIX "" CACHE STRING "Suffix for 'lib' directories, e.g. '64'")
-
-# build the components
-add_subdirectory(src)
-add_subdirectory(mrblib)
-add_subdirectory(tools)
-add_subdirectory(test)
-
-# install the header files
-install(FILES include/mruby.h DESTINATION include)
-install(FILES include/mrbconf.h DESTINATION include)
-install(DIRECTORY include/mruby DESTINATION include FILES_MATCHING PATTERN "*.h")
-
-# TODO refactor once proper versioning scheme implemented
-# archive packaging
-set(CPACK_GENERATOR "TGZ;ZIP")
-string(TOLOWER ${CMAKE_SYSTEM_NAME} MRUBY_HOST)
-if(CMAKE_C_COMPILER_VERSION)
- string(REPLACE "." "" MRUBY_GCC_VERSION ${CMAKE_C_COMPILER_VERSION})
-endif()
-
-# TODO add build info suffix for non-Windows builds?
-if(MINGW)
- set(MRUBY_BUILD "-mingw${MRUBY_GCC_VERSION}")
-elseif(MSVC)
- set(MRUBY_BUILD "-msvc${MSVC_VERSION}")
-endif()
-set(CPACK_PACKAGE_FILE_NAME
- "${CMAKE_PROJECT_NAME}-${MRUBY_VERSION}-${MRUBY_HOST}${MRUBY_BUILD}"
- )
-include(CPack)
-
-# vim: ts=2 sts=2 sw=2 et
View
129 Rakefile
@@ -1,116 +1,59 @@
+# encoding: utf-8
# Build description.
# basic build file for mruby
-def default_make
- `which gmake 2>/dev/null` == "" ? 'make' : 'gmake'
-end
-
-# compiler, linker (gcc), archiver, parser generator
-CC = ENV['CC'] || 'gcc'
-LL = ENV['LL'] || 'gcc'
-AR = ENV['AR'] || 'ar'
-YACC = ENV['YACC'] || 'bison'
-MAKE = ENV['MAKE'] || default_make
-
-# mruby source root path
-MRUBY_ROOT = ENV['MRUBY_ROOT'] || File.expand_path(File.dirname(__FILE__))
-
-# by default GEMs are deactivated
-ENABLE_GEMS = true
-
-# the default file which contains the active GEMs
-ACTIVE_GEMS = ENV['ACTIVE_GEMS'] || File.join(MRUBY_ROOT, '/mrbgems/GEMS.active')
-GEMS_DATABASE = File.join MRUBY_ROOT, 'mrbgems', 'GEMS.db'
-
-# default compile option
-COMPILE_MODE = ENV['COMPILE_MODE'] || :debug
-
+load 'tasks/ruby_ext.rake'
+load 'tasks/mruby_build.rake'
+load 'tasks/mruby_gem_spec.rake'
##############################
# compile flags
+load File.expand_path(ENV['CONFIG'] || './build_config.rb')
-case COMPILE_MODE.to_s
-when 'release'
- CFLAGS = ['-O3']
-when 'small'
- CFLAGS = ['-Os']
-else # including 'debug'
- e = ENV['CFLAGS']
- CFLAGS = if e then [e] else ['-g', '-O3'] end
-end
-LDFLAGS = [ENV['LDFLAGS']]
-LIBS = [ENV['LIBS'] || '-lm -lcrypto']
-
-if ENABLE_GEMS
- require './mrbgems/build_tasks'
- Rake::Task[:load_mrbgems_flags].invoke
-else
- CFLAGS << "-DDISABLE_GEMS"
-end
-
-CFLAGS << "-Wall" << "-Werror-implicit-function-declaration" << "-I#{MRUBY_ROOT}/include" << "-I#{MRUBY_ROOT}/src"
-
-if ENV['OS'] == 'Windows_NT'
- MAKE_FLAGS = "--no-print-directory CC=#{CC} LL=#{LL} AR=#{AR} YACC=#{YACC} CFLAGS=\"#{CFLAGS.join(' ')}\" LDFLAGS=\"#{LDFLAGS.join(' ')}\" LIBS=\"#{LIBS.join(' ')}\" ENABLE_GEMS=\"#{ENABLE_GEMS}\" MRUBY_ROOT=\"#{MRUBY_ROOT}\""
-else
- MAKE_FLAGS = "--no-print-directory CC='#{CC}' LL='#{LL}' AR='#{AR}' YACC='#{YACC}' CFLAGS='#{CFLAGS.join(' ')}' LDFLAGS='#{LDFLAGS.join(' ')}' LIBS='#{LIBS.join(' ')}' ENABLE_GEMS='#{ENABLE_GEMS}' MRUBY_ROOT='#{MRUBY_ROOT}'"
-end
+load 'tasks/rules.rake'
+load 'src/mruby_core.rake'
+load 'mrblib/mrblib.rake'
+load 'tools/mrbc/mrbc.rake'
+load 'tasks/mrbgems.rake'
+load 'tasks/libmruby.rake'
+load 'tools/mruby/mruby.rake'
+load 'tools/mirb/mirb.rake'
+load 'test/mrbtest.rake'
##############################
-# internal variables
+# generic build targets, rules
+task :default => :all
-CP = ENV['CP'] ||= 'cp'
-RM_F = ENV['RM_F'] ||= 'rm -f'
-CAT = ENV['CAT'] ||= 'cat'
+binfiles = [exefile('bin/mruby'), exefile('bin/mirb'), exefile('bin/mrbc')]
+desc "build all targets, install (locally) in-repo"
+task :all => binfiles + MRuby.targets.map { |t| [exefile("#{t.build_dir}/bin/mruby"), exefile("#{t.build_dir}/bin/mirb"), exefile("#{t.build_dir}/bin/mrbc")] }.flatten
-##############################
-# generic build targets, rules
+file exefile('bin/mruby') => exefile('build/host/bin/mruby') do |t|
+ FileUtils.cp t.prerequisites.first, t.name
+end
-task :default => :all
+file exefile('bin/mirb') => exefile('build/host/bin/mirb') do |t|
+ FileUtils.cp t.prerequisites.first, t.name
+end
-desc "build all targets, install (locally) in-repo"
-task :all do
- sh "#{MAKE} -C src #{MAKE_FLAGS}"
- sh "#{MAKE} -C mrblib #{MAKE_FLAGS}"
- if ENABLE_GEMS
- puts "-- MAKE mrbgems --"
- Rake::Task['mrbgems_all'].invoke
- end
- sh "#{MAKE} -C tools/mruby #{MAKE_FLAGS}"
- sh "#{MAKE} -C tools/mirb #{MAKE_FLAGS}"
+file exefile('bin/mrbc') => exefile('build/host/bin/mrbc') do |t|
+ FileUtils.cp t.prerequisites.first, t.name
end
-desc "sh all mruby tests"
-task :test => [:all] do
- sh "#{MAKE} -C test #{MAKE_FLAGS}"
+desc "run all mruby tests"
+task :test => MRuby.targets.map { |t| exefile("#{t.build_dir}/test/mrbtest") } do
+ sh "#{filename exefile('build/host/test/mrbtest')}"
+ if MRuby.targets.count > 1
+ puts "\nYou should run #{MRuby.targets.map{ |t| t.name == 'host' ? nil : "#{t.build_dir}/test/mrbtest" }.compact.join(', ')} on target device."
+ end
end
desc "clean all built and in-repo installed artifacts"
task :clean do
- sh "#{MAKE} clean -C src #{MAKE_FLAGS}"
- sh "#{MAKE} clean -C mrblib #{MAKE_FLAGS}"
- if ENABLE_GEMS
- puts "-- MAKE mrbgems --"
- Rake::Task['mrbgems_clean'].invoke
+ MRuby.targets.each do |t|
+ FileUtils.rm_rf t.build_dir
end
- sh "#{MAKE} clean -C tools/mruby #{MAKE_FLAGS}"
- sh "#{MAKE} clean -C tools/mirb #{MAKE_FLAGS}"
- sh "#{MAKE} clean -C test #{MAKE_FLAGS}"
-end
-
-desc "show build config summary"
-task :showconfig do
- puts " CC = #{CC}"
- puts " LL = #{LL}"
- puts " AR = #{AR}"
- puts " YACC = #{YACC}"
- puts " MAKE = #{MAKE}"
- puts ""
- puts " CFLAGS = #{CFLAGS.join(' ')}"
- puts " LDFLAGS = #{LDFLAGS.join(' ')}"
- puts " LIBS = #{LIBS.join(' ')}"
- puts ""
- puts " ENABLE_GEMS = #{ENABLE_GEMS}"
+ FileUtils.rm_f binfiles
end
View
No changes.
View
@@ -0,0 +1,53 @@
+MRuby::Build.new do |conf|
+ conf.cc = ENV['CC'] || 'gcc'
+ conf.ld = ENV['LD'] || 'gcc'
+ conf.ar = ENV['AR'] || 'ar'
+ # conf.cxx = conf.cc
+ # conf.objcc = conf.cc
+ # conf.asm = conf.cc
+ # conf.yacc = 'bison'
+ # conf.gperf = 'gperf'
+ # conf.cat = 'cat'
+ # conf.git = 'git'
+
+ conf.cflags << (ENV['CFLAGS'] || %w(-g -O3 -Wall -Werror-implicit-function-declaration))
+ conf.ldflags << (ENV['LDFLAGS'] || %w(-lm))
+ # conf.cxxflags = []
+ # conf.objccflags = []
+ # conf.asmflags = []
+
+ # conf.gem 'doc/mrbgems/ruby_extension_example'
+ # conf.gem 'doc/mrbgems/c_extension_example'
+ # conf.gem 'doc/mrbgems/c_and_ruby_extension_example'
+ # conf.gem :git => 'git@github.com:masuidrive/mrbgems-example.git', :branch => 'master'
+end
+
+=begin
+MRuby::CrossBuild.new('i386') do |conf|
+ conf.cc = ENV['CC'] || 'gcc'
+ conf.ld = ENV['LD'] || 'gcc'
+ conf.ar = ENV['AR'] || 'ar'
+ # conf.cxx = 'gcc'
+ # conf.objcc = 'gcc'
+ # conf.asm = 'gcc'
+ # conf.yacc = 'bison'
+ # conf.gperf = 'gperf'
+ # conf.cat = 'cat'
+ # conf.git = 'git'
+
+ if ENV['OS'] == 'Windows_NT' # MinGW
+ conf.cflags = %w(-g -O3 -Wall -Werror-implicit-function-declaration -Di386_MARK)
+ conf.ldflags = %w(-s -static)
+ else
+ conf.cflags << %w(-g -O3 -Wall -Werror-implicit-function-declaration -arch i386)
+ conf.ldflags << %w(-arch i386)
+ end
+ # conf.cxxflags << []
+ # conf.objccflags << []
+ # conf.asmflags << []
+
+ # conf.gem 'doc/mrbgems/ruby_extension_example'
+ # conf.gem 'doc/mrbgems/c_extension_example'
+ # conf.gem 'doc/mrbgems/c_and_ruby_extension_example'
+end
+=end
@@ -1,30 +0,0 @@
-# Sample toolchain file for building for Windows from an Arch Linux system.
-#
-# Typical usage:
-# 1) install cross compiler: `sudo pacman -S mingw32-gcc`
-# 2) cp cmake/Toolchain-Arch-mingw32.cmake.sample ~/Toolchain-Arch-mingw32.cmake
-# 3) tweak toolchain values as needed
-# 4) cd build
-# 5) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-Arch-mingw32.cmake ..
-
-# name of the target OS on which the built artifacts will run
-# and the toolchain prefix
-set(CMAKE_SYSTEM_NAME Windows)
-set(TOOLCHAIN_PREFIX i486-mingw32)
-
-# cross compilers to use for C and C++
-set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
-set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
-set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
-
-# target environment on the build host system
-# set 1st to dir with the cross compiler's C/C++ headers/libs
-# set 2nd to dir containing personal cross development headers/libs
-set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} ~/crossdev/w32)
-
-# modify default behavior of FIND_XXX() commands to
-# search for headers/libs in the target environment and
-# search for programs in the build host environment
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
@@ -1,37 +0,0 @@
-#
-# Typical usage:
-# 0) install cmake version 2.8-9 or higher.
-# 1) install a PizzaFactory cross compiler
-# a) darwin toolchain targeting sh-elf: http://sourceforge.jp/projects/pf3gnuchains/downloads/50061/sh-pizzafactory-elf.pkg/
-# b) install pkg.
-# c) export PATH=$PATH:/pizza/bin
-# 2) cp cmake/Toolchain-OSX-GenericShElf.cmake.sample ~/Toolchain-OSX-GenericShElf.cmake
-# 3) tweak toolchain values as needed
-# 4) cd build
-# 5) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-OSX-GenericShElf.cmake ..
-# 6) Run mirb on gdb
-# a) sh-pizzafactory-elf-gdb tools/mirb/mirb
-# b) target sim
-# c) load
-# d) run
-
-# name of the target OS on which the built artifacts will run
-# and the toolchain prefix
-set(CMAKE_SYSTEM_NAME Generic)
-set(TOOLCHAIN_PREFIX sh-pizzafactory-elf)
-
-# cross compilers to use for C and C++
-set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
-set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
-
-# target environment(s) on the build host system
-# set 1st to dir with the cross compiler's C/C++ headers/libs
-# set 2nd to dir containing personal cross development headers/libs
-set(CMAKE_FIND_ROOT_PATH /pizza/${TOOLCHAIN_PREFIX})
-
-# modify default behavior of FIND_XXX() commands to
-# search for headers/libs in the target environment and
-# search for programs in the build host environment
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Oops, something went wrong.

0 comments on commit abb869b

Please sign in to comment.