Skip to content

Commit

Permalink
Merge pull request #10 from ellemenno/v3.0.3
Browse files Browse the repository at this point in the history
v3.0.3
  • Loading branch information
pixeldroid authored Sep 17, 2017
2 parents 7f0d218 + c5d9001 commit 22be2eb
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 19 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Rake tasks for working with loomlibs

loomlibs are linkable LoomScript code libraries used to expand features of the [Loom SDK][loomsdk].

If you use [Rake][rake] and follow a consistent file layout across projects, these tasks can simplify the steps of seting up, building, installing, testing, demo-ing, and releasing loom libraries (`*.loomlib`).
If you use [Rake][rake] and follow a consistent file layout across projects, these tasks can simplify the steps of setting up, building, installing, testing, demo-ing, and releasing loom libraries (`*.loomlib`).

The tasks install into your `.loom` directory, and can be loaded from there into the Rakefiles of your projects.

loom tasks do not replace or interfere with the [loomcli][loomcli]; the two can be used safely together.
See [more details](#more-details) for the list of tasks provided.


## installation
Expand Down Expand Up @@ -65,14 +65,15 @@ Running `rake` in your project directory will execute the default task, which pr
rake lib:show # lists libs installed for sprint34 SDK
rake lib:uninstall # removes Foo.loomlib from sprint34 SDK
rake lib:version[v] # sets the library version number into lib/src/Foo.build and lib/src/Foo.ls
rake list_sdks # lists loom sdk versions available use
rake sdk[id] # sets the provided SDK version in the config files of lib, cli, gui, and test
rake test # shorthand for rake test:run
rake test:build # builds test/bin/FooTest.loom against sprint34 SDK
rake test:ci # runs test/bin/FooTest.loom for CI
rake test:run # runs test/bin/FooTest.loom for the console
rake test:run[seed] # runs test/bin/FooTest.loom for the console
rake test:sdk[id] # sets the provided SDK version into test/loom.config
rake version # reports loomlib version
(using loomtasks v3.0.2)
(using loomtasks v3.0.3)

If you are looking for more detail on any of the tasks, use `rake help`.

Expand Down Expand Up @@ -200,7 +201,6 @@ Pull requests are welcome!


[gh-releases]: https://help.github.com/articles/about-releases/ "about GitHub releases"
[loomcli]: https://loomsdk.com/#see "See the Loom CLI demo"
[loomsdk]: https://github.com/LoomSDK/LoomSDK "The Loom SDK, a native mobile app and game framework"
[rake]: https://rubygems.org/gems/rake "Rake (Ruby make)"
[spec-ls]: https://github.com/pixeldroid/spec-ls "spec-ls: a simple specification framework for loom"
15 changes: 13 additions & 2 deletions lib/tasks/loomlib.rake
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ task :list_targets => :check_consts do |t, args|
a = "#{LoomTasks.const_lib_name} v#{LoomTasks.lib_version(const_lib_version_file)} Rakefile"
b = "running on Ruby #{RUBY_VERSION}"
puts "#{a} #{b}"
system("rake -T")
system('rake -T')
puts "(using loomtasks v#{LoomTasks::VERSION})"
end

Expand All @@ -89,14 +89,15 @@ desc [
"show detailed usage and project info",
].join("\n")
task :help do |t, args|
system("rake -D")
system('rake -D')

puts "Please see the README for additional details."
end

desc [
"sets the provided SDK version in the config files of lib, cli, gui, and test",
"each config file can also be set independently, using the namespaced tasks provided",
"available sdks can be listed with 'rake list_sdks'",
].join("\n")
task :sdk, [:id] do |t, args|
args.with_defaults(:id => default_sdk)
Expand All @@ -112,3 +113,13 @@ task :sdk, [:id] do |t, args|

puts "[#{t.name}] task completed, all loom.configs updated to #{sdk_version}"
end

desc [
"lists loom sdk versions available use",
"loom sdks are stored in #{LoomTasks.sdk_root}",
].join("\n")
task :list_sdks do |t, args|
cmd = "ls -l1 #{LoomTasks.sdk_root}" unless windows?
cmd = "dir /b #{LoomTasks.sdk_root}" if windows?
system(cmd)
end
3 changes: 2 additions & 1 deletion lib/tasks/rakefiles/loomlib_cli.rake
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ namespace :cli do
FileUtils.cp(binary, main)

Dir.chdir('cli') do
cmd = "#{LoomTasks.loomexec(sdk_version)} #{args.options}"
cmd = LoomTasks.loomexec(sdk_version, args.options)
try(cmd, "failed to exec .loom")
end
end

desc [
"sets the provided SDK version into #{cli_config_file}",
"this updates #{cli_config_file} to define which SDK will compile the test apps",
"available sdks can be listed with 'rake list_sdks'",
].join("\n")
task :sdk, [:id] do |t, args|
args.with_defaults(:id => default_sdk)
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/rakefiles/loomlib_gui.rake
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace :gui do
desc [
"sets the provided SDK version into #{gui_config_file}",
"this updates #{gui_config_file} to define which SDK will compile the test apps",
"available sdks can be listed with 'rake list_sdks'",
].join("\n")
task :sdk, [:id] do |t, args|
args.with_defaults(:id => default_sdk)
Expand Down
7 changes: 6 additions & 1 deletion lib/tasks/rakefiles/loomlib_lib.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include LoomTasks


@lib_loom_config = nil
@lib_build_config = nil

def lib_build_file()
File.join('lib', 'src', "#{lib_name}.build")
Expand Down Expand Up @@ -35,6 +36,10 @@ def lib_build_config()
@lib_build_config || (@lib_build_config = LoomTasks.parse_loom_config(lib_build_file))
end

def release_dir()
'releases'
end

def readme_file()
'README.md'
end
Expand Down Expand Up @@ -108,7 +113,6 @@ namespace :lib do
task :release => LIBRARY do |t, args|
sdk = lib_config['sdk_version']
ext = '.loomlib'
release_dir = 'releases'
lib = t.prerequisites[0]
lib_version = LoomTasks.lib_version(lib_version_file)

Expand All @@ -130,6 +134,7 @@ namespace :lib do
desc [
"sets the provided SDK version into #{lib_config_file}",
"this updates #{lib_config_file} to define which SDK will compile the loomlib and be the install target",
"available sdks can be listed with 'rake list_sdks'",
].join("\n")
task :sdk, [:id] => 'lib:uninstall' do |t, args|
args.with_defaults(:id => default_sdk)
Expand Down
10 changes: 7 additions & 3 deletions lib/tasks/rakefiles/loomlib_test.rake
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ namespace :test do
FileUtils.cp(binary, main)

Dir.chdir('test') do
cmd = "#{loomexec(sdk_version)} --format junit --format console"
opts = '--format junit --format console'
cmd = LoomTasks.loomexec(sdk_version, opts)
try(cmd, "tests failed")
end
end
Expand All @@ -87,7 +88,7 @@ namespace :test do
"runs #{TEST} for the console",
"the test runner will print short-form results to stdout",
].join("\n")
task :run => TEST do |t, args|
task :run, [:seed] => TEST do |t, args|
sdk_version = test_config['sdk_version']
binary = t.prerequisites[0]
main = File.join('test', LoomTasks.main_binary)
Expand All @@ -99,14 +100,17 @@ namespace :test do
FileUtils.cp(binary, main)

