Browse Source

mad with no deps

Maxim Sokhatsky 11 years ago
parent
commit
a391e95692
8 changed files with 20 additions and 91 deletions
  1. 2 8
      .travis.yml
  2. 0 2
      LICENSE
  3. 1 1
      Makefile
  4. 3 6
      build
  5. BIN
      mad
  6. 2 13
      otp.mk
  7. 2 1
      rebar.config
  8. 10 60
      src/mad.erl

+ 2 - 8
.travis.yml

@@ -2,13 +2,7 @@ language: erlang
 otp_release:
 otp_release:
   - R16B02
   - R16B02
   - R16B01
   - R16B01
-  - R15B03
-  - R15B02
-  - R15B01
-  - R14B04
-  - R14B03
-  - R14B02
 notifications:
 notifications:
   email: false
   email: false
-  irc: "chat.freenode.net#xprous"
-script: "make test"
+  irc: "chat.freenode.net#n2o"
+script: "./mad get-deps compile"

+ 0 - 2
LICENSE

@@ -1,7 +1,5 @@
 Copyright (c) 2013 Sina Samavati <sina.samv@gmail.com>
 Copyright (c) 2013 Sina Samavati <sina.samv@gmail.com>
 
 
-MIT License
-
 Permission is hereby granted, free of charge, to any person obtaining
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
 a copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 "Software"), to deal in the Software without restriction, including

+ 1 - 1
Makefile

@@ -1,4 +1,4 @@
-APPS    := getopt stdlib sasl
+APPS    := stdlib sasl
 VER     := 1.0.0
 VER     := 1.0.0
 PLT_NAME := ~/mad_dialyzer.plt
 PLT_NAME := ~/mad_dialyzer.plt
 
 

+ 3 - 6
build

@@ -4,15 +4,12 @@ main(_) ->
     App = "mad",
     App = "mad",
     EmuArgs = "-noshell -noinput",
     EmuArgs = "-noshell -noinput",
     Files = files(),
     Files = files(),
