Add packaging files for build
[platform/upstream/gn.git] / packaging / gn.spec
1 #
2 # spec file for package gn
3 #
4 # Copyright (c) 2020 SUSE LLC
5 #
6 # All modifications and additions to the file contributed by third parties
7 # remain the property of their copyright owners, unless otherwise agreed
8 # upon. The license for this file, and modifications and additions to the
9 # file, is the same license as for the pristine package itself (unless the
10 # license for the pristine package is not an Open Source License, in which
11 # case the license is the MIT License). An "Open Source License" is a
12 # license that conforms to the Open Source Definition (Version 1.9)
13 # published by the Open Source Initiative.
14
15 # Please submit bugfixes or comments via https://bugs.opensuse.org/
16 #
17
18 Name:           gn
19 Version:        20210313
20 Release:        0
21 Summary:        A meta-build system that generates build files for Ninja
22 License:        BSD-3-Clause
23 URL:            https://gn.googlesource.com/
24 #Source:         https://dev.gentoo.org/~floppym/dist/%{name}-%{version}.tar.xz
25 Source0:    %{name}-%{version}.tar.gz
26 Source1001:     gn.manifest
27 BuildRequires:  gcc-c++
28 BuildRequires:  ninja
29 BuildRequires:  python3-base
30 Requires(post): /sbin/ldconfig
31 Requires(postun): /sbin/ldconfig
32
33 %description
34 GN is a meta-build system that generates build files for Ninja.
35
36 %prep
37 %setup -q
38
39 %build
40 cp %{SOURCE1001} .
41 export CC=gcc
42 export CXX=g++
43 export AR=ar
44 export CXXFLAGS="%{optflags}"
45
46 # bootstrap
47 python3 build/gen.py \
48   --no-strip \
49   --no-last-commit-position \
50   --no-static-libstdc++
51 PV=%{version}
52 cat >out/last_commit_position.h <<-EOF
53         #ifndef OUT_LAST_COMMIT_POSITION_H_
54         #define OUT_LAST_COMMIT_POSITION_H_
55         #define LAST_COMMIT_POSITION_NUM ${PV##0.}
56         #define LAST_COMMIT_POSITION "${PV}"
57         #endif  // OUT_LAST_COMMIT_POSITION_H_
58 EOF
59
60 ninja -C out %{?_smp_mflags} gn
61
62 %check
63 ninja -C out %{?_smp_mflags} gn_unittests
64 ./out/gn_unittests
65
66 %install
67 install -Dm 0755 out/%{name} %{buildroot}%{_bindir}/%{name}
68
69 %files
70 %license LICENSE
71 %{_bindir}/%{name}
72
73 %changelog