destination 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 51cf1d14a0c68b2167284b5cb4be5d8ae66d6a9b
4
+ data.tar.gz: c44b499d6d4181c7957b32e5e75e3209f2c22120
5
+ SHA512:
6
+ metadata.gz: 7331348cf976737cc1b7bcd4c6d360e3122b5d4b232ecad73057afb919e0b373b8ef03bf8b5a434d2754bbcd96a2a06e3da6d12e17dbba00434eee8e0321da2d
7
+ data.tar.gz: 4b97cee34f568fc21302a09116f7d18f987ca34b7237e4325f2d10d0d149a04947cb5464cae940929442a9ff244e2495cf8f1d57836a8b5a2841321ce6be3357
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ This project is licensed under the MIT license.
2
+
3
+ Copyright (c) 2014 Dirk Gadsden
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ ## destination
2
+
3
+ Objective-C is a neat language. Clang is an incredibly powerful compiler. Xcode... well Xcode's a bit like wading through a olympic swimming pool full of elephant turds.
4
+
5
+ Thing is, though, Obj-C and Clang *don't actually need Xcode*. Destination (shortened to **dest** in your terminal) is a way to build Objective-C code without having to deal with Xcode. Right now it's rudimentary, but eventually this puppy should be able to build everything from a small `main.m` script to a giant application. We'll see how that goes.
6
+
7
+ ### Getting started
8
+
9
+ ```
10
+ # Clone the repo
11
+ ...
12
+ # Go into the test project directory
13
+ cd test/project
14
+ # Invoke destination
15
+ rake build
16
+ # Launch the program it just built!
17
+ ./project
18
+ ```
19
+
20
+ ### License
21
+
22
+ Copyright 2014 Dirk Gadsden and licensed under the MIT license. See LICENSE for details.
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dest/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "destination"
8
+ spec.version = Dest::VERSION
9
+ spec.authors = ["Dirk Gadsden"]
10
+ spec.email = ["dirk@dirk.to"]
11
+ spec.summary = "Free your code from Xcode"
12
+ spec.description = "Tool for building Objective-C code without the use of Xcode"
13
+ spec.homepage = "https://github.com/dirk/dest"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rake", '~> 3.0', '>= 3.0.0'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rspec", '~> 3.0', '>= 3.0.0'
25
+ spec.add_development_dependency "rspec-expectations", '~> 3.0', '>= 3.0.0'
26
+ end
@@ -0,0 +1,6 @@
1
+
2
+ require 'dest/version'
3
+ require 'dest/project/base'
4
+
5
+ module Dest
6
+ end
@@ -0,0 +1,37 @@
1
+
2
+ module Dest
3
+ module Project
4
+ class << self
5
+ attr_accessor :current
6
+ end
7
+
8
+ class Base
9
+ attr_reader :dir
10
+ attr_accessor :frameworks, :sources, :target
11
+ def initialize dir
12
+ @dir = dir
13
+ @frameworks = ['Foundation']
14
+ @sources = scan_sources
15
+ @target = guess_target
16
+ end
17
+ def scan_sources
18
+ src = Dir[File.join(@dir, 'src', '*.m')]
19
+ root = Dir[File.join(@dir, '*.m')]
20
+ return src + root
21
+ end
22
+ def guess_target
23
+ # Turns '/a/b/c' into just 'c'
24
+ File.basename dir
25
+ end
26
+
27
+ def self.setup dir=nil, &block
28
+ unless dir
29
+ dir = ::Rake.application.original_dir
30
+ end
31
+ proj = self.new dir
32
+ Dest::Project.current = proj
33
+ block.call proj
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,78 @@
1
+
2
+ require 'dest'
3
+
4
+ module Dest
5
+ class Rake
6
+ # Quick access to setting up the Rake environment
7
+ def self.setup
8
+ self.new.setup
9
+ end
10
+ # Pull in handy Rake DSL
11
+ include ::Rake::DSL
12
+
13
+ def project
14
+ Dest::Project.current
15
+ end
16
+
17
+ def objectsify fn
18
+ fn.sub(/\.m$/, '.bc').sub project.dir, @build_dir
19
+ end
20
+
21
+ def flags
22
+ return @flags if @flags
23
+ flags = []
24
+ flags << '-S' # Only run preprocess and compilation steps
25
+ flags << '-Wall' # All warnings
26
+ flags << '-emit-llvm'
27
+ flags << '-fobjc-arc'
28
+ @flags = flags.join ' '
29
+ end
30
+
31
+ def compile source, object
32
+ sh "clang #{source} #{flags} -o #{object}"
33
+ end
34
+
35
+ # Set up rake hooks
36
+ def setup
37
+ # puts project.sources.inspect
38
+ # puts project.target
39
+ @build_dir = File.join project.dir, 'build'
40
+ unless Dir.exists? @build_dir
41
+ Dir.mkdir @build_dir
42
+ end
43
+
44
+ desc 'Build the project'
45
+ task 'build' => project.target do
46
+ puts "Built #{File.basename project.target}"
47
+ end
48
+
49
+ # Build the sources into their objects via the rule below
50
+ file project.target => project.sources.map {|fn| objectsify fn } do |t|
51
+ # Then build the target file from the sources
52
+ target = t.name
53
+ objects = t.prerequisites
54
+ # Little message
55
+ puts "Linking #{File.basename target} from #{objects.length.to_s} objects"
56
+ # Then figure out our frameworks and objects
57
+ objects = objects.join ' '
58
+ frameworks = project.frameworks.map {|f| "-framework #{f}" }.join ' '
59
+ sh "clang #{objects} -lobjc #{frameworks} -o #{target}"
60
+ end
61
+
62
+ # Set up a file task for every source file to catch changes
63
+ project.sources.each do |src|
64
+ # Figure out where stuff should come from and go to
65
+ source_file = src
66
+ object_file = objectsify src
67
+
68
+ file object_file => source_file do |t|
69
+ basename = File.basename src
70
+ puts "Compiling #{basename}"
71
+
72
+ compile source_file, object_file
73
+ end
74
+ end
75
+
76
+ end#self.setup
77
+ end#Rake
78
+ end#Dest
@@ -0,0 +1,3 @@
1
+ module Dest
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dest do
4
+ it 'should have a version' do
5
+ expect(Dest::VERSION).to be_a String
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.require
4
+
5
+ require 'dest'
6
+
7
+ RSpec.configure do |config|
8
+ # Some (optional) config here
9
+ end
@@ -0,0 +1,10 @@
1
+ # Adjust our load path for testing
2
+ lib = File.expand_path('../../../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'dest/rake'
6
+
7
+ Dest::Project::Base.setup do |proj|
8
+ proj.frameworks << 'Cocoa'
9
+ end
10
+ Dest::Rake.setup
@@ -0,0 +1,36 @@
1
+ // Adapted from http://www.cocoawithlove.com/2010/09/minimalist-cocoa-programming.html
2
+ // Updated to work with ARC.
3
+
4
+ #import <Foundation/Foundation.h>
5
+ #import <Cocoa/Cocoa.h>
6
+
7
+ int main ()
8
+ {
9
+ [NSApplication sharedApplication];
10
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
11
+ // Set up the menubar
12
+ id menubar = [NSMenu new];
13
+ id appMenuItem = [NSMenuItem new];
14
+ [menubar addItem:appMenuItem];
15
+ [NSApp setMainMenu:menubar];
16
+ // Set up the menu
17
+ id appMenu = [NSMenu new];
18
+ id appName = [[NSProcessInfo processInfo] processName];
19
+ id quitTitle = [@"Quit " stringByAppendingString:appName];
20
+ id quitMenuItem = [[NSMenuItem alloc] initWithTitle:quitTitle
21
+ action:@selector(terminate:)
22
+ keyEquivalent:@"q"];
23
+ [appMenu addItem:quitMenuItem];
24
+ [appMenuItem setSubmenu:appMenu];
25
+ // Create our window
26
+ id window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200)
27
+ styleMask:NSTitledWindowMask
28
+ backing:NSBackingStoreBuffered
29
+ defer:NO];
30
+ [window cascadeTopLeftFromPoint:NSMakePoint(20,20)];
31
+ [window setTitle:appName];
32
+ [window makeKeyAndOrderFront:nil];
33
+ [NSApp activateIgnoringOtherApps:YES];
34
+ [NSApp run];
35
+ return 0;
36
+ }
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: destination
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dirk Gadsden
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.5'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.5'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 3.0.0
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '3.0'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 3.0.0
67
+ - !ruby/object:Gem::Dependency
68
+ name: rspec-expectations
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '3.0'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 3.0.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.0'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.0.0
87
+ description: Tool for building Objective-C code without the use of Xcode
88
+ email:
89
+ - dirk@dirk.to
90
+ executables: []
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - ".rspec"
95
+ - Gemfile
96
+ - LICENSE
97
+ - README.md
98
+ - dest.gemspec
99
+ - lib/dest.rb
100
+ - lib/dest/project/base.rb
101
+ - lib/dest/rake.rb
102
+ - lib/dest/version.rb
103
+ - spec/base_spec.rb
104
+ - spec/spec_helper.rb
105
+ - test/project/Rakefile
106
+ - test/project/main.m
107
+ homepage: https://github.com/dirk/dest
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.2.2
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Free your code from Xcode
131
+ test_files:
132
+ - spec/base_spec.rb
133
+ - spec/spec_helper.rb
134
+ - test/project/Rakefile
135
+ - test/project/main.m