Commit 01b2e73f authored by Steve Revill's avatar Steve Revill

Some improvements and changes.

Detail:
  Support for subdirectories of the Env directory added. The scan is
  now recursive to find any nested Env files.

  The environment list construction only bothers to list Obey files and
  is hard-wired to ignore the !Common file. Thus, the menu now doesn't
  contain bogus entries like '!Common', 'Makefile' and 'VersionNum'.

  When you select a different build directory, the environment is reset
  to blank to reinforce the fact that you should really run a new env
  file.
Admin:
  Tested. Requires new srcbuild in Library-0_87 (srcbuild-0_35).

Version 0.14. Tagged as 'builder-0_14'
parent 5fdb913d
/* (0.13)
/* (0.14)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.60.
*
*/
#define Module_MajorVersion_CMHG 0.13
#define Module_MajorVersion_CMHG 0.14
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 12 Dec 2000
#define Module_Date_CMHG 19 Oct 2001
#define Module_MajorVersion "0.13"
#define Module_Version 13
#define Module_MajorVersion "0.14"
#define Module_Version 14
#define Module_MinorVersion ""
#define Module_Date "12 Dec 2000"
#define Module_Date "19 Oct 2001"
#define Module_ApplicationDate2 "12-Dec-00"
#define Module_ApplicationDate4 "12-Dec-2000"
#define Module_ApplicationDate2 "19-Oct-01"
#define Module_ApplicationDate4 "19-Oct-2001"
#define Module_ComponentName "builder"
#define Module_ComponentPath "RiscOS/Utilities/Release/builder"
#define Module_FullVersion "0.13"
#define Module_HelpVersion "0.13 (12 Dec 2000)"
#define Module_FullVersion "0.14"
#define Module_HelpVersion "0.14 (19 Oct 2001)"
#define Module_LibraryVersionInfo "0:14"
......@@ -29,6 +29,7 @@
#include "swis.h"
#include "gadgets.h"
#include "env.h"
#include "constants.h"
extern char *build_tree;
......@@ -42,15 +43,48 @@ extern char *default_env;
_kernel_oserror *
env_populate(int window, int gadget, char *default_env)
{
_kernel_swi_regs reg;
_kernel_oserror *err=NULL;
char buffer[96];
char directory[BUFFER_SIZE];
char subdirectory[BUFFER_SIZE];
char strings_available[BUFFER_SIZE];
char *filename;
sprintf(directory,"%s.%s",build_tree,ENV_DIR);
strcpy(strings_available,"");
strcpy(subdirectory,"");
ERR_RETURN(err,env_recurse(directory,subdirectory,strings_available,window,gadget,default_env));
ERR_RETURN(err,stringset_set_available(0,window,gadget,strings_available));
if (default_env) {
if (strstr(strings_available,default_env)!=NULL) {
ERR_RETURN(err,stringset_set_selected(0,window,gadget,default_env));
}
} else {
ERR_RETURN(err,stringset_set_selected(0,window,gadget,""));
}
return (NULL);
}
/*
*
*
*
*
*/
_kernel_oserror *
env_recurse(char *directory,
char *subdirectory,
char *strings_available,
int window,
int gadget,
char *default_env)
{
_kernel_swi_regs reg;
_kernel_oserror *err=NULL;
char buffer[96];
char *filename;
int dir_length;
int path_length;
reg.r[0] = 10;
reg.r[1] = (int)directory;
......@@ -61,25 +95,55 @@ env_populate(int window, int gadget, char *default_env)
reg.r[6] = NULL;
do {
ERR_RETURN(err,_kernel_swi(OS_GBPB,&reg,&reg));
if (reg.r[4] != -1) {
if (reg.r[3] > 0) /* If we read any items */
{
filename = buffer+20;
if (strlen(strings_available)+strlen(filename)+1<
sizeof(strings_available)) {
if (strlen(strings_available)>0) /* more than one, add , */
strcat(strings_available,",");
strcat(strings_available,filename);
if ((*(int *)(buffer + 16) & 2) != 0) /* Recurse into directories */
{
dir_length = strlen(directory);
path_length = strlen(subdirectory);
strcat(directory, ".");
strcat(directory, filename);
if (strlen(subdirectory) != 0) strcat(subdirectory, ".");
strcat(subdirectory, filename);
ERR_RETURN(err,env_recurse(directory,subdirectory,strings_available,window,gadget,default_env));
directory[dir_length] = '\0';
subdirectory[path_length] = '\0';
}
else
{
if ((*(int *)(buffer + 0) & 0x000FFF00) == 0x000FEB00) /* Skip non-Obey files */
if (strcmp(filename, "!Common") != 0) /* Skip the !Common files */
{
char item[BUFFER_SIZE];
/* Nested env files are prefixed by their parent directory name(s) in the menu listing */
if (strlen(subdirectory) == 0)
{
strcpy(item,filename);
}
else
{
sprintf(item,"%s.%s",subdirectory,filename);
}
/* If we have room in our structure, add this item to our menu */
if (strlen(strings_available)+strlen(item)+1<BUFFER_SIZE)
{
if (strlen(strings_available)>0) /* more than one, add , */
{
strcat(strings_available,",");
}
strcat(strings_available,item);
}
}
}
}
} while (reg.r[4] != -1);
ERR_RETURN(err,stringset_set_available(0,window,gadget,strings_available));
if (default_env) {
if (strstr(strings_available,default_env)!=NULL) {
ERR_RETURN(err,stringset_set_selected(0,window,gadget,default_env));
}
} else {
ERR_RETURN(err,stringset_set_selected(0,window,gadget,""));
}
return (NULL);
}
......
......@@ -498,6 +498,8 @@ stringset_changed(int event_code,ToolboxEvent *event,
ERR_CHECK_RETURN(err,stringset_get_selected(0,window_options_id,
OPTIONS_GADGET_TREE,current,sizeof(current),&i));
set_build_tree(current);
default_env = NULL;
ERR_CHECK_RETURN(err,env_populate(window_options_id,OPTIONS_GADGET_ENV,default_env));
} else if (id_block->self_component == OPTIONS_GADGET_ENV) {
ERR_CHECK_RETURN(err,stringset_get_selected(0,window_options_id,
......
......@@ -28,6 +28,7 @@
#include "kernel.h"
_kernel_oserror *env_populate(int window, int gadget, char *default_env);
_kernel_oserror *env_recurse(char *directory, char *subdirectory, char *strings_available, int window, int gadget, char *default_env);
_kernel_oserror *env_source(void);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment