Skip to content

Commit

Permalink
Include retrospective compiler versions from new Inform distribution
Browse files Browse the repository at this point in the history
This uses the "retrospective" directory from the Inform source, where
versions 6L02, 6L38, and 6M62 are kept. The names of the versions and the
blurbs that are shown below the setting in the UI are controlled by a file
named retrospective.txt that we include in our GResource bundle.
  • Loading branch information
ptomato committed May 11, 2022
1 parent 7afcc16 commit 5adb720
Show file tree
Hide file tree
Showing 15 changed files with 480 additions and 59 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
mkdir intools
touch intools/{ni,inform6,cBlorb}
chmod a+x intools/ni
mkdir -p retrospective/6{L02,L38,M62}
touch retrospective/6{L02,L38,M62}/ni
touch retrospective/6{L02,L38,M62}/cBlorb
touch retrospective/retrospective.txt
- name: configure
run: meson _build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/_build
/_install
/intools
/retrospective
/subprojects/chimara
/subprojects/ratify
3 changes: 3 additions & 0 deletions build-aux/com.inform7.IDE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ modules:
- bash intest/scripts/first.sh
- cd inform; bash scripts/first.sh
- make -C inform forceintegration
- make -C inform retrospective
- cp -R inform/retrospective /app/tmp
- name: inform7-ide
buildsystem: meson
sources:
Expand All @@ -218,5 +220,6 @@ modules:
- cp -R /app/tmp/intools .
- cp -R /app/tmp/data/* data/
- cp -R /app/tmp/inform/* src/inform/
- cp -R /app/tmp/retrospective .

...
2 changes: 2 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ override_dh_auto_build:
bash intest/scripts/first.sh
cd inform; bash scripts/first.sh
make -C inform forceintegration
make -C inform retrospective
cp -R inform/retrospective .
dh_auto_configure
dh_auto_build

Expand Down
50 changes: 50 additions & 0 deletions inform7-ide.spec
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ bash intest/scripts/first.sh
cd inform
bash scripts/first.sh
make forceintegration
make retrospective
cp -R retrospective ../%{name}-%{version}/
cd ..
%{shrink:%{__meson} --buildtype=plain --prefix=%{_prefix} --libdir=%{_libdir}
--libexecdir=%{_libexecdir} --bindir=%{_bindir} --sbindir=%{_sbindir}
Expand Down Expand Up @@ -167,6 +169,52 @@ fi
%{pkgdatadir}/Templates/Quixe/waiting.gif
%{pkgdatadir}/highlighting/*.lang
%{pkgdatadir}/styles/*.xml
%{pkgdatadir}/retrospective/6L02/Extensions/Emily*Short/*.i7x
%{pkgdatadir}/retrospective/6L02/Extensions/Eric*Eve/*.i7x
%{pkgdatadir}/retrospective/6L02/Extensions/Graham*Nelson/*.i7x
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/*.i6t
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/*.jpg
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/*.html
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/*.pdf
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Languages/*/Syntax.preform
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Languages/*/about.txt
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Languages/*/flag.png
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Templates/Classic/*.html
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Templates/Parchment/*.css
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Templates/Parchment/*.gif
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Templates/Parchment/*.js
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Templates/Parchment/*.txt
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Templates/Quixe/*.css
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Templates/Quixe/*.gif
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Templates/Quixe/*.js
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Templates/Quixe/*.txt
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Templates/Standard/*.css
%{pkgdatadir}/retrospective/6L02/Extensions/Reserved/Templates/Standard/*.html
%{pkgdatadir}/retrospective/6L02/Outcome*Pages/*.html
%{pkgdatadir}/retrospective/6L02/Outcome*Pages/texts.txt
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Extensions/Emily*Short/*.i7x
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Extensions/Eric*Eve/*.i7x
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Extensions/Graham*Nelson/*.i7x
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/I6T/*.i6t
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Languages/*/Syntax.preform
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Languages/*/about.txt
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Languages/*/flag.png
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Miscellany/*.jpg
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Miscellany/*.html
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Miscellany/*.pdf
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Templates/Classic/*.html
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Templates/Parchment/*.css
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Templates/Parchment/*.gif
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Templates/Parchment/*.js
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Templates/Parchment/*.txt
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Templates/Quixe/*.css
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Templates/Quixe/*.gif
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Templates/Quixe/*.js
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Templates/Quixe/*.txt
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Templates/Standard/*.css
%{pkgdatadir}/retrospective/{6L38,6M62}/Internal/Templates/Standard/*.html
%{pkgdatadir}/retrospective/{6L38,6M62}/Outcome*Pages/*.html
%{pkgdatadir}/retrospective/{6L38,6M62}/Outcome*Pages/texts.txt
%{_datadir}/icons/hicolor/*/actions/com.inform7.IDE.builtin.png
%{_datadir}/icons/hicolor/*/apps/com.inform7.IDE.png
%{_datadir}/icons/hicolor/*/emblems/com.inform7.IDE.materials.png
Expand All @@ -193,6 +241,8 @@ fi
%{pkglibdir}/glulxe.so
%{pkglibexecdir}/inform6
%{pkglibexecdir}/ni
%{pkglibexecdir}/retrospective/*/cBlorb
%{pkglibexecdir}/retrospective/*/ni

