1use cmake_parser_derive::CMake;
2
3use crate::{
4 command::common::{Condition, FileMatch, HashAlgorithm, NewlineStyle, Permission, Permissions},
5 doc::command_scope::{CommandScope, ToCommandScope},
6 Token,
7};
8
9#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
13#[cmake(pkg = "crate", untagged)]
14pub enum File<'t> {
15 Reading(FileReading<'t>),
16 Writing(FileWriting<'t>),
17 Filesystem(FileFilesystem<'t>),
18 PathConversion(FilePathConversion<'t>),
19 Transfer(FileTransfer<'t>),
20 Locking(FileLocking<'t>),
21 Archiving(FileArchiving<'t>),
22}
23
24impl<'t> ToCommandScope for File<'t> {
25 fn to_command_scope(&self) -> CommandScope {
26 CommandScope::Scripting
27 }
28}
29
30#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
31#[cmake(pkg = "crate", untagged)]
32pub enum FileReading<'t> {
33 #[cmake(transparent)]
34 Read(FileRead<'t>),
35 #[cmake(transparent)]
36 Strings(FileStrings<'t>),
37 Hash(FileHash<'t>),
38 #[cmake(transparent)]
39 Timestamp(FileTimestamp<'t>),
40 #[cmake(transparent)]
41 GetRuntimeDependencies(Box<FileGetRuntimeDependencies<'t>>),
42}
43
44#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
45#[cmake(pkg = "crate")]
46pub struct FileRead<'t> {
47 #[cmake(positional)]
48 pub filename: Token<'t>,
49 #[cmake(positional)]
50 pub variable: Token<'t>,
51 pub offset: Option<Token<'t>>,
52 pub limit: Option<Token<'t>>,
53 pub hex: bool,
54}
55
56#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
57#[cmake(pkg = "crate")]
58pub struct FileStrings<'t> {
59 #[cmake(positional)]
60 pub filename: Token<'t>,
61 #[cmake(positional)]
62 pub variable: Token<'t>,
63 pub options: Option<Vec<StringsOption<'t>>>,
64}
65
66#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
67#[cmake(pkg = "crate", transparent)]
68pub enum StringsOption<'t> {
69 LengthMaximum(Token<'t>),
70 LengthMinimum(Token<'t>),
71 LimitCount(Token<'t>),
72 LimitInput(Token<'t>),
73 LimitOutput(Token<'t>),
74 NewlineConsume,
75 NoHexConversion,
76 Regex(Token<'t>),
77 Encoding(StringsEncoding),
78}
79
80#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
81#[cmake(pkg = "crate", list)]
82pub enum StringsEncoding {
83 #[cmake(rename = "UTF-8")]
84 Utf8,
85 #[cmake(rename = "UTF-16LE")]
86 Utf16LE,
87 #[cmake(rename = "UTF-16BE")]
88 Utf16BE,
89 #[cmake(rename = "UTF-32LE")]
90 Utf32LE,
91 #[cmake(rename = "UTF-32BE")]
92 Utf32BE,
93}
94
95#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
96#[cmake(pkg = "crate", positional)]
97pub struct FileHash<'t> {
98 pub hash_algorithm: HashAlgorithm,
99 pub filename: Token<'t>,
100 pub variable: Token<'t>,
101}
102
103#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
104#[cmake(pkg = "crate", default = "format")]
105pub struct FileTimestamp<'t> {
106 #[cmake(positional)]
107 pub filename: Token<'t>,
108 #[cmake(positional)]
109 pub variable: Token<'t>,
110 #[cmake(rename = "")]
111 pub format: Option<Token<'t>>,
112 pub utc: bool,
113}
114
115#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
116#[cmake(pkg = "crate")]
117pub struct FileGetRuntimeDependencies<'t> {
118 pub resolved_dependencies_var: Option<Token<'t>>,
119 pub unresolved_dependencies_var: Option<Token<'t>>,
120 pub conflicting_dependencies_prefix: Option<Token<'t>>,
121 pub executables: Option<Vec<Token<'t>>>,
122 pub libraries: Option<Vec<Token<'t>>>,
123 pub modules: Option<Vec<Token<'t>>>,
124 pub directories: Option<Vec<Token<'t>>>,
125 pub bundle_executable: Option<Token<'t>>,
126 pub pre_include_regexes: Option<Vec<Token<'t>>>,
127 pub pre_exclude_regexes: Option<Vec<Token<'t>>>,
128 pub post_include_regexes: Option<Vec<Token<'t>>>,
129 pub post_exclude_regexes: Option<Vec<Token<'t>>>,
130 pub post_include_files: Option<Vec<Token<'t>>>,
131 pub post_exclude_files: Option<Vec<Token<'t>>>,
132}
133
134#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
135#[cmake(pkg = "crate", transparent)]
136pub enum FileWriting<'t> {
137 Write(FileWrite<'t>),
138 Append(FileWrite<'t>),
139 Touch(FileTouch<'t>),
140 #[cmake(rename = "TOUCH_NOCREATE")]
141 TouchNoCreate(FileTouch<'t>),
142 Generate(FileGenerate<'t>),
143 Configure(FileConfigure<'t>),
144}
145
146#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
147#[cmake(pkg = "crate", positional)]
148pub struct FileWrite<'t> {
149 pub filename: Token<'t>,
150 pub content: Option<Vec<Token<'t>>>,
151}
152
153#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
154#[cmake(pkg = "crate", positional)]
155pub struct FileTouch<'t> {
156 pub files: Option<Vec<Token<'t>>>,
157}
158
159#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
160#[cmake(pkg = "crate")]
161pub struct FileGenerate<'t> {
162 #[cmake(positional, transparent)]
163 pub output: Token<'t>,
164 #[cmake(positional)]
165 pub input: GenerateInput<'t>,
166 pub condition: Option<Condition<'t>>,
167 pub target: Option<Token<'t>>,
168 pub permissions: Option<Permissions<'t>>,
169 pub newline_style: Option<NewlineStyle>,
170}
171
172#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
173#[cmake(pkg = "crate", transparent)]
174pub enum GenerateInput<'t> {
175 Input(Token<'t>),
176 Content(Token<'t>),
177}
178
179#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
180#[cmake(pkg = "crate")]
181pub struct FileConfigure<'t> {
182 #[cmake(positional, transparent)]
183 pub output: Token<'t>,
184 #[cmake(positional, transparent)]
185 pub content: Token<'t>,
186 pub escape_quotes: bool,
187 #[cmake(rename = "@ONLY")]
188 pub only: bool,
189 pub newline_style: Option<NewlineStyle>,
190}
191
192#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
193#[cmake(pkg = "crate", transparent)]
194pub enum FileFilesystem<'t> {
195 Glob(FileGlob<'t>),
196 GlobRecurse(FileGlobRecurse<'t>),
197 MakeDirectory(FileMakeDirectory<'t>),
198 Remove(FileRemove<'t>),
199 RemoveRecurse(FileRemove<'t>),
200 Rename(FileRename<'t>),
201 CopyFile(FileCopyFile<'t>),
202 Copy(FileCopy<'t>),
203 Install(FileInstall<'t>),
204 Size(FileSize<'t>),
205 ReadSymlink(FileReadSymlink<'t>),
206 CreateLink(FileCreateLink<'t>),
207 Chmod(FileChmod<'t>),
208 ChmodRecurse(FileChmod<'t>),
209}
210
211#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
212#[cmake(pkg = "crate", default = "globbing_expressions")]
213pub struct FileGlob<'t> {
214 #[cmake(positional)]
215 pub variable: Token<'t>,
216 pub list_directories: Option<ListDirectories>,
217 pub relative: Option<Token<'t>>,
218 pub configure_depends: bool,
219 #[cmake(rename = "")]
220 pub globbing_expressions: Option<Vec<Token<'t>>>,
221}
222
223#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
224#[cmake(pkg = "crate", default = "globbing_expressions")]
225pub struct FileGlobRecurse<'t> {
226 #[cmake(positional)]
227 pub variable: Token<'t>,
228 pub follow_symlinks: bool,
229 pub list_directories: Option<ListDirectories>,
230 pub relative: Option<Token<'t>>,
231 pub configure_depends: bool,
232 #[cmake(rename = "")]
233 pub globbing_expressions: Option<Vec<Token<'t>>>,
234}
235
236#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
237#[cmake(pkg = "crate", list)]
238pub enum ListDirectories {
239 #[cmake(rename = "true")]
240 True,
241 #[cmake(rename = "false")]
242 False,
243}
244
245#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
246#[cmake(pkg = "crate", positional, allow_empty)]
247pub struct FileMakeDirectory<'t> {
248 pub directories: Option<Vec<Token<'t>>>,
249}
250
251#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
252#[cmake(pkg = "crate", positional, allow_empty)]
253pub struct FileRemove<'t> {
254 pub files: Option<Vec<Token<'t>>>,
255}
256
257#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
258#[cmake(pkg = "crate")]
259pub struct FileRename<'t> {
260 #[cmake(positional)]
261 pub oldname: Token<'t>,
262 #[cmake(positional)]
263 pub newname: Token<'t>,
264 pub result: Option<Token<'t>>,
265 pub no_replace: bool,
266}
267
268#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
269#[cmake(pkg = "crate")]
270pub struct FileCopyFile<'t> {
271 #[cmake(positional)]
272 pub oldname: Token<'t>,
273 #[cmake(positional)]
274 pub newname: Token<'t>,
275 pub result: Option<Token<'t>>,
276 pub only_if_different: bool,
277 pub input_may_be_recent: bool,
278}
279
280#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
281#[cmake(pkg = "crate", default = "files")]
282pub struct FileCopy<'t> {
283 #[cmake(rename = "")]
284 pub files: Vec<Token<'t>>,
285 pub destination: Token<'t>,
286 pub source_permissions: Option<SourcePermissions>,
287 pub file_permissions: Option<Vec<Permission>>,
288 pub directory_permissions: Option<Vec<Permission>>,
289 pub follow_symlink_chain: bool,
290 pub files_matching: bool,
291 pub file_matches: Option<Vec<FileMatch<'t>>>,
292}
293
294#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
295#[cmake(pkg = "crate")]
296pub enum SourcePermissions {
297 #[cmake(rename = "NO_SOURCE_PERMISSIONS")]
298 No,
299 #[cmake(rename = "USE_SOURCE_PERMISSIONS")]
300 Use,
301}
302
303#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
304#[cmake(pkg = "crate", default = "files")]
305pub struct FileInstall<'t> {
306 pub files: Vec<Token<'t>>,
307 pub destination: Token<'t>,
308 pub source_permissions: Option<SourcePermissions>,
309 pub file_permissions: Option<Vec<Permission>>,
310 pub directory_permissions: Option<Vec<Permission>>,
311 pub follow_symlink_chain: bool,
312 pub files_matching: bool,
313 pub file_matches: Option<Vec<FileMatch<'t>>>,
314}
315
316#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
317#[cmake(pkg = "crate", positional)]
318pub struct FileSize<'t> {
319 pub filename: Token<'t>,
320 pub variable: Token<'t>,
321}
322
323#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
324#[cmake(pkg = "crate", positional)]
325pub struct FileReadSymlink<'t> {
326 pub linkname: Token<'t>,
327 pub variable: Token<'t>,
328}
329
330#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
331#[cmake(pkg = "crate")]
332pub struct FileCreateLink<'t> {
333 #[cmake(positional)]
334 pub original: Token<'t>,
335 #[cmake(positional)]
336 pub linkname: Token<'t>,
337 pub result: Option<Token<'t>>,
338 pub copy_on_error: bool,
339 pub symbolic: bool,
340}
341
342#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
343#[cmake(pkg = "crate", default = "files")]
344pub struct FileChmod<'t> {
345 #[cmake(rename = "")]
346 pub files: Vec<Token<'t>>,
347 pub permissions: Option<Vec<Permission>>,
348 pub file_permissions: Option<Vec<Permission>>,
349 pub directory_permissions: Option<Vec<Permission>>,
350}
351
352#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
353#[cmake(pkg = "crate", transparent)]
354#[allow(clippy::enum_variant_names)]
355pub enum FilePathConversion<'t> {
356 RealPath(FileRealPath<'t>),
357 RelativePath(FileRelativePath<'t>),
358 #[cmake(rename = "TO_CMAKE_PATH")]
359 ToCMakePath(FileToCMakePath<'t>),
360 ToNativePath(FileToNativePath<'t>),
361}
362
363#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
364#[cmake(pkg = "crate")]
365pub struct FileRealPath<'t> {
366 #[cmake(positional)]
367 pub path: Token<'t>,
368 #[cmake(positional)]
369 pub out_var: Token<'t>,
370 pub base_directory: Option<Token<'t>>,
371 pub expand_tilde: bool,
372}
373
374#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
375#[cmake(pkg = "crate", positional)]
376pub struct FileRelativePath<'t> {
377 pub variable: Token<'t>,
378 pub directory: Token<'t>,
379 pub file: Token<'t>,
380}
381
382#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
383#[cmake(pkg = "crate", positional)]
384pub struct FileToCMakePath<'t> {
385 pub path: Token<'t>,
386 pub variable: Token<'t>,
387}
388
389#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
390#[cmake(pkg = "crate", positional)]
391pub struct FileToNativePath<'t> {
392 pub path: Token<'t>,
393 pub variable: Token<'t>,
394}
395
396#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
397#[cmake(pkg = "crate", transparent)]
398pub enum FileTransfer<'t> {
399 Download(FileDownload<'t>),
400 Upload(FileUpload<'t>),
401}
402
403#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
404#[cmake(pkg = "crate", default = "file")]
405pub struct FileDownload<'t> {
406 #[cmake(positional)]
407 pub url: Token<'t>,
408 #[cmake(rename = "")]
409 pub file: Option<Token<'t>>,
410 pub options: Option<Vec<DownloadOption<'t>>>,
411}
412
413#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
414#[cmake(pkg = "crate", transparent)]
415pub enum DownloadOption<'t> {
416 InactivityTimeout(Token<'t>),
417 Log(Token<'t>),
418 ShowProgress,
419 Status(Token<'t>),
420 Timeout(Token<'t>),
421 #[cmake(rename = "USERPWD")]
422 UserPwd(Token<'t>),
423 #[cmake(rename = "HTTPHEADER")]
424 HttpHeader(Token<'t>),
425 #[cmake(rename = "NETRC")]
426 NetRC(NetRCLevel),
427 #[cmake(rename = "NETRC_FILE")]
428 NetRCFile(Token<'t>),
429 TlsVerify(TlsVerify),
430 #[cmake(rename = "TLS_CAINFO")]
431 TlsCAInfo(Token<'t>),
432 ExpectedHash(Token<'t>), ExpectedMD5(Token<'t>),
434 RangeStart(Token<'t>),
435 RangeEnd(Token<'t>),
436}
437
438#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
439#[cmake(pkg = "crate", list)]
440pub enum NetRCLevel {
441 Ignored,
442 Optional,
443 Required,
444}
445
446#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
447#[cmake(pkg = "crate", list)]
448pub enum TlsVerify {
449 On,
450 Off,
451}
452
453#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
454#[cmake(pkg = "crate")]
455pub struct FileUpload<'t> {
456 #[cmake(positional)]
457 pub file: Token<'t>,
458 #[cmake(positional)]
459 pub url: Token<'t>,
460 pub options: Option<Vec<UploadOption<'t>>>,
461}
462
463#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
464#[cmake(pkg = "crate", transparent)]
465pub enum UploadOption<'t> {
466 InactivityTimeout(Token<'t>),
467 Log(Token<'t>),
468 ShowProgress,
469 Status(Token<'t>),
470 Timeout(Token<'t>),
471 #[cmake(rename = "USERPWD")]
472 UserPwd(Token<'t>),
473 #[cmake(rename = "HTTPHEADER")]
474 HttpHeader(Token<'t>),
475 #[cmake(rename = "NETRC")]
476 NetRC(NetRCLevel),
477 #[cmake(rename = "NETRC_FILE")]
478 NetRCFile(Token<'t>),
479 TlsVerify(TlsVerify),
480 #[cmake(rename = "TLS_CAINFO")]
481 TlsCAInfo(Token<'t>),
482}
483
484#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
485#[cmake(pkg = "crate", transparent)]
486pub enum FileLocking<'t> {
487 Lock(FileLock<'t>),
488}
489
490#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
491#[cmake(pkg = "crate")]
492pub struct FileLock<'t> {
493 #[cmake(positional)]
494 pub path: Token<'t>,
495 pub directory: bool,
496 pub release: bool,
497 pub guard: Option<LockGuard>,
498 pub result_variable: Option<Token<'t>>,
499 pub timeout: Option<Token<'t>>,
500}
501
502#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
503#[cmake(pkg = "crate", list)]
504pub enum LockGuard {
505 Function,
506 File,
507 Process,
508}
509
510#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
511#[cmake(pkg = "crate", transparent)]
512pub enum FileArchiving<'t> {
513 ArchiveCreate(FileArchiveCreate<'t>),
514 ArchiveExtract(FileArchiveExtract<'t>),
515}
516
517#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
518#[cmake(pkg = "crate")]
519pub struct FileArchiveCreate<'t> {
520 #[cmake(positional, transparent)]
521 pub output: Token<'t>,
522 pub paths: Vec<Token<'t>>,
523 pub format: Option<ArchiveFormat>,
524 pub compression: Option<ArchiveCompression<'t>>,
525 pub mtime: Option<Token<'t>>,
526 pub verbose: bool,
527}
528
529#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
530#[cmake(pkg = "crate", list)]
531pub enum ArchiveFormat {
532 #[cmake(rename = "7zip")]
533 SevenZip,
534 #[cmake(rename = "gnutar")]
535 GnuTar,
536 #[cmake(rename = "pax")]
537 Pax,
538 #[cmake(rename = "paxr")]
539 PaxR,
540 #[cmake(rename = "raw")]
541 Raw,
542 #[cmake(rename = "zip")]
543 Zip,
544}
545
546#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
547#[cmake(pkg = "crate", positional)]
548pub struct ArchiveCompression<'t> {
549 pub compression: Compression,
550 #[cmake(transparent)]
551 pub compression_level: Option<Token<'t>>,
552}
553
554#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
555#[cmake(pkg = "crate", list)]
556pub enum Compression {
557 #[cmake(rename = "None")]
558 None,
559 #[cmake(rename = "BZip2")]
560 BZip2,
561 #[cmake(rename = "GZip")]
562 GZip,
563 #[cmake(rename = "XZ")]
564 Xz,
565 #[cmake(rename = "Zstd")]
566 Zstd,
567}
568
569#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
570#[cmake(pkg = "crate")]
571pub struct FileArchiveExtract<'t> {
572 #[cmake(positional, transparent)]
573 pub input: Token<'t>,
574 pub destination: Option<Token<'t>>,
575 pub patterns: Option<Vec<Token<'t>>>,
576 pub list_only: bool,
577 pub verbose: bool,
578 pub touch: bool,
579}
580
581#[cfg(test)]
582mod tests {
583 use super::*;
584 use crate::command::common::FileMatchKind;
585 use crate::doc::cmake_parse::tests::{quoted_token, token, tokens_vec};
586 use crate::*;
587 use pretty_assertions::assert_eq;
588
589 #[test]
590 fn file() {
591 let src = include_bytes!("../../../../../fixture/commands/scripting/file");
592 let cmakelists = parse_cmakelists(src).unwrap();
593 let doc = Doc::from(cmakelists);
594 assert_eq!(
595 doc.commands(),
596 Ok(vec![
597 Command::File(Box::new(File::Reading(FileReading::Read(FileRead {
598 filename: token(b"filename1"),
599 variable: token(b"variable1"),
600 offset: Some(token(b"offset1")),
601 limit: Some(token(b"limit1")),
602 hex: true,
603 })))),
604 Command::File(Box::new(File::Reading(FileReading::Strings(FileStrings {
605 filename: token(b"filename1"),
606 variable: token(b"variable1"),
607 options: None,
608 })))),
609 Command::File(Box::new(File::Reading(FileReading::Strings(FileStrings {
610 filename: token(b"filename1"),
611 variable: token(b"variable1"),
612 options: Some(vec![
613 StringsOption::LengthMaximum(token(b"length_maximum1")),
614 StringsOption::LengthMinimum(token(b"length_minimum1")),
615 StringsOption::LimitCount(token(b"limit_count1")),
616 StringsOption::LimitInput(token(b"limit_input1")),
617 StringsOption::LimitOutput(token(b"limit_output1")),
618 StringsOption::NewlineConsume,
619 StringsOption::NoHexConversion,
620 StringsOption::Regex(token(b"regex1")),
621 StringsOption::Encoding(StringsEncoding::Utf8),
622 StringsOption::Encoding(StringsEncoding::Utf16LE),
623 StringsOption::Encoding(StringsEncoding::Utf16BE),
624 StringsOption::Encoding(StringsEncoding::Utf32LE),
625 StringsOption::Encoding(StringsEncoding::Utf32BE),
626 ]),
627 })))),
628 Command::File(Box::new(File::Reading(FileReading::Hash(FileHash {
629 hash_algorithm: HashAlgorithm::SHA1,
630 filename: token(b"filename1"),
631 variable: token(b"variable1"),
632 })))),
633 Command::File(Box::new(File::Reading(FileReading::Timestamp(
634 FileTimestamp {
635 filename: token(b"filename1"),
636 variable: token(b"variable1"),
637 format: Some(token(b"format1")),
638 utc: true,
639 }
640 )))),
641 Command::File(Box::new(File::Reading(
642 FileReading::GetRuntimeDependencies(Box::new(FileGetRuntimeDependencies {
643 resolved_dependencies_var: Some(token(b"resolved_dependencies_var1")),
644 unresolved_dependencies_var: Some(token(b"unresolved_dependencies_var1")),
645 conflicting_dependencies_prefix: Some(token(
646 b"conflicting_dependencies_prefix1"
647 )),
648 executables: Some(tokens_vec([b"executables1", b"executables2"])),
649 libraries: Some(tokens_vec([b"libraries1", b"libraries2"])),
650 modules: Some(tokens_vec([b"modules1", b"modules2"])),
651 directories: Some(tokens_vec([b"directories1", b"directories2"])),
652 bundle_executable: Some(token(b"bundle_executable1")),
653 pre_include_regexes: Some(tokens_vec([
654 b"pre_include_regexes1",
655 b"pre_include_regexes2"
656 ])),
657 pre_exclude_regexes: Some(tokens_vec([
658 b"pre_exclude_regexes1",
659 b"pre_exclude_regexes2"
660 ])),
661 post_include_regexes: Some(tokens_vec([
662 b"post_include_regexes1",
663 b"post_include_regexes2"
664 ])),
665 post_exclude_regexes: Some(tokens_vec([
666 b"post_exclude_regexes1",
667 b"post_exclude_regexes2"
668 ])),
669 post_include_files: Some(tokens_vec([
670 b"post_include_files1",
671 b"post_include_files2"
672 ])),
673 post_exclude_files: Some(tokens_vec([
674 b"post_exclude_files1",
675 b"post_exclude_files2"
676 ])),
677 }))
678 ))),
679 Command::File(Box::new(File::Writing(FileWriting::Write(FileWrite {
680 filename: token(b"filename1"),
681 content: Some(tokens_vec([b"content1"])),
682 })))),
683 Command::File(Box::new(File::Writing(FileWriting::Append(FileWrite {
684 filename: token(b"filename1"),
685 content: Some(tokens_vec([b"content1"])),
686 })))),
687 Command::File(Box::new(File::Writing(FileWriting::Touch(FileTouch {
688 files: Some(tokens_vec([b"file1", b"file2"])),
689 })))),
690 Command::File(Box::new(File::Writing(FileWriting::TouchNoCreate(
691 FileTouch {
692 files: Some(tokens_vec([b"file1", b"file2"])),
693 }
694 )))),
695 Command::File(Box::new(File::Writing(FileWriting::Generate(
696 FileGenerate {
697 output: token(b"output1"),
698 input: GenerateInput::Input(token(b"input1")),
699 condition: None,
700 target: None,
701 permissions: None,
702 newline_style: None,
703 }
704 )))),
705 Command::File(Box::new(File::Writing(FileWriting::Generate(
706 FileGenerate {
707 output: token(b"output1"),
708 input: GenerateInput::Content(token(b"content1")),
709 condition: None,
710 target: None,
711 permissions: None,
712 newline_style: None,
713 }
714 )))),
715 Command::File(Box::new(File::Writing(FileWriting::Generate(
716 FileGenerate {
717 output: token(b"output1"),
718 input: GenerateInput::Input(token(b"input1")),
719 condition: Some(Condition {
720 conditions: tokens_vec([b"condition1"]),
721 }),
722 target: Some(token(b"target1")),
723 permissions: Some(Permissions::File(tokens_vec([b"file1", b"file2"]))),
724 newline_style: Some(NewlineStyle::Dos),
725 }
726 )))),
727 Command::File(Box::new(File::Writing(FileWriting::Configure(
728 FileConfigure {
729 output: token(b"output1"),
730 content: token(b"content1"),
731 escape_quotes: false,
732 only: false,
733 newline_style: None,
734 }
735 )))),
736 Command::File(Box::new(File::Writing(FileWriting::Configure(
737 FileConfigure {
738 output: token(b"output1"),
739 content: token(b"content1"),
740 escape_quotes: true,
741 only: true,
742 newline_style: Some(NewlineStyle::CrLf),
743 }
744 )))),
745 Command::File(Box::new(File::Filesystem(FileFilesystem::Glob(FileGlob {
746 variable: token(b"variable1"),
747 list_directories: None,
748 relative: None,
749 configure_depends: false,
750 globbing_expressions: None,
751 })))),
752 Command::File(Box::new(File::Filesystem(FileFilesystem::Glob(FileGlob {
753 variable: token(b"variable1"),
754 list_directories: Some(ListDirectories::True),
755 relative: Some(token(b"relative1")),
756 configure_depends: true,
757 globbing_expressions: Some(tokens_vec([b"gexp1", b"gexp2"])),
758 })))),
759 Command::File(Box::new(File::Filesystem(FileFilesystem::GlobRecurse(
760 FileGlobRecurse {
761 variable: token(b"variable1"),
762 follow_symlinks: false,
763 list_directories: None,
764 relative: None,
765 configure_depends: false,
766 globbing_expressions: None,
767 }
768 )))),
769 Command::File(Box::new(File::Filesystem(FileFilesystem::GlobRecurse(
770 FileGlobRecurse {
771 variable: token(b"variable1"),
772 follow_symlinks: true,
773 list_directories: Some(ListDirectories::False),
774 relative: Some(token(b"relative1")),
775 configure_depends: true,
776 globbing_expressions: Some(tokens_vec([b"gexp1", b"gexp2"])),
777 }
778 )))),
779 Command::File(Box::new(File::Filesystem(FileFilesystem::MakeDirectory(
780 FileMakeDirectory { directories: None }
781 )))),
782 Command::File(Box::new(File::Filesystem(FileFilesystem::MakeDirectory(
783 FileMakeDirectory {
784 directories: Some(tokens_vec([b"dir1", b"dir2"])),
785 }
786 )))),
787 Command::File(Box::new(File::Filesystem(FileFilesystem::Remove(
788 FileRemove { files: None }
789 )))),
790 Command::File(Box::new(File::Filesystem(FileFilesystem::Remove(
791 FileRemove {
792 files: Some(tokens_vec([b"file1", b"file2"])),
793 }
794 )))),
795 Command::File(Box::new(File::Filesystem(FileFilesystem::RemoveRecurse(
796 FileRemove { files: None }
797 )))),
798 Command::File(Box::new(File::Filesystem(FileFilesystem::RemoveRecurse(
799 FileRemove {
800 files: Some(tokens_vec([b"file1", b"file2"])),
801 }
802 )))),
803 Command::File(Box::new(File::Filesystem(FileFilesystem::Rename(
804 FileRename {
805 oldname: token(b"oldname1"),
806 newname: token(b"newname1"),
807 result: Some(token(b"result1")),
808 no_replace: true,
809 }
810 )))),
811 Command::File(Box::new(File::Filesystem(FileFilesystem::CopyFile(
812 FileCopyFile {
813 oldname: token(b"oldname1"),
814 newname: token(b"newname1"),
815 result: Some(token(b"result1")),
816 only_if_different: true,
817 input_may_be_recent: true,
818 }
819 )))),
820 Command::File(Box::new(File::Filesystem(FileFilesystem::Copy(FileCopy {
821 files: tokens_vec([b"/opt/foo/lib/libfoo.so"]),
822 destination: token(b"lib"),
823 source_permissions: None,
824 file_permissions: None,
825 directory_permissions: None,
826 follow_symlink_chain: true,
827 files_matching: false,
828 file_matches: None,
829 })))),
830 Command::File(Box::new(File::Filesystem(FileFilesystem::Install(
831 FileInstall {
832 files: tokens_vec([b"/opt/foo/bin/foo", b"/opt/foo/bin/boo"]),
833 destination: token(b"bin"),
834 source_permissions: None,
835 file_permissions: None,
836 directory_permissions: None,
837 follow_symlink_chain: false,
838 files_matching: true,
839 file_matches: Some(vec![
840 FileMatch {
841 kind: Some(FileMatchKind::Pattern(quoted_token(b"CVS"),),),
842 exclude: true,
843 permissions: None,
844 },
845 FileMatch {
846 kind: Some(FileMatchKind::Pattern(quoted_token(b"scripts/*"),),),
847 exclude: false,
848 permissions: Some(vec![
849 Permission::OwnerExecute,
850 Permission::OwnerWrite,
851 Permission::OwnerRead,
852 Permission::GroupExecute,
853 Permission::GroupRead,
854 ]),
855 },
856 ],),
857 }
858 )))),
859 Command::File(Box::new(File::Filesystem(FileFilesystem::Size(FileSize {
860 filename: token(b"filename1"),
861 variable: token(b"variable1"),
862 })))),
863 Command::File(Box::new(File::Filesystem(FileFilesystem::ReadSymlink(
864 FileReadSymlink {
865 linkname: token(b"linkname1"),
866 variable: token(b"variable1"),
867 }
868 )))),
869 Command::File(Box::new(File::Filesystem(FileFilesystem::CreateLink(
870 FileCreateLink {
871 original: token(b"original1"),
872 linkname: token(b"linkname1"),
873 result: None,
874 copy_on_error: false,
875 symbolic: false,
876 }
877 )))),
878 Command::File(Box::new(File::Filesystem(FileFilesystem::CreateLink(
879 FileCreateLink {
880 original: token(b"original1"),
881 linkname: token(b"linkname1"),
882 result: Some(token(b"result1")),
883 copy_on_error: true,
884 symbolic: true,
885 }
886 )))),
887 Command::File(Box::new(File::Filesystem(FileFilesystem::Chmod(
888 FileChmod {
889 files: tokens_vec([b"file1"]),
890 permissions: Some(vec![Permission::OwnerRead, Permission::OwnerWrite]),
891 file_permissions: None,
892 directory_permissions: None,
893 }
894 )))),
895 Command::File(Box::new(File::Filesystem(FileFilesystem::Chmod(
896 FileChmod {
897 files: tokens_vec([b"file1", b"file2"]),
898 permissions: None,
899 file_permissions: Some(vec![
900 Permission::OwnerWrite,
901 Permission::OwnerExecute
902 ]),
903 directory_permissions: None,
904 }
905 )))),
906 Command::File(Box::new(File::Filesystem(FileFilesystem::Chmod(
907 FileChmod {
908 files: tokens_vec([b"file1", b"file2", b"file3"]),
909 permissions: None,
910 file_permissions: None,
911 directory_permissions: Some(vec![
912 Permission::SetGID,
913 Permission::OwnerWrite
914 ]),
915 }
916 )))),
917 Command::File(Box::new(File::Filesystem(FileFilesystem::ChmodRecurse(
918 FileChmod {
919 files: tokens_vec([b"file1"]),
920 permissions: Some(vec![Permission::OwnerRead, Permission::OwnerWrite]),
921 file_permissions: None,
922 directory_permissions: None,
923 }
924 )))),
925 Command::File(Box::new(File::Filesystem(FileFilesystem::ChmodRecurse(
926 FileChmod {
927 files: tokens_vec([b"file1", b"file2"]),
928 permissions: None,
929 file_permissions: Some(vec![
930 Permission::OwnerWrite,
931 Permission::OwnerExecute
932 ]),
933 directory_permissions: None,
934 }
935 )))),
936 Command::File(Box::new(File::Filesystem(FileFilesystem::ChmodRecurse(
937 FileChmod {
938 files: tokens_vec([b"file1", b"file2", b"file3"]),
939 permissions: None,
940 file_permissions: None,
941 directory_permissions: Some(vec![
942 Permission::SetGID,
943 Permission::OwnerWrite
944 ]),
945 }
946 )))),
947 Command::File(Box::new(File::PathConversion(
948 FilePathConversion::RealPath(FileRealPath {
949 path: token(b"path1"),
950 out_var: token(b"out_var1"),
951 base_directory: None,
952 expand_tilde: false,
953 })
954 ))),
955 Command::File(Box::new(File::PathConversion(
956 FilePathConversion::RealPath(FileRealPath {
957 path: token(b"path1"),
958 out_var: token(b"out_var1"),
959 base_directory: Some(token(b"base_directory1")),
960 expand_tilde: true,
961 })
962 ))),
963 Command::File(Box::new(File::PathConversion(
964 FilePathConversion::RelativePath(FileRelativePath {
965 variable: token(b"variable1"),
966 directory: token(b"directory1"),
967 file: token(b"file1"),
968 })
969 ))),
970 Command::File(Box::new(File::PathConversion(
971 FilePathConversion::ToCMakePath(FileToCMakePath {
972 path: token(b"path1"),
973 variable: token(b"variable1"),
974 })
975 ))),
976 Command::File(Box::new(File::PathConversion(
977 FilePathConversion::ToNativePath(FileToNativePath {
978 path: token(b"path1"),
979 variable: token(b"variable1"),
980 })
981 ))),
982 Command::File(Box::new(File::Transfer(FileTransfer::Download(
983 FileDownload {
984 url: token(b"url1"),
985 file: None,
986 options: None,
987 }
988 )))),
989 Command::File(Box::new(File::Transfer(FileTransfer::Download(
990 FileDownload {
991 url: token(b"url1"),
992 file: Some(token(b"file1")),
993 options: Some(vec![
994 DownloadOption::InactivityTimeout(token(b"inactivity_timeout1")),
995 DownloadOption::Log(token(b"log1")),
996 DownloadOption::ShowProgress,
997 DownloadOption::Status(token(b"status1")),
998 DownloadOption::Timeout(token(b"timeout1")),
999 DownloadOption::UserPwd(token(b"userpwd1")),
1000 DownloadOption::HttpHeader(token(b"header1:value1")),
1001 DownloadOption::NetRC(NetRCLevel::Ignored),
1002 DownloadOption::NetRC(NetRCLevel::Optional),
1003 DownloadOption::NetRC(NetRCLevel::Required),
1004 DownloadOption::NetRCFile(token(b"netrc_file1")),
1005 DownloadOption::TlsVerify(TlsVerify::On),
1006 DownloadOption::TlsVerify(TlsVerify::Off),
1007 DownloadOption::TlsCAInfo(token(b"tls_cainfo1")),
1008 DownloadOption::ExpectedHash(token(b"MD5=12345")),
1009 DownloadOption::ExpectedMD5(token(b"expected_md5")),
1010 DownloadOption::RangeStart(token(b"range_start1")),
1011 DownloadOption::RangeEnd(token(b"range_end1")),
1012 ]),
1013 }
1014 )))),
1015 Command::File(Box::new(File::Transfer(FileTransfer::Upload(FileUpload {
1016 file: token(b"file1"),
1017 url: token(b"url1"),
1018 options: None,
1019 })))),
1020 Command::File(Box::new(File::Transfer(FileTransfer::Upload(FileUpload {
1021 file: token(b"file1"),
1022 url: token(b"url1"),
1023 options: Some(vec![
1024 UploadOption::InactivityTimeout(token(b"inactivity_timeout1")),
1025 UploadOption::Log(token(b"log1")),
1026 UploadOption::ShowProgress,
1027 UploadOption::Status(token(b"status1")),
1028 UploadOption::Timeout(token(b"timeout1")),
1029 UploadOption::UserPwd(token(b"userpwd1")),
1030 UploadOption::HttpHeader(token(b"header1:value1")),
1031 UploadOption::NetRC(NetRCLevel::Ignored),
1032 UploadOption::NetRC(NetRCLevel::Optional),
1033 UploadOption::NetRC(NetRCLevel::Required),
1034 UploadOption::NetRCFile(token(b"netrc_file1")),
1035 UploadOption::TlsVerify(TlsVerify::On),
1036 UploadOption::TlsVerify(TlsVerify::Off),
1037 UploadOption::TlsCAInfo(token(b"tls_cainfo1")),
1038 ]),
1039 })))),
1040 Command::File(Box::new(File::Locking(FileLocking::Lock(FileLock {
1041 path: token(b"path1"),
1042 directory: false,
1043 release: false,
1044 guard: None,
1045 result_variable: None,
1046 timeout: None,
1047 })))),
1048 Command::File(Box::new(File::Locking(FileLocking::Lock(FileLock {
1049 path: token(b"path1"),
1050 directory: false,
1051 release: false,
1052 guard: Some(LockGuard::File),
1053 result_variable: None,
1054 timeout: None,
1055 })))),
1056 Command::File(Box::new(File::Locking(FileLocking::Lock(FileLock {
1057 path: token(b"path1"),
1058 directory: false,
1059 release: false,
1060 guard: Some(LockGuard::Process),
1061 result_variable: None,
1062 timeout: None,
1063 })))),
1064 Command::File(Box::new(File::Locking(FileLocking::Lock(FileLock {
1065 path: token(b"path1"),
1066 directory: true,
1067 release: true,
1068 guard: Some(LockGuard::Function),
1069 result_variable: Some(token(b"result_variable1")),
1070 timeout: Some(token(b"timeout1")),
1071 })))),
1072 Command::File(Box::new(File::Archiving(FileArchiving::ArchiveCreate(
1073 FileArchiveCreate {
1074 output: token(b"output1"),
1075 paths: tokens_vec([b"path1", b"path2"]),
1076 format: None,
1077 compression: None,
1078 mtime: None,
1079 verbose: false,
1080 }
1081 )))),
1082 Command::File(Box::new(File::Archiving(FileArchiving::ArchiveCreate(
1083 FileArchiveCreate {
1084 output: token(b"output1"),
1085 paths: tokens_vec([b"path1", b"path2"]),
1086 format: Some(ArchiveFormat::PaxR),
1087 compression: Some(ArchiveCompression {
1088 compression: Compression::Xz,
1089 compression_level: Some(token(b"5")),
1090 }),
1091 mtime: Some(token(b"mtime1")),
1092 verbose: true,
1093 }
1094 )))),
1095 Command::File(Box::new(File::Archiving(FileArchiving::ArchiveExtract(
1096 FileArchiveExtract {
1097 input: token(b"input1"),
1098 destination: None,
1099 patterns: None,
1100 list_only: false,
1101 verbose: false,
1102 touch: false,
1103 }
1104 )))),
1105 Command::File(Box::new(File::Archiving(FileArchiving::ArchiveExtract(
1106 FileArchiveExtract {
1107 input: token(b"input1"),
1108 destination: Some(token(b"destination1")),
1109 patterns: Some(tokens_vec([b"pattern1", b"pattern2"])),
1110 list_only: true,
1111 verbose: true,
1112 touch: true,
1113 }
1114 )))),
1115 ])
1116 )
1117 }
1118}