Rakefile #1

  • //
  • guest/
  • surajdolby/
  • p4ruby/
  • Rakefile
  • View
  • Commits
  • Open Download .zip Download (3 KB)
require 'rake/clean'

$:.push File.expand_path("../lib", __FILE__)
require 'P4/version'

task 'version' do
  puts P4::VERSION
end

GEM_SPEC = Gem::Specification.new { |t|
  t.name = 'p4ruby'
  t.version = P4::VERSION
  t.platform = Gem::Platform::RUBY
  t.summary = 'Ruby extensions to the C++ Perforce API'
  t.description = t.summary + '.'
  t.author = 'Perforce Software, Inc.'
  t.email = '[email protected]'
  t.homepage = 'https://swarm.workshop.perforce.com/projects/perforce-software-p4ruby/'
  t.extensions = ['ext/P4/extconf.rb']
  t.licenses = ['MIT']

  t.files = %w( LICENSE.txt README.md )
  t.files += Dir.glob('ext/**/*.cpp')
  t.files += Dir.glob('ext/**/*.h')
  t.files += Dir.glob('lib/**/*.rb')
  t.files += Dir.glob('p4-bin/**/p4api.*')
}

begin
  require 'rake/extensiontask'

  unless ENV['P4RUBY_CROSS_PLATFORM'].nil?
    Rake::ExtensionTask.new('P4', GEM_SPEC) do |ext|
      ext.cross_compile = true
      ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
    end
  else
    Rake::ExtensionTask.new('P4', GEM_SPEC)
  end

  Gem::PackageTask.new(GEM_SPEC) do |pkg|
    pkg.need_tar = false
    pkg.need_zip = false
  end

rescue Exception
  #puts 'could not load rake/extensiontask'
end

require 'rake/testtask'

Rake::TestTask.new do |t|
  t.libs << '.'
  t.libs << 'test'
  t.warning = true
  t.verbose = true
  t.test_files = FileList[ 'test/testlib.rb', 'test/*_test.rb']
end

require 'rake/packagetask'

package_task = Rake::PackageTask.new('p4ruby', :noversion) do |p|
  p.need_tar = true
  p.need_zip = true
  p.package_files.include %w(
    Gemfile
    LICENSE.txt
    Rakefile
    README.md
  )
  p.package_files.include 'ext/**/*'
  p.package_files.include 'lib/**/*'
  p.package_files.include 'test/**/*'
end

# On some older platforms (Ruby 1.9) the 'directory' command doesn't work
# correctly.
begin
  desc 'Create doc directory from docbook files (requires ant)'
  directory 'doc' => 'docbook' do
    puts 'Executing docbook'
    sh 'cd docbook && ant publicsite -Ddoc.build.path=../p4-doc/manuals/_build && cd ..'
    doc_files = FileList['doc/**/*']
    package_task.package_files += doc_files
  end
  CLEAN.include('doc')

  desc 'Create build.properties, used to share version numbers in Jenkins tasks'
  file 'build.properties' do
    props = <<-END.gsub(/^ {4}/, '')
      P4RUBY_VERSION=#{P4::VERSION}
    END
    IO.write('build.properties', props)
  end

  # Remove output of 'rake compile' command
  CLEAN.include('lib/P4.bundle')
  CLEAN.include('lib/P4.so')

  CLEAN.include('pkg')

rescue Exception => e
  puts 'Not creating documentation rules used for builds, this is common in test environments'
end
# Change User Description Committed
#1 15524 surajdolby Populate -o //guest/perforce_software/p4ruby/main/...
//guest/surajdolby/p4ruby/....
//guest/perforce_software/p4ruby/main/Rakefile
#17 14754 tjuricek Fall back to hard-coded p4ruby version strings.

While a little bit more work, our tools don't really account for filenames with version numbers in them.

Additionally, this avoids having lots of files hanging around just because we've tested p4ruby against updates to dependencies (the p4api). Releases should be *very* rare, and the general rule is just to update the version whenever you make a release to rubygems.
#16 14753 tjuricek Include the generated Version file if it exists.
#15 14734 tjuricek Commenting out debugging message to use the 'version' task on systems that might not support the extensions task.
#14 14733 tjuricek Capture exception when trying to load rake/extensiontask.

Old versions of Ruby (like 1.9 installed via package managers) often have issues with this task.
#13 14719 tjuricek Mirroring the current state of the workshop.

From this point, we will try to rebuild the history of p4-ruby in the workshop from this codeline.
#12 14710 tjuricek Only configure the extension task for cross-compiling if the P4RUBY_CROSS_PLATFORM environment variable is set

Imported from Git
 Author: Tristan Juricek <[email protected]> 1423002666 -0800
 Committer: Tristan Juricek <[email protected]> 1423002666 -0800
 sha1: 9ce17f3ec56131a622187697d628bbb46263a30e
 push-state: incomplete
 parent-changes: 0ee1ad0df0afa24cced9c06798fe0bef2bcde3c2=[987673]
#11 14709 tjuricek Added p4api distribution to the gem to avoid problems with accessing ftp.perforce.com.

Imported from Git
 Author: Tristan Juricek <[email protected]> 1421449615 -0800
 Committer: Tristan Juricek <[email protected]> 1421449615 -0800
 sha1: 0ee1ad0df0afa24cced9c06798fe0bef2bcde3c2
 push-state: complete
 parent-changes: ff7dae2417a343af394a3cfdbcbfb1706b62df2c=[987544]
