Skip to content

Commit

Permalink
#380 Use only minor version in installation path
Browse files Browse the repository at this point in the history
Additional fix bug in resolving correct libraries.
  • Loading branch information
SanderMertens committed Oct 25, 2015
1 parent 23f76a3 commit 6628367
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 75 deletions.
2 changes: 1 addition & 1 deletion build/artefact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
end

CLEAN.include(".corto/obj")
CLEAN.include("doc")
CLOBBER.include(TARGETDIR + "/" + ARTEFACT)
CLOBBER.include(GENERATED_SOURCES)
CLOBBER.include(GENERATED_HEADERS)
CLOBBER.include("doc")

if USE_COMPONENT_LOADED.length == 0 then
CLOBBER.include(".corto/components.txt")
Expand Down
2 changes: 1 addition & 1 deletion build/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
if ENV['CORTO_VERSION'] then
VERSION ||= ENV['CORTO_VERSION']
else
VERSION ||= `corto -v`
VERSION ||= `corto --minor`[0...-1]
end
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export CORTO_BUILD=`echo $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )`/buil
export CORTO_HOME=$HOME/.corto
export CORTO_TARGET=$HOME/.corto
export PATH=$CORTO_TARGET/bin:$PATH
export CORTO_VERSION=0.2.0-alpha
export CORTO_VERSION=0.2
3 changes: 2 additions & 1 deletion generators/html/src/html.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,8 @@ static corto_int16 html_copy(const char* path, const char *name) {
char sourcePath[PATH_MAX];
char destinationPath[PATH_MAX];
char *cortoHome = getenv("CORTO_HOME");
sprintf(sourcePath, "%s/etc/corto/%s/generators/%s", cortoHome, CORTO_VERSION, name);
sprintf(sourcePath, "%s/etc/corto/%s.%s/generators/%s", cortoHome,
CORTO_VERSION_MAJOR, CORTO_VERSION_MINOR, name);
sprintf(destinationPath, "%s/%s", path, name);
if (corto_cp(sourcePath, destinationPath)) {
goto error;
Expand Down
47 changes: 16 additions & 31 deletions packages/corto/io/README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,39 @@
# ::corto::io
### print(string str)
#### str
### println(string str)
#### str
### readln()
#### Returns

## file

### binary
### construct()

#### Returns

### destruct()

### flush()

### handle
### mode
### name
### read(uint32 bytes)

#### bytes

#### Returns

### readAll()

#### Returns

### readLn()

#### Returns

### readText()

#### Returns

### write(sequence{octet,0} data)

#### data

#### Returns

### writeText(string txt)

#### txt

#### Returns

### print(string str)

#### str

### println(string str)

#### str

### readln()

#### Returns

## fileMode
### Append
### Read
### ReadAppend
### ReadWrite
### Write
18 changes: 15 additions & 3 deletions packages/corto/lang/src/corto.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct corto_exitHandler {

#define VERSION_MAJOR "0"
#define VERSION_MINOR "2"
#define VERSION_PATCH "0"
#define VERSION_PATCH "1"
#define VERSION_SUFFIX "alpha"

#ifdef VERSION_SUFFIX
Expand Down Expand Up @@ -699,12 +699,13 @@ int corto_start(void) {

/* CORTO_BUILD is where the buildsystem is located */
if (!corto_getenv("CORTO_BUILD")) {
corto_setenv("CORTO_BUILD", "/usr/local/lib/corto/%s/build", CORTO_VERSION);
corto_setenv("CORTO_BUILD", "/usr/local/lib/corto/%s.%s/build",
CORTO_VERSION_MAJOR, CORTO_VERSION_MINOR);
}

/* CORTO_HOME is where corto binaries are located */
if (!corto_getenv("CORTO_HOME")) {
corto_setenv("CORTO_HOME", "/usr/local", CORTO_VERSION);
corto_setenv("CORTO_HOME", "/usr/local");
}

/* CORTO_TARGET is where a project will be built */
Expand Down Expand Up @@ -767,6 +768,17 @@ int corto_start(void) {
corto_operatorInit();
#endif

/* Register exit-handler */
void corto_loaderOnExit(void* udata);
corto_onexit(corto_loaderOnExit, NULL);

/* Register library-binding */
int corto_loadLibraryAction(corto_string file, int argc, char* argv[], void *data);
corto_loaderRegister("so", corto_loadLibraryAction, NULL);

int corto_fileLoader(corto_string file, int argc, char* argv[], void *data);
corto_loaderRegister("", corto_fileLoader, NULL);

/* Register C-binding and vm-binding */
{
corto_uint32 id;
Expand Down
33 changes: 14 additions & 19 deletions packages/corto/lang/src/corto_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ int corto_loaderRegister(corto_string ext, corto_loadAction handler, void* userD
if ((h = corto_lookupExt(ext))) {
if (h->load != handler) {
corto_error("corto_loaderRegister: extension '%s' is already registered with another loader.", ext);
abort();
goto error;
}
} else {
Expand Down Expand Up @@ -162,15 +163,15 @@ static corto_string corto_packageToFile(corto_string package) {

static corto_dl corto_loadValidLibrary(corto_string fileName) {
corto_dl result = NULL;
corto_string ___ (*build)();
corto_string ___ (*build)(void);

if (!(result = corto_dlOpen(fileName))) {
corto_error("%s", corto_dlError());
goto error;
}

/* Lookup build function */
build = (corto_string ___ (*)())corto_dlProc(result, "corto_getBuild");
build = (corto_string ___ (*)(void))corto_dlProc(result, "corto_getBuild");

/* Validate version */
if (!build || strcmp(build(), corto_getBuild())) {
Expand Down Expand Up @@ -235,7 +236,8 @@ static int corto_loadLibrary(corto_string fileName, int argc, char* argv[]) {
int corto_loadComponent(corto_string component, int argc, char* argv[]) {
int result;
corto_string path = corto_envparse(
"$CORTO_TARGET/lib/corto/%s/components/%s", CORTO_VERSION, component);
"$CORTO_TARGET/lib/corto/%s.%s/components/%s",
CORTO_VERSION_MAJOR, CORTO_VERSION_MINOR, component);
result = corto_loadLibrary(path, argc, argv);
corto_dealloc(path);
return result;
Expand All @@ -244,7 +246,7 @@ int corto_loadComponent(corto_string component, int argc, char* argv[]) {
/*
* An adapter on top of corto_loadLibrary to fit the corto_loadAction signature.
*/
static int corto_loadLibraryAction(corto_string file, int argc, char* argv[], void *data) {
int corto_loadLibraryAction(corto_string file, int argc, char* argv[], void *data) {
CORTO_UNUSED(data);
return corto_loadLibrary(file, argc, argv);
}
Expand Down Expand Up @@ -327,7 +329,8 @@ corto_string corto_locateLibrary(corto_string lib) {
time_t t = 0;

/* Look for local packages first */
targetPath = corto_envparse("$CORTO_TARGET/lib/corto/%s/%s", CORTO_VERSION, lib);
targetPath = corto_envparse("$CORTO_TARGET/lib/corto/%s.%s/%s",
CORTO_VERSION_MAJOR, CORTO_VERSION_MINOR, lib);
if (corto_fileTest(targetPath)) {
if (corto_checkLibrary(targetPath)) {
t = corto_getModified(targetPath);
Expand All @@ -337,7 +340,8 @@ corto_string corto_locateLibrary(corto_string lib) {

/* Look for packages in CORTO_HOME */
if (strcmp(corto_getenv("CORTO_HOME"), corto_getenv("CORTO_TARGET"))) {
corto_string homePath = corto_envparse("$CORTO_HOME/lib/corto/%s/%s", CORTO_VERSION, lib);
corto_string homePath = corto_envparse("$CORTO_HOME/lib/corto/%s.%s/%s",
CORTO_VERSION_MAJOR, CORTO_VERSION_MINOR, lib);
if (corto_fileTest(homePath)) {
time_t myT = corto_getModified(homePath);
if ((myT > t) || !result) {
Expand All @@ -352,7 +356,8 @@ corto_string corto_locateLibrary(corto_string lib) {
/* Look for global packages */
if (strcmp("/usr/local", corto_getenv("CORTO_TARGET")) &&
strcmp("/usr/local", corto_getenv("CORTO_HOME"))) {
usrPath = corto_envparse("/usr/local/lib/corto/%s/%s", CORTO_VERSION, lib);
usrPath = corto_envparse("/usr/local/lib/corto/%s.%s/%s",
CORTO_VERSION_MAJOR, CORTO_VERSION_MINOR, lib);
if (corto_fileTest(usrPath)) {
time_t myT = corto_getModified(usrPath);
if ((myT >= t) || !result) {
Expand Down Expand Up @@ -500,7 +505,7 @@ static int corto_packageLoader(corto_string package) {
}

/* Load file with unspecified extension */
static int corto_fileLoader(corto_string file, int argc, char* argv[], void* udata) {
int corto_fileLoader(corto_string file, int argc, char* argv[], void* udata) {
CORTO_UNUSED(udata);
corto_id testName;

Expand All @@ -525,7 +530,7 @@ static int corto_fileLoader(corto_string file, int argc, char* argv[], void* uda
return -1;
}

static void corto_loaderOnExit(void* udata) {
void corto_loaderOnExit(void* udata) {
struct corto_fileHandler* h;
corto_dl dl;
void (*proc)(int code);
Expand Down Expand Up @@ -565,16 +570,6 @@ static void corto_loaderOnExit(void* udata) {
}
}

/* Register handlers for shared objects */
CORTO_DLL_CONSTRUCT {

/* Register exit-handler */
corto_onexit(corto_loaderOnExit, NULL);

/* Register library-binding */
corto_loaderRegister("so", corto_loadLibraryAction, NULL);
corto_loaderRegister("", corto_fileLoader, NULL);
}
#else
int corto_load(corto_string str) {
CORTO_UNUSED(str);
Expand Down
5 changes: 4 additions & 1 deletion packages/corto/md/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ::corto::md
### parse(object destination,string text)
### parse(string text)
#### text
#### Returns
### parseToCorto(object destination,string text)
#### destination
#### text

Expand Down
6 changes: 4 additions & 2 deletions tools/corto/src/cortotool.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main(int argc, char* argv[]) {
cortotool_printUsage(FALSE);
break;
} else if (*(argv[i]+1) == 'v') {
printf("%s", CORTO_VERSION);
printf("%s\n", CORTO_VERSION);
} else if (*(argv[i]+1) == 'c') {
if (corto_loadComponent(argv[i + 1], 0, NULL)) {
corto_error("%s: %s", argv[i + 1], corto_lasterr());
Expand All @@ -89,10 +89,12 @@ int main(int argc, char* argv[]) {
i++;
} else if (*(argv[i]+1) == '-') {
if (!strcmp(argv[i] + 2, "version")) {
corto_error("corto version %s (%s) build %s\n",
printf("corto version %s (%s) build %s\n\n",
CORTO_VERSION,
CORTO_PLATFORM_STRING,
corto_getBuild());
} else if (!strcmp(argv[i] + 2, "minor")) {
printf("%s.%s\n", CORTO_VERSION_MAJOR, CORTO_VERSION_MINOR);
} else if (!strcmp(argv[i] + 2, "help")) {
cortotool_printUsage(FALSE);
} else if (!strcmp(argv[i] + 2, "expert")) {
Expand Down
Loading

0 comments on commit 6628367

Please sign in to comment.