%changelog
* Tue Apr 19 2022 Philip Chimento <philip.chimento@gmail.com> - 2.0.0-1
Expand Down
20 changes: 20 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ subdir('po')
install_data('intools/cBlorb', 'intools/inform6', 'intools/ni',
install_dir: pkglibexecdir, install_mode: 'rwxr-xr-x')

foreach build : ['6L02', '6L38', '6M62']
install_data('retrospective/@0@/cBlorb'.format(build),
'retrospective/@0@/ni'.format(build),
install_dir: pkglibexecdir / 'retrospective' / build,
install_mode: 'rwxr-xr-x')
endforeach

i18n.merge_file(input: 'com.inform7.IDE.desktop.in',
output: 'com.inform7.IDE.desktop', type: 'desktop', po_dir: 'po',
install: true, install_dir: datadir / 'applications')
Expand All @@ -126,6 +133,19 @@ install_subdir('data/highlighting', install_dir: pkgdatadir)
install_subdir('data/styles', install_dir: pkgdatadir,
exclude_files: ['styles.its', 'styles.pot', 'update-pot.sh'])

retrospective_data_dirs = {
'6L02': ['Extensions', 'I6T', 'Outcome Pages'],
'6L38': ['Internal', 'Outcome Pages'],
'6M62': ['Internal', 'Outcome Pages'],
}
foreach build, internal_dirs : retrospective_data_dirs
retrospectivedir = pkgdatadir / 'retrospective' / build
foreach internal_dir : internal_dirs
install_subdir('retrospective/@0@/@1@'.format(build, internal_dir),
install_dir: retrospectivedir)
endforeach
endforeach

# Named Icons
# -----------
# com.inform7.IDE.png: named application icon (inform.iconset)
Expand Down
224 changes: 224 additions & 0 deletions src/app-retrospective.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2022 Philip Chimento <philip.chimento@gmail.com>
*/

#include "config.h"

#include <ctype.h>
#include <stdbool.h>

#include <gio/gio.h>

#include "app.h"
#include "app-retrospective.h"
#include "story.h"

typedef enum {
INFORM_10_1,
INFORM_9_2,
INFORM_9_1
} ArgsStyle;

static ArgsStyle
get_args_style(const char *version_id)
{
if (g_str_equal(version_id, "6L02"))
return INFORM_9_1;
if (g_str_equal(version_id, "6L38") || g_str_equal(version_id, "6M62"))
return INFORM_9_2;
return INFORM_10_1;
}

static void
retrospective_free(RetrospectiveData *self)
{
g_free(self->display_name);
g_free(self->description);
g_free(self);
}

/* Helper functions for asserting the retrospective.txt file has the correct
* format */

static bool
is_empty(const char *str)
{
return str && *str == '\0';
}

static bool
is_comma(const char *str)
{
if (!str)
return FALSE;
if (*str++ != ',')
return FALSE;
while(isspace(*str))
str++;
return *str == '\0';
}

static char *
is_present(const char *str)
{
g_assert(str);
return g_strdup(str);
}

/* Parse the retrospective.txt file and store the relevant data in a hash table
* (key: string, value: RetrospectiveData) */
void
parse_retrospective_txt(GHashTable **entries_out, char ***ids_out)
{
g_assert(entries_out);
g_assert(ids_out);

g_autoptr(GError) error = NULL;
g_autoptr(GBytes) resource = g_resources_lookup_data("/com/inform7/IDE/retrospective.txt",
G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
if (!resource) {
g_error("failed to look up retrospective data: %s", error->message);
}

GHashTable *entries = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify)retrospective_free);
/* COMPAT: Use GStrvBuilder in GLib >= 2.68 */
g_autoptr(GPtrArray) ids = g_ptr_array_new_with_free_func(g_free);

size_t len;
const char *retrospective_content = g_bytes_get_data(resource, &len);
g_auto(GStrv) lines = g_strsplit_set(retrospective_content, "\r\n", -1);
for (char **line = lines; *line != NULL; line++) {
if (**line == '\0')
continue; /* Skip blank lines */

g_auto(GStrv) parts = g_strsplit(g_strchomp(*line), "'", -1);

RetrospectiveData *record = g_new0(RetrospectiveData, 1);

/* Since the retrospective.txt file is built into Inform, we are
* draconian about any irregularities in the file format. */
g_assert(is_empty(parts[0]));
char *build_num = is_present(parts[1]);
g_assert(is_comma(parts[2]));
record->display_name = is_present(parts[3]);
g_assert(is_comma(parts[4]));
record->description = is_present(parts[5]);
g_assert(is_empty(parts[6]));

g_ptr_array_add(ids, g_strdup(build_num));
bool was_new = g_hash_table_insert(entries, build_num, record);
g_assert(was_new);
}

