410.1.18
by Matthew Fuller
Pull generated source files into a separate include. |
1 |
#
|
2 |
# Rules for generated source files
|
|
3 |
#
|
|
4 |
||
5 |
||
443.1.2
by Matthew Fuller
Switch deftwmrc builder back to building a .c file, with a .h bringing |
6 |
# Hand-build deftwmrc.c
|
7 |
set(defc ${CMAKE_CURRENT_BINARY_DIR}/deftwmrc.c) |
|
540.1.2
by Matthew Fuller
Define a ${TOOLS} var for our tools/ dir and use it instead of |
8 |
set(mkdefc ${TOOLS}/mk_deftwmrc.sh) |
443.1.2
by Matthew Fuller
Switch deftwmrc builder back to building a .c file, with a .h bringing |
9 |
add_custom_command(OUTPUT ${defc} |
10 |
DEPENDS system.ctwmrc ${mkdefc} |
|
11 |
COMMAND ${mkdefc} ${CMAKE_CURRENT_SOURCE_DIR}/system.ctwmrc > ${defc} |
|
410.1.18
by Matthew Fuller
Pull generated source files into a separate include. |
12 |
)
|
13 |
||
14 |
||
15 |
# Hand-build ctwm_atoms.[ch]
|
|
16 |
set(ctwm_atoms ctwm_atoms.h ctwm_atoms.c) |
|
17 |
add_custom_command(OUTPUT ${ctwm_atoms} |
|
540.1.4
by Matthew Fuller
Add dependancies on the generating scripts too. |
18 |
DEPENDS ctwm_atoms.in ${TOOLS}/mk_atoms.sh |
540.1.2
by Matthew Fuller
Define a ${TOOLS} var for our tools/ dir and use it instead of |
19 |
COMMAND ${TOOLS}/mk_atoms.sh ${CMAKE_CURRENT_SOURCE_DIR}/ctwm_atoms.in ctwm_atoms CTWM |
410.1.18
by Matthew Fuller
Pull generated source files into a separate include. |
20 |
)
|
21 |
||
22 |
||
459.1.6
by Matthew Fuller
Start putting together some util funcs to turn X event id's into names |
23 |
# Generate up the event names lookup source
|
24 |
set(en_list ${CMAKE_CURRENT_SOURCE_DIR}/event_names.list) |
|
462
by Matthew Fuller
Generate event_names_table.h rather than event_names.c. |
25 |
set(en_out ${CMAKE_CURRENT_BINARY_DIR}/event_names_table.h) |
540.1.2
by Matthew Fuller
Define a ${TOOLS} var for our tools/ dir and use it instead of |
26 |
set(en_mk ${TOOLS}/mk_event_names.sh) |
459.1.6
by Matthew Fuller
Start putting together some util funcs to turn X event id's into names |
27 |
add_custom_command(OUTPUT ${en_out} |
462
by Matthew Fuller
Generate event_names_table.h rather than event_names.c. |
28 |
DEPENDS ${en_list} ${en_mk} |
29 |
COMMAND ${en_mk} ${en_list} > ${en_out} |
|
459.1.6
by Matthew Fuller
Start putting together some util funcs to turn X event id's into names |
30 |
)
|
462
by Matthew Fuller
Generate event_names_table.h rather than event_names.c. |
31 |
# Have to manually add this, or cmake won't notice that it's needed in
|
32 |
# time to make it.
|
|
528.1.60
by Matthew Fuller
Use a different way to force this header into cmake's knowledge. This |
33 |
#set_source_files_properties(event_names.c OBJECT_DEPENDS ${en_out})
|
34 |
# This also seems a blessed hackaround, and avoids having to encode the
|
|
35 |
# knowledge of what files #include it.
|
|
36 |
list(APPEND CTWMSRC ${CMAKE_CURRENT_BINARY_DIR}/event_names_table.h) |
|
459.1.6
by Matthew Fuller
Start putting together some util funcs to turn X event id's into names |
37 |
|
38 |
||
528.1.61
by Matthew Fuller
Add in building the function_defs.h. |
39 |
# Create function bits
|
40 |
set(fd_list ${CMAKE_CURRENT_SOURCE_DIR}/functions_defs.list) |
|
540.1.2
by Matthew Fuller
Define a ${TOOLS} var for our tools/ dir and use it instead of |
41 |
set(fd_mk ${TOOLS}/mk_function_bits.sh) |
528.1.62
by Matthew Fuller
Go ahead and pluralize for consistency. |
42 |
set(fd_h ${CMAKE_CURRENT_BINARY_DIR}/functions_defs.h) |
534.1.9
by Matthew Fuller
Add _deferral.h into cmake's knowledge of what we're generating. |
43 |
set(fdd_h ${CMAKE_CURRENT_BINARY_DIR}/functions_deferral.h) |
534.1.17
by Matthew Fuller
Add the parse_table.h to the files this generates. |
44 |
set(fpt_h ${CMAKE_CURRENT_BINARY_DIR}/functions_parse_table.h) |
535.1.6
by Matthew Fuller
Add the dispatch_execution to the list of files this generates. |
45 |
set(fde_h ${CMAKE_CURRENT_BINARY_DIR}/functions_dispatch_execution.h) |
528.1.61
by Matthew Fuller
Add in building the function_defs.h. |
46 |
add_custom_command( |
535.1.6
by Matthew Fuller
Add the dispatch_execution to the list of files this generates. |
47 |
OUTPUT ${fd_h} ${fdd_h} ${fpt_h} ${fde_h} |
534.1.13
by Matthew Fuller
Add the gen script to the list of dependancies, to make life easier |
48 |
DEPENDS ${fd_list} ${fd_mk} |
49 |
COMMAND ${fd_mk} ${fd_list} ${CMAKE_CURRENT_BINARY_DIR} |
|
528.1.61
by Matthew Fuller
Add in building the function_defs.h. |
50 |
)
|
535.1.6
by Matthew Fuller
Add the dispatch_execution to the list of files this generates. |
51 |
list(APPEND CTWMSRC ${fd_h} ${fdd_h} ${fpt_h} ${fde_h}) |
528.1.61
by Matthew Fuller
Add in building the function_defs.h. |
52 |
|
53 |
||
410.1.18
by Matthew Fuller
Pull generated source files into a separate include. |
54 |
# Setup config header file
|
55 |
configure_file(ctwm_config.h.in ctwm_config.h ESCAPE_QUOTES) |
|
411.1.1
by Matthew Fuller
Move to always processing version.c, and inagurate by just turning the |
56 |
|
57 |
||
58 |
# Fill in version info
|
|
582.1.16
by Matthew Fuller
Need the vcs checks before the gen_source_files tries to build |
59 |
|
605.1.6
by Matthew Fuller
Redo comments through the version.c generating stuff, so it's more |
60 |
# Need the VCS bits; add a guard here to prevent dev screwups when
|
61 |
# working on the build system.
|
|
582.1.16
by Matthew Fuller
Need the vcs checks before the gen_source_files tries to build |
62 |
if(NOT VCS_CHECKS_RUN) |
63 |
message(FATAL_ERROR "Internal error: VCS checks not done yet!") |
|
64 |
endif() |
|
65 |
||
605.1.6
by Matthew Fuller
Redo comments through the version.c generating stuff, so it's more |
66 |
# Building the version.c file happens in 2 steps. First, an original
|
67 |
# source file (${version_c_src}) is processed with tools/mk_version_in.sh
|
|
68 |
# to write in the ctwm version info found in the VERSION file in the root
|
|
69 |
# of the tree. That's written to an intermediate file (${version_c_in}).
|
|
70 |
# Secondly, the intermediate file is processed to store up info about the
|
|
71 |
# VCS revision being built from, into the final file (${version_c}) which
|
|
72 |
# is actually compiled.
|
|
73 |
#
|
|
74 |
# A special case occurs when there's no VCS info we can find to work
|
|
75 |
# with, AND we have a pregen'd .in file (${vresion_c_gen}); this is
|
|
76 |
# commonly the case with a release tarball, where part of the release
|
|
77 |
# building process pre-stashes the bzr revision info. In that case, we
|
|
78 |
# swap the original (${version_c_src}) to point to the pregen'd file
|
|
79 |
# (which already has the VCS info), and make the second step just cp the
|
|
80 |
# intermediate file over.
|
|
466.1.6
by Matthew Fuller
Shuffle some stuff around so we go through a configure_file() step |
81 |
set(version_c_src ${CMAKE_CURRENT_SOURCE_DIR}/version.c.in) |
82 |
set(version_c_in ${CMAKE_CURRENT_BINARY_DIR}/version.c.in) |
|
83 |
set(version_c ${CMAKE_CURRENT_BINARY_DIR}/version.c) |
|
411.1.4
by Matthew Fuller
If we're in bzr shape, use the script to alter the version.c file |
84 |
|
546.1.9
by Matthew Fuller
Add a FORCE_PREGEN_FILES check in the cmake setup so that we can force |
85 |
# Maybe a pregen'd
|
86 |
set(version_c_gen ${GENSRCDIR}/version.c.in) |
|
87 |
||
88 |
# Override
|
|
89 |
if(FORCE_PREGEN_FILES) |
|
90 |
set(HAS_BZR 0) |
|
91 |
set(HAS_GIT 0) |
|
92 |
endif() |
|
93 |
||
605.1.6
by Matthew Fuller
Redo comments through the version.c generating stuff, so it's more |
94 |
# Now, what's our process for going from the intermediate .c.in file to
|
95 |
# the final .c with the VCS revision info added? This is the 2nd step in
|
|
96 |
# the process, but we describe it first here so we can change where
|
|
97 |
# ${version_c_src} points if necessary.
|
|
411.1.8
by Matthew Fuller
Expand out this condition a bit. Technically redundant, since we |
98 |
if(IS_BZR_CO AND HAS_BZR) |
605.1.6
by Matthew Fuller
Redo comments through the version.c generating stuff, so it's more |
99 |
# We're in a bzr tree, so write in the bzr revision info
|
540.1.2
by Matthew Fuller
Define a ${TOOLS} var for our tools/ dir and use it instead of |
100 |
set(rw_ver_bzr "${TOOLS}/rewrite_version_bzr.sh") |
411.1.4
by Matthew Fuller
If we're in bzr shape, use the script to alter the version.c file |
101 |
add_custom_command(OUTPUT ${version_c} |
466.1.4
by Matthew Fuller
Add dependancy on the script so it notices when I change it. |
102 |
DEPENDS ${version_c_in} ${BZR_DIRSTATE_FILE} ${rw_ver_bzr} |
681
by Matthew Fuller
Update build and dev scripts to brz-ify. mk_tar.sh is just swapped to |
103 |
COMMAND env BZR_CMD=${BZR_CMD} ${rw_ver_bzr} < ${version_c_in} > ${version_c} |
411.1.11
by Matthew Fuller
Put COMMENT's on these build cases so it's clearer what's going on. |
104 |
COMMENT "Generating version.c from current WT state." |
635
by Matthew Fuller
Explicitly run these VCS-id-including scripts from the main source |
105 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
411.1.4
by Matthew Fuller
If we're in bzr shape, use the script to alter the version.c file |
106 |
)
|
475.1.4
by Matthew Fuller
Add support for writing git revision info into version.c. |
107 |
elseif(IS_GIT_CO AND HAS_GIT) |
605.1.6
by Matthew Fuller
Redo comments through the version.c generating stuff, so it's more |
108 |
# We're in a git tree, so write in the git revision info
|
540.1.2
by Matthew Fuller
Define a ${TOOLS} var for our tools/ dir and use it instead of |
109 |
set(rw_ver_git "${TOOLS}/rewrite_version_git.sh") |
475.1.4
by Matthew Fuller
Add support for writing git revision info into version.c. |
110 |
add_custom_command(OUTPUT ${version_c} |
540.1.3
by Matthew Fuller
Fix which script we depend on here. |
111 |
DEPENDS ${version_c_in} ${GIT_INDEX_FILE} ${rw_ver_git} |
475.1.4
by Matthew Fuller
Add support for writing git revision info into version.c. |
112 |
COMMAND ${rw_ver_git} < ${version_c_in} > ${version_c} |
113 |
COMMENT "Generating version.c from current git state." |
|
635
by Matthew Fuller
Explicitly run these VCS-id-including scripts from the main source |
114 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
475.1.4
by Matthew Fuller
Add support for writing git revision info into version.c. |
115 |
)
|
605.1.5
by Matthew Fuller
Pull these conditionals out to top-level, rather than just bifurcating |
116 |
elseif(EXISTS ${version_c_gen}) |
605.1.6
by Matthew Fuller
Redo comments through the version.c generating stuff, so it's more |
117 |
# There's a prebuilt one to use; commonly this means we're building
|
118 |
# from a release tarball, and it includes pre-stashed bzr revision
|
|
119 |
# info about the release. So, in this case, we replace the original
|
|
120 |
# source with our pregen'd one (which already has the info in it),
|
|
121 |
# and just use 'cp' to turn the intermediate .c.in into the final .c.
|
|
605.1.5
by Matthew Fuller
Pull these conditionals out to top-level, rather than just bifurcating |
122 |
set(version_c_src ${version_c_gen}) |
123 |
||
124 |
add_custom_command(OUTPUT ${version_c} |
|
125 |
DEPENDS ${version_c_in} |
|
126 |
COMMAND cp ${version_c_in} ${version_c} |
|
127 |
COMMENT "Using pregenerated version.c." |
|
128 |
)
|
|
411.1.4
by Matthew Fuller
If we're in bzr shape, use the script to alter the version.c file |
129 |
else() |
605.1.6
by Matthew Fuller
Redo comments through the version.c generating stuff, so it's more |
130 |
# We've got nothing at all, so just NULL out the VCS info; it's all
|
131 |
# we can do.
|
|
605.1.5
by Matthew Fuller
Pull these conditionals out to top-level, rather than just bifurcating |
132 |
add_custom_command(OUTPUT ${version_c} |
133 |
DEPENDS ${version_c_in} |
|
134 |
COMMAND sed -e 's/%%VCSTYPE%%/NULL/' -e 's/%%REVISION%%/NULL/' |
|
135 |
< ${version_c_in} > ${version_c} |
|
136 |
COMMENT "Using null version.c." |
|
137 |
)
|
|
138 |
endif() |
|
466.1.3
by Matthew Fuller
Adjust version.c so it can be built standalone for printing out bits |
139 |
|
605.1.6
by Matthew Fuller
Redo comments through the version.c generating stuff, so it's more |
140 |
# Now handle the first step; turning the original source .c.in into the
|
141 |
# intermediate .c.in with the ctwm version written in. That's _usually_
|
|
142 |
# starting with the version.c.in in the source tree, but in the "no VCS
|
|
143 |
# info, but we have a pregen'd gen/version.c to use" case above it's the
|
|
144 |
# pregen'd file.
|
|
516.1.8
by Matthew Fuller
Use the mk_version_in.sh script in place of configure_file() to build |
145 |
add_custom_command(OUTPUT ${version_c_in} |
146 |
DEPENDS ${version_c_src} ${CMAKE_CURRENT_SOURCE_DIR}/VERSION |
|
540.1.4
by Matthew Fuller
Add dependancies on the generating scripts too. |
147 |
DEPENDS ${TOOLS}/mk_version_in.sh |
540.1.2
by Matthew Fuller
Define a ${TOOLS} var for our tools/ dir and use it instead of |
148 |
COMMAND ${TOOLS}/mk_version_in.sh ${version_c_src} > ${version_c_in} |
516.1.8
by Matthew Fuller
Use the mk_version_in.sh script in place of configure_file() to build |
149 |
COMMENT "Writing version info into version.c.in" |
150 |
)
|
|
151 |
||
466.1.6
by Matthew Fuller
Shuffle some stuff around so we go through a configure_file() step |
152 |
|
466.1.3
by Matthew Fuller
Adjust version.c so it can be built standalone for printing out bits |
153 |
# Setup a 'version' binary build tool too, for easily printing bits or
|
466.1.10
by Matthew Fuller
Disable building the main()-ified version.c; we don't seem likely to |
154 |
# wholes of our version.
|
155 |
#
|
|
156 |
# Not currently being used, but left as an example of possibilities. If
|
|
157 |
# we need the version in the build process, we'll get it from the
|
|
158 |
# ${ctwm_version_*} vars now.
|
|
159 |
#add_executable(version ${version_c})
|
|
160 |
#set_target_properties(version PROPERTIES COMPILE_FLAGS "-DBUILD_VERSION_BIN")
|