Skip to content

Commit 174b799

Browse files
committed
src,doc: move source files to separate subdirs
Closes: https://github.com/kdudka/csdiff/pull/15
1 parent 24405f8 commit 174b799

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+176
-153
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/csdiff_build
22
/tags
3-
/version.cc

CMakeLists.txt

Lines changed: 4 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2011 - 2019 Red Hat, Inc.
1+
# Copyright (C) 2011 - 2020 Red Hat, Inc.
22
#
33
# This file is part of csdiff.
44
#
@@ -18,140 +18,9 @@
1818
cmake_minimum_required(VERSION 2.8)
1919
project(csdiff CXX)
2020
enable_testing()
21-
add_definitions(-Wall -Wextra -fPIC -std=c++11)
2221

23-
# cslib.a
24-
add_library(cs STATIC
25-
abstract-filter.cc
26-
abstract-parser.cc
27-
abstract-writer.cc
28-
color.cc
29-
csdiff-core.cc
30-
csfilter.cc
31-
csparser.cc
32-
cswriter.cc
33-
cwe-mapper.cc
34-
deflookup.cc
35-
defqueue.cc
36-
gcc-parser.cc
37-
html-writer.cc
38-
instream.cc
39-
json-parser.cc
40-
json-writer.cc
41-
parser-common.cc
42-
shared-string.cc
43-
version.cc
44-
)
22+
# C/C++ sources
23+
add_subdirectory(src)
4524