-    escript:create(App, [shebang, {comment, ""}, {emu_args, EmuArgs},
-                         {archive, Files, []}]),
+    escript:create(App, [shebang, {comment, ""}, {emu_args, EmuArgs}, {archive, Files, []}]),
     ok = file:change_mode(App, 8#764).
     ok = file:change_mode(App, 8#764).
 
 
+read_file(File) -> {ok, Bin} = file:read_file(filename:absname(File)), Bin.
 files() ->
 files() ->
     [{filename:basename(F), read_file(F)}
     [{filename:basename(F), read_file(F)}
      || F <- filelib:wildcard(filename:join("ebin", "*")) ++
      || F <- filelib:wildcard(filename:join("ebin", "*")) ++
-            filelib:wildcard(filename:join(["deps", "*", "ebin", "*"]))].
+             filelib:wildcard(filename:join(["deps", "*", "ebin", "*"]))].
 
 
-read_file(File) ->
-    {ok, Bin} = file:read_file(filename:absname(File)),
-    Bin.

BIN
mad


+ 2 - 13
otp.mk

@@ -1,20 +1,9 @@
-empty :=
-ROOTS := deps .
-space := $(empty) $(empty)
-comma := $(empty),$(empty)
-ERL_LIBS := $(subst $(space),:,$(ROOTS))
-
-test: ct
 compile: get-deps
 compile: get-deps
 get-deps compile clean:
 get-deps compile clean:
 	./mad $@
 	./mad $@
 escript: compile
 escript: compile
 	./build
 	./build
-$(PLT_NAME):
-	dialyzer -pa . -pa deps/*/ebin --build_plt --output_plt $(PLT_NAME) --apps $(APPS) || true
-dialyze: compile $(PLT_NAME)
-	dialyzer deps/*/ebin ebin --plt $(PLT_NAME) --no_native -Werror_handling -Wunderspecs -Wrace_conditions
-ct: fetch-deps compile
+ct: get-deps compile
 	rebar ct skip_deps=true verbose=1
 	rebar ct skip_deps=true verbose=1
 
 
-.PHONY: fetch-deps compile escript dialyze ct
+.PHONY: get-deps compile escript ct

+ 2 - 1
rebar.config

@@ -1,5 +1,6 @@
 {cache,"~/.mad/repos"}.
 {cache,"~/.mad/repos"}.
 {deps_dir,"deps"}.
 {deps_dir,"deps"}.
 {deps, [
 {deps, [
-        {getopt, ".*",   {git, "git://github.com/jcomellas/getopt.git", {tag, "v0.8.2"}}}
+      {sh, ".*", {git, "git://github.com/synrc/sh", "HEAD"}},
+      {fs, ".*", {git, "git://github.com/synrc/fs", "HEAD"}}
        ]}.
        ]}.

+ 10 - 60
src/mad.erl

@@ -4,19 +4,10 @@
 -export([main/1]).
 -export([main/1]).
 
 
 main([]) -> help();
 main([]) -> help();
-main(Args) ->
-
-    {Opts, Params} = case getopt:parse(option_spec_list(), Args) of
-                         {ok, {Opts1, Params1}} ->
-                             {Opts1, [list_to_atom(E) || E <- Params1]};
-                         {error, {Reason, Data}} ->
-                             help(Reason, Data)
-                     end,
-    maybe_invalid(Params),
-    maybe_help(Opts, Params),
+main(Params) ->
 
 
     Cwd = mad_utils:cwd(),
     Cwd = mad_utils:cwd(),
-    ConfigFile = get_value(config_file, Opts, "rebar.config"),
+    ConfigFile = "rebar.config",
     ConfigFileAbs = filename:join(Cwd, ConfigFile),
     ConfigFileAbs = filename:join(Cwd, ConfigFile),
     Conf = mad_utils:consult(ConfigFileAbs),
     Conf = mad_utils:consult(ConfigFileAbs),
     Conf1 = mad_utils:script(ConfigFileAbs, Conf),
     Conf1 = mad_utils:script(ConfigFileAbs, Conf),
@@ -30,7 +21,7 @@ main(Args) ->
     LibDirs = mad_utils:lib_dirs(Cwd, Conf),
     LibDirs = mad_utils:lib_dirs(Cwd, Conf),
     code:add_paths(LibDirs),
     code:add_paths(LibDirs),
 
 
-    Fun = fun(F) -> ?MODULE:F(Cwd, ConfigFile, Conf1) end,
+    Fun = fun(F) -> Name = list_to_atom(F), ?MODULE:Name(Cwd, ConfigFile, Conf1) end,
     lists:foreach(Fun, Params).
     lists:foreach(Fun, Params).
 
 
 %% fetch dependencies
 %% fetch dependencies
@@ -49,11 +40,11 @@ main(Args) ->
 
 
 %% compile dependencies and the app
 %% compile dependencies and the app
 compile(Cwd, ConfigFile, Conf) ->
 compile(Cwd, ConfigFile, Conf) ->
-    'compile-apps'(Cwd, ConfigFile, Conf),
-    'compile-deps'(Cwd, ConfigFile, Conf).
+    'compile-deps'(Cwd, ConfigFile, Conf),
+    'compile-apps'(Cwd, ConfigFile, Conf).
 
 
 'compile-apps'(Cwd, ConfigFile, Conf) ->
 'compile-apps'(Cwd, ConfigFile, Conf) ->
-    Dirs = get_value(sub_dirs, Conf, []),
+    Dirs = mad_utils:sub_dirs(Cwd, ConfigFile, Conf),
     case Dirs of
     case Dirs of
         [] -> mad_compile:dep(Cwd, Conf, ConfigFile, Cwd);
         [] -> mad_compile:dep(Cwd, Conf, ConfigFile, Cwd);
         Apps -> mad_compile:deps(Cwd, Conf, ConfigFile, Apps) end.
         Apps -> mad_compile:deps(Cwd, Conf, ConfigFile, Apps) end.
@@ -63,53 +54,12 @@ compile(Cwd, ConfigFile, Conf) ->
 
 
 get_value(Key, Opts, Default) ->
 get_value(Key, Opts, Default) ->
     case lists:keyfind(Key, 1, Opts) of
     case lists:keyfind(Key, 1, Opts) of
-        {Key, Value} ->
-            Value;
+        {Key, Value} -> Value;
         _ -> Default end.
         _ -> Default end.
 
 
-option_spec_list() ->
-    [
-     {help, $h, "help", undefined, "Displays this message"},
-     {config_file, $C, "config", {string, "rebar.config"}, "Rebar config file to use"}
-    ].
-
-maybe_help(Opts, Params) ->
-    Fun = fun(L) ->
-                  case lists:member(help, L) of
-                      true ->
-                          help();
-                      false ->
-                          ok
-                  end
-          end,
-    Fun(Opts),
-    Fun(Params).
-
-maybe_invalid(Params) ->
-    lists:foreach(fun(E) ->
-                          case erlang:function_exported(?MODULE, E, 3) of
-                              true -> ok;
-                              false -> help("invalid_parameter", E)
-                          end
-                  end, Params).
-
-help("invalid_parameter", Data) ->
-    help(io_lib:format("invalid_parameter \"~s\"", [Data]));
-help(Reason, Data) ->
-    help(io_lib:format("~s ~p", [Reason, Data])).
-
-help(Msg) ->
-    io:format("Error: ~s~n~n", [Msg]),
-    help().
-
+help(Reason, Data) -> help(io_lib:format("~s ~p", [Reason, Data])).
+help(Msg) -> io:format("Error: ~s~n~n", [Msg]), help().
 help() ->
 help() ->
     io:format("Manage Deps~n"),
     io:format("Manage Deps~n"),
-    Params = [
-              {"", ""},
-              {"get-deps", "Fetch dependencies"},
-              {"compile-deps", "Compile dependencies"},
-              {"compile-apps", "Compile applications"},
-              {"compile", "Compile dependencies and applications"}
-             ],
-    getopt:usage(option_spec_list(), escript:script_name(), "", Params),
+    io:format("mad get-deps compile~n"),
     halt().
     halt().