Initial snapshot
This commit is contained in:
commit
fee4dd4e6d
373 changed files with 62144 additions and 0 deletions
113
environment/profile/host/darwin/darwin.conf
Normal file
113
environment/profile/host/darwin/darwin.conf
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kane...ironment/profile/host/darwin/darwin.conf
|
||||
#
|
||||
# created julien quintard [tue may 8 13:19:52 2007]
|
||||
# updated julien quintard [fri may 1 02:11:38 2009]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file contains the libraries, binaries, script and tools related to
|
||||
# the generic darwin host sub-profile.
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- includes ---------------------------------------------------------
|
||||
#
|
||||
|
||||
_INCLUDES_ = -I${_INCLUDE_DIR_}
|
||||
|
||||
#
|
||||
# ---------- flags ------------------------------------------------------------
|
||||
#
|
||||
|
||||
_CC_FLAGS_ = -D___kaneton \
|
||||
${_INCLUDES_} \
|
||||
${_KANETON_FLAGS_} \
|
||||
-fno-builtin \
|
||||
-Wimplicit \
|
||||
-Wparentheses \
|
||||
-Wreturn-type \
|
||||
-Wswitch -Wswitch-enum \
|
||||
-Wunused-function \
|
||||
-Wunused-variable \
|
||||
-Wmissing-prototypes \
|
||||
-Wmissing-declarations \
|
||||
-Wall
|
||||
|
||||
_LD_FLAGS_ = ${_INCLUDES_}
|
||||
|
||||
_AS_FLAGS_ =
|
||||
|
||||
_CPP_FLAGS_ =
|
||||
|
||||
_SHELL_FLAGS_ =
|
||||
|
||||
_PYTHON_FLAGS_ =
|
||||
|
||||
_PERL_FLAGS_ =
|
||||
|
||||
_MAKE_FLAGS_ =
|
||||
|
||||
#
|
||||
# ---------- binaries ---------------------------------------------------------
|
||||
#
|
||||
|
||||
_BINARIES_ = ${_SHELL_}, ${_CC_}, ${_MAKE_}, \
|
||||
${_RM_}, ${_AR_}, ${_RANLIB_}, \
|
||||
${_LD_}, ${_AS_}, ${_BIBTEX_},\
|
||||
${_LN_}, ${_TOUCH_}, ${_WC_}, \
|
||||
${_DATE_}, ${_TAIL_}, ${_TAR_}, \
|
||||
${_PDFLATEX_}, ${_CP_}, \
|
||||
${_CAT_}, ${_SED_}, ${_CPP_}, \
|
||||
${_MTOOLS_}, ${_MCOPY_}, \
|
||||
${_XPDF_}, ${_MKTEMP_}, ${_MV_},\
|
||||
${_LEX_}, ${_SCRIPT_}, \
|
||||
${_PERL_}, ${_PYTHON_}, \
|
||||
${_DIRNAME_}, ${_BASENAME_}, \
|
||||
${_WHICH_}
|
||||
|
||||
_SHELL_ = bash
|
||||
_CC_ = i386-elf-gcc-3.4.6
|
||||
_AS_ = i386-elf-as
|
||||
_MAKE_ = gmake
|
||||
_RM_ = rm -f
|
||||
_PURGE_ = ${_RM_} *.pyc *~ .*~ \#* .\#*
|
||||
_AR_ = i386-elf-ar cq
|
||||
_RANLIB_ = i386-elf-ranlib
|
||||
_CD_ = cd
|
||||
_LD_ = i386-elf-ld
|
||||
_LN_ = ln -s -f
|
||||
_TOUCH_ = touch
|
||||
_WC_ = wc
|
||||
_DATE_ = date -u
|
||||
_TAIL_ = tail
|
||||
_TAR_ = tar
|
||||
_PDFLATEX_ = pdflatex
|
||||
_BIBTEX_ = bibtex
|
||||
_CP_ = cp
|
||||
_CAT_ = cat
|
||||
_SED_ = sed -r
|
||||
_ECHO_ = /bin/echo
|
||||
_CPP_ = i386-elf-cpp-3.4.6
|
||||
_MTOOLS_ = mtools
|
||||
_MCOPY_ = mcopy
|
||||
_XPDF_ = open
|
||||
_MKTEMP_ = mktemp
|
||||
_MV_ = mv
|
||||
_PWD_ = pwd
|
||||
_LEX_ = lex -t
|
||||
_SCRIPT_ = script
|
||||
_PERL_ = perl
|
||||
_PYTHON_ = python2.5
|
||||
_DIRNAME_ = dirname
|
||||
_BASENAME_ = basename
|
||||
_WHICH_ = which
|
||||
_EXIT_ = exit
|
||||
33
environment/profile/host/darwin/darwin.desc
Normal file
33
environment/profile/host/darwin/darwin.desc
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/fanfwe/kane...nvironment/profile/host/darwin/darwin.desc
|
||||
#
|
||||
# created julien quintard [tue may 8 13:20:04 2007]
|
||||
# updated francois goudal [mon aug 4 15:54:31 2008]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file describes the darwin environment variables.
|
||||
#
|
||||
|
||||
- variable: _SHELL_
|
||||
string: Shell
|
||||
type: any
|
||||
description: The shell binary path
|
||||
|
||||
- variable: _CC_
|
||||
string: C Compiler
|
||||
type: any
|
||||
description: The C compiler binary path
|
||||
|
||||
- variable: _MAKE_
|
||||
string: Make
|
||||
type: any
|
||||
description: The make binary path
|
||||
493
environment/profile/host/darwin/darwin.mk
Normal file
493
environment/profile/host/darwin/darwin.mk
Normal file
|
|
@ -0,0 +1,493 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kane...nvironment/profile/host/darwin/darwin.mk
|
||||
#
|
||||
# created julien quintard [tue may 8 13:03:34 2007]
|
||||
# updated julien quintard [fri aug 29 20:03:17 2008]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file implements the remaining functions of the kaneton make interface.
|
||||
#
|
||||
# indeed the major generic part of the interface is already provided by the
|
||||
# host profile.
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- python path ------------------------------------------------------
|
||||
#
|
||||
|
||||
export PYTHONPATH=$(shell $(_ECHO_) $${PYTHONPATH}):$(_PYTHON_INCLUDE_DIR_)
|
||||
|
||||
#
|
||||
# ---------- functions --------------------------------------------------------
|
||||
#
|
||||
|
||||
#
|
||||
# colorize functions
|
||||
#
|
||||
# 1: text
|
||||
# 2: options
|
||||
#
|
||||
|
||||
define env_colorize-black
|
||||
"[30;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-red
|
||||
"[31;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-green
|
||||
"[32;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-yellow
|
||||
"[33;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-blue
|
||||
"[34;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-magenta
|
||||
"[35;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-cyan
|
||||
"[36;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-white
|
||||
"[37;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-
|
||||
"$(1)"
|
||||
endef
|
||||
|
||||
#
|
||||
# perform function
|
||||
#
|
||||
# 1: command
|
||||
#
|
||||
|
||||
ifeq ($(_OUTPUT_),$(_OUTPUT_VERBOSE_)) # if the user wants to display
|
||||
# additional debug information
|
||||
|
||||
define env_perform
|
||||
$(_ECHO_) " $(1)" && \
|
||||
$(1)
|
||||
endef
|
||||
|
||||
else
|
||||
|
||||
define env_perform
|
||||
$(1)
|
||||
endef
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
# print functions wrapper
|
||||
#
|
||||
# 1: text
|
||||
# 2: color
|
||||
# 3: options
|
||||
#
|
||||
|
||||
ifeq ($(_DISPLAY_),$(_DISPLAY_COLORED_)) # if the user wants to display
|
||||
# the text with color
|
||||
|
||||
define env_print
|
||||
print_options="" && \
|
||||
if [ -n "$(3)" ] ; then \
|
||||
if [ $$(( $(3) & $(ENV_OPTION_NO_NEWLINE) )) -ne 0 ] ; then \
|
||||
print_options="$${print_options} -n" ; \
|
||||
fi ; \
|
||||
fi && \
|
||||
$(_ECHO_) $${print_options} $(call env_colorize-$(2),$(1),)
|
||||
endef
|
||||
|
||||
else # if not ...
|
||||
|
||||
define env_print
|
||||
print_options="" && \
|
||||
if [ -n "$(3)" ] ; then \
|
||||
if [ $$(( $(3) & $(ENV_OPTION_NO_NEWLINE) )) -ne 0 ] ; then \
|
||||
print_options="$${print_options} -n" ; \
|
||||
fi ; \
|
||||
fi && \
|
||||
$(_ECHO_) $${print_options} $(1)
|
||||
endef
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
# change the current working directory
|
||||
#
|
||||
# $(1): directory
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_cd
|
||||
cd_options="" && \
|
||||
$(call env_perform, \
|
||||
$(_CD_) $${cd_options} $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# returns a file contents
|
||||
#
|
||||
# $(1): the file
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_pull
|
||||
$(_CAT_) $(2) $(1)
|
||||
endef
|
||||
|
||||
#
|
||||
# launch a new program/script/make etc.
|
||||
#
|
||||
# $(1): file
|
||||
# $(2): arguments
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_launch
|
||||
launch_options="" && \
|
||||
cwd=$$($(_PWD_)) && \
|
||||
directory=$$($(_DIRNAME_) $(1)) && \
|
||||
file=$$($(_BASENAME_) $(1)) && \
|
||||
if [ "$${directory}" != "." ] ; then \
|
||||
$(call env_perform, \
|
||||
$(_CD_) $${directory}) ; \
|
||||
fi && \
|
||||
case "$${file}" in \
|
||||
*.sh) \
|
||||
$(call env_perform, \
|
||||
$(_SHELL_) $${launch_options} $${file} $(_SHELL_FLAGS_) $(2)) ; \
|
||||
;; \
|
||||
*.py) \
|
||||
$(call env_perform, \
|
||||
$(_PYTHON_) $${launch_options} $${file} $(_PYTHON_FLAGS_) $(2)) ; \
|
||||
;; \
|
||||
*.pl) \
|
||||
$(call env_perform, \
|
||||
$(_PERL_) $${launch_options} $${file} $(_PERL_FLAGS_) $(2)) ; \
|
||||
;; \
|
||||
Makefile) \
|
||||
$(call env_perform, \
|
||||
$(_MAKE_) $${launch_options} -f $${file} $(_MAKE_FLAGS_) ${2}) ; \
|
||||
;; \
|
||||
esac ; \
|
||||
return=$${?} && \
|
||||
if [ "$${directory}" != "." ] ; then \
|
||||
$(call env_perform, \
|
||||
$(_CD_) $${cwd}) ; \
|
||||
fi && \
|
||||
if [ $${return} -ne 0 ] ; then \
|
||||
$(_EXIT_) 42 ; \
|
||||
fi
|
||||
endef
|
||||
|
||||
#
|
||||
# from c file to preprocessed c file
|
||||
#
|
||||
# $(1): preprocessed file
|
||||
# $(2): c file
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_preprocess
|
||||
preprocess_options="" && \
|
||||
$(call env_display,green,PREPROCESS,$(2), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_CPP_) -P $(_CPP_FLAGS_) $${preprocess_options} $(2) -o $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# from c file to object file
|
||||
#
|
||||
# $(1): object file
|
||||
# $(2): c file
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_compile-c
|
||||
compile_c_options="" && \
|
||||
$(call env_display,green,COMPILE-C,$(2), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_CC_) $(_CC_FLAGS_) $${compile_c_options} -c $(2) -o $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# from lex file to c file
|
||||
#
|
||||
# $(1): c file
|
||||
# $(2): lex file
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_lex-l
|
||||
lex_l_options="" && \
|
||||
$(call env_display,green,LEX-L,$(2), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_LEX_) $${lex_l_options} $(2) > $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# from S file to object file
|
||||
#
|
||||
# $(1): object file
|
||||
# $(2): S file
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_assemble-S
|
||||
assemble_S_options="" && \
|
||||
$(call env_display,green,ASSEMBLE-S,$(2), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_CPP_) $(2) | $(_AS_) $(_AS_FLAGS_) $${assemble_S_options} -o $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# create a static library from object files
|
||||
#
|
||||
# $(1): static library file name
|
||||
# $(2): object files
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_static-library
|
||||
static_library_options="" && \
|
||||
$(call env_display,magenta,STATIC-LIBRARY,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_AR_) $${static_library_options} $(1) $(2)) && \
|
||||
$(call env_perform, \
|
||||
$(_RANLIB_) $${static_library_options} $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# create a dynamic library from object files, static libraries
|
||||
# and/or dynamic libraries
|
||||
#
|
||||
# $(1): dynamic library file name
|
||||
# $(2): objects files and/or libraries
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_dynamic-library
|
||||
dynamic_library_options="" && \
|
||||
$(call env_display,magenta,DYNAMIC-LIBRARY,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_LD_) --shared $(_LD_FLAGS_) $${dynamic_library_options} \
|
||||
-o $(1) $(2))
|
||||
endef
|
||||
|
||||
#
|
||||
# create an executable file from object file and/or library files
|
||||
#
|
||||
# $(1): executable file name
|
||||
# $(2): objects files and/or libraries
|
||||
# $(3): layout file
|
||||
# $(4): options
|
||||
#
|
||||
|
||||
define env_executable
|
||||
executable_options="" && \
|
||||
if [ -n "$(3)" ] ; then \
|
||||
executable_options="$${executable_options} -T $(3)" ; \
|
||||
fi && \
|
||||
if [ -n "$(4)" ] ; then \
|
||||
if [ $$(( $(4) & $(ENV_OPTION_NO_STANDARD) )) -ne 0 ] ; then \
|
||||
executable_options="$${executable_options} -nostdinc -nostdlib" ; \
|
||||
fi ; \
|
||||
fi && \
|
||||
$(call env_display,magenta,EXECUTABLE,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_CC_) $(_CC_FLAGS_) $(_LD_FLAGS_) $${executable_options} -o $(1) \
|
||||
$(2) "`$(_CC_) -print-libgcc-file-name`")
|
||||
endef
|
||||
|
||||
#
|
||||
# create an archive file from multiple object files
|
||||
#
|
||||
# note that the archive file is also an object file
|
||||
#
|
||||
# $(1): archive file name
|
||||
# $(2): objects files and/or libraries
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_archive
|
||||
archive_options="" && \
|
||||
$(call env_display,magenta,ARCHIVE,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_LD_) -r $(_LD_FLAGS_) $${archive_options} -o $(1) $(2))
|
||||
endef
|
||||
|
||||
#
|
||||
# remove the files
|
||||
#
|
||||
# $(1): files
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_remove
|
||||
remove_options="" && \
|
||||
for f in $(1) ; do \
|
||||
if [ -e $${f} ] ; then \
|
||||
$(call env_display,red,REMOVE,$${f}, ,) ; \
|
||||
fi && \
|
||||
$(call env_perform, \
|
||||
$(_RM_) $${remove_options} $${f}) ; \
|
||||
done
|
||||
endef
|
||||
|
||||
#
|
||||
# purge i.e clean the directory from unwanted files
|
||||
#
|
||||
|
||||
define env_purge
|
||||
$(call env_display,red,PURGE,,,) && \
|
||||
$(call env_perform, \
|
||||
$(_PURGE_))
|
||||
endef
|
||||
|
||||
#
|
||||
# generate prototypes from a source file
|
||||
#
|
||||
# $(1): file list
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_prototypes
|
||||
prototypes_options="" && \
|
||||
for f in $(1) ; do \
|
||||
if [ -e $${f} ] ; then \
|
||||
$(call env_display,yellow,PROTOTYPES,$${f}, ,) && \
|
||||
$(call env_launch,$(_MKP_TOOL_), \
|
||||
$${prototypes_options} $${f},) ; \
|
||||
fi ; \
|
||||
done
|
||||
endef
|
||||
|
||||
#
|
||||
# genereate header dependencies
|
||||
#
|
||||
# $(1): the files for which the dependencies are generated
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_headers
|
||||
headers_options="" && \
|
||||
for f in $(1) ; do \
|
||||
if [ -e $${f} ] ; then \
|
||||
$(call env_display,yellow,HEADERS,$$f, ,) && \
|
||||
$(call env_perform, \
|
||||
$(_CC_) $(_CC_FLAGS_) -M -MG $${headers_options} \
|
||||
$${f} >> $(_DEPENDENCY_MK_)) ; \
|
||||
fi ; \
|
||||
done
|
||||
endef
|
||||
|
||||
#
|
||||
# generate a version file
|
||||
#
|
||||
# $(1): the version file to generate
|
||||
#
|
||||
|
||||
define env_version
|
||||
$(call env_display,yellow,VERSION,$(1), ,) && \
|
||||
$(_ECHO_) -n "" > $(1) && \
|
||||
$(_ECHO_) -n "const char version[] = \"$(_TITLE_)-$(_VERSION_)" >> $(1) && \
|
||||
$(_ECHO_) " "$(shell LANG=C $(_DATE_))" $(USER)@$(HOSTNAME)\";" >> $(1)
|
||||
endef
|
||||
|
||||
#
|
||||
# create a link between two files
|
||||
#
|
||||
# $(1): link created
|
||||
# $(2): destination
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_link
|
||||
link_options="" && \
|
||||
$(call env_display,cyan,LINK,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_LN_) $${link_options} $(2) $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# compile a tex document
|
||||
#
|
||||
# $(1): the file name without extension
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_compile-tex
|
||||
compile_tex_options="" && \
|
||||
$(call env_display,green,COMPILE-TEX,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_PDFLATEX_) $${compile_tex_options} $(1).tex) && \
|
||||
$(call env_perform, \
|
||||
$(_BIBTEX_) $(1).tex) && \
|
||||
$(call env_perform, \
|
||||
$(_PDFLATEX_) $${compile_tex_options} $(1).tex) ; \
|
||||
$(call env_perform, \
|
||||
$(_PDFLATEX_) $${compile_tex_options} $(1).tex)
|
||||
endef
|
||||
|
||||
#
|
||||
# build a document
|
||||
#
|
||||
# $(1): the file name without extension
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_document
|
||||
if [ -n "$(2)" ] ; then \
|
||||
if [ $$(( $(2) & $(ENV_OPTION_PRIVATE) )) -ne 0 ] ; then \
|
||||
$(_ECHO_) '\def\mode{private}' > $(_DEPENDENCY_TEX_) ; \
|
||||
fi ; \
|
||||
fi && \
|
||||
if [ ! -f $(_DEPENDENCY_TEX_) ] ; then \
|
||||
$(_ECHO_) '\def\mode{public}' > $(_DEPENDENCY_TEX_) ; \
|
||||
fi && \
|
||||
$(call env_compile-tex,$(1),$(2))
|
||||
endef
|
||||
|
||||
#
|
||||
# launch a document viewer
|
||||
#
|
||||
# $(1): the file name without extension
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_view
|
||||
$(call env_display,yellow,VIEW,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_XPDF_) $(1).pdf)
|
||||
endef
|
||||
|
||||
#
|
||||
# ---------- component-based behaviour ----------------------------------------
|
||||
#
|
||||
|
||||
#
|
||||
# meta definitions
|
||||
#
|
||||
|
||||
ifneq ($(call findstring,kaneton,$(components)),)
|
||||
_CC_FLAGS_ += -D___kaneton$$\kernel
|
||||
endif
|
||||
226
environment/profile/host/darwin/darwin.py
Normal file
226
environment/profile/host/darwin/darwin.py
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kane...nvironment/profile/host/darwin/darwin.py
|
||||
#
|
||||
# created julien quintard [tue may 8 13:20:21 2007]
|
||||
# updated julien quintard [tue may 5 12:10:33 2009]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file implements the remaining functions of the kaneton python interface.
|
||||
#
|
||||
# note that the host profile already provides many functions. these
|
||||
# functions can be overriden but you will probably just use them.
|
||||
#
|
||||
# in addition, the host profile already imports some packages.
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- python path ------------------------------------------------------
|
||||
#
|
||||
|
||||
pythonpath = os.getenv("PYTHONPATH")
|
||||
if not pythonpath:
|
||||
pythonpath = ""
|
||||
|
||||
os.putenv("PYTHONPATH", pythonpath + ":" + _PYTHON_INCLUDE_DIR_)
|
||||
|
||||
#
|
||||
# ---------- functions --------------------------------------------------------
|
||||
#
|
||||
|
||||
#
|
||||
# colorize()
|
||||
#
|
||||
# this function returns a colorized text if the environment is configured
|
||||
# to or simply the original text.
|
||||
#
|
||||
# note that this function implementation is based on UNIX escape sequences.
|
||||
#
|
||||
def colorize(text, color, options):
|
||||
if _DISPLAY_ == _DISPLAY_UNCOLORED_:
|
||||
return text
|
||||
|
||||
if options & OPTION_FLICKERING:
|
||||
text = "[05m" + text
|
||||
if options & OPTION_BOLD:
|
||||
text = "[01m" + text
|
||||
|
||||
if color == COLOR_BLACK:
|
||||
text = "[30m" + text
|
||||
elif color == COLOR_RED:
|
||||
text = "[31m" + text
|
||||
elif color == COLOR_GREEN:
|
||||
text = "[32m" + text
|
||||
elif color == COLOR_YELLOW:
|
||||
text = "[33m" + text
|
||||
elif color == COLOR_BLUE:
|
||||
text = "[34m" + text
|
||||
elif color == COLOR_MAGENTA:
|
||||
text = "[35m" + text
|
||||
elif color == COLOR_CYAN:
|
||||
text = "[36m" + text
|
||||
elif color == COLOR_WHITE:
|
||||
text = "[37m" + text
|
||||
|
||||
return text + "[39;49;00m"
|
||||
|
||||
|
||||
|
||||
#
|
||||
# launch()
|
||||
#
|
||||
# this function launch a new program/script/make etc.
|
||||
#
|
||||
def launch(file, arguments, options):
|
||||
directory = None
|
||||
info = None
|
||||
status = 0
|
||||
wd = None
|
||||
|
||||
if options & OPTION_QUIET:
|
||||
output = " >/dev/null 2>&1"
|
||||
else:
|
||||
output = ""
|
||||
|
||||
info = os.path.split(file)
|
||||
|
||||
directory = info[0]
|
||||
file = info[1]
|
||||
|
||||
if directory:
|
||||
wd = cwd(OPTION_NONE)
|
||||
cd(directory, OPTION_NONE)
|
||||
|
||||
if re.match("^.*\.sh$", file):
|
||||
status = os.system(_SHELL_ + " " + file + " " + arguments + output)
|
||||
elif re.match("^.*\.py$", file):
|
||||
status = os.system(_PYTHON_ + " " + file + " " + arguments + output)
|
||||
elif re.match("^.*\.pl$", file):
|
||||
status = os.system(_PERL_ + " " + file + " " + arguments + output)
|
||||
elif re.match("^Makefile$", file):
|
||||
status = os.system(_MAKE_ + " -f " + file + " " + arguments + output)
|
||||
else:
|
||||
status = os.system(file + " " + arguments + output)
|
||||
|
||||
if directory:
|
||||
cd(wd, OPTION_NONE)
|
||||
|
||||
return status
|
||||
|
||||
|
||||
|
||||
#
|
||||
# pack()
|
||||
#
|
||||
# this function creates an archive of the given directory.
|
||||
#
|
||||
def pack(directory, file, options):
|
||||
launch(_TAR_, "-cjf " + file + " " + directory, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# unpack()
|
||||
#
|
||||
# this function unpackages an archive into the given (optional) directory.
|
||||
#
|
||||
def unpack(file, directory, options):
|
||||
if directory:
|
||||
launch(_TAR_, "-xjf " + file + " -C " + directory, OPTION_NONE)
|
||||
else:
|
||||
launch(_TAR_, "-xjf " + file, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# load()
|
||||
#
|
||||
# this function copies a file on a device, this device can be virtual:
|
||||
# an image.
|
||||
#
|
||||
def load(file, device, path, options):
|
||||
if options == OPTION_DEVICE:
|
||||
launch(_MCOPY_, "-o -n " + file + " " + device + path, OPTION_NONE)
|
||||
|
||||
if options == OPTION_IMAGE:
|
||||
launch(_MCOPY_, "-o -n " + "-i" + device + " " +
|
||||
file + " ::" + path, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# record()
|
||||
#
|
||||
# this function runs the program recording a session.
|
||||
#
|
||||
def record(transcript, options):
|
||||
directory = None
|
||||
time = None
|
||||
log = None
|
||||
tmp = None
|
||||
wd = None
|
||||
|
||||
tmp = temporary(OPTION_DIRECTORY)
|
||||
|
||||
directory = tmp + "/" + "transcript"
|
||||
|
||||
log = directory + "/" + "log"
|
||||
time = directory + "/" + "time"
|
||||
|
||||
mkdir(directory, OPTION_NONE)
|
||||
|
||||
launch(_SCRIPT_, "-q -t " + log + " -c " +
|
||||
_TRANSCRIPT_CMD_ + " 2> " + time, OPTION_NONE)
|
||||
|
||||
wd = cwd(OPTION_NONE)
|
||||
|
||||
cd(tmp, OPTION_NONE)
|
||||
|
||||
pack("transcript", wd + "/" + transcript, OPTION_NONE)
|
||||
|
||||
cd(wd, OPTION_NONE)
|
||||
|
||||
remove(tmp, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# play()
|
||||
#
|
||||
# this function runs the program replaying a session.
|
||||
#
|
||||
def play(transcript, options):
|
||||
directory = None
|
||||
time = None
|
||||
log = None
|
||||
tmp = None
|
||||
wd = None
|
||||
|
||||
tmp = temporary(OPTION_DIRECTORY)
|
||||
|
||||
log = tmp + "/" + "transcript/log"
|
||||
time = tmp + "/" + "transcript/time"
|
||||
|
||||
unpack(transcript, tmp, OPTION_NONE)
|
||||
|
||||
launch(_SCRIPTREPLAY_TOOL_, time + " " + log, OPTION_NONE)
|
||||
|
||||
remove(tmp, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# locate()
|
||||
#
|
||||
# this function tries to locate a program on the system.
|
||||
#
|
||||
def locate(file, options):
|
||||
return launch(_WHICH_, file + " 1>/dev/null 2>/dev/null", OPTION_NONE)
|
||||
1
environment/profile/host/darwin/ia32.ia32/educational
Symbolic link
1
environment/profile/host/darwin/ia32.ia32/educational
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
.
|
||||
33
environment/profile/host/darwin/ia32.ia32/ia32.conf
Normal file
33
environment/profile/host/darwin/ia32.ia32/ia32.conf
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/fanfwe/kane...t/profile/host/darwin/ia32.ia32/ia32.conf
|
||||
#
|
||||
# created julien quintard [thu jun 28 21:15:33 2007]
|
||||
# updated francois goudal [mon aug 4 15:57:00 2008]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file contains definitions specific to the ia32 target microprocessor
|
||||
# architecture.
|
||||
#
|
||||
|
||||
#
|
||||
# include the darwin generic definitions
|
||||
#
|
||||
|
||||
include ../darwin.conf
|
||||
|
||||
#
|
||||
# microprocessor specific definitions
|
||||
#
|
||||
|
||||
_CC_FLAGS_ += -D___kaneton$$\endian=0 \
|
||||
-D___kaneton$$\wordsz=32 \
|
||||
-D___kaneton$$\pagesz=4096
|
||||
1
environment/profile/host/darwin/ia32.ia32/ia32.desc
Symbolic link
1
environment/profile/host/darwin/ia32.ia32/ia32.desc
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../darwin.desc
|
||||
1
environment/profile/host/darwin/ia32.ia32/ia32.mk
Symbolic link
1
environment/profile/host/darwin/ia32.ia32/ia32.mk
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../darwin.mk
|
||||
1
environment/profile/host/darwin/ia32.ia32/ia32.py
Symbolic link
1
environment/profile/host/darwin/ia32.ia32/ia32.py
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../darwin.py
|
||||
1
environment/profile/host/darwin/ia32.ia32/optimised
Symbolic link
1
environment/profile/host/darwin/ia32.ia32/optimised
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
.
|
||||
33
environment/profile/host/darwin/ia32.null/null.conf
Normal file
33
environment/profile/host/darwin/ia32.null/null.conf
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/fanfwe/kane...t/profile/host/darwin/ia32.null/null.conf
|
||||
#
|
||||
# created julien quintard [thu jun 28 21:15:33 2007]
|
||||
# updated francois goudal [mon aug 4 16:05:31 2008]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file contains definitions specific to the null target microprocessor
|
||||
# architecture.
|
||||
#
|
||||
|
||||
#
|
||||
# include the darwin generic definitions
|
||||
#
|
||||
|
||||
include ../darwin.conf
|
||||
|
||||
#
|
||||
# microprocessor specific definitions
|
||||
#
|
||||
|
||||
_CC_FLAGS_ += -D___kaneton$$\endian=0 \
|
||||
-D___kaneton$$\wordsz=32 \
|
||||
-D___kaneton$$\pagesz=1
|
||||
1
environment/profile/host/darwin/ia32.null/null.desc
Symbolic link
1
environment/profile/host/darwin/ia32.null/null.desc
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../darwin.desc
|
||||
1
environment/profile/host/darwin/ia32.null/null.mk
Symbolic link
1
environment/profile/host/darwin/ia32.null/null.mk
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../darwin.mk
|
||||
1
environment/profile/host/darwin/ia32.null/null.py
Symbolic link
1
environment/profile/host/darwin/ia32.null/null.py
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../darwin.py
|
||||
33
environment/profile/host/host.conf
Normal file
33
environment/profile/host/host.conf
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kaneton/environment/profile/host/host.conf
|
||||
#
|
||||
# created julien quintard [tue may 8 13:03:21 2007]
|
||||
# updated julien quintard [fri dec 17 20:04:01 2010]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file contains the default host variables. the different hosts
|
||||
# should either complete or override them.
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- garbage ----------------------------------------------------------
|
||||
#
|
||||
|
||||
_GARBAGE_ = *~ .*~ \#* .\#* *.pyc *.aux \
|
||||
*.log *.toc *.bbl *.blg *.nav \
|
||||
*.out *.snm *.vrb *.pdf
|
||||
|
||||
#
|
||||
# ---------- binaries ---------------------------------------------------------
|
||||
#
|
||||
|
||||
_BINARIES_ = <null>
|
||||
18
environment/profile/host/host.desc
Normal file
18
environment/profile/host/host.desc
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kaneton/environment/profile/host/host.desc
|
||||
#
|
||||
# created julien quintard [tue may 8 13:03:26 2007]
|
||||
# updated julien quintard [sat may 19 14:30:26 2007]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# XXX
|
||||
#
|
||||
214
environment/profile/host/host.mk
Normal file
214
environment/profile/host/host.mk
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kaneton.STABLE/environment/profile/host/host.mk
|
||||
#
|
||||
# created julien quintard [tue may 8 13:03:34 2007]
|
||||
# updated julien quintard [mon nov 29 10:18:58 2010]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file contains generic stuff about the implementation of the kaneton
|
||||
# make interface. there are few functions here because make was not designed
|
||||
# in a portable way.
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- directives -------------------------------------------------------
|
||||
#
|
||||
|
||||
.SILENT:
|
||||
|
||||
#
|
||||
# ---------- options ----------------------------------------------------------
|
||||
#
|
||||
|
||||
ENV_HEADER_NONE = 0
|
||||
ENV_HEADER_OK = 1
|
||||
ENV_HEADER_ERROR = 2
|
||||
ENV_HEADER_INTERACTIVE = 4
|
||||
|
||||
ENV_COLOR_NONE = 0
|
||||
ENV_COLOR_RED = 1
|
||||
ENV_COLOR_GREEN = 2
|
||||
ENV_COLOR_YELLOW = 3
|
||||
ENV_COLOR_BLUE = 4
|
||||
ENV_COLOR_WHITE = 5
|
||||
|
||||
ENV_OPTION_NONE = 0
|
||||
ENV_OPTION_NO_NEWLINE = 1
|
||||
ENV_OPTION_FLICKERING = 2
|
||||
|
||||
ENV_OPTION_NO_STANDARD = 1
|
||||
ENV_OPTION_STANDARD = 2
|
||||
|
||||
ENV_OPTION_PRIVATE = 1
|
||||
|
||||
#
|
||||
# ---------- default rule -----------------------------------------------------
|
||||
#
|
||||
# this rule is invoked when a Makefile is called without specifying a
|
||||
# rule name.
|
||||
#
|
||||
# this rule is intended to check whether the configured environment files
|
||||
# are up-to-date. if not, this rule re-builds the configured environment files.
|
||||
#
|
||||
|
||||
ENV_DEPENDENCIES := $(wildcard \
|
||||
$(_PROFILE_DIR_)/*.conf \
|
||||
$(_PROFILE_DIR_)/host/*.conf \
|
||||
$(_PROFILE_DIR_)/host/*.mk \
|
||||
$(_PROFILE_DIR_)/host/*.py \
|
||||
$(_PROFILE_HOST_DIR_)/*.conf \
|
||||
$(_PROFILE_HOST_DIR_)/*.mk \
|
||||
$(_PROFILE_HOST_DIR_)/*.py \
|
||||
$(_PROFILE_DIR_)/kaneton/*.conf \
|
||||
$(_PROFILE_DIR_)/kaneton/*.py \
|
||||
$(_PROFILE_DIR_)/kaneton/*.mk \
|
||||
$(_PROFILE_LIBRARY_DIR_)/*.conf \
|
||||
$(_PROFILE_LIBRARY_DIR_)/*.mk \
|
||||
$(_PROFILE_LIBRARY_DIR_)/*.py \
|
||||
$(_PROFILE_MODULES_DIR_)/*.conf \
|
||||
$(_PROFILE_MODULES_DIR_)/*.mk \
|
||||
$(_PROFILE_MODULES_DIR_)/*.py \
|
||||
$(_PROFILE_MACHINE_DIR_)/*.conf \
|
||||
$(_PROFILE_MACHINE_DIR_)/*.mk \
|
||||
$(_PROFILE_MACHINE_DIR_)/*.py \
|
||||
$(_PROFILE_PLATFORM_DIR_)/*.conf \
|
||||
$(_PROFILE_PLATFORM_DIR_)/*.mk \
|
||||
$(_PROFILE_PLATFORM_DIR_)/*.py \
|
||||
$(_PROFILE_ARCHITECTURE_DIR_)/*.conf \
|
||||
$(_PROFILE_ARCHITECTURE_DIR_)/*.mk \
|
||||
$(_PROFILE_ARCHITECTURE_DIR_)/*.py \
|
||||
$(_PROFILE_GLUE_DIR_)/*.conf \
|
||||
$(_PROFILE_GLUE_DIR_)/*.mk \
|
||||
$(_PROFILE_GLUE_DIR_)/*.py \
|
||||
$(_PROFILE_CORE_DIR_)/*.conf \
|
||||
$(_PROFILE_CORE_DIR_)/*.mk \
|
||||
$(_PROFILE_CORE_DIR_)/*.py \
|
||||
$(_PROFILE_DIR_)/user/*.conf \
|
||||
$(_PROFILE_DIR_)/user/*.mk \
|
||||
$(_PROFILE_DIR_)/user/*.py \
|
||||
$(_PROFILE_USER_DIR_)/*.conf \
|
||||
$(_PROFILE_USER_DIR_)/*.mk \
|
||||
$(_PROFILE_USER_DIR_)/*.py)
|
||||
|
||||
_: $(_ENV_MK_) $(_ENV_PY_)
|
||||
$(call env_launch,Makefile,main,)
|
||||
|
||||
$(_ENV_MK_) $(_ENV_PY): \
|
||||
$(ENV_DEPENDENCIES)
|
||||
$(call env_launch,$(_ENVIRONMENT_DIR_)/Makefile,initialize,)
|
||||
|
||||
#
|
||||
# ---------- traps ------------------------------------------------------------
|
||||
#
|
||||
|
||||
%.o: %.S
|
||||
$(call env_assemble-S,$@,$<,)
|
||||
|
||||
%.o: %.c
|
||||
$(call env_compile-c,$@,$<,)
|
||||
|
||||
%.c: %.l
|
||||
$(call env_lex-l,$@,$<,)
|
||||
|
||||
#
|
||||
# ---------- functions --------------------------------------------------------
|
||||
#
|
||||
|
||||
#
|
||||
# display functions
|
||||
#
|
||||
# 1: action
|
||||
# 2: file
|
||||
# 3: identation
|
||||
# 4: options
|
||||
#
|
||||
|
||||
define env_display-red
|
||||
$(call env_print,[,blue,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,$(1),red,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,],blue,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,$(3)$(2),,)
|
||||
endef
|
||||
|
||||
define env_display-green
|
||||
$(call env_print,[,blue,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,$(1),green,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,],blue,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,$(3)$(2),,)
|
||||
endef
|
||||
|
||||
define env_display-yellow
|
||||
$(call env_print,[,blue,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,$(1),yellow,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,],blue,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,$(3)$(2),,)
|
||||
endef
|
||||
|
||||
define env_display-magenta
|
||||
$(call env_print,[,blue,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,$(1),magenta,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,],blue,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,$(3)$(2),,)
|
||||
endef
|
||||
|
||||
define env_display-cyan
|
||||
$(call env_print,[,blue,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,$(1),cyan,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,],blue,$(ENV_OPTION_NO_NEWLINE)) && \
|
||||
$(call env_print,$(3)$(2),,)
|
||||
endef
|
||||
|
||||
#
|
||||
# display wrapper
|
||||
#
|
||||
# $(1): color
|
||||
# $(2): action
|
||||
# $(3): file
|
||||
# $(4): indentation
|
||||
# $(5): options
|
||||
#
|
||||
|
||||
define env_display
|
||||
$(call env_display-$(1),$(2),$(3),$(4),$(5))
|
||||
endef
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
|
||||
directory := $(CURDIR)
|
||||
|
||||
#
|
||||
# ---------- component-based behaviour ----------------------------------------
|
||||
#
|
||||
|
||||
#
|
||||
# behaviour
|
||||
#
|
||||
|
||||
behaviour := default
|
||||
|
||||
#
|
||||
# components
|
||||
#
|
||||
|
||||
ifeq ($(call findstring,$(component),$(components)),)
|
||||
components += $(component)
|
||||
endif
|
||||
|
||||
export components
|
||||
|
||||
#
|
||||
# ---------- cc flags ---------------------------------------------------------
|
||||
#
|
||||
|
||||
_CC_FLAGS_ += $(foreach m,$(_MODULES_),-DMODULE_$(m))
|
||||
382
environment/profile/host/host.py
Normal file
382
environment/profile/host/host.py
Normal file
|
|
@ -0,0 +1,382 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kaneton/environment/profile/host/host.py
|
||||
#
|
||||
# created julien quintard [tue may 8 13:03:40 2007]
|
||||
# updated julien quintard [mon mar 7 16:36:27 2011]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file contains generic stuff about the python interface including
|
||||
# options and general functions.
|
||||
#
|
||||
# since the python scripting language was designed to provide portable
|
||||
# operations, the following operations are considered as generic, making
|
||||
# work easier for host sub-profiles.
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- imports ----------------------------------------------------------
|
||||
#
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import shutil
|
||||
import time
|
||||
|
||||
#
|
||||
# ---------- options ----------------------------------------------------------
|
||||
#
|
||||
|
||||
HEADER_NONE = 0
|
||||
HEADER_OK = 1
|
||||
HEADER_ERROR = 2
|
||||
HEADER_INTERACTIVE = 4
|
||||
|
||||
COLOR_NONE = 0
|
||||
COLOR_BLACK = 1
|
||||
COLOR_RED = 2
|
||||
COLOR_GREEN = 3
|
||||
COLOR_YELLOW = 4
|
||||
COLOR_BLUE = 5
|
||||
COLOR_MAGENTA = 6
|
||||
COLOR_CYAN = 7
|
||||
COLOR_WHITE = 8
|
||||
|
||||
OPTION_NONE = 0
|
||||
|
||||
OPTION_QUIET = 1
|
||||
|
||||
OPTION_NO_NEWLINE = 1
|
||||
OPTION_FLICKERING = 2
|
||||
OPTION_BOLD = 4
|
||||
|
||||
OPTION_FILE = 1
|
||||
OPTION_DIRECTORY = 2
|
||||
OPTION_LINK = 4
|
||||
OPTION_RECURSIVE = 8
|
||||
OPTION_EXIST = 16
|
||||
OPTION_HIDDEN = 32
|
||||
OPTION_ALL = OPTION_FILE | OPTION_DIRECTORY | OPTION_LINK
|
||||
|
||||
OPTION_DEVICE = 1
|
||||
OPTION_IMAGE = 2
|
||||
|
||||
OPTION_CURRENT_DIRECTORY = 1
|
||||
|
||||
#
|
||||
# ---------- functions --------------------------------------------------------
|
||||
#
|
||||
|
||||
#
|
||||
# display()
|
||||
#
|
||||
# this function prints a kaneton message.
|
||||
#
|
||||
def display(header, text, options):
|
||||
if header == HEADER_NONE:
|
||||
sys.stdout.write(colorize(text, COLOR_NONE, OPTION_NONE))
|
||||
elif header == HEADER_OK:
|
||||
sys.stdout.write(colorize("[", COLOR_BLUE, OPTION_BOLD))
|
||||
sys.stdout.write(colorize("+", COLOR_GREEN, OPTION_BOLD))
|
||||
sys.stdout.write(colorize("]", COLOR_BLUE, OPTION_BOLD))
|
||||
sys.stdout.write(" ")
|
||||
sys.stdout.write(colorize(text, COLOR_NONE, OPTION_NONE))
|
||||
elif header == HEADER_ERROR:
|
||||
sys.stdout.write(colorize("[", COLOR_BLUE, OPTION_BOLD))
|
||||
sys.stdout.write(colorize("!", COLOR_RED, OPTION_BOLD))
|
||||
sys.stdout.write(colorize("]", COLOR_BLUE, OPTION_BOLD))
|
||||
sys.stdout.write(" ")
|
||||
sys.stdout.write(colorize(text, COLOR_NONE, OPTION_NONE))
|
||||
elif header == HEADER_INTERACTIVE:
|
||||
sys.stdout.write(colorize("[", COLOR_BLUE, OPTION_BOLD))
|
||||
sys.stdout.write(colorize("?",
|
||||
COLOR_YELLOW,
|
||||
OPTION_FLICKERING | OPTION_BOLD))
|
||||
sys.stdout.write(colorize("]", COLOR_BLUE, OPTION_BOLD))
|
||||
sys.stdout.write(" ")
|
||||
sys.stdout.write(colorize(text, COLOR_NONE, OPTION_NONE))
|
||||
|
||||
if not options & OPTION_NO_NEWLINE:
|
||||
sys.stdout.write("\n")
|
||||
|
||||
|
||||
|
||||
#
|
||||
# pull()
|
||||
#
|
||||
# this function reads the content of a single file.
|
||||
#
|
||||
def pull(file, options):
|
||||
handle = None
|
||||
line = None
|
||||
|
||||
if not os.path.exists(file):
|
||||
return None
|
||||
|
||||
try:
|
||||
handle = open(file, "r")
|
||||
except IOError:
|
||||
return None
|
||||
|
||||
content = ""
|
||||
for line in handle.readlines():
|
||||
content += line
|
||||
|
||||
handle.close()
|
||||
|
||||
return content
|
||||
|
||||
|
||||
|
||||
#
|
||||
# push()
|
||||
#
|
||||
# this function writes the content of a single file.
|
||||
#
|
||||
def push(file, content, options):
|
||||
handle = None
|
||||
|
||||
handle = open(file, "w")
|
||||
|
||||
handle.write(content)
|
||||
|
||||
handle.close()
|
||||
|
||||
|
||||
|
||||
#
|
||||
# temporary()
|
||||
#
|
||||
# this function provides an easy way to create a temporary file or directory.
|
||||
#
|
||||
def temporary(options):
|
||||
location = None
|
||||
|
||||
if options == OPTION_FILE:
|
||||
tuple = tempfile.mkstemp()
|
||||
|
||||
os.close(tuple[0])
|
||||
|
||||
location = tuple[1]
|
||||
elif options == OPTION_DIRECTORY:
|
||||
location = tempfile.mkdtemp()
|
||||
|
||||
return location
|
||||
|
||||
|
||||
|
||||
#
|
||||
# cwd()
|
||||
#
|
||||
# this function returns the current working directory.
|
||||
#
|
||||
def cwd(options):
|
||||
return os.getcwd()
|
||||
|
||||
|
||||
|
||||
#
|
||||
# input()
|
||||
#
|
||||
# this function waits for an input.
|
||||
#
|
||||
def input(options):
|
||||
return input()
|
||||
|
||||
|
||||
|
||||
#
|
||||
# copy()
|
||||
#
|
||||
# this function copies a file or a directory.
|
||||
#
|
||||
def copy(source, destination, options):
|
||||
if os.path.isdir(source):
|
||||
shutil.copytree(source, destination, True)
|
||||
else:
|
||||
shutil.copy2(source, destination)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# move()
|
||||
#
|
||||
# this function moves a file or a directory.
|
||||
#
|
||||
def move(source, destination, options):
|
||||
copy(source, destination, options)
|
||||
remove(source, options)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# link()
|
||||
#
|
||||
# this function builds a link name source to the file destination.
|
||||
#
|
||||
def link(source, destination, options):
|
||||
os.symlink(destination, source)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# remove()
|
||||
#
|
||||
# this function removes the targets.
|
||||
#
|
||||
def remove(target, options):
|
||||
entries = None
|
||||
entry = None
|
||||
|
||||
if os.path.isfile(target) or os.path.islink(target):
|
||||
os.unlink(target)
|
||||
|
||||
if os.path.isdir(target):
|
||||
entries = os.listdir(target)
|
||||
for entry in entries:
|
||||
remove(target + "/" + entry, OPTION_NONE)
|
||||
os.rmdir(target)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# list()
|
||||
#
|
||||
# this function lists the entries of a directory.
|
||||
#
|
||||
def list(directory, options):
|
||||
elements = []
|
||||
entries = None
|
||||
entry = None
|
||||
|
||||
entries = os.listdir(directory)
|
||||
|
||||
for entry in entries:
|
||||
if not (options & OPTION_HIDDEN) and \
|
||||
(entry[0:1] == "."):
|
||||
continue
|
||||
if (options & OPTION_LINK) and \
|
||||
(os.path.islink(directory + "/" + entry)):
|
||||
elements += [ entry ]
|
||||
if (options & OPTION_FILE) and \
|
||||
(os.path.isfile(directory + "/" + entry)) and \
|
||||
(not os.path.islink(directory + "/" + entry)):
|
||||
elements += [ entry ]
|
||||
if (options & OPTION_DIRECTORY) and \
|
||||
(os.path.isdir(directory + "/" + entry)) and \
|
||||
(not os.path.islink(directory + "/" + entry)):
|
||||
elements += [ entry ]
|
||||
|
||||
return elements
|
||||
|
||||
|
||||
|
||||
#
|
||||
# cd()
|
||||
#
|
||||
# this function changes the current working directory.
|
||||
#
|
||||
def cd(directory, options):
|
||||
os.chdir(directory)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# search()
|
||||
#
|
||||
# this function searches for file names matching the given pattern.
|
||||
#
|
||||
def search(directory, pattern, options):
|
||||
elements = []
|
||||
entries = None
|
||||
entry = None
|
||||
|
||||
entries = os.listdir(directory)
|
||||
|
||||
for entry in entries:
|
||||
if (options & OPTION_FILE) and \
|
||||
(os.path.isfile(directory + "/" + entry)) and \
|
||||
(re.search(pattern, entry)):
|
||||
elements += [ directory + "/" + entry ]
|
||||
|
||||
if (os.path.isdir(directory + "/" + entry)):
|
||||
if (options & OPTION_DIRECTORY) and \
|
||||
(re.search(pattern, entry)):
|
||||
elements += [ directory + "/" + entry ]
|
||||
|
||||
if (options & OPTION_RECURSIVE) and \
|
||||
(not os.path.islink(directory + "/" + entry)):
|
||||
elements += search(directory + "/" + entry, pattern, options)
|
||||
|
||||
return elements
|
||||
|
||||
|
||||
|
||||
#
|
||||
# mkdir()
|
||||
#
|
||||
# this function creates a directory.
|
||||
#
|
||||
def mkdir(directory, options):
|
||||
path = None
|
||||
steps = None
|
||||
step = None
|
||||
|
||||
steps = directory.strip("/").split("/")
|
||||
|
||||
for step in steps:
|
||||
if not path:
|
||||
path = "/" + step
|
||||
else:
|
||||
path = path + "/" + step
|
||||
|
||||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# stamp()
|
||||
#
|
||||
# this function returns the current formatted date.
|
||||
#
|
||||
def stamp(options):
|
||||
return time.strftime("%Y%m%d")
|
||||
|
||||
|
||||
|
||||
#
|
||||
# path()
|
||||
#
|
||||
# this function returns information on a path: file, directory etc.
|
||||
#
|
||||
def path(path, options):
|
||||
if options == OPTION_FILE:
|
||||
return os.path.basename(path)
|
||||
if options == OPTION_DIRECTORY:
|
||||
return os.path.dirname(path)
|
||||
if options == OPTION_EXIST:
|
||||
return os.path.exists(path)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
||||
#
|
||||
# info()
|
||||
#
|
||||
# this function returns information on the system.
|
||||
#
|
||||
def info(options):
|
||||
if (options & OPTION_CURRENT_DIRECTORY):
|
||||
return os.path.curdir
|
||||
1
environment/profile/host/linux/ia32.ia32/educational
Symbolic link
1
environment/profile/host/linux/ia32.ia32/educational
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
.
|
||||
1
environment/profile/host/linux/ia32.ia32/ia32.conf
Symbolic link
1
environment/profile/host/linux/ia32.ia32/ia32.conf
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../linux.conf
|
||||
1
environment/profile/host/linux/ia32.ia32/ia32.desc
Symbolic link
1
environment/profile/host/linux/ia32.ia32/ia32.desc
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../linux.desc
|
||||
1
environment/profile/host/linux/ia32.ia32/ia32.mk
Symbolic link
1
environment/profile/host/linux/ia32.ia32/ia32.mk
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../linux.mk
|
||||
1
environment/profile/host/linux/ia32.ia32/ia32.py
Symbolic link
1
environment/profile/host/linux/ia32.ia32/ia32.py
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../linux.py
|
||||
1
environment/profile/host/linux/ia32.ia32/optimised
Symbolic link
1
environment/profile/host/linux/ia32.ia32/optimised
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
.
|
||||
137
environment/profile/host/linux/ia32.mips64/mips64.conf
Normal file
137
environment/profile/host/linux/ia32.mips64/mips64.conf
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kane...ofile/host/linux/ia32.mips64/mips64.conf
|
||||
#
|
||||
# created julien quintard [thu jun 28 21:15:33 2007]
|
||||
# updated julien quintard [fri may 1 23:54:21 2009]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file contains definitions specific to the mips64 target microprocessor
|
||||
# architecture.
|
||||
#
|
||||
|
||||
#
|
||||
# include the linux generic definitions
|
||||
#
|
||||
|
||||
_INCLUDES_ = -I${_INCLUDE_DIR_}
|
||||
|
||||
#
|
||||
# ---------- flags ------------------------------------------------------------
|
||||
#
|
||||
|
||||
_CC_FLAGS_ = -D___kaneton \
|
||||
${_INCLUDES_} \
|
||||
${_KANETON_FLAGS_} \
|
||||
-fno-builtin \
|
||||
-Wimplicit \
|
||||
-Wparentheses \
|
||||
-Wreturn-type \
|
||||
-Wswitch -Wswitch-enum \
|
||||
-Wunused-function \
|
||||
-Wunused-variable \
|
||||
-Wmissing-prototypes \
|
||||
-Wmissing-declarations \
|
||||
-Wall -W -std=c99 \
|
||||
-mabi=64 \
|
||||
-G 0 \
|
||||
-march=mips64 \
|
||||
-EL \
|
||||
-mgp64 \
|
||||
-mfp64 \
|
||||
-mlong64 \
|
||||
-DMIPS64_DEPENDENT \
|
||||
-DMIPS64_DEV
|
||||
|
||||
_LD_FLAGS_ = --warn-unresolved-symbols \
|
||||
--oformat=elf64-littlemips
|
||||
|
||||
_ASM_FLAGS_ = -mabi=64 \
|
||||
-G 0 \
|
||||
-march=mips64 \
|
||||
-EL \
|
||||
-mgp64 \
|
||||
-mfp64
|
||||
|
||||
_CPP_FLAGS_ =
|
||||
|
||||
_SHELL_FLAGS_ =
|
||||
|
||||
_PYTHON_FLAGS_ =
|
||||
|
||||
_PERL_FLAGS_ =
|
||||
|
||||
_MAKE_FLAGS_ =
|
||||
|
||||
#
|
||||
# ---------- binaries ---------------------------------------------------------
|
||||
#
|
||||
|
||||
_BINARIES_ = ${_SHELL_}, ${_CC_}, ${_MAKE_}, \
|
||||
${_RM_}, ${_AR_}, ${_RANLIB_}, \
|
||||
${_LD_}, ${_AS_}, ${_BIBTEX_},\
|
||||
${_LN_}, ${_TOUCH_}, ${_WC_}, \
|
||||
${_DATE_}, ${_TAIL_}, ${_TAR_}, \
|
||||
${_PDFLATEX_}, ${_CP_}, \
|
||||
${_CAT_}, ${_SED_}, ${_CPP_}, \
|
||||
${_MTOOLS_}, ${_MCOPY_}, \
|
||||
${_XPDF_}, ${_MKTEMP_}, ${_MV_},\
|
||||
${_LEX_}, ${_SCRIPT_}, \
|
||||
${_PERL_}, ${_PYTHON_}, \
|
||||
${_DIRNAME_}, ${_BASENAME_}, \
|
||||
${_WHICH_}
|
||||
|
||||
_SHELL_ = bash
|
||||
_CC_ = mips64-gcc
|
||||
_AS_ = mips64-as
|
||||
_OBJCOPY_ = mips64-objcopy
|
||||
_MAKE_ = gmake
|
||||
_RM_ = rm -f
|
||||
_PURGE_ = ${_RM_} *.pyc *~ .*~ \#* .\#*
|
||||
_AR_ = mips64-ar cq
|
||||
_RANLIB_ = mips64-ranlib
|
||||
_CD_ = cd
|
||||
_LD_ = mips64-ld
|
||||
_LN_ = ln -s -f
|
||||
_TOUCH_ = touch
|
||||
_WC_ = wc
|
||||
_DATE_ = date -u
|
||||
_TAIL_ = tail
|
||||
_TAR_ = tar
|
||||
_PDFLATEX_ = pdflatex
|
||||
_BIBTEX_ = bibtex
|
||||
_CP_ = cp
|
||||
_CAT_ = cat
|
||||
_SED_ = sed -r
|
||||
_ECHO_ = echo
|
||||
_CPP_ = mips64-cpp
|
||||
_MTOOLS_ = mtools
|
||||
_MCOPY_ = mcopy
|
||||
_XPDF_ = xpdf
|
||||
_MKTEMP_ = mktemp
|
||||
_MV_ = mv
|
||||
_PWD_ = pwd
|
||||
_LEX_ = lex -t
|
||||
_SCRIPT_ = script
|
||||
_PERL_ = perl
|
||||
_PYTHON_ = python
|
||||
_DIRNAME_ = dirname
|
||||
_BASENAME_ = basename
|
||||
_WHICH_ = which
|
||||
_EXIT_ = exit
|
||||
|
||||
#
|
||||
# microprocessor specific definitions
|
||||
#
|
||||
|
||||
_CC_FLAGS_ += -D___kaneton$$\endian=1 \
|
||||
-D___kaneton$$\wordsz=64 \
|
||||
-D___kaneton$$\pagesz=4096
|
||||
33
environment/profile/host/linux/ia32.mips64/mips64.desc
Normal file
33
environment/profile/host/linux/ia32.mips64/mips64.desc
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kane...nvironment/profile/host/linux/linux.desc
|
||||
#
|
||||
# created julien quintard [tue may 8 13:20:04 2007]
|
||||
# updated julien quintard [tue may 29 16:37:31 2007]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file describes the linux environment variables.
|
||||
#
|
||||
|
||||
- variable: _SHELL_
|
||||
string: Shell
|
||||
type: any
|
||||
description: The shell binary path
|
||||
|
||||
- variable: _CC_
|
||||
string: C Compiler
|
||||
type: any
|
||||
description: The C compiler binary path
|
||||
|
||||
- variable: _MAKE_
|
||||
string: Make
|
||||
type: any
|
||||
description: The make binary path
|
||||
23
environment/profile/host/linux/ia32.mips64/mips64.mk
Normal file
23
environment/profile/host/linux/ia32.mips64/mips64.mk
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/enguerrand/...profile/host/linux/ia32.mips64/mips64.mk
|
||||
#
|
||||
# created julien quintard [tue may 8 13:03:34 2007]
|
||||
# updated enguerrand raymond [sun may 17 09:36:48 2009]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file implements the remaining functions of the kaneton make interface.
|
||||
#
|
||||
# indeed the major generic part of the interface is already provided by the
|
||||
# host profile.
|
||||
#
|
||||
|
||||
include ../linux.mk
|
||||
219
environment/profile/host/linux/ia32.mips64/mips64.py
Normal file
219
environment/profile/host/linux/ia32.mips64/mips64.py
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/enguerrand/...profile/host/linux/ia32.mips64/mips64.py
|
||||
#
|
||||
# created julien quintard [tue may 8 13:20:21 2007]
|
||||
# updated enguerrand raymond [fri apr 17 20:59:36 2009]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file implements the remaining functions of the kaneton python interface.
|
||||
#
|
||||
# note that the host profile already provides many functions. these
|
||||
# functions can be overriden but you will probably just use them.
|
||||
#
|
||||
# in addition, the host profile already imports some packages.
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- python path ------------------------------------------------------
|
||||
#
|
||||
|
||||
pythonpath = os.getenv("PYTHONPATH")
|
||||
if not pythonpath:
|
||||
pythonpath = ""
|
||||
|
||||
os.putenv("PYTHONPATH", pythonpath + ":" + _PYTHON_INCLUDE_DIR_)
|
||||
|
||||
#
|
||||
# ---------- functions --------------------------------------------------------
|
||||
#
|
||||
|
||||
#
|
||||
# colorize()
|
||||
#
|
||||
# this function returns a colorized text if the environment is configured
|
||||
# to or simply the original text.
|
||||
#
|
||||
# note that this function implementation is based on UNIX escape sequences.
|
||||
#
|
||||
def colorize(text, color, options):
|
||||
if _DISPLAY_ == _DISPLAY_UNCOLORED_:
|
||||
return text
|
||||
|
||||
if options & OPTION_FLICKERING:
|
||||
text = "[01;05m" + text + "[39;49;00m"
|
||||
|
||||
if color == COLOR_BLACK:
|
||||
text = "[30;01m" + text + "[39;49;00m"
|
||||
elif color == COLOR_RED:
|
||||
text = "[31;01m" + text + "[39;49;00m"
|
||||
elif color == COLOR_GREEN:
|
||||
text = "[32;01m" + text + "[39;49;00m"
|
||||
elif color == COLOR_YELLOW:
|
||||
text = "[33;01m" + text + "[39;49;00m"
|
||||
elif color == COLOR_BLUE:
|
||||
text = "[34;01m" + text + "[39;49;00m"
|
||||
elif color == COLOR_MAGENTA:
|
||||
text = "[35;01m" + text + "[39;49;00m"
|
||||
elif color == COLOR_CYAN:
|
||||
text = "[36;01m" + text + "[39;49;00m"
|
||||
elif color == COLOR_WHITE:
|
||||
text = "[37;01m" + text + "[39;49;00m"
|
||||
|
||||
return text
|
||||
|
||||
|
||||
|
||||
#
|
||||
# launch()
|
||||
#
|
||||
# this function launch a new program/script/make etc.
|
||||
#
|
||||
def launch(file, arguments, options):
|
||||
directory = None
|
||||
info = None
|
||||
status = 0
|
||||
wd = None
|
||||
|
||||
info = os.path.split(file)
|
||||
|
||||
directory = info[0]
|
||||
file = info[1]
|
||||
|
||||
if directory:
|
||||
wd = cwd(OPTION_NONE)
|
||||
cd(directory, OPTION_NONE)
|
||||
|
||||
if re.match("^.*\.sh$", file):
|
||||
status = os.system(_SHELL_ + " " + file + " " + arguments)
|
||||
elif re.match("^.*\.py$", file):
|
||||
status = os.system(_PYTHON_ + " " + file + " " + arguments)
|
||||
elif re.match("^.*\.pl$", file):
|
||||
status = os.system(_PERL_ + " " + file + " " + arguments)
|
||||
elif re.match("^Makefile$", file):
|
||||
status = os.system(_MAKE_ + " -f " + file + " " + arguments)
|
||||
else:
|
||||
status = os.system(file + " " + arguments)
|
||||
|
||||
if directory:
|
||||
cd(wd, OPTION_NONE)
|
||||
|
||||
return status
|
||||
|
||||
|
||||
|
||||
#
|
||||
# pack()
|
||||
#
|
||||
# this function creates an archive of the given directory.
|
||||
#
|
||||
def pack(directory, file, options):
|
||||
launch(_TAR_, "-cjf " + file + " " + directory, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# unpack()
|
||||
#
|
||||
# this function unpackages an archive into the given (optional) directory.
|
||||
#
|
||||
def unpack(file, directory, options):
|
||||
if directory:
|
||||
launch(_TAR_, "-xjf " + file + " -C " + directory, OPTION_NONE)
|
||||
else:
|
||||
launch(_TAR_, "-xjf " + file, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# load()
|
||||
#
|
||||
# this function copies a file on a device, this device can be virtual:
|
||||
# an image.
|
||||
#
|
||||
def load(file, device, path, options):
|
||||
if options == OPTION_DEVICE:
|
||||
launch(_MCOPY_, "-o -n " + file + " " + device + path, OPTION_NONE)
|
||||
|
||||
if options == OPTION_IMAGE:
|
||||
launch(_MCOPY_, "-o -n " + "-i" + device + " " +
|
||||
file + " ::" + path, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# record()
|
||||
#
|
||||
# this function runs the program recording a session.
|
||||
#
|
||||
def record(transcript, options):
|
||||
directory = None
|
||||
time = None
|
||||
log = None
|
||||
tmp = None
|
||||
wd = None
|
||||
|
||||
tmp = temporary(OPTION_DIRECTORY)
|
||||
|
||||
directory = tmp + "/" + "transcript"
|
||||
|
||||
log = directory + "/" + "log"
|
||||
time = directory + "/" + "time"
|
||||
|
||||
mkdir(directory, OPTION_NONE)
|
||||
|
||||
launch(_SCRIPT_, "-q -t " + log + " -c " +
|
||||
_TRANSCRIPT_CMD_ + " 2> " + time, OPTION_NONE)
|
||||
|
||||
wd = cwd(OPTION_NONE)
|
||||
|
||||
cd(tmp, OPTION_NONE)
|
||||
|
||||
pack("transcript", wd + "/" + transcript, OPTION_NONE)
|
||||
|
||||
cd(wd, OPTION_NONE)
|
||||
|
||||
remove(tmp, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# play()
|
||||
#
|
||||
# this function runs the program replaying a session.
|
||||
#
|
||||
def play(transcript, options):
|
||||
directory = None
|
||||
time = None
|
||||
log = None
|
||||
tmp = None
|
||||
wd = None
|
||||
|
||||
tmp = temporary(OPTION_DIRECTORY)
|
||||
|
||||
log = tmp + "/" + "transcript/log"
|
||||
time = tmp + "/" + "transcript/time"
|
||||
|
||||
unpack(transcript, tmp, OPTION_NONE)
|
||||
|
||||
launch(_SCRIPTREPLAY_TOOL_, time + " " + log, OPTION_NONE)
|
||||
|
||||
remove(tmp, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# locate()
|
||||
#
|
||||
# this function tries to locate a program on the system.
|
||||
#
|
||||
def locate(file, options):
|
||||
return launch(_WHICH_, file + " 1>/dev/null 2>/dev/null", OPTION_NONE)
|
||||
48
environment/profile/host/linux/ia32.mips64/util.py
Normal file
48
environment/profile/host/linux/ia32.mips64/util.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/enguerrand/...t/profile/host/linux/ia32.mips64/util.py
|
||||
#
|
||||
# created enguerrand raymond [fri apr 17 20:59:04 2009]
|
||||
# updated enguerrand raymond [fri apr 17 21:00:47 2009]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file implements some useful functions used for mips compilation, build
|
||||
# and installation.
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
# binary_extract()
|
||||
#
|
||||
# this function extracts given sections (section names separate by space)
|
||||
# from elf to put in binary
|
||||
#
|
||||
def binary_extract(elf, sections, binary):
|
||||
section_list = sections.split()
|
||||
cmd_option = "-S"
|
||||
|
||||
for section in section_list:
|
||||
cmd_option += " -j " + section
|
||||
|
||||
cmd_option += " --output-target binary " + elf + " " + binary
|
||||
|
||||
launch(_OBJCOPY_, cmd_option, "")
|
||||
|
||||
|
||||
|
||||
#
|
||||
# concat_file()
|
||||
#
|
||||
# this function concatenates file a the result file end
|
||||
#
|
||||
def concat_file(file, result):
|
||||
os.system(_CAT_ + " " + file + " >> " + result)
|
||||
33
environment/profile/host/linux/ia32.null/null.conf
Normal file
33
environment/profile/host/linux/ia32.null/null.conf
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kane...t/profile/host/linux/ia32.null/null.conf
|
||||
#
|
||||
# created julien quintard [thu jun 28 21:15:33 2007]
|
||||
# updated julien quintard [wed mar 26 23:37:31 2008]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file contains definitions specific to the null target microprocessor
|
||||
# architecture.
|
||||
#
|
||||
|
||||
#
|
||||
# include the linux generic definitions
|
||||
#
|
||||
|
||||
include ../linux.conf
|
||||
|
||||
#
|
||||
# microprocessor specific definitions
|
||||
#
|
||||
|
||||
_CC_FLAGS_ += -D___kaneton$$\endian=0 \
|
||||
-D___kaneton$$\wordsz=32 \
|
||||
-D___kaneton$$\pagesz=1
|
||||
1
environment/profile/host/linux/ia32.null/null.desc
Symbolic link
1
environment/profile/host/linux/ia32.null/null.desc
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../linux.desc
|
||||
1
environment/profile/host/linux/ia32.null/null.mk
Symbolic link
1
environment/profile/host/linux/ia32.null/null.mk
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../linux.mk
|
||||
1
environment/profile/host/linux/ia32.null/null.py
Symbolic link
1
environment/profile/host/linux/ia32.null/null.py
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../linux.py
|
||||
113
environment/profile/host/linux/linux.conf
Normal file
113
environment/profile/host/linux/linux.conf
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kane...nvironment/profile/host/linux/linux.conf
|
||||
#
|
||||
# created julien quintard [tue may 8 13:19:52 2007]
|
||||
# updated julien quintard [mon feb 7 10:36:01 2011]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file contains the libraries, binaries, script and tools related to
|
||||
# the generic linux host sub-profile.
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- includes ---------------------------------------------------------
|
||||
#
|
||||
|
||||
_INCLUDES_ = -I${_INCLUDE_DIR_}
|
||||
|
||||
#
|
||||
# ---------- flags ------------------------------------------------------------
|
||||
#
|
||||
|
||||
_CC_FLAGS_ = ${_INCLUDES_} \
|
||||
${_KANETON_FLAGS_} \
|
||||
-fno-builtin \
|
||||
-fno-stack-protector \
|
||||
-Wimplicit \
|
||||
-Wparentheses \
|
||||
-Wreturn-type \
|
||||
-Wswitch -Wswitch-enum \
|
||||
-Wunused-function \
|
||||
-Wunused-variable \
|
||||
-Wmissing-prototypes \
|
||||
-Wmissing-declarations \
|
||||
-Wall
|
||||
|
||||
_LD_FLAGS_ = ${_INCLUDES_}
|
||||
|
||||
_ASM_FLAGS_ =
|
||||
|
||||
_CPP_FLAGS_ =
|
||||
|
||||
_SHELL_FLAGS_ =
|
||||
|
||||
_PYTHON_FLAGS_ =
|
||||
|
||||
_PERL_FLAGS_ =
|
||||
|
||||
_MAKE_FLAGS_ =
|
||||
|
||||
#
|
||||
# ---------- binaries ---------------------------------------------------------
|
||||
#
|
||||
|
||||
_BINARIES_ = ${_SHELL_}, ${_CC_}, ${_MAKE_}, \
|
||||
${_RM_}, ${_AR_}, ${_RANLIB_}, \
|
||||
${_LD_}, ${_AS_}, ${_BIBTEX_},\
|
||||
${_LN_}, ${_TOUCH_}, ${_WC_}, \
|
||||
${_DATE_}, ${_TAIL_}, ${_TAR_}, \
|
||||
${_PDFLATEX_}, ${_CP_}, \
|
||||
${_CAT_}, ${_SED_}, ${_CPP_}, \
|
||||
${_MTOOLS_}, ${_MCOPY_}, \
|
||||
${_XPDF_}, ${_MKTEMP_}, ${_MV_},\
|
||||
${_LEX_}, ${_SCRIPT_}, \
|
||||
${_PERL_}, ${_PYTHON_}, \
|
||||
${_DIRNAME_}, ${_BASENAME_}, \
|
||||
${_WHICH_}
|
||||
|
||||
_SHELL_ = bash
|
||||
_CC_ = gcc
|
||||
_AS_ = as
|
||||
_MAKE_ = make
|
||||
_RM_ = rm -f
|
||||
_PURGE_ = ${_RM_} ${_GARBAGE_}
|
||||
_AR_ = ar cq
|
||||
_RANLIB_ = ranlib
|
||||
_CD_ = cd
|
||||
_LD_ = ld
|
||||
_LN_ = ln -s -f
|
||||
_TOUCH_ = touch
|
||||
_WC_ = wc
|
||||
_DATE_ = date -u
|
||||
_TAIL_ = tail
|
||||
_TAR_ = tar
|
||||
_PDFLATEX_ = pdflatex
|
||||
_BIBTEX_ = bibtex
|
||||
_CP_ = cp
|
||||
_CAT_ = cat
|
||||
_SED_ = sed -r
|
||||
_ECHO_ = echo
|
||||
_CPP_ = cpp
|
||||
_MTOOLS_ = mtools
|
||||
_MCOPY_ = mcopy
|
||||
_XPDF_ = xpdf
|
||||
_MKTEMP_ = mktemp
|
||||
_MV_ = mv
|
||||
_PWD_ = pwd
|
||||
_LEX_ = lex -t
|
||||
_SCRIPT_ = script
|
||||
_PERL_ = perl
|
||||
_PYTHON_ = python
|
||||
_DIRNAME_ = dirname
|
||||
_BASENAME_ = basename
|
||||
_WHICH_ = which
|
||||
_EXIT_ = exit
|
||||
33
environment/profile/host/linux/linux.desc
Normal file
33
environment/profile/host/linux/linux.desc
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kane...nvironment/profile/host/linux/linux.desc
|
||||
#
|
||||
# created julien quintard [tue may 8 13:20:04 2007]
|
||||
# updated julien quintard [tue may 29 16:37:31 2007]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file describes the linux environment variables.
|
||||
#
|
||||
|
||||
- variable: _SHELL_
|
||||
string: Shell
|
||||
type: any
|
||||
description: The shell binary path
|
||||
|
||||
- variable: _CC_
|
||||
string: C Compiler
|
||||
type: any
|
||||
description: The C compiler binary path
|
||||
|
||||
- variable: _MAKE_
|
||||
string: Make
|
||||
type: any
|
||||
description: The make binary path
|
||||
507
environment/profile/host/linux/linux.mk
Normal file
507
environment/profile/host/linux/linux.mk
Normal file
|
|
@ -0,0 +1,507 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kane.../environment/profile/host/linux/linux.mk
|
||||
#
|
||||
# created julien quintard [tue may 8 13:03:34 2007]
|
||||
# updated julien quintard [sun dec 5 00:02:41 2010]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file implements the remaining functions of the kaneton make interface.
|
||||
#
|
||||
# indeed the major generic part of the interface is already provided by the
|
||||
# host profile.
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- lang -------------------------------------------------------------
|
||||
#
|
||||
# incorrect locales may prevent the system from compiling properly.
|
||||
#
|
||||
# the following forces the LANG environment variable to US.
|
||||
#
|
||||
export LANG=US
|
||||
|
||||
#
|
||||
# ---------- python path ------------------------------------------------------
|
||||
#
|
||||
|
||||
export PYTHONPATH=$(shell $(_ECHO_) $${PYTHONPATH}):$(_PYTHON_INCLUDE_DIR_)
|
||||
|
||||
#
|
||||
# ---------- functions --------------------------------------------------------
|
||||
#
|
||||
|
||||
#
|
||||
# colorize functions
|
||||
#
|
||||
# 1: text
|
||||
# 2: options
|
||||
#
|
||||
|
||||
define env_colorize-black
|
||||
"[30;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-red
|
||||
"[31;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-green
|
||||
"[32;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-yellow
|
||||
"[33;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-blue
|
||||
"[34;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-magenta
|
||||
"[35;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-cyan
|
||||
"[36;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-white
|
||||
"[37;01m$(1)[39;49;00m"
|
||||
endef
|
||||
|
||||
define env_colorize-
|
||||
"$(1)"
|
||||
endef
|
||||
|
||||
#
|
||||
# perform function
|
||||
#
|
||||
# 1: command
|
||||
#
|
||||
|
||||
ifeq ($(_OUTPUT_),$(_OUTPUT_VERBOSE_)) # if the user wants to display
|
||||
# additional debug information
|
||||
|
||||
define env_perform
|
||||
$(_ECHO_) " $(1)" && \
|
||||
$(1)
|
||||
endef
|
||||
|
||||
else
|
||||
|
||||
define env_perform
|
||||
$(1)
|
||||
endef
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
# print functions wrapper
|
||||
#
|
||||
# 1: text
|
||||
# 2: color
|
||||
# 3: options
|
||||
#
|
||||
|
||||
ifeq ($(_DISPLAY_),$(_DISPLAY_COLORED_)) # if the user wants to display
|
||||
# the text with color
|
||||
|
||||
define env_print
|
||||
print_options="" && \
|
||||
if [ -n "$(3)" ] ; then \
|
||||
if [ $$(( $(3) & $(ENV_OPTION_NO_NEWLINE) )) -ne 0 ] ; then \
|
||||
print_options="$${print_options} -n" ; \
|
||||
fi ; \
|
||||
fi && \
|
||||
$(_ECHO_) $${print_options} $(call env_colorize-$(2),$(1),)
|
||||
endef
|
||||
|
||||
else # if not ...
|
||||
|
||||
define env_print
|
||||
print_options="" && \
|
||||
if [ -n "$(3)" ] ; then \
|
||||
if [ $$(( $(3) & $(ENV_OPTION_NO_NEWLINE) )) -ne 0 ] ; then \
|
||||
print_options="$${print_options} -n" ; \
|
||||
fi ; \
|
||||
fi && \
|
||||
$(_ECHO_) $${print_options} "$(1)"
|
||||
endef
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
# change the current working directory
|
||||
#
|
||||
# $(1): directory
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_cd
|
||||
cd_options="" && \
|
||||
$(call env_perform, \
|
||||
$(_CD_) $${cd_options} $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# returns a file contents
|
||||
#
|
||||
# $(1): the file
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_pull
|
||||
$(_CAT_) $(2) $(1)
|
||||
endef
|
||||
|
||||
#
|
||||
# launch a new program/script/make etc.
|
||||
#
|
||||
# $(1): file
|
||||
# $(2): arguments
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_launch
|
||||
launch_options="" && \
|
||||
cwd=$$($(_PWD_)) && \
|
||||
directory=$$($(_DIRNAME_) $(1)) && \
|
||||
file=$$($(_BASENAME_) $(1)) && \
|
||||
if [ "$${directory}" != "." ] ; then \
|
||||
$(call env_perform, \
|
||||
$(_CD_) $${directory}) ; \
|
||||
fi && \
|
||||
case "$${file}" in \
|
||||
*.sh) \
|
||||
$(call env_perform, \
|
||||
$(_SHELL_) $${launch_options} $${file} $(_SHELL_FLAGS_) $(2)) ; \
|
||||
;; \
|
||||
*.py) \
|
||||
$(call env_perform, \
|
||||
$(_PYTHON_) $${launch_options} $${file} $(_PYTHON_FLAGS_) $(2)) ; \
|
||||
;; \
|
||||
*.pl) \
|
||||
$(call env_perform, \
|
||||
$(_PERL_) $${launch_options} $${file} $(_PERL_FLAGS_) $(2)) ; \
|
||||
;; \
|
||||
Makefile) \
|
||||
$(call env_perform, \
|
||||
$(_MAKE_) $${launch_options} -f $${file} $(_MAKE_FLAGS_) ${2}) ; \
|
||||
;; \
|
||||
esac ; \
|
||||
return=$${?} && \
|
||||
if [ "$${directory}" != "." ] ; then \
|
||||
$(call env_perform, \
|
||||
$(_CD_) $${cwd}) ; \
|
||||
fi && \
|
||||
if [ $${return} -ne 0 ] ; then \
|
||||
$(_EXIT_) 42 ; \
|
||||
fi
|
||||
endef
|
||||
|
||||
#
|
||||
# from c file to preprocessed c file
|
||||
#
|
||||
# $(1): preprocessed file
|
||||
# $(2): c file
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_preprocess
|
||||
preprocess_options="" && \
|
||||
$(call env_display,green,PREPROCESS,$(2), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_CPP_) -P $(_CPP_FLAGS_) $${preprocess_options} $(2) -o $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# from c file to object file
|
||||
#
|
||||
# $(1): object file
|
||||
# $(2): c file
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_compile-c
|
||||
compile_c_options="" && \
|
||||
$(call env_display,green,COMPILE-C,$(2), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_CC_) $(_CC_FLAGS_) $${compile_c_options} -c $(2) -o $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# from lex file to c file
|
||||
#
|
||||
# $(1): c file
|
||||
# $(2): lex file
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_lex-l
|
||||
lex_l_options="" && \
|
||||
$(call env_display,green,LEX-L,$(2), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_LEX_) $${lex_l_options} $(2) > $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# from S file to object file
|
||||
#
|
||||
# $(1): object file
|
||||
# $(2): S file
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_assemble-S
|
||||
assemble_S_options="" && \
|
||||
$(call env_display,green,ASSEMBLE-S,$(2), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_CPP_) $(2) | $(_AS_) $(_ASM_FLAGS_) $${assemble_S_options} -o $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# create a static library from object files
|
||||
#
|
||||
# $(1): static library file name
|
||||
# $(2): object files
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_static-library
|
||||
static_library_options="" && \
|
||||
$(call env_display,magenta,STATIC-LIBRARY,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_AR_) $${static_library_options} $(1) $(2)) && \
|
||||
$(call env_perform, \
|
||||
$(_RANLIB_) $${static_library_options} $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# create a dynamic library from object files, static libraries
|
||||
# and/or dynamic libraries
|
||||
#
|
||||
# $(1): dynamic library file name
|
||||
# $(2): objects files and/or libraries
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_dynamic-library
|
||||
dynamic_library_options="" && \
|
||||
$(call env_display,magenta,DYNAMIC-LIBRARY,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_LD_) --shared $(_LD_FLAGS_) $${dynamic_library_options} \
|
||||
-o $(1) $(2))
|
||||
endef
|
||||
|
||||
#
|
||||
# create an executable file from object file and/or library files
|
||||
#
|
||||
# $(1): executable file name
|
||||
# $(2): objects files and/or libraries
|
||||
# $(3): layout file
|
||||
# $(4): options
|
||||
#
|
||||
|
||||
define env_executable
|
||||
executable_options="" && \
|
||||
if [ -n "$(3)" ] ; then \
|
||||
executable_options="$${executable_options} -T $(3)" ; \
|
||||
fi && \
|
||||
if [ -n "$(4)" ] ; then \
|
||||
if [ $$(( $(4) & $(ENV_OPTION_NO_STANDARD) )) -ne 0 ] ; then \
|
||||
executable_options="$${executable_options} -nostdinc -nostdlib" ; \
|
||||
fi ; \
|
||||
fi && \
|
||||
$(call env_display,magenta,EXECUTABLE,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_CC_) $(_CC_FLAGS_) $(_LD_FLAGS_) $${executable_options} -o $(1) \
|
||||
$(2) "`$(_CC_) -print-libgcc-file-name`")
|
||||
endef
|
||||
|
||||
#
|
||||
# create an archive file from multiple object files
|
||||
#
|
||||
# note that the archive file is also an object file
|
||||
#
|
||||
# $(1): archive file name
|
||||
# $(2): objects files and/or libraries
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_archive
|
||||
archive_options="" && \
|
||||
$(call env_display,magenta,ARCHIVE,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_LD_) -r $(_LD_FLAGS_) $${archive_options} -o $(1) $(2))
|
||||
endef
|
||||
|
||||
#
|
||||
# remove the files
|
||||
#
|
||||
# $(1): files
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_remove
|
||||
remove_options="" && \
|
||||
for f in $(1) ; do \
|
||||
if [ -e $${f} ] ; then \
|
||||
$(call env_display,red,REMOVE,$${f}, ,) ; \
|
||||
fi && \
|
||||
$(call env_perform, \
|
||||
$(_RM_) $${remove_options} $${f}) ; \
|
||||
done
|
||||
endef
|
||||
|
||||
#
|
||||
# purge i.e clean the directory from unwanted files
|
||||
#
|
||||
|
||||
define env_purge
|
||||
$(call env_display,red,PURGE,,,) && \
|
||||
$(call env_perform, \
|
||||
$(_PURGE_))
|
||||
endef
|
||||
|
||||
#
|
||||
# generate prototypes from a source file
|
||||
#
|
||||
# $(1): file list
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_prototypes
|
||||
prototypes_options="" && \
|
||||
for f in $(1) ; do \
|
||||
if [ -e $${f} ] ; then \
|
||||
$(call env_display,yellow,PROTOTYPES,$${f}, ,) && \
|
||||
$(call env_launch,$(_MKP_TOOL_), \
|
||||
$${prototypes_options} $${f},) ; \
|
||||
fi ; \
|
||||
done
|
||||
endef
|
||||
|
||||
#
|
||||
# genereate header dependencies
|
||||
#
|
||||
# $(1): the files for which the dependencies are generated
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_headers
|
||||
headers_options="" && \
|
||||
for f in $(1) ; do \
|
||||
if [ -e $${f} ] ; then \
|
||||
$(call env_display,yellow,HEADERS,$$f, ,) && \
|
||||
$(call env_perform, \
|
||||
$(_CC_) $(_CC_FLAGS_) -M -MG $${headers_options} \
|
||||
$${f} >> $(_DEPENDENCY_MK_)) ; \
|
||||
fi ; \
|
||||
done
|
||||
endef
|
||||
|
||||
#
|
||||
# generate a version file
|
||||
#
|
||||
# $(1): the version file to generate
|
||||
#
|
||||
|
||||
define env_version
|
||||
$(call env_display,yellow,VERSION,$(1), ,) && \
|
||||
$(_ECHO_) -n "" > $(1) && \
|
||||
$(_ECHO_) -n "const char version[] = \"$(_TITLE_)-$(_VERSION_)" >> $(1) && \
|
||||
$(_ECHO_) " "$(shell $(_DATE_))" $(USER)@$(HOSTNAME)\";" >> $(1)
|
||||
endef
|
||||
|
||||
#
|
||||
# create a link between two files
|
||||
#
|
||||
# $(1): link created
|
||||
# $(2): destination
|
||||
# $(3): options
|
||||
#
|
||||
|
||||
define env_link
|
||||
link_options="" && \
|
||||
$(call env_display,cyan,LINK,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_LN_) $${link_options} $(2) $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# compile a tex document
|
||||
#
|
||||
# $(1): the file name without extension
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_compile-tex
|
||||
compile_tex_options="" && \
|
||||
$(call env_display,green,COMPILE-TEX,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_PDFLATEX_) $${compile_tex_options} $(1)) && \
|
||||
$(call env_perform, \
|
||||
$(_PDFLATEX_) $${compile_tex_options} $(1)) && \
|
||||
$(call env_perform, \
|
||||
$(_BIBTEX_) $(1)) && \
|
||||
$(call env_perform, \
|
||||
$(_BIBTEX_) $(1)) && \
|
||||
$(call env_perform, \
|
||||
$(_PDFLATEX_) $${compile_tex_options} $(1)) ; \
|
||||
$(call env_perform, \
|
||||
$(_PDFLATEX_) $${compile_tex_options} $(1))
|
||||
endef
|
||||
|
||||
#
|
||||
# build a document
|
||||
#
|
||||
# $(1): the file name without extension
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_document
|
||||
$(call env_remove,$(_DEPENDENCY_TEX_),) && \
|
||||
if [ -n "$(2)" ] ; then \
|
||||
if [ $$(( $(2) & $(ENV_OPTION_PRIVATE) )) -ne 0 ] ; then \
|
||||
$(_ECHO_) '\def\mode{private}' > $(_DEPENDENCY_TEX_) ; \
|
||||
fi ; \
|
||||
fi && \
|
||||
if [ ! -f $(_DEPENDENCY_TEX_) ] ; then \
|
||||
$(_ECHO_) '\def\mode{public}' > $(_DEPENDENCY_TEX_) ; \
|
||||
fi && \
|
||||
$(call env_compile-tex,$(1),$(2))
|
||||
endef
|
||||
|
||||
#
|
||||
# launch a document viewer
|
||||
#
|
||||
# $(1): the file name without extension
|
||||
# $(2): options
|
||||
#
|
||||
|
||||
define env_view
|
||||
$(call env_display,yellow,VIEW,$(1), ,) && \
|
||||
$(call env_perform, \
|
||||
$(_XPDF_) $(1).pdf)
|
||||
endef
|
||||
|
||||
#
|
||||
# ---------- component-based behaviour ----------------------------------------
|
||||
#
|
||||
|
||||
#
|
||||
# kaneton
|
||||
#
|
||||
|
||||
ifneq ($(call findstring,kaneton,$(components)),)
|
||||
_CC_FLAGS_ += -D___kaneton$$\kernel
|
||||
endif
|
||||
239
environment/profile/host/linux/linux.py
Normal file
239
environment/profile/host/linux/linux.py
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/kaneton/environment/profile/host/linux/linux.py
|
||||
#
|
||||
# created julien quintard [tue may 8 13:20:21 2007]
|
||||
# updated julien quintard [sat mar 5 09:13:35 2011]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- information ------------------------------------------------------
|
||||
#
|
||||
# this file implements the remaining functions of the kaneton python interface.
|
||||
#
|
||||
# note that the host profile already provides many functions. these
|
||||
# functions can be overriden but you will probably just use them.
|
||||
#
|
||||
# in addition, the host profile already imports some packages.
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- lang -------------------------------------------------------------
|
||||
#
|
||||
# incorrect locales may prevent the system from compiling properly.
|
||||
#
|
||||
# the following forces the LANG environment variable to US.
|
||||
#
|
||||
os.putenv("LANG", "US")
|
||||
|
||||
#
|
||||
# ---------- python path ------------------------------------------------------
|
||||
#
|
||||
|
||||
_pythonpath_ = os.getenv("PYTHONPATH")
|
||||
|
||||
if not _pythonpath_:
|
||||
os.putenv("PYTHONPATH", _PYTHON_INCLUDE_DIR_)
|
||||
else:
|
||||
os.putenv("PYTHONPATH", _pythonpath_ + ":" + _PYTHON_INCLUDE_DIR_)
|
||||
|
||||
#
|
||||
# ---------- functions --------------------------------------------------------
|
||||
#
|
||||
|
||||
#
|
||||
# colorize()
|
||||
#
|
||||
# this function returns a colorized text if the environment is configured
|
||||
# to or simply the original text.
|
||||
#
|
||||
# note that this function implementation is based on UNIX escape sequences.
|
||||
#
|
||||
def colorize(text, color, options):
|
||||
if _DISPLAY_ == _DISPLAY_UNCOLORED_:
|
||||
return text
|
||||
|
||||
if options & OPTION_FLICKERING:
|
||||
text = "[05m" + text
|
||||
if options & OPTION_BOLD:
|
||||
text = "[01m" + text
|
||||
|
||||
if color == COLOR_BLACK:
|
||||
text = "[30m" + text
|
||||
elif color == COLOR_RED:
|
||||
text = "[31m" + text
|
||||
elif color == COLOR_GREEN:
|
||||
text = "[32m" + text
|
||||
elif color == COLOR_YELLOW:
|
||||
text = "[33m" + text
|
||||
elif color == COLOR_BLUE:
|
||||
text = "[34m" + text
|
||||
elif color == COLOR_MAGENTA:
|
||||
text = "[35m" + text
|
||||
elif color == COLOR_CYAN:
|
||||
text = "[36m" + text
|
||||
elif color == COLOR_WHITE:
|
||||
text = "[37m" + text
|
||||
|
||||
return text + "[39;49;00m"
|
||||
|
||||
|
||||
|
||||
#
|
||||
# launch()
|
||||
#
|
||||
# this function launch a new program/script/make etc.
|
||||
#
|
||||
def launch(file, arguments, options):
|
||||
directory = None
|
||||
info = None
|
||||
status = 0
|
||||
wd = None
|
||||
|
||||
if options & OPTION_QUIET:
|
||||
output = " >/dev/null 2>&1"
|
||||
else:
|
||||
output = ""
|
||||
|
||||
info = os.path.split(file)
|
||||
|
||||
directory = info[0]
|
||||
file = info[1]
|
||||
|
||||
if directory:
|
||||
wd = cwd(OPTION_NONE)
|
||||
cd(directory, OPTION_NONE)
|
||||
|
||||
if re.match("^.*\.sh$", file):
|
||||
status = os.system(_SHELL_ + " " + file + " " + arguments + output)
|
||||
elif re.match("^.*\.py$", file):
|
||||
status = os.system(_PYTHON_ + " " + file + " " + arguments + output)
|
||||
elif re.match("^.*\.pl$", file):
|
||||
status = os.system(_PERL_ + " " + file + " " + arguments + output)
|
||||
elif re.match("^Makefile$", file):
|
||||
status = os.system(_MAKE_ + " -f " + file + " " + arguments + output)
|
||||
else:
|
||||
if directory:
|
||||
file = "./" + file
|
||||
|
||||
status = os.system(file + " " + arguments + output)
|
||||
|
||||
if directory:
|
||||
cd(wd, OPTION_NONE)
|
||||
|
||||
return status
|
||||
|
||||
|
||||
|
||||
#
|
||||
# pack()
|
||||
#
|
||||
# this function creates an archive of the given directory.
|
||||
#
|
||||
def pack(directory, file, options):
|
||||
launch(_TAR_, "-cjf " + file + " " + directory, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# unpack()
|
||||
#
|
||||
# this function unpackages an archive into the given (optional) directory.
|
||||
#
|
||||
def unpack(file, directory, options):
|
||||
if directory:
|
||||
launch(_TAR_, "-xjf " + file + " -C " + directory, OPTION_NONE)
|
||||
else:
|
||||
launch(_TAR_, "-xjf " + file, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# load()
|
||||
#
|
||||
# this function copies a file on a device, this device can be virtual:
|
||||
# an image.
|
||||
#
|
||||
def load(file, device, path, options):
|
||||
if options == OPTION_DEVICE:
|
||||
return launch(_MCOPY_, "-o -n " + file + " " + device + path,
|
||||
OPTION_NONE)
|
||||
elif options == OPTION_IMAGE:
|
||||
return launch(_MCOPY_, "-o -n " + "-i" + device + " " +
|
||||
file + " ::" + path, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# record()
|
||||
#
|
||||
# this function runs the program recording a session.
|
||||
#
|
||||
def record(transcript, options):
|
||||
directory = None
|
||||
time = None
|
||||
log = None
|
||||
tmp = None
|
||||
wd = None
|
||||
|
||||
tmp = temporary(OPTION_DIRECTORY)
|
||||
|
||||
directory = tmp + "/" + "transcript"
|
||||
|
||||
log = directory + "/" + "log"
|
||||
time = directory + "/" + "time"
|
||||
|
||||
mkdir(directory, OPTION_NONE)
|
||||
|
||||
launch(_SCRIPT_, "-q -t " + log + " -c " +
|
||||
_TRANSCRIPT_CMD_ + " 2> " + time, OPTION_NONE)
|
||||
|
||||
wd = cwd(OPTION_NONE)
|
||||
|
||||
cd(tmp, OPTION_NONE)
|
||||
|
||||
pack("transcript", wd + "/" + transcript, OPTION_NONE)
|
||||
|
||||
cd(wd, OPTION_NONE)
|
||||
|
||||
remove(tmp, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# play()
|
||||
#
|
||||
# this function runs the program replaying a session.
|
||||
#
|
||||
def play(transcript, options):
|
||||
directory = None
|
||||
time = None
|
||||
log = None
|
||||
tmp = None
|
||||
wd = None
|
||||
|
||||
tmp = temporary(OPTION_DIRECTORY)
|
||||
|
||||
log = tmp + "/" + "transcript/log"
|
||||
time = tmp + "/" + "transcript/time"
|
||||
|
||||
unpack(transcript, tmp, OPTION_NONE)
|
||||
|
||||
launch(_REPLAY_TOOL_, time + " " + log, OPTION_NONE)
|
||||
|
||||
remove(tmp, OPTION_NONE)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# locate()
|
||||
#
|
||||
# this function tries to locate a program on the system.
|
||||
#
|
||||
def locate(file, options):
|
||||
return launch(_WHICH_, file + " 1>/dev/null 2>/dev/null", OPTION_NONE)
|
||||
Reference in a new issue