g_ptr_array_add(ids, NULL);
*ids_out = (char **)g_ptr_array_steal(ids, NULL);
*entries_out = entries;
}

const char *
i7_app_get_retrospective_display_name(I7App *self, const char *id)
{
const RetrospectiveData *record = get_retrospective_data(self, id);
return record->display_name;
}

const char *
i7_app_get_retrospective_description(I7App *self, const char *id)
{
const RetrospectiveData *record = get_retrospective_data(self, id);
return record->description;
}

static const char *
get_inform_format_arg(ArgsStyle style, I7StoryFormat format)
{
switch(format) {
case I7_STORY_FORMAT_Z8:
if (style == INFORM_9_1)
return "-extension=z8";
return "-format=z8";
case I7_STORY_FORMAT_GLULX:
if (style == INFORM_9_1)
return "-extension=ulx";
return "-format=ulx";
default:
;
}
g_assert_not_reached();
return "error";
}

char **
i7_app_get_inform_command_line(I7App *self, const char *version_id, int format, bool debug, bool reproducible, GFile *project_file)
{
g_autoptr(GPtrArray) builder = g_ptr_array_new_with_free_func(g_free);

ArgsStyle style = get_args_style(version_id);

g_autoptr(GFile) inform_compiler = NULL;
if (style == INFORM_10_1)
inform_compiler = i7_app_get_binary_file(self, "ni");
else
inform_compiler = i7_app_get_retrospective_binary_file(self, version_id, "ni");
char *inform_path = g_file_get_path(inform_compiler);
g_ptr_array_add(builder, inform_path);

g_autoptr(GFile) internal_dir = NULL;
if (style == INFORM_10_1)
internal_dir = i7_app_get_internal_dir(self);
else
internal_dir = i7_app_get_retrospective_internal_dir(self, version_id);
char *internal_path = g_file_get_path(internal_dir);
if (style == INFORM_9_1)
g_ptr_array_add(builder, g_strdup("-rules"));
else
g_ptr_array_add(builder, g_strdup("-internal"));
g_ptr_array_add(builder, internal_path);

g_ptr_array_add(builder, g_strdup(get_inform_format_arg(style, (I7StoryFormat)format)));

char *project_path = g_file_get_path(project_file);
if (style == INFORM_9_1)
g_ptr_array_add(builder, g_strdup("-package"));
else
g_ptr_array_add(builder, g_strdup("-project"));
g_ptr_array_add(builder, project_path);

if (!debug)
g_ptr_array_add(builder, g_strdup("-release")); /* Omit "not for relase" material */

if(reproducible)
g_ptr_array_add(builder, g_strdup("-rng"));

g_ptr_array_add(builder, NULL);
return (char **)g_ptr_array_steal(builder, NULL);
}

char **
i7_app_get_inblorb_command_line(I7App *self, const char *version_id, GFile *blorb_file)
{
g_autoptr(GPtrArray) builder = g_ptr_array_new_with_free_func(g_free);

ArgsStyle style = get_args_style(version_id);

g_autoptr(GFile) inblorb = NULL;
if (style == INFORM_10_1)
inblorb = i7_app_get_binary_file(self, "cBlorb");
else
inblorb = i7_app_get_retrospective_binary_file(self, version_id, "cBlorb");
char *inblorb_path = g_file_get_path(inblorb);
g_ptr_array_add(builder, inblorb_path);

if (style != INFORM_10_1)
g_ptr_array_add(builder, g_strdup("-unix"));

g_ptr_array_add(builder, g_strdup("Release.blurb"));

char *blorb_path = g_file_get_path(blorb_file);
g_ptr_array_add(builder, blorb_path);

g_ptr_array_add(builder, NULL);
return (char **)g_ptr_array_steal(builder, NULL);
}
19 changes: 19 additions & 0 deletions src/app-retrospective.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2022 Philip Chimento <philip.chimento@gmail.com>
*/

#pragma once

#include <glib.h>

#include "app.h"

/* Record parsed out of retrospective.txt */
typedef struct {
char *display_name;
char *description;
} RetrospectiveData;

void parse_retrospective_txt(GHashTable **entries_out, char ***ids_out);
const RetrospectiveData *get_retrospective_data(I7App *app, const char *id);
Loading

0 comments on commit 5adb720

Please sign in to comment.