#10 14706 tjuricek Change name of archives to 'p4ruby' prefix.

Imported from Git
 Author: Tristan Juricek <[email protected]> 1421272531 -0800
 Committer: Tristan Juricek <[email protected]> 1421273320 -0800
 sha1: 03d1b340c12bb010a6de54e3253073c04abfee3c
 push-state: complete
 parent-changes: c168443e61dd1085420551037a39c05fc3450d4f=[985882]
#9 14703 tjuricek Set up call to 'rake cross native gem' as the main build step now.

This utilizes the 'cross compile' feature where we can build multiple versions of ruby under one gem package, though it's really going to be used for 'direct compilation'. The following variables need to be set to run the tools/build_p4ruby.sh now:

* RUBY_USE_VERSION - Should be the rvm version with the gem for publishing to geminabox
* RUBY_CC_VERSION - The colon (:) delimited string of ruby versions to build - each version should be installed via RVM and registered in ~/.rake_compiler/config.yml
* P4RUBY_CROSS_PLATFORM - The platform ID we are building on, needs to be set, e.g., 'x86_64-linux', 'i686-linux', 'x86_64-darwin-11'. Note that OS X uses the darwin 'version'.

P4RUBY-176

Imported from Git
 Author: Tristan Juricek <[email protected]> 1421184895 -0800
 Committer: Tristan Juricek <[email protected]> 1421184895 -0800
 sha1: 1e9e81f882ba0584a7bc66a48637a6576aee7cb9
 push-state: complete
 parent-changes: 50a9ca3b8ecb1e77ba823cbde20a7c89bd731d86=[984317]
#8 14697 tjuricek Revise bash 'build' script, and move dependency declarations for bundler.

It should now allow for setting the RUBY_VERSION environment variable, and should try to publish the precompiled gem to the internal gem server for testing.

P4RUBY-176

Imported from Git
 Author: Tristan Juricek <[email protected]> 1421100863 -0800
 Committer: Tristan Juricek <[email protected]> 1421100863 -0800
 sha1: 5d56ba62b673bd8c8ee78587dc6cc43365b6ac5d
 push-state: complete
 parent-changes: 80da9291ba8705d8e89946adbf3668173dd624a4=[984070]
#7 14696 tjuricek Allow the 'rake native gem' command to build the native gems for this platform.

The gem specification is now a part of the Rakefile for the rake-compiler tasks to figure out the native rules.

P4RUBY-176

Imported from Git
 Author: Tristan Juricek <[email protected]> 1421094211 -0800
 Committer: Tristan Juricek <[email protected]> 1421094260 -0800
 sha1: 80da9291ba8705d8e89946adbf3668173dd624a4
 push-state: complete
 parent-changes: f3345a676c834c47ee2211637abf2e827872dff5=[982334]
#6 14693 tjuricek Add basic 'create the source gem' task and clean rules for the output of 'rake compile' and gems.

Imported from Git
 Author: Tristan Juricek <[email protected]> 1418326971 -0800
 Committer: Tristan Juricek <[email protected]> 1418327031 -0800
 sha1: 98f9b10c0c37b44bfc8659e7934440fe1252c4c2
 push-state: complete
 parent-changes: e609513caf80a760161fc1e65c134a93915fbb7f=[974325]
#5 14688 tjuricek Add 'doc' directory to clean task.

Imported from Git
 Author: Tristan Juricek <[email protected]> 1416505978 -0800
 Committer: Tristan Juricek <[email protected]> 1416505978 -0800
 sha1: 6ce1d1757766a308d583b6d7a2b5b50574b9c1f1
 push-state: incomplete
 parent-changes: eb0ad5b8d97623c172d21e1786c025ac98e65466=[964380]
#4 14686 tjuricek Merge commit '01caf9661acf4dc7ebf23d33113e4be4ad364ece'

Imported from Git
 Author: Tristan Juricek <[email protected]> 1415915946 -0800
 Committer: Tristan Juricek <[email protected]> 1415915946 -0800
 sha1: 1aaf024362a53435ed87c853fd577049a38eae87
 push-state: complete
 parent-branch: WUpgNvsySG6cferVT-Hvuw==@961945
 parent-changes: c9daabefe02bc3d038f9a3dd4a8c2f1488746a25=[961945]/01caf9661acf4dc7ebf23d33113e4be4ad364ece=[961192]
#3 14682 Git Fusion Git Fusion branch management

Imported from Git
 ghost-of-change-num: 960958
 ghost-of-sha1: 005052ae424bd69f426f7209e741ca1c8c3253c7
 ghost-precedes-sha1: ad052c71a568ef12165e143a6866ad9ceffbb4a1
 parent-branch: None@960958
 push-state: incomplete
#2 14679 tony Fix p4ruby test run so it also includes the current directory in the
library search path. This helps us pick up the P4.so we're testing.

Also fixed some minor gripes and backed out a previous change that
obviously didn't work under 1.8
#1 14675 tony Add a 'make test' target that calls 'rake test' and
a Rakefile that loads and runs all the unit tests.

Reformatted p4conf.rb while I was there and added a vim
modeline so righteous editors will get the correct settings
immediately.