Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
67c0cd22
Commit
67c0cd22
authored
Jul 24, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Header containing GLSL source code is generated only after change of any of shader source files.
parent
618a5f0e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
22 deletions
+34
-22
Shaders.cmake
CMakeModules/Shaders.cmake
+34
-22
No files found.
CMakeModules/Shaders.cmake
View file @
67c0cd22
...
@@ -4,6 +4,19 @@
...
@@ -4,6 +4,19 @@
# number of input files
# number of input files
list
(
LENGTH inputFiles shadersNumber
)
list
(
LENGTH inputFiles shadersNumber
)
# check if GLSL source files were updated since the last time
set
(
update
"FALSE"
)
foreach
(
inputFile
${
inputFiles
}
)
if
(
${
inputFile
}
IS_NEWER_THAN
${
outputFile
}
)
set
(
update
"TRUE"
)
endif
(
${
inputFile
}
IS_NEWER_THAN
${
outputFile
}
)
endforeach
(
inputFile
${
inputFiles
}
)
if
(
NOT update
)
message
(
"Headers are up-to-date"
)
return
()
endif
(
NOT update
)
# write header
# write header
file
(
WRITE
${
outputFile
}
"// Do not edit this file, it is autogenerated by CMake.
file
(
WRITE
${
outputFile
}
"// Do not edit this file, it is autogenerated by CMake.
...
@@ -14,28 +27,27 @@ const unsigned int shaders_number = ${shadersNumber};
...
@@ -14,28 +27,27 @@ const unsigned int shaders_number = ${shadersNumber};
const char *shaders_src[] = {
\n
"
)
const char *shaders_src[] = {
\n
"
)
foreach
(
inputFile
${
inputFiles
}
)
foreach
(
inputFile
${
inputFiles
}
)
# put the input file name into the output file
# put the input file name into the output file
file
(
APPEND
${
outputFile
}
"
\n
//
${
inputFile
}
"
)
file
(
APPEND
${
outputFile
}
"
\n
//
${
inputFile
}
"
)
# process the input file
# process the input file
file
(
READ
${
inputFile
}
contents
)
file
(
READ
${
inputFile
}
contents
)
# remove /* */ comments
# remove /* */ comments
string
(
REGEX REPLACE
"/
\\
*.*
\\
*/"
""
contents
"
${
contents
}
"
)
string
(
REGEX REPLACE
"/
\\
*.*
\\
*/"
""
contents
"
${
contents
}
"
)
# remove // comments
# remove // comments
string
(
REGEX REPLACE
"//[^
\n
]*"
""
contents
"
${
contents
}
"
)
string
(
REGEX REPLACE
"//[^
\n
]*"
""
contents
"
${
contents
}
"
)
# remove whitespaces at the beginning of each line
# remove whitespaces at the beginning of each line
string
(
REGEX REPLACE
"
\n
([
\t
])*"
"
\n
"
contents
"
${
contents
}
"
)
string
(
REGEX REPLACE
"
\n
([
\t
])*"
"
\n
"
contents
"
${
contents
}
"
)
# remove unnecessary spaces
# remove unnecessary spaces
string
(
REGEX REPLACE
" *([
\\
*/+&
\\
|,=<>
\(\)
]) *"
"
\\
1"
contents
"
${
contents
}
"
)
string
(
REGEX REPLACE
" *([
\\
*/+&
\\
|,=<>
\(\)
]) *"
"
\\
1"
contents
"
${
contents
}
"
)
# remove empty lines & wrap every line in "" and add '\n' at the end of each line
# remove empty lines & wrap every line in "" and add '\n' at the end of each line
string
(
REGEX REPLACE
"
\n
+"
"
\\\\
n
\"\n\"
"
contents
"
${
contents
}
"
)
string
(
REGEX REPLACE
"
\n
+"
"
\\\\
n
\"\n\"
"
contents
"
${
contents
}
"
)
# remove unnecessary " & \n from the beginning and the end of contents
# remove unnecessary " & \n from the beginning and the end of contents
string
(
REGEX REPLACE
"^
\\\\
n
\"
"
""
contents
"
${
contents
}
"
)
string
(
REGEX REPLACE
"^
\\\\
n
\"
"
""
contents
"
${
contents
}
"
)
string
(
REGEX REPLACE
"
\"
$"
","
contents
"
${
contents
}
"
)
string
(
REGEX REPLACE
"
\"
$"
","
contents
"
${
contents
}
"
)
file
(
APPEND
${
outputFile
}
"
${
contents
}
"
)
file
(
APPEND
${
outputFile
}
"
${
contents
}
"
)
endforeach
(
inputFile
${
inputFiles
}
)
endforeach
(
inputFile
${
inputFiles
}
)
# write footer
# write footer
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment