[Scons-users] Dependency between Command calls
Oliver Koch
QKoch at web.de
Sat Apr 12 14:13:41 EDT 2025
Dear SCons experts,
Thank your for your last supporting comments!
I have developed a small SConstruct file (attached) that implements to
tool calls via Command().
However, I have a few questions regarding generalization as given in the
comments of the SConstruct file.
The required input file (MyDeps.puml) is also attached.
The output of the two subsequent runs of "scons" are given in Run1.out
and Run2.out.
So, the build is executed as intended, but the toy example is not really
scalable to a real world tool chain.
Could you answer my questions resp. give me some hints, how to make this
a "real" build chain?
Thank you!
Oliver
--
Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft.
www.avast.com
-------------- next part --------------
from SCons.Script import *
#from SCons.Environment import Base as BaseEnvironment
env = Environment()
def PlantUML(target, source, env):
import os
for src in source:
Cmd = 'java.exe' + \
' -jar C:\\Progra~1\\PlantUML\\plantuml.jar' + \
' -tsvg ' + str(src)
print('Calling: ', Cmd)
os.system(Cmd)
# target should not be an input, but is given from Cmd output.
# How to make a list of targets from the just created files?
for tgt in target:
print(' Creating: ', str(tgt))
return None
def SVGZ(target, source, env):
import os
for src in source:
Cmd = '"C:\\Progra~1\\7-Zip\\7z.exe" a -tgzip' + \
' ' + str(src) + 'z' + \
' ' + str(src)
print('Calling: ', Cmd)
os.system(Cmd)
for tgt in target:
print(' Creating: ', str(tgt))
return None
# This is not executed. Why?
act = env.Action(PlantUML, cmdstr="Building ${TARGET}")
MyPUMLs = env.Glob('*.puml')
print('*.puml:')
for puml in MyPUMLs:
print(' ', puml)
# The output files are hard-coded here only for one puml file!
SVGs = ['My_Dependencies.svg','Additional.svg']
# The number and name of output files is only defined by the input file content.
# Specifically by the lines "@startuml <diagram name = output file base name>".
# Can this be generalized?
# Or is the target not important and could be empty?
env.Command(SVGs, MyPUMLs, PlantUML)
# There could be many .puml. Every as a separate input to PlantUML.
# Every .puml can generate one or more .svg.
# Now, all generated .svg could be globbed again and separately zipped.
# But how to keep the dependency between a specific .puml,
# all its generated .svg files, and the compressed .svgz?
env.Command('My_Dependencies.svgz', 'My_Dependencies.svg', SVGZ) # Should not be hard coded!
env.Command('Additional.svgz', 'Additional.svg', SVGZ) # Should not be hard coded!
# I am lloking for something like:
# for svg in SVGs:
# env.Command(svg.basename + '.svgz', svg, SVGZ)
-------------- next part --------------
scons: Reading SConscript files ...
*.puml:
MyDeps.puml
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
-------------- next part --------------
@startuml My_Dependencies
file "MyDeps.puml" as MyDepsPUML
node "java.exe -jar C:\Progra~1\PlantUML\plantuml.jar -tsvg MyDeps.puml" as JavaEXE
file "My_Dependencies.svg" as MyDepsSVG
file "Additional.svg" as AddSVG
MyDepsPUML --> JavaEXE
JavaEXE --> MyDepsSVG
JavaEXE --> AddSVG
@enduml
'
@startuml Additional
A --> B
@enduml
-------------- next part --------------
scons: Reading SConscript files ...
*.puml:
MyDeps.puml
scons: done reading SConscript files.
scons: Building targets ...
PlantUML(["My_Dependencies.svg", "Additional.svg"], ["MyDeps.puml"])
Calling: java.exe -jar C:\Progra~1\PlantUML\plantuml.jar -tsvg MyDeps.puml
Creating: My_Dependencies.svg
Creating: Additional.svg
SVGZ(["Additional.svgz"], ["Additional.svg"])
Calling: "C:\Progra~1\7-Zip\7z.exe" a -tgzip Additional.svgz Additional.svg
7-Zip 24.09 (x64) : Copyright (c) 1999-2024 Igor Pavlov : 2024-11-29
Scanning the drive:
1 file, 1885 bytes (2 KiB)
Creating archive: Additional.svgz
Add new data to archive: 1 file, 1885 bytes (2 KiB)
Files read from disk: 1
Archive size: 592 bytes (1 KiB)
Everything is Ok
Creating: Additional.svgz
SVGZ(["My_Dependencies.svgz"], ["My_Dependencies.svg"])
Calling: "C:\Progra~1\7-Zip\7z.exe" a -tgzip My_Dependencies.svgz My_Dependencies.svg
7-Zip 24.09 (x64) : Copyright (c) 1999-2024 Igor Pavlov : 2024-11-29
Scanning the drive:
1 file, 3990 bytes (4 KiB)
Creating archive: My_Dependencies.svgz
Add new data to archive: 1 file, 3990 bytes (4 KiB)
Files read from disk: 1
Archive size: 1354 bytes (2 KiB)
Everything is Ok
Creating: My_Dependencies.svgz
scons: done building targets.
More information about the Scons-users
mailing list