Changeset 649a64c in rtems-source-builder


Ignore:
Timestamp:
Apr 16, 2013, 4:25:34 AM (6 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, 4.9, master
Children:
82e9f91
Parents:
b022691
git-author:
Chris Johns <chrisj@…> (04/16/13 04:25:34)
git-committer:
Chris Johns <chrisj@…> (04/16/13 04:28:34)
Message:

Add download git support.

Add support to use a git cloned repo as the source. Move the download
code out of the build module and into a separate module. Add to this
module support for git.

Update the GCC common configuration to support using a symlinked
git repo.

Add checks for all languages.

Location:
source-builder
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • source-builder/config/checks.cfg

    rb022691 r649a64c  
    1919
    2020#
     21# Default to Ada off.
     22#
     23%ifn %{defined enable_ada}
     24%define enable_ada 0
     25%endif
     26
     27#
     28# Default to Go off.
     29#
     30%ifn %{defined enable_go}
     31%define enable_go 0
     32%endif
     33
     34#
     35# Default to Fortran off.
     36#
     37%ifn %{defined enable_fortran}
     38%define enable_fortran 0
     39%endif
     40
     41#
     42# Default to Java off.
     43#
     44%ifn %{defined enable_java}
     45%define enable_java 0
     46%endif
     47
     48#
     49# Default to ObjC off.
     50#
     51%ifn %{defined enable_objc}
     52%define enable_objc 0
     53%endif
     54
     55#
    2156# Hack to get around the ARM EABBI mess.
    2257#
     
    2459%define enable_obsolete 0
    2560%endif
    26 
  • source-builder/config/gcc-common-1.cfg

    rb022691 r649a64c  
    3434%prep
    3535  # gcc and optional the g++ core if separate packages
     36  source_dir_0="gcc-%{gcc_version}"
    3637  %setup -q -c -n %{name}-%{version}
    3738  %{?source1:%setup -q -D -T -n %{name}-%{version} -a1}
    38   cd gcc-%{gcc_version}
     39  cd ${source_dir_0}
    3940  %{?patch0:%patch0 %{?patch0_opts:%{patch0_opts}}%{!?patch0_opts:-p1}}
    4041  %{?patch1:%patch1 %{?patch1_opts:%{patch1_opts}}%{!?patch1_opts:-p1}}
     
    5051
    5152  # newlib
     53  source_dir_10="newlib-%{newlib_version}"
    5254  %setup -q -D -T -n %{name}-%{version} -a10
    53   cd newlib-%{newlib_version}
     55  cd ${source_dir_10}
    5456  %{?patch10:%patch10 %{?patch10_opts:%{patch10_opts}}%{!?patch10_opts:-p1}}
    5557  %{?patch11:%patch11 %{?patch11_opts:%{patch11_opts}}%{!?patch11_opts:-p1}}
     
    6567
    6668  # Link newlib into the gcc source tree
    67   ln -s ../newlib-%{newlib_version}/newlib gcc-%{gcc_version}
     69  %{__rmfile} ${source_dir_0}/newlib
     70  %{__ln_s} $PWD/${source_dir_10}/newlib ${source_dir_0}/newlib
    6871
    6972  # MPFR
     73  source_dir_20="mpfr-%{mpfr_version}"
    7074  %setup -q -D -T -n %{name}-%{version} -a20
    71   cd mpfr-%{mpfr_version}
     75  cd ${source_dir_20}
    7276  %{?patch20:%patch20 -p1}
    7377  cd ..
    7478  # Build MPFR one-tree style
    75   ln -s ../mpfr-%{mpfr_version} gcc-%{gcc_version}/mpfr
     79  %{__rmfile} ${source_dir_0}/mpfr
     80  %{__ln_s} $PWD/${source_dir_20} ${source_dir_0}/mpfr
    7681
    7782  # MPC
     83  source_dir_21="mpc-%{mpc_version}"
    7884  %setup -q -D -T -n %{name}-%{version} -a21
    79   cd mpc-%{mpc_version}
     85  cd ${source_dir_21}
    8086  %{?patch21:%patch21 -p1}
    8187  cd ..
    8288  # Build MPC one-tree style
    83   ln -s ../mpc-%{mpc_version} gcc-%{gcc_version}/mpc
     89  %{__rmfile} ${source_dir_0}/mpc
     90  %{__ln_s} $PWD/${source_dir_21} ${source_dir_0}/mpc
    8491
    8592  # GMP
     93  source_dir_22="gmp-%{gmp_version}"
    8694  %setup -q -D -T -n %{name}-%{version} -a22
    87   cd gmp-%{gmp_version}
     95  cd ${source_dir_22}
    8896  %{?patch22:%patch22 -p1}
    8997  cd ..
    9098  # Build GMP one-tree style
    91   ln -s ../gmp-%{gmp_version} gcc-%{gcc_version}/gmp
    92 
    93   echo "%{gcc_version_message}" > gcc-%{gcc_version}/gcc/DEV-PHASE
     99  %{__rmfile} ${source_dir_0}/gmp
     100  %{__ln_s} $PWD/${source_dir_22} ${source_dir_0}/gmp
     101
     102  echo "%{gcc_version_message}" > ${source_dir_0}/gcc/DEV-PHASE
    94103
    95104  # Fix timestamps
    96   cd gcc-%{gcc_version}
     105  cd ${source_dir_0}
    97106  contrib/gcc_update --touch
    98107  cd ..
    99108
    100109%build
     110  # Build directory support.
    101111  if test "%{_build}" != "%{_host}" ; then
    102112    build_dir="build-cxc"
     
    106116  mkdir -p ${build_dir}
    107117  cd ${build_dir}
     118
     119  # Languages.
    108120  languages="c"
    109121%if %{enable_cxx}
    110122  languages="$languages,c++"
    111123%endif
     124%if %{enable_ada}
     125  languages="$languages,ada"
     126%endif
     127%if %{enable_go}
     128  languages="$languages,go"
     129%endif
     130%if %{enable_fortran}
     131  languages="$languages,fortran"
     132%endif
     133%if %{enable_java}
     134  languages="$languages,java"
     135%endif
     136%if %{enable_objc}
     137  languages="$languages,objc"
     138%endif
     139
     140  # Host flags
    112141  if test "%{_build}" != "%{_host}" ; then
    113142    CFLAGS_FOR_BUILD="-g -O2 -Wall"
     
    121150  fi
    122151  export CFLAGS CFLAGS_FOR_BUILD CC CXXFLAGS_FOR_BUILD CXX
    123   ../gcc-%{gcc_version}/configure \
     152
     153  ../${source_dir_0}/configure \
    124154    --prefix=%{_prefix} \
    125155    --bindir=%{_bindir} \
     
    148178    --enable-languages="$languages"
    149179
    150   unset CFLAGS CFLAGS_FOR_BUILD CC CXXFLAGS_FOR_BUILD CXX
    151 
    152180  if test "%_host" != "%_build" ; then
    153181    # Bug in gcc-3.2.1:
    154182    # Somehow, gcc doesn't get syslimits.h right for Cdn-Xs
    155183    mkdir -p gcc/include
    156     cp ../gcc-%{gcc_version}/gcc/gsyslimits.h gcc/include/syslimits.h
     184    cp ../${source_dir_0}/gcc/gsyslimits.h gcc/include/syslimits.h
    157185  fi
    158186
    159187  %{__make} %{?_smp_mflags} all
    160188  cd ..
     189
     190  unset CFLAGS CFLAGS_FOR_BUILD CC CXXFLAGS_FOR_BUILD CXX
    161191
    162192%install
     
    180210  %{__rmfile} $SB_BUILD_ROOT%{_mandir}/man3/*ffi*
    181211
     212  # Clean the symlinks away incase the source is a repo
     213  %{__rmfile} ${source_dir_0}/newlib
     214  %{__rmfile} ${source_dir_0}/mpfr
     215  %{__rmfile} ${source_dir_0}/mpc
     216  %{__rmfile} ${source_dir_0}/gmp
     217
    182218%testing
    183219  # Add testing here.
  • source-builder/sb/build.py

    rb022691 r649a64c  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2012 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2013 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3535    import check
    3636    import config
     37    import download
    3738    import error
    3839    import execute
     
    126127            path.mkdir(mkpath)
    127128
    128     def get_file(self, url, local):
    129         if local is None:
    130             raise error.general('source/patch path invalid')
    131         if not path.isdir(path.dirname(local)) and not self.opts.download_disabled():
    132             _notice(self.opts,
    133                     'Creating source directory: %s' % (os.path.relpath(path.host(path.dirname(local)))))
    134             self.mkdir(path.host(path.dirname(local)))
    135         if not path.exists(local):
    136             if self.opts.download_disabled():
    137                 raise error.general('source not found: %s' % (path.host(local)))
    138             #
    139             # Not localy found so we need to download it. Check if a URL has
    140             # been provided on the command line.
    141             #
    142             url_bases = self.opts.urls()
    143             urls = []
    144             if url_bases is not None:
    145                 for base in url_bases:
    146                     if base[-1:] != '/':
    147                         base += '/'
    148                     url_path = urlparse.urlsplit(url)[2]
    149                     slash = url_path.rfind('/')
    150                     if slash < 0:
    151                         url_file = url_path
    152                     else:
    153                         url_file = url_path[slash + 1:]
    154                     urls.append(urlparse.urljoin(base, url_file))
    155             urls.append(url)
    156             if self.opts.trace():
    157                 print '_url:', ','.join(urls), '->', local
    158             for url in urls:
    159                 #
    160                 # Hack for GitHub.
    161                 #
    162                 if url.startswith('https://api.github.com'):
    163                     url = urlparse.urljoin(url, self.config.expand('tarball/%{version}'))
    164                 _notice(self.opts, 'download: %s -> %s' % (url, os.path.relpath(path.host(local))))
    165                 if not self.opts.dry_run():
    166                     failed = False
    167                     _in = None
    168                     _out = None
    169                     try:
    170                         _in = urllib2.urlopen(url)
    171                         _out = open(path.host(local), 'wb')
    172                         _out.write(_in.read())
    173                     except IOError, err:
    174                         msg = 'download: %s: error: %s' % (url, str(err))
    175                         _notice(self.opts, msg)
    176                         if path.exists(local):
    177                             os.remove(path.host(local))
    178                         failed = True
    179                     except ValueError, err:
    180                         msg = 'download: %s: error: %s' % (url, str(err))
    181                         _notice(self.opts, msg)
    182                         if path.exists(local):
    183                             os.remove(path.host(local))
    184                         failed = True
    185                     except:
    186                         msg = 'download: %s: error' % (url)
    187                         print >> sys.stderr, msg
    188                         if _out is not None:
    189                             _out.close()
    190                         raise
    191                     if _out is not None:
    192                         _out.close()
    193                     if _in is not None:
    194                         del _in
    195                     if not failed:
    196                         if not path.isfile(local):
    197                             raise error.general('source is not a file: %s' % (path.host(local)))
    198                         return
    199             if not self.opts.dry_run():
    200                 raise error.general('downloading %s: all paths have failed, giving up' % (url))
    201 
    202     def parse_url(self, url, pathkey):
    203         #
    204         # Split the source up into the parts we need.
    205         #
    206         source = {}
    207         source['url'] = url
    208         source['path'] = path.dirname(url)
    209         source['file'] = path.basename(url)
    210         source['name'], source['ext'] = path.splitext(source['file'])
    211         #
    212         # Get the file. Checks the local source directory first.
    213         #
    214         source['local'] = None
    215         for p in self.config.define(pathkey).split(':'):
    216             local = path.join(path.abspath(p), source['file'])
    217             if source['local'] is None:
    218                 source['local'] = local
    219             if path.exists(local):
    220                 source['local'] = local
    221                 break
    222         #
    223         # Is the file compressed ?
    224         #
    225         esl = source['ext'].split('.')
    226         if esl[-1:][0] == 'gz':
    227             source['compressed'] = '%{__gzip} -dc'
    228         elif esl[-1:][0] == 'bz2':
    229             source['compressed'] = '%{__bzip2} -dc'
    230         elif esl[-1:][0] == 'bz2':
    231             source['compressed'] = '%{__zip} -u'
    232         elif esl[-1:][0] == 'xz':
    233             source['compressed'] = '%{__xz} -dc'
    234         source['script'] = ''
    235         return source
    236 
    237129    def source(self, package, source_tag):
    238130        #
     
    251143        if url is None:
    252144            raise error.general('source tag not found: source%d' % (source_tag))
    253         source = self.parse_url(url, '_sourcedir')
    254         self.get_file(source['url'], source['local'])
    255         if 'compressed' in source:
     145        source = download.parse_url(url, '_sourcedir', self.config, self.opts)
     146        download.get_file(source['url'], source['local'], self.opts, self.config)
     147        if 'symlink' in source:
     148            source['script'] = '%%{__ln_s} %s ${source_dir_%d}' % (source['local'], source_tag)
     149        elif 'compressed' in source:
    256150            source['script'] = source['compressed'] + ' ' + \
    257151                source['local'] + ' | %{__tar_extract} -'
     
    276170        # Parse the URL first in the source builder's patch directory.
    277171        #
    278         patch = self.parse_url(url, '_patchdir')
     172        patch = download.parse_url(url, '_patchdir', self.config, self.opts)
    279173        #
    280174        # If not in the source builder package check the source directory.
    281175        #
    282176        if not path.exists(patch['local']):
    283             patch = self.parse_url(url, '_patchdir')
    284         self.get_file(patch['url'], patch['local'])
     177            patch = download.parse_url(url, '_patchdir', self.config, self.opts)
     178        download.get_file(patch['url'], patch['local'], self.opts, self.config)
    285179        if 'compressed' in patch:
    286180            patch['script'] = patch['compressed'] + ' ' +  patch['local']
  • source-builder/sb/git.py

    rb022691 r649a64c  
    3838    def _run(self, args, check = False):
    3939        e = execute.capture_execution()
    40         exit_code, proc, output = e.spawn([self.git] + args)
     40        if path.exists(self.path):
     41            cwd = self.path
     42        else:
     43            cwd = None
     44        exit_code, proc, output = e.spawn([self.git] + args, cwd = cwd)
    4145        if check:
    4246            self._git_exit_code(exit_code)
     
    6266        return (int(vs[0]), int(vs[1]), int(vs[2]), int(vs[3]))
    6367
     68    def clone(self, url, path):
     69        ec, output = self._run(['clone', url, path])
     70        if ec != 0:
     71            raise error.general('clone of %s failed: %s' % (url, output))
     72
     73    def fetch(self, url, path):
     74        ec, output = self._run(['fetch', url])
     75        if ec != 0:
     76            raise error.general('fetch of %s failed: %s' % (url, output))
     77
     78    def pull(self):
     79        ec, output = self._run(['pull'])
     80        if ec != 0:
     81            raise error.general('pull of %s failed: %s' % (url, output))
     82
     83    def reset(self, args):
     84        if type(args) == str:
     85            args = [args]
     86        ec, output = self._run(['reset'] + args)
     87        if ec != 0:
     88            raise error.general('pull of %s failed: %s' % (url, output))
     89
     90    def branch(self):
     91        ec, output = self._run(['branch'])
     92        if ec == 0:
     93            for b in output.split('\n'):
     94                if b[0] == '*':
     95                    return b[2:]
     96        return None
     97
     98    def checkout(self, branch = 'master'):
     99        ec, output = self._run(['checkout', branch])
     100        return ec == 0
     101
    64102    def status(self):
    65103        _status = {}
    66         ec, output = self._run(['status'])
    67         if ec == 0:
    68             state = 'none'
    69             for l in output.split('\n'):
    70                 if l.startswith('# On branch '):
    71                     _status['branch'] = l[len('# On branch '):]
    72                 elif l.startswith('# Changes to be committed:'):
    73                     state = 'staged'
    74                 elif l.startswith('# Changes not staged for commit:'):
    75                     state = 'unstaged'
    76                 elif l.startswith('# Untracked files:'):
    77                     state = 'untracked'
    78                 elif state != 'none' and l[0] == '#':
    79                     if l.strip() != '#' and not l.startswith('#   ('):
    80                         if state not in _status:
    81                             _status[state] = []
    82                         l = l[1:]
    83                         if ':' in l:
    84                             l = l.split(':')[1]
    85                         _status[state] += [l.strip()]
     104        if path.exists(self.path):
     105            ec, output = self._run(['status'])
     106            if ec == 0:
     107                state = 'none'
     108                for l in output.split('\n'):
     109                    if l.startswith('# On branch '):
     110                        _status['branch'] = l[len('# On branch '):]
     111                    elif l.startswith('# Changes to be committed:'):
     112                        state = 'staged'
     113                    elif l.startswith('# Changes not staged for commit:'):
     114                        state = 'unstaged'
     115                    elif l.startswith('# Untracked files:'):
     116                        state = 'untracked'
     117                    elif state != 'none' and l[0] == '#':
     118                        if l.strip() != '#' and not l.startswith('#   ('):
     119                            if state not in _status:
     120                                _status[state] = []
     121                            l = l[1:]
     122                            if ':' in l:
     123                                l = l.split(':')[1]
     124                            _status[state] += [l.strip()]
    86125        return _status
    87126
     
    91130
    92131    def valid(self):
    93         ec, output = self._run(['status'])
    94         return ec == 0
     132        if path.exists(self.path):
     133            ec, output = self._run(['status'])
     134            return ec == 0
     135        return False
    95136
    96137    def remotes(self):
Note: See TracChangeset for help on using the changeset viewer.