From 99853361819bff87e7cf8103c5205721ec195c32 Mon Sep 17 00:00:00 2001 From: umarcor Date: Tue, 5 Jan 2021 20:46:15 +0100 Subject: mv dist/* scripts/ --- scripts/ansi_color.sh | 18 + scripts/ci-run.sh | 493 ++++++++++++++ scripts/gcc/Make-lang.in | 218 +++++++ scripts/gcc/config-lang.in | 36 ++ scripts/gcc/lang-options.h | 29 + scripts/gcc/lang-specs.h | 28 + scripts/macosx/install-ada.sh | 60 ++ scripts/man.sh | 15 + scripts/msys2-llvm/PKGBUILD | 34 + scripts/msys2-mcode/PKGBUILD | 31 + scripts/termux.sh | 15 + scripts/windows/InstallerTemplate.ps1 | 359 ++++++++++ scripts/windows/appveyor/build.ps1 | 112 ++++ scripts/windows/appveyor/info.ps1 | 68 ++ scripts/windows/appveyor/install.ps1 | 39 ++ scripts/windows/appveyor/shared.psm1 | 49 ++ scripts/windows/appveyor/test.ps1 | 121 ++++ scripts/windows/compile-ghdl.ps1 | 243 +++++++ scripts/windows/compile-libraries.ps1 | 862 +++++++++++++++++++++++++ scripts/windows/compile.ps1 | 765 ++++++++++++++++++++++ scripts/windows/mcode/Makefile.in | 54 ++ scripts/windows/mcode/binary_file-format.ads | 3 + scripts/windows/mcode/compile.bat | 31 + scripts/windows/mcode/complib.bat | 119 ++++ scripts/windows/mcode/default_paths.ads | 9 + scripts/windows/mcode/ghdl.nsi | 458 +++++++++++++ scripts/windows/mcode/ghdlfilter.adb | 132 ++++ scripts/windows/mcode/ghdlversion.adb | 30 + scripts/windows/mcode/grt-backtraces-impl.ads | 3 + scripts/windows/mcode/grt-modules.adb | 39 ++ scripts/windows/mcode/ortho_code-x86-flags.ads | 2 + scripts/windows/mcode/winbuild.bat | 20 + scripts/windows/mcode/windows_default_path.adb | 68 ++ scripts/windows/mcode/windows_default_path.ads | 30 + scripts/windows/shared.psm1 | 368 +++++++++++ scripts/windows/targets.psm1 | 416 ++++++++++++ 36 files changed, 5377 insertions(+) create mode 100644 scripts/ansi_color.sh create mode 100755 scripts/ci-run.sh create mode 100644 scripts/gcc/Make-lang.in create mode 100644 scripts/gcc/config-lang.in create mode 100644 scripts/gcc/lang-options.h create mode 100644 scripts/gcc/lang-specs.h create mode 100755 scripts/macosx/install-ada.sh create mode 100755 scripts/man.sh create mode 100644 scripts/msys2-llvm/PKGBUILD create mode 100644 scripts/msys2-mcode/PKGBUILD create mode 100755 scripts/termux.sh create mode 100644 scripts/windows/InstallerTemplate.ps1 create mode 100644 scripts/windows/appveyor/build.ps1 create mode 100644 scripts/windows/appveyor/info.ps1 create mode 100644 scripts/windows/appveyor/install.ps1 create mode 100644 scripts/windows/appveyor/shared.psm1 create mode 100644 scripts/windows/appveyor/test.ps1 create mode 100644 scripts/windows/compile-ghdl.ps1 create mode 100644 scripts/windows/compile-libraries.ps1 create mode 100644 scripts/windows/compile.ps1 create mode 100644 scripts/windows/mcode/Makefile.in create mode 100644 scripts/windows/mcode/binary_file-format.ads create mode 100644 scripts/windows/mcode/compile.bat create mode 100644 scripts/windows/mcode/complib.bat create mode 100644 scripts/windows/mcode/default_paths.ads create mode 100644 scripts/windows/mcode/ghdl.nsi create mode 100644 scripts/windows/mcode/ghdlfilter.adb create mode 100644 scripts/windows/mcode/ghdlversion.adb create mode 100644 scripts/windows/mcode/grt-backtraces-impl.ads create mode 100644 scripts/windows/mcode/grt-modules.adb create mode 100644 scripts/windows/mcode/ortho_code-x86-flags.ads create mode 100644 scripts/windows/mcode/winbuild.bat create mode 100644 scripts/windows/mcode/windows_default_path.adb create mode 100644 scripts/windows/mcode/windows_default_path.ads create mode 100644 scripts/windows/shared.psm1 create mode 100644 scripts/windows/targets.psm1 (limited to 'scripts') diff --git a/scripts/ansi_color.sh b/scripts/ansi_color.sh new file mode 100644 index 000000000..bb5c348bc --- /dev/null +++ b/scripts/ansi_color.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +enable_color() { + ENABLECOLOR='-c ' + ANSI_RED="\033[31m" + ANSI_GREEN="\033[32m" + ANSI_YELLOW="\033[33m" + ANSI_BLUE="\033[34m" + ANSI_MAGENTA="\033[35m" + ANSI_GRAY="\033[90m" + ANSI_CYAN="\033[36;1m" + ANSI_DARKCYAN="\033[36m" + ANSI_NOCOLOR="\033[0m" +} + +disable_color() { unset ENABLECOLOR ANSI_RED ANSI_GREEN ANSI_YELLOW ANSI_BLUE ANSI_MAGENTA ANSI_CYAN ANSI_DARKCYAN ANSI_NOCOLOR; } + +enable_color diff --git a/scripts/ci-run.sh b/scripts/ci-run.sh new file mode 100755 index 000000000..cee5d05e2 --- /dev/null +++ b/scripts/ci-run.sh @@ -0,0 +1,493 @@ +#! /bin/bash + +scriptdir=`dirname $0` + +if [ -n "$GITHUB_EVENT_PATH" ]; then + export CI=true +fi + +. "$scriptdir/ansi_color.sh" +disable_color + +print_start() { + COL="$ANSI_YELLOW" + if [ "x$2" != "x" ]; then + COL="$2" + fi + printf "${COL}${1}$ANSI_NOCOLOR\n" +} + +gstart () { + print_start "$@" +} +gend () { + : +} + +if [ -n "$TRAVIS" ]; then + echo "INFO: set 'gstart' and 'gend' for TRAVIS" + # This is a trimmed down copy of https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/* + travis_time_start() { + # `date +%N` returns the date in nanoseconds. It is used as a replacement for $RANDOM, which is only available in bash. + travis_timer_id=`date +%N` + travis_start_time=`travis_nanoseconds` + echo "travis_time:start:$travis_timer_id" + } + travis_time_finish() { + travis_end_time=`travis_nanoseconds` + local duration=$(($travis_end_time-$travis_start_time)) + echo "travis_time:end:$travis_timer_id:start=$travis_start_time,finish=$travis_end_time,duration=$duration" + } + + if [ "$TRAVIS_OS_NAME" = "osx" ]; then + travis_nanoseconds() { + date -u '+%s000000000' + } + else + travis_nanoseconds() { + date -u '+%s%N' + } + fi + + gstart () { + echo "travis_fold:start:group" + travis_time_start + print_start "$@" + } + + gend () { + travis_time_finish + echo "travis_fold:end:group" + } +else + if [ -n "$CI" ]; then + echo "INFO: set 'gstart' and 'gend' for CI" + gstart () { + printf '::group::' + print_start "$@" + SECONDS=0 + } + + gend () { + duration=$SECONDS + echo '::endgroup::' + printf "${ANSI_GRAY}took $(($duration / 60)) min $(($duration % 60)) sec.${ANSI_NOCOLOR}\n" + } + fi +fi + +echo "cliargs: $0 $@" + +# Stop in case of error +set -e + +ISGPL=false +ISSYNTH=true + +# Transform long options to short ones +for arg in "$@"; do + shift + case "$arg" in + "--color"|"-color") set -- "$@" "-c";; + "--backend"|"-backend") set -- "$@" "-b";; + "--pkg"|"-pkg") set -- "$@" "-p";; + "--gpl"|"-gpl") set -- "$@" "-g";; + "--no-synth"|"-no-synth") set -- "$@" "-s";; + *) set -- "$@" "$arg" + esac +done +# Parse args +while getopts ":b:p:cgs" opt; do + case $opt in + c) enable_color;; + b) BACK=$OPTARG ;; + p) PKG_NAME=$OPTARG;; + g) ISGPL=true;; + s) ISSYNTH=false;; + \?) printf "$ANSI_RED[CI - args] Invalid option: -$OPTARG $ANSI_NOCOLOR\n" >&2 + exit 1 ;; + :) printf "$ANSI_RED[CI - args] Option -$OPTARG requires an argument. $ANSI_NOCOLOR\n" >&2 + exit 1 ;; + esac +done +shift $((OPTIND -1)) + +#--- + +# +# Build command options +# + +notag() { + # No tag: use date + commit id + echo "`git log -1 --date=short --pretty=format:%cd | sed 's/-//g'`-$PKG_SHA" +} + +vertag() { + if expr "$1" : 'v[0-9].*' > /dev/null; then + # Check version defined in configure. + cfgver=`grep "^ghdl_version=" configure | sed -e 's/.*"\(.*\)"/\1/'` + if [ "x$1" != "xv$cfgver" ]; then + printf "${ANSI_RED}Tag '$1' does not match configure 'ghdl_version' ($cfgver)!${ANSI_NOCOLOR}\n" 1>&2; + exit 1 + fi + # Remove leading 'v' in tags in the filenames. + echo $1 | cut -c2- + else + # Regular tag (like snapshots), nothing to change. + echo "$1" + fi +} + +buildCmdOpts () { + BUILD_ARG="$1" + + # Get short commit SHA + if [ -n "$TRAVIS_COMMIT" ]; then + GIT_SHA="$TRAVIS_COMMIT" + fi + if [ -n "$GITHUB_SHA" ]; then + GIT_SHA="$GITHUB_SHA" + fi + if [ -z "$GIT_SHA" ]; then + GIT_SHA="`git rev-parse --verify HEAD`" + fi + PKG_SHA="`printf $GIT_SHA | cut -c1-10`" + + echo "TRAVIS_COMMIT: $TRAVIS_COMMIT" + echo "TRAVIS_TAG: $TRAVIS_TAG" + echo "GITHUB_SHA: $GITHUB_SHA" + echo "GITHUB_REF: $GITHUB_REF" + echo "GIT_SHA: $GIT_SHA" + + # Compute package name + case "$GITHUB_REF" in + *tags*) + PKG_TAG="$(vertag "`echo "$GITHUB_REF" | sed 's#^refs/tags/\(.*\)#\1#g'`")" + ;; + *heads*|*pull*) + PKG_TAG="`notag`" + ;; + "") + if [ -z "$TRAVIS_TAG" ]; then + PKG_TAG="`notag`" + else + PKG_TAG="`vertag "$TRAVIS_TAG"`" + fi + ;; + *) + PKG_TAG="$GITHUB_REF" + ;; + esac + + echo "PKG_SHA: $PKG_SHA" + echo "PKG_TAG: $PKG_TAG" + + # Extract from BUILD_ARG + IFS='+' read -ra REFS <<< "$BUILD_ARG" + DDIST=${REFS[0]} # Linux distro (eg: ubuntuXX, fedoraXX) + DBACK=${REFS[1]} # Build/backend (eg: mcode, llvm) + + PKG_NAME="ghdl-${PKG_TAG}-${DDIST}-${DBACK}" + BUILD_CMD_OPTS="$ENABLECOLOR -b $DBACK" + + if [ "x$ISGPL" = "xtrue" ]; then + BUILD_CMD_OPTS="$BUILD_CMD_OPTS --gpl" + PKG_NAME="${PKG_NAME}-gpl" + DEXT="-gpl" + fi + export BUILD_CMD_OPTS="${BUILD_CMD_OPTS} -p $PKG_NAME" + + GHDL_IMAGE_TAG="`echo $BUILD_ARG | sed -e 's/+/-/g'`" + BUILD_IMAGE_TAG="$GHDL_IMAGE_TAG" + + case $BUILD_ARG in + *gcc*) + BUILD_IMAGE_TAG="`echo $GHDL_IMAGE_TAG | sed 's#\(.*\)-gcc.*#\1-gcc#g'`" + ;; + esac + + GHDL_IMAGE_TAG="${GHDL_IMAGE_TAG}$DEXT" +} + +run_cmd() { + echo "$@" + "$@" +} + +# +# Build ghdl +# + +build () { + rm -f build_ok + + #--- Env + + gstart "[GHDL - build] Environment" + env + gend + + #--- GPL: gpl-ize sources + + if [ "$ISGPL" = "true" ]; then + GPLDIR="${PKG_NAME}.src" + gstart "[GHDL - build] create GPL source package (${ANSI_CYAN}${GPLDIR}.tgz${ANSI_NOCOLOR})" + files=`echo *` + make -f Makefile.in srcdir=. clean-pure-gpl + mkdir "$GPLDIR" + cp -pdrl $files "$GPLDIR" + tar -zcf "${GPLDIR}.tgz" "$GPLDIR" + gend + fi + + #--- Configure + + CDIR=`pwd` + INSTALL_DIR="$CDIR/install-$BACK" + mkdir "$INSTALL_DIR" + mkdir "build-$BACK" + cd "build-$BACK" + + if [ "x$ISSYNTH" = "xfalse" ]; then + CONFIG_OPTS+=" --disable-synth" + fi + + case "$BACK" in + gcc*) + gstart "[GHDL - build] Get gcc sources" + gccURL="https://codeload.github.com/gcc-mirror/gcc/tar.gz/releases/${BACK}" + echo "$gccURL" + mkdir gcc-srcs + curl -L "$gccURL" | tar -xz -C gcc-srcs --strip-components=1 + cd gcc-srcs + sed -i.bak s/ftp:/http:/g ./contrib/download_prerequisites + ./contrib/download_prerequisites + cd .. + gend + + gstart "[GHDL - build] Configure ghdl" + run_cmd ../configure --with-gcc=gcc-srcs $CONFIG_OPTS + gend + gstart "[GHDL - build] Copy sources" + make copy-sources + mkdir gcc-objs; cd gcc-objs + gend + gstart "[GHDL - build] Configure gcc" + run_cmd ../gcc-srcs/configure --enable-languages=c,vhdl --disable-bootstrap --disable-lto --disable-multilib --disable-libssp --disable-libgomp --disable-libquadmath "`gcc -v 2>&1 | grep -o -- --enable-default-pie`" + gend + ;; + mcode) + CXX="" + ;; + llvm) + CXX="clang++" + CONFIG_OPTS+=" --with-llvm-config CXX=$CXX" + ;; + llvm-3.5) + CXX="clang++" + CONFIG_OPTS+=" --with-llvm-config=llvm-config-3.5 CXX=$CXX" + ;; + llvm-*) + llvmver=`echo $BACK | sed -e "s/llvm-//"` + CXX="clang++-$llvmver" + CONFIG_OPTS+=" --with-llvm-config=llvm-config-$llvmver CXX=$CXX" + ;; + *) + printf "$ANSI_RED[GHDL - build] Unknown build $BACK $ANSI_NOCOLOR\n" + exit 1;; + esac + + if [ ! "`echo $BACK | grep gcc`" ]; then + gstart "[GHDL - build] Configure" + run_cmd ../configure $CONFIG_OPTS + gend + fi + + #--- make + + gstart "[GHDL - build] Make" + set +e + make LIB_CFLAGS="$LIB_CFLAGS" OPT_FLAGS="$OPT_FLAGS" -j`nproc` 2>make_err.log + tail -1000 make_err.log + set -e + gend + + gstart "[GHDL - build] Install" + make DESTDIR="$INSTALL_DIR" install + cd .. + gend + + if [ "`echo $BACK | grep gcc`" ]; then + gstart "[GHDL - build] Make ghdllib" + make DESTDIR="$INSTALL_DIR" ghdllib + gend + + gstart "[GHDL - build] Install ghdllib" + make DESTDIR="$INSTALL_DIR" install + cd .. + gend + fi + + #--- package + + gstart "[GHDL - build] Create package ${ANSI_DARKCYAN}${PKG_NAME}.tgz" + tar -zcvf "${PKG_NAME}.tgz" -C "$INSTALL_DIR/usr/local" . + gend + + #--- build tools versions + + { + make --version | grep 'Make' + gnatls --version | grep 'GNATLS' + gcc --version | grep 'gcc' + if [ "$CXX" != "" ]; then + $CXX --version | grep 'clang' + fi + } > BUILD_TOOLS + + #--- + + printf "$ANSI_GREEN[GHDL - build] SUCCESSFUL${ANSI_NOCOLOR}\n" + touch build_ok +} + +# +# Build ghdl/ghdl image +# + +build_img_ghdl() { + gstart "[DOCKER - build] ghdl/ghdl:${GHDL_IMAGE_TAG}" "$ANSI_BLUE" + docker build -t ghdl/ghdl:$GHDL_IMAGE_TAG . -f-< tmp-dpaths.ads + echo "-- This file is created by Makefile" >> tmp-dpaths.ads + echo "package Default_Paths is" >> tmp-dpaths.ads + echo " -- Accept long lines." >> tmp-dpaths.ads + echo " pragma Style_Checks (\"M999\");" >> tmp-dpaths.ads + echo " Install_Prefix : constant String :=" >> tmp-dpaths.ads + echo " \"$(exec_prefix)\";" >> tmp-dpaths.ads + suffix=`expr @"$(libexecdir)" : @"$(prefix)/\(.*\)"`; \ + if test x"$$suffix" = x; then suffix="$(libexecdir)"; fi; \ + echo " Compiler_Gcc : constant String :=" >> tmp-dpaths.ads; \ + echo " \"$$suffix/gcc/$(target_noncanonical)/$(version)/ghdl1$(exeext)\";" >> tmp-dpaths.ads + echo " Compiler_Debug : constant String := \"\";" >> tmp-dpaths.ads + echo " Compiler_Mcode : constant String := \"\";" >> tmp-dpaths.ads + echo " Compiler_Llvm : constant String := \"\";" >> tmp-dpaths.ads + echo " Post_Processor : constant String := \"\";" >> tmp-dpaths.ads + echo " Lib_Prefix : constant String :=">> tmp-dpaths.ads + echo " \"lib/ghdl\";" >> tmp-dpaths.ads + echo " Shared_Library_Extension : constant String :=">> tmp-dpaths.ads + echo " \"$(VHDL_SOEXT)\";" >> tmp-dpaths.ads + echo " Default_Pie : constant Boolean := False;" >> tmp-dpaths.ads + echo "end Default_Paths;" >> tmp-dpaths.ads + $(srcdir)/../move-if-change tmp-dpaths.ads $@ + +GHDL_GRT_OBJS=vhdl/grt-cstdio.o + +# The driver for ghdl. Depends on ghdl1 to use object files in vhdl/ subdir. +ghdl$(exeext): ghdl1$(exeext) $(GHDL_GRT_OBJS) vhdl/default_paths.ads force + $(GNATMAKE) -o $@ -aI$(srcdir)/vhdl -aI$(srcdir)/vhdl/ghdldrv \ + -aIvhdl -aOvhdl ghdl_gcc \ + -cargs $(CFLAGS) $(GHDL_ADAFLAGS) \ + -bargs -E \ + -largs --LINK=$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) \ + $(GHDL_GRT_OBJS) $(LIBS) + +# Build hooks: + +vhdl.all.build: + +vhdl.all.cross: + @echo "No support for building vhdl cross-compiler" + exit 1 + +vhdl.start.encap: +vhdl.rest.encap: + +# Documentation hooks +doc/ghdl.info: vhdl/ghdl.texi + -rm -f doc/ghdl.info* + $(MAKEINFO) $(MAKEINFOFLAGS) -o $@ $< + +doc/ghdl.dvi: vhdl/ghdl.texi + $(TEXI2DVI) -o $@ $< + +vhdl.info: doc/ghdl.info + +vhdl.man: + +vhdl.dvi: doc/ghdl.dvi + +vhdl.generated-manpages: + +# Install hooks: +# ghdl1 is installed elsewhere as part of $(COMPILERS). + +vhdl.install-normal: + +vhdl.install-plugin: + +# Install the driver program as ghdl. +vhdl.install-common: ghdl$(exeext) ghdl1$(exeext) + -mkdir $(DESTDIR)$(bindir) + -$(RM) $(DESTDIR)$(bindir)/ghdl$(exeext) + $(INSTALL_PROGRAM) ghdl$(exeext) $(DESTDIR)$(bindir)/ghdl$(exeext) + -mkdir $(DESTDIR)$(libdir) + -mkdir $(DESTDIR)$(libdir)/ghdl + $(INSTALL_DATA) ../libbacktrace/.libs/libbacktrace.a $(DESTDIR)$(libdir)/ghdl + +install-info:: $(DESTDIR)$(infodir)/ghdl.info + +vhdl.install-info: $(DESTDIR)$(infodir)/ghdl.info + +vhdl.install-man: $(DESTDIR)$(man1dir)/ghdl$(man1ext) + +$(DESTDIR)$(man1dir)/ghdl$(man1ext): $(srcdir)/vhdl/ghdl.1 + -rm -f $@ + -$(INSTALL_DATA) $< $@ + -chmod a-x $@ + +vhdl.uninstall: + -$(RM) $(DESTDIR)$(bindir)/ghdl$(exeext) + + +# Clean hooks: +# A lot of the ancillary files are deleted by the main makefile. +# We just have to delete files specific to us. + +vhdl.mostlyclean: + -$(RM) vhdl/*$(objext) vhdl/*.ali vhdl/b~*.ad? + -$(RM) vhdl/default_paths.ads +vhdl.clean: + -$(RM) vhdl/*$(objext) + -$(RM) vhdl/default_paths.ads +vhdl.distclean: + -$(RM) vhdl/Makefile + -$(RM) ghdl$(exeext) +vhdl.extraclean: + +vhdl.maintainer-clean: + + +# Stage hooks: +# The main makefile has already created stage?/vhdl + +vhdl.stage1: + -$(MV) vhdl/*$(objext) vhdl/*.ali vhdl/b_*.c stage1/vhdl + -$(MV) vhdl/stamp-* stage1/vhdl +vhdl.stage2: + -$(MV) vhdl/*$(objext) vhdl/*.ali vhdl/b_*.c stage2/vhdl + -$(MV) vhdl/stamp-* stage2/vhdl +vhdl.stage3: + -$(MV) vhdl/*$(objext) vhdl/*.ali vhdl/b_*.c stage3/vhdl + -$(MV) vhdl/stamp-* stage3/vhdl +vhdl.stage4: + -$(MV) vhdl/*$(objext) vhdl/*.ali vhdl/b_*.c stage4/vhdl + -$(MV) vhdl/stamp-* stage4/vhdl + +# No vhdl-specific selftests +selftest-vhdl: diff --git a/scripts/gcc/config-lang.in b/scripts/gcc/config-lang.in new file mode 100644 index 000000000..3ce9851f3 --- /dev/null +++ b/scripts/gcc/config-lang.in @@ -0,0 +1,36 @@ +# Top level configure fragment for GNU vhdl (GHDL). +# Copyright (C) 1994-2001 Free Software Foundation, Inc. + +#This file is part of GNU CC. + +#GNU CC is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 2, or (at your option) +#any later version. + +#GNU CC is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. + +#You should have received a copy of the GNU General Public License +#along with GNU CC; see the file COPYING. If not, write to +#the Free Software Foundation, 59 Temple Place - Suite 330, +#Boston, MA 02111-1307, USA. + +# Configure looks for the existence of this file to auto-config each language. +# We define several parameters used by configure: +# +# language - name of language as it would appear in $(LANGUAGES) +# boot_language - "yes" if we need to build this language in stage1 +# compilers - value to add to $(COMPILERS) +# stagestuff - files to add to $(STAGESTUFF) + +language="vhdl" +boot_language=no + +compilers="ghdl1\$(exeext)" + +stagestuff="ghdl\$(exeext) ghdl1\$(exeext)" + +gtfiles="\$(srcdir)/vhdl/ortho-lang.c" diff --git a/scripts/gcc/lang-options.h b/scripts/gcc/lang-options.h new file mode 100644 index 000000000..c92b12132 --- /dev/null +++ b/scripts/gcc/lang-options.h @@ -0,0 +1,29 @@ +/* Definitions for switches for vhdl. + Copyright (C) 2002 + Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +DEFINE_LANG_NAME ("vhdl") + +/* This is the contribution to the `lang_options' array in gcc.c for ghdl. */ + + {"--ghdl-", "Specify options to GHDL"}, + + + diff --git a/scripts/gcc/lang-specs.h b/scripts/gcc/lang-specs.h new file mode 100644 index 000000000..050443521 --- /dev/null +++ b/scripts/gcc/lang-specs.h @@ -0,0 +1,28 @@ +/* Definitions for specs for vhdl. + Copyright (C) 2002 + Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This is the contribution to the `default_compilers' array in gcc.c for + GHDL. */ + + {".vhd", "@vhdl", 0, 0, 0}, + {".vhdl", "@vhdl", 0, 0, 0}, + {"@vhdl", + "ghdl1 %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}", 0, 0, 0}, diff --git a/scripts/macosx/install-ada.sh b/scripts/macosx/install-ada.sh new file mode 100755 index 000000000..760be908b --- /dev/null +++ b/scripts/macosx/install-ada.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -e + +if [ -e gnat/etc/install_ok ] && [ "x$(cat gnat/etc/install_ok)" = "x2019" ]; then + echo "gnatgpl already installed" + exit 0 +fi + +echo "Download and install gnat-gpl" +set -x + +# Remove old gnat directory +if [ -d gnat ]; then + rm -rf gnat +fi + +# Download from community.adacore.com and extract +wget -O dmgfile https://community.download.adacore.com/v1/5a7801fc686e86de838cfaf7071170152d81254d?filename=gnat-community-2019-20190517-x86_64-darwin-bin.dmg +7z x dmgfile +installer="gnat-community-2019-20190517-x86_64-darwin-bin/gnat-community-2019-20190517-x86_64-darwin-bin.app/Contents/MacOS/gnat-community-2019-20190517-x86_64-darwin-bin" + +# Install +mkdir -p gnat +chmod +x $installer +./$installer PREFIX=gnat + +# Cleanup: remove components not needed +rm -rf gnat/share/{themes,icons} \ + gnat/share/{man,info,doc,examples,gpr,gprconfig,gnatcoll} \ + gnat/share/gps \ + gnat/share/gdb* gnat/share/glib* gnat/share/gcc-*/python \ + gnat/etc/fonts gnat/etc/gtk* \ + gnat/include/{asis,aunit,gnat_util,gnatcoll,gpr,xmlada} \ + gnat/include/aws* gnat/include/pycairo gnat/include/python* \ + gnat/include/pygobject* gnat/include/gdb \ + gnat/include/c++ \ + gnat/lib/{aunit,gnat,gnat_util,gnatcoll,gpr,gps,xmlada} \ + gnat/lib/aws* gnat/lib/girepository* gnat/lib/gtk* \ + gnat/lib/python* \ + gnat/lib/gcc/x86*/*/{gcc-include,plugin,install-tools} \ + gnat/lib/gcc/x86*/*/rts-ios-simulator \ + gnat/lib/gcc/x86*/*/rts-native/adalib/lib*.dSYM \ + gnat/lib/gcc/x86*/*/rts-native/adalib/*.dylib \ + gnat/lib/gcc/x86*/*/rts-native/adalib/lib*_pic.a \ + gnat/libexec/gprbuild \ + gnat/libexec/gcc/x86*/*/{plugin,install-tools} \ + gnat/bin/aws* gnat/bin/gps* gnat/bin/gcov* \ + gnat/bin/gnat2* gnat/bin/xml2* gnat/bin/gnatcoll* \ + gnat/bin/gnat{doc,metric,pp,stub,prep,test,check,elim,inspect,find,kr} \ + gnat/bin/gnat{xref,name} \ + gnat/bin/gpr* gnat/bin/templates* gnat/bin/web* gnat/bin/wsdl* \ + gnat/bin/{gdb,cpp,c++,g++} gnat/bin/x86_64-* \ + gnat/lib/libcc1* gnat/lib/libgomp* gnat/lib/libitm* gnat/lib/libasan* \ + gnat/lib/libatomic* gnat/lib/libobjc* gnat/lib/libssp* \ + gnat/lib/libstdc++* gnat/lib/libubsan* gnat/lib/libsupc++* \ + gnat/lib/libxmlada* \ + gnat/libexec/gcc/x86*/*/{cc1obj,cc1plus,lto1} + +echo "2019" > gnat/etc/install_ok diff --git a/scripts/man.sh b/scripts/man.sh new file mode 100755 index 000000000..4c5316ddb --- /dev/null +++ b/scripts/man.sh @@ -0,0 +1,15 @@ +#! /bin/bash + +cd $(dirname $0)/.. + +rm -rf doc/_build/man/* + +set -e + +docker run --rm -it \ + -v /$(pwd):/src \ + -w //src/doc \ + btdi/sphinx:featured \ + sh -c "sphinx-build -T -b man . ./_build/man" + +nroff -man doc/_build/man/ghdl.1 diff --git a/scripts/msys2-llvm/PKGBUILD b/scripts/msys2-llvm/PKGBUILD new file mode 100644 index 000000000..9abac48af --- /dev/null +++ b/scripts/msys2-llvm/PKGBUILD @@ -0,0 +1,34 @@ +_realname=ghdl +pkgbase=mingw-w64-${_realname} +pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}") +pkgver=ci +pkgrel=1 +pkgdesc="GHDL: the open-source analyzer, compiler, simulator and (experimental) synthesizer for VHDL (LLVM backend) (mingw-w64)" +arch=('any') +provides=("${MINGW_PACKAGE_PREFIX}-${_realname}") +pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}-llvm") +depends=( + "${MINGW_PACKAGE_PREFIX}-clang" + "${MINGW_PACKAGE_PREFIX}-gcc-ada" + 'zlib-devel' +) + +build() { + mkdir "${srcdir}/builddir" + cd "${srcdir}/builddir" + export CC=clang + export CXX=clang++ + ../../../../configure \ + --prefix=${MINGW_PREFIX} \ + --with-llvm-config="llvm-config --link-static" \ + LDFLAGS="-static" \ + --enable-libghdl \ + --enable-synth + make GNATMAKE="gnatmake -j$(nproc)" +} + +package() { + cd "${srcdir}/builddir" + mkdir -p "${pkgdir}${MINGW_PREFIX}/lib" + make DESTDIR="${pkgdir}" install +} diff --git a/scripts/msys2-mcode/PKGBUILD b/scripts/msys2-mcode/PKGBUILD new file mode 100644 index 000000000..853b0429b --- /dev/null +++ b/scripts/msys2-mcode/PKGBUILD @@ -0,0 +1,31 @@ +_realname=ghdl +pkgbase=mingw-w64-${_realname} +pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}") +pkgver=ci +pkgrel=1 +pkgdesc="GHDL: the open-source analyzer, compiler, simulator and (experimental) synthesizer for VHDL (mcode backend) (mingw-w64)" +arch=('any') +provides=("${MINGW_PACKAGE_PREFIX}-${_realname}") +pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}-mcode") +depends=( + "${MINGW_PACKAGE_PREFIX}-gcc-ada" + 'zlib-devel' +) +makedepends=("${MINGW_PACKAGE_PREFIX}-gcc") + +build() { + mkdir "${srcdir}/builddir" + cd "${srcdir}/builddir" + ../../../../configure \ + --prefix=${MINGW_PREFIX} \ + LDFLAGS=-static \ + --enable-libghdl \ + --enable-synth + make GNATMAKE="gnatmake -j$(nproc)" +} + +package() { + cd "${srcdir}/builddir" + mkdir -p "${pkgdir}${MINGW_PREFIX}/lib" + make DESTDIR="${pkgdir}" install +} diff --git a/scripts/termux.sh b/scripts/termux.sh new file mode 100755 index 000000000..f2b115850 --- /dev/null +++ b/scripts/termux.sh @@ -0,0 +1,15 @@ +# Build and install GHDL on termux (https://termux.com/) + +cd $(dirname "$0")/.. + +curl -fsSL https://its-pointless.github.io/setup-pointless-repo.sh | bash - +pkg install gnat-10 llvm clang make +setupgcc-10 +setup-patchforgcc + +mkdir -p build-termux +cd build-termux +CXX=clang++ +../configure --default-pic --enable-synth --with-llvm-config=llvm-config --prefix="$PREFIX" +make +make install diff --git a/scripts/windows/InstallerTemplate.ps1 b/scripts/windows/InstallerTemplate.ps1 new file mode 100644 index 000000000..f04a89ad4 --- /dev/null +++ b/scripts/windows/InstallerTemplate.ps1 @@ -0,0 +1,359 @@ +# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- +# vim: tabstop=2:shiftwidth=2:noexpandtab +# kate: tab-width 2; replace-tabs off; indent-width 2; +# +# ============================================================================== +# Authors: Patrick Lehmann +# +# PowerShell Script: Self-extracting (ZIP) installer for GHDL for Windows +# +# Description: +# ------------------------------------ +# This is a PowerShell script (executable) which: +# - writes a ZIP file form an internal BLOB variable (base64 encoded) +# - extract the ZIP file's content to a destination directory +# +# ============================================================================== +# Copyright (C) 2015-2017 Patrick Lehmann +# +# GHDL is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2, or (at your option) any later +# version. +# +# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with GHDL; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# ============================================================================== + +# .SYNOPSIS +# GHDL for Windows - GHDL installer script +# Use 'install.ps1 -Help' to see the integrated help page +# +# .EXAMPLE +# # +# # Normal flow +# PS> .\install.ps1 -Install +# +# # Advanced flow +# PS> .\compile.ps1 -AddToPath Machine -Install "C:\Tools\GHDL" +# +[CmdletBinding()] +Param( + # install all files into a directory (xcopy deployment) + [switch]$Install = $false, + [Parameter(Mandatory=$false, ValueFromRemainingArguments=$true)] + [String]$InstallDir = "", + # update files + [switch]$Update, + + # register GHDL in PATH + [Parameter(Mandatory=$false)] + [ValidateSet("Machine", "User", "Session", "Remove", "Pass")] + [String]$AddToPath = "", + + # display this help" + [switch]$Help +) + +# save parameters and current working directory +$Script_ScriptDir = $PSScriptRoot +$Script_WorkingDir = Get-Location +$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) + +# set default values +$EnableVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"] +$EnableDebug = $PSCmdlet.MyInvocation.BoundParameters["Debug"] +if ($EnableVerbose -eq $null) { $EnableVerbose = $false } +if ($EnableDebug -eq $null) { $EnableDebug = $false } +if ($EnableDebug -eq $true) { $EnableVerbose = $true } + +# Display help if no command was selected +$Help = $Help -or (-not ($Install -or $Update)) + +# configure some variables: paths, executables, directory names, ... +$GHDLVersion = "0.34-dev" +$GHDLBackend = "mcode" +$DefaultInstallPath = "C:\Program Files (x86)\GHDL" # This is the default path for 32-bit applications (x86-32) + +Write-Host "================================================================================" -ForegroundColor Magenta +Write-Host "GHDL for Windows - GHDL install script" -ForegroundColor Magenta +Write-Host "================================================================================" -ForegroundColor Magenta + +function Exit-Script +{ [CmdletBinding()] + param( + [int]$ExitCode = 0 + ) + cd $Script_WorkingDir + exit $ExitCode +} + +if ($Help) +{ Get-Help $MYINVOCATION.InvocationName -Detailed + Exit-Script +} + +$EnvPath_ContainerMapping = @{ + Machine = [EnvironmentVariableTarget]::Machine + User = [EnvironmentVariableTarget]::User +} + +# GitHub user: https://github.com/mkropat +# Gist account at GitHub: https://gist.github.com/mkropat +# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 +function Add-EnvPath +{ param( + [Parameter(Mandatory=$true)] + [string] $Path, + + [ValidateSet("Machine", "User", "Session")] + [string] $Container = "Session" + ) + + if ($Container -ne "Session") + { $containerType = $EnvPath_ContainerMapping[$Container] + $persistedPaths = [Environment]::GetEnvironmentVariable("Path", $containerType) -split ";" + if ($persistedPaths -notcontains $Path) + { $persistedPaths = $persistedPaths + $Path | where { $_ } + [Environment]::SetEnvironmentVariable("Path", $persistedPaths -join ";", $containerType) + } + } + + $envPaths = $env:Path -split ";" + if ($envPaths -notcontains $Path) + { $envPaths = $envPaths + $Path | where { $_ } + $env:Path = $envPaths -join ";" + } +} + +# GitHub user: https://github.com/mkropat +# Gist account at GitHub: https://gist.github.com/mkropat +# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 +function Remove-EnvPath +{ param ( + [Parameter(Mandatory=$true)] + [string] $Path, + + [ValidateSet("Machine", "User", "Session")] + [string] $Container = "Session" + ) + + if ($Container -ne "Session") + { $containerType = $EnvPath_ContainerMapping[$Container] + $persistedPaths = [Environment]::GetEnvironmentVariable("Path", $containerType) -split ";" + if ($persistedPaths -contains $Path) + { $persistedPaths = $persistedPaths | where { $_ -and $_ -ne $Path } + [Environment]::SetEnvironmentVariable("Path", $persistedPaths -join ";", $containerType) + } + } + + $envPaths = $env:Path -split ";" + if ($envPaths -contains $Path) + { $envPaths = $envPaths | where { $_ -and $_ -ne $Path } + $env:Path = $envPaths -join ";" + } +} + +# GitHub user: https://github.com/mkropat +# Gist account at GitHub: https://gist.github.com/mkropat +# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 +function Get-EnvPath +{ param ( + [Parameter(Mandatory=$true)] + [ValidateSet("Machine", "User")] + [string] $Container + ) + + $containerType = $EnvPath_ContainerMapping[$Container] + [Environment]::GetEnvironmentVariable('Path', $containerType) -split ";" | where { $_ } +} + +# ============================================================================ +# Base64 encoded zip file content +# ============================================================================ + +# DATASECTION + +# ============================================================================ + + +# ============================================================================ +# Install tasks +# ============================================================================ +if ($Install) +{ Write-Host "Installing GHDL $GHDLVersion for Windows..." + if ($InstallDir -eq "") + { $InstallPath = $DefaultInstallPath + } + else + { $InstallPath = $InstallDir } + $InstallPath = $InstallPath.TrimEnd("\") + + if (Test-Path -Path $InstallPath) + { Write-Host "[ERROR]: Directory '$InstallPath' already exists." -ForegroundColor Red + Exit-Script -1 + } + Write-Host " Install directory: $InstallPath" + Write-Host " Creating directory '$InstallPath' and sub-directories..." + New-Item -ItemType Directory -Path "$InstallPath" -ErrorAction SilentlyContinue | Out-Null + + # writing ZIP file to disk + $TempFilePath = [System.IO.Path]::GetTempFileName().TrimEnd("tmp") + "zip" + Write-Host " Writing temporary ZIP file: $TempFilePath" + $CompressedFileContentAsBytes = [System.Convert]::FromBase64String($CompressedFileContentInBase64) + [System.IO.File]::WriteAllBytes("$TempFilePath", $CompressedFileContentAsBytes) + + Write-Host " Extracting ZIP file to: $InstallPath" + Microsoft.PowerShell.Archive\Expand-Archive "$TempFilePath" -DestinationPath $InstallPath -Force + + Remove-Item $TempFilePath + + + if ($AddToPath -eq "") + { while($true) + { Write-Host " Install GHDL in PATH at machine level? [" -NoNewline -ForegroundColor DarkCyan + Write-Host "M" -NoNewline -ForegroundColor Cyan + Write-Host "achine/" -NoNewline -ForegroundColor DarkCyan + Write-Host "u" -NoNewline -ForegroundColor Cyan + Write-Host "ser/" -NoNewline -ForegroundColor DarkCyan + Write-Host "s" -NoNewline -ForegroundColor Cyan + Write-Host "ession]: " -NoNewline -ForegroundColor DarkCyan + $InstallInPath = (Read-Host).ToLower() + if ($InstallInPath -in "m","u","s") + { break } + else + { Write-Host "[ERROR]: Unsupported choice: '$InstallInPath'." -ForegroundColor Red } + } + } + elseif ($AddToPath -eq "Machine") + { $InstallInPath = "m" } + elseif ($AddToPath -eq "User") + { $InstallInPath = "u" } + elseif ($AddToPath -eq "Session") + { $InstallInPath = "s" } + + if (($InstallInPath -eq "") -or ($InstallInPath -eq "m")) + { Write-Host " Adding GHDL to PATH at machine level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Machine" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "u") + { Write-Host " Adding GHDL to PATH at user level." + Add-EnvPath -Path "$InstallPath\bin" -Container "User" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "s") + { Write-Host " Adding GHDL to PATH at session level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + + Write-Host + Write-Host "Installing files " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + + Exit-Script +} # Install +elseif ($Update) +{ Write-Host "Updating GHDL $GHDLVersion for Windows..." + if ($InstallDir -eq "") + { $InstallPath = $DefaultInstallPath + } + else + { $InstallPath = $InstallDir } + $InstallPath = $InstallPath.TrimEnd("\") + + Write-Host " Install directory: $InstallPath" + if (Test-Path -Path $InstallPath) + { Write-Host " Cleaning up installation directory '$InstallPath'." -ForegroundColor Yellow + Get-ChildItem -Path $InstallPath -Depth 0 | foreach { Remove-Item $_.FullName -Recurse -Force } + } + + Write-Host " Creating directory sub-directories in '$InstallPath' ..." + + # writing ZIP file to disk + $TempFilePath = [System.IO.Path]::GetTempFileName() + Write-Host " Writing temporary ZIP file: $TempFilePath" + $CompressedFileContentAsBytes = [System.Convert]::FromBase64String($CompressedFileContentInBase64) + [System.IO.File]::WriteAllBytes("$TempFilePath", $CompressedFileContentAsBytes) + + Write-Host " Extracting ZIP file to: $InstallPath" + Expand-Archive "$TempFilePath" -OutputPath $InstallPath -ShowProgress + + Remove-Item $TempFilePath + + if ($AddToPath -eq "") + { while($true) + { Write-Host " Install GHDL in PATH at machine level? [" -NoNewline -ForegroundColor DarkCyan + Write-Host "M" -NoNewline -ForegroundColor Cyan + Write-Host "achine/" -NoNewline -ForegroundColor DarkCyan + Write-Host "u" -NoNewline -ForegroundColor Cyan + Write-Host "ser/" -NoNewline -ForegroundColor DarkCyan + Write-Host "s" -NoNewline -ForegroundColor Cyan + Write-Host "ession/" -NoNewline -ForegroundColor DarkCyan + Write-Host "r" -NoNewline -ForegroundColor Cyan + Write-Host "emove/" -NoNewline -ForegroundColor DarkCyan + Write-Host "p" -NoNewline -ForegroundColor Cyan + Write-Host "ass]: " -NoNewline -ForegroundColor DarkCyan + $InstallInPath = (Read-Host).ToLower() + if ($InstallInPath -in "m","u","s","r","p") + { break } + else + { Write-Host "[ERROR]: Unsupported choice: '$InstallInPath'." -ForegroundColor Red } + } + } + elseif ($AddToPath -eq "Machine") + { $InstallInPath = "m" } + elseif ($AddToPath -eq "User") + { $InstallInPath = "u" } + elseif ($AddToPath -eq "Session") + { $InstallInPath = "s" } + elseif ($AddToPath -eq "Remove") + { $InstallInPath = "r" } + elseif ($AddToPath -eq "Pass") + { $InstallInPath = "p" } + + if ($InstallInPath -ne "p") + { Write-Host " Removing GHDL from PATH variables in Machine, User, Session ..." -ForegroundColor Yellow + foreach ($container in @("Machine", "User")) + { foreach ($entry in (Get-EnvPath -Container $container)) + { if ($entry.ToLower().Contains("ghdl")) + { Write-Host " Removing '$entry' from $container level." + Remove-EnvPath -Path $entry -Container $container + } + } + } + Remove-EnvPath -Path $entry -Container "Session" + + if (($InstallInPath -eq "") -or ($InstallInPath -eq "m")) + { Write-Host " Adding GHDL to PATH at machine level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Machine" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "u") + { Write-Host " Adding GHDL to PATH at user level." + Add-EnvPath -Path "$InstallPath\bin" -Container "User" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "s") + { Write-Host " Adding GHDL to PATH at session level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + } + + Write-Host + Write-Host "Updating files " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + + Exit-Script +} # Update + +Exit-Script diff --git a/scripts/windows/appveyor/build.ps1 b/scripts/windows/appveyor/build.ps1 new file mode 100644 index 000000000..359fb4da7 --- /dev/null +++ b/scripts/windows/appveyor/build.ps1 @@ -0,0 +1,112 @@ +function Restore-NativeCommandStream +{ <# + .SYNOPSIS + This CmdLet gathers multiple ErrorRecord objects and reconstructs outputs + as a single line. + + .DESCRIPTION + This CmdLet collects multiple ErrorRecord objects and emits one String + object per line. + .PARAMETER InputObject + A object stream is required as an input. + .PARAMETER Indent + Indentation string. + #> + [CmdletBinding()] + param( + [Parameter(ValueFromPipeline=$true)] + $InputObject + ) + + begin + { $LineRemainer = "" } + + process + { if ($InputObject -is [System.Management.Automation.ErrorRecord]) + { if ($InputObject.FullyQualifiedErrorId -eq "NativeCommandError") + { Write-Output $InputObject.ToString() } + elseif ($InputObject.FullyQualifiedErrorId -eq "NativeCommandErrorMessage") + { $NewLine = $LineRemainer + $InputObject.ToString() + while (($NewLinePos = $NewLine.IndexOf("`n")) -ne -1) + { Write-Output $NewLine.Substring(0, $NewLinePos) + $NewLine = $NewLine.Substring($NewLinePos + 1) + } + $LineRemainer = $NewLine + } + } + elseif ($InputObject -is [String]) + { Write-Output $InputObject } + else + { Write-Host "Unsupported object in pipeline stream" } + } + + end + { if ($LineRemainer -ne "") + { Write-Output $LineRemainer } + } +} + +#### Environment + +$BUILD_DIRNAME = "$($env:BUILD_MINGW)-$($env:BUILD_BACKEND)" +$GHDL_BUILD_DIR = "$($env:APPVEYOR_BUILD_FOLDER)\build\$BUILD_DIRNAME" + +if ($env:APPVEYOR_REPO_TAG -eq "true") +{ + # There is a tag. Remove the leading v. + $BUILD_VERSION = $($env:APPVEYOR_REPO_TAG_NAME) -creplace "^v", "" +} +else +{ + $BUILD_VERSION = $($env:APPVEYOR_BUILD_VERSION) +} + +$PREFIX_DIRNAME = "$BUILD_VERSION-$BUILD_DIRNAME" + +$GHDL_PREFIX_DIR = "c:/Tools/GHDL/$PREFIX_DIRNAME" +$ZipFile = "ghdl-$PREFIX_DIRNAME.zip" + +$env:GHDL_BUILD_DIR = $GHDL_BUILD_DIR +$env:GHDL_PREFIX_DIR = $GHDL_PREFIX_DIR + +#### Build + +mkdir $GHDL_BUILD_DIR | cd + +if ($env:BUILD_BACKEND -eq "mcode") +{ Write-Host "Configuring GHDL for $($env:BUILD_MINGW), mcode..." -Foreground Yellow + + c:\msys64\usr\bin\bash.exe -c "../../configure --prefix=$GHDL_PREFIX_DIR LDFLAGS=-static" 2>&1 | Restore-NativeCommandStream | %{ "$_" } +} +elseif ($env:BUILD_BACKEND -eq "llvm") +{ Write-Host "Configuring GHDL for $($env:BUILD_MINGW), LLVM..." -Foreground Yellow + + c:\msys64\usr\bin\bash.exe -c "../../configure --prefix=$GHDL_PREFIX_DIR --with-llvm-config='llvm-config --link-static' LDFLAGS='-static' --enable-libghdl --enable-synth CXX=clang++" 2>&1 | Restore-NativeCommandStream | %{ "$_" } +} + +Write-Host "Building GHDL and libraries..." -Foreground Yellow +c:\msys64\usr\bin\make.exe 2>&1 | Restore-NativeCommandStream | %{ "$_" } +$Err = $LastExitCode + +if ($Err -eq 0) +{ + Write-Host "Installing GHDL and libraries..." -Foreground Yellow + c:\msys64\usr\bin\make.exe install 2>&1 | Restore-NativeCommandStream | %{ "$_" } + $Err = $LastExitCode +} + +#### Binaries + +if ($Err -eq 0) +{ + Write-Host "Building binary archives..." -Foreground Yellow + cd c:\Tools + 7z a "$($env:APPVEYOR_BUILD_FOLDER)\$ZipFile" -r "GHDL\$PREFIX_DIRNAME\" + + cd $env:APPVEYOR_BUILD_FOLDER + Push-AppveyorArtifact $ZipFile +} + +cd $env:APPVEYOR_BUILD_FOLDER + +exit $Err diff --git a/scripts/windows/appveyor/info.ps1 b/scripts/windows/appveyor/info.ps1 new file mode 100644 index 000000000..675bbe77e --- /dev/null +++ b/scripts/windows/appveyor/info.ps1 @@ -0,0 +1,68 @@ +function Restore-NativeCommandStream +{ <# + .SYNOPSIS + This CmdLet gathers multiple ErrorRecord objects and reconstructs outputs + as a single line. + + .DESCRIPTION + This CmdLet collects multiple ErrorRecord objects and emits one String + object per line. + .PARAMETER InputObject + A object stream is required as an input. + .PARAMETER Indent + Indentation string. + #> + [CmdletBinding()] + param( + [Parameter(ValueFromPipeline=$true)] + $InputObject + ) + + begin + { $LineRemainer = "" } + + process + { if ($InputObject -is [System.Management.Automation.ErrorRecord]) + { if ($InputObject.FullyQualifiedErrorId -eq "NativeCommandError") + { Write-Output $InputObject.ToString() } + elseif ($InputObject.FullyQualifiedErrorId -eq "NativeCommandErrorMessage") + { $NewLine = $LineRemainer + $InputObject.ToString() + while (($NewLinePos = $NewLine.IndexOf("`n")) -ne -1) + { Write-Output $NewLine.Substring(0, $NewLinePos) + $NewLine = $NewLine.Substring($NewLinePos + 1) + } + $LineRemainer = $NewLine + } + } + elseif ($InputObject -is [String]) + { Write-Output $InputObject } + else + { Write-Host "Unsupported object in pipeline stream" } + } + + end + { if ($LineRemainer -ne "") + { Write-Output $LineRemainer } + } +} + + +Write-Host ("ExecutionPolicy = {0}" -f (Get-ExecutionPolicy)) -Foreground Yellow +Write-Host "List env:..." -Foreground Yellow +dir env: | foreach { Write-Host (" {0}={1}" -f $_.Name,$_.Value) } +Write-Host "Print env:PATH..." -Foreground Yellow +$env:PATH.Split(";") | foreach { Write-Host " $_" } +Write-Host "Print GCC setup..." -Foreground Yellow +gcc.exe -v 2>&1 | Restore-NativeCommandStream | %{ "$_" } +Write-Host "Print GCC search directories..." -Foreground Yellow +gcc.exe -print-search-dirs 2>&1 | Restore-NativeCommandStream | %{ "$_" } + +if ($env:BUILD_BACKEND -eq "llvm") +{ Write-Host "Print CLang setup..." -Foreground Yellow + clang.exe -v 2>&1 | Restore-NativeCommandStream | %{ "$_" } + Write-Host "Print CLang search directories..." -Foreground Yellow + clang.exe -print-search-dirs 2>&1 | Restore-NativeCommandStream | %{ "$_" } +} + +Write-Host "Print gnatls setup..." -Foreground Yellow +gnatls.exe -v 2>&1 | Restore-NativeCommandStream | %{ "$_" } diff --git a/scripts/windows/appveyor/install.ps1 b/scripts/windows/appveyor/install.ps1 new file mode 100644 index 000000000..bf780fa19 --- /dev/null +++ b/scripts/windows/appveyor/install.ps1 @@ -0,0 +1,39 @@ +Write-Host "Installing dependencies ..." -Foreground Yellow +Write-Host "----------------------------------------" -Foreground Yellow +Write-Host "Installing MinGW64 packages ..." -Foreground Yellow + +C:\msys64\usr\bin\pacman -V +# list installed packages and versions +# C:\msys64\usr\bin\pacman -Q + +if ($env:BUILD_MINGW -eq "mingw32") +{ Write-Host "Installing MinGW32 packages ..." -Foreground Yellow + if ($env:BUILD_BACKEND -eq "mcode") + { + } + elseif ($env:BUILD_BACKEND -eq "llvm") + { C:\msys64\usr\bin\pacman -S mingw-w64-i686-llvm mingw-w64-i686-clang --noconfirm + } +} +elseif ($env:BUILD_MINGW -eq "mingw64") +{ Write-Host "Installing MinGW64 packages ..." -Foreground Yellow + if ($env:BUILD_BACKEND -eq "mcode") + { + } + elseif ($env:BUILD_BACKEND -eq "llvm") + { C:\msys64\usr\bin\pacman -S mingw-w64-x86_64-llvm mingw-w64-x86_64-clang --noconfirm + } +} + +Write-Host "Installing NuGet as PackageProvider ..." -Foreground Yellow +Install-PackageProvider NuGet -Force +Import-PackageProvider NuGet -Force +Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + +Write-Host "Installing PowerShell modules ..." -Foreground Yellow +Install-Module Pscx -AllowClobber + +#Write-Host "Check all Write-* CmdLets ..." -Foreground Yellow +#Get-Command -Verb Write | Format-Table + +exit $LastExitCode diff --git a/scripts/windows/appveyor/shared.psm1 b/scripts/windows/appveyor/shared.psm1 new file mode 100644 index 000000000..3335182ff --- /dev/null +++ b/scripts/windows/appveyor/shared.psm1 @@ -0,0 +1,49 @@ +function Restore-NativeCommandStream +{ <# + .SYNOPSIS + This CmdLet gathers multiple ErrorRecord objects and reconstructs outputs + as a single line. + + .DESCRIPTION + This CmdLet collects multiple ErrorRecord objects and emits one String + object per line. + .PARAMETER InputObject + A object stream is required as an input. + .PARAMETER Indent + Indentation string. + #> + [CmdletBinding()] + param( + [Parameter(ValueFromPipeline=$true)] + $InputObject + ) + + begin + { $LineRemainer = "" } + + process + { if ($InputObject -is [System.Management.Automation.ErrorRecord]) + { if ($InputObject.FullyQualifiedErrorId -eq "NativeCommandError") + { Write-Output $InputObject.ToString() } + elseif ($InputObject.FullyQualifiedErrorId -eq "NativeCommandErrorMessage") + { $NewLine = $LineRemainer + $InputObject.ToString() + while (($NewLinePos = $NewLine.IndexOf("`n")) -ne -1) + { Write-Output $NewLine.Substring(0, $NewLinePos) + $NewLine = $NewLine.Substring($NewLinePos + 1) + } + $LineRemainer = $NewLine + } + } + elseif ($InputObject -is [String]) + { Write-Output $InputObject } + else + { Write-Host "Unsupported object in pipeline stream" } + } + + end + { if ($LineRemainer -ne "") + { Write-Output $LineRemainer } + } +} + +Export-ModuleMember -Function 'Restore-NativeCommandStream' diff --git a/scripts/windows/appveyor/test.ps1 b/scripts/windows/appveyor/test.ps1 new file mode 100644 index 000000000..65045f889 --- /dev/null +++ b/scripts/windows/appveyor/test.ps1 @@ -0,0 +1,121 @@ +function Restore-NativeCommandStream +{ <# + .SYNOPSIS + This CmdLet gathers multiple ErrorRecord objects and reconstructs outputs + as a single line. + + .DESCRIPTION + This CmdLet collects multiple ErrorRecord objects and emits one String + object per line. + .PARAMETER InputObject + A object stream is required as an input. + .PARAMETER Indent + Indentation string. + #> + [CmdletBinding()] + param( + [Parameter(ValueFromPipeline=$true)] + $InputObject + ) + + begin + { $LineRemainer = "" } + + process + { if ($InputObject -is [System.Management.Automation.ErrorRecord]) + { if ($InputObject.FullyQualifiedErrorId -eq "NativeCommandError") + { Write-Output $InputObject.ToString() } + elseif ($InputObject.FullyQualifiedErrorId -eq "NativeCommandErrorMessage") + { $NewLine = $LineRemainer + $InputObject.ToString() + while (($NewLinePos = $NewLine.IndexOf("`n")) -ne -1) + { Write-Output $NewLine.Substring(0, $NewLinePos) + $NewLine = $NewLine.Substring($NewLinePos + 1) + } + $LineRemainer = $NewLine + } + } + elseif ($InputObject -is [String]) + { Write-Output $InputObject } + else + { Write-Host "Unsupported object in pipeline stream" } + } + + end + { if ($LineRemainer -ne "") + { Write-Output $LineRemainer } + } +} + +Write-Host "Run testsuites..." -Foreground Yellow +cd "$($env:APPVEYOR_BUILD_FOLDER)\testsuite" +# Use a MinGW compatible path +$env:GHDL="$($env:GHDL_PREFIX_DIR)/bin/ghdl.exe" + +# Exit status +$Err = 0 + +# ============================================================================= +$TestFramework = "GNA" +Write-Host "Running GNA tests..." -Foreground Yellow +cd gna + +$Directories = dir -Directory * +foreach ($Directory in $Directories) +{ $TestName = "GNA test: {0}" -f $Directory.Name + $FileName = $Directory.Name + + Write-Host $TestName -Foreground Yellow + cd $Directory + Add-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Running + $start = Get-Date + c:\msys64\usr\bin\bash.exe -c "./testsuite.sh" 2>&1 | Restore-NativeCommandStream | %{ "$_" } + $end = Get-Date + $TotalMilliseconds = ($end - $start).TotalMilliseconds + if ($LastExitCode -eq 0) + { Write-Host "PASSED" -Foreground Green + Update-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Passed -Duration $TotalMilliseconds + } + else + { Write-Host "FAILED" -Foreground Red + Update-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Failed -Duration $TotalMilliseconds + $Err = 1 + } +} +cd ..\.. + +# ============================================================================= +$TestFramework = "VESTS" +Write-Host "Running VESTS tests..." -Foreground Yellow + +cd vests + +$TestName = "VESTS test:" # {0}" -f $Directory +$FileName = "VESTS" #$Directory + +Write-Host $TestName -Foreground Yellow +# Disable vests. It works but takes ~20 min +if ($true) +{ Add-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Skipped + $start = Get-Date +} +else +{ Add-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Running + $start = Get-Date + c:\msys64\usr\bin\bash.exe -c "./testsuite.sh" 2>&1 | Restore-NativeCommandStream | %{ "$_" } + $end = Get-Date + $TotalMilliseconds = ($end - $start).TotalMilliseconds + if ($LastExitCode -eq 0) + { Write-Host "PASSED" -Foreground Green + Update-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Passed -Duration $TotalMilliseconds + } + else + { Write-Host "FAILED" -Foreground Red + Update-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Failed -Duration $TotalMilliseconds + $Err = 1 + } + cd .. +} + +# ============================================================================= +cd $env:APPVEYOR_BUILD_FOLDER +exit $Err diff --git a/scripts/windows/compile-ghdl.ps1 b/scripts/windows/compile-ghdl.ps1 new file mode 100644 index 000000000..0f126e846 --- /dev/null +++ b/scripts/windows/compile-ghdl.ps1 @@ -0,0 +1,243 @@ +# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- +# vim: tabstop=2:shiftwidth=2:noexpandtab +# kate: tab-width 2; replace-tabs off; indent-width 2; +# +# ============================================================================== +# Authors: Patrick Lehmann (ported batch file to PowerShell) +# Brian Davis (contributions to the batch file) +# Tristan Gingold (initial batch file for compilations on Windows) +# +# PowerShell Script: Script to compile GHDL for Windows +# +# Description: +# ------------------------------------ +# This is a PowerShell script (executable) which: +# - sets up a compilation environment +# - test all dependencies +# - compiles GHDL with GNAT +# +# ============================================================================== +# Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold +# Copyright (C) 2015-2017 Patrick Lehmann +# +# GHDL is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2, or (at your option) any later +# version. +# +# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with GHDL; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# ============================================================================== + +# .SYNOPSIS +# GHDL for Windows - GHDL compile script +# Use 'compile-ghdl.ps1 -Help' to see the integrated help page +# +# .EXAMPLE +# C:\PS> .\compile-ghdl.ps1 -Clean -Compile +# +[CmdletBinding()] +param( + # Display this help" + [switch]$Help = $false, + + # Slean up all files and directories + [switch]$Clean = $false, + [switch]$Clean_GHDL = $false, + + # Compile all targets + [switch]$All = $false, + + # Compile main targets + [switch]$Compile = $false, + # Compile GHDL (simulator) + [switch]$Compile_GHDL = $false, + # Undocumented + [switch]$Test = $false, + # Undocumented + [switch]$Test_GHDL = $false, + + # Build options + # Build a release version + [switch]$Release = $false, + # Set the back-end + [string]$Backend = "mcode", + + # Reduced messages + [switch]$Quiet = $false, + # Skip warning messages. (Show errors only.) + [switch]$SuppressWarnings = $false, + # Halt on errors + [switch]$HaltOnError = $false, + # Undocumented + [switch]$Hosted = $false +) + +# configure script here +$RelPathToRoot = "..\.." + +# --------------------------------------------- +# save parameters and working directory +$Script_ScriptDir = $PSScriptRoot +$Script_WorkingDir = Get-Location +$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) + +# set default values +$EnableDebug = [bool]$PSCmdlet.MyInvocation.BoundParameters["Debug"] +$EnableVerbose = [bool]$PSCmdlet.MyInvocation.BoundParameters["Verbose"] -or $EnableDebug + +# load modules from GHDL's 'libraries' directory +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -Debug:$false -ArgumentList "$Script_WorkingDir", $Hosted +Import-Module $PSScriptRoot\targets.psm1 -Verbose:$false -Debug:$false + +# Display help if no command was selected +$Help = $Help -or (-not ( + $All -or + $Clean -or $Clean_GHDL -or + $Compile -or $Compile_GHDL -or + $Test -or $Test_GHDL + )) + +if (-not $Hosted) +{ Write-Host "================================================================================" -ForegroundColor Magenta + Write-Host "GHDL for Windows - GHDL compile script" -ForegroundColor Magenta + Write-Host "================================================================================" -ForegroundColor Magenta +} + +if ($Help) +{ Get-Help $MYINVOCATION.InvocationName -Detailed + Exit-CompileScript +} + +if ($Clean) +{ $Clean_GHDL = $true +} +if ($All) +{ $Compile = $true +} +if ($Compile) +{ $Compile_GHDL = $true +} +if ($Test) +{ $Test_GHDL = $true +} + +# configure some variables: paths, executables, directory names, ... +$BuildDirectoryName = "build" + +# Parameter checks +if ($Backend -ne "mcode") +{ Write-Host "[ERROR]: Back-end '$Backend' is not supported on Windows." -ForegroundColor Red + Exit-CompileScript -1 +} + +# construct directories +$BinaryDestinationDirectory = "$GHDLRootDir\$BuildDirectoryName\$Backend" +# construct executables +$GHDLNewExecutable = "$GHDLRootDir\$BuildDirectoryName\$Backend\bin\ghdl.exe" + +# grep GHDL version string from Ada source file +$GHDLVersion = Get-GHDLVersion $GHDLRootDir +# compute some variables +$BuildRelease = if ($Release) { "Release" } else { "Development" } +if (-not $Hosted) +{ Write-Host " Version: $GHDLVersion" + Write-Host " Release: $BuildRelease" +} + +$Git_IsGitRepo = Test-GitRepository +# gather git information +if ($Git_IsGitRepo) +{ $Git_Branch_Name = & git rev-parse --abbrev-ref HEAD + $Git_Commit_DateString = & git log -1 --format=%cd --date=short + $Git_Commit_ShortHash = & git rev-parse --short HEAD + + if (-not $Hosted) + { Write-Host " Git branch: $Git_Branch_Name" + Write-Host " Git commit: $Git_Commit_DataString ($Git_Commit_ShortHash)" + } +} +if (-not $Hosted) +{ Write-Host "" } + +if ($Release) +{ $BuildDirectory = $BinaryDestinationDirectory } +else +{ $BuildDirectory = $BinaryDestinationDirectory } + + +# ============================================================================== +# Main Target: Clean +# ============================================================================== +if ($Clean_GHDL) +{ $error = Invoke-Clean $BuildDirectory -Quiet:$Quiet -Verbose:$EnableVerbose -Debug:$EnableDebug + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } +} # Clean + + +# ============================================================================== +# Main Target: GHDL +# ============================================================================== +if ($Compile_GHDL) +{ # create a build directory + $error = New-BuildDirectory $BuildDirectory + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } + + # patch the version file if it's no release build + if (-not $Release -and $Git_IsGitRepo) + { $error = Invoke-PatchVersionFile $GHDLRootDir $Git_Branch_Name $Git_Commit_DateString $Git_Commit_ShortHash + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } + } + + # build C source files + $error = Invoke-CompileCFiles $GHDLRootDir $BinaryDestinationDirectory + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } + + # build Ada source files + $error = Invoke-CompileGHDLAdaFiles $GHDLRootDir $BinaryDestinationDirectory + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } + + # strip result + $error = Invoke-StripGHDLExecutable $BinaryDestinationDirectory + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } +} + + +# ============================================================================== +# Main Target: GHDL +# ============================================================================== +if ($Test_GHDL) +{ # running ghdl + $error = Test-GHDLVersion $BuildDir + if ($error -eq $true) + { Write-Host " [FAILED]" -ForegroundColor Red + Exit-CompileScript -1 + } +} # Test + +Exit-CompileScript 0 diff --git a/scripts/windows/compile-libraries.ps1 b/scripts/windows/compile-libraries.ps1 new file mode 100644 index 000000000..a37b78618 --- /dev/null +++ b/scripts/windows/compile-libraries.ps1 @@ -0,0 +1,862 @@ +# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- +# vim: tabstop=2:shiftwidth=2:noexpandtab +# kate: tab-width 2; replace-tabs off; indent-width 2; +# +# ============================================================================== +# Authors: Patrick Lehmann (ported batch file to PowerShell) +# Brian Davis (contributions to the batch file) +# Tristan Gingold (initial batch file for compilations on Windows) +# +# PowerShell Script: Script to compile VHDL libraries for GHDL +# +# Description: +# ------------------------------------ +# This is a PowerShell script (executable) which: +# - sets up a compilation environment +# - test all dependencies +# - pre processes VHDL files with GHDLFilter +# - analyses VHDL files with GHDL +# +# ============================================================================== +# Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold +# Copyright (C) 2015-2017 Patrick Lehmann +# +# GHDL is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2, or (at your option) any later +# version. +# +# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with GHDL; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# ============================================================================== + +# .SYNOPSIS +# GHDL for Windows - Library compile script +# Use 'compile-libraries.ps1 -Help' to see the integrated help page +# +# .EXAMPLE +# C:\PS> .\compile-libraries.ps1 -Clean +# .EXAMPLE +# C:\PS> .\compile-libraries.ps1 -Compile -Verbose +# .EXAMPLE +# C:\PS> .\compile-libraries.ps1 -VHDL2008 -SuppressWarnings +# +[CmdletBinding()] +param( + # Display this help" + [switch]$Help = $false, + + # Clean up all files and directories + [switch]$Clean = $false, + + # Compile all library files + [switch]$Compile = $false, + + # Set VHDL Standard to '87 + [switch]$VHDL87 = $false, + # Set VHDL Standard to '93 + [switch]$VHDL93 = $false, + # Set VHDL Standard to '08 + [switch]$VHDL2008 = $false, + + # Skip warning messages. (Show errors only.) + [switch]$SuppressWarnings = $false, + # Halt on errors + [switch]$HaltOnError = $false, + + # Set GHDL executable + [string]$GHDL = "", + # Undocumented + [switch]$Hosted = $false +) + +# configure script here +$RelPathToRoot = "..\.." + +# --------------------------------------------- +# save parameters and working directory +$Script_ScriptDir = $PSScriptRoot +$Script_WorkingDir = Get-Location +$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) + +# set default values +$EnableDebug = [bool]$PSCmdlet.MyInvocation.BoundParameters["Debug"] +$EnableVerbose = [bool]$PSCmdlet.MyInvocation.BoundParameters["Verbose"] -or $EnableDebug + +# load modules from GHDL's 'libraries' directory +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -Debug:$false -ArgumentList "$Script_WorkingDir", $Hosted + +# Display help if no command was selected +$Help = $Help -or (-not ($Compile -or $VHDL87 -or $VHDL93 -or $VHDL2008 -or $Clean)) + +if ($Help) +{ Get-Help $MYINVOCATION.InvocationName -Detailed + Exit-CompileScript +} +if ($Compile) +{ $VHDL87 = $true + $VHDL93 = $true + $VHDL2008 = $true +} + +# configure some variables: paths, executables, directory names, ... +$VHDLLibrariesSourceDirectoryName = "libraries" +$VHDLLibrariesDestinationDirectoryName = "lib" +$BuildDirectoryName = "build" +$Backend = "mcode" + +# construct directories +$VHDLSourceLibraryDirectory = "$GHDLRootDir\$VHDLLibrariesSourceDirectoryName" +$VHDLDestinationLibraryDirectory = "$GHDLRootDir\$BuildDirectoryName\$Backend\$VHDLLibrariesDestinationDirectoryName" +# construct executables +$GHDLNewExecutable = "$GHDLRootDir\$BuildDirectoryName\$Backend\bin\ghdl.exe" + + +# Library sources +$SourceFiles = @{ + "std" = @( + "textio", "textio-body" + ); + "ieee" = @( + "std_logic_1164", "std_logic_1164-body", + "numeric_std", "numeric_std-body", + "numeric_bit", "numeric_bit-body" + ); + "math" = @( + "math_real", "math_real-body", + "math_complex", "math_complex-body" + ); + "std08" = @( + "textio", "textio-body", + "env", "env-body" + ); + "ieee2008" = @( + "std_logic_1164", "std_logic_1164-body", + "std_logic_textio", + "math_real", "math_real-body", + "math_complex", "math_complex-body", + "numeric_bit", "numeric_bit-body", + "numeric_bit_unsigned", "numeric_bit_unsigned-body", + "numeric_std", "numeric_std-body", + "numeric_std_unsigned", "numeric_std_unsigned-body", + "fixed_float_types", + "fixed_generic_pkg", "fixed_generic_pkg-body", + "fixed_pkg", + "float_generic_pkg", "float_generic_pkg-body", + "float_pkg", + "ieee_std_context", + "ieee_bit_context" + ); + "vital95" = @( + "vital_timing", "vital_timing-body", + "vital_primitives", "vital_primitives-body" + ); + "vital2000" = @( + "timing_p", "timing_b", + "prmtvs_p", "prmtvs_b", + "memory_p", "memory_b" + ); + "synopsys" = @( + "std_logic_arith", + "std_logic_unsigned", + "std_logic_signed" + ); + "synopsys8793" = @( + "std_logic_textio", + "std_logic_misc", "std_logic_misc-body" + ); + "mentor" = @( + "std_logic_arith", "std_logic_arith-body" + ) +} + +if (-not $Hosted) +{ Write-Host "================================================================================" -ForegroundColor Yellow + Write-Host "GHDL ($Backend) for Windows - Library compile script" -ForegroundColor Yellow + Write-Host "================================================================================" -ForegroundColor Yellow +} + +if ($Clean) +{ Write-Host "Removing all created files and directories..." -ForegroundColor Yellow + if (Test-Path -Path $VHDLDestinationLibraryDirectory) + { $EnableVerbose -and (Write-Host " rmdir $VHDLDestinationLibraryDirectory") | Out-Null + Remove-Item $VHDLDestinationLibraryDirectory -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: Cannot remove '$VHDLDestinationLibraryDirectory'." -ForegroundColor Red + Exit-CompileScript -1 + } + } + if (-not ($VHDL87 -or $VHDL93 -or $VHDL2008)) + { Exit-CompileScript } +} + +# get GHDL executable +if ($GHDL -ne "") +{ $GHDLExecutable = $GHDL } +elseif (Test-Path env:GHDL) +{ $GHDLExecutable = $env:GHDL } +elseif (Test-Path $GHDLNewExecutable -PathType Leaf) +{ $GHDLExecutable = $GHDLNewExecutable } +else +{ $GHDLExecutable = "ghdl.exe" } + +if (-not (Test-Path $GHDLExecutable -PathType Leaf)) +{ Write-Host "GHDL executable 'ghdl.exe' not found." -ForegroundColor Red + Write-Host "Use adv. options '-GHDL' to set the GHDL executable." -ForegroundColor Yellow + Exit-CompileScript -1 +} + + +$ErrorCount = 0 +if ($VHDL87 -or $VHDL93 -or $VHDL2008) +{ Write-Host "Compiling VHDL Libraries..." + Write-Host "Preparing..." + + # create lib directory if it does not exist + if (Test-Path -Path $VHDLDestinationLibraryDirectory) + { $EnableVerbose -and (Write-Host " Directory '$VHDLDestinationLibraryDirectory' already exists.") | Out-Null + + # change working directory to VHDLDestinationLibraryDirectory + $EnableVerbose -and (Write-Host " cd $VHDLDestinationLibraryDirectory") | Out-Null + Set-Location $VHDLDestinationLibraryDirectory + + $EnableVerbose -and (Write-Host " Cleaning up directory...") | Out-Null + Remove-Item ./* -Force -Recurse -ErrorAction SilentlyContinue + } + else + { $EnableVerbose -and (Write-Host " Creating directory '$VHDLDestinationLibraryDirectory'.") | Out-Null + New-Item -ItemType Directory -Path $VHDLDestinationLibraryDirectory -ErrorAction SilentlyContinue | Out-Null + if (-not $?) + { Write-Host "[ERROR]: Cannot create destination directory '$VHDLDestinationLibraryDirectory'." -ForegroundColor Red + Exit-CompileScript -1 + } + + # change working directory to VHDLDestinationLibraryDirectory + $EnableVerbose -and (Write-Host " Change working directory to $VHDLDestinationLibraryDirectory") | Out-Null + Set-Location $VHDLDestinationLibraryDirectory + } + + Write-Host + Write-Host "Start compilation..." +} +# ============================================================================ +# v87 +# ============================================================================ +if ($VHDL87) +{ $VHDLVersion = "87" + Write-Host "Compiling libraries for VHDL-$VHDLVersion" -ForegroundColor Cyan + + # ---------------------------------------------------------------------- + # v87\std + # ---------------------------------------------------------------------- + $VHDLLibrary = "std" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VHDLDestinationLibraryDirectory\$VHDLLibrary\v$VHDLVersion" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "std" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C --bootstrap --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v87\ieee + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "ieee" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VHDLDestinationLibraryDirectory\$VHDLFlavor\v$VHDLVersion" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v87\synopsys + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "synopsys" + Write-Host " Compiling library '$VHDLLibrary' ($VHDLFlavor)..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VHDLDestinationLibraryDirectory\$VHDLFlavor\v$VHDLVersion" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + foreach ($SourceFile in $SourceFiles[$VHDLFlavor] + $SourceFiles["synopsys8793"]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital95" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } +} +# ============================================================================ +# v93 +# ============================================================================ +if ($VHDL93) +{ $VHDLVersion = "93" + Write-Host "Compiling libraries for VHDL-$VHDLVersion" -ForegroundColor Cyan + + # ---------------------------------------------------------------------- + # v93\std + # ---------------------------------------------------------------------- + $VHDLLibrary = "std" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VHDLDestinationLibraryDirectory\$VHDLLibrary\v$VHDLVersion" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "std" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C --bootstrap --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v93\ieee + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "ieee" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VHDLDestinationLibraryDirectory\$VHDLFlavor\v$VHDLVersion" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex] + $SourceFiles["math"]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital2000" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v93\synopsys + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "synopsys" + Write-Host " Compiling library '$VHDLLibrary' ($VHDLFlavor)..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VHDLDestinationLibraryDirectory\$VHDLFlavor\v$VHDLVersion" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex] + $SourceFiles["math"]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + foreach ($SourceFile in $SourceFiles[$VHDLFlavor] + $SourceFiles["synopsys8793"]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital2000" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v93\mentor + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "mentor" + Write-Host " Compiling library '$VHDLLibrary' ($VHDLFlavor)..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VHDLDestinationLibraryDirectory\$VHDLFlavor\v$VHDLVersion" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex] + $SourceFiles["math"]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + foreach ($SourceFile in $SourceFiles[$VHDLFlavor]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital2000" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } +} +# ============================================================================== +# v08 +# ============================================================================== +if ($VHDL2008) +{ $VHDLVersion = "08" + Write-Host "Compiling libraries for VHDL-$VHDLVersion" -ForegroundColor Cyan + + # ---------------------------------------------------------------------- + # v08\std + # ---------------------------------------------------------------------- + $VHDLLibrary = "std" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VHDLDestinationLibraryDirectory\$VHDLLibrary\v$VHDLVersion" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "std08" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLLibrary\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C --bootstrap --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v08\ieee + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "ieee" + Write-Host " Compiling library '$VHDLLibrary'..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VHDLDestinationLibraryDirectory\$VHDLFlavor\v$VHDLVersion" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee2008" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital2000" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" -frelaxed-rules --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + # ---------------------------------------------------------------------- + # v08\synopsys + # ---------------------------------------------------------------------- + $VHDLLibrary = "ieee" + $VHDLFlavor = "synopsys" + Write-Host " Compiling library '$VHDLLibrary' ($VHDLFlavor)..." -ForegroundColor DarkCyan + + $LibraryDirectory = "$VHDLDestinationLibraryDirectory\$VHDLFlavor\v$VHDLVersion" + New-LibraryDirectory $LibraryDirectory # $EnableVerbose + Set-Location $LibraryDirectory + + $VHDLSourcesIndex = "ieee2008" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + foreach ($SourceFile in $SourceFiles[$VHDLFlavor]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLFlavor\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + + $VHDLSourcesIndex = "vital2000" + foreach ($SourceFile in $SourceFiles[$VHDLSourcesIndex]) + { Write-Host " file: v$VHDLVersion\$SourceFile.v$VHDLVersion" + $EnableVerbose -and (Write-Host " Patching file for VHDL-$VHDLVersion" ) | Out-Null + $EnableDebug -and (Write-Host " Get-Content `"$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl`" -Encoding Ascii ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Format-VHDLSourceFile -Version `"$VHDLVersion`" ``" -ForegroundColor DarkGray ) | Out-Null + $EnableDebug -and (Write-Host " | Out-File `"$SourceFile.v$VHDLVersion`" -Encoding Ascii" -ForegroundColor DarkGray ) | Out-Null + # Patch file + Get-Content "$VHDLSourceLibraryDirectory\$VHDLSourcesIndex\$SourceFile.vhdl" -Encoding Ascii ` + | Format-VHDLSourceFile -Version "$VHDLVersion" ` + | Out-File "$SourceFile.v$VHDLVersion" -Encoding Ascii + + # Analyze file + $InvokeExpr = "$GHDLExecutable -a -C `"-P../std`" -frelaxed-rules --std=$VHDLVersion --work=$VHDLLibrary $SourceFile.v$VHDLVersion 2>&1" + $EnableVerbose -and (Write-Host " Analyzing file '$SourceFile.v$VHDLVersion'" ) | Out-Null + $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings " " + if (($LastExitCode -ne 0) -or -not $?) + { $ErrorCount += 1 + if ($HaltOnError) + { Exit-CompileScript -1 } + } + } + +} # $VHDL2008 + + +Write-Host "--------------------------------------------------------------------------------" +Write-Host "Compiling VHDL libraries " -NoNewline +if ($ErrorCount -gt 0) +{ Write-Host "[FAILED]" -ForegroundColor Red } +else +{ Write-Host "[SUCCESSFUL]" -ForegroundColor Green } + +Exit-CompileScript diff --git a/scripts/windows/compile.ps1 b/scripts/windows/compile.ps1 new file mode 100644 index 000000000..da3c67731 --- /dev/null +++ b/scripts/windows/compile.ps1 @@ -0,0 +1,765 @@ +# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- +# vim: tabstop=2:shiftwidth=2:noexpandtab +# kate: tab-width 2; replace-tabs off; indent-width 2; +# +# ============================================================================== +# Authors: Patrick Lehmann (ported batch file to PowerShell) +# Brian Davis (contributions to the batch file) +# Tristan Gingold (initial batch file for compilations on Windows) +# +# PowerShell Script: Script to compile GHDL for Windows +# +# Description: +# ------------------------------------ +# This is a PowerShell script (executable) which: +# - compiles GHDL and GHDLFilter +# - analyses VHDL libraries +# - installs GHDL into a directory (xcopy deploiment) +# +# ============================================================================== +# Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold +# Copyright (C) 2015-2017 Patrick Lehmann +# +# GHDL is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2, or (at your option) any later +# version. +# +# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with GHDL; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# ============================================================================== + +# .SYNOPSIS +# GHDL for Windows - GHDL compile script +# Use 'compile.ps1 -Help' to see the integrated help page +# +# .EXAMPLE +# # +# # Normal flow +# PS> .\compile.ps1 -Clean +# PS> .\compile.ps1 -Compile +# PS> .\compile.ps1 -Install +# +# # Combine all commands in a single call +# PS>.\compile.ps1 -Clean -Compile -Install "C:\Tools\GHDL" +# +# # Install to user defined dir +# PS> .\compile.ps1 -Install "C:\Tools\GHDL" +# +# # Update or Uninstall +# PS> .\compile.ps1 -Update +# PS> .\compile.ps1 -Uninstall +# +# # Create a Zip-file +# PS>.\compile.ps1 -Package -Zip +# +[CmdletBinding()] +Param( + # Clean up all files and directories + [switch]$Clean, + [switch]$Clean_GHDL, + [switch]$Clean_Libraries, + + # Compile GHDL + [switch]$Compile, + [switch]$Compile_GHDL, + [switch]$Compile_Libraries, + + # Create an installer package + [switch]$Package, + # Creates a zip-file for xcopy deployment + [switch]$Zip, + # Creates a self-extracting ps1-file for xcopy deployment + [switch]$PS1, + + # Install all files into a directory (xcopy deployment) + [switch]$Install = $false, + [parameter(mandatory=$false, ValueFromRemainingArguments=$true)] + [string]$InstallDir = "", + # Update files + [switch]$Update, + # Uninstall all files from a directory + [switch]$Uninstall, + + # register GHDL in PATH + [Parameter(Mandatory=$false)] + [ValidateSet("Machine", "User", "Session", "Remove", "Pass")] + [String]$AddToPath = "", + + # Display this help" + [switch]$Help +) + +# configure script here +$RelPathToRoot = "..\.." + +# save parameters and current working directory +$Script_ScriptDir = $PSScriptRoot +$Script_WorkingDir = Get-Location +$GHDLRootDir = Convert-Path (Resolve-Path ($PSScriptRoot + "\" + $RelPathToRoot)) + +# set default values +$Hosting = $true +$EnableDebug = [bool]$PSCmdlet.MyInvocation.BoundParameters["Debug"] +$EnableVerbose = [bool]$PSCmdlet.MyInvocation.BoundParameters["Verbose"] -or $EnableDebug + +# load modules from GHDL's 'libraries' directory +Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -Debug:$false -ArgumentList "$Script_WorkingDir", $Hosting +Import-Module $PSScriptRoot\targets.psm1 -Verbose:$false -Debug:$false + +# Display help if no command was selected +$Help = $Help -or (-not ( + $All -or + $Clean -or $Clean_GHDL -or $Clean_Libraries -or $Clean_Package_Zip -or + $Compile -or $Compile_GHDL -or $Compile_Libraries -or + $Package -or + $Install -or $Update -or $Uninstall + )) + +Write-Host "================================================================================" -ForegroundColor Magenta +Write-Host "GHDL for Windows - GHDL compile and bundle script" -ForegroundColor Magenta +Write-Host "================================================================================" -ForegroundColor Magenta + +if ($Help) +{ Get-Help $MYINVOCATION.InvocationName -Detailed + Exit-CompileScript +} + +if ($All) +{ $Clean = $true + $Compile = $true + $Package = $true +} +if ($Clean) +{ $Clean_GHDL = $true + $Clean_Libraries = $true + $Clean_Package_Zip = $true +} +if ($Compile) +{ $Compile_GHDL = $true + $Compile_Libraries = $true +} + +# configure some variables: paths, executables, directory names, ... +$GHDLVersion = Get-GHDLVersion $GHDLRootDir +$Backend = "mcode" +$WindowsDirName = "dist\windows" #\$Backend" +$BuildDirectoryName = "build" +$BuildBackendDirectoryName = "$BuildDirectoryName\$Backend" +$VHDLLibrariesDirectoryName = "lib" +$PackageDirectoryName = "build\zip\$Backend" +$ZipPackageFileName = "ghdl-$Backend-$GHDLVersion.zip" +$PS1PackageFileName = "ghdl-$Backend-$GHDLVersion.installer.ps1" +$InstallerTemplateFileName = "InstallerTemplate.ps1" +$DefaultInstallPath = "C:\Program Files (x86)\GHDL" # This is the default path for 32-bit applications (x86-32) + +# construct directories +$GHDLWindowsDir = "$GHDLRootDir\$WindowsDirName" +$GHDLBuildDir = "$GHDLRootDir\$BuildBackendDirectoryName" +$GHDLVendorLibraryDir = "$GHDLRootDir\libraries\vendors" +$GHDLCompiledLibraryDir = "$GHDLRootDir\$BuildBackendDirectoryName\$VHDLLibrariesDirectoryName" +$GHDLZipPackageDir = "$GHDLRootDir\$PackageDirectoryName" +$GHDLZipPackageFile = "$GHDLZipPackageDir\$ZipPackageFileName" +$InstallerTemplateFile = "$GHDLWindowsDir\$InstallerTemplateFileName" +$GHDLPS1PackageFile = "$GHDLZipPackageDir\$PS1PackageFileName" + +# construct files +$InstallDirFile = "$BuildDirectoryName\InstallDir.conf" + +$EnvPath_ContainerMapping = @{ + Machine = [EnvironmentVariableTarget]::Machine + User = [EnvironmentVariableTarget]::User +} + +function Exit-Script +{ [CmdletBinding()] + param( + [int]$ExitCode = 0 + ) + cd $Script_WorkingDir + # unload modules + Remove-Module shared -Verbose:$false -Debug:$false + Remove-Module targets -Verbose:$false -Debug:$false + exit $ExitCode +} + +# GitHub user: https://github.com/mkropat +# Gist account at GitHub: https://gist.github.com/mkropat +# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 +function Add-EnvPath +{ param( + [Parameter(Mandatory=$true)] + [string] $Path, + + [ValidateSet("Machine", "User", "Session")] + [string] $Container = "Session" + ) + + if ($Container -ne "Session") + { $containerType = $EnvPath_ContainerMapping[$Container] + $persistedPaths = [Environment]::GetEnvironmentVariable("Path", $containerType) -split ";" + if ($persistedPaths -notcontains $Path) + { $persistedPaths = $persistedPaths + $Path | where { $_ } + [Environment]::SetEnvironmentVariable("Path", $persistedPaths -join ";", $containerType) + } + } + + $envPaths = $env:Path -split ";" + if ($envPaths -notcontains $Path) + { $envPaths = $envPaths + $Path | where { $_ } + $env:Path = $envPaths -join ";" + } +} + +# GitHub user: https://github.com/mkropat +# Gist account at GitHub: https://gist.github.com/mkropat +# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 +function Remove-EnvPath +{ param ( + [Parameter(Mandatory=$true)] + [string] $Path, + + [ValidateSet("Machine", "User", "Session")] + [string] $Container = "Session" + ) + + if ($Container -ne "Session") + { $containerType = $EnvPath_ContainerMapping[$Container] + $persistedPaths = [Environment]::GetEnvironmentVariable("Path", $containerType) -split ";" + if ($persistedPaths -contains $Path) + { $persistedPaths = $persistedPaths | where { $_ -and $_ -ne $Path } + [Environment]::SetEnvironmentVariable("Path", $persistedPaths -join ";", $containerType) + } + } + + $envPaths = $env:Path -split ";" + if ($envPaths -contains $Path) + { $envPaths = $envPaths | where { $_ -and $_ -ne $Path } + $env:Path = $envPaths -join ";" + } +} + +# GitHub user: https://github.com/mkropat +# Gist account at GitHub: https://gist.github.com/mkropat +# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9 +function Get-EnvPath +{ param ( + [Parameter(Mandatory=$true)] + [ValidateSet("Machine", "User")] + [string] $Container + ) + + $containerType = $EnvPath_ContainerMapping[$Container] + [Environment]::GetEnvironmentVariable('Path', $containerType) -split ";" | where { $_ } +} + + +if ($false) +{ # Write-Host "Uninstalling GHDL $GHDLVersion for Windows..." + + # Write-Host "[ERROR]: This command is not implemented." -ForegroundColor Red + Exit-Script -1 +} # Uninstall +else +{ # ============================================================================ + # Clean tasks + # ============================================================================ + if ($Clean) + { Write-Host "Removing all created files and directories..." } + + if ($Clean_GHDL) + { $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1" + $Script_Parameters = @( + '-Clean', + '-Hosted', + '-Verbose:$EnableVerbose', + '-Debug:$EnableDebug' + ) + + Write-Host "Running compile-ghdl.ps1 -Clean ..." -ForegroundColor DarkCyan + Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") + Invoke-Expression $InvokeExpr + if ($LastExitCode -ne 0) + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red + Exit-Script -1 + } + else + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "Completed compile-ghdl.ps1 " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + } + } # Clean_GHDL + if ($Clean_Libraries) + { if ($Clean_GHDL) + { Write-Host } + + $Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1" + $Script_Parameters = @( + '-Clean', + '-Hosted', + '-Verbose:$EnableVerbose', + '-Debug:$EnableDebug' + ) + + Write-Host "Running compile-libraries.ps1 -Clean ..." -ForegroundColor DarkCyan + Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") + Invoke-Expression $InvokeExpr + if ($LastExitCode -ne 0) + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red + Exit-Script -1 + } + else + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "Completed compile-libraries.ps1 " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + } + } # Clean_Libraries + if ($Clean_Package_Zip) + { if ($Clean_GHDL -or $Clean_Libraries) + { Write-Host } + + Write-Host "Running more clean-up tasks..." -ForegroundColor DarkCyan + Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "Removing installer packages and temporary directories..." -ForegroundColor Yellow + if (Test-Path -Path $GHDLZipPackageDir) + { Write-Host " rmdir $GHDLZipPackageDir" + Remove-Item $GHDLZipPackageDir -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: While deleting '$GHDLZipPackageDir'." -ForegroundColor Red + Exit-Script -1 + } + } + + if (Test-Path -Path $GHDLZipPackageFile) + { Write-Host " rm $GHDLZipPackageFile" + Remove-Item $GHDLZipPackageFile -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: While deleting '$GHDLZipPackageFile'." -ForegroundColor Red + Exit-Script -1 + } + } + + Write-Host + Write-Host "Clean " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + } # Clean_Package_Zip + + # ============================================================================ + # Compile tasks + # ============================================================================ + if ($Compile_GHDL) + { if ($Clean) + { Write-Host } + + $Script_Path = $GHDLWindowsDir + "\compile-ghdl.ps1" + $Script_Parameters = @() + $Script_Parameters = @( + '-All', + '-Hosted', + '-Verbose:$EnableVerbose', + '-Debug:$EnableDebug' + ) + + # Write-Host "Compiling GHDL $GHDLVersion for Windows..." -ForegroundColor DarkCyan + # Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + + Write-Host + Write-Host "Running compile-ghdl.ps1 -All ..." -ForegroundColor DarkCyan + Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") + Invoke-Expression $InvokeExpr + if ($LastExitCode -ne 0) + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red + Exit-Script -1 + } + else + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "Completed compile-ghdl.ps1 " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + } + } # Compile_GHDL + if ($Compile_Libraries) + { if ($Compile_GHDL) + { Write-Host } + + $Script_Path = $GHDLWindowsDir + "\compile-libraries.ps1" + $Script_Parameters = @() + $Script_Parameters = @( + '-Compile', + '-Hosted', + '-Verbose:$EnableVerbose', + '-Debug:$EnableDebug' + ) + + # Write-Host "Compiling GHDL's libraries ..." -ForegroundColor DarkCyan + # Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + + $env:GHDL = "$GHDLBuildDir\ghdl.exe" + Write-Host ("Setting env:GHDL to '" + $env:GHDL + "'") + + Write-Host + Write-Host "Running compile-libraries.ps1 -Compile ..." -ForegroundColor DarkCyan + Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + $InvokeExpr = "$Script_Path " + ($Script_Parameters -join " ") + Invoke-Expression $InvokeExpr + if ($LastExitCode -ne 0) + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "[ERROR]: While executing '$InvokeExpr'." -ForegroundColor Red + Exit-Script -1 + } + else + { Write-Host "--------------------------------------------------------------------------------" -ForegroundColor DarkCyan + Write-Host "Completed compile-libraries.ps1 " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + } + } # Compile_GHDL + + # ============================================================================ + # Package tasks + # ============================================================================ + if ($Package) + { Write-Host "Creating an installation package for GHDL $GHDLVersion for Windows" + $Good = $false + + if ($Zip) + { Write-Host "Loading PowerShell Community Extensions (PSCX) " -NoNewline + if ((Get-Module -ListAvailable | Where {$_.Name -like "PSCX"}).Version -ge "3.1.0.0") + { Import-Module Pscx -Verbose:$false + Write-Host "[Done]" -ForegroundColor Green + } + else + { Write-Host "[FAILED]" -ForegroundColor RED + Exit-Script -1 + } + + Write-Host "Output format: zip-file" + Write-Host " Removing old directory '$GHDLZipPackageDir'." + if (Test-Path -Path $GHDLZipPackageDir) + { Remove-Item $GHDLZipPackageDir -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: While deleting '$GHDLZipPackageDir'." -ForegroundColor Red + Exit-Script -1 + } + } + if (Test-Path -Path $GHDLZipPackageFile) + { Remove-Item $GHDLZipPackageFile -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: While deleting '$GHDLZipPackageFile'." -ForegroundColor Red + Exit-Script -1 + } + } + + Write-Host " Creating directory '$GHDLZipPackageDir' and sub-directories..." + New-Item -ItemType directory -Path "$GHDLZipPackageDir" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$GHDLZipPackageDir\bin" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$GHDLZipPackageDir\include" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$GHDLZipPackageDir\lib" -ErrorAction SilentlyContinue | Out-Null + + Write-Host " Gathering files..." + # executables + Copy-Item "$GHDLBuildDir\ghdl.exe" "$GHDLZipPackageDir\bin\ghdl.exe" -ErrorAction SilentlyContinue + # include files + Copy-Item "$GHDLRootDir\src\grt\vpi_user.h" "$GHDLZipPackageDir\include" -ErrorAction SilentlyContinue + # pre-compile scripts + Copy-Item $GHDLVendorLibraryDir -Recurse "$GHDLZipPackageDir\lib\vendors" -ErrorAction SilentlyContinue + # pre-compiled libraries + Copy-Item $GHDLCompiledLibraryDir -Recurse "$GHDLZipPackageDir" -ErrorAction SilentlyContinue + + Write-Host " Compressing all files into '$GHDLZipPackageFile'..." + $file = Get-ChildItem $GHDLZipPackageDir -Recurse | Write-Zip -IncludeEmptyDirectories -EntryPathRoot $GHDLZipPackageDir -OutputPath $GHDLZipPackageFile + Write-Host " $([math]::round(($file.Length / 1MB), 3)) MiB written to disk" + + Write-Host + Write-Host "Creating package " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + + $Good = $true + } + + if ($PS1) + { Write-Host "Creating a self-extracting PowerShell package for GHDL $GHDLVersion for Windows" + + if (-not (Test-Path -Path $GHDLZipPackageFile)) + { Write-Host "[ERROR]: ZIP file '$GHDLZipPackageFile' does not exist." -ForegroundColor Red + Exit-Script -1 + } + + # Read ZIP file and convert it to base64 + $ResolvedPath = Resolve-Path "$GHDLZipPackageFile" + $CompressedFileContentAsBytes = [System.IO.File]::ReadAllBytes("$ResolvedPath") + $CompressedFileContentInBase64 = [System.Convert]::ToBase64String($CompressedFileContentAsBytes) + + # Read a Installer template and add the base64 content + $Installer = Get-Content $InstallerTemplateFile + $Installer = $Installer -replace "# DATASECTION", "`$CompressedFileContentInBase64 = `"$CompressedFileContentInBase64`"" + $Installer | Out-File -FilePath $GHDLPS1PackageFile + + Write-Host + Write-Host "Creating package " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + + $Good = $true + } + + if (-not $Good) + { Write-Host "[ERROR]: No package format selected." -ForegroundColor Red + Write-Host "Possible formats:" + Write-Host " - Zip-file (-Zip)" + Write-Host + } + } + # ============================================================================ + # Install tasks + # ============================================================================ + if ($Install) + { Write-Host "Installing GHDL $GHDLVersion for Windows..." + if ($InstallDir -eq "") + { if (Test-Path $InstallDirFile -PathType Leaf) + { Write-Host " Reading installation path from '$InstallDirFile' ..." + $InstallPath = Get-Content $InstallDirFile -Encoding Ascii + } + else + { $InstallPath = $DefaultInstallPath } + } + else + { $InstallPath = $InstallDir } + $InstallPath = $InstallPath.TrimEnd("\") + + if ($Zip) + { Write-Host "Loading PowerShell Community Extensions (PSCX) " -NoNewline + if ((Get-Module -ListAvailable | Where {$_.Name -like "PSCX"}).Version -ge "3.1.0.0") + { Import-Module Pscx -Verbose:$false + Write-Host "[Done]" -ForegroundColor Green + } + else + { Write-Host "[FAILED]" -ForegroundColor RED + Exit-Script -1 + } + + Write-Host " Installing from Zip-file..." + + Write-Host "[ERROR]: This command is not implemented." -ForegroundColor Red + } + else + { Write-Host " Writing installation path to '$InstallDirFile'..." + $InstallPath | Out-File -FilePath $InstallDirFile -Encoding Ascii + + if (Test-Path -Path $InstallPath) + { Write-Host "[ERROR]: Directory '$InstallPath' already exists." -ForegroundColor Red + Exit-Script -1 + } + Write-Host " Install directory: $InstallPath" + Write-Host " Creating directory '$InstallPath' and sub-directories..." + New-Item -ItemType directory -Path "$InstallPath" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$InstallPath\bin" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$InstallPath\include" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$InstallPath\lib" -ErrorAction SilentlyContinue | Out-Null + + Write-Host " Copying files..." + # executables + Copy-Item "$GHDLBuildDir\ghdl.exe" "$InstallPath\bin\ghdl.exe" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # include files + Copy-Item "$GHDLRootDir\src\grt\vpi_user.h" "$InstallPath\include" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # pre-compile scripts + Copy-Item $GHDLVendorLibraryDir -Recurse "$InstallPath\lib" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # pre-compiled libraries + Copy-Item $GHDLCompiledLibraryDir -Recurse "$InstallPath" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + + while($true) + { Write-Host " Install GHDL in PATH at machine level? [" -NoNewline -ForegroundColor DarkCyan + Write-Host "M" -NoNewline -ForegroundColor Cyan + Write-Host "achine/" -NoNewline -ForegroundColor DarkCyan + Write-Host "u" -NoNewline -ForegroundColor Cyan + Write-Host "ser/" -NoNewline -ForegroundColor DarkCyan + Write-Host "s" -NoNewline -ForegroundColor Cyan + Write-Host "ession/" -NoNewline -ForegroundColor DarkCyan + Write-Host "p" -NoNewline -ForegroundColor Cyan + Write-Host "ass]: " -NoNewline -ForegroundColor DarkCyan + $InstallInPath = (Read-Host).ToLower() + if ($InstallInPath -in "m","u","s","p") + { break } + else + { Write-Host "[ERROR]: Unsupported choice: '$InstallInPath'." -ForegroundColor Red } + } + + if (($InstallInPath -eq "") -or ($InstallInPath -eq "m")) + { Write-Host " Adding GHDL to PATH at machine level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Machine" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "u") + { Write-Host " Adding GHDL to PATH at user level." + Add-EnvPath -Path "$InstallPath\bin" -Container "User" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "s") + { Write-Host " Adding GHDL to PATH at session level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + + Write-Host + Write-Host "Installing files " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + + Exit-Script + } # Zip + } # Install + elseif ($Update) + { Write-Host "Updating GHDL $GHDLVersion for Windows..." + if (Test-Path $InstallDirFile -PathType Leaf) + { Write-Host " Reading installation path from '$InstallDirFile' ..." + $InstallPath = Get-Content $InstallDirFile -Encoding Ascii + } + else + { if ($InstallDir -eq "") + { } + else + { $InstallPath = $InstallDir } + } + $InstallPath = $InstallPath.TrimEnd("\") + + Write-Host " Install directory: $InstallPath" + if (Test-Path -Path $InstallPath) + { Write-Host " Cleaning up installation directory '$InstallPath'." -ForegroundColor Yellow + Get-ChildItem -Path $InstallPath -Depth 0 | foreach { Remove-Item $_.FullName -Recurse -Force } + } + + + Write-Host " Creating directory sub-directories in '$InstallPath' ..." + New-Item -ItemType directory -Path "$InstallPath\bin" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$InstallPath\include" -ErrorAction SilentlyContinue | Out-Null + New-Item -ItemType directory -Path "$InstallPath\lib" -ErrorAction SilentlyContinue | Out-Null + + Write-Host " Copying files..." + # executables + Copy-Item "$GHDLBuildDir\ghdl.exe" "$InstallPath\bin\ghdl.exe" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # include files + Copy-Item "$GHDLRootDir\src\grt\vpi_user.h" "$InstallPath\include" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # pre-compile scripts + Copy-Item $GHDLVendorLibraryDir -Recurse "$InstallPath\lib" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + # pre-compiled libraries + Copy-Item $GHDLCompiledLibraryDir -Recurse "$InstallPath" -Verbose:$EnableVerbose -ErrorAction SilentlyContinue + + if ($AddToPath -eq "") + { while($true) + { Write-Host " Install GHDL in PATH at machine level? [" -NoNewline -ForegroundColor DarkCyan + Write-Host "M" -NoNewline -ForegroundColor Cyan + Write-Host "achine/" -NoNewline -ForegroundColor DarkCyan + Write-Host "u" -NoNewline -ForegroundColor Cyan + Write-Host "ser/" -NoNewline -ForegroundColor DarkCyan + Write-Host "s" -NoNewline -ForegroundColor Cyan + Write-Host "ession/" -NoNewline -ForegroundColor DarkCyan + Write-Host "r" -NoNewline -ForegroundColor Cyan + Write-Host "emove/" -NoNewline -ForegroundColor DarkCyan + Write-Host "p" -NoNewline -ForegroundColor Cyan + Write-Host "ass]: " -NoNewline -ForegroundColor DarkCyan + $InstallInPath = (Read-Host).ToLower() + if ($InstallInPath -in "m","u","s","r","p") + { break } + else + { Write-Host "[ERROR]: Unsupported choice: '$InstallInPath'." -ForegroundColor Red } + } + } + elseif ($AddToPath -eq "Machine") + { $InstallInPath = "m" } + elseif ($AddToPath -eq "User") + { $InstallInPath = "u" } + elseif ($AddToPath -eq "Session") + { $InstallInPath = "s" } + elseif ($AddToPath -eq "Remove") + { $InstallInPath = "r" } + elseif ($AddToPath -eq "Pass") + { $InstallInPath = "p" } + + if ($InstallInPath -ne "p") + { Write-Host " Removing GHDL from PATH variables in Machine, User, Session ..." -ForegroundColor Yellow + foreach ($container in @("Machine", "User")) + { foreach ($entry in (Get-EnvPath -Container $container)) + { if ($entry.ToLower().Contains("ghdl")) + { Write-Host " Removing '$entry' from $container level." + Remove-EnvPath -Path $entry -Container $container + } + } + } + Remove-EnvPath -Path $entry -Container "Session" + + if (($InstallInPath -eq "") -or ($InstallInPath -eq "m")) + { Write-Host " Adding GHDL to PATH at machine level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Machine" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "u") + { Write-Host " Adding GHDL to PATH at user level." + Add-EnvPath -Path "$InstallPath\bin" -Container "User" + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + elseif ($InstallInPath -eq "s") + { Write-Host " Adding GHDL to PATH at session level." + Add-EnvPath -Path "$InstallPath\bin" -Container "Session" + } + } + + Write-Host + Write-Host "Updating files " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + + Exit-Script + } # Update + elseif ($Uninstall) + { Write-Host "Uninstalling GHDL $GHDLVersion for Windows..." + if (Test-Path $InstallDirFile -PathType Leaf) + { Write-Host " Reading installation path from '$InstallDirFile' ..." + $InstallPath = Get-Content $InstallDirFile -Encoding Ascii + } + else + { $InstallPath = $DefaultInstallPath } + + Write-Host " Install directory: $InstallPath" + if (Test-Path -Path $InstallPath) + { Write-Host " Removing installation directory '$InstallPath'." -ForegroundColor Yellow + Remove-Item $InstallPath -Recurse -Force -ErrorAction SilentlyContinue + } + + Write-Host " Removing GHDL from PATH variables in Machine, User, Session ..." -ForegroundColor Yellow + foreach ($container in @("Machine", "User")) + { foreach ($entry in (Get-EnvPath -Container $container)) + { if ($entry.ToLower().Contains("ghdl")) + { Write-Host " Removing '$entry' from $container level." + Remove-EnvPath -Path $entry -Container $container + } + } + } + Remove-EnvPath -Path $entry -Container "Session" + + Write-Host + Write-Host "Uninstalling files " -NoNewline + Write-Host "[SUCCESSFUL]" -ForegroundColor Green + Write-Host + + Exit-Script + } # Uninstall + +} # Clean + +Exit-Script diff --git a/scripts/windows/mcode/Makefile.in b/scripts/windows/mcode/Makefile.in new file mode 100644 index 000000000..be1f11516 --- /dev/null +++ b/scripts/windows/mcode/Makefile.in @@ -0,0 +1,54 @@ +PREFIX=/usr/local +target=i686-pc-linux-gnu + +CFLAGS=-O +GNATFLAGS=$(CFLAGS) -gnatn + +GRT_FLAGS=$(CFLAGS) + +all: ghdl_mcode std.v93 std.v87 ieee.v93 ieee.v87 synopsys.v93 synopsys.v87 mentor.v93 + + +GRTSRCDIR=grt + +####grt Makefile.inc + +ghdl_mcode: default_paths.ads $(GRT_ADD_OBJS) mmap_binding.o force + gnatmake -aIghdldrv -aIghdl -aIortho -aIgrt $(GNATFLAGS) ghdl_mcode $(GNAT_BARGS) -largs mmap_binding.o $(GNAT_LARGS) $(GRT_ADD_OBJS) $(GRT_EXTRA_LIB) -Wl,--version-script=$(GRTSRCDIR)/grt.ver -Wl,--export-dynamic + +mmap_binding.o: ortho/mmap_binding.c + $(CC) -c -g -o $@ $< + +default_paths.ads: Makefile + echo "-- DO NOT EDIT" > tmp-dpaths.ads + echo "-- This file is created by Makefile" >> tmp-dpaths.ads + echo "package Default_Paths is" >> tmp-dpaths.ads + echo " Prefix : constant String :=">> tmp-dpaths.ads + echo " \"$(PREFIX)/lib/ghdl/\";" >> tmp-dpaths.ads + echo "end Default_Paths;" >> tmp-dpaths.ads + if test -r $@ && cmp tmp-dpaths.ads $@; then \ + echo "$@ unchanged"; \ + else \ + mv tmp-dpaths.ads $@; \ + fi + $(RM) tmp-dpaths.ads + +force: + +LIB93_DIR:=./lib/v93 +LIB87_DIR:=./lib/v87 +LIBSRC_DIR:=./libraries +ANALYZE=../../../ghdl_mcode -a --ieee=none +REL_DIR=../../.. +VHDLLIBS_COPY_OBJS:=no +CP=cp +LN=ln -s + +./lib: + mkdir $@ + +$(LIB93_DIR) $(LIB87_DIR): ./lib + mkdir $@ + + +####libraries Makefile.inc diff --git a/scripts/windows/mcode/binary_file-format.ads b/scripts/windows/mcode/binary_file-format.ads new file mode 100644 index 000000000..daf2afe2e --- /dev/null +++ b/scripts/windows/mcode/binary_file-format.ads @@ -0,0 +1,3 @@ +with Binary_File.Coff; + +package Binary_File.Format renames Binary_File.Coff; diff --git a/scripts/windows/mcode/compile.bat b/scripts/windows/mcode/compile.bat new file mode 100644 index 000000000..9a1825e46 --- /dev/null +++ b/scripts/windows/mcode/compile.bat @@ -0,0 +1,31 @@ +mkdir build +cd build + +rem Do the compilation +set CFLAGS= -O -Wall + +gcc -c %CFLAGS% ../../../src/grt/grt-cstdio.c +if errorlevel 1 goto failed + +gcc -c %CFLAGS% ../../../src/grt/grt-cvpi.c +if errorlevel 1 goto failed + +gcc -c %CFLAGS% ../../../src/grt/config/clock.c +if errorlevel 1 goto failed + +gcc -c %CFLAGS% ../../../src/ortho/mcode/memsegs_c.c +if errorlevel 1 goto failed + +gcc -c %CFLAGS% -DWITH_GNAT_RUN_TIME ../../../src/grt/config/win32.c +if errorlevel 1 goto failed + +gnatmake %CFLAGS% -gnatn -aI../windows -aI../../../src -aI../../../src/ghdldrv -aI../../../src/psl -aI../../../src/grt -aI../../../src/ortho/mcode -aI../../../src/vhdl -aI../../../src/vhdl/translate ghdl_jit -aI../../../src/ortho -o ghdl.exe -largs grt-cstdio.o clock.o grt-cvpi.o memsegs_c.o win32.o -ldbghelp -Wl,--stack,8404992 +if errorlevel 1 goto failed + +cd .. +exit /b 0 + +:failed +echo "Compilation failed" +cd .. +exit /b 1 diff --git a/scripts/windows/mcode/complib.bat b/scripts/windows/mcode/complib.bat new file mode 100644 index 000000000..e7291ad03 --- /dev/null +++ b/scripts/windows/mcode/complib.bat @@ -0,0 +1,119 @@ +set GHDL=ghdl + +cd build +gnatmake -aI..\windows ghdlfilter +cd .. + +set REL=..\..\.. +set LIBSRC=%REL%\..\..\libraries + +:: +:: library sources +:: +set STD_SRCS= textio textio-body +set IEEE_SRCS= std_logic_1164 std_logic_1164-body numeric_std numeric_std-body numeric_bit numeric_bit-body +set MATH_SRCS= math_real math_real-body math_complex math_complex-body + +set STD08_SRCS= textio textio-body env env-body +set IEEE08_SRCS= std_logic_1164 std_logic_1164-body std_logic_textio math_real math_real-body math_complex math_complex-body numeric_bit numeric_bit-body numeric_bit_unsigned numeric_bit_unsigned-body numeric_std numeric_std-body numeric_std_unsigned numeric_std_unsigned-body fixed_float_types fixed_generic_pkg fixed_generic_pkg-body fixed_pkg float_generic_pkg float_generic_pkg-body float_pkg ieee_bit_context ieee_std_context + +set VITAL95_SRCS= vital_timing vital_timing-body vital_primitives vital_primitives-body +set VITAL2000_SRCS= timing_p timing_b prmtvs_p prmtvs_b memory_p memory_b + +set SYNOPSYS_SRCS= std_logic_arith std_logic_textio std_logic_unsigned std_logic_signed std_logic_misc std_logic_misc-body +set MENTOR_SRCS= std_logic_arith std_logic_arith-body + + +mkdir lib +cd lib + +::::::::::::::::: +echo v87 libraries... + +mkdir v87 +cd v87 + +echo std +mkdir std +cd std +for %%F in (%STD_SRCS%) do %REL%\build\ghdlfilter -v87 < %LIBSRC%\std\%%F.vhdl > %%F.v87 && %REL%\build\%GHDL% -a --std=87 --bootstrap --work=std %%F.v87 +cd .. + +echo ieee +mkdir ieee +cd ieee +for %%F in (%IEEE_SRCS%) do %REL%\build\ghdlfilter -v87 < %LIBSRC%\ieee\%%F.vhdl > %%F.v87 && %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee %%F.v87 +for %%F in (%VITAL95_SRCS%) do copy %LIBSRC%\vital95\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee %%F.vhd +cd .. + +echo synopsys +mkdir synopsys +cd synopsys +for %%F in (%IEEE_SRCS%) do %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee ..\ieee\%%F.v87 +for %%F in (%VITAL95_SRCS%) do %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee ..\ieee\%%F.vhd +for %%F in (%SYNOPSYS_SRCS%) do copy %LIBSRC%\synopsys\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=87 -P..\std --work=ieee %%F.vhd +cd .. + +cd .. + +::::::::::::::::: +echo v93 libraries... + +mkdir v93 +cd v93 + +echo std +mkdir std +cd std +for %%F in (%STD_SRCS%) do %REL%\build\ghdlfilter -v93 < %LIBSRC%\std\%%F.vhdl > %%F.v93 && %REL%\build\%GHDL% -a --std=93 --bootstrap --work=std %%F.v93 +cd .. + +echo ieee +mkdir ieee +cd ieee +for %%F in (%IEEE_SRCS%) do %REL%\build\ghdlfilter -v93 < %LIBSRC%\ieee\%%F.vhdl > %%F.v93 && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.v93 +for %%F in (%VITAL2000_SRCS%) do copy %LIBSRC%\vital2000\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.vhd +for %%F in (%MATH_SRCS%) do copy %LIBSRC%\ieee\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.vhd +cd .. + +echo synopsys +mkdir synopsys +cd synopsys +for %%F in (%IEEE_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.v93 +for %%F in (%VITAL2000_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd +for %%F in (%MATH_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd +for %%F in (%SYNOPSYS_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\..\v87\synopsys\%%F.vhd +cd .. + +echo mentor +mkdir mentor +cd mentor +for %%F in (%IEEE_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.v93 +for %%F in (%VITAL2000_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd +for %%F in (%MATH_SRCS%) do %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee ..\ieee\%%F.vhd +for %%F in (%MENTOR_SRCS%) do copy %LIBSRC%\mentor\%%F.vhdl %%F.vhd && %REL%\build\%GHDL% -a --std=93 -P..\std --work=ieee %%F.vhd +cd .. + +cd .. + +::::::::::::::::: +echo v08 libraries... + +mkdir v08 +cd v08 + +echo std +mkdir std +cd std +for %%F in (%STD08_SRCS%) do %REL%\build\ghdlfilter -v08 < %LIBSRC%\std\%%F.vhdl > %%F.v08 && %REL%\build\%GHDL% -a --std=08 --bootstrap --work=std %%F.v08 +cd .. + +echo ieee +mkdir ieee +cd ieee +for %%F in (%IEEE08_SRCS%) do %REL%\build\ghdlfilter -v08 < %LIBSRC%\ieee2008\%%F.vhdl > %%F.v08 && %REL%\build\%GHDL% -a --std=08 -P..\std --work=ieee %%F.v08 +cd .. + +::::::::::::::::: + +cd ..\.. diff --git a/scripts/windows/mcode/default_paths.ads b/scripts/windows/mcode/default_paths.ads new file mode 100644 index 000000000..6b1d9d952 --- /dev/null +++ b/scripts/windows/mcode/default_paths.ads @@ -0,0 +1,9 @@ +with Windows_Default_Path; +pragma Elaborate_All (Windows_Default_Path); + +package Default_Paths is + Install_Prefix : constant String := + Windows_Default_Path.Get_Windows_Exec_Path; + Lib_Prefix : constant String := "lib"; + Shared_Library_Extension : constant String := ".dll"; +end Default_Paths; diff --git a/scripts/windows/mcode/ghdl.nsi b/scripts/windows/mcode/ghdl.nsi new file mode 100644 index 000000000..21ecb50c4 --- /dev/null +++ b/scripts/windows/mcode/ghdl.nsi @@ -0,0 +1,458 @@ +; ghdl.nsi +; +; This script is based on example2.nsi. +; remember the directory, +; Check if administrator +; uninstall support +; TODO: +; * allow multiple version +; * command line installation +; * Allow user install + +;-------------------------------- +!include version.nsi +;-------------------------------- + +; The name of the installer +Name "Ghdl" + +; The file to write +OutFile "ghdl-installer-${VERSION}.exe" + +SetDateSave on + +; The default installation directory +InstallDir $PROGRAMFILES\Ghdl + +; Registry key to check for directory (so if you install again, it will +; overwrite the old one automatically) +InstallDirRegKey HKLM "Software\Ghdl" "Install_Dir" + +LicenseData ..\..\..\COPYING +; LicenseForceSelection + +;-------------------------------- + +; Pages + +Page license +Page components +Page directory +Page instfiles + +UninstPage uninstConfirm +UninstPage instfiles + +;-------------------------------- +Function .onInit + Call IsNT + pop $R0 + StrCmp $R0 1 nt_ok + MessageBox MB_OK|MB_ICONEXCLAMATION "You must use Windows NT (XP/2000/Me...)" + Quit + +nt_ok: + Call IsUserAdmin + Pop $R0 + StrCmp $R0 "true" Admin + MessageBox MB_OK|MB_ICONEXCLAMATION "You must have Admin rights" + Quit + +Admin: + + ;;; Check if already installed. + ReadRegStr $0 HKLM "Software\Ghdl" "Install_Dir" + IfErrors not_installed + ReadRegStr $0 HKLM "Software\Ghdl" "Version" + IfErrors unknown_prev_version + Goto known_version +unknown_prev_version: + StrCpy $0 "(unknown)" +known_version: + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "You already have GHDL version $0 installed. Deinstall ?" IDCANCEL install_abort IDOK deinstall +install_abort: + Abort "Installation aborted" +deinstall: + ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "UninstallString" + IfErrors deinstall_failed + + ; First version of the GHDL installer adds quotes + StrCpy $1 $0 1 + StrCmp $1 '"' 0 str_ok + StrCpy $1 $0 "" 1 + StrCpy $0 $1 -1 +str_ok: + + ; Read install dir + ReadRegStr $1 HKLM "Software\Ghdl" "Install_Dir" + IfErrors deinstall_failed + +; MessageBox MB_OK 'copy $0 to $TEMP' + + ClearErrors +; MessageBox MB_OK 'copy $0 to $TEMP' + CopyFiles $0 $TEMP + IfErrors deinstall_failed + ExecWait '"$TEMP\uninst-ghdl.exe" /S _?=$1' + IfErrors deinstall_failed + Delete "$TEMP\uninst-ghdl.exe" + Return +deinstall_failed: + Delete $TEMP\uninst-ghdl.exe + MessageBox MB_YESNO|MB_ICONSTOP "Can't deinstall GHDL: de-installer not found or failed. Continue installation ?" IDNO install_abort +not_installed: + Return +FunctionEnd + +;-------------------------------- + +; The stuff to install +Section "Ghdl Compiler (required)" + + SectionIn RO + + ; Set output path to the installation directory. + SetOutPath $INSTDIR\bin + File /oname=ghdl.exe ..\build\ghdl.exe + + SetOutPath $INSTDIR + File /oname=COPYING.txt ..\..\..\COPYING + + ; Write the installation path into the registry + WriteRegStr HKLM "Software\Ghdl" "Install_Dir" $INSTDIR + ; Write te version + WriteRegStr HKLM "Software\Ghdl" "Version" ${VERSION} + + ; Write the uninstall keys for Windows + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "DisplayName" "Ghdl" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "UninstallString" $INSTDIR\uninst-ghdl.exe + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" "NoRepair" 1 + WriteUninstaller $INSTDIR\uninst-ghdl.exe" + +SectionEnd + +Section "VHDL standard and ieee libraries" + SectionIn RO + SetOutPath $INSTDIR\lib\v87 + File /r ..\lib\v87\std ..\lib\v87\ieee + SetOutPath $INSTDIR\lib\v93 + File /r ..\lib\v93\std ..\lib\v93\ieee + SetOutPath $INSTDIR\lib\v08 + File /r ..\lib\v08\std ..\lib\v08\ieee +SectionEnd + +Section "Synopsys libraries (Recommended)" + SetOutPath $INSTDIR\lib\v87 + File /r ..\lib\v87\synopsys + SetOutPath $INSTDIR\lib\v93 + File /r ..\lib\v93\synopsys +SectionEnd + +Section "Documentation (Recommended)" + SetOutPath $INSTDIR + File /oname=ghdl.htm ..\..\..\doc\ghdl.html +SectionEnd + +Section "Add in PATH (Recommended)" + WriteRegDWORD HKLM "Software\Ghdl" "PathSet" 1 + Push $INSTDIR\Bin + Call AddToPath +SectionEnd + +; Optional section (can be disabled by the user) +;Section "Start Menu Shortcuts" +; +; CreateDirectory "$SMPROGRAMS\Ghdl" +; CreateShortCut "$SMPROGRAMS\Ghdl\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 +; CreateShortCut "$SMPROGRAMS\Ghdl\Ghdl.lnk" "$INSTDIR\example2.nsi" "" "$INSTDIR\example2.nsi" 0 +; +;SectionEnd +; + +;-------------------------------- + +; Uninstaller + +Section "Uninstall" + + ReadRegDWORD $0 HKLM "Software\Ghdl" "PathSet" + StrCmp $0 "1" "" path_not_set + Push $INSTDIR\Bin + Call un.RemoveFromPath + +path_not_set: + + ; Remove registry keys + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ghdl" + DeleteRegKey HKLM Software\Ghdl + + ; Remove files and uninstaller + Delete $INSTDIR\bin\ghdl.exe + Delete $INSTDIR\bin\ghdl.htm + Delete $INSTDIR\uninst-ghdl.exe + Delete $INSTDIR\COPYING.txt + RMDir $INSTDIR\bin + RMDir /r $INSTDIR\lib + + + ; Remove shortcuts, if any + ; Delete "$SMPROGRAMS\Ghdl\*.*" + + ; Remove directories used + ; RMDir "$SMPROGRAMS\Ghdl" + RMDir "$INSTDIR" + +SectionEnd + +;;;;;;;; Misc functions + +; Author: Lilla (lilla@earthlink.net) 2003-06-13 +; function IsUserAdmin uses plugin \NSIS\PlusgIns\UserInfo.dll +; This function is based upon code in \NSIS\Contrib\UserInfo\UserInfo.nsi +; This function was tested under NSIS 2 beta 4 (latest CVS as of this writing). +; +; Usage: +; Call IsUserAdmin +; Pop $R0 ; at this point $R0 is "true" or "false" +; +Function IsUserAdmin +Push $R0 +Push $R1 +Push $R2 + +ClearErrors +UserInfo::GetName +IfErrors Win9x +Pop $R1 +UserInfo::GetAccountType +Pop $R2 + +StrCmp $R2 "Admin" 0 Continue +; Observation: I get here when running Win98SE. (Lilla) +; The functions UserInfo.dll looks for are there on Win98 too, +; but just don't work. So UserInfo.dll, knowing that admin isn't required +; on Win98, returns admin anyway. (per kichik) +; MessageBox MB_OK 'User "$R1" is in the Administrators group' +StrCpy $R0 "true" +Goto Done + +Continue: +; You should still check for an empty string because the functions +; UserInfo.dll looks for may not be present on Windows 95. (per kichik) +StrCmp $R2 "" Win9x +StrCpy $R0 "false" +;MessageBox MB_OK 'User "$R1" is in the "$R2" group' +Goto Done + +Win9x: +; comment/message below is by UserInfo.nsi author: +; This one means you don't need to care about admin or +; not admin because Windows 9x doesn't either +;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!" +StrCpy $R0 "true" + +Done: +;MessageBox MB_OK 'User= "$R1" AccountType= "$R2" IsUserAdmin= "$R0"' + +Pop $R2 +Pop $R1 +Exch $R0 +FunctionEnd + + +!define ALL_USERS + +!ifndef WriteEnvStr_RegKey + !ifdef ALL_USERS + !define WriteEnvStr_RegKey \ + 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' + !else + !define WriteEnvStr_RegKey 'HKCU "Environment"' + !endif +!endif + +!verbose 3 +!include "WinMessages.NSH" +!verbose 4 + +; AddToPath - Adds the given dir to the search path. +; Input - head of the stack +; Note - Win9x systems requires reboot + +Function AddToPath + Exch $0 + Push $1 + Push $2 + Push $3 + + # don't add if the path doesn't exist + IfFileExists "$0\*.*" "" AddToPath_done + + ReadEnvStr $1 PATH + Push "$1;" + Push "$0;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + Push "$1;" + Push "$0\;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + GetFullPathName /SHORT $3 $0 + Push "$1;" + Push "$3;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + Push "$1;" + Push "$3\;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + + ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH" + StrCpy $2 $1 1 -1 # copy last char + StrCmp $2 ";" 0 +2 # if last char == ; + StrCpy $1 $1 -1 # remove last char + StrCmp $1 "" AddToPath_NTdoIt + StrCpy $0 "$1;$0" + AddToPath_NTdoIt: + WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $0 + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + + AddToPath_done: + Pop $3 + Pop $2 + Pop $1 + Pop $0 +FunctionEnd + +; RemoveFromPath - Remove a given dir from the path +; Input: head of the stack + +Function un.RemoveFromPath + Exch $0 + Push $1 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + + IntFmt $6 "%c" 26 # DOS EOF + + ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH" + StrCpy $5 $1 1 -1 # copy last char + StrCmp $5 ";" +2 # if last char != ; + StrCpy $1 "$1;" # append ; + Push $1 + Push "$0;" + Call un.StrStr ; Find `$0;` in $1 + Pop $2 ; pos of our dir + StrCmp $2 "" unRemoveFromPath_done + ; else, it is in path + # $0 - path to add + # $1 - path var + StrLen $3 "$0;" + StrLen $4 $2 + StrCpy $5 $1 -$4 # $5 is now the part before the path to remove + StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove + StrCpy $3 $5$6 + + StrCpy $5 $3 1 -1 # copy last char + StrCmp $5 ";" 0 +2 # if last char == ; + StrCpy $3 $3 -1 # remove last char + + WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $3 + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + + unRemoveFromPath_done: + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 +FunctionEnd + +########################################### +# Utility Functions # +########################################### + +; IsNT +; no input +; output, top of the stack = 1 if NT or 0 if not +; +; Usage: +; Call IsNT +; Pop $R0 +; ($R0 at this point is 1 or 0) + +!macro IsNT un +Function ${un}IsNT + Push $0 + ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion + StrCmp $0 "" 0 IsNT_yes + ; we are not NT. + Pop $0 + Push 0 + Return + + IsNT_yes: + ; NT!!! + Pop $0 + Push 1 +FunctionEnd +!macroend +!insertmacro IsNT "" +;!insertmacro IsNT "un." + +; StrStr +; input, top of stack = string to search for +; top of stack-1 = string to search in +; output, top of stack (replaces with the portion of the string remaining) +; modifies no other variables. +; +; Usage: +; Push "this is a long ass string" +; Push "ass" +; Call StrStr +; Pop $R0 +; ($R0 at this point is "ass string") + +!macro StrStr un +Function ${un}StrStr +Exch $R1 ; st=haystack,old$R1, $R1=needle + Exch ; st=old$R1,haystack + Exch $R2 ; st=old$R1,old$R2, $R2=haystack + Push $R3 + Push $R4 + Push $R5 + StrLen $R3 $R1 + StrCpy $R4 0 + ; $R1=needle + ; $R2=haystack + ; $R3=len(needle) + ; $R4=cnt + ; $R5=tmp + loop: + StrCpy $R5 $R2 $R3 $R4 + StrCmp $R5 $R1 done + StrCmp $R5 "" done + IntOp $R4 $R4 + 1 + Goto loop +done: + StrCpy $R1 $R2 "" $R4 + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Exch $R1 +FunctionEnd +!macroend +!insertmacro StrStr "" +!insertmacro StrStr "un." + diff --git a/scripts/windows/mcode/ghdlfilter.adb b/scripts/windows/mcode/ghdlfilter.adb new file mode 100644 index 000000000..d75526dbd --- /dev/null +++ b/scripts/windows/mcode/ghdlfilter.adb @@ -0,0 +1,132 @@ +-- +-- Preprocessor to handle library source metacomments +-- +-- Limitations: +-- - line metacomments must occur at end of line with no trailing space before the line break +-- - block metacomments must start in column 1 +-- +-- Supported line metacomments: +-- +-- --!V87 +-- --V87 +-- --V93 +-- --V08 +-- +-- Supported block metacomments: +-- +-- --START-!V87 +-- --END-!V87 +-- +-- --START-V93 +-- --END-V93 +-- +-- --START-V08 +-- --END-V08 +-- +-- +with Ada.Command_Line; use Ada.Command_Line; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Ghdlfilter is + type Mode_Kind is (Mode_93, Mode_87, Mode_08); + Mode : Mode_Kind; + + Line : String (1 .. 128); + Len : Natural; + + Comment : Boolean; + Block_Comment : Boolean; +begin + if Argument_Count /= 1 then + Put_Line (Standard_Error, "usage: " & Command_Name & " -v93|-v87|-v08"); + return; + end if; + + if Argument (1) = "-v93" then + Mode := Mode_93; + elsif Argument (1) = "-v87" then + Mode := Mode_87; + elsif Argument (1) = "-v08" then + Mode := Mode_08; + else + Put_Line (Standard_Error, "bad mode"); + return; + end if; + + Block_Comment := False; + + loop + exit when End_Of_File; + Get_Line (Line, Len); + + Comment := Block_Comment; + + -- + -- look for line metacomments + -- + if Len > 6 then + + if Mode = Mode_87 and ( Line (Len - 5 .. Len) = "--!V87" ) then + Comment := True; + end if; + + end if; + + + if Len > 5 then + + if Mode = Mode_87 and ( (Line (Len - 4 .. Len) = "--V93") or (Line (Len - 4 .. Len) = "--V08") ) then + Comment := True; + + elsif Mode = Mode_93 and ( (Line (Len - 4 .. Len) = "--V87") or (Line (Len - 4 .. Len) = "--V08") ) then + Comment := True; + + elsif Mode = Mode_08 and ( (Line (Len - 4 .. Len) = "--V87") or (Line (Len - 4 .. Len) = "--V93") ) then + Comment := True; + end if; + + end if; + + -- + -- look for block metacomment start + -- + if Len = 12 + and then Mode /= Mode_93 + and then Line (1 .. 12) = "--START-!V87" then + Block_Comment := True; + end if; + + if Len = 11 + and then Mode /= Mode_93 + and then Line (1 .. 11) = "--START-V93" then + Block_Comment := True; + end if; + + if Len = 11 + and then Mode /= Mode_08 + and then Line (1 .. 11) = "--START-V08" then + Block_Comment := True; + end if; + + -- + -- look for block metacomment end + -- + if Len = 9 and then ( (Line (1 .. 9) = "--END-V93") or (Line (1 .. 9) = "--END-V08") ) then + Block_Comment := False; + end if; + + if Len = 10 and then ( Line (1 .. 10) = "--END-!V87" ) then + Block_Comment := False; + end if; + + -- + -- comment output lines as needed + -- + if Comment then + Put ("-- "); + end if; + + Put_Line (Line (1 .. Len)); + + end loop; +end Ghdlfilter; diff --git a/scripts/windows/mcode/ghdlversion.adb b/scripts/windows/mcode/ghdlversion.adb new file mode 100644 index 000000000..d2f1c28be --- /dev/null +++ b/scripts/windows/mcode/ghdlversion.adb @@ -0,0 +1,30 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Strings.Fixed; use Ada.Strings.Fixed; + +procedure Ghdlversion is + Line : String (1 .. 128); + Len : Natural; + Pos : Natural; + E : Natural; +begin + loop + exit when End_Of_File; + Get_Line (Line, Len); + + -- Search GHDL + Pos := Index (Line (1 .. Len), "GHDL "); + if Pos /= 0 then + Pos := Pos + 5; + E := Pos; + while Line (E) in '0' .. '9' + or Line (E) in 'a' .. 'z' + or Line (E) = '.' + loop + exit when E = Len; + E := E + 1; + end loop; + Put_Line ("!define VERSION """ & Line (Pos .. E - 1) & """"); + return; + end if; + end loop; +end Ghdlversion; diff --git a/scripts/windows/mcode/grt-backtraces-impl.ads b/scripts/windows/mcode/grt-backtraces-impl.ads new file mode 100644 index 000000000..81db677ed --- /dev/null +++ b/scripts/windows/mcode/grt-backtraces-impl.ads @@ -0,0 +1,3 @@ +with Grt.Backtraces.Jit; + +package Grt.Backtraces.Impl renames Grt.Backtraces.Jit; diff --git a/scripts/windows/mcode/grt-modules.adb b/scripts/windows/mcode/grt-modules.adb new file mode 100644 index 000000000..de5eb79b8 --- /dev/null +++ b/scripts/windows/mcode/grt-modules.adb @@ -0,0 +1,39 @@ +-- GHDL Run Time (GRT) - Modules. +-- Copyright (C) 2005 Tristan Gingold +-- +-- GHDL is free software; you can redistribute it and/or modify it under +-- the terms of the GNU General Public License as published by the Free +-- Software Foundation; either version 2, or (at your option) any later +-- version. +-- +-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or +-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +-- for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. +with System.Storage_Elements; -- Work around GNAT bug. +with Grt.Vcd; +with Grt.Vpi; +with Grt.Waves; +with Grt.Vital_Annotate; +with Grt.Disp_Tree; +with Grt.Disp_Rti; +with Grt.Backtraces; + +package body Grt.Modules is + procedure Register_Modules is + begin + -- List of modules to be registered. + Grt.Disp_Tree.Register; + Grt.Vcd.Register; + Grt.Waves.Register; + Grt.Vpi.Register; + Grt.Vital_Annotate.Register; + Grt.Disp_Rti.Register; + Grt.Backtraces.Register; + end Register_Modules; +end Grt.Modules; diff --git a/scripts/windows/mcode/ortho_code-x86-flags.ads b/scripts/windows/mcode/ortho_code-x86-flags.ads new file mode 100644 index 000000000..8915f3122 --- /dev/null +++ b/scripts/windows/mcode/ortho_code-x86-flags.ads @@ -0,0 +1,2 @@ +with Ortho_Code.X86.Flags_Windows; +package Ortho_Code.X86.Flags renames Ortho_Code.X86.Flags_Windows; diff --git a/scripts/windows/mcode/winbuild.bat b/scripts/windows/mcode/winbuild.bat new file mode 100644 index 000000000..670b77d1e --- /dev/null +++ b/scripts/windows/mcode/winbuild.bat @@ -0,0 +1,20 @@ +call windows\compile +if errorlevel 1 goto end + +call windows\complib +if errorlevel 1 goto end + +strip build\ghdl.exe + +gnatmake windows/ghdlversion -o windows/ghdlversion.exe +windows\ghdlversion < ..\..\src\version.ads > windows\version.nsi + +"c:\Program Files\NSIS\makensis" windows\ghdl.nsi +if errorlevel 1 goto end + +exit /b 0 + +:end +echo "Error during compilation" +exit /b 1 + diff --git a/scripts/windows/mcode/windows_default_path.adb b/scripts/windows/mcode/windows_default_path.adb new file mode 100644 index 000000000..c627356f9 --- /dev/null +++ b/scripts/windows/mcode/windows_default_path.adb @@ -0,0 +1,68 @@ +-- Find installation path (using executable). +-- Copyright (C) 2002 - 2016 Tristan Gingold +-- +-- GHDL is free software; you can redistribute it and/or modify it under +-- the terms of the GNU General Public License as published by the Free +-- Software Foundation; either version 2, or (at your option) any later +-- version. +-- +-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or +-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +-- for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. +-- +-- As a special exception, if other files instantiate generics from this +-- unit, or you link this unit with other files to produce an executable, +-- this unit does not by itself cause the resulting executable to be +-- covered by the GNU General Public License. This exception does not +-- however invalidate any other reasons why the executable file might be +-- covered by the GNU Public License. + +with Interfaces.C; use Interfaces.C; +with System; use System; + +package body Windows_Default_Path is + + subtype DWORD is Interfaces.C.Unsigned_Long; + subtype HINSTANCE is Address; + function GetModuleFileName (Inst : HINSTANCE; Buf : Address; Size : DWORD) + return DWORD; + pragma Import (Stdcall, GetModuleFileName, "GetModuleFileNameA"); + + function Get_Windows_Exec_Path return String + is + File : String (1 .. 256); + Size : DWORD; + P : Natural; + begin + -- Get exe file path. + Size := GetModuleFileName (Null_Address, File'Address, File'Length); + if Size = 0 or Size = File'Length then + return "{cannot find install path}\lib"; + end if; + + -- Remove Program file. + P := Natural (Size); + while P > 0 loop + exit when File (P) = '\'; + exit when File (P) = ':' and P = 2; + P := P - 1; + end loop; + if File (P) = '\' and P > 1 then + -- Remove directory + P := P - 1; + while P > 0 loop + exit when File (P) = '\'; + exit when File (P) = ':' and P = 2; + P := P - 1; + end loop; + end if; + + return File (1 .. P); + end Get_Windows_Exec_Path; +end Windows_Default_Path; diff --git a/scripts/windows/mcode/windows_default_path.ads b/scripts/windows/mcode/windows_default_path.ads new file mode 100644 index 000000000..9da3be559 --- /dev/null +++ b/scripts/windows/mcode/windows_default_path.ads @@ -0,0 +1,30 @@ +-- Find installation path (using executable). +-- Copyright (C) 2002 - 2016 Tristan Gingold +-- +-- GHDL is free software; you can redistribute it and/or modify it under +-- the terms of the GNU General Public License as published by the Free +-- Software Foundation; either version 2, or (at your option) any later +-- version. +-- +-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or +-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +-- for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. +-- +-- As a special exception, if other files instantiate generics from this +-- unit, or you link this unit with other files to produce an executable, +-- this unit does not by itself cause the resulting executable to be +-- covered by the GNU General Public License. This exception does not +-- however invalidate any other reasons why the executable file might be +-- covered by the GNU Public License. + +package Windows_Default_Path is + -- Get the default path from executable name. + -- This function is called during elaboration! + function Get_Windows_Exec_Path return String; +end Windows_Default_Path; diff --git a/scripts/windows/shared.psm1 b/scripts/windows/shared.psm1 new file mode 100644 index 000000000..33136941d --- /dev/null +++ b/scripts/windows/shared.psm1 @@ -0,0 +1,368 @@ +# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- +# vim: tabstop=2:shiftwidth=2:noexpandtab +# kate: tab-width 2; replace-tabs off; indent-width 2; +# +# ============================================================================== +# Authors: Patrick Lehmann +# +# PowerShell Module: The module provides common CmdLets for ... +# +# Description: +# ------------------------------------ +# This PowerShell module provides CommandLets (CmdLets) to ... +# +# ============================================================================== +# Copyright (C) 2016-2017 Patrick Lehmann +# +# GHDL is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2, or (at your option) any later +# version. +# +# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with GHDL; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# ============================================================================== + +[CmdletBinding()] +param( + [Parameter(Mandatory=$true)][string]$WorkingDir, + [Parameter(Mandatory=$true)][Switch]$Hosted +) + +$Module_WorkingDir = $WorkingDir +$Module_Hosted = $Hosted + +function Exit-CompileScript +{ <# + .SYNOPSIS + Undocumented + .DESCRIPTION + Undocumented + .PARAMETER ExitCode + ExitCode of this script run + #> + [CmdletBinding()] + param( + [int]$ExitCode = 0 + ) + cd $Module_WorkingDir + # unload modules + if (-not $Module_Hosted) + { Remove-Module shared -Verbose:$false -Debug:$false + Remove-Module targets -Verbose:$false -Debug:$false + } + exit $ExitCode +} + +function New-LibraryDirectory +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER Directory + Undocumented + #> + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)][string]$Directory #, + # [Parameter(Mandatory=$true)][bool]$EnableVerbose + ) + $EnableVerbose = $false + if (Test-Path -Path $Directory) + { $EnableVerbose -and (Write-Host " Directory '$Directory' already exists." ) | Out-Null } + else + { Write-Host " Creating directory '$Directory'." + New-Item -ItemType directory -Path $Directory -ErrorAction SilentlyContinue | Out-Null + } +} + +function Format-VHDLSourceFile +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER Version + Undocumented + .PARAMETER InputObject + A object stream is required as an input. + #> + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)][string]$Version, + [Parameter(ValueFromPipeline=$true)]$InputObject + ) + + begin + { $State = 1 + $Version = switch ($Version) + { "87" { 87 } + "93" { 93 } + "02" { 2 } + "08" { 8 } + } + } + + process + { if ($InputObject -is [String]) + { $Line = $InputObject.ToString() + if ($Line.StartsWith("--START-V")) + { $State = switch ($Line.Substring(9, 2)) + { "87" { 87 } + "93" { 93 } + "02" { 2 } + "08" { 8 } + } + } + elseif ($Line.StartsWith("--START-!V")) + { if ($Line.Substring(10, 2) -eq $Version) + { $State = 2 } + } + elseif ($Line.StartsWith("--END-V") -or $Line.StartsWith("--END-!V")) + { $State = 1 } + else + { if ($State -eq 1) + { if ($Line.EndsWith("--V$Version")) + { Write-Output $Line } + elseif (-not (($Line -like "*--V??") -or ($Line.EndsWith("--!V$Version")))) + { Write-Output $Line } + } + elseif ($State -eq $Version) + { Write-Output $Line } + } + } + else + { Write-Host "Unknown pipeline object type." -ForegroundColor Red } + } + + end + { + } +} + +function Restore-NativeCommandStream +{ <# + .SYNOPSIS + This CmdLet gathers multiple ErrorRecord objects and reconstructs outputs + as a single line. + + .DESCRIPTION + This CmdLet collects multiple ErrorRecord objects and emits one String + object per line. + .PARAMETER InputObject + A object stream is required as an input. + .PARAMETER Indent + Indentation string. + #> + [CmdletBinding()] + param( + [Parameter(ValueFromPipeline=$true)] + $InputObject + ) + + begin + { $LineRemainer = "" } + + process + { if ($InputObject -is [System.Management.Automation.ErrorRecord]) + { if ($InputObject.FullyQualifiedErrorId -eq "NativeCommandError") + { Write-Output $InputObject.ToString() } + elseif ($InputObject.FullyQualifiedErrorId -eq "NativeCommandErrorMessage") + { $NewLine = $LineRemainer + $InputObject.ToString() + while (($NewLinePos = $NewLine.IndexOf("`n")) -ne -1) + { Write-Output $NewLine.Substring(0, $NewLinePos) + $NewLine = $NewLine.Substring($NewLinePos + 1) + } + $LineRemainer = $NewLine + } + } + elseif ($InputObject -is [String]) + { Write-Output $InputObject } + else + { Write-Host "Unsupported object in pipeline stream" } + } + + end + { if ($LineRemainer -ne "") + { Write-Output $LineRemainer } + } +} + +function Write-ColoredGCCLine +{ <# + .SYNOPSIS + This CmdLet colors GHDL output lines. + + .DESCRIPTION + This CmdLet colors GHDL output lines. Warnings are prefixed with 'WARNING: ' + in yellow and errors are prefixed with 'ERROR: ' in red. + + .PARAMETER InputObject + A object stream is required as an input. + .PARAMETER SuppressWarnings + Skip warning messages. (Show errors only.) + .PARAMETER Indent + Indentation string. + #> + [CmdletBinding()] + param( + [Parameter(ValueFromPipeline=$true)] + $InputObject, + + [Parameter(Position=1)] + [switch]$SuppressWarnings = $false, + [Parameter(Position=2)] + [string]$Indent = "" + ) + + begin + { $ErrorRecordFound = $false } + + process + { if ($InputObject -is [String]) + { if ($InputObject -match ":\d+:\d+:\swarning:\s") + { if (-not $SuppressWarnings) + { Write-Host "${Indent}WARNING: " -NoNewline -ForegroundColor Yellow + Write-Host $InputObject + } + } + elseif ($InputObject -match ":\d+:\d+:\s") + { $ErrorRecordFound = $true + Write-Host "${Indent}ERROR: " -NoNewline -ForegroundColor Red + Write-Host $InputObject + } + else + { Write-Host "${Indent}$InputObject" } + } + else + { Write-Host "Unsupported object in pipeline stream" } + } + + end + { $ErrorRecordFound } +} + +function Write-ColoredGHDLLine +{ <# + .SYNOPSIS + This CmdLet colors GHDL output lines. + + .DESCRIPTION + This CmdLet colors GHDL output lines. Warnings are prefixed with 'WARNING: ' + in yellow and errors are prefixed with 'ERROR: ' in red. + + .PARAMETER InputObject + A object stream is required as an input. + + .PARAMETER SuppressWarnings + Skip warning messages. (Show errors only.) + #> + [CmdletBinding()] + param( + [Parameter(ValueFromPipeline=$true)] + $InputObject, + + [Parameter(Position=1)] + [switch]$SuppressWarnings = $false, + [Parameter(Position=2)] + [string]$Indent = "" + ) + + begin + { $ErrorRecordFound = $false } + + process + { if ($InputObject -is [String]) + { if ($InputObject -match ":\d+:\d+:warning:\s") + { if (-not $SuppressWarnings) + { Write-Host "${Indent}WARNING: " -NoNewline -ForegroundColor Yellow + Write-Host $InputObject + } + } + elseif ($InputObject -match ":\d+:\d+:\s") + { $ErrorRecordFound = $true + Write-Host "${Indent}ERROR: " -NoNewline -ForegroundColor Red + Write-Host $InputObject + } + else + { Write-Host "${Indent}$InputObject" } + } + else + { Write-Host "Unsupported object in pipeline stream" } + } + + end + { $ErrorRecordFound } +} + +function Write-HostExtended +{ <# + .SYNOPSIS + This CmdLet colors GHDL output lines. + + .DESCRIPTION + This CmdLet colors GHDL output lines. Warnings are prefixed with 'WARNING: ' + in yellow and errors are prefixed with 'ERROR: ' in red. + + .PARAMETER InputObject + A object stream is required as an input. + .PARAMETER Indent + Indentation string. + #> + [CmdletBinding()] + param( + [Parameter(ValueFromPipeline=$true)] + $InputObject, + + [Parameter(Position=1)] + [string]$Indent = "" + ) + + begin + { } + + process + { if ($InputObject -is [String]) + { Write-Host "${Indent}$InputObject" } + else + { Write-Host "Unsupported object in pipeline stream" } + } + + end + { } +} + +function Test-GitRepository +{ <# + .SYNOPSIS + Returns true, if the current working directy is under git control. + #> + + git rev-parse 2>&1 | Out-Null + return $LastExitCode -eq 0 +} + +# export functions +Export-ModuleMember -Function 'Exit-CompileScript' + +Export-ModuleMember -Function 'New-LibraryDirectory' +Export-ModuleMember -Function 'Format-VHDLSourceFile' + +Export-ModuleMember -Function 'Restore-NativeCommandStream' +Export-ModuleMember -Function 'Write-ColoredGCCLine' +Export-ModuleMember -Function 'Write-ColoredGHDLLine' +Export-ModuleMember -Function 'Write-HostExtended' + +Export-ModuleMember -Function 'Test-GitRepository' diff --git a/scripts/windows/targets.psm1 b/scripts/windows/targets.psm1 new file mode 100644 index 000000000..1264db247 --- /dev/null +++ b/scripts/windows/targets.psm1 @@ -0,0 +1,416 @@ +# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- +# vim: tabstop=2:shiftwidth=2:noexpandtab +# kate: tab-width 2; replace-tabs off; indent-width 2; +# +# ============================================================================== +# Authors: Patrick Lehmann +# +# PowerShell Module: The module provides build targets for GHDL. +# +# Description: +# ------------------------------------ +# This PowerShell module provides build targets for GHDL. +# +# ============================================================================== +# Copyright (C) 2016-2017 Patrick Lehmann +# +# GHDL is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2, or (at your option) any later +# version. +# +# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with GHDL; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# ============================================================================== + +# TODO: +# check if: +# - program are installed / auto find programs / auto find paths +# - program version + +# configure compiler tools +$Prog_GCC = "gcc.exe" +$Prog_GNATMake = "gnatmake.exe" +$Prog_Strip = "strip.exe" + +# configure output file +$GHDL_Mcode_Name = "ghdl.exe" + +# configure directory structure +$CommonSourceDirName = "src" +$WinMcodeSourceDirName = "dist\windows\mcode" +# $WinLLVMSourceDirName = "dist\windows\llvm" + +# construct file paths +$VersionFileName_In = "version.in" +$VersionFileName_Ads = "version.ads" + + +function Invoke-Clean +{ <# + .SYNOPSIS + This CommandLet removes all generated files. + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console. + #> + [CmdletBinding()] + param( + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + + $EnableDebug = -not $Quiet -and ( $PSCmdlet.MyInvocation.BoundParameters["Debug"]) + $EnableVerbose = -not $Quiet -and ($EnableDebug -or $PSCmdlet.MyInvocation.BoundParameters["Verbose"]) + + -not $Quiet -and (Write-Host "Executing build target 'Clean' ..." -ForegroundColor Yellow) | Out-Null + $EnableVerbose -and (Write-Host " Removing all created files and directories..." ) | Out-Null + if (Test-Path -Path $BuildDirectory) + { $EnableDebug -and (Write-Host " rmdir $BuildDirectory" ) | Out-Null + Remove-Item $BuildDirectory -Force -Recurse -ErrorAction SilentlyContinue + if ($? -eq $false) + { Write-Host "[ERROR]: Cannot remove '$BuildDirectory'." -ForegroundColor Red + return $true + } + } + return $false +} # Invoke-Clean + +function New-BuildDirectory +{ <# + .SYNOPSIS + This CommandLet creates a build directory if not existent, yet. + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console. + #> + [CmdletBinding()] + param( + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + + Write-Host "Executing build target 'BuildDirectory' ..." -ForegroundColor Yellow + if (Test-Path -Path $BuildDirectory -PathType Container) + { -not $Quiet -and (Write-Host " Directory '$BuildDirectory' already exists." ) | Out-Null } + else + { -not $Quiet -and (Write-Host " Creating new directory '$BuildDirectory'." ) | Out-Null + New-Item -ItemType Directory -Path $BuildDirectory -ErrorAction SilentlyContinue | Out-Null + if ($? -eq $false) + { Write-Host "[ERROR]: Cannot create '$BuildDirectory'." -ForegroundColor Red + return $true + } + } + + return $false +} # New-BuildDirectory + +function Get-GHDLVersion +{ <# + .SYNOPSIS + Returns the GHDL version string. + .PARAMETER GHDLRootDir + The repository root directory. + #> + [CmdletBinding()] + param( + [string] $GHDLRootDir + ) + # construct DirectoryPaths + $ConfigureFilePath = $GHDLRootDir + "\configure" + + if (-not (Test-Path -Path $ConfigureFilePath -PathType Leaf)) + { Write-Host "[ERROR]: Version file '$ConfigureFilePath' does not exists." -ForegroundColor Red + return $true + } + $FileContent = Get-Content -Path $ConfigureFilePath + foreach ($Line in $FileContent) + { if ($Line -match 'ghdl_version=\"(.+?)\"') + { return $Matches[2] } + } + Write-Host "[ERROR]: RegExp didn't match in '$ConfigureFilePath'." -ForegroundColor Red + return $true +} # Get-GHDLVersion + +function Invoke-PatchVersionFile +{ <# + .SYNOPSIS + This CommandLet patches the version file to include the git patch state. + .PARAMETER GHDLRootDir + The repository root directory. + .PARAMETER GitBranchName + The branch's name, where HEAD is located. + .PARAMETER GitCommitDataString + The DateTime when HEAD was commited. + .PARAMETER GitCommitHash + The Hash of HEAD. + .PARAMETER Quiet + Disable outputs to the host console. + #> + [CmdletBinding()] + param( + [string] $GHDLRootDir, + [string] $GitBranchName = "unknown", + [string] $GitCommitDataString = "unknown", + [string] $GitCommitHash = "........", + [switch] $Quiet = $false + ) + # construct DirectoryPaths + $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName + $VersionInputFilePath = $SourceDirectory + "\" + $VersionFileName_In + $VersionFilePath = $SourceDirectory + "\" + $VersionFileName_Ads + + Write-Host "Executing build target 'PatchVersionFile' ..." -ForegroundColor Yellow + + if (-not (Test-Path -Path $VersionInputFilePath -PathType Leaf)) + { Write-Host "[ERROR]: Version file '$VersionInputFilePath' does not exists." -ForegroundColor Red + return $true + } + -not $Quiet -and (Write-Host " Patching '$VersionInputFilePath'.") | Out-Null + $FileContent = Get-Content -Path $VersionInputFilePath -Encoding Ascii + if ($? -eq $false) + { Write-Host "[ERROR]: While opening '$VersionInputFilePath'." -ForegroundColor Red + return $true + } + $GHDLVersion = Get-GHDLVersion $GHDLRootDir + $FileContent = $FileContent -Replace "\s@VER@\s", $GHDLVersion + + $FileContent = $FileContent -Replace "\s\(tarball\)\s", " (commit: $GitCommitDataString; git branch: $GitBranchName'; hash: $GitCommitHash) " + + + $FileContent | Out-File $VersionFilePath -Encoding Ascii + if ($? -eq $false) + { Write-Host "[ERROR]: While writing to '$VersionFilePath'." -ForegroundColor Red + return $true + } + + return $false +} # Invoke-PatchVersionFile + + +function Get-CFlags +{ <# + .SYNOPSIS + Returns common ANSI C compiler flags for GCC. + #> + return @( + "-O1", # optimize; level 1 + "-g" # enable debug symbols + ) +} + +function Invoke-CompileCFiles +{ <# + .SYNOPSIS + This CommandLet compiles all C files with GCC. + .PARAMETER GHDLRootDir + The repository root directory. + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console + #> + [CmdletBinding()] + param( + [string] $GHDLRootDir, + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + # construct DirectoryPaths + $SourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName + + Set-Location $BuildDirectory + Write-Host "Executing build target 'CompileCFiles' ..." -ForegroundColor Yellow + + # list all files to be compiled; add additional CFlags if needed + $SourceFiles = @() + $SourceFiles += New-Object PSObject -Property @{File="grt\grt-cstdio.c"; CFlags=@()} + $SourceFiles += New-Object PSObject -Property @{File="grt\grt-cvpi.c"; CFlags=@()} + $SourceFiles += New-Object PSObject -Property @{File="grt\grt-cdynload.c"; CFlags=@()} + $SourceFiles += New-Object PSObject -Property @{File="grt\config\clock.c"; CFlags=@()} + $SourceFiles += New-Object PSObject -Property @{File="grt\config\win32.c"; CFlags=@('-DWITH_GNAT_RUN_TIME')} + $SourceFiles += New-Object PSObject -Property @{File="ortho\mcode\memsegs_c.c"; CFlags=@()} + + # compile C files + foreach ($SourceFile in $SourceFiles) + { $Parameters = @() + $Parameters += "-c" # compile only + $Parameters += Get-CFlags # append common CFlags + $Parameters += $SourceFile.CFlags + $Parameters += $SourceDirectory + "\" + $SourceFile.File + + # call C compiler + $InvokeExpr = "$Prog_GCC " + ($Parameters -join " ") + " 2>&1" + + Write-Host (" compiling: " + $SourceFile.File) + Write-Debug " call: $InvokeExpr" + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGCCLine -Indent " " + if ($LastExitCode -ne 0) + { Write-Host ("[ERROR]: While compiling '{0}'." -f $SourceFile.File) -ForegroundColor Red + return $true + } + } + + return $false +} # Invoke-CompileCFiles + + +function Invoke-CompileGHDLAdaFiles +{ <# + .SYNOPSIS + This CommandLet compiles all Ada files with GNAT. + .PARAMETER GHDLRootDir + The repository root directory. + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console + #> + [CmdletBinding()] + param( + [string] $GHDLRootDir, + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + # construct DirectoryPaths + $CommonSourceDirectory = $GHDLRootDir + "\" + $CommonSourceDirName + $WinMcodeSourceDirectory = $GHDLRootDir + "\" + $WinMcodeSourceDirName + + Set-Location $BuildDirectory + Write-Host "Executing build target 'CompileGHDLAdaFiles' ..." -ForegroundColor Yellow + + $Parameters = @() + $Parameters += Get-CFlags # append common CFlags + $Parameters += '-gnatn' + + # append all source paths + $Parameters += '-aI' + $WinMcodeSourceDirectory + $Parameters += '-aI' + $CommonSourceDirectory + $Parameters += '-aI' + $CommonSourceDirectory + '\ghdldrv' + $Parameters += '-aI' + $CommonSourceDirectory + '\psl' + $Parameters += '-aI' + $CommonSourceDirectory + '\grt' + $Parameters += '-aI' + $CommonSourceDirectory + '\ortho' + $Parameters += '-aI' + $CommonSourceDirectory + '\ortho\mcode' + $Parameters += '-aI' + $CommonSourceDirectory + '\vhdl' + $Parameters += '-aI' + $CommonSourceDirectory + '\vhdl\translate' + + # top level + $Parameters += 'ghdl_jit' + + # add output filename + $Parameters += '-o' + $Parameters += $GHDL_Mcode_Name + + # append linker parameters + $Parameters += '-largs' + $Parameters += 'grt-cstdio.o' + $Parameters += 'clock.o' + $Parameters += 'grt-cvpi.o' + $Parameters += 'grt-cdynload.o' + $Parameters += 'memsegs_c.o' + $Parameters += 'win32.o' + $Parameters += '-ldbghelp' + $Parameters += '-largs' + # $Parameters += '-Wl,--stack,8404992' + + # call Ada compiler (GNAT) + $InvokeExpr = "$Prog_GNATMake " + ($Parameters -join " ") + " 2>&1" + + Write-Host " compiling with GNAT" + Write-Debug " call: $InvokeExpr" + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGCCLine -Indent " " + if ($LastExitCode -ne 0) + { Write-Host "[ERROR]: While compiling '$GHDL_Mcode_Name'." -ForegroundColor Red + return $true + } + return $false +} # Invoke-CompileGHDLAdaFiles + + +function Invoke-StripGHDLExecutable +{ <# + .SYNOPSIS + This CommandLet strips the result files. + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console + #> + [CmdletBinding()] + param( + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + + Set-Location $BuildDirectory + Write-Host "Executing build target 'StripGHDLExecutable' ..." -ForegroundColor Yellow + + # call striping tool (strip) + Write-Host " stripping '$GHDL_Mcode_Name'" + Write-Debug " call: $Prog_Strip $GHDL_Mcode_Name" + & $Prog_Strip $GHDL_Mcode_Name + if ($LastExitCode -ne 0) + { Write-Host "[ERROR]: While stripping '$GHDL_Mcode_Name'." -ForegroundColor Red + return $true + } + return $false +} # Invoke-StripGHDLExecutable + +function Test-GHDLVersion +{ <# + .SYNOPSIS + This CommandLet executes ghdl to read the version information + .PARAMETER BuildDirectory + The directory where all generated files are stored. + .PARAMETER Quiet + Disable outputs to the host console + #> + [CmdletBinding()] + param( + [string] $BuildDirectory, + [switch] $Quiet = $false + ) + + Set-Location $BuildDirectory + Write-Host "Executing build target 'GHDLVersion' ..." -ForegroundColor Yellow + + if (-not (Test-Path -Path $GHDL_Mcode_Name -PathType Leaf)) + { Write-Host " GHDL executable '$GHDL_Mcode_Name' does not exists." -ForegroundColor Red + return $true + } + + # call ghdl + $InvokeExpr = "$GHDL_Mcode_Name --version 2>&1" + + Write-Host " executing '$GHDL_Mcode_Name'" + Write-Host " call: $InvokeExpr" + Write-Host " ----------------------------------------" + Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-HostExtended " " + Write-Host " ----------------------------------------" + if ($LastExitCode -ne 0) + { Write-Host "[ERROR]: While executing '$GHDL_Mcode_Name'." -ForegroundColor Red + return $true + } + return $false +} # Test-GHDLVersion + + +# export functions +Export-ModuleMember -Function 'Get-GHDLVersion' +Export-ModuleMember -Function 'Invoke-Clean' +Export-ModuleMember -Function 'New-BuildDirectory' +Export-ModuleMember -Function 'Invoke-PatchVersionFile' +Export-ModuleMember -Function 'Restore-PatchedVersionFile' +Export-ModuleMember -Function 'Invoke-CompileCFiles' +Export-ModuleMember -Function 'Invoke-CompileGHDLAdaFiles' +Export-ModuleMember -Function 'Invoke-StripGHDLExecutable' +Export-ModuleMember -Function 'Test-GHDLVersion' -- cgit v1.2.3