[svn:parrot] r36888 - trunk/tools/dev
fperrad at svn.parrot.org
fperrad at svn.parrot.org
Thu Feb 19 21:26:26 UTC 2009
Author: fperrad
Date: Thu Feb 19 21:26:25 2009
New Revision: 36888
URL: https://trac.parrot.org/parrot/changeset/36888
Log:
[install] merge from pdd30_install branch + many improvements
Modified:
trunk/tools/dev/mk_language_shell.pl
Modified: trunk/tools/dev/mk_language_shell.pl
==============================================================================
--- trunk/tools/dev/mk_language_shell.pl Thu Feb 19 20:25:29 2009 (r36887)
+++ trunk/tools/dev/mk_language_shell.pl Thu Feb 19 21:26:25 2009 (r36888)
@@ -23,14 +23,20 @@
files and directories (relative to C<path>, which defaults
to F<languages/xyz> if an explicit C<path> isn't given):
+ MAINTAINER
README
+ STATUS
Configure.pl
xyz.pir
config/makefiles/root.in
+ doc/running.pod
+ doc/Xyz.pod
+ src/builtins/say.pir
src/parser/grammar.pg
src/parser/grammar-oper.pg
src/parser/actions.pm
- src/builtins/say.pir
+ src/pmc/Xyz.pmc
+ src/ops/Xyz.ops
t/harness
t/00-sanity.t
@@ -135,6 +141,20 @@
__README__
Language '@lang@' was created with @script@, @rev at .
+See doc/@lang at .pod for the documentation, and
+doc/running.pod for the command-line options.
+
+__MAINTAINER__
+# @Id@
+
+N: My Name
+E: My Email
+
+__STATUS__
+Number of tests passing:
+Percentage of implementation finished:
+TODO:
+
__Configure.pl__
# @Id@
@@ -161,71 +181,102 @@
## @Id@
## arguments we want to run parrot with
-PARROT_ARGS =
+PARROT_ARGS =
## configuration settings
BUILD_DIR = @build_dir@
LOAD_EXT = @load_ext@
O = @o@
+BIN_DIR = @bin_dir@
+LIB_DIR = @lib_dir@
+DOC_DIR = @doc_dir@
+MANDIR = @mandir@
+PARROT_DYNEXT = $(BUILD_DIR)/runtime/parrot/dynext
## Setup some commands
PERL = @perl@
RM_F = @rm_f@
CP = @cp@
CAT = @cat@
+MKPATH = @mkpath@
+POD2MAN = pod2man
+#IF(parrot_is_shared and not(cygwin or win32)):export LD_RUN_PATH := @blib_dir@:$(LD_RUN_PATH)
PARROT = ../../parrot at exe@
-BUILD_DYNPMC = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl
+PBC_TO_EXE = ../../pbc_to_exe at exe@
+PMCBUILD = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl
+OPSBUILD = $(PERL) $(BUILD_DIR)/tools/build/dynoplibs.pl
+RECONFIGURE = $(PERL) $(BUILD_DIR)/tools/dev/reconfigure.pl
#IF(darwin):
#IF(darwin):# MACOSX_DEPLOYMENT_TARGET must be defined for OS X compilation/linking
#IF(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@
## places to look for things
-PARROT_DYNEXT = $(BUILD_DIR)/runtime/parrot/dynext
PGE_LIBRARY = $(BUILD_DIR)/runtime/parrot/library/PGE
+PCT = $(BUILD_DIR)/runtime/parrot/library/PCT.pbc
PERL6GRAMMAR = $(PGE_LIBRARY)/Perl6Grammar.pbc
NQP = $(BUILD_DIR)/compilers/nqp/nqp.pbc
-PCT = $(BUILD_DIR)/runtime/parrot/library/PCT.pbc
PMC_DIR = src/pmc
-
-all: @lclang at .pbc
+OPS_DIR = src/ops
+OPSLIB = @lclang@
@UCLANG at _GROUP = $(PMC_DIR)/@lclang at _group$(LOAD_EXT)
+ at UCLANG@_OPS = $(OPS_DIR)/@lclang at _ops$(LOAD_EXT)
+
+build: $(@UCLANG at _GROUP) $(@UCLANG at _OPS) @lclang at .pbc
+
+all: $(@UCLANG at _GROUP) $(@UCLANG at _OPS) @lclang at .pbc @lclang@@exe@ installable
SOURCES = @lclang at .pir \
src/gen_grammar.pir \
src/gen_actions.pir \
src/gen_builtins.pir \
-# $(@UCLANG at _GROUP)
+ $(@UCLANG at _GROUP)
BUILTINS_PIR = \
- src/builtins/say.pir \
+ src/builtins/say.pir
-# PMCS = @lclang@
-# PMC_SOURCES = $(PMC_DIR)/@lclang at .pmc
+PMCS = @lang@
+PMC_SOURCES = $(PMC_DIR)/@lang at .pmc
+OPS_SOURCES = $(OPS_DIR)/@lang at .ops
+DOCS = MAINTAINER README TODO
# the default target
- at lclang@.pbc: $(PARROT) $(SOURCES)
+ at lclang@.pbc: $(SOURCES)
$(PARROT) $(PARROT_ARGS) -o @lclang at .pbc @lclang at .pir
+ at lclang@@exe@: @lclang at .pbc
+ $(PBC_TO_EXE) @lclang at .pbc
+
src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg src/parser/grammar-oper.pg
$(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
--output=src/gen_grammar.pir \
src/parser/grammar.pg \
- src/parser/grammar-oper.pg \
+ src/parser/grammar-oper.pg
src/gen_actions.pir: $(NQP) $(PCT) src/parser/actions.pm
$(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_actions.pir \
--target=pir src/parser/actions.pm
src/gen_builtins.pir: $(BUILTINS_PIR)
- $(CAT) $(BUILTINS_PIR) >src/gen_builtins.pir
+ $(CAT) $(BUILTINS_PIR) > src/gen_builtins.pir
+
+$(@UCLANG at _GROUP): $(PMC_SOURCES)
+ @cd $(PMC_DIR) && $(PMCBUILD) generate $(PMCS)
+ @cd $(PMC_DIR) && $(PMCBUILD) compile $(PMCS)
+ @cd $(PMC_DIR) && $(PMCBUILD) linklibs $(PMCS)
+ @cd $(PMC_DIR) && $(PMCBUILD) copy "--destination=$(PARROT_DYNEXT)" $(PMCS)
+
+$(@UCLANG at _OPS): $(OPS_SOURCES)
+ @cd $(OPS_DIR) && $(OPSBUILD) generate $(OPSLIB)
+ @cd $(OPS_DIR) && $(OPSBUILD) compile $(OPSLIB)
+ @cd $(OPS_DIR) && $(OPSBUILD) linklibs $(OPSLIB)
+ @cd $(OPS_DIR) && $(OPSBUILD) copy "--destination=$(PARROT_DYNEXT)" $(OPSLIB)
-$(@UCLANG at _GROUP): $(PARROT) $(PMC_SOURCES)
- cd $(PMC_DIR) && $(BUILD_DYNPMC) generate $(PMCS)
- cd $(PMC_DIR) && $(BUILD_DYNPMC) compile $(PMCS)
- cd $(PMC_DIR) && $(BUILD_DYNPMC) linklibs $(PMCS)
- cd $(PMC_DIR) && $(BUILD_DYNPMC) copy --destination=$(PARROT_DYNEXT) $(PMCS)
+installable: installable_ at lclang@@exe@
+
+installable_ at lclang@@exe@: @lclang at .pbc
+ $(PBC_TO_EXE) @lclang at .pbc --install
# regenerate the Makefile
Makefile: config/makefiles/root.in
@@ -236,10 +287,16 @@
@echo ""
@echo "Following targets are available for the user:"
@echo ""
- @echo " all: @lclang at .pbc"
+ @echo " build: @lclang at .pbc"
@echo " This is the default."
+ @echo " @lclang@@exe@ Self-hosting binary not to be installed."
+ @echo " all: @lclang at .pbc @lclang@@exe@ installable Makefile"
+ @echo " installable: Create libs and self-hosting binaries to be installed."
+ @echo " install: Install the installable targets and docs."
+ @echo ""
@echo "Testing:"
@echo " test: Run the test suite."
+ @echo " test-installable: Test self-hosting targets."
@echo " testclean: Clean up test results."
@echo ""
@echo "Cleaning:"
@@ -251,15 +308,41 @@
@echo " help: Print this help message."
@echo ""
-test: all
+test: build
$(PERL) t/harness
-# this target has nothing to do
+# TODO: rename build_dir. basic run for missing libs
+test-installable: installable
+ echo "1" | ./installable_ at lclang@@exe@
+
+install: installable
+ $(CP) installable_ at lclang@@exe@ $(DESTDIR)$(BIN_DIR)/parrot- at lclang@@exe@
+ @cd $(OPS_DIR) && $(OPSBUILD) copy "--destination=$(DESTDIR)$(LIB_DIR)/parrot/dynext" $(OPSLIB)
+ @cd $(PMC_DIR) && $(PMCBUILD) copy "--destination=$(DESTDIR)$(LIB_DIR)/parrot/dynext" $(PMCS)
+ -$(MKPATH) $(LIB_DIR)/parrot/languages/@lclang@
+ $(CP) @lclang at .pbc $(DESTDIR)$(LIB_DIR)/parrot/languages/@lclang@/@lclang at .pbc
+ -$(MKPATH) $(DESTDIR)$(MANDIR)/man1
+ $(POD2MAN) doc/running.pod > $(DESTDIR)$(MANDIR)/man1/parrot- at lclang@.1
+ -$(MKPATH) $(DESTDIR)$(DOC_DIR)/languages/@lclang@
+ $(CP) $(DOCS) $(DESTDIR)$(DOC_DIR)/languages/@lclang@
+
+win32-inno-installer: installable
+ -$(MKPATH) man/man1
+ $(POD2MAN) doc/running.pod > man/man1/parrot- at lclang@.1
+ -$(MKPATH) man/html
+ pod2html --infile doc/running.pod --outfile man/html/parrot- at lclang@.html
+ $(CP) installable_ at lclang@@exe@ parrot- at lclang@@exe@
+ cd @build_dir@ && $(PERL) tools/dev/mk_inno_language.pl @lclang@
+ cd @build_dir@ && iscc parrot- at lclang@.iss
+
+# clean intermediate test files
testclean:
CLEANUPS = \
@lclang at .pbc \
- "src/gen_*.pir"
+ "src/gen_*.pir" \
+ @lclang@@exe@ \
+ installable_ at lclang@@exe@
PMC_CLEANUPS = \
"$(PMC_DIR)/*.h" \
@@ -273,10 +356,16 @@
#IF(win32): "$(PMC_DIR)/*.lib" \
"$(PMC_DIR)/*$(LOAD_EXT)"
+OPS_CLEANUPS = \
+ "$(OPS_DIR)/*.c" \
+ "$(OPS_DIR)/*.h" \
+ "$(OPS_DIR)/*$(O)" \
+ "$(OPS_DIR)/*$(LOAD_EXT)"
clean: testclean
$(RM_F) $(CLEANUPS)
-# $(RM_F) $(PMC_CLEANUPS)
+ $(RM_F) $(PMC_CLEANUPS)
+ $(RM_F) $(OPS_CLEANUPS)
realclean: clean
$(RM_F) Makefile
@@ -288,6 +377,47 @@
# End:
# vim: ft=make:
+__doc/@lang at .pod__
+# @Id@
+
+=head1 @lang@
+
+=head1 Design
+
+=head1 SEE ALSO
+
+=cut
+
+# Local Variables:
+# fill-column:78
+# End:
+# vim: expandtab shiftwidth=4:
+__doc/running.pod__
+# @Id@
+
+=head1 Running
+
+This document describes how to use the command line @lclang@ program, which
+...
+
+=head2 Usage
+
+ parrot @lclang at .pbc [OPTIONS] <input>
+
+or
+
+ parrot- at lclang@@exe [OPTIONS] <input>
+
+A number of additional options are available:
+
+ -q Quiet mode; suppress output of summary at the end.
+
+=cut
+
+# Local Variables:
+# fill-column:78
+# End:
+# vim: expandtab shiftwidth=4:
__ at lclang@.pir__
=head1 TITLE
@@ -312,32 +442,18 @@
=cut
-.HLL '@lclang@'
-
-.namespace [ '@lang@';'Compiler' ]
+.namespace [ '@lang@::Compiler' ]
.loadlib '@lclang at _group'
-.sub '' :anon :load :init
+.sub 'onload' :anon :load :init
load_bytecode 'PCT.pbc'
- .local pmc parrotns, hllns, exports
- parrotns = get_root_namespace ['parrot']
- hllns = get_hll_namespace
- exports = split ' ', 'PAST PCT PGE'
- parrotns.'export_to'(hllns, exports)
-.end
-.include 'src/gen_grammar.pir'
-.include 'src/gen_actions.pir'
-
-.sub 'onload' :anon :load :init
$P0 = get_hll_global ['PCT'], 'HLLCompiler'
$P1 = $P0.'new'()
- $P1.'language'('@lclang@')
- $P0 = get_hll_namespace ['@lang@';'Grammar']
- $P1.'parsegrammar'($P0)
- $P0 = get_hll_namespace ['@lang@';'Grammar';'Actions']
- $P1.'parseactions'($P0)
+ $P1.'language'('@lang@')
+ $P1.'parsegrammar'('@lang@::Grammar')
+ $P1.'parseactions'('@lang@::Grammar::Actions')
.end
=item main(args :slurpy) :main
@@ -350,11 +466,13 @@
.sub 'main' :main
.param pmc args
- $P0 = compreg '@lclang@'
+ $P0 = compreg '@lang@'
$P1 = $P0.'command_line'(args)
.end
.include 'src/gen_builtins.pir'
+.include 'src/gen_grammar.pir'
+.include 'src/gen_actions.pir'
=back
@@ -448,7 +566,7 @@
class @lang@::Grammar::Actions;
method TOP($/) {
- my $past := PAST::Block.new( :blocktype('declaration'), :node( $/ ), :hll('@lclang@') );
+ my $past := PAST::Block.new( :blocktype('declaration'), :node( $/ ) );
for $<statement> {
$past.push( $( $_ ) );
}
@@ -523,6 +641,221 @@
# End:
# vim: expandtab shiftwidth=4:
+__src/pmc/@lang at .pmc__
+/*
+Copyright (C) 20xx, Parrot Foundation.
+ at Id@
+
+=head1 NAME
+
+src/pmc/@lang at .pmc - @lang@
+
+=head1 DESCRIPTION
+
+These are the vtable functions for the @lang@ class.
+
+=cut
+
+=head2 Helper functions
+
+=over 4
+
+=item INTVAL size(INTERP, PMC, PMC)
+
+*/
+
+#include "parrot/parrot.h"
+
+static INTVAL
+size(Interp *interp, PMC* self, PMC* obj)
+{
+ INTVAL retval;
+ INTVAL dimension;
+ INTVAL length;
+ INTVAL pos;
+
+ if (!obj || PMC_IS_NULL(obj)) {
+ /* not set, so a simple 1D */
+ return VTABLE_get_integer(interp, self);
+ }
+
+ retval = 1;
+ dimension = VTABLE_get_integer(interp, obj);
+ for (pos = 0; pos < dimension; pos++)
+ {
+ length = VTABLE_get_integer_keyed_int(interp, obj, pos);
+ retval *= length;
+ }
+ return retval;
+}
+
+/*
+
+=back
+
+=head2 Methods
+
+=over 4
+
+=cut
+
+*/
+
+pmclass @lang@
+ extends ResizablePMCArray
+ provides array
+ group @lclang at _group
+
+ need_ext
+ dynpmc
+ {
+/*
+
+=item C<void class_init()>
+
+initialize the pmc class. Store some constants, etc.
+
+=cut
+
+*/
+
+ /* RT#48194: move any constant string declarations here so we just do them once. */
+ void class_init() {
+ }
+
+
+/*
+
+=item C<PMC* init()>
+
+initialize the instance.
+
+=cut
+
+*/
+
+void init() {
+ SUPER();
+};
+
+=item C<PMC* get()>
+
+Returns a vector-like PMC.
+
+=cut
+
+*/
+
+ METHOD PMC* get() {
+ PMC* property;
+ INTVAL array_t;
+ STRING* property_name;
+
+ property_name = string_from_literal(INTERP, "property");
+ shape = VTABLE_getprop(INTERP, SELF, property_name);
+ if (PMC_IS_NULL(property)) {
+ /*
+ * No property has been set yet. This means that we are
+ * a simple vector
+ *
+ * we use our own type here. Perhaps a better way to
+ * specify it?
+ */
+ /*
+ array_t = pmc_type(INTERP,
+ string_from_literal(INTERP, "@lang@"));
+ */
+ property = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+
+ VTABLE_set_integer_native(INTERP, property, 1);
+ VTABLE_set_integer_keyed_int(INTERP, property, 0,
+ VTABLE_get_integer(INTERP, SELF));
+ VTABLE_setprop(INTERP, SELF, property_name, property);
+ }
+ RETURN(PMC* property);
+ }
+
+/*
+
+=item C<PMC* set()>
+
+Change the existing @lang@ by passing in an existing vector.
+
+If the new property is larger than our old property, pad the end of the APLv
+with elements from the beginning.
+
+If the new property is shorter than our old property, truncate elements from
+the end of the APLv.
+
+=cut
+
+*/
+
+ METHOD set(PMC *new_property) {
+ STRING* property_name;
+ PMC* old_property;
+ INTVAL old_size, new_size, pos;
+
+ /* save the old property momentarily, set the new property */
+ property_name = string_from_literal(INTERP, "property");
+ old_property = VTABLE_getprop(INTERP, SELF, property_name);
+ VTABLE_setprop(INTERP, SELF, property_name, new_property);
+
+ /* how big are these property? */
+ old_size = size(INTERP, SELF, old_property);
+ new_size = size(INTERP, SELF, new_property);
+
+ if (old_size > new_size) {
+ for (; new_size != old_size; new_size++) {
+ VTABLE_pop_pmc(INTERP, SELF);
+ }
+ } else if (new_size > old_size) {
+ pos = 0;
+ for (; new_size != old_size; old_size++, pos++) {
+ /* RT#48196 clone this? */
+ VTABLE_push_pmc(INTERP, SELF,
+ VTABLE_get_pmc_keyed_int(INTERP, SELF, pos));
+ }
+ }
+ }
+
+/*
+
+=back
+
+=cut
+
+*/
+
+}
+
+/*
+ * Local variables:
+ * c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
+__src/ops/@lang at .ops__
+/*
+ * @id@
+ * Copyright (C) 20xx, Parrot Foundation.
+ */
+
+#include "parrot/dynext.h"
+VERSION = PARROT_VERSION;
+
+/* Op to get the address of a PMC. */
+inline op @lclang at _pmc_addr(out INT, invar PMC) :base_core {
+ $1 = (int) $2;
+ goto NEXT();
+}
+
+/*
+ * Local variables:
+ * c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
__src/builtins/say.pir__
# @Id@
@@ -576,7 +909,6 @@
say 'ok ', 2;
say 'ok ', 2 + 1;
say 'ok', ' ', 4;
-
__DATA__
More information about the parrot-commits
mailing list