46-
# link cslib.a and boost libraries
47-
find_library(BOOST_REGEX boost_regex REQUIRED)
48-
find_library(BOOST_PROGRAM_OPTIONS boost_program_options REQUIRED)
49-
link_libraries(cs
50-
boost_regex
51-
boost_program_options)
52-
53-
# the list of executables
54-
add_executable(csdiff csdiff.cc)
55-
add_executable(csgrep csgrep.cc)
56-
add_executable(cshtml cshtml.cc)
57-
add_executable(cslinker cslinker.cc)
58-
add_executable(cssort cssort.cc)
59-
60-
# experimental
61-
add_executable(cstrans-df-run cstrans-df-run.cc)
62-
target_link_libraries(cstrans-df-run
63-
boost_filesystem
64-
boost_system)
65-
66-
# load regression tests
25+
# regression tests
6726
add_subdirectory(tests)
68-
69-
# declare what 'make install' should install
70-
install(TARGETS
71-
csdiff
72-
csgrep
73-
cshtml
74-
cslinker
75-
cssort
76-
cstrans-df-run
77-
DESTINATION bin)
78-
79-
# pycsdiff - python binding of csdiff
80-
option(BUILD_PYCSDIFF "Set to ON to enable python binding" ON)
81-
if (BUILD_PYCSDIFF)
82-
set(BOOST_PYTHON_LIB_NAME "boost_python"
83-
CACHE STRING "Name of the boost_python library")
84-
85-
# boost_python3 is used on Fedora 29.
86-
# boost_python38 is used on Fedora 31.
87-
# boost_python-3.x is used on Gentoo Linux.
88-
find_library(BOOST_PYTHON NAMES ${BOOST_PYTHON_LIB_NAME}
89-
boost_python3
90-
boost_python39 boost_python-3.9
91-
boost_python38 boost_python-3.8
92-
boost_python37 boost_python-3.7
93-
boost_python36 boost_python-3.6
94-
boost_python35 boost_python-3.5)
95-
96-
message(STATUS "BOOST_PYTHON: ${BOOST_PYTHON}")
97-
98-
# query PYTHON_INCLUDE_DIR
99-
find_package(PythonInterp REQUIRED)
100-
find_package(PythonLibs REQUIRED)
101-
message(STATUS "PYTHON_INCLUDE_DIR: ${PYTHON_INCLUDE_DIR}")
102-
if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/pyconfig.h")
103-
message(FATAL_ERROR "
104-
${PYTHON_INCLUDE_DIR}/pyconfig.h does not exits")
105-
endif()
106-
107-
# query PYTHON_SITEARCH
108-
execute_process(COMMAND ${PYTHON_EXECUTABLE}
109-
-c "from distutils.sysconfig import get_python_lib
110-
print(get_python_lib(1))"
111-
RESULT_VARIABLE PYTHON_SITEARCH_STATUS
112-
OUTPUT_VARIABLE PYTHON_SITEARCH
113-
OUTPUT_STRIP_TRAILING_WHITESPACE)
114-
if("${PYTHON_SITEARCH_STATUS}" EQUAL 0)
115-
message(STATUS "PYTHON_SITEARCH: ${PYTHON_SITEARCH}")
116-
else()
117-
message(FATAL_ERROR "
118-
failed to query PYTHON_SITEARCH")
119-
endif()
120-
121-
message(STATUS "python binding enabled, the pycsdiff module will be built!")
122-
add_library(pycsdiff SHARED pycsdiff.cc)
123-
set_target_properties(pycsdiff PROPERTIES
124-
COMPILE_FLAGS "-I${PYTHON_INCLUDE_DIR}"
125-
PREFIX "")
126-
target_link_libraries(pycsdiff ${BOOST_PYTHON})
127-
install(TARGETS pycsdiff DESTINATION ${PYTHON_SITEARCH})
128-
endif()
129-
130-
# macro to generate a man page from the corresponding binary
131-
macro(create_manpage BINARY)
132-
set(H2M_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/${BINARY}.h2m")
133-
if(EXISTS "${H2M_INCLUDE}")
134-
set(H2M_ARGS --include ${H2M_INCLUDE})
135-
else()
136-
set(H2M_ARGS "")
137-
endif()
138-
add_custom_command(TARGET ${BINARY} POST_BUILD
139-
COMMAND ${HELP2MAN} --no-info --section 1 ${H2M_ARGS}
140-
${CMAKE_CURRENT_BINARY_DIR}/${BINARY}
141-
> ${BINARY}.1 || rm -f ${BINARY}.1
142-
COMMENT "Generating ${BINARY} man page"
143-
VERBATIM)
144-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BINARY}.1
145-
DESTINATION share/man/man1)
146-
endmacro(create_manpage)
147-
148-
# generate man pages using help2man if available
149-
find_program(HELP2MAN help2man)
150-
if(HELP2MAN)
151-
create_manpage(csdiff)
152-
create_manpage(csgrep)
153-
create_manpage(cshtml)
154-
create_manpage(cslinker)
155-
create_manpage(cssort)
156-
create_manpage(cstrans-df-run)
157-
endif()

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2011 Red Hat, Inc.
1+
# Copyright (C) 2011 - 2020 Red Hat, Inc.
22
#
33
# This file is part of csdiff.
44
#
@@ -22,7 +22,7 @@ CTEST ?= ctest -j$(NUM_CPU) --progress
2222

2323
CMAKE_BUILD_TYPE ?= RelWithDebInfo
2424

25-
.PHONY: all check clean distclean distcheck fast install version.cc
25+
.PHONY: all check clean distclean distcheck fast install version.cc src/version.cc
2626

2727
all: version.cc
2828
mkdir -p csdiff_build
@@ -37,9 +37,9 @@ check: all
3737

3838
clean:
3939
if test -e csdiff_build/Makefile; then $(MAKE) clean -C csdiff_build; fi
40-
if test -e .git; then rm -f version.cc; fi
4140

4241
distclean:
42+
if test -e .git; then rm -f src/version.cc; fi
4343
rm -rf csdiff_build
4444

4545
distcheck: distclean
@@ -48,7 +48,9 @@ distcheck: distclean
4848
install: all
4949
$(MAKE) -C csdiff_build install
5050

51-
version.cc:
51+
version.cc: src/version.cc
52+
53+
src/version.cc:
5254
@if test -e .git; then \
5355
cmd='git log --pretty="0.%cd_%h" --date=short -1 | tr -d -'; \
5456
else \
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

make-srpm.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ make %{?_smp_mflags} VERBOSE=yes
148148
mkdir ../csdiff_build_py2
149149
cd ../csdiff_build_py2
150150
%cmake .. -B. -DPYTHON_EXECUTABLE=%{__python2}
151-
make %{?_smp_mflags} VERBOSE=yes
151+
make %{?_smp_mflags} VERBOSE=yes pycsdiff
152152
%endif
153153
154154
%if %{with python3}
@@ -162,17 +162,15 @@ make %{?_smp_mflags} VERBOSE=yes pycsdiff
162162
163163
%install
164164
%if %{with python2}
165-
mkdir -vp %{buildroot}%{python2_sitearch}
166-
install -vm0644 csdiff_build_py2/pycsdiff.so %{buildroot}%{python2_sitearch}
165+
make install-pycsdiff -C csdiff_build_py2 DESTDIR=%{buildroot}
167166
%endif
168167
169168
%if %{with python3}
170-
mkdir -vp %{buildroot}%{python3_sitearch}
171-
install -vm0644 csdiff_build_py3/pycsdiff.so %{buildroot}%{python3_sitearch}
169+
make install-pycsdiff -C csdiff_build_py3 DESTDIR=%{buildroot}
172170
%endif
173171
174172
cd csdiff_build
175-
make install DESTDIR="\$RPM_BUILD_ROOT"
173+
%make_install
176174
177175
%check
178176
cd csdiff_build

0 commit comments

Comments
 (0)