Exemplo n.º 1
0
/**
 *  Usage:
 *              build <package dir> [--destdir <destination>] [-march=<arch>] --cppflags --cflags -ldflags
 *
 */
int main( int argc, char** argv )
{
	int mem_start = CRuntime_GetAllocationCount();
	int mem_stop;

	int status = 1;

	Arguments* arguments = Arguments_new( argc, argv );
	if ( Arguments_isHelp( arguments ) )
	{
		printUsage();
		exit(0);
	}
	else if ( Arguments_isInvalid( arguments ) )
	{
		printUsage();
		exit(0);
	}

	if ( Arguments_isVersion( arguments ) )
	{
		fprintf( stdout, "build %s\n", BuildManager_GetVersion() );
		exit(0);
	}

	status = dobuild( arguments );

	Arguments_delete( arguments );
	if ( !status )
	{
		fprintf( stderr, "build: Exiting due to error.\n" );
	}

	mem_stop = CRuntime_GetAllocationCount();

#ifdef DEBUG_MEMORY	
	fprintf( stderr, "build: Memory leaked: %i\n", mem_stop - mem_start ); 
#endif

	return !status;
}
Exemplo n.º 2
0
Arquivo: erln8.c Projeto: mkb/erln8
// if not executing one of the erlang commands
// then process erln8 options etc
int erln8(int argc, gchar* argv[]) {
  // TODO: think about getting erlangs, configs, repos in one go
  //       instead of for each option. meh, maybe I don't care.
  GError* error = NULL;
  GOptionContext* context;
  context = g_option_context_new("");
  g_option_context_add_main_entries (context, entries, NULL);
  if (!g_option_context_parse (context, &argc, &argv, &error)) {
    g_error("erln8 option parsing failed: %s\n", error->message);
  }
  g_debug("argv[0] = [%s]\n",argv[0]);
  g_debug("opt_id = %s\n", opt_id);
  if(opt_quickstart) {
    initialize();
    opt_clone = "default";
    doclone();
    opt_repo = "default";
    opt_config = "default";
    // detect the latest git TAG from the OTP repo
    // I hope this works... ;-)
    opt_tag = "`git describe --abbrev=0 --tags`";
    opt_id = "quickstart_build";
    display_latest_quickstart();
    dobuild();
    return 0;
  }
  if(opt_init_erln8) {
    initialize();
    return 0;
  } else {
    if(!check_home()) {
      g_error("Please initialize erln8 with --init\n");
    }
  }
  GHashTable* runtime_options = get_erln8();
  gchar* use_color = (gchar*)g_hash_table_lookup(runtime_options, "color");
  if(g_strcmp0(use_color, "true") == 0) {
    opt_color = TRUE;
  } else {
    opt_color = FALSE;
  }
  if(opt_use) {
    init_here(opt_use);
    return 0;
  }
  if(opt_list) {
    list_erlangs();
    return 0;
  }
  if(opt_clone) {
    doclone();
    return 0;
  }
  if(opt_repos) {
    dorepos();
    return 0 ;
  }
  if(opt_configs) {
    doconfigs();
    return 0;
  }
  if(opt_fetch) {
    if(opt_repo == NULL) {
      git_fetch("default");
    } else {
      git_fetch(opt_repo);
    }
    return 0;
  }
  if(opt_build) {
    dobuild();
    return 0;
  }
  if(opt_link) {
    dolink();
    return 0;
  }
  if(opt_unlink) {
    dounlink();
    return 0;
  }
  if(opt_buildable) {
    git_allbuildable();
    return 0;
  }
  if(opt_show) {
    gchar* erl = which_erlang();
    if(erl != NULL) {
      printf("%s\n", erl);
      g_free(erl);
      return 0;
    }
  }
  if(opt_prompt) {
    gchar* erl = which_erlang();
    if(erl != NULL) {
      printf("%s", erl);
      g_free(erl);
    } else {
      printf("erln8 error");
    }
    return 0;
  }
  printf("\nerln8: the sneaky Erlang version manager\n");
  printf("(c) 2013 Dave Parfitt\n");
  printf("Licensed under the Apache License, Version 2.0\n\n");
  printf("%s\n", g_option_context_get_help(context, TRUE, NULL));
  return 0;
}