Dir.chdir('test') do
cmd = "#{loomexec(sdk_version)} --format ansi"
opts = '--format ansi'
cmd = LoomTasks.loomexec(sdk_version, opts)
cmd = "#{cmd} --seed #{args.seed}" if args.seed
try(cmd, "tests failed")
end
end

desc [
"sets the provided SDK version into #{test_config_file}",
"this updates #{test_config_file} to define which SDK will compile the test apps",
"available sdks can be listed with 'rake list_sdks'",
].join("\n")
task :sdk, [:id] do |t, args|
args.with_defaults(:id => default_sdk)
Expand Down
13 changes: 8 additions & 5 deletions lib/tasks/rakefiles/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module LoomTasks

VERSION = '3.0.2'
VERSION = '3.0.3'

EXIT_OK = 0

Expand All @@ -32,12 +32,14 @@ def main_binary()
File.join(bin_dir, 'Main.loom')
end

def loomexec(sdk_version)
def loomexec(sdk_version, args = nil)
# needs to be run in the project root
# stubbornly, the runner loads bin/Main.loom from the current working directory
# weirdly, the runner expects a throw-away arg, so we pass an ignorable something
ignorable = '//'
"#{File.join(sdk_tools(sdk_version), 'loomexec')} #{ignorable}"
executable = File.join(sdk_tools(sdk_version), 'loomexec')

args ? "#{executable} #{ignorable} #{args}" : executable
end

def loomlaunch(sdk_version)
Expand Down Expand Up @@ -65,8 +67,9 @@ def global_config_file()
File.join(Dir.home, '.loom', 'loom.config')
end

def sdk_root()
File.join(Dir.home, '.loom', 'sdks')
def sdk_root(sdk_version = nil)
root = File.join(Dir.home, '.loom', 'sdks')
sdk_version ? File.join(root, sdk_version) : root
end

def sdk_architecture()
Expand Down
6 changes: 4 additions & 2 deletions lib/tasks/templates/LoomlibSpec.ls.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ package

public static class <%= lib_name %>Spec
{
private static const it:Thing = Spec.describe('<%= lib_name %>');
private static var it:Thing;

public static function describe():void
public static function specify(specifier:Spec):void
{
it = specifier.describe('<%= lib_name %>');

it.should('have useful tests', have_useful_tests);
}

Expand Down

0 comments on commit 22be2eb

Please sign in to comment.