applied-ai-018 commited on
Commit
3018c75
·
verified ·
1 Parent(s): 960b28b

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. cc-multilingual-main/cc_net/bin/build_binary +0 -0
  2. cc-multilingual-main/cc_net/bin/spm_encode +0 -0
  3. cc-multilingual-main/cc_net/bin/spm_train +0 -0
  4. cc-multilingual-main/cc_net/build/lib/cc_net/data/cutoff.csv +101 -0
  5. cc-multilingual-main/cc_net/build/lib/cc_net/data/test_stats.json +38 -0
  6. cc-multilingual-main/cc_net/build/lib/cc_net/mine.py +648 -0
  7. cc-multilingual-main/cc_net/build/lib/cc_net/perplexity.py +356 -0
  8. cc-multilingual-main/cc_net/build/lib/cc_net/process_wet_file.py +292 -0
  9. cc-multilingual-main/cc_net/build/lib/cc_net/regroup.py +122 -0
  10. cc-multilingual-main/cc_net/build/lib/cc_net/text_normalizer.py +189 -0
  11. cc-multilingual-main/cc_net/cc_net.egg-info/PKG-INFO +194 -0
  12. cc-multilingual-main/cc_net/cc_net.egg-info/SOURCES.txt +33 -0
  13. cc-multilingual-main/cc_net/cc_net.egg-info/dependency_links.txt +1 -0
  14. cc-multilingual-main/cc_net/cc_net.egg-info/requires.txt +24 -0
  15. cc-multilingual-main/cc_net/cc_net.egg-info/top_level.txt +1 -0
  16. cc-multilingual-main/cc_net/tests/__init__.py +6 -0
  17. cc-multilingual-main/cc_net/tests/conftest.py +19 -0
  18. cc-multilingual-main/cc_net/tests/data/sample.warc.txt +66 -0
  19. cc-multilingual-main/cc_net/tests/test_dedup.py +245 -0
  20. cc-multilingual-main/cc_net/tests/test_flat_hash_set.py +78 -0
  21. cc-multilingual-main/cc_net/tests/test_jsonql.py +312 -0
  22. cc-multilingual-main/cc_net/tests/test_minify.py +153 -0
  23. cc-multilingual-main/cc_net/tests/test_normalizer.py +29 -0
  24. cc-multilingual-main/cc_net/tests/test_parse_wet_file.py +47 -0
  25. cc-multilingual-main/cc_net/tests/test_regroup.py +50 -0
  26. cc-multilingual-main/cc_net/tests/test_transformer.py +86 -0
  27. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_acquire_msys.cmake +644 -0
  28. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_add_to_path.cmake +10 -0
  29. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_backup_restore_env_vars.cmake +35 -0
  30. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_build_ninja.cmake +30 -0
  31. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_build_nmake.cmake +166 -0
  32. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_buildpath_length_warning.cmake +8 -0
  33. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_check_features.cmake +96 -0
  34. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_check_linkage.cmake +36 -0
  35. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_clean_executables_in_bin.cmake +46 -0
  36. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_common_functions.cmake +3 -0
  37. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_configure_cmake.cmake +393 -0
  38. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_configure_make.cmake +912 -0
  39. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_configure_qmake.cmake +167 -0
  40. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_copy_tool_dependencies.cmake +45 -0
  41. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_download_distfile.cmake +275 -0
  42. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_execute_required_process.cmake +129 -0
  43. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_extract_source_archive.cmake +158 -0
  44. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_extract_source_archive_ex.cmake +11 -0
  45. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(DOXYGEN).cmake +11 -0
  46. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(GIT).cmake +15 -0
  47. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(GPERF).cmake +8 -0
  48. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(JOM).cmake +13 -0
  49. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(MESON).cmake +18 -0
  50. cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(NINJA).cmake +28 -0
cc-multilingual-main/cc_net/bin/build_binary ADDED
Binary file (727 kB). View file
 
cc-multilingual-main/cc_net/bin/spm_encode ADDED
Binary file (74.5 kB). View file
 
cc-multilingual-main/cc_net/bin/spm_train ADDED
Binary file (60.5 kB). View file
 
cc-multilingual-main/cc_net/build/lib/cc_net/data/cutoff.csv ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,de,it,fr,nl,pl,pt,es,no,da,id,lt,fi,en,hu,ro,ko,ar,bn,fa,ru,uk,ml,my,lv,is,ca,ne,et,hy,ja,hr,hi,az,el,cs,bg,he,zh,ka,km,gu,mk,kn,mr,af,mn,kk,be
2
+ 0,0,0,0,10,0,0,0,0,0,0,0,10,0,0,0,20,0,0,0,0,0,0,10,10,10,0,10,0,0,0,0,0,0,0,0,0,0,10,0,10,10,10,10,10,10,0,0,10
3
+ 1,150,100,70,170,50,70,70,170,160,210,70,400,160,30,70,20,100,70,110,70,40,480,550,430,410,80,330,470,210,400,290,190,130,210,270,120,400,600,230,410,510,190,730,460,130,240,50,170
4
+ 2,170,110,90,200,70,80,90,210,190,260,90,490,180,30,80,30,180,80,150,90,50,740,840,570,490,90,420,630,300,540,360,220,200,250,350,180,520,750,360,460,580,250,1020,630,190,300,110,250
5
+ 3,190,120,90,230,70,90,90,230,210,300,100,570,200,40,90,30,220,90,180,110,60,930,980,650,530,100,470,720,360,620,400,240,240,270,410,220,620,840,420,490,630,280,1170,720,220,330,150,300
6
+ 4,200,130,100,240,80,90,100,250,220,320,110,620,210,40,100,30,250,100,190,110,60,1080,1140,710,560,110,510,780,400,670,440,260,270,280,450,230,690,900,480,530,670,300,1280,790,260,360,190,340
7
+ 5,210,130,100,260,90,100,110,260,230,340,110,670,220,40,110,30,260,100,210,120,70,1210,1260,760,580,120,540,830,430,710,470,270,300,290,480,250,760,950,520,550,690,320,1370,840,290,380,210,370
8
+ 6,220,140,110,270,90,100,110,270,240,350,120,700,230,40,110,30,280,110,220,130,70,1310,1390,790,600,120,570,870,450,750,490,280,320,300,510,270,810,990,560,560,720,340,1440,880,310,400,240,390
9
+ 7,230,140,110,280,100,110,120,280,250,370,120,740,230,50,120,30,290,110,230,140,70,1400,1500,820,620,130,590,900,480,770,510,300,340,310,540,290,850,1030,580,570,740,350,1500,920,330,410,270,410
10
+ 8,230,150,110,290,100,110,120,290,260,380,130,770,240,50,120,40,310,120,240,140,80,1470,1590,840,640,130,610,930,500,800,530,310,360,320,560,300,880,1060,610,600,760,370,1550,950,350,430,280,430
11
+ 9,240,150,120,300,100,110,120,300,270,400,130,790,250,50,120,40,320,120,240,150,80,1540,1660,860,650,140,630,960,520,820,540,310,380,330,580,310,910,1090,630,610,780,380,1600,990,370,450,310,450
12
+ 10,250,160,120,310,110,120,130,310,270,410,140,810,250,50,130,40,330,130,250,150,90,1600,1740,880,660,140,650,980,530,840,550,320,390,340,600,320,940,1110,650,620,800,390,1640,1010,380,460,330,470
13
+ 11,250,160,120,310,110,120,130,310,280,420,140,830,260,50,130,60,340,130,260,150,90,1650,1810,900,680,150,660,1000,550,860,570,330,410,350,610,330,970,1140,670,640,820,400,1680,1040,390,480,350,480
14
+ 12,260,160,130,320,110,120,130,320,290,430,140,850,260,50,130,70,350,130,270,160,90,1700,1870,920,690,150,680,1020,570,880,580,340,420,350,630,340,990,1160,690,660,840,410,1720,1060,400,490,370,500
15
+ 13,270,170,130,330,120,130,140,330,290,440,150,870,270,60,140,80,360,140,270,160,90,1750,1930,930,700,150,690,1030,580,890,590,350,440,360,640,340,1010,1180,710,680,860,420,1760,1090,410,500,380,510
16
+ 14,270,170,130,340,120,130,140,340,300,450,150,890,270,60,140,110,370,140,280,170,100,1800,1990,950,710,160,700,1050,590,910,600,360,450,370,650,350,1030,1200,730,700,880,430,1790,1110,420,510,400,520
17
+ 15,280,170,140,340,120,130,140,340,300,460,150,900,280,60,140,110,380,140,290,170,100,1850,2040,960,720,160,720,1070,600,920,610,360,460,370,670,360,1050,1220,740,710,890,430,1820,1130,430,520,420,540
18
+ 16,280,180,140,350,120,130,140,350,310,470,160,920,280,60,150,120,380,150,290,170,100,1890,2080,980,730,160,730,1080,620,940,620,370,470,380,680,360,1070,1240,750,740,910,440,1850,1150,440,530,440,550
19
+ 17,290,180,140,360,130,140,150,350,320,480,160,940,280,60,150,120,390,150,300,180,110,1940,2120,990,740,170,740,1100,630,950,630,380,480,380,690,370,1090,1260,770,760,920,450,1880,1170,450,550,450,560
20
+ 18,300,180,150,360,130,140,150,360,320,490,160,950,290,60,150,160,400,150,300,180,110,1980,2170,1000,750,170,750,1110,640,970,640,390,490,390,700,380,1100,1270,780,770,940,460,1910,1190,450,560,470,570
21
+ 19,300,190,150,370,130,140,150,370,330,500,160,970,290,70,150,230,410,160,310,180,110,2030,2200,1010,760,170,760,1130,650,980,640,390,500,390,710,380,1120,1290,790,790,950,460,1940,1210,460,570,480,580
22
+ 20,310,190,150,370,130,140,150,370,330,510,170,980,300,70,160,330,420,160,310,180,110,2070,2240,1030,770,180,770,1140,660,990,650,400,510,400,720,390,1140,1310,800,810,970,470,1970,1220,470,580,490,590
23
+ 21,310,190,150,380,140,150,160,380,340,520,170,990,300,70,160,370,420,160,320,190,120,2110,2270,1040,770,180,780,1160,670,1010,660,410,520,400,740,400,1150,1320,820,830,980,480,1990,1240,480,590,510,600
24
+ 22,320,200,160,390,140,150,160,380,340,530,170,1010,300,70,160,450,430,170,330,190,120,2160,2300,1050,780,180,790,1170,670,1020,670,410,530,410,750,400,1170,1340,830,850,1000,480,2020,1260,490,600,520,610
25
+ 23,320,200,160,390,140,150,160,390,350,540,170,1020,310,70,160,600,440,170,330,190,120,2190,2340,1060,790,190,800,1180,680,1030,680,420,540,420,760,410,1180,1350,840,870,1010,490,2040,1270,490,610,530,620
26
+ 24,330,200,160,400,140,150,160,400,350,540,170,1030,310,70,170,670,450,170,340,200,130,2230,2360,1070,800,190,810,1190,690,1040,680,430,550,420,770,410,1200,1370,850,890,1020,500,2060,1290,500,620,550,630
27
+ 25,340,210,170,400,150,160,170,400,360,550,180,1050,320,80,170,740,460,170,340,200,130,2270,2390,1080,810,190,820,1210,700,1050,690,440,560,430,780,420,1210,1380,860,910,1040,500,2090,1300,510,630,560,640
28
+ 26,340,210,170,410,150,160,170,410,360,560,180,1060,320,80,170,790,460,180,350,200,130,2300,2420,1090,820,190,830,1220,710,1060,700,440,570,430,780,420,1220,1400,870,930,1050,510,2110,1320,510,640,570,640
29
+ 27,350,210,170,420,150,160,170,410,370,570,180,1070,320,80,170,840,470,180,350,200,130,2340,2450,1100,830,200,840,1230,720,1080,700,450,580,440,790,430,1240,1410,880,960,1070,510,2140,1330,520,650,580,650
30
+ 28,350,220,180,420,150,160,170,420,370,580,180,1090,330,80,180,840,480,180,360,210,140,2370,2470,1110,840,200,850,1240,730,1090,710,460,580,440,800,440,1250,1430,890,990,1080,520,2160,1350,530,660,590,660
31
+ 29,360,220,180,430,160,160,180,430,380,590,190,1100,330,80,180,890,490,190,370,210,140,2400,2500,1120,850,200,860,1250,740,1100,720,470,590,450,810,440,1270,1440,900,1010,1100,520,2180,1370,530,670,600,670
32
+ 30,370,220,180,430,160,170,180,430,380,600,190,1110,340,80,180,920,490,190,370,210,140,2430,2530,1130,850,210,860,1270,750,1110,720,480,600,450,820,450,1280,1460,910,1040,1110,530,2210,1380,540,680,610,670
33
+ 31,370,230,190,440,160,170,180,440,390,610,190,1120,340,80,180,920,500,190,380,220,140,2470,2550,1140,860,210,870,1280,750,1120,730,480,610,460,830,460,1290,1470,920,1070,1120,540,2230,1400,550,690,620,680
34
+ 32,380,230,190,450,160,170,180,440,390,620,190,1140,350,90,180,920,510,200,390,220,150,2510,2570,1150,870,210,880,1290,760,1130,740,490,620,460,840,460,1310,1490,930,1100,1140,540,2250,1410,550,700,630,690
35
+ 33,380,230,190,450,170,170,190,450,400,630,190,1150,350,90,190,940,520,200,390,220,150,2540,2590,1160,880,220,890,1300,770,1140,740,500,630,470,850,470,1320,1500,940,1120,1150,550,2270,1430,560,710,650,700
36
+ 34,390,240,200,460,170,180,190,460,410,640,200,1160,350,90,190,940,530,200,400,220,150,2570,2610,1170,890,220,900,1310,780,1150,750,510,640,470,860,470,1330,1520,960,1150,1160,550,2290,1440,570,720,660,700
37
+ 35,400,240,200,460,170,180,190,460,410,640,200,1170,360,90,190,940,530,210,410,230,150,2590,2630,1180,900,220,910,1320,790,1160,760,520,650,480,870,480,1350,1530,970,1180,1180,560,2310,1460,580,730,670,710
38
+ 36,400,240,200,470,170,180,190,470,420,660,200,1180,360,90,190,1010,540,210,410,230,160,2620,2650,1190,910,230,920,1330,800,1170,760,520,660,480,880,490,1360,1540,980,1210,1190,560,2330,1470,580,740,680,720
39
+ 37,410,250,210,480,180,190,200,480,420,670,200,1200,370,90,200,1010,550,210,420,230,160,2650,2660,1200,920,230,930,1340,810,1180,770,530,670,490,890,490,1370,1560,990,1240,1200,570,2350,1490,590,750,690,730
40
+ 38,410,250,210,480,180,190,200,480,430,680,210,1210,370,100,200,1020,560,210,430,230,160,2680,2680,1210,930,230,930,1350,820,1190,770,540,680,500,900,500,1390,1570,1000,1270,1220,580,2370,1500,600,760,700,730
41
+ 39,420,260,210,490,180,190,200,490,440,690,210,1220,380,100,200,1020,570,220,440,240,160,2710,2700,1220,930,240,940,1360,830,1200,780,550,690,500,910,510,1400,1590,1010,1300,1230,580,2390,1520,600,770,710,740
42
+ 40,430,260,220,490,190,190,210,500,440,700,210,1230,380,100,200,1020,570,220,440,240,170,2740,2720,1240,940,240,950,1370,840,1210,790,560,700,510,920,510,1410,1610,1020,1330,1250,590,2410,1540,610,780,720,750
43
+ 41,430,260,220,500,190,200,210,500,450,710,210,1240,390,100,210,1050,580,220,450,240,170,2770,2740,1250,950,240,960,1380,850,1230,790,570,710,510,930,520,1430,1620,1030,1360,1260,600,2430,1550,620,790,730,760
44
+ 42,440,270,220,510,190,200,210,510,450,720,210,1260,390,100,210,1050,590,230,460,250,170,2800,2760,1260,960,250,970,1390,860,1240,800,580,720,520,940,530,1440,1640,1040,1400,1270,600,2450,1570,630,800,740,770
45
+ 43,450,270,230,510,190,200,220,520,460,730,220,1270,400,110,210,1050,600,230,470,250,170,2820,2770,1270,970,250,980,1410,860,1250,800,590,730,530,940,530,1450,1650,1050,1430,1290,610,2470,1580,630,810,750,770
46
+ 44,450,280,230,520,200,210,220,530,470,740,220,1280,400,110,220,1050,610,230,480,250,180,2840,2790,1280,980,250,980,1420,870,1260,810,600,740,530,950,540,1470,1670,1070,1470,1300,610,2490,1600,640,820,750,780
47
+ 45,460,280,240,530,200,210,220,530,480,750,220,1290,410,110,220,1180,620,240,490,260,180,2870,2800,1290,990,260,990,1430,890,1270,820,610,760,540,970,550,1480,1690,1080,1510,1320,620,2510,1610,650,830,770,790
48
+ 46,470,280,240,530,200,210,230,540,480,760,220,1310,420,110,220,1180,630,240,500,260,180,2900,2820,1300,1000,260,1000,1440,900,1280,820,620,770,550,980,550,1500,1700,1090,1550,1330,630,2530,1630,650,840,780,790
49
+ 47,470,290,250,540,210,220,230,550,490,780,230,1320,420,110,220,1260,640,250,510,260,180,2930,2840,1310,1010,270,1010,1450,910,1290,830,630,780,550,990,560,1510,1720,1100,1580,1350,630,2540,1640,660,850,790,800
50
+ 48,480,290,250,550,210,220,230,560,500,790,230,1330,430,120,230,1410,650,250,520,270,190,2950,2850,1320,1020,270,1020,1460,920,1300,840,640,790,560,1000,570,1530,1740,1120,1620,1360,640,2570,1660,670,860,800,810
51
+ 49,490,300,260,560,210,220,240,570,500,800,230,1340,440,120,230,1430,660,250,530,270,190,2970,2870,1330,1030,270,1030,1470,930,1310,840,650,800,570,1010,580,1540,1750,1130,1650,1370,650,2580,1670,680,880,810,820
52
+ 50,500,300,260,560,220,230,240,570,510,810,230,1360,440,120,230,1540,670,260,550,270,190,3000,2880,1350,1050,280,1040,1480,940,1330,850,660,820,580,1020,590,1560,1770,1140,1690,1390,660,2600,1690,680,890,820,830
53
+ 51,500,310,270,570,220,230,250,580,520,830,240,1370,450,120,240,1560,680,260,560,280,200,3020,2900,1360,1060,280,1050,1500,950,1340,850,670,830,580,1030,600,1570,1790,1160,1730,1410,660,2620,1710,690,900,830,830
54
+ 52,510,310,270,580,220,230,250,590,530,840,240,1380,460,120,240,1610,690,270,570,280,200,3040,2910,1370,1070,290,1050,1510,970,1350,860,680,840,590,1040,600,1590,1810,1180,1780,1420,670,2640,1720,700,910,840,840
55
+ 53,520,320,280,590,230,240,250,600,540,850,240,1400,460,130,240,1700,700,270,580,280,200,3070,2930,1390,1090,290,1060,1520,980,1360,870,700,850,600,1050,610,1600,1830,1190,1820,1440,680,2660,1740,710,920,850,850
56
+ 54,530,320,280,590,230,240,260,610,550,870,250,1410,470,130,250,1730,710,280,600,290,200,3090,2940,1400,1100,300,1070,1540,990,1370,870,710,870,610,1060,620,1610,1840,1210,1870,1460,690,2680,1760,710,930,860,860
57
+ 55,540,330,290,600,240,250,260,620,560,880,250,1430,480,130,250,1800,720,280,620,290,210,3110,2960,1410,1120,300,1080,1550,1000,1380,880,720,880,620,1080,630,1630,1860,1220,1910,1480,700,2700,1780,720,950,870,860
58
+ 56,550,340,300,610,240,250,270,630,560,900,250,1440,490,130,250,1850,730,280,630,300,210,3130,2980,1430,1130,300,1090,1560,1020,1400,890,740,890,630,1090,640,1650,1880,1240,1960,1490,700,2720,1790,730,960,880,870
59
+ 57,560,340,300,620,240,260,270,640,570,910,250,1450,500,140,260,1950,750,290,650,300,210,3150,2990,1440,1150,310,1100,1580,1030,1410,890,750,900,640,1100,650,1660,1900,1260,2020,1510,710,2740,1810,740,970,900,880
60
+ 58,570,350,310,630,250,260,280,660,580,930,260,1470,510,140,260,1950,760,290,670,300,220,3170,3010,1450,1160,310,1110,1590,1050,1420,900,760,920,650,1110,660,1680,1920,1270,2070,1530,720,2760,1830,750,990,910,890
61
+ 59,580,350,320,640,250,260,280,670,590,950,260,1480,510,140,260,2040,770,300,680,310,220,3200,3020,1470,1170,320,1120,1600,1060,1440,910,780,930,660,1130,670,1700,1940,1290,2130,1550,730,2780,1850,760,1000,920,900
62
+ 60,590,360,330,650,260,270,290,680,600,970,270,1500,520,140,270,2130,790,300,700,310,220,3220,3040,1480,1190,330,1130,1620,1080,1450,910,790,950,670,1140,680,1710,1950,1310,2180,1570,740,2800,1870,770,1010,930,910
63
+ 61,600,370,340,660,260,270,290,690,620,980,270,1510,530,150,270,2210,800,310,720,320,230,3240,3050,1500,1210,330,1140,1630,1090,1460,920,810,960,680,1160,690,1730,1970,1330,2230,1580,750,2820,1890,780,1030,940,920
64
+ 62,610,370,340,670,270,280,300,710,630,1000,270,1530,550,150,280,2280,810,320,740,320,230,3260,3060,1510,1220,340,1160,1650,1110,1470,930,830,980,690,1170,700,1750,2000,1350,2290,1600,760,2840,1920,790,1040,950,920
65
+ 63,620,380,350,680,270,290,300,720,640,1020,280,1550,560,150,280,2290,830,320,770,330,230,3280,3080,1530,1240,340,1170,1660,1130,1490,930,840,990,700,1190,720,1770,2020,1370,2350,1620,770,2860,1940,800,1060,970,930
66
+ 64,630,390,360,690,280,290,310,730,650,1040,280,1560,570,160,290,2310,850,330,790,330,240,3300,3090,1540,1260,350,1180,1680,1150,1500,940,860,1010,720,1200,730,1790,2040,1400,2400,1650,780,2880,1960,810,1080,980,950
67
+ 65,640,400,370,700,280,300,320,750,670,1060,280,1580,580,160,290,2380,860,330,810,340,240,3320,3110,1560,1280,360,1190,1690,1170,1520,950,880,1020,730,1220,740,1810,2060,1420,2460,1670,790,2900,1990,820,1100,990,950
68
+ 66,660,410,380,710,290,300,320,770,680,1090,290,1600,600,160,300,2400,880,340,840,340,240,3340,3120,1580,1310,360,1200,1710,1190,1530,960,900,1030,740,1230,750,1830,2090,1450,2510,1690,810,2920,2010,830,1120,1010,960
69
+ 67,670,410,400,730,300,310,330,780,690,1110,290,1620,610,170,300,2420,900,350,870,350,250,3360,3140,1600,1330,370,1210,1730,1210,1550,960,920,1050,760,1250,770,1850,2120,1480,2570,1710,820,2950,2030,840,1130,1020,970
70
+ 68,680,420,410,740,300,320,340,800,710,1130,300,1640,630,170,310,2450,920,360,890,350,250,3380,3150,1620,1350,380,1230,1740,1230,1570,970,940,1070,770,1270,780,1870,2140,1510,2620,1740,830,2970,2050,850,1150,1030,980
71
+ 69,700,430,420,750,310,320,340,820,720,1150,300,1650,640,170,310,2490,940,360,920,360,260,3400,3170,1640,1380,390,1240,1760,1250,1580,980,960,1080,790,1290,790,1890,2170,1540,2670,1760,850,2990,2080,870,1180,1050,990
72
+ 70,710,440,430,770,320,330,350,840,740,1180,310,1670,660,180,320,2500,960,370,950,370,260,3420,3190,1660,1400,400,1250,1780,1270,1600,990,980,1100,800,1300,810,1910,2200,1570,2710,1790,860,3010,2100,880,1200,1060,1000
73
+ 71,730,460,450,780,320,340,360,860,760,1200,310,1690,680,180,320,2570,980,380,980,370,270,3440,3210,1680,1430,400,1270,1800,1290,1620,990,1010,1120,820,1320,830,1940,2230,1600,2760,1810,880,3030,2130,890,1220,1080,1010
74
+ 72,740,470,460,800,330,350,370,890,770,1230,320,1710,700,190,330,2660,1000,390,1010,380,270,3460,3220,1700,1460,410,1280,1820,1320,1640,1000,1030,1140,840,1340,840,1960,2260,1640,2810,1840,890,3060,2160,900,1250,1100,1030
75
+ 73,760,480,480,810,340,350,380,910,790,1260,330,1740,720,190,340,2730,1030,400,1050,390,280,3480,3240,1730,1490,420,1300,1840,1340,1660,1010,1060,1170,860,1360,860,1990,2290,1670,2860,1870,910,3080,2190,920,1270,1110,1040
76
+ 74,780,500,500,830,350,360,390,940,810,1290,330,1760,740,200,340,2850,1050,410,1080,400,280,3500,3260,1750,1520,430,1320,1860,1360,1680,1020,1080,1190,880,1390,880,2010,2320,1710,2900,1900,930,3110,2220,930,1300,1130,1050
77
+ 75,800,510,520,850,360,370,400,970,830,1320,340,1780,770,200,350,2930,1070,420,1110,400,290,3520,3280,1780,1560,440,1330,1880,1390,1710,1030,1110,1220,900,1410,900,2030,2350,1760,2940,1930,950,3130,2250,950,1330,1150,1060
78
+ 76,820,530,530,870,370,380,410,1000,860,1350,350,1810,800,210,360,2980,1100,440,1150,410,290,3540,3290,1800,1600,460,1350,1900,1420,1730,1040,1150,1240,920,1430,920,2060,2390,1800,2980,1940,970,3160,2280,970,1360,1170,1070
79
+ 77,840,550,550,890,380,390,430,1030,880,1380,350,1830,830,210,360,2990,1130,450,1190,420,300,3560,3310,1830,1630,470,1370,1930,1450,1750,1060,1180,1260,950,1460,940,2090,2420,1850,3020,1980,990,3190,2320,980,1400,1190,1090
80
+ 78,860,570,570,910,390,400,440,1070,910,1420,360,1860,860,220,370,3080,1160,470,1230,430,310,3580,3330,1860,1670,480,1390,1950,1480,1780,1070,1220,1290,970,1490,960,2120,2460,1900,3060,2010,1010,3210,2350,1000,1430,1210,1100
81
+ 79,890,590,600,930,400,410,450,1110,940,1460,370,1880,890,220,380,3170,1200,480,1270,440,310,3600,3350,1890,1720,500,1400,1980,1510,1810,1080,1260,1320,1000,1520,990,2150,2500,1950,3100,2050,1030,3240,2390,1030,1470,1230,1120
82
+ 80,920,620,630,960,410,420,470,1150,970,1500,380,1910,930,230,390,3210,1230,500,1320,450,320,3620,3370,1920,1760,510,1430,2010,1540,1830,1090,1300,1350,1030,1550,1010,2180,2540,2020,3140,2100,1060,3260,2420,1050,1510,1250,1130
83
+ 81,950,640,660,990,430,440,480,1200,1000,1540,390,1940,970,240,410,3290,1260,520,1370,460,330,3640,3390,1960,1810,520,1450,2040,1580,1860,1110,1340,1390,1060,1580,1040,2220,2590,2080,3180,2140,1090,3290,2460,1070,1540,1280,1150
84
+ 82,980,670,700,1010,440,450,500,1260,1030,1580,400,1980,1010,250,420,3370,1300,540,1430,480,340,3660,3410,1990,1860,540,1470,2070,1610,1890,1120,1390,1430,1100,1620,1070,2250,2630,2160,3230,2190,1120,3320,2500,1100,1590,1310,1170
85
+ 83,1010,710,740,1050,450,460,520,1320,1070,1630,410,2010,1060,260,430,3420,1340,570,1490,490,350,3680,3430,2030,1920,560,1500,2110,1640,1930,1140,1440,1470,1130,1650,1100,2290,2680,2230,3260,2240,1150,3350,2540,1130,1640,1340,1190
86
+ 84,1050,750,780,1080,470,480,540,1390,1110,1690,420,2050,1110,260,450,3460,1390,590,1550,510,360,3690,3460,2080,1990,580,1530,2150,1680,1960,1150,1490,1520,1170,1690,1140,2330,2730,2320,3310,2290,1190,3380,2590,1170,1690,1370,1210
87
+ 85,1100,800,830,1120,490,500,560,1470,1160,1740,440,2090,1170,270,470,3540,1440,630,1620,520,370,3710,3480,2120,2060,600,1560,2190,1730,2000,1170,1550,1570,1220,1740,1180,2370,2780,2420,3350,2350,1230,3410,2600,1200,1740,1400,1220
88
+ 86,1150,860,890,1170,500,520,590,1560,1210,1810,450,2130,1230,280,490,3620,1490,660,1680,540,390,3730,3510,2170,2140,630,1600,2230,1770,2040,1190,1620,1630,1260,1780,1220,2410,2830,2550,3390,2410,1280,3440,2660,1240,1790,1450,1250
89
+ 87,1200,930,960,1210,520,540,630,1660,1270,1870,460,2180,1300,300,510,3670,1550,700,1710,560,400,3750,3540,2220,2210,650,1630,2280,1820,2080,1210,1690,1680,1320,1830,1260,2460,2890,2700,3430,2490,1330,3470,2700,1280,1850,1490,1280
90
+ 88,1260,1010,1040,1260,550,570,660,1770,1340,1930,480,2240,1380,310,540,3670,1610,740,1740,590,420,3770,3560,2270,2280,690,1670,2320,1880,2130,1240,1760,1750,1380,1890,1320,2520,2950,2880,3470,2570,1380,3510,2750,1330,1920,1540,1310
91
+ 89,1340,1100,1140,1320,570,600,710,1870,1420,2010,500,2300,1460,330,570,3670,1680,780,1760,610,430,3790,3590,2340,2360,720,1720,2380,1930,2190,1260,1840,1820,1450,1950,1370,2580,3020,3080,3520,2640,1440,3540,2810,1380,2000,1590,1350
92
+ 90,1420,1220,1260,1390,610,630,760,1980,1510,2110,520,2370,1570,350,620,3670,1760,840,1800,640,460,3810,3610,2400,2430,760,1770,2440,2000,2250,1290,1920,1910,1530,2010,1440,2630,3090,3350,3560,2710,1510,3580,2870,1420,2090,1650,1390
93
+ 91,1530,1360,1390,1460,650,670,820,2100,1620,2220,550,2440,1700,380,680,3670,1850,900,1880,670,480,3830,3650,2470,2510,800,1830,2510,2070,2310,1320,2000,2000,1620,2090,1510,2700,3160,3750,3600,2800,1590,3610,2930,1470,2200,1710,1430
94
+ 92,1660,1440,1560,1550,690,720,900,2240,1730,2340,580,2530,1860,410,750,3670,1940,970,2000,710,510,3850,3680,2550,2590,850,1900,2590,2150,2380,1360,2100,2100,1730,2180,1600,2770,3240,3850,3650,2900,1670,3650,3010,1530,2310,1790,1490
95
+ 93,1830,1610,1760,1650,750,780,980,2380,1870,2480,610,2630,2060,450,830,3680,2050,1060,2110,760,550,3870,3710,2640,2650,920,1960,2680,2250,2450,1410,2200,2220,1850,2280,1700,2860,3320,3860,3690,2990,1760,3690,3050,1610,2420,1880,1540
96
+ 94,2060,1910,1870,1780,820,860,1090,2500,2010,2640,650,2750,2270,500,890,3680,2170,1170,2220,820,590,3890,3750,2740,2740,1000,2060,2780,2360,2530,1460,2320,2360,1990,2400,1820,2950,3400,3870,3730,3100,1870,3730,3140,1720,2560,1990,1620
97
+ 95,2350,2300,2030,1930,920,960,1260,2640,2200,2810,700,2880,2520,550,960,3750,2320,1300,2350,900,640,3910,3780,2850,2840,1100,2180,2900,2480,2640,1530,2480,2510,2130,2540,1980,3060,3490,3870,3770,3220,2020,3760,3230,1840,2730,2120,1720
98
+ 96,2690,2570,2390,2110,1050,1090,1520,2830,2450,3060,770,3050,2750,580,1010,3800,2480,1470,2540,990,710,3930,3820,2980,2950,1250,2330,3040,2620,2770,1620,2680,2690,2350,2710,2170,3180,3590,3880,3810,3340,2180,3810,3340,2010,2930,2280,1860
99
+ 97,3140,2790,2910,2360,1220,1290,1870,3090,2770,3420,850,3250,3260,680,1060,3860,2680,1710,2770,1130,790,3950,3860,3150,3090,1450,2530,3210,2790,2950,1740,2920,2890,2610,2860,2440,3320,3680,3880,3850,3480,2410,3850,3470,2230,3170,2500,2010
100
+ 98,3560,3270,3230,2670,1500,1610,2260,3370,3160,3840,990,3470,3460,830,1140,3920,2950,2070,2990,1370,950,3970,3910,3350,3280,1680,2800,3440,3030,3160,1930,3210,3150,2930,3100,2820,3500,3780,3880,3910,3610,2730,3900,3620,2590,3400,2820,2310
101
+ 99,3560,3660,3520,3150,1880,2290,2540,3630,3590,3860,1270,3720,3590,1230,1630,3950,3330,2640,3370,1850,1320,3990,3950,3630,3570,2210,3240,3710,3370,3460,2290,3570,3500,3370,3470,3410,3730,3890,3890,3950,3800,3200,3950,3810,3200,3690,3270,2850
cc-multilingual-main/cc_net/build/lib/cc_net/data/test_stats.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "2019-09/de_head_0000.json.gz": {
3
+ "size": 5264993,
4
+ "checksum": "fc12ba3dc982ef06e7e44a916f298e1c16f9a806"
5
+ },
6
+ "2019-09/de_middle_0000.json.gz": {
7
+ "size": 9195535,
8
+ "checksum": "2369ff0296ab1d924c81083f17ce41f22a10ad69"
9
+ },
10
+ "2019-09/de_tail_0000.json.gz": {
11
+ "size": 33029074,
12
+ "checksum": "18865040a7263242d298958f358f7cb5511114d4"
13
+ },
14
+ "2019-09/fr_head_0000.json.gz": {
15
+ "size": 4076580,
16
+ "checksum": "4eef4017bbbe042fc01c45b5fbcf94de49f5138e"
17
+ },
18
+ "2019-09/fr_middle_0000.json.gz": {
19
+ "size": 8075095,
20
+ "checksum": "fd251a5b924c4aa66a63c375ca3a8fae23b3273b"
21
+ },
22
+ "2019-09/fr_tail_0000.json.gz": {
23
+ "size": 27248949,
24
+ "checksum": "4a8aed38abc6b9d04459e8d424bd47426f063638"
25
+ },
26
+ "2019-09/it_head_0000.json.gz": {
27
+ "size": 1760696,
28
+ "checksum": "e5e50e49b4a5147ea82b385babd5c83f74d2a4ed"
29
+ },
30
+ "2019-09/it_middle_0000.json.gz": {
31
+ "size": 4461832,
32
+ "checksum": "7daab7b7acb93d81e50534196ada4e94947b8224"
33
+ },
34
+ "2019-09/it_tail_0000.json.gz": {
35
+ "size": 14754298,
36
+ "checksum": "1adc018519a598ff162261d7e480ea41d3458768"
37
+ }
38
+ }
cc-multilingual-main/cc_net/build/lib/cc_net/mine.py ADDED
@@ -0,0 +1,648 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ """
8
+ Main script to download a CC dump, remove duplicates, split by language and
9
+ filter the documents.
10
+
11
+ The pipeline parameters are described in the `Config` class.
12
+ """
13
+
14
+ import hashlib
15
+ import json
16
+ import time
17
+ import warnings
18
+ from argparse import ArgumentParser
19
+ from collections import defaultdict
20
+ from itertools import repeat
21
+ from pathlib import Path
22
+ from typing import Any, Dict, Iterable, List, NamedTuple, Optional, Sequence, Tuple
23
+
24
+ import func_argparse
25
+
26
+ # Local scripts
27
+ from cc_net import dedup, execution, jsonql, minify, perplexity, process_wet_file
28
+ from cc_net import regroup as regroup_module
29
+ from cc_net import split_by_lang
30
+ from cc_net.execution import Executor
31
+
32
+ # Constant
33
+ FILE_DIR = Path(__file__).parent
34
+ CUTOFF_CSV = FILE_DIR / "data" / "cutoff.csv"
35
+
36
+ DEFAULT_PIPELINE = [
37
+ # "dedup",
38
+ "lid",
39
+ "keep_lang",
40
+ "sp",
41
+ "lm",
42
+ "pp_bucket",
43
+ "drop",
44
+ "split_by_lang",
45
+ ]
46
+
47
+
48
+ class Config(NamedTuple):
49
+ """
50
+ Mine Common Crawl with the given settings.
51
+
52
+ config_name
53
+ dump: CC dump id
54
+ output_dir: working directory
55
+ mined_dir: name of the destination folder, full path will be {ouput_dir}/{mined_dir}/{dump_id}
56
+ execution: chose how to parallelize the execution
57
+ num_shards: number of shards to split the dump
58
+ num_segments_per_shard: allow to download a small portion of CC (eg for tests)
59
+ min_len: remove documents shorter than this (in chars)
60
+ hashes_in_mem: number of shards hashes to use for dedup
61
+ lang_whitelist: only treat those languages
62
+ lang_blacklist: ignore those languages
63
+ lang_threshold: remove docs whose top language score is lower than this
64
+ keep_bucket: keep only those perplexity bucket chose from (head, middle, tail, all)
65
+ lm_dir: folder containing LMs
66
+ lm_languages: only use LMs for the following languages
67
+ cutoff: cutoff file to use for split in head/middle/tail
68
+ mine_num_processes: number of processes to use for mining
69
+ target_size: size of finals files produce during `regroup` stage
70
+ cleanup_after_regroup: delete intermediary files after regroup
71
+ task_parallelism: max number of task to run in parallel
72
+ pipeline: restricts the mining pipeline to the given steps. Order is important !
73
+ experiments: (HACK) enable specific experiments in the code
74
+ """
75
+
76
+ config_name: str = "base"
77
+ dump: str = "2017-51"
78
+ output_dir: Path = Path("data")
79
+ mined_dir: str = "mined"
80
+ execution: str = "auto"
81
+ num_shards: int = 1600
82
+ num_segments_per_shard: int = -1
83
+ metadata: Optional[str] = None
84
+ min_len: int = 300
85
+ hash_in_mem: int = 50
86
+ lang_whitelist: Sequence[str] = ['hi']
87
+ lang_blacklist: Sequence[str] = []
88
+ lang_threshold: float = 0.5
89
+ keep_bucket: Sequence[str] = []
90
+ lm_dir: Path = Path("data/lm_sp")
91
+ cutoff: Path = CUTOFF_CSV
92
+ lm_languages: Optional[Sequence[str]] = None
93
+ mine_num_processes: int = 16
94
+ target_size: str = "4G"
95
+ cleanup_after_regroup: bool = False
96
+ task_parallelism: int = -1
97
+ pipeline: Sequence[str] = DEFAULT_PIPELINE
98
+ experiments: Sequence[str] = []
99
+ cache_dir: Optional[Path] = None
100
+
101
+ def get_executor(
102
+ self, name: str, timeout_hour: int = 1, mem_gb: int = 1, cpus: int = 1
103
+ ) -> Executor:
104
+ name = "_".join((name, self.config_name, *self.experiments))
105
+ return execution.get_executor(
106
+ name,
107
+ self.output_dir / "logs",
108
+ self.execution,
109
+ timeout_hour=timeout_hour,
110
+ mem_gb=mem_gb,
111
+ cpus=cpus,
112
+ task_parallelism=self.task_parallelism,
113
+ )
114
+
115
+ def get_cc_shard(self, shard: int) -> process_wet_file.CCShardReader:
116
+ dump_cache: Optional[Path] = None
117
+ if self.cache_dir:
118
+ self.cache_dir.mkdir(exist_ok=True)
119
+ dump_cache = self.cache_dir / self.dump
120
+ dump_cache.mkdir(exist_ok=True)
121
+
122
+ return process_wet_file.CCShardReader(
123
+ self.dump,
124
+ shard=shard,
125
+ num_shards=self.num_shards,
126
+ num_segments_per_shard=self.num_segments_per_shard,
127
+ min_len=self.min_len,
128
+ cache_dir=dump_cache,
129
+ )
130
+
131
+ @classmethod
132
+ def from_json(cls, json_file: Path) -> "Config":
133
+ raw_lines = json_file.read_text().splitlines()
134
+ raw_lines = [l for l in raw_lines if not l.strip().startswith("//")]
135
+ json_config = json.loads("".join(raw_lines))
136
+ path_keys = ["cache_dir", "lm_dir", "output_dir"]
137
+ for key in path_keys:
138
+ if key in json_config:
139
+ json_config[key] = Path(json_config[key])
140
+ return Config(**json_config)
141
+
142
+ @property
143
+ def will_split(self) -> bool:
144
+ return "split_by_lang" in self.pipeline or "split_by_segment" in self.pipeline
145
+
146
+ def get_lm_languages(self) -> Sequence[str]:
147
+ if self.lm_languages is not None:
148
+ return self.lm_languages
149
+
150
+ if self.lang_whitelist:
151
+ return self.lang_whitelist
152
+
153
+ languages = [m.name.split(".")[0] for m in self.lm_dir.glob("*.arpa.bin")]
154
+ if self.lang_blacklist:
155
+ languages = [l for l in languages if l not in self.lang_blacklist]
156
+ return languages
157
+
158
+ def get_mined_dir(self, regroup: bool = False) -> Path:
159
+ if self.will_split and not regroup:
160
+ return self.output_dir / f"{self.mined_dir}_split" / self.dump
161
+ return self.output_dir / self.mined_dir / self.dump
162
+
163
+
164
+ BASE_CONFIG = Config()
165
+
166
+ BYLANG_CONFIG = Config(
167
+ config_name="by_lang",
168
+ mined_dir="mined_by_lang",
169
+ pipeline=list(BASE_CONFIG.pipeline[:-1]) + ["split_by_lang"],
170
+ )
171
+
172
+ REPRODUCE_CONFIG = Config(
173
+ config_name="reproduce",
174
+ dump="2019-09",
175
+ mined_dir="reproduce",
176
+ pipeline=["fetch_metadata", "keep_lang", "keep_bucket", "split_by_lang"],
177
+ metadata="https://dl.fbaipublicfiles.com/cc_net/1.0.0",
178
+ # Optional filtering:
179
+ # It won't change much the execution speed, but decreases the disk requirement.
180
+ # Restrict languages
181
+ lang_whitelist=["fr"],
182
+ # Restrict perplexity buckets
183
+ # Top languages have been split in perplexity buckets according
184
+ # to a Wikipedia trained LM.
185
+ # The buckets from low perplexity (good) to high (bad) are:
186
+ # ["head", "middle", "tail"]
187
+ # Languages without a LM have only one bucket "all".
188
+ # It won't change much the execution speed, but decreases the disk requirement.
189
+ keep_bucket=["head", "all"],
190
+ mine_num_processes=1,
191
+ )
192
+
193
+ TEST_CONFIG = BASE_CONFIG._replace(
194
+ config_name="test",
195
+ dump="2019-09",
196
+ output_dir=Path("test_data"),
197
+ execution="local",
198
+ num_shards=4,
199
+ num_segments_per_shard=1,
200
+ hash_in_mem=2,
201
+ mine_num_processes=2,
202
+ lang_whitelist=["de", "it", "fr"],
203
+ target_size="32M",
204
+ cleanup_after_regroup=False,
205
+ cache_dir=Path("test_data/wet_cache"),
206
+ )
207
+
208
+ PREDEF_CONFIGS = {
209
+ "base": BASE_CONFIG,
210
+ "by_lang": BYLANG_CONFIG,
211
+ "test": TEST_CONFIG,
212
+ "test_slurm": TEST_CONFIG._replace(execution="slurm,partition=dev"),
213
+ "debug": TEST_CONFIG._replace(config_name="debug", mine_num_processes=0),
214
+ "reproduce": REPRODUCE_CONFIG,
215
+ "augment": BASE_CONFIG._replace(
216
+ config_name="augment", dump="2019-13", lang_blacklist=["en"]
217
+ ),
218
+ }
219
+
220
+
221
+ def tmp(output: Path) -> Path:
222
+ return output.parent / (output.stem + ".tmp" + output.suffix)
223
+
224
+
225
+ def finalize(tmp_output: Path, output: Path) -> None:
226
+ if not tmp_output.exists():
227
+ warnings.warn(f"Targeted tmp output {tmp_output} doesn't exists.")
228
+ return
229
+
230
+ tmp_index = tmp_output.parent / (tmp_output.name + ".index")
231
+ tmp_output.rename(output)
232
+
233
+ if tmp_index.exists():
234
+ tmp_index.rename(output.parent / (output.name + ".index"))
235
+
236
+
237
+ def _transpose(iterable: Sequence[Tuple[Any, ...]], n=-1) -> Tuple[List, ...]:
238
+ if n < 0:
239
+ n = len(iterable[0])
240
+ columns: tuple = tuple([] for _ in range(n))
241
+ for row in iterable:
242
+ assert len(row) == n, f"Found tuple of len({len(row)}, expected {n}: {row}"
243
+ for i in range(n):
244
+ columns[i].append(row[i])
245
+
246
+ return columns
247
+
248
+
249
+ def hashes(conf: Config) -> List[Path]:
250
+ """Computes hashes for each shard."""
251
+
252
+ hashes_dir = conf.output_dir / "hashes" / conf.dump
253
+ outputs = [hashes_dir / f"{shard:04d}.bin" for shard in range(conf.num_shards)]
254
+ missing_outputs = [(shard, o) for shard, o in enumerate(outputs) if not o.exists()]
255
+
256
+ if not missing_outputs:
257
+ return outputs
258
+
259
+ hashes_dir.mkdir(parents=True, exist_ok=True)
260
+ # With FlatHashSet we need ~2Gb of RAM / shard, but we need to account for
261
+ # overhead due to how the dynamic allocation works.
262
+ ex = conf.get_executor(f"hashes_{conf.dump}", mem_gb=4, timeout_hour=6, cpus=2)
263
+ ex(_hashes_shard, repeat(conf), *_transpose(missing_outputs))
264
+
265
+ # Wait a bit so that files appears on the disk.
266
+ time.sleep(20)
267
+ assert all(o.exists() for o in outputs)
268
+ return outputs
269
+
270
+
271
+ def _hashes_shard(conf: Config, shard: int, output: Path):
272
+ tmp_output = tmp(output)
273
+ jsonql.run_pipes(
274
+ dedup.HashesCollector(field="raw_content", output=tmp_output),
275
+ inputs=conf.get_cc_shard(shard),
276
+ )
277
+ finalize(tmp_output, output)
278
+ return f"Hashed {output}"
279
+
280
+
281
+ HASHES_IN_MEM = [0, 1, 2, 5, 10, 20, 50, 100, 200, 400]
282
+
283
+
284
+ def mine(conf: Config) -> List[Path]:
285
+ """Remove dups, run LID and LMs, and split by lang and quality."""
286
+ mined_dir = conf.get_mined_dir()
287
+ if conf.will_split:
288
+ # Give a directories when splitting
289
+ outputs = [mined_dir / f"{shard:04d}" for shard in range(conf.num_shards)]
290
+ else:
291
+ # Files otherwise
292
+ outputs = [
293
+ mined_dir / f"{shard:04d}.json.gz" for shard in range(conf.num_shards)
294
+ ]
295
+
296
+ if "mini_again" in conf.experiments:
297
+ mined_dir = conf.output_dir / "mini_again" / conf.dump
298
+ outputs = [mined_dir / f"{shard:04d}" for shard in range(conf.num_shards)]
299
+
300
+ # TODO: try to reduce this / make it a function of "hash_in_mem" / num_langs
301
+ mem_gb = 60 + 1 * conf.hash_in_mem
302
+ timeout_hour = 5
303
+ if "hashes" in conf.experiments:
304
+ # HACK: used for generating paper figures
305
+ outputs = [
306
+ conf.output_dir / f"hashes_exp/{conf.dump}_0000_dedup{h:03d}.json.gz"
307
+ for h in HASHES_IN_MEM
308
+ ]
309
+ mem_gb = int(max(HASHES_IN_MEM) * 1.2)
310
+ timeout_hour = 8
311
+
312
+ missing_outputs = [(shard, o) for shard, o in enumerate(outputs) if not o.exists()]
313
+
314
+ if "mini_again" in conf.experiments:
315
+ missing_outputs = [
316
+ (shard, o)
317
+ for shard, o in enumerate(outputs)
318
+ if shard in [5, 139] and not o.exists()
319
+ ]
320
+
321
+ if not missing_outputs:
322
+ return outputs
323
+
324
+ mined_dir.mkdir(parents=True, exist_ok=True)
325
+ ex = conf.get_executor(
326
+ f"mine_{conf.dump}",
327
+ mem_gb=mem_gb,
328
+ timeout_hour=timeout_hour,
329
+ cpus=conf.mine_num_processes + 1,
330
+ )
331
+
332
+ # Compute hashes firsts.
333
+ if "dedup" in conf.pipeline:
334
+ hashes_groups = list(jsonql.grouper(hashes(conf), conf.hash_in_mem))
335
+ hashes_files: Iterable[List[Path]] = [
336
+ hashes_groups[shard // conf.hash_in_mem] for shard, o in missing_outputs
337
+ ]
338
+ else:
339
+ hashes_files = repeat([])
340
+
341
+ ex(_mine_shard, repeat(conf), hashes_files, *_transpose(missing_outputs))
342
+
343
+ assert all(o.exists() for o in outputs)
344
+ return outputs
345
+
346
+
347
+ def _get_segment(tmp_output: Path, doc: dict) -> str:
348
+ segment: str = doc["cc_segment"].split("/")[-1]
349
+ return str(tmp_output / segment.replace(".warc.wet.gz", ".json.gz"))
350
+
351
+
352
+ def _mine_shard(conf: Config, hashes: List[Path], shard: int, output: Path) -> str:
353
+ assert conf.pipeline
354
+ tmp_output = tmp(output)
355
+ if "hashes" in conf.experiments:
356
+ # HACK: used for generating paper figures
357
+ hashes_in_mem = shard
358
+ hashes = hashes[: HASHES_IN_MEM[hashes_in_mem]]
359
+ shard = 0
360
+ cc_shard = conf.get_cc_shard(shard)
361
+
362
+ steps: Dict[str, Optional[jsonql.Transformer]] = {}
363
+ lang_id = Path("bin") / "lid.bin"
364
+ steps["lid_before_dedup"] = split_by_lang.Classifier(
365
+ model=lang_id, field="raw_content", out_field="lid_before_dedup", top=5
366
+ )
367
+ steps["dedup"] = dedup.DuplicatesRemover(field="raw_content", hashes_files=hashes)
368
+
369
+ steps["lid"] = split_by_lang.Classifier(
370
+ model=lang_id,
371
+ field="raw_content",
372
+ out_field="language",
373
+ top=1,
374
+ threshold=conf.lang_threshold,
375
+ )
376
+ steps["lid_after_dedup"] = split_by_lang.Classifier(
377
+ model=lang_id, field="raw_content", out_field="lid_after_dedup", top=5
378
+ )
379
+
380
+ if conf.lang_blacklist:
381
+ steps["keep_lang"] = jsonql.where(
382
+ [lambda doc: doc.get("language") not in set(conf.lang_blacklist)]
383
+ )
384
+ elif conf.lang_whitelist:
385
+ steps["keep_lang"] = jsonql.where(
386
+ [lambda doc: doc.get("language") in set(conf.lang_whitelist)]
387
+ )
388
+ else:
389
+ steps["keep_lang"] = None
390
+
391
+ tok_field = "tokenized"
392
+ steps["sp"] = perplexity.MultiSentencePiece(
393
+ {l: conf.lm_dir / f"{l}.sp.model" for l in conf.get_lm_languages()},
394
+ field="raw_content",
395
+ output_field=tok_field,
396
+ normalize=True,
397
+ )
398
+ steps["lm"] = perplexity.DocLM(
399
+ {l: conf.lm_dir / f"{l}.arpa.bin" for l in conf.get_lm_languages()},
400
+ field=tok_field,
401
+ output_field="perplexity",
402
+ normalize=False, # Normalization is done before SentencePiece
403
+ # load_method=kenlm.LoadMethod.PARALLEL_READ,
404
+ )
405
+ steps["pp_bucket"] = perplexity.PerplexityBucket(CUTOFF_CSV)
406
+ steps["drop"] = perplexity.DropKeys(tok_field)
407
+
408
+ steps["keep_bucket"] = None
409
+ if conf.keep_bucket:
410
+ steps["keep_bucket"] = jsonql.where(
411
+ [lambda doc: doc.get("bucket", "all") in conf.keep_bucket]
412
+ )
413
+
414
+ if "fetch_metadata" in conf.pipeline:
415
+ # TODO: better default
416
+ assert conf.metadata is not None
417
+ steps["fetch_metadata"] = minify.MetadataFetcher(
418
+ f"{conf.metadata}/{conf.dump}/"
419
+ )
420
+
421
+ steps["minify"] = minify.Minifier()
422
+
423
+ pattern = str(tmp_output / "{language}_{bucket}.json.gz")
424
+ steps["split_by_lang"] = jsonql.split(pattern=str(pattern), mkdir=True)
425
+
426
+ steps["split_by_segment"] = jsonql.split(
427
+ split_fn=lambda doc: _get_segment(tmp_output, doc), mkdir=True
428
+ )
429
+
430
+ pipeline = filter(None, (steps[s] for s in conf.pipeline))
431
+
432
+ jsonql.run_pipes(
433
+ *pipeline,
434
+ inputs=cc_shard,
435
+ processes=conf.mine_num_processes,
436
+ chunksize=100,
437
+ # The splitter takes care of writing to files.
438
+ output=tmp_output if not conf.will_split else None,
439
+ )
440
+ finalize(tmp_output, output)
441
+ return f"Mined {output}"
442
+
443
+
444
+ def regroup(conf: Config, all_dirs: List[Path]) -> Path:
445
+ """Reshards each language/quality after 'mine'."""
446
+ regroup_dir = conf.get_mined_dir(regroup=True)
447
+ assert all_dirs
448
+ all_files = [f for d in all_dirs for f in d.glob("*.json.gz")]
449
+ if not all_files:
450
+ print(f"No .json.gz file found in {all_dirs[0]}")
451
+
452
+ splits: Dict[str, List[Path]] = defaultdict(list)
453
+ for f in all_files:
454
+ split = f.name.split(".")[0]
455
+ splits[split].append(f)
456
+
457
+ print(f"Identified {len(all_files)} files to regroup from {len(splits)} splits.")
458
+ inputs: List[List[Path]] = []
459
+ outputs: List[Path] = []
460
+ target_size = jsonql.parse_size(conf.target_size)
461
+ for split, files in splits.items():
462
+ cuts = list(regroup_module.determine_groups(files, target_size=target_size))
463
+ if not cuts:
464
+ continue
465
+
466
+ pattern = f"{split}_????.json.gz"
467
+ existing_outputs = sorted(regroup_dir.glob(pattern))
468
+
469
+ if not conf.cleanup_after_regroup:
470
+ # We still have all the inputs so it is safe to overwrite existing outputs.
471
+ assert len(existing_outputs) <= len(cuts)
472
+ existing_outputs = []
473
+
474
+ if len(existing_outputs) > 0 and len(cuts) == 1:
475
+ # append to existing file if size allows it.
476
+ new_size = (
477
+ sum(f.stat().st_size for f in cuts[0])
478
+ + existing_outputs[-1].stat().st_size
479
+ )
480
+ if new_size < target_size:
481
+ print(f"Will append {cuts[0]} to {existing_outputs[-1]}")
482
+ cuts[0].insert(0, existing_outputs.pop(-1))
483
+
484
+ n_existing = len(existing_outputs)
485
+ for i, cut in enumerate(cuts):
486
+ # avoid overwriting existing files.
487
+ j = i + n_existing
488
+ output = regroup_dir / f"{split}_{j:04}.json.gz"
489
+ inputs.append(cut)
490
+ outputs.append(output)
491
+ print(
492
+ str(regroup_dir / pattern),
493
+ "->",
494
+ len(cuts),
495
+ f"shards ({n_existing} already there).",
496
+ )
497
+
498
+ ex = conf.get_executor(f"regroup_{conf.dump}", mem_gb=1, timeout_hour=12, cpus=2)
499
+ ex(_regroup, repeat(conf), inputs, outputs)
500
+
501
+ return regroup_dir
502
+
503
+
504
+ def _regroup(conf: Config, inputs: List[Path], output: Path) -> str:
505
+ output.parent.mkdir(parents=True, exist_ok=True)
506
+ regroup_module.fast_reshard(
507
+ inputs, output, tmp=tmp(output), rm_original=conf.cleanup_after_regroup
508
+ )
509
+ return f"Regrouped {output}"
510
+
511
+
512
+ def move_segments(conf: Config, all_dirs: Sequence[Path]) -> Path:
513
+ """Reshards each language/quality after 'mine'."""
514
+ # check that mining is over.
515
+ regroup_dir = conf.get_mined_dir(regroup=True)
516
+ assert all_dirs, "Received no dirs to move"
517
+ assert all(
518
+ d.is_dir() for d in all_dirs
519
+ ), f"move_segments was expecting dirs received files: {all_dirs[:10]}..."
520
+
521
+ regroup_dir.parent.mkdir(exist_ok=True)
522
+ regroup_dir.mkdir(exist_ok=True)
523
+ ex = conf.get_executor(f"moveseg_{conf.dump}", mem_gb=1, timeout_hour=1, cpus=2)
524
+
525
+ def _move_segments(subdir: Path, regroup_dir: Path) -> str:
526
+ n = 0
527
+ for f in subdir.iterdir():
528
+ if not f.is_file() or f.is_symlink():
529
+ continue
530
+ n += f.name.endswith(".json.gz")
531
+ new_name = regroup_dir / f.name
532
+ target = new_name.resolve()
533
+ assert f.resolve() != target
534
+ # this make the job idempotent.
535
+ f.rename(new_name)
536
+ f.symlink_to(target)
537
+
538
+ if n == 0:
539
+ return ""
540
+
541
+ return f"Moved {n} .json.gz files from {subdir} to {regroup_dir}"
542
+
543
+ ex(_move_segments, all_dirs, repeat(regroup_dir))
544
+ print(f"Results are in {regroup_dir}")
545
+ return regroup_dir
546
+
547
+
548
+ def _validate_test(conf: Config, output_dir: Path, generate: bool = False):
549
+ stats: Dict[str, dict] = {}
550
+ for file in sorted(output_dir.glob("*.json.gz")):
551
+ fname = "/".join((file.parent.name, file.name))
552
+ # The order of documents is not guaranteed inside a shard,
553
+ lines = sorted(jsonql.open_read(file))
554
+ content = "\n".join(lines)
555
+ size = len(content)
556
+ checksum = hashlib.sha1(bytes(content, encoding="utf-8")).hexdigest()
557
+ # first_document = json.loads(lines[0])
558
+ stats[fname] = {"size": size, "checksum": checksum}
559
+
560
+ def dump(x):
561
+ return json.dumps(x, indent=2, ensure_ascii=False)
562
+
563
+ print("*** Stats ***")
564
+ stats_raw = dump(stats)
565
+ stats_file = FILE_DIR / "data" / "test_stats.json"
566
+ if generate:
567
+ print("Saving stats to", stats_file)
568
+ stats_file.write_text(stats_raw)
569
+ return
570
+
571
+ expected_stats: Dict[str, dict] = {}
572
+ if stats_file.exists():
573
+ expected_stats = json.loads(stats_file.read_text())
574
+
575
+ if expected_stats == stats:
576
+ print("Everything looks good !")
577
+ return
578
+
579
+ stats_file.with_suffix(".actual.json").write_text(stats_raw)
580
+ print("*** Expected Stats ***")
581
+ print(dump(expected_stats))
582
+
583
+ print("*** Diff ***")
584
+ for fname in sorted(expected_stats.keys()):
585
+ print(fname)
586
+ assert fname in expected_stats, "missing file " + fname
587
+ if expected_stats[fname]["size"] != stats[fname]["size"]:
588
+ print(
589
+ " - Expected size",
590
+ expected_stats[fname]["size"],
591
+ ", size",
592
+ stats[fname]["size"],
593
+ )
594
+ if expected_stats[fname]["checksum"] != stats[fname]["checksum"]:
595
+ print(
596
+ " - Expected checksum",
597
+ expected_stats[fname]["checksum"],
598
+ ", checksum",
599
+ stats[fname]["checksum"],
600
+ )
601
+
602
+
603
+ def get_main_parser() -> ArgumentParser:
604
+ # Generates the 'main' parser by patching a 'Config' parser
605
+ p = func_argparse.func_argparser(Config)
606
+
607
+ # Override defaults value to None, so we know what was set by the user.
608
+ # Note that it will keep the original default values in the help message.
609
+ p.set_defaults(**{f: None for f in Config._fields})
610
+ p.add_argument("--config", type=str, default="base")
611
+ p.set_defaults(__command=main)
612
+ return p
613
+
614
+
615
+ def main(config: str = "base", **config_as_dict: Any) -> None:
616
+ # Use the given 'config' as default value.
617
+ config_base = config
618
+ if config_base in PREDEF_CONFIGS:
619
+ conf = PREDEF_CONFIGS[config_base]
620
+ elif Path(config_base).exists():
621
+ conf = Config.from_json(Path(config_base))
622
+ else:
623
+ raise ValueError(
624
+ f"Invalid value {config_base} for --config. "
625
+ f"Choose from ({', '.join(PREDEF_CONFIGS)}) or give an existing .json file."
626
+ )
627
+ conf = conf._replace(**{k: v for (k, v) in config_as_dict.items() if v is not None})
628
+
629
+ print(f"Will run cc_net.mine.main with the following config:", conf)
630
+
631
+ all_files = mine(conf)
632
+ if conf.will_split:
633
+ assert all_files
634
+ assert all(d.is_dir() for d in all_files)
635
+ all_dirs = all_files
636
+ if "split_by_lang" in conf.pipeline:
637
+ # Only try regrouping if we split the shards.
638
+ regroup(conf, all_dirs)
639
+ elif "split_by_segment" in conf.pipeline:
640
+ # If we split by segment then regrouping is trivial, since segments appear in only one shard.
641
+ move_segments(conf, all_dirs)
642
+
643
+ if conf.config_name == "test":
644
+ _validate_test(conf, conf.get_mined_dir(regroup=True))
645
+
646
+
647
+ if __name__ == "__main__":
648
+ func_argparse.parse_and_call(get_main_parser())
cc-multilingual-main/cc_net/build/lib/cc_net/perplexity.py ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import argparse
8
+ import time
9
+ from pathlib import Path
10
+ from typing import Dict, List, Optional, Sequence, Tuple, Union
11
+
12
+ import kenlm # type: ignore
13
+ import numpy as np # type: ignore
14
+ import pandas as pd # type: ignore
15
+ import sentencepiece # type: ignore
16
+
17
+ from cc_net import jsonql, text_normalizer
18
+
19
+ LMDescriptor = Union[Dict[str, Path], Union[Path, str]]
20
+
21
+
22
+ def get_args():
23
+ parser = argparse.ArgumentParser(
24
+ description="Compute the score of each sentences of a document",
25
+ parents=[jsonql.io_parser()],
26
+ )
27
+ parser.add_argument("--models", type=str)
28
+
29
+ parser.add_argument("--sentences", action="store_true", default=False)
30
+ parser.add_argument(
31
+ "--languages", type=str, help="Ignore doc with another language"
32
+ )
33
+ parser.add_argument("--field", type=str, default=None)
34
+ parser.add_argument("--newline", type=str, default="\n")
35
+ return vars(parser.parse_args())
36
+
37
+
38
+ def pp(log_score, length):
39
+ return 10.0 ** (-log_score / length)
40
+
41
+
42
+ class SentencePiece(jsonql.Transformer):
43
+ # Sentence Pieces model have to be read back from disk.
44
+ warning_when_pickling = True
45
+
46
+ def __init__(
47
+ self,
48
+ model: Path,
49
+ field: str,
50
+ output_field: str = "tokenized",
51
+ normalize: bool = False,
52
+ ):
53
+ super().__init__()
54
+ self.model = model
55
+ self.field = field
56
+ self.output_field = output_field
57
+ self.normalize = normalize
58
+ self.sp: sentencepiece.SentencePieceProcessor = None
59
+
60
+ def _prepare(self):
61
+ if self.sp is not None:
62
+ return
63
+ self.sp = sentencepiece.SentencePieceProcessor()
64
+ self.sp.load(str(self.model))
65
+ return self
66
+
67
+ def do(self, document: dict) -> dict:
68
+ text = document[self.field]
69
+ if self.normalize:
70
+ text = text_normalizer.normalize(text)
71
+ tokenized = self.sp.encode_as_pieces(text)
72
+ document[self.output_field] = " ".join(tokenized)
73
+ return document
74
+
75
+
76
+ class MultiSentencePiece(jsonql.Transformer):
77
+ warning_when_pickling = True
78
+
79
+ def __init__(
80
+ self,
81
+ models: Union[Path, Dict[str, Path]],
82
+ field: str,
83
+ output_field: str = "tokenized",
84
+ normalize: bool = False,
85
+ ):
86
+ super().__init__()
87
+ self.field = field
88
+ self.output_field = output_field
89
+ self.normalize = normalize
90
+ self._prefetch: Sequence[str] = []
91
+
92
+ if isinstance(models, Path):
93
+ self.models = {
94
+ m.name.split(".")[0]: m for m in models.parent.glob(models.name)
95
+ }
96
+ else:
97
+ self.models = models
98
+ self._prefetch = list(models.keys())
99
+ self.sp: Dict[str, sentencepiece.SentencePieceProcessor] = {}
100
+
101
+ def _prepare(self) -> None:
102
+ for lang in self._prefetch:
103
+ assert (
104
+ self.get_sp(lang) is not None
105
+ ), f"No model found for {lang} at {self.models.get(lang)}."
106
+
107
+ def get_sp(self, lang) -> Optional[sentencepiece.SentencePieceProcessor]:
108
+ sp = self.sp.get(lang)
109
+ if sp is not None:
110
+ return sp
111
+ if lang not in self.models:
112
+ return None
113
+
114
+ start_load = time.time()
115
+ self.log(f"Loading {self.models[lang]}...")
116
+ sp = sentencepiece.SentencePieceProcessor()
117
+ sp.load(str(self.models[lang]))
118
+ self.sp[lang] = sp
119
+ load_time = time.time() - start_load
120
+ self.log(f"Loaded {self.models[lang]} (took {load_time / 60:.1f}min)")
121
+ return sp
122
+
123
+ def do(self, document: dict) -> Optional[dict]:
124
+ text = document[self.field]
125
+ if self.normalize:
126
+ text = text_normalizer.normalize(text)
127
+ sp = self.get_sp(document.get("language"))
128
+ if sp is None:
129
+ return document
130
+ tokenized = sp.encode_as_pieces(text)
131
+ document[self.output_field] = " ".join(tokenized)
132
+ return document
133
+
134
+
135
+ class DocLM(jsonql.Transformer):
136
+ def __init__(
137
+ self,
138
+ models: Union[Path, Dict[str, Path]],
139
+ field: str,
140
+ output_field: str = "perplexity",
141
+ newline: str = "\n",
142
+ normalize: bool = True,
143
+ load_method: int = 2,
144
+ ):
145
+ super().__init__()
146
+ self.field = field
147
+ self.output_field = output_field
148
+ self.newline = newline
149
+ self.normalize = normalize
150
+ self._prefetch: Sequence[str] = []
151
+ self.lm_config = kenlm.Config()
152
+ # This is the default settings
153
+ # POPULATE will mmap the models and populate the pages.
154
+ # Maybe that's not the best way when the models are on a network disk.
155
+ # TODO: try copying models file, try READ or PARALLEL_READ
156
+ self.lm_config.load_method = load_method
157
+
158
+ if isinstance(models, Path):
159
+ self.models = {
160
+ m.name.split(".")[0]: m for m in models.parent.glob(models.name)
161
+ }
162
+ else:
163
+ self.models = models
164
+ self._prefetch = list(models.keys())
165
+ self.lm: Dict[str, kenlm.Model] = {}
166
+ self.n_lines = 0
167
+
168
+ def _prepare(self) -> None:
169
+ for lang in self._prefetch:
170
+ assert (
171
+ self.get_lm(lang) is not None
172
+ ), f"No model found for {lang} at {self.models.get(lang)}."
173
+
174
+ def get_lines(self, document: dict) -> List[str]:
175
+ lang = document.get("language")
176
+ if not lang:
177
+ return []
178
+ if lang not in self.models:
179
+ return []
180
+
181
+ content = document.get(self.field)
182
+ if not content:
183
+ return []
184
+
185
+ lines = content.split(self.newline)
186
+ self.n_lines += len(lines)
187
+ return lines
188
+
189
+ def get_lm(self, lang: Optional[str]) -> Optional[kenlm.Model]:
190
+ if lang is None:
191
+ return None
192
+ lm = self.lm.get(lang)
193
+ if lm is not None:
194
+ return lm
195
+ model = self.models.get(lang)
196
+ if model is None:
197
+ return None
198
+ start_load = time.time()
199
+ self.log(f"Loading {self.models[lang]}...")
200
+ lm = kenlm.Model(str(model), self.lm_config)
201
+ self.lm[lang] = lm
202
+ load_time = time.time() - start_load
203
+ self.log(f"Loaded {self.models[lang]} (took {load_time / 60:.1f}min)")
204
+
205
+ return lm
206
+
207
+ def do(self, document: dict) -> dict:
208
+ lines = self.get_lines(document)
209
+ model = self.get_lm(document.get("language"))
210
+ if not lines or not model:
211
+ return document
212
+
213
+ doc_log_score, doc_length = 0, 0
214
+ for line in lines:
215
+ if self.normalize:
216
+ line = text_normalizer.normalize(line)
217
+ log_score = model.score(line)
218
+ length = len(line.split()) + 1
219
+ doc_log_score += log_score
220
+ doc_length += length
221
+
222
+ document[self.output_field] = round(pp(doc_log_score, doc_length), 1)
223
+ return document
224
+
225
+ def summary(self):
226
+ delay = time.time() - self.start_time
227
+ h = delay / 3600
228
+ s = self.n_lines / delay
229
+
230
+ summ = super().summary()
231
+ summ.append(f"Processed {self.n_lines:_} lines in {h:.2}h ({s:.1} lines/s).")
232
+ return summ
233
+
234
+
235
+ class SentencesLM(DocLM):
236
+ """Returns the score of each individual paragraph."""
237
+
238
+ def do(self, document: dict) -> Optional[str]: # type: ignore
239
+ lines = self.get_lines(document)
240
+ model = self.get_lm(document.get("language"))
241
+ if not lines or not model:
242
+ return None
243
+
244
+ sentences = []
245
+ for line in lines:
246
+ if self.normalize:
247
+ line = text_normalizer.normalize(line)
248
+ log_score = model.score(line)
249
+ length = len(line.split()) + 1
250
+
251
+ sentences.append(f"{pp(log_score, length)}\t{line}")
252
+
253
+ return "\n".join(sentences)
254
+
255
+
256
+ class PerplexityBucket(jsonql.Transformer):
257
+ def __init__(
258
+ self, cutoff_csv: Path, percentile_head: int = 30, percentile_tail: int = 60
259
+ ):
260
+ super().__init__()
261
+ self.cutoff_csv = cutoff_csv
262
+ self.percentile_head = percentile_head
263
+ self.percentile_tail = percentile_tail
264
+ self.cutoffs: Dict[str, Tuple[float, float]] = {}
265
+
266
+ def _prepare(self) -> None:
267
+ cutoffs = pd.read_csv(self.cutoff_csv, index_col=0)
268
+ self.cutoffs = {
269
+ l: (cutoffs[l][self.percentile_head], cutoffs[l][self.percentile_tail])
270
+ for l in cutoffs.columns
271
+ }
272
+
273
+ def get_bucket(self, doc: dict) -> str:
274
+ perplexity = doc.get("perplexity", -1)
275
+ lang = doc.get("language")
276
+ if lang not in self.cutoffs or perplexity < 0:
277
+ return "all"
278
+
279
+ pp_head, pp_tail = self.cutoffs[lang]
280
+ if perplexity < pp_head:
281
+ return "head"
282
+ if perplexity < pp_tail:
283
+ return "middle"
284
+ return "tail"
285
+
286
+ def do(self, doc: dict) -> dict:
287
+ doc["bucket"] = self.get_bucket(doc)
288
+ return doc
289
+
290
+
291
+ class DropKeys(jsonql.Transformer):
292
+ def __init__(self, *keys):
293
+ super().__init__()
294
+ self.keys = keys
295
+
296
+ def do(self, document: dict) -> Optional[dict]:
297
+ if not document:
298
+ return None
299
+
300
+ for key in self.keys:
301
+ document.pop(key, None)
302
+ return document
303
+
304
+
305
+ class RemoveSmall(jsonql.Transformer):
306
+ def __init__(self, field, min_len):
307
+ super().__init__()
308
+ self.field = field
309
+ self.min_len = min_len
310
+ self.removed = 0
311
+
312
+ def do(self, document: dict) -> Optional[dict]:
313
+ if not document:
314
+ return None
315
+
316
+ content = document.get(self.field)
317
+ if not content or len(content) < self.min_len:
318
+ self.removed += 1
319
+ return None
320
+ return document
321
+
322
+ def summary(self):
323
+ r, n = self.removed, self.processed
324
+ ratio = r / n if n else 0
325
+ return [f"Removed {r} small documents out of {n} ({ratio:.1%})"]
326
+
327
+
328
+ def perplexity_to_bin(file: Path, output: Path, models, tok_field: str):
329
+ pp_field = "perplexity"
330
+ lm = DocLM(models, tok_field, output_field=pp_field)
331
+ stats: List[float] = []
332
+ max_stats = 1_000_000
333
+ batch_size = 100_000
334
+ i = 0
335
+ batch = []
336
+ with open(output, "wb") as o:
337
+ for doc in jsonql.read_jsons(file):
338
+ i += 1
339
+ pp = lm(doc)[pp_field]
340
+ if len(stats) < max_stats:
341
+ stats.append(pp)
342
+ batch.append(pp)
343
+ if len(batch) >= batch_size:
344
+ np.array(batch, dtype=np.float32).tofile(o)
345
+ batch = []
346
+ if len(batch) > 0:
347
+ np.array(batch, dtype=np.float32).tofile(o)
348
+
349
+
350
+ if __name__ == "__main__":
351
+ args = get_args()
352
+ output = Path(args["output"])
353
+ if output.suffix == ".bin":
354
+ perplexity_to_bin(args["file"], output, args["models"], args["field"])
355
+ else:
356
+ jsonql.run_pipe(DocLM, args)
cc-multilingual-main/cc_net/build/lib/cc_net/process_wet_file.py ADDED
@@ -0,0 +1,292 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import contextlib
8
+ import functools
9
+ import logging
10
+ import re
11
+ import tempfile
12
+ import time
13
+ import urllib.request
14
+ from pathlib import Path
15
+ from typing import ContextManager, Iterable, Iterator, List, Optional, Sequence
16
+ from urllib.parse import urlparse
17
+
18
+ import func_argparse
19
+ from bs4 import BeautifulSoup # type: ignore
20
+
21
+ from cc_net import jsonql
22
+
23
+ WET_URL_ROOT = "https://data.commoncrawl.org"
24
+
25
+
26
+ logger = logging.getLogger(__name__)
27
+
28
+
29
+ def cc_wet_paths_url(dump_id: str) -> str:
30
+ return "/".join([WET_URL_ROOT, "crawl-data", "CC-MAIN-" + dump_id, "wet.paths.gz"])
31
+
32
+
33
+ @functools.lru_cache()
34
+ def cc_segments(dump_id: str, cache_dir: Path = None) -> List[str]:
35
+ wet_paths = cc_wet_paths_url(dump_id)
36
+ cache_dir = cache_dir or jsonql._tmp_dir()
37
+ wet_paths_cache = cache_dir / f"wet_{dump_id}.paths.gz"
38
+ f = jsonql.open_remote_file(wet_paths, cache=wet_paths_cache)
39
+ return [segment.strip() for segment in f]
40
+
41
+
42
+ def list_dumps() -> List[str]:
43
+ home_page = BeautifulSoup(
44
+ urllib.request.urlopen("http://index.commoncrawl.org/"), features="html.parser"
45
+ )
46
+ dumps = [a.get("href").strip("/") for a in home_page.findAll("a")]
47
+ dumps = [a[8:] for a in dumps if re.match(r"^CC-MAIN-\d\d\d\d-\d\d$", a)]
48
+
49
+ return sorted(dumps)
50
+
51
+
52
+ def ls():
53
+ for dump in list_dumps():
54
+ print(dump, "->", cc_wet_paths_url(dump))
55
+
56
+
57
+ def parse_doc(headers: List[str], doc: List[str]) -> Optional[dict]:
58
+ """Headers format is:
59
+ WARC/1.0
60
+ WARC-Type: conversion
61
+ WARC-Target-URI: [url]
62
+ WARC-Date: [crawldate: 2019-02-15T19:15:59Z]
63
+ WARC-Record-ID: <urn:uuid:8865156e-d5f1-4734-9c68-4b46eaf2bb7e>
64
+ WARC-Refers-To: <urn:uuid:340152e2-65cf-4143-b522-8ce4e2d069d7>
65
+ WARC-Block-Digest: sha1:S3DTWCONT2L6ORTGCY2KXEZ37LNBB7V2
66
+ Content-Type: text/plain
67
+ Content-Length: 7743
68
+ """
69
+ if not headers or not doc:
70
+ return None
71
+
72
+ try:
73
+ warc_type = headers[1].split()[1]
74
+ if warc_type != "conversion":
75
+ return None
76
+ url = headers[2].split()[1]
77
+ date = headers[3].split()[1]
78
+ digest = headers[6].split()[1]
79
+ length = 0
80
+ for h in headers:
81
+ if(h != "" and h.split()[0] == "Content-Length:"):
82
+ length = int(h.split()[1])
83
+ break
84
+
85
+ except Exception as e:
86
+ logger.warning("Can't parse header:", e, headers, doc)
87
+ return None
88
+
89
+ # Docs are separated by two empty lines.
90
+ last = None
91
+ if not doc[-1] and not doc[-2]:
92
+ last = -2
93
+ title, doc = doc[0], doc[1:last]
94
+
95
+ return {
96
+ "url": url,
97
+ "date_download": date,
98
+ "digest": digest,
99
+ "length": length,
100
+ "nlines": len(doc),
101
+ "source_domain": urlparse(url).netloc,
102
+ "title": title,
103
+ "raw_content": "\n".join(doc),
104
+ }
105
+
106
+
107
+ def group_by_docs(warc_lines: Iterable[str]) -> Iterable[dict]:
108
+ doc: List[str] = []
109
+ headers, read_headers = [], True
110
+ for warc in warc_lines:
111
+ warc = warc.strip()
112
+ if read_headers:
113
+ headers.append(warc)
114
+ read_headers = warc != ""
115
+ continue
116
+
117
+ if warc == "WARC/1.0":
118
+ # We reached the beginning of the new doc.
119
+ parsed = parse_doc(headers, doc)
120
+ if parsed is not None:
121
+ yield parsed
122
+ headers, doc, read_headers = [warc], [], True
123
+ continue
124
+
125
+ doc.append(warc)
126
+
127
+ # Return the last document
128
+ if doc:
129
+ parsed = parse_doc(headers, doc)
130
+ if parsed is not None:
131
+ yield parsed
132
+
133
+
134
+ def parse_warc_file(lines: Iterable[str], min_len: int = 1) -> Iterator[dict]:
135
+ n_doc = 0
136
+ n_ok = 0
137
+ for doc in group_by_docs(lines):
138
+ n_doc += 1
139
+ if not doc or len(doc["raw_content"]) < min_len:
140
+ continue
141
+ n_ok += 1
142
+ yield doc
143
+ if n_doc > 0:
144
+ logger.info(f"Kept {n_ok:_d} documents over {n_doc:_d} ({n_ok / n_doc:.1%}).")
145
+ else:
146
+ logger.info(f"Found no documents")
147
+
148
+
149
+ def dl(
150
+ dump: str,
151
+ shard: int,
152
+ num_shards: int,
153
+ output: Path = None,
154
+ num_segments_per_shard: int = 0,
155
+ ):
156
+ """Download a shard of the common crawl, and export it to json.
157
+
158
+ Arguments:
159
+ output: filename of the output file
160
+ dump: CC dump id
161
+ shard: id of the shard
162
+ num_shards: total number of shards
163
+ num_segments_per_shard: manual control of the number of segment per shard.
164
+ """
165
+ reader = CCShardReader(dump, shard, num_shards, num_segments_per_shard)
166
+ jsonql.run_pipes(inputs=reader, output=output)
167
+ logger.info(f"Done. {output} is ready.")
168
+
169
+
170
+ class CCSegmentsReader(Iterable[dict]):
171
+ def __init__(
172
+ self, segments: Sequence[str], min_len: int = 0, cache_dir: Path = None
173
+ ):
174
+ self._segments = segments
175
+ self.min_len = min_len
176
+ if cache_dir is not None:
177
+ cache_dir = Path(cache_dir)
178
+ cache_dir.mkdir(exist_ok=True)
179
+ self.cache_dir = cache_dir
180
+ self.retrieved_segments = 0
181
+
182
+ def segment_url(self, segment: str):
183
+ return "/".join((WET_URL_ROOT, segment))
184
+
185
+ @property
186
+ def segments(self) -> Sequence[str]:
187
+ return self._segments
188
+
189
+ def open_segment(self, segment: str) -> Iterable[str]:
190
+ url = self.segment_url(segment)
191
+ file: Optional[Path] = None
192
+ if self.cache_dir:
193
+ file = self.cache_dir / segment.split("/")[-1]
194
+ if not file or not file.exists():
195
+ self.retrieved_segments += 1
196
+
197
+ return jsonql.open_remote_file(url, cache=file)
198
+
199
+ def __iter__(self) -> Iterator[dict]:
200
+ n = len(self.segments)
201
+ for i, segment in enumerate(self.segments):
202
+ start = time.time()
203
+ # TODO: start downloading the next segment in the background
204
+ for doc in parse_warc_file(self.open_segment(segment), self.min_len):
205
+ doc["cc_segment"] = segment
206
+ yield doc
207
+
208
+ if i + 1 >= n:
209
+ continue
210
+ end = time.time()
211
+ delay = (end - start) / 3600 * (n - 1 - i)
212
+ logger.info(
213
+ f"Parsed {i + 1} / {n} files. Estimated remaining time: {delay:.1f}h"
214
+ )
215
+
216
+
217
+ class CCShardReader(CCSegmentsReader):
218
+ def __init__(
219
+ self,
220
+ dump: str,
221
+ shard: int,
222
+ num_shards: int = -1,
223
+ num_segments_per_shard: int = 40,
224
+ min_len: int = 300,
225
+ cache_dir: Path = None,
226
+ ):
227
+ """Downloads a shard of Common Crawl, and yields dict.
228
+
229
+ Arguments:
230
+ dump: CC dump id
231
+ shard: id of the shard
232
+ num_shards: total number of shards
233
+ num_segments_per_shard: if set will limit the number of files by shard.
234
+ Useful for testing.
235
+ """
236
+ super().__init__([], min_len=min_len, cache_dir=cache_dir)
237
+ self.dump = dump
238
+ self.shard = shard
239
+ assert num_shards > 0 or num_segments_per_shard > 0
240
+ self.num_shards = num_shards
241
+ self.num_segments_per_shard = num_segments_per_shard
242
+
243
+ @property
244
+ def segments(self) -> Sequence[str]:
245
+ # Delaying the initialization allows to delay the looking up of the WET files
246
+ if self._segments:
247
+ return self._segments
248
+ segments = cc_segments(self.dump, self.cache_dir)
249
+ n = len(segments)
250
+ if self.num_shards < 0:
251
+ self.num_shards = n // self.num_segments_per_shard
252
+ i_min = (self.shard * n) // self.num_shards
253
+ i_max = ((self.shard + 1) * n) // self.num_shards
254
+ if self.num_segments_per_shard > 0:
255
+ i_max = min(i_max, i_min + self.num_segments_per_shard)
256
+ self._segments = segments[i_min:i_max]
257
+ return self._segments
258
+
259
+
260
+ def _tmp(prefix: str = None, suffix: str = None, dir: Path = None) -> Path:
261
+ _, tmp_path = tempfile.mkstemp(prefix=prefix, suffix=suffix, dir=dir)
262
+ return Path(tmp_path)
263
+
264
+
265
+ @contextlib.contextmanager
266
+ def timer(name: str = "-"):
267
+ start = time.time()
268
+ yield None
269
+ delay = time.time() - start
270
+ print(f"{name} took {delay:.1f}s")
271
+
272
+
273
+ def benchmark(tmp_path: Path):
274
+ segments = [
275
+ "crawl-data/CC-MAIN-2019-09/segments/1550249406966.99/wet/CC-MAIN-20190222220601-20190223002601-00441.warc.wet.gz"
276
+ ]
277
+ seg_file = tmp_path / "CC-MAIN-20190222220601-20190223002601-00441.warc.wet.gz"
278
+
279
+ with timer("from network"):
280
+ list(CCSegmentsReader(segments))
281
+
282
+ with timer("from network, with caching"):
283
+ list(CCSegmentsReader(segments, cache_dir=tmp_path))
284
+ assert seg_file.exists()
285
+
286
+ with timer("from disk"):
287
+ CCSegmentsReader(segments, cache_dir=tmp_path)
288
+ seg_file.unlink()
289
+
290
+
291
+ if __name__ == "__main__":
292
+ func_argparse.main(ls, dl)
cc-multilingual-main/cc_net/build/lib/cc_net/regroup.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import logging
8
+ import subprocess
9
+ from pathlib import Path
10
+ from typing import List
11
+
12
+ import func_argparse
13
+ import numpy as np
14
+
15
+ from cc_net import jsonql
16
+
17
+
18
+ def get_index(file: Path) -> Path:
19
+ return file.parent / (file.name + ".index")
20
+
21
+
22
+ def _get_tmp(output: Path) -> Path:
23
+ return output.parent / (output.stem + ".tmp" + output.suffix)
24
+
25
+
26
+ def reshard(
27
+ inputs: List[Path],
28
+ output: Path,
29
+ tmp: Path = None,
30
+ free_original: bool = False,
31
+ rm_original: bool = False,
32
+ ) -> Path:
33
+ """Read the given files and concatenate them to the output file.
34
+
35
+ Can remove original files on completion, or just write dummy content into them to free disk.
36
+ """
37
+ if tmp is None:
38
+ tmp = _get_tmp(output)
39
+ logging.info(f"Resharding {inputs} to {tmp}, will move later to {output}")
40
+ jsonql.run_pipes(file=inputs, output=tmp)
41
+ tmp.replace(output)
42
+ tmp_index = get_index(tmp)
43
+ if tmp_index.exists():
44
+ tmp_index.replace(get_index(output))
45
+
46
+ if not (free_original or rm_original):
47
+ return output
48
+
49
+ for _input in inputs:
50
+ if rm_original:
51
+ _input.unlink()
52
+ elif free_original:
53
+ # Overwrite the previous file.
54
+ # This frees up disk space and allows doit to properly track the success.
55
+ _input.write_text(f"Resharded into {output}")
56
+ if get_index(_input).is_file():
57
+ get_index(_input).unlink()
58
+
59
+ return output
60
+
61
+
62
+ def fast_reshard(
63
+ inputs: List[Path],
64
+ output: Path,
65
+ tmp: Path = None,
66
+ free_original: bool = False,
67
+ rm_original: bool = False,
68
+ ) -> Path:
69
+ """Same as reshard but don't re-compress the output.
70
+
71
+ This will lead to a bigger output file, especially if the shards are very small.
72
+ """
73
+ if tmp is None:
74
+ tmp = _get_tmp(output)
75
+ with open(tmp, "wb") as o:
76
+ subprocess.run(["cat"] + [str(f) for f in inputs], stdout=o)
77
+
78
+ tmp.replace(output)
79
+ indexes_files = [get_index(i) for i in inputs]
80
+ existing_indexes = sum(i.exists() for i in indexes_files)
81
+ assert (
82
+ existing_indexes == len(indexes_files) or existing_indexes == 0
83
+ ), "some indexes don't exist."
84
+ if existing_indexes > 0:
85
+ indexes = [np.load(idx) for idx in indexes_files]
86
+ for i in range(len(indexes) - 1):
87
+ indexes[i + 1] += indexes[i][-1]
88
+ with open(str(output) + ".index", "wb") as o:
89
+ np.save(o, np.concatenate(indexes))
90
+
91
+ if not (free_original or rm_original):
92
+ return output
93
+
94
+ for _input in inputs:
95
+ if rm_original:
96
+ _input.unlink()
97
+ elif free_original:
98
+ # Overwrite the previous file.
99
+ # This frees up disk space and allows doit to properly track the success.
100
+ _input.write_text(f"Resharded into {output}")
101
+ if get_index(_input).is_file():
102
+ get_index(_input).unlink()
103
+
104
+ return output
105
+
106
+
107
+ def determine_groups(
108
+ inputs: List[Path], target_size: int = 4 * 1024 ** 3
109
+ ) -> List[List[Path]]:
110
+ if len(inputs) == 0:
111
+ return []
112
+
113
+ sample = inputs[:10]
114
+ typical_size = sum(s.stat().st_size for s in sample) / len(sample)
115
+ group_size = min(target_size // typical_size, len(inputs))
116
+ group_size = max(group_size, 1)
117
+
118
+ return jsonql.grouper(inputs, group_size)
119
+
120
+
121
+ if __name__ == "__main__":
122
+ func_argparse.single_main(reshard)
cc-multilingual-main/cc_net/build/lib/cc_net/text_normalizer.py ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import re
8
+ import unicodedata
9
+
10
+ UNICODE_PUNCT = {
11
+ ",": ",",
12
+ "。": ".",
13
+ "、": ",",
14
+ "„": '"',
15
+ "”": '"',
16
+ "“": '"',
17
+ "«": '"',
18
+ "»": '"',
19
+ "1": '"',
20
+ "」": '"',
21
+ "「": '"',
22
+ "《": '"',
23
+ "》": '"',
24
+ "´": "'",
25
+ "∶": ":",
26
+ ":": ":",
27
+ "?": "?",
28
+ "!": "!",
29
+ "(": "(",
30
+ ")": ")",
31
+ ";": ";",
32
+ "–": "-",
33
+ "—": " - ",
34
+ ".": ". ",
35
+ "~": "~",
36
+ "’": "'",
37
+ "…": "...",
38
+ "━": "-",
39
+ "〈": "<",
40
+ "〉": ">",
41
+ "【": "[",
42
+ "】": "]",
43
+ "%": "%",
44
+ "►": "-",
45
+ }
46
+
47
+ UNICODE_PUNCT_RE = re.compile(f"[{''.join(UNICODE_PUNCT.keys())}]")
48
+
49
+
50
+ def replace_unicode_punct(text: str) -> str:
51
+ return "".join((UNICODE_PUNCT.get(c, c) for c in text))
52
+
53
+
54
+ def remove_unicode_punct(text: str) -> str:
55
+ """More aggressive version of replace_unicode_punct but also faster."""
56
+ return UNICODE_PUNCT_RE.sub("", text)
57
+
58
+
59
+ def strip_accents(line: str) -> str:
60
+ """Strips accents from a piece of text."""
61
+ nfd = unicodedata.normalize("NFD", line)
62
+ output = [c for c in nfd if unicodedata.category(c) != "Mn"]
63
+ if len(output) == line:
64
+ return line
65
+ return "".join(output)
66
+
67
+
68
+ # Build a regex matching all control characters.
69
+ NON_PRINTING_CHARS_RE = re.compile(
70
+ f"[{''.join(map(chr, list(range(0,32)) + list(range(127,160))))}]"
71
+ )
72
+ DIGIT_RE = re.compile(r"\d")
73
+ PUNCT_OR_NON_PRINTING_CHARS_RE = re.compile(
74
+ (UNICODE_PUNCT_RE.pattern + NON_PRINTING_CHARS_RE.pattern).replace("][", "")
75
+ )
76
+
77
+
78
+ def remove_non_printing_char(text: str) -> str:
79
+ return NON_PRINTING_CHARS_RE.sub("", text)
80
+
81
+
82
+ def normalize_spacing_for_tok(text: str, language: str = "en") -> str:
83
+ res = (
84
+ text.replace("\r", "")
85
+ # remove extra spaces
86
+ .replace("(", " (")
87
+ .replace(")", ") ")
88
+ .replace(" +", " ")
89
+ )
90
+ res = re.sub(r"\) ([\.\!\:\?\;\,])", r"\)\1", res)
91
+ res = res.replace("( ", "(").replace(" )", ")")
92
+ res = re.sub(r"(\d) \%", r"\1\%", res)
93
+ res = res.replace(" :", ":").replace(" ;", ";")
94
+ res = res.replace("`", "'").replace("''", ' " ')
95
+
96
+ res = (
97
+ res.replace("„", '"')
98
+ .replace("“", '"')
99
+ .replace("”", '"')
100
+ .replace("–", "-")
101
+ .replace("—", " - ")
102
+ .replace(" +", " ")
103
+ .replace("´", "'")
104
+ .replace("([a-z])‘([a-z])", r"\1'\2/")
105
+ .replace("([a-z])’([a-z])", r"\1'\2/")
106
+ .replace("‘", '"')
107
+ .replace("‚", '"')
108
+ .replace("’", '"')
109
+ .replace("''", '"')
110
+ .replace("´´", '"')
111
+ .replace("…", "...")
112
+ # French quotes
113
+ .replace(" « ", ' "')
114
+ .replace("« ", '"')
115
+ .replace("«", '"')
116
+ .replace(" » ", '" ')
117
+ .replace(" »", '"')
118
+ .replace("»", '"')
119
+ # handle pseudo-spaces
120
+ .replace(" %", "%")
121
+ .replace("nº ", "nº ")
122
+ .replace(" :", ":")
123
+ .replace(" ºC", " ºC")
124
+ .replace(" cm", " cm")
125
+ .replace(" ?", "?")
126
+ .replace(" !", "!")
127
+ .replace(" ;", ";")
128
+ .replace(", ", ", ")
129
+ .replace(" +", " ")
130
+ .replace(".", ". ")
131
+ )
132
+ # English "quotation," followed by comma, style
133
+ if language == "en":
134
+ res = re.sub(r"\"([,\.]+)", r"\1\"", res)
135
+ # Czech is confused
136
+ elif language == "cs" or language == "cz":
137
+ pass
138
+ # German/Spanish/French "quotation", followed by comma, style
139
+ else:
140
+ res = res.replace(',"', '",')
141
+ res = re.sub(
142
+ r"(\.+)\"(\s*[^<])", r"\"\1\2", res
143
+ ) # don't fix period at end of sentence
144
+
145
+ if (
146
+ language == "de"
147
+ or language == "es"
148
+ or language == "cz"
149
+ or language == "cs"
150
+ or language == "fr"
151
+ ):
152
+ res = re.sub(r"(\d) (\d)", r"\1,\2", res)
153
+ else:
154
+ res = re.sub(r"(\d) (\d)", r"\1.\2", res)
155
+ return res
156
+
157
+
158
+ def normalize(line: str, accent=True, case=True, numbers=True, punct=1) -> str:
159
+ line = line.strip()
160
+ if not line:
161
+ return line
162
+ if case:
163
+ line = line.lower()
164
+ if accent:
165
+ line = strip_accents(line)
166
+ if numbers:
167
+ line = DIGIT_RE.sub("0", line)
168
+ if punct == 1:
169
+ line = replace_unicode_punct(line)
170
+ elif punct == 2:
171
+ line = remove_unicode_punct(line)
172
+ line = remove_non_printing_char(line)
173
+ return line
174
+
175
+
176
+ def slow_normalize_for_dedup(line: str) -> str:
177
+ return normalize(line, accent=False, case=True, numbers=True, punct=2)
178
+
179
+
180
+ def normalize_for_dedup(line: str) -> str:
181
+ line = line.strip()
182
+ if not line:
183
+ return line
184
+ # case
185
+ line = line.lower()
186
+ # numbers
187
+ line = DIGIT_RE.sub("0", line)
188
+ line = PUNCT_OR_NON_PRINTING_CHARS_RE.sub("", line)
189
+ return line
cc-multilingual-main/cc_net/cc_net.egg-info/PKG-INFO ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: cc_net
3
+ Version: 1.0.0
4
+ Summary: Tools to download and clean Common Crawl
5
+ Home-page: https://github.com/facebookresearch/cc_net
6
+ Author: Guillaume Wenzek
7
+ Author-email: [email protected]
8
+ License: CC-BY-NC-4.0
9
+ Project-URL: Bug Tracker, https://github.com/facebookresearch/cc_net/issues
10
+ Project-URL: Source Code, https://github.com/facebookresearch/cc_net
11
+ Keywords: common crawl dataset
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Programming Language :: Python :: 3.7
14
+ Requires-Python: >=3.7
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: beautifulsoup4>=4.7.1
17
+ Requires-Dist: pandas>=0.23.4
18
+ Requires-Dist: requests>=2.22.0
19
+ Requires-Dist: fasttext>=0.9.1
20
+ Requires-Dist: sentencepiece>=0.1.82
21
+ Requires-Dist: kenlm@ git+https://github.com/kpu/kenlm.git@master
22
+ Requires-Dist: func_argparse>=1.1.1
23
+ Requires-Dist: psutil>=5.6.3
24
+ Requires-Dist: sacremoses
25
+ Requires-Dist: submitit>=1.0.0
26
+ Requires-Dist: typing_extensions
27
+ Provides-Extra: dev
28
+ Requires-Dist: mypy==0.790; extra == "dev"
29
+ Requires-Dist: pytest; extra == "dev"
30
+ Requires-Dist: black==19.3b0; extra == "dev"
31
+ Requires-Dist: isort==5.6.4; extra == "dev"
32
+ Provides-Extra: tools
33
+ Requires-Dist: lxml; extra == "tools"
34
+ Requires-Dist: sentence_splitter; extra == "tools"
35
+ Provides-Extra: getpy
36
+ Requires-Dist: getpy@ git+https://github.com/gwenzek/[email protected] ; extra == "getpy"
37
+
38
+ # cc_net
39
+
40
+ Tools to download and clean Common Crawl as introduced in our paper [CCNet](https://arxiv.org/abs/1911.00359).
41
+
42
+ If you found these resources useful, please consider citing:
43
+
44
+ ```
45
+ @inproceedings{wenzek2020ccnet,
46
+ title={CCNet: Extracting High Quality Monolingual Datasets from Web Crawl Data},
47
+ author={Wenzek, Guillaume and Lachaux, Marie-Anne and Conneau, Alexis and Chaudhary, Vishrav and Guzm{\'a}n, Francisco and Joulin, Armand and Grave, {\'E}douard},
48
+ booktitle={Proceedings of The 12th Language Resources and Evaluation Conference},
49
+ pages={4003--4012},
50
+ year={2020}
51
+ }
52
+ ```
53
+
54
+ [![CircleCI](https://circleci.com/gh/facebookresearch/cc_net.svg?style=svg)](https://circleci.com/gh/facebookresearch/cc_net)
55
+
56
+
57
+ ## Installation
58
+
59
+ We only tried this on Linux but installation should be possible on MacOS too.
60
+
61
+ 1. Create or simlink a `data` folder to where you want to download the corpus.
62
+
63
+ 2. Run `make install`. This will download some resources and install required packages.
64
+
65
+ 3. If you have a C++ 17 compiler you can also run
66
+ `pip install .[getpy]`, it provides more memory efficient hashset.
67
+
68
+ 4. Install the following tools manually if `make install` failed:
69
+ - `lmplz` and `build_binary` from [KenLM](https://github.com/kpu/kenlm)
70
+ - `spm_train` and `spm_encode` from [Sentence Piece](https://github.com/google/sentencepiece)
71
+
72
+ ## Training Language Models
73
+
74
+ The `Makefile` is used to train Sentence Piece and LM on Wikipedia data.
75
+
76
+ * `make help` shows help
77
+ * `make lang=de lm` trains a Sentence Piece and a LM on German Wikipedia
78
+ * `make all_lm` trains the same model than in the paper
79
+ * `make lang=de dl_lm` downloads the LM trained for the paper
80
+ * `make dl_all_lm` downloads all of them
81
+
82
+ ## Pipeline overview
83
+
84
+ The full mining pipeline is divided in 3 steps:
85
+
86
+ - `hashes` downloads one Common-Crawl snapshot, and compute hashes for each paragraph
87
+ - `mine` removes duplicates, detects language, run the LM and split by lang/perplexity buckets
88
+ - `regroup` regroup the files created by `mine` in chunks of 4Gb
89
+
90
+ Each step needs the previous step to be over before starting.
91
+ You can launch the full pipeline using `python -m cc_net`.
92
+
93
+ * `python -m cc_net --help` shows help
94
+ * `python -m cc_net --dump 2019-13` treats a specific snapshot
95
+ * `python -m cc_net -l my -l gu`
96
+ restricts to specific languages
97
+ * `python -m cc_net --lm_dir my_lms/` uses custom LMs
98
+ * `python -m cc_net --lang_threshold 0.3` set a specific field in `mine.Config`
99
+ * `python -m cc_net --config test` runs on a tiny subset of a snapshot
100
+ * `python -m cc_net --config config/my_config.json` uses configuration from the given config file
101
+
102
+ ## Reproducing our work
103
+
104
+ Given the CPU required to run the full pipeline on such a big corpus we share a mapping from url to the information we computed.
105
+ You can reconstruct the corpus used in the paper by using:
106
+
107
+ ```sh
108
+ python -m cc_net --conf reproduce --dump 2019-09
109
+ ```
110
+
111
+ ## Extract XLM-R data
112
+
113
+ [Unsupervised Cross-lingual Representation Learning at Scale (XLM-RoBERTa)](https://arxiv.org/pdf/1911.02116.pdf)
114
+ paper was trained on data extracted by an internal version of cc_net.
115
+
116
+ Due to the format being a little bit different please use the following command instead:
117
+
118
+ ```sh
119
+ python cc_net/tools/dl_cc_100.py --help
120
+ python cc_net/tools/dl_cc_100.py --outdir data_cc100 --process 8
121
+ ```
122
+
123
+ If you use this version of the data please also consider citing:
124
+
125
+ ```bibtex
126
+ @article{conneau2019unsupervised,
127
+ title={Unsupervised Cross-lingual Representation Learning at Scale},
128
+ author={Conneau, Alexis and Khandelwal, Kartikay and Goyal, Naman and Chaudhary, Vishrav and Wenzek, Guillaume and Guzm{\'a}n, Francisco and Grave, Edouard and Ott, Myle and Zettlemoyer, Luke and Stoyanov, Veselin},
129
+ journal={arXiv preprint arXiv:1911.02116},
130
+ year={2019}
131
+ }
132
+ ```
133
+
134
+
135
+ ## Adapting to your infrastructure
136
+
137
+ Given the computation cost of running the full pipeline we distributed the computation
138
+ on a [Slurm](https://slurm.schedmd.com/) cluster using [submitit](https://github.com/facebookincubator/submitit).
139
+ `submitit` will default to spawning processes on your machine if Slurm cluster is found.
140
+ You should tweak `--task_parallelism` to something adapated to your machine.
141
+ Defaults are 512 for mining and 20 for reproducing.
142
+
143
+ To run the tasks in-process use `--execution debug`.
144
+
145
+
146
+ ## Output format
147
+
148
+ Generated files are compressed JSON files. There is one JSON object per line.
149
+
150
+ __List of fields__:
151
+
152
+ - url: webpage URL (part of CC)
153
+ - date_download: date of download (part of CC)
154
+ - digest: sha1 digest of the webpage (part of CC)
155
+ - length: number of chars
156
+ - nlines: number of lines
157
+ - source_domain: web domain of the webpage
158
+ - title: page title (part of CC)
159
+ - raw_content: webpage content after deduplication
160
+ - original_nlines: number of lines before deduplication
161
+ - original_length: number of chars before deduplication
162
+ - language: language detected by FastText LID
163
+ - language_score: language score
164
+ - perplexity: perplexity of a LM trained on Wikipedia
165
+
166
+ __Sample JSON object__:
167
+ ```json
168
+ {
169
+ "url": "http://www.pikespeakhospice.org/members/1420",
170
+ "date_download": "2019-02-15T18:40:25Z",
171
+ "digest": "sha1:VQW3KXUOALO543IJGTK2JLVEAN2XXKHI",
172
+ "length": 752,
173
+ "nlines": 5,
174
+ "source_domain": "www.pikespeakhospice.org",
175
+ "title": "LeeRoy Aragon",
176
+ "raw_content": "Date Honored: March 2017\nHe was a man of integrity, a hard worker, and a dedicated family man. He loved spending time with family camping, fishing, hunting, boating and just hanging out.\nHis Catholic faith was extremely important to him as he gave of his time and talents to the community. He had many friends through church and the Knights of Columbus. He was a meticulous handyman, and enjoyed building and fixing things and restoring antique furniture to perfection. He was a fan and supported his Colorado Rockies and Denver Broncos. Throughout the years he had devoted four-legged friends (his dogs and a horse named Sunny Boy).\nWe have many cherished memories of him that we will treasure until we are with him again.\n~ Family of LeeRoy F. Aragon",
177
+ "original_nlines": 7,
178
+ "original_length": 754,
179
+ "language": "en",
180
+ "language_score": 0.99,
181
+ "perplexity": 255.11,
182
+ }
183
+ ```
184
+
185
+ You can peak at those files using UNIX tools `zcat` and [`jq`](https://stedolan.github.io/jq/manual/), eg:
186
+ `zcat data/mined/2019-09/en_head_0000.json.gz | head -1 | jq .`
187
+
188
+ `jq` can do some complicated filtering.
189
+ `jsonql.py` provides a Python API with multiprocess support to do more complicated operations like LM scoring of the document.
190
+
191
+ ## License
192
+
193
+ By contributing to `cc_net`, you agree that your contributions will be licensed
194
+ under the LICENSE file in the root directory of this source tree.
cc-multilingual-main/cc_net/cc_net.egg-info/SOURCES.txt ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ cc_net/__init__.py
5
+ cc_net/__main__.py
6
+ cc_net/dedup.py
7
+ cc_net/execution.py
8
+ cc_net/flat_hash_set.py
9
+ cc_net/get_wiki_cirrus.py
10
+ cc_net/jsonql.py
11
+ cc_net/mine.py
12
+ cc_net/minify.py
13
+ cc_net/perplexity.py
14
+ cc_net/process_wet_file.py
15
+ cc_net/regroup.py
16
+ cc_net/split_by_lang.py
17
+ cc_net/text_normalizer.py
18
+ cc_net/tokenizer.py
19
+ cc_net.egg-info/PKG-INFO
20
+ cc_net.egg-info/SOURCES.txt
21
+ cc_net.egg-info/dependency_links.txt
22
+ cc_net.egg-info/requires.txt
23
+ cc_net.egg-info/top_level.txt
24
+ cc_net/data/cutoff.csv
25
+ cc_net/data/test_stats.json
26
+ tests/test_dedup.py
27
+ tests/test_flat_hash_set.py
28
+ tests/test_jsonql.py
29
+ tests/test_minify.py
30
+ tests/test_normalizer.py
31
+ tests/test_parse_wet_file.py
32
+ tests/test_regroup.py
33
+ tests/test_transformer.py
cc-multilingual-main/cc_net/cc_net.egg-info/dependency_links.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
cc-multilingual-main/cc_net/cc_net.egg-info/requires.txt ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ beautifulsoup4>=4.7.1
2
+ pandas>=0.23.4
3
+ requests>=2.22.0
4
+ fasttext>=0.9.1
5
+ sentencepiece>=0.1.82
6
+ kenlm@ git+https://github.com/kpu/kenlm.git@master
7
+ func_argparse>=1.1.1
8
+ psutil>=5.6.3
9
+ sacremoses
10
+ submitit>=1.0.0
11
+ typing_extensions
12
+
13
+ [dev]
14
+ mypy==0.790
15
+ pytest
16
+ black==19.3b0
17
+ isort==5.6.4
18
+
19
+ [getpy]
20
+ getpy@ git+https://github.com/gwenzek/[email protected]
21
+
22
+ [tools]
23
+ lxml
24
+ sentence_splitter
cc-multilingual-main/cc_net/cc_net.egg-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ cc_net
cc-multilingual-main/cc_net/tests/__init__.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+ #
cc-multilingual-main/cc_net/tests/conftest.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import pytest
8
+
9
+
10
+ def _request_is_disabled(self, *args, **kwargs):
11
+ raise Exception(
12
+ f"Your code tried to call 'request' with: {args}, {kwargs}. Unit test aren't allowed to reach internet."
13
+ )
14
+
15
+
16
+ @pytest.fixture(autouse=True)
17
+ def no_requests(monkeypatch):
18
+ """Remove requests.sessions.Session.request for all tests."""
19
+ monkeypatch.setattr("requests.sessions.Session.request", _request_is_disabled)
cc-multilingual-main/cc_net/tests/data/sample.warc.txt ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ WARC/1.0
2
+ WARC-Type: warcinfo
3
+ WARC-Date: 2019-03-27T06:10:48Z
4
+ WARC-Filename: CC-MAIN-20190318132220-20190318153634-00064.warc.wet.gz
5
+ WARC-Record-ID: <urn:uuid:d711dd43-8280-457b-9566-530ef6ea5d43>
6
+ Content-Type: application/warc-fields
7
+ Content-Length: 370
8
+
9
+ Software-Info: ia-web-commons.1.1.9-SNAPSHOT-20190314010907
10
+ Extracted-Date: Wed, 27 Mar 2019 06:10:48 GMT
11
+ robots: checked via crawler-commons 0.11-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
12
+ isPartOf: CC-MAIN-2019-13
13
+ operator: Common Crawl Admin ([email protected])
14
+ description: Wide crawl of the web for March 2019
15
+ publisher: Common Crawl
16
+
17
+ WARC/1.0
18
+ WARC-Type: conversion
19
+ WARC-Target-URI: http://sample_english.com
20
+ WARC-Date: 2019-03-18T00:00:00Z
21
+ WARC-Record-ID: <urn:uuid:cd61b0b3-d9b0-466c-9a5e-99c191f8d2e1>
22
+ WARC-Refers-To: <urn:uuid:eb4541d2-5ad0-4ed0-91a6-34380636d506>
23
+ WARC-Block-Digest: sha1:XQZHW7QWIG54HVAV3KPRW6MK5ILDNCER
24
+ Content-Type: text/plain
25
+ Content-Length: 353
26
+
27
+ Famous Mark Twain Quotes
28
+ Don't part with your illusions. When they are gone you may still exist, but you have ceased to live.
29
+ Education: that which reveals to the wise, and conceals from the stupid, the vast limits of their knowledge.
30
+
31
+ Facts are stubborn things, but statistics are more pliable.
32
+ Fiction is obliged to stick to possibilities. Truth isn't.
33
+
34
+ WARC/1.0
35
+ WARC-Type: conversion
36
+ WARC-Target-URI: http://sample_chinese.zh
37
+ WARC-Date: 2019-03-18T00:00:01Z
38
+ WARC-Record-ID: <urn:uuid:cd61b0b3-d9b0-466c-9a5e-99c191f8d2e1>
39
+ WARC-Refers-To: <urn:uuid:eb4541d2-5ad0-4ed0-91a6-34380636d506>
40
+ WARC-Block-Digest: sha1:Y4E6URVYGIAFNVRTPZ5S3J64RTZTP6HJ
41
+ Content-Type: text/plain
42
+ Content-Length: 109
43
+
44
+ 馬克·吐溫名言
45
+ 不要放棄你的幻想。 當它們消失後,您可能仍然存在,但您已經不復存在。
46
+ 教育:向智者揭示並從愚蠢者中隱藏其知識的巨大局限的教育。
47
+ 事實是固執的東西,但統計數字卻比較柔和。
48
+ 小說必須堅持可能。 真理不是。
49
+
50
+ WARC/1.0
51
+ WARC-Type: conversion
52
+ WARC-Target-URI: http://sample_russian.ru
53
+ WARC-Date: 2019-03-18T00:00:02Z
54
+ WARC-Record-ID: <urn:uuid:27dccd48-27b2-4eb0-b10b-a43661cbf0bc>
55
+ WARC-Refers-To: <urn:uuid:5d53cf06-9ccf-4216-917a-89cdc3d50d54>
56
+ WARC-Block-Digest: sha1:RBW57C753IE4CHCOZCMS2BHMHBEGXKXL
57
+ Content-Type: text/plain
58
+ Content-Length: 355
59
+
60
+ Цитаты знаменитого Марка Твена
61
+ Не расставайся со своими иллюзиями. Когда они исчезнут, вы все еще можете существовать, но вы перестали жить.
62
+ Образование: то, что открывает мудрым и скрывает от глупых обширные границы их знаний.
63
+ Факты - упрямые вещи, но статистика более податлива.
64
+ Художественная литература обязана придерживаться возможностей. Правда нет.
65
+
66
+
cc-multilingual-main/cc_net/tests/test_dedup.py ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import json
8
+ from pathlib import Path
9
+ from typing import Iterable, Sequence
10
+
11
+ from cc_net import dedup, jsonql
12
+ from cc_net.dedup import str_hash
13
+ from cc_net.flat_hash_set import FlatHashSet
14
+
15
+
16
+ def text(*args: str) -> str:
17
+ return "\n".join(args)
18
+
19
+
20
+ def write_docs(file: Path, docs: Iterable[Sequence[str]]):
21
+ file.parent.mkdir(exist_ok=True)
22
+ with open(file, "w") as f:
23
+ for sentences in docs:
24
+ doc = dict(text=text(*sentences))
25
+ print(json.dumps(doc), file=f)
26
+
27
+
28
+ def as_dict(hash_set):
29
+ if not isinstance(hash_set, dict):
30
+ hash_set = {k: v for (k, v) in hash_set.items()}
31
+ return hash_set
32
+
33
+
34
+ def load_hashes(file):
35
+ results = dedup.FlatHashSet()
36
+ results.load(file)
37
+ return as_dict(results)
38
+
39
+
40
+ LENGTHS = ["original_length", "length"]
41
+
42
+
43
+ def assert_documents_equal(expected, actual, ignoring={}):
44
+ expected = [{k: doc[k] for k in doc if k not in ignoring} for doc in expected]
45
+ actual = [{k: doc[k] for k in doc if k not in ignoring} for doc in expected]
46
+ assert expected == actual
47
+
48
+
49
+ def test_simple_dedup(tmp_path: Path) -> None:
50
+ write_docs(
51
+ tmp_path / "docs.json",
52
+ [
53
+ ["_Hello", "_World", "I'm so original"],
54
+ ["_world", "I'm originaler", "_Hello"],
55
+ ],
56
+ )
57
+ results = list(dedup.deduplicate(tmp_path / "docs.json", field="text"))
58
+ expected = [
59
+ # First document is untouched
60
+ dict(
61
+ text=text("_Hello", "_World", "I'm so original"),
62
+ original_nlines=3,
63
+ nlines=3,
64
+ line_ids=[0, 1, 2],
65
+ ),
66
+ # Second documents loses several lines
67
+ dict(text="I'm originaler", original_nlines=3, nlines=1, line_ids=[1]),
68
+ ]
69
+
70
+ assert_documents_equal(expected, results, ignoring=LENGTHS)
71
+
72
+
73
+ def test_dedup_with_dump(tmp_path: Path):
74
+ hashes = tmp_path / "hashes.bin"
75
+ documents = [
76
+ dict(text=text("_Hello", "_World", "I'm so original")),
77
+ dict(text=text("_world", "I'm originaler", "_Hello")),
78
+ ]
79
+ collector = dedup.HashesCollector(field="text", output=hashes)
80
+ list(collector.map(documents))
81
+ results = load_hashes(hashes)
82
+ expected = {
83
+ str_hash(l): l.startswith("_")
84
+ for l in ["_hello", "_world", "i'm so original", "i'm originaler"]
85
+ }
86
+ assert expected == results
87
+
88
+
89
+ def test_dedup_with_np_dump(tmp_path: Path):
90
+ hashes = tmp_path / "hashes.bin"
91
+ documents = [
92
+ dict(text=text("_Hello", "_World", "I'm so original")),
93
+ dict(text=text("_world", "I'm originaler", "_Hello")),
94
+ ]
95
+ with dedup.HashesCollector(field="text", output=hashes) as d:
96
+ list(d.map(documents))
97
+
98
+ results = FlatHashSet()
99
+ results.load_np(hashes)
100
+ expected = set(
101
+ str_hash(l) for l in ["_hello", "_world", "i'm so original", "i'm originaler"]
102
+ )
103
+ assert expected == set(results.keys())
104
+
105
+
106
+ def test_dedup_from_hashes(tmp_path: Path):
107
+ documents = [
108
+ dict(text=text("_Hello", "World", "I'm so original")),
109
+ dict(text=text("Good morning", "World", "I'm originaler")),
110
+ ]
111
+ seen = ["_hello", "i'm originaler", "world"]
112
+ hashes = [str_hash(h) for h in seen]
113
+ h = dedup.FlatHashSet()
114
+ h.add(hashes)
115
+ # Note: 'world' appears only once and won't be treated as a duplicate.
116
+ h.add(hashes[:-1])
117
+ h.dump(tmp_path / "hashes.bin")
118
+
119
+ results = list(
120
+ dedup.DuplicatesRemover("text", [tmp_path / "hashes.bin"]).map(documents)
121
+ )
122
+ expected = [
123
+ dict(
124
+ text=text("World", "I'm so original"),
125
+ original_nlines=3,
126
+ nlines=2,
127
+ line_ids=[1, 2],
128
+ ),
129
+ dict(
130
+ text=text("Good morning", "World"),
131
+ original_nlines=3,
132
+ nlines=2,
133
+ line_ids=[0, 1],
134
+ ),
135
+ ]
136
+
137
+ assert_documents_equal(expected, results, ignoring=LENGTHS)
138
+
139
+
140
+ def test_dedup_fast(tmp_path: Path):
141
+ data = tmp_path / "data"
142
+ part_0 = [["Hello", "_World", "I'm so original"]]
143
+ write_docs(data / "part_0.json", part_0)
144
+ part_1 = [["Good morning", "_World", "I'm originaler"]]
145
+ write_docs(data / "part_1.json", part_1)
146
+ parts = [data / "part_0.json", data / "part_1.json"]
147
+
148
+ res = tmp_path / "res"
149
+ res.mkdir()
150
+ h = tmp_path / "hashes.bin"
151
+ field = "text"
152
+ jsonql.run_pipes(dedup.HashesCollector(field, output=h), file=parts)
153
+ for part in parts:
154
+ jsonql.run_pipes(
155
+ dedup.DuplicatesRemover(field, [h]), file=part, output=res / part.name
156
+ )
157
+ jsonql.run_pipes(
158
+ dedup.DuplicatesRemover(field, [h]), file=part, output=res / part.name
159
+ )
160
+
161
+ results_0 = list(jsonql.read_jsons(res / "part_0.json"))
162
+ expected_0 = [
163
+ dict(
164
+ text=text("Hello", "I'm so original"),
165
+ original_nlines=3,
166
+ nlines=2,
167
+ line_ids=[0, 2],
168
+ )
169
+ ]
170
+ assert_documents_equal(expected_0, results_0, ignoring=LENGTHS)
171
+
172
+ results_1 = list(jsonql.read_jsons(res / "part_1.json"))
173
+ expected_1 = [
174
+ dict(
175
+ text=text("Good morning", "I'm originaler"),
176
+ original_nlines=3,
177
+ nlines=2,
178
+ line_ids=[0, 2],
179
+ )
180
+ ]
181
+
182
+ assert_documents_equal(expected_1, results_1, ignoring=LENGTHS)
183
+
184
+ words = [w for part in [part_0, part_1] for doc in part for w in doc]
185
+ expected = {str_hash(s.lower()): s.startswith("_") for s in words}
186
+ assert expected == load_hashes(h)
187
+
188
+
189
+ def test_remove_duplicates_sharded(tmp_path: Path):
190
+ data = tmp_path / "data"
191
+ part_0 = [["Hello", "_World", "I'm so original"]]
192
+ write_docs(data / "part_0.json", part_0)
193
+ part_1 = [["_Good morning", "_World", "I'm originaler"]]
194
+ write_docs(data / "part_1.json", part_1)
195
+
196
+ h = tmp_path / "hashes"
197
+ h.mkdir()
198
+ h0 = FlatHashSet()
199
+ h0.add([str_hash(s.lower()) for doc in part_0 for s in doc])
200
+ h0.add([str_hash("_world")])
201
+ h0.dump(h / "part_0.bin")
202
+ assert {
203
+ str_hash("hello"): False,
204
+ str_hash("_world"): True,
205
+ str_hash("i'm so original"): False,
206
+ } == as_dict(h0)
207
+
208
+ h1 = FlatHashSet()
209
+ h1.add([str_hash(s.lower()) for doc in part_1 for s in doc])
210
+ h1.add([str_hash("_good morning")])
211
+ h1.dump(h / "part_1.bin")
212
+ assert {
213
+ str_hash("_good morning"): True,
214
+ str_hash("_world"): False,
215
+ str_hash("i'm originaler"): False,
216
+ } == as_dict(h1)
217
+
218
+ res = tmp_path / "res"
219
+ res.mkdir()
220
+ # dedup.DISABLE_MULTI_PROCESSING = True # Simplifies debugging
221
+ dedup.remove_duplicates_sharded(
222
+ files=[data / "part_0.json", data / "part_1.json"],
223
+ outputs=[res / "part_0.json", res / "part_1.json"],
224
+ field="text",
225
+ hashes_dir=h,
226
+ )
227
+
228
+ results_0 = list(jsonql.read_jsons(res / "part_0.json"))
229
+ expected_0 = [
230
+ dict(
231
+ text=text("Hello", "I'm so original"),
232
+ original_nlines=3,
233
+ nlines=2,
234
+ line_ids=[0, 2],
235
+ )
236
+ ]
237
+ assert_documents_equal(expected_0, results_0, ignoring=LENGTHS)
238
+
239
+ # First pass removes "_world", second "_good morning".
240
+ results_1 = list(jsonql.read_jsons(res / "part_1.json"))
241
+ expected_1 = [
242
+ dict(text=text("I'm originaler"), original_nlines=3, nlines=1, line_ids=[2])
243
+ ]
244
+
245
+ assert_documents_equal(expected_1, results_1, ignoring=LENGTHS)
cc-multilingual-main/cc_net/tests/test_flat_hash_set.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import numpy as np
8
+ import pytest
9
+
10
+ from cc_net.flat_hash_set import HASH_TYPE, FlatHashSet, NaiveHashSet
11
+
12
+
13
+ def as_dict(flat_hash_set) -> dict:
14
+ return {k: v for (k, v) in flat_hash_set.items()}
15
+
16
+
17
+ need_getpy = pytest.mark.skipif(
18
+ FlatHashSet == NaiveHashSet, reason="getpy isn't installed"
19
+ )
20
+
21
+
22
+ def same_behavior(test_case):
23
+ def run_case():
24
+ naive = as_dict(test_case(FlatHashSet))
25
+ flat = as_dict(test_case(NaiveHashSet))
26
+ assert naive == flat
27
+
28
+ return need_getpy(run_case)
29
+
30
+
31
+ @same_behavior
32
+ def test_setitem(hash_set_cls):
33
+ h = hash_set_cls()
34
+ h[np.arange(10, dtype=h.dtype)] = np.zeros(10, dtype=np.uint8)
35
+ h[np.arange(5, dtype=h.dtype)] = np.ones(5, dtype=np.uint8)
36
+ return h
37
+
38
+
39
+ @same_behavior
40
+ def test_add_dup(hash_set_cls):
41
+ h = hash_set_cls()
42
+ h.add(np.arange(10, dtype=h.dtype))
43
+ h.add(np.arange(5, dtype=h.dtype))
44
+
45
+ expected = {i: i < 5 for i in range(10)}
46
+ assert expected == as_dict(h), f"add_dup with {hash_set_cls.__name__}"
47
+ return h
48
+
49
+
50
+ @need_getpy
51
+ def test_gp_dict():
52
+ import getpy as gp # type: ignore
53
+
54
+ h = gp.Dict(HASH_TYPE, np.uint8)
55
+ h[np.arange(10, dtype=HASH_TYPE)] = np.zeros(10, dtype=np.uint8)
56
+ h[np.arange(5, dtype=HASH_TYPE)] = np.ones(5, dtype=np.uint8)
57
+ expected = {i: i < 5 for i in range(10)}
58
+ assert expected == as_dict(h)
59
+
60
+
61
+ def check_reload(h, dump, load, tmp_path):
62
+ dump_path = tmp_path / dump.__name__
63
+ dump(h, dump_path)
64
+ h2 = type(h)()
65
+ load(h2, dump_path)
66
+ assert as_dict(h) == as_dict(h2)
67
+
68
+
69
+ @pytest.mark.parametrize("hash_set_cls", [FlatHashSet, NaiveHashSet])
70
+ def test_loading(tmp_path, hash_set_cls):
71
+ h = hash_set_cls()
72
+ x = np.random.randint(0, 2 ** 32, (100,), dtype=h.dtype)
73
+ h.add(x)
74
+
75
+ check_reload(h, hash_set_cls.dump, hash_set_cls.load, tmp_path)
76
+ check_reload(h, hash_set_cls.dump_np, hash_set_cls.load_np, tmp_path)
77
+ if hasattr(hash_set_cls, "dump_gp"):
78
+ check_reload(h, hash_set_cls.dump_gp, hash_set_cls.load_gp, tmp_path)
cc-multilingual-main/cc_net/tests/test_jsonql.py ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import io
8
+ from pathlib import Path
9
+ from typing import Sequence
10
+
11
+ import numpy as np
12
+ import pytest
13
+
14
+ from cc_net import jsonql
15
+
16
+
17
+ def bar(small_bar: str) -> str:
18
+ return small_bar.replace(" ", " " * 10).replace("█", "█" * 10)
19
+
20
+
21
+ def get_output(transformer, data, **kwargs):
22
+ with io.StringIO() as output:
23
+ # Convert data to a generator so that it's not interpreted as a file list.
24
+ jsonql.run_pipe(transformer, kwargs, file=(x for x in data), output=output)
25
+ return output.getvalue()
26
+
27
+
28
+ def test_split(tmp_path: Path):
29
+ data = [
30
+ dict(text="Hello world", lang="en"),
31
+ dict(text="Boujour les amis", lang="fr"),
32
+ dict(text="Rock your boat", lang="en"),
33
+ ]
34
+ with jsonql.split(tmp_path / "{lang}.json") as split:
35
+ list(split.map(data))
36
+ summary = split.summary()
37
+ assert "Found 2 splits." in summary
38
+ en_docs = list(jsonql.read_jsons(tmp_path / "en.json"))
39
+ assert [data[0], data[2]] == en_docs
40
+
41
+ fr_docs = list(jsonql.read_jsons(tmp_path / "fr.json"))
42
+ assert [data[1]] == fr_docs
43
+
44
+
45
+ def test_split_bad_pattern(tmp_path: Path):
46
+ data = [dict(text="Hello world", lang="en")]
47
+ with pytest.raises(KeyError):
48
+ with jsonql.split(tmp_path / "{language}.json") as split:
49
+ list(split.map(data))
50
+
51
+
52
+ def test_histogram():
53
+ data = [0.1, 0.1, 0.1, 0.1, 0.4, 0.4, 0.9, 0.9]
54
+ hist, bins = jsonql.histogram(data, bins=8, weights=None)
55
+ np.testing.assert_almost_equal(bins, [0.1 * x for x in range(1, 10)])
56
+ np.testing.assert_almost_equal(hist, [4, 0, 0, 2, 0, 0, 0, 2])
57
+
58
+ data = [0, 0.1, 0.1, 0.1, 0.1, 0.4, 0.4, 0.8, 0.8, 1]
59
+ hist, bins = jsonql.histogram(data, bins=10, weights=None)
60
+ np.testing.assert_almost_equal(bins, [0.1 * x for x in range(11)])
61
+ np.testing.assert_almost_equal(hist, [1, 4, 0, 0, 2, 0, 0, 0, 2, 1])
62
+
63
+
64
+ def test_display_stats():
65
+ stats = {
66
+ jsonql.ALL_DOCUMENTS: 100,
67
+ "title": 80,
68
+ "title.length": 80 * 50,
69
+ "text": 100,
70
+ "text.length": 100 * 1000,
71
+ "popularity": 8,
72
+ "popularity.val": [0.1, 0.1, 0.1, 0.1, 0.4, 0.4, 0.9, 0.9],
73
+ }
74
+
75
+ (title,) = jsonql.display_stats(stats, "title")
76
+ assert "title" in title
77
+ assert "saw 80 times" in title
78
+ assert "average length is" in title
79
+ assert "\n" not in title
80
+
81
+ (text,) = jsonql.display_stats(stats, "text")
82
+ assert "text" in text
83
+ assert "saw 100 times" in text
84
+ assert "average length is" in text
85
+ assert "\n" not in text
86
+
87
+ histogram = jsonql.display_stats(
88
+ stats, "popularity", bins=[x / 10 for x in range(1, 10)]
89
+ )
90
+ assert "popularity" in histogram[0]
91
+ assert "saw 8 times" in histogram[0]
92
+ assert "histogram is" in histogram[0]
93
+ assert "0.100 " + bar("████████") in histogram[1]
94
+ assert "0.400 " + bar("████ ") in histogram[2]
95
+ assert "0.800 " + bar("████ ") in histogram[3]
96
+
97
+ cum_histogram = jsonql.display_stats(stats, "popularity", bins=8, cumulative=True)
98
+ assert "popularity" in cum_histogram[0]
99
+ assert "saw 8 times" in cum_histogram[0]
100
+ assert "histogram is" in cum_histogram[0]
101
+ assert "0.100 " + bar("████ ") in cum_histogram[1]
102
+ assert "0.400 " + bar("██████ ") in cum_histogram[2]
103
+ assert "0.800 " + bar("████████") in cum_histogram[3]
104
+
105
+
106
+ def test_describe():
107
+ def sample(pop):
108
+ return dict(title="Lorem", text="Lorem ipsum dolor sit amet.", popularity=pop)
109
+
110
+ data = [sample(pop) for pop in [0.1, 0.1, 0.1, 0.1, 0.4, 0.4, 0.9, 0.9]]
111
+ desc = get_output(
112
+ jsonql.describe, data, columns=None, bins=[x / 10 for x in range(1, 10)]
113
+ )
114
+
115
+ assert "Field title saw 8 times (100.0%), average length is 5" in desc
116
+ assert "Field text saw 8 times (100.0%), average length is 27" in desc
117
+ assert "Field popularity saw 8 times (100.0%), histogram is" in desc
118
+ assert "0.100 " + bar("████████") in desc
119
+ assert "0.400 " + bar("████ ") in desc
120
+ assert "0.800 " + bar("████ ") in desc
121
+
122
+ desc = get_output(jsonql.describe, data, columns=["text"])
123
+ assert "Field title saw 8 times (100.0%), average length is 5" not in desc
124
+ assert "Field text saw 8 times (100.0%), average length is 27" in desc
125
+ assert "Field popularity, histogram is:" not in desc
126
+
127
+
128
+ def test_custom_pipe():
129
+ def transformer(source, sep=" "):
130
+ for i, line in enumerate(source):
131
+ res = f"{i}{sep}{line}"
132
+ yield res
133
+
134
+ data = ["hello", "world"]
135
+ assert get_output(transformer, data) == "0 hello\n1 world\n"
136
+ assert get_output(transformer, data, sep="_") == "0_hello\n1_world\n"
137
+
138
+
139
+ def test_open_read_write(tmp_path: Path):
140
+ def _lines(filename: Path) -> Sequence[str]:
141
+ # jsonql.lines calls open_read
142
+ return list(jsonql.lines(filename))
143
+
144
+ tmp = tmp_path
145
+ with jsonql.open_write(tmp / "a.txt") as o:
146
+ print("a", file=o)
147
+ assert _lines(tmp / "a.txt") == ["a"]
148
+
149
+ jsonql.write_jsons([{"a": 1}], tmp / "a.txt")
150
+ assert _lines(tmp / "a.txt") == ['{"a": 1}']
151
+
152
+ with jsonql.open_write(tmp / "a.gz") as o:
153
+ print("a", file=o)
154
+ assert _lines(tmp / "a.gz") == ["a"]
155
+
156
+ with jsonql.open_write([tmp / "a0.txt", tmp / "a1.txt"]) as o:
157
+ print("a", file=o)
158
+ assert _lines(tmp / "a0.txt") == ["a"]
159
+ assert not (tmp / "a1.txt").is_file()
160
+
161
+ with jsonql.open_write([tmp / "b0.txt", tmp / "b1.txt"], max_size="1k") as o:
162
+ print("0" * 2000, file=o)
163
+ print("1" * 2000, file=o)
164
+ assert _lines(tmp / "b0.txt") == ["0" * 2000]
165
+ assert _lines(tmp / "b1.txt") == ["1" * 2000]
166
+
167
+ with jsonql.open_write(tmp / "a_????.json") as o:
168
+ print("a", file=o)
169
+ assert _lines(tmp / "a_0000.json") == ["a"]
170
+ assert not (tmp / "a_0001.json").is_file()
171
+ assert _lines(tmp / "a_*.json") == ["a"]
172
+
173
+ with jsonql.open_write(tmp / "b_??.json", max_size="1k") as o:
174
+ print("0" * 2000, file=o)
175
+ print("1" * 2000, file=o)
176
+ assert _lines(tmp / "b_00.json") == ["0" * 2000]
177
+ assert _lines(tmp / "b_01.json") == ["1" * 2000]
178
+ assert _lines(tmp / "b_*.json") == ["0" * 2000, "1" * 2000]
179
+
180
+
181
+ def test_split_file(tmp_path: Path):
182
+ file = tmp_path / "test.txt"
183
+ content = "Hello\nWorld\n"
184
+
185
+ with open(file, "w") as o:
186
+ o.write(content)
187
+
188
+ with jsonql.SplitFile(file, chunk=0, n_chunks=2) as f:
189
+ assert f.readlines() == ["Hello\n"]
190
+
191
+ with jsonql.SplitFile(file, chunk=1, n_chunks=2) as f:
192
+ assert f.readlines() == ["World\n"]
193
+
194
+
195
+ def test_split_file_middle_of_line(tmp_path: Path):
196
+ file = tmp_path / "test.txt"
197
+ content = "Hello _|_\nWorld\n"
198
+ # split is here ^
199
+
200
+ with open(file, "w") as o:
201
+ o.write(content)
202
+
203
+ with jsonql.SplitFile(file, chunk=0, n_chunks=2) as f:
204
+ assert f.readlines() == ["Hello _|_\n"]
205
+
206
+ with jsonql.SplitFile(file, chunk=1, n_chunks=2) as f:
207
+ assert f.readlines() == ["World\n"]
208
+
209
+
210
+ def test_split_file_middle_of_char(tmp_path: Path):
211
+ file = tmp_path / "test.txt"
212
+ content = "Hello\U0001F40D\nWorld\n"
213
+ # split is here ^^
214
+
215
+ with open(file, "w") as o:
216
+ o.write(content)
217
+
218
+ with jsonql.SplitFile(file, chunk=0, n_chunks=2) as f:
219
+ assert f.readlines() == ["Hello🐍\n"]
220
+
221
+ with jsonql.SplitFile(file, chunk=1, n_chunks=2) as f:
222
+ assert f.readlines() == ["World\n"]
223
+
224
+
225
+ def test_blocked_gzip(tmp_path: Path):
226
+ file = tmp_path / "test.gz"
227
+ f = str(file)
228
+ # Each object is 10/11 bytes long. We have 2 of them by block.
229
+ content = ['{"xx": %d}' % i for i in range(80)]
230
+ with jsonql.BlockedGzipWriter(file, "wt", block_size="20B") as o:
231
+ for line in content:
232
+ print(line, file=o)
233
+
234
+ jr = jsonql.JsonReader(strict=True)
235
+ expected = list(jr.map(content))
236
+ # read as one file
237
+ assert expected == list(jsonql.read_jsons(file))
238
+ # read first block
239
+ assert expected[:2] == list(jsonql.read_jsons(f + "[0/40]"))
240
+ # read last block
241
+ assert expected[-2:] == list(jsonql.read_jsons(f + "[39/40]"))
242
+
243
+ readers = jsonql.get_block_readers(file, 9)
244
+ read_as_several_files = [list(jsonql.read_jsons(r)) for r in readers]
245
+ # 40 splits of 2 docs, 9 readers -> 5 splits, 10 docs per reader
246
+ assert list(jsonql.grouper(expected, 10)) == read_as_several_files
247
+
248
+
249
+ def test_enter_exit(capsys):
250
+ class MyTransformer(jsonql.Transformer):
251
+ def __enter__(self):
252
+ print("trans: started")
253
+ self.ready = True
254
+ return self
255
+
256
+ def __exit__(self, *args):
257
+ print("trans: done")
258
+
259
+ def do(self, x):
260
+ return (x, x)
261
+
262
+ def acc(values):
263
+ print("acc: started")
264
+ res = 0
265
+ for (x, _) in values:
266
+ res += int(x)
267
+ print("acc: done")
268
+ yield f"acc: result={res}"
269
+
270
+ t = MyTransformer()
271
+ data = (str(x) for x in range(10))
272
+ print("pipeline: started")
273
+ # Print to stdout.
274
+ jsonql.run_pipes(t, acc, file=data)
275
+ print("pipeline: done")
276
+ out = capsys.readouterr().out
277
+ assert (
278
+ "\n".join(
279
+ [
280
+ "pipeline: started",
281
+ "trans: started",
282
+ "acc: started",
283
+ "acc: done",
284
+ f"acc: result=45",
285
+ # Transformers are closed at the very end.
286
+ "trans: done",
287
+ "pipeline: done\n",
288
+ ]
289
+ )
290
+ == out
291
+ )
292
+
293
+
294
+ def test_write_to_stdout(capsys):
295
+ lines = [str(x) for x in range(10)]
296
+ jsonql.run_pipes(file=iter(lines))
297
+ out = capsys.readouterr().out
298
+ assert out == "\n".join(lines) + "\n"
299
+
300
+
301
+ def test_write_to_stdout_handle_newlines(capsys):
302
+ lines = [str(x) + "\n" for x in range(10)]
303
+ jsonql.run_pipes(file=iter(lines))
304
+ out = capsys.readouterr().out
305
+ assert out == "".join(lines)
306
+
307
+
308
+ def test_multiprocess(capsys):
309
+ mult = jsonql.Mapper(lambda x: f"2x = {2 * int(x)}")
310
+ jsonql.run_pipes(mult, processes=2, file=(str(x) for x in range(10)))
311
+ out = set(capsys.readouterr().out.strip("\n").split("\n"))
312
+ assert set(f"2x = {2 * x}" for x in range(10)) == out
cc-multilingual-main/cc_net/tests/test_minify.py ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import json
8
+ from pathlib import Path
9
+
10
+ import pytest
11
+
12
+ import cc_net
13
+ import cc_net.minify as minify
14
+ from cc_net import jsonql, process_wet_file
15
+ from cc_net.minify import (
16
+ HASH_SIZE,
17
+ decode_hashes,
18
+ encode_hashes,
19
+ encode_line_ids,
20
+ get_hashes,
21
+ )
22
+
23
+
24
+ def test_encode_decode():
25
+ sentences = ["Hello world !", "Is everyone happy in here ?"]
26
+ hashes = get_hashes(sentences)
27
+ assert all([len(h) == HASH_SIZE for h in hashes])
28
+ hashes_int = [minify._b2i(h) for h in hashes]
29
+ encoded = encode_hashes(hashes)
30
+ decoded = decode_hashes(encoded)
31
+ assert all([len(d) == HASH_SIZE for d in decoded])
32
+
33
+ decoded_int = [minify._b2i(d) for d in decoded]
34
+
35
+ assert hashes_int == decoded_int
36
+ assert hashes == decoded
37
+
38
+
39
+ def test_minify():
40
+ doc = {
41
+ "raw_content": "Hello world !\nIs everyone happy in here ?",
42
+ "language": "en",
43
+ "perplexity": 120.0,
44
+ "line_ids": [0, 4],
45
+ }
46
+ expected = {"line_ids": "AAAEAA==", "language": "en", "perplexity": 120.0}
47
+ minifier = minify.Minifier()
48
+ assert expected == minifier(doc)
49
+
50
+
51
+ @pytest.fixture
52
+ def http_from_disk(monkeypatch):
53
+ def read_sample_file(url: str, n_retry: int = 3) -> bytes:
54
+ expected_url = process_wet_file.WET_URL_ROOT + "/crawl-data/sample.warc.wet"
55
+ assert expected_url == url
56
+ file = Path(__file__).parent / "data" / "sample.warc.txt"
57
+ return file.read_bytes()
58
+
59
+ monkeypatch.setattr(cc_net.jsonql, "request_get_content", read_sample_file)
60
+
61
+
62
+ def test_minify_and_fetch(http_from_disk, tmp_path: Path):
63
+ full_quotes = """Don't part with your illusions. When they are gone you may still exist, but you have ceased to live.
64
+ Education: that which reveals to the wise, and conceals from the stupid, the vast limits of their knowledge.
65
+ Facts are stubborn things, but statistics are more pliable.
66
+ Fiction is obliged to stick to possibilities. Truth isn't."""
67
+ # We don't need no education.
68
+ chosen_quotes = "\n".join(
69
+ l for l in full_quotes.splitlines() if "Education" not in l
70
+ )
71
+
72
+ cc_doc = {
73
+ "url": "http://sample_english.com",
74
+ "date_download": "2019-03-18T00:00:00Z",
75
+ "digest": "sha1:XQZHW7QWIG54HVAV3KPRW6MK5ILDNCER",
76
+ "source_domain": "sample_english.com",
77
+ "title": "Famous Mark Twain Quotes",
78
+ "raw_content": full_quotes,
79
+ "cc_segment": "crawl-data/sample.warc.wet",
80
+ "nlines": 4,
81
+ "length": 353,
82
+ }
83
+
84
+ ccnet_metadata = {
85
+ "language": "en",
86
+ "language_score": 0.99,
87
+ "perplexity": 151.5,
88
+ "bucket": "head",
89
+ "raw_content": chosen_quotes,
90
+ "nlines": 3,
91
+ "length": len(chosen_quotes),
92
+ "original_nlines": 4,
93
+ "original_length": 353,
94
+ "line_ids": [0, 2, 3],
95
+ }
96
+ ccnet_doc = dict(cc_doc, **ccnet_metadata)
97
+ mini = minify.Minifier()(ccnet_doc.copy())
98
+ assert mini is not ccnet_doc
99
+
100
+ important_fields = [
101
+ "url",
102
+ "digest",
103
+ "cc_segment",
104
+ "language",
105
+ "language_score",
106
+ "perplexity",
107
+ "bucket",
108
+ "line_ids",
109
+ ]
110
+ expected = {k: ccnet_doc[k] for k in important_fields}
111
+ expected["line_ids"] = encode_line_ids(expected["line_ids"]) # type: ignore
112
+ assert expected == mini
113
+
114
+ with jsonql.open_write(tmp_path / "sample.json") as o:
115
+ print(json.dumps(mini), file=o)
116
+ fetcher = minify.MetadataFetcher(tmp_path)
117
+ # line_ids is removed when unminifying
118
+ ccnet_doc.pop("line_ids")
119
+ assert ccnet_doc == fetcher(cc_doc)
120
+
121
+
122
+ def test_fetch(http_from_disk, tmp_path: Path):
123
+ mini_docs = [
124
+ {
125
+ "url": "http://sample_chinese.com",
126
+ "digest": "sha1:Y4E6URVYGIAFNVRTPZ5S3J64RTZTP6HJ",
127
+ "cc_segment": "crawl-data/sample.warc.wet",
128
+ "line_ids": encode_line_ids([2]),
129
+ "bucket": "not_that_great",
130
+ },
131
+ {
132
+ "url": "http://sample_english.com",
133
+ "digest": "sha1:XQZHW7QWIG54HVAV3KPRW6MK5ILDNCER",
134
+ "cc_segment": "crawl-data/sample.warc.wet",
135
+ "line_ids": encode_line_ids([3]),
136
+ "bucket": "top_notch",
137
+ },
138
+ ]
139
+ with jsonql.open_write(tmp_path / "sample.json") as o:
140
+ for mini in mini_docs:
141
+ print(json.dumps(mini), file=o)
142
+
143
+ fetcher = minify.MetadataFetcher(tmp_path)
144
+ cc = process_wet_file.CCSegmentsReader(["crawl-data/sample.warc.wet"])
145
+ docs = [d for d in fetcher.map(cc) if d is not None]
146
+ assert cc.retrieved_segments == 1
147
+
148
+ # Note: documents are retrieved as they are ordered in the .warc.wet file
149
+ assert [
150
+ "Facts are stubborn things, but statistics are more pliable.",
151
+ "事實是固執的東西,但統計數字卻比較柔和。",
152
+ ] == [d["raw_content"] for d in docs]
153
+ assert ["top_notch", "not_that_great"] == [d["bucket"] for d in docs]
cc-multilingual-main/cc_net/tests/test_normalizer.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import cc_net.text_normalizer as txt
8
+
9
+
10
+ def test_unicode_punct():
11
+ weird = ",。、„”“«»1」「《》´∶:?!();–—.~’…━〈〉【】%"
12
+ replaced = ',.,""""""""""\'::?!();- - . ~\'...-<>[]%'
13
+ assert txt.replace_unicode_punct(weird) == replaced
14
+
15
+ assert txt.remove_unicode_punct(weird) == ""
16
+
17
+
18
+ def test_numbers():
19
+ weird = "023456789 | 0123456789"
20
+ normalized = "000000000 | 0000000000"
21
+ assert txt.normalize(weird, numbers=True) == normalized
22
+ assert txt.normalize(weird, numbers=False) == weird
23
+
24
+
25
+ def test_normalize_for_dedup():
26
+ weird = "023´∶:\x10 | ;012 hèllo"
27
+ normalized = "000 | ;000 hèllo"
28
+ assert normalized == txt.slow_normalize_for_dedup(weird)
29
+ assert normalized == txt.normalize_for_dedup(weird)
cc-multilingual-main/cc_net/tests/test_parse_wet_file.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ from pathlib import Path
8
+
9
+ from cc_net import process_wet_file
10
+
11
+
12
+ def test_parsing():
13
+ sample = Path(__file__).parent / "data" / "sample.warc.txt"
14
+ with open(sample) as f:
15
+ documents = list(process_wet_file.parse_warc_file(f))
16
+
17
+ expected_urls = [
18
+ "http://sample_english.com",
19
+ "http://sample_chinese.zh",
20
+ "http://sample_russian.ru",
21
+ ]
22
+ assert expected_urls == [d["url"] for d in documents]
23
+ expected_domains = ["sample_english.com", "sample_chinese.zh", "sample_russian.ru"]
24
+ assert expected_domains == [d["source_domain"] for d in documents]
25
+
26
+ expected_date = [
27
+ "2019-03-18T00:00:00Z",
28
+ "2019-03-18T00:00:01Z",
29
+ "2019-03-18T00:00:02Z",
30
+ ]
31
+ assert expected_date == [d["date_download"] for d in documents]
32
+
33
+ expected_title = [
34
+ "Famous Mark Twain Quotes",
35
+ "馬克·吐溫名言",
36
+ "Цитаты знаменитого Марка Твена",
37
+ ]
38
+ assert expected_title == [d["title"] for d in documents]
39
+
40
+ expected_quotes = """Don't part with your illusions. When they are gone you may still exist, but you have ceased to live.
41
+ Education: that which reveals to the wise, and conceals from the stupid, the vast limits of their knowledge.
42
+
43
+ Facts are stubborn things, but statistics are more pliable.
44
+ Fiction is obliged to stick to possibilities. Truth isn't.
45
+ """
46
+
47
+ assert expected_quotes == documents[0]["raw_content"]
cc-multilingual-main/cc_net/tests/test_regroup.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import time
8
+
9
+ from cc_net import jsonql, regroup
10
+
11
+
12
+ def check_regroup(tmp_path, regroup_fn, check_blocks_boundaries=False):
13
+ n_shards = 4
14
+ n_docs = 20
15
+ shards = [
16
+ [dict(id=i, shard=s, raw_content="hello world") for i in range(n_docs)]
17
+ for s in range(n_shards)
18
+ ]
19
+ shards_files = [tmp_path / f"{s:04d}.json.gz" for s in range(n_shards)]
20
+ for shard, shard_file in zip(shards, shards_files):
21
+ jsonql.run_pipes(inputs=shard, output=shard_file)
22
+ regroup_file = tmp_path / "regroup.json.gz"
23
+ start = time.time()
24
+ regroup_fn(shards_files, regroup_file)
25
+ duration = time.time() - start
26
+ print(f"{regroup_fn.__module__}.{regroup_fn.__name__} took {duration}s")
27
+
28
+ regrouped = list(jsonql.read_jsons(regroup_file))
29
+ assert [doc for shard in shards for doc in shard] == regrouped
30
+
31
+ readers = jsonql.get_block_readers(regroup_file, n_shards)
32
+ if not check_blocks_boundaries:
33
+ assert [doc for shard in shards for doc in shard] == [
34
+ doc for reader in readers for doc in jsonql.read_jsons(reader)
35
+ ]
36
+ return
37
+
38
+ for shard, reader in zip(shards, readers):
39
+ block = [doc for doc in jsonql.read_jsons(reader)]
40
+ assert shard == block
41
+
42
+
43
+ def test_regroup(tmp_path):
44
+ # With regroup boundaries will be every 256Mb.
45
+ check_regroup(tmp_path, regroup.reshard, check_blocks_boundaries=False)
46
+
47
+
48
+ def test_fast_regroup(tmp_path):
49
+ # With fast regroup boundaries should match the shards.
50
+ check_regroup(tmp_path, regroup.fast_reshard, check_blocks_boundaries=True)
cc-multilingual-main/cc_net/tests/test_transformer.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ #
6
+
7
+ import inspect
8
+ import pickle
9
+ from pathlib import Path
10
+
11
+ import pytest
12
+
13
+ from cc_net import dedup, jsonql, perplexity, split_by_lang, tokenizer
14
+
15
+
16
+ def get_transformers(module):
17
+ return [
18
+ v
19
+ for v in vars(module).values()
20
+ if type(v) is type
21
+ and issubclass(v, jsonql.Transformer)
22
+ and v != jsonql.Transformer
23
+ ]
24
+
25
+
26
+ ALL_TRANSFORMERS = (
27
+ get_transformers(jsonql)
28
+ + get_transformers(dedup)
29
+ + get_transformers(perplexity)
30
+ + get_transformers(tokenizer)
31
+ + get_transformers(split_by_lang)
32
+ )
33
+
34
+
35
+ def check_transformer_is_calling_super_init(cls: type):
36
+ assert issubclass(cls, jsonql.Transformer)
37
+ # accessing __init__ is generally an error, but here we do want to inspect
38
+ # the __init__method.
39
+ code = inspect.getsource(cls.__init__) # type: ignore
40
+ code = code.replace(" ", "")
41
+
42
+ # Check that super().__init__ is called.
43
+ assert "super().__init__()" in code
44
+
45
+
46
+ def test_bad_transformers_are_caught():
47
+ class BadTransformer(jsonql.Transformer):
48
+ def __init__(self, arg):
49
+ # We aren't calling super /!\
50
+ self.arg = arg
51
+
52
+ with pytest.raises(AssertionError):
53
+ check_transformer_is_calling_super_init(BadTransformer)
54
+
55
+
56
+ @pytest.mark.parametrize("transformer", ALL_TRANSFORMERS)
57
+ def test_transformer_is_correctly_implemented(transformer):
58
+ check_transformer_is_calling_super_init(transformer)
59
+
60
+
61
+ @pytest.mark.skipif(
62
+ not Path("bin/lid.bin").exists(), reason="bin/lid.bin not found, run `make install`"
63
+ )
64
+ def test_can_pickle_transformer(tmp_path):
65
+ model = Path("bin/lid.bin")
66
+ if not model.exists():
67
+ return
68
+ classifier = split_by_lang.Classifier(model, "text", "lang")
69
+ classifier.__enter__()
70
+ doc = dict(text="Hello world ! This is English btw.")
71
+ original_results = classifier(doc)
72
+
73
+ with open(tmp_path / "transformer.pkl", "wb") as o:
74
+ pickle.dump(classifier, o)
75
+ with open(tmp_path / "transformer.pkl", "rb") as f:
76
+ classifier = pickle.load(f)
77
+
78
+ assert original_results == classifier(doc)
79
+
80
+ # Do it again with the unpickled object.
81
+ with open(tmp_path / "transformer.pkl", "wb") as o:
82
+ pickle.dump(classifier, o)
83
+ with open(tmp_path / "transformer.pkl", "rb") as f:
84
+ classifier = pickle.load(f)
85
+
86
+ assert original_results == classifier(doc)
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_acquire_msys.cmake ADDED
@@ -0,0 +1,644 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Full mirror list: https://github.com/msys2/MSYS2-packages/blob/master/pacman-mirrors/mirrorlist.msys
2
+ set(Z_VCPKG_ACQUIRE_MSYS_MIRRORS
3
+ # Alternative primary
4
+ "https://repo.msys2.org/"
5
+ # Tier 1
6
+ "https://mirror.yandex.ru/mirrors/msys2/"
7
+ "https://mirrors.tuna.tsinghua.edu.cn/msys2/"
8
+ "https://mirrors.ustc.edu.cn/msys2/"
9
+ "https://mirror.selfnet.de/msys2/"
10
+ )
11
+
12
+ # Downloads the given package
13
+ function(z_vcpkg_acquire_msys_download_package out_archive)
14
+ cmake_parse_arguments(PARSE_ARGV 1 "arg" "" "URL;SHA512;FILENAME" "")
15
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
16
+ message(FATAL_ERROR "internal error: z_vcpkg_acquire_msys_download_package passed extra args: ${arg_UNPARSED_ARGUMENTS}")
17
+ endif()
18
+
19
+ string(REPLACE "https://repo.msys2.org/" "https://mirror.msys2.org/" all_urls "${arg_URL}")
20
+ foreach(mirror IN LISTS Z_VCPKG_ACQUIRE_MSYS_MIRRORS)
21
+ string(REPLACE "https://mirror.msys2.org/" "${mirror}" mirror_url "${arg_URL}")
22
+ list(APPEND all_urls "${mirror_url}")
23
+ endforeach()
24
+
25
+ vcpkg_download_distfile(msys_archive
26
+ URLS ${all_urls}
27
+ SHA512 "${arg_SHA512}"
28
+ FILENAME "${arg_FILENAME}"
29
+ QUIET
30
+ )
31
+ set("${out_archive}" "${msys_archive}" PARENT_SCOPE)
32
+ endfunction()
33
+
34
+ # Declares a package
35
+ # Writes to the following cache variables:
36
+ # - Z_VCPKG_MSYS_PACKAGES_AVAILABLE
37
+ # - Z_VCPKG_MSYS_${arg_NAME}_URL
38
+ # - Z_VCPKG_MSYS_${arg_NAME}_SHA512
39
+ # - Z_VCPKG_MSYS_${arg_NAME}_FILENAME
40
+ # - Z_VCPKG_MSYS_${arg_NAME}_DEPS
41
+ # - Z_VCPKG_MSYS_${arg_NAME}_PATCHES
42
+ # - Z_VCPKG_MSYS_${arg_NAME}_DIRECT
43
+ # - Z_VCPKG_MSYS_${arg_NAME}_PROVIDES
44
+ # - Z_VCPKG_MSYS_${alias}_PROVIDED_BY
45
+ function(z_vcpkg_acquire_msys_declare_package)
46
+ cmake_parse_arguments(PARSE_ARGV 0 arg "DIRECT" "NAME;URL;SHA512" "DEPS;PATCHES;PROVIDES")
47
+
48
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
49
+ message(FATAL_ERROR "internal error: z_vcpkg_acquire_msys_declare_package passed extra args: ${arg_UNPARSED_ARGUMENTS}")
50
+ endif()
51
+ foreach(required_arg IN ITEMS URL SHA512)
52
+ if(NOT DEFINED arg_${required_arg})
53
+ message(FATAL_ERROR "internal error: z_vcpkg_acquire_msys_declare_package requires argument: ${required_arg}")
54
+ endif()
55
+ endforeach()
56
+
57
+ if(arg_DIRECT)
58
+ if(NOT arg_NAME)
59
+ message(FATAL_ERROR "internal error: z_vcpkg_acquire_msys_declare_package requires argument: NAME")
60
+ endif()
61
+ get_filename_component(filename "${arg_URL}" NAME)
62
+ else()
63
+ if(NOT arg_URL MATCHES [[^https://mirror\.msys2\.org/.*/(([^/]*)-[^-/]+-[^-/]+-[^-/]+\.pkg\.tar\.(xz|zst))$]])
64
+ message(FATAL_ERROR "internal error: regex does not match supplied URL to vcpkg_acquire_msys: ${arg_URL}")
65
+ endif()
66
+ set(filename "msys2-${CMAKE_MATCH_1}")
67
+ if(NOT DEFINED arg_NAME)
68
+ set(arg_NAME "${CMAKE_MATCH_2}")
69
+ endif()
70
+ if(Z_VCPKG_MSYS_${arg_NAME}_DIRECT)
71
+ return()
72
+ endif()
73
+ if(arg_NAME IN_LIST Z_VCPKG_MSYS_PACKAGES_AVAILABLE)
74
+ message(FATAL_ERROR "Redeclaration of package '${arg_NAME}'")
75
+ endif()
76
+ endif()
77
+
78
+ list(APPEND Z_VCPKG_MSYS_PACKAGES_AVAILABLE "${arg_NAME}")
79
+ set(Z_VCPKG_MSYS_PACKAGES_AVAILABLE "${Z_VCPKG_MSYS_PACKAGES_AVAILABLE}" CACHE INTERNAL "")
80
+ set(Z_VCPKG_MSYS_${arg_NAME}_URL "${arg_URL}" CACHE INTERNAL "")
81
+ set(Z_VCPKG_MSYS_${arg_NAME}_SHA512 "${arg_SHA512}" CACHE INTERNAL "")
82
+ set(Z_VCPKG_MSYS_${arg_NAME}_FILENAME "${filename}" CACHE INTERNAL "")
83
+ set(Z_VCPKG_MSYS_${arg_NAME}_DEPS "${arg_DEPS}" CACHE INTERNAL "")
84
+ set(Z_VCPKG_MSYS_${arg_NAME}_PATCHES "${arg_PATCHES}" CACHE INTERNAL "")
85
+ set(Z_VCPKG_MSYS_${arg_NAME}_DIRECT "${arg_DIRECT}" CACHE INTERNAL "")
86
+ set(Z_VCPKG_MSYS_${arg_NAME}_PROVIDES "${arg_PROVIDES}" CACHE INTERNAL "")
87
+ foreach(name IN LISTS arg_PROVIDES)
88
+ set(Z_VCPKG_MSYS_${name}_PROVIDED_BY "${arg_NAME}" CACHE INTERNAL "")
89
+ endforeach()
90
+ endfunction()
91
+
92
+ # Collects all required packages to satisfy the given input set
93
+ # Writes to the following cache variables:
94
+ # - Z_VCPKG_MSYS_<name>_ARCHIVE
95
+ function(z_vcpkg_acquire_msys_download_packages)
96
+ cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "OUT_UNKNOWN;OUT_RESOLVED" "PACKAGES")
97
+ set(backlog "${arg_PACKAGES}")
98
+ list(REMOVE_DUPLICATES backlog)
99
+
100
+ list(FILTER arg_PACKAGES EXCLUDE REGEX "^mingw64")
101
+ if(NOT arg_PACKAGES STREQUAL "" AND NOT "msys2-runtime" IN_LIST arg_PACKAGES)
102
+ list(APPEND backlog "msys2-runtime")
103
+ endif()
104
+
105
+ set(unknown "")
106
+ set(resolved "")
107
+ set(need_msys_runtime 0)
108
+ while(NOT backlog STREQUAL "")
109
+ list(POP_FRONT backlog name)
110
+ if(DEFINED Z_VCPKG_MSYS_${name}_PROVIDED_BY AND NOT name IN_LIST Z_VCPKG_MSYS_PACKAGES_AVAILABLE)
111
+ set(name "${Z_VCPKG_MSYS_${name}_PROVIDED_BY}")
112
+ if(name IN_LIST resolved)
113
+ continue()
114
+ endif()
115
+ endif()
116
+ if(NOT name IN_LIST Z_VCPKG_MSYS_PACKAGES_AVAILABLE)
117
+ list(APPEND unknown "${name}")
118
+ continue()
119
+ endif()
120
+ list(APPEND resolved "${name}")
121
+ list(REMOVE_ITEM Z_VCPKG_MSYS_${name}_DEPS ${resolved} ${backlog})
122
+ list(APPEND backlog ${Z_VCPKG_MSYS_${name}_DEPS})
123
+
124
+ z_vcpkg_acquire_msys_download_package(archive
125
+ URL "${Z_VCPKG_MSYS_${name}_URL}"
126
+ SHA512 "${Z_VCPKG_MSYS_${name}_SHA512}"
127
+ FILENAME "${Z_VCPKG_MSYS_${name}_FILENAME}"
128
+ )
129
+ set(Z_VCPKG_MSYS_${name}_ARCHIVE "${archive}" CACHE INTERNAL "")
130
+ endwhile()
131
+ if(DEFINED arg_OUT_UNKNOWN)
132
+ set("${arg_OUT_UNKNOWN}" "${unknown}" PARENT_SCOPE)
133
+ endif()
134
+ if(DEFINED arg_OUT_RESOLVED)
135
+ set("${arg_OUT_RESOLVED}" "${resolved}" PARENT_SCOPE)
136
+ endif()
137
+ endfunction()
138
+
139
+ # Returns a stable collection of hashes, regardless of package order
140
+ function(z_vcpkg_acquire_msys_collect_hashes out_hash)
141
+ cmake_parse_arguments(PARSE_ARGV 1 "arg" "" "" "PACKAGES")
142
+ list(SORT arg_PACKAGES)
143
+ set(result "")
144
+ foreach(name IN LISTS arg_PACKAGES)
145
+ if(NOT DEFINED Z_VCPKG_MSYS_${name}_SHA512)
146
+ message(FATAL_ERROR "SHA512 unknown for '${name}'.")
147
+ endif()
148
+ string(APPEND result "${Z_VCPKG_MSYS_${name}_SHA512}")
149
+ foreach(patch IN LISTS Z_VCPKG_MSYS_${name}_PATCHES)
150
+ file(SHA512 "${patch}" patch_sha)
151
+ string(APPEND result "${patch_sha}")
152
+ endforeach()
153
+ endforeach()
154
+ set(${out_hash} "${result}" PARENT_SCOPE)
155
+ endfunction()
156
+
157
+ function(vcpkg_acquire_msys out_msys_root)
158
+ cmake_parse_arguments(PARSE_ARGV 1 "arg"
159
+ "NO_DEFAULT_PACKAGES;Z_ALL_PACKAGES"
160
+ "Z_DECLARE_EXTRA_PACKAGES_COMMAND"
161
+ "PACKAGES;DIRECT_PACKAGES"
162
+ )
163
+
164
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
165
+ message(WARNING "vcpkg_acquire_msys was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
166
+ endif()
167
+
168
+ z_vcpkg_acquire_msys_declare_all_packages()
169
+ if(NOT "${arg_Z_DECLARE_EXTRA_PACKAGES_COMMAND}" STREQUAL "")
170
+ cmake_language(CALL "${arg_Z_DECLARE_EXTRA_PACKAGES_COMMAND}")
171
+ endif()
172
+ set(requested "${arg_PACKAGES}")
173
+ if(arg_Z_ALL_PACKAGES)
174
+ set(requested "${Z_VCPKG_MSYS_PACKAGES_AVAILABLE}")
175
+ elseif(NOT arg_NO_DEFAULT_PACKAGES)
176
+ list(APPEND requested bash coreutils file gawk grep gzip diffutils make pkgconf sed)
177
+ endif()
178
+
179
+ if(DEFINED arg_DIRECT_PACKAGES AND NOT arg_DIRECT_PACKAGES STREQUAL "")
180
+ list(LENGTH arg_DIRECT_PACKAGES direct_packages_length)
181
+ math(EXPR direct_packages_parity "${direct_packages_length} % 2")
182
+ math(EXPR direct_packages_number "${direct_packages_length} / 2")
183
+ math(EXPR direct_packages_last "${direct_packages_number} - 1")
184
+
185
+ if(direct_packages_parity EQUAL 1)
186
+ message(FATAL_ERROR "vcpkg_acquire_msys(... DIRECT_PACKAGES ...) requires exactly pairs of URL/SHA512")
187
+ endif()
188
+
189
+ set(direct_packages "")
190
+ # direct_packages_last > direct_packages_number - 1 > 0 - 1 >= 0, so this is fine
191
+ foreach(index RANGE "${direct_packages_last}")
192
+ math(EXPR url_index "${index} * 2")
193
+ math(EXPR sha512_index "${url_index} + 1")
194
+ list(GET arg_DIRECT_PACKAGES "${url_index}" url)
195
+ list(GET arg_DIRECT_PACKAGES "${sha512_index}" sha512)
196
+ get_filename_component(filename "${url}" NAME)
197
+ if(NOT filename MATCHES "^(.*)-[^-]+-[^-]+-[^-]+\.pkg\.tar\..*$")
198
+ message(FATAL_ERROR "Cannot determine package name for '${filename}'")
199
+ endif()
200
+ set(pkg_name "${CMAKE_MATCH_1}")
201
+ z_vcpkg_acquire_msys_declare_package(
202
+ NAME "${pkg_name}"
203
+ URL "${url}"
204
+ SHA512 "${sha512}"
205
+ DIRECT
206
+ )
207
+ list(APPEND direct_packages "${pkg_name}")
208
+ endforeach()
209
+ list(INSERT requested 0 ${direct_packages})
210
+ endif()
211
+
212
+ z_vcpkg_acquire_msys_download_packages(
213
+ PACKAGES ${requested}
214
+ OUT_RESOLVED resolved
215
+ OUT_UNKNOWN unknown
216
+ )
217
+ if(NOT unknown STREQUAL "")
218
+ message(FATAL_ERROR "Unknown packages were required for vcpkg_acquire_msys(${requested}): ${unknown}
219
+ This can be resolved by explicitly passing URL/SHA pairs to DIRECT_PACKAGES.")
220
+ endif()
221
+ set(Z_VCPKG_MSYS_PACKAGES_RESOLVED "${resolved}" CACHE INTERNAL "Export for CI")
222
+
223
+ z_vcpkg_acquire_msys_collect_hashes(hashes PACKAGES ${resolved})
224
+ string(SHA512 total_hash "${hashes}")
225
+ string(SUBSTRING "${total_hash}" 0 16 total_hash)
226
+ set(path_to_root "${DOWNLOADS}/tools/msys2/${total_hash}")
227
+
228
+ if(NOT EXISTS "${path_to_root}")
229
+ file(REMOVE_RECURSE "${path_to_root}.tmp")
230
+ file(MAKE_DIRECTORY "${path_to_root}.tmp/tmp")
231
+ foreach(name IN LISTS resolved)
232
+ file(ARCHIVE_EXTRACT
233
+ INPUT "${Z_VCPKG_MSYS_${name}_ARCHIVE}"
234
+ DESTINATION "${path_to_root}.tmp"
235
+ )
236
+ if(Z_VCPKG_MSYS_${name}_PATCHES)
237
+ z_vcpkg_apply_patches(
238
+ SOURCE_PATH "${path_to_root}.tmp"
239
+ PATCHES ${Z_VCPKG_MSYS_${name}_PATCHES}
240
+ )
241
+ endif()
242
+ endforeach()
243
+ file(RENAME "${path_to_root}.tmp" "${path_to_root}")
244
+ endif()
245
+ # Due to skipping the regular MSYS2 installer,
246
+ # some config files need to be established explicitly.
247
+ if(NOT EXISTS "${path_to_root}/etc/fstab")
248
+ # This fstab entry removes the cygdrive prefix from paths.
249
+ file(WRITE "${path_to_root}/etc/fstab" "none / cygdrive binary,posix=0,noacl,user 0 0")
250
+ endif()
251
+ message(STATUS "Using msys root at ${path_to_root}")
252
+ set("${out_msys_root}" "${path_to_root}" PARENT_SCOPE)
253
+ endfunction()
254
+
255
+ # Expand this while CMAKE_CURRENT_LIST_DIR is for this file.
256
+ set(Z_VCPKG_AUTOMAKE_CLANG_CL_PATCH "${CMAKE_CURRENT_LIST_DIR}/compile_wrapper_consider_clang-cl.patch")
257
+
258
+ macro(z_vcpkg_acquire_msys_declare_all_packages)
259
+ set(Z_VCPKG_MSYS_PACKAGES_AVAILABLE "" CACHE INTERNAL "")
260
+
261
+ # The following list can be updated via test port vcpkg-ci-msys2[update-all].
262
+ # Upstream binary package information is available via
263
+ # https://packages.msys2.org/search?t=binpkg&q=<Pkg>
264
+
265
+ # msys subsystem
266
+ z_vcpkg_acquire_msys_declare_package(
267
+ URL "https://mirror.msys2.org/msys/x86_64/autoconf-wrapper-20221207-1-any.pkg.tar.zst"
268
+ SHA512 601ceb483ddf49d744ed7e365317d64777752e35010a1087082452afd42d8d29fc5331cb3fa4654eb09eec85416c8c5b70fed91a45acfaa667f06f80e6d42f30
269
+ PROVIDES autoconf
270
+ DEPS autoconf2.71 bash sed
271
+ )
272
+ z_vcpkg_acquire_msys_declare_package(
273
+ URL "https://mirror.msys2.org/msys/x86_64/autoconf2.71-2.71-3-any.pkg.tar.zst"
274
+ SHA512 dd312c428b2e19afd00899eb53ea4255794dea4c19d1d6dea2419cb6a54209ea2130d48abbc20af12196b9f628143436f736fbf889809c2c2291be0c69c0e306
275
+ DEPS awk bash diffutils m4 perl sed
276
+ )
277
+ z_vcpkg_acquire_msys_declare_package(
278
+ URL "https://mirror.msys2.org/msys/x86_64/autoconf-archive-2023.02.20-1-any.pkg.tar.zst"
279
+ SHA512 0dbdba67934402eeb974e6738eb9857d013342b4e3a11200710b87fbf085d5bebf49b29b6a14b6ff2511b126549919a375b68f19cc22aa18f6ba23c57290ac72
280
+ )
281
+ z_vcpkg_acquire_msys_declare_package(
282
+ URL "https://mirror.msys2.org/msys/x86_64/automake-wrapper-20221207-2-any.pkg.tar.zst"
283
+ SHA512 4351c607edcf00df055b1310a790e41a63c575fbd80a6888d3693b88cad31d4628f9b96f849e319089893c826cf4473d9b31206d7ccb4cea15fd05b6b0ccb582
284
+ PROVIDES automake
285
+ DEPS automake1.16 bash gawk
286
+ )
287
+ z_vcpkg_acquire_msys_declare_package(
288
+ URL "https://mirror.msys2.org/msys/x86_64/automake1.16-1.16.5-1-any.pkg.tar.zst"
289
+ SHA512 62c9dfe28d6f1d60310f49319723862d29fc1a49f7be82513a4bf1e2187ecd4023086faf9914ddb6701c7c1e066ac852c0209db2c058f3865910035372a4840a
290
+ DEPS bash perl
291
+ PATCHES "${Z_VCPKG_AUTOMAKE_CLANG_CL_PATCH}"
292
+ )
293
+ z_vcpkg_acquire_msys_declare_package(
294
+ URL "https://mirror.msys2.org/msys/x86_64/bash-5.2.026-1-x86_64.pkg.tar.zst"
295
+ SHA512 f69046b27b0ecec6afc60b3ba107491c50c70f6f41b989fe6fcc58da798345cb8336ff6cc668bc13ee49ff24d3be4b5932bc8fe87e80da4e6243063c18f0dcf8
296
+ PROVIDES sh
297
+ )
298
+ z_vcpkg_acquire_msys_declare_package(
299
+ URL "https://mirror.msys2.org/msys/x86_64/binutils-2.42-1-x86_64.pkg.tar.zst"
300
+ SHA512 6e12fbb6e7a14bac5cf3665d0e9867d40ef47ba76d4887748671e46e9ea288dbfc59b40461e6552559aa24651a057c18c022d2f24d679edfc42d8ca7e43af28d
301
+ DEPS libiconv libintl zlib
302
+ )
303
+ z_vcpkg_acquire_msys_declare_package(
304
+ URL "https://mirror.msys2.org/msys/x86_64/bzip2-1.0.8-4-x86_64.pkg.tar.zst"
305
+ SHA512 1d2ce42c6775c0cb0fe9c2863c975fd076579131d0a5bce907355315f357df4ee66869c9c58325f5b698f3aba2413b2823deda86dd27fdb6e2e5e5d4de045259
306
+ DEPS libbz2
307
+ )
308
+ z_vcpkg_acquire_msys_declare_package(
309
+ URL "https://mirror.msys2.org/msys/x86_64/coreutils-8.32-5-x86_64.pkg.tar.zst"
310
+ SHA512 63f99348e654440458f26e9f52ae3289759a5a03428cf2fcf5ac7b47fdf7bf7f51d08e3346f074a21102bee6fa0aeaf88b8ebeba1e1f02a45c8f98f69c8db59c
311
+ DEPS libiconv libintl gmp
312
+ )
313
+ z_vcpkg_acquire_msys_declare_package(
314
+ URL "https://mirror.msys2.org/msys/x86_64/diffutils-3.10-1-x86_64.pkg.tar.zst"
315
+ SHA512 7ed406370a699be98bff4eeb156a063de80ac8e332fb1873639e0b95b2e72e626351e24c5ca0021af9c0e56c4a3d91bd6669e6245b21c9d4ebdbb36888d8e39d
316
+ DEPS libiconv libintl sh
317
+ )
318
+ z_vcpkg_acquire_msys_declare_package(
319
+ URL "https://mirror.msys2.org/msys/x86_64/file-5.45-1-x86_64.pkg.tar.zst"
320
+ SHA512 fae01c7e2c88357be024aa09dba7b805d596cec7cde5c29a46c3ab209c67de64a005887e346edaad84b5173c033cb6618997d864f7fad4a7555bd38a3f7831c5
321
+ DEPS gcc-libs libbz2 liblzma libzstd zlib
322
+ )
323
+ z_vcpkg_acquire_msys_declare_package(
324
+ URL "https://mirror.msys2.org/msys/x86_64/findutils-4.9.0-3-x86_64.pkg.tar.zst"
325
+ SHA512 1538733929ecc11bc7c19797577e4cd59cc88499b375e3c2ea4a8ed4d66a1a02f4468ff916046c76195ba92f4c591d0e351371768117a423595d2e43b3321aad
326
+ DEPS libintl libiconv
327
+ )
328
+ z_vcpkg_acquire_msys_declare_package(
329
+ URL "https://mirror.msys2.org/msys/x86_64/gawk-5.3.0-1-x86_64.pkg.tar.zst"
330
+ SHA512 01a65153ffa109c51f05ef014534feecde9fc3e83ab4f5fc7f0ae957ea8a0bad2756fc65a86e20ab87a063c92161f7a7fccc8232b51c44c6ee506b7cff3762e7
331
+ PROVIDES awk
332
+ DEPS libintl libreadline mpfr sh
333
+ )
334
+ z_vcpkg_acquire_msys_declare_package(
335
+ URL "https://mirror.msys2.org/msys/x86_64/gcc-libs-13.2.0-2-x86_64.pkg.tar.zst" # 05-Jul-2022
336
+ SHA512 0bf8d56516ed7f14db2d1a991ccced0977d33a560f1844b114b62b2cd93d96374d3b85c5257adc0c4f141c3f3533bc4e8914349547092d607c22dea3bdbbbd0d
337
+ )
338
+ z_vcpkg_acquire_msys_declare_package(
339
+ URL "https://mirror.msys2.org/msys/x86_64/gettext-0.22.4-1-x86_64.pkg.tar.zst"
340
+ SHA512 7bd1dc50df8a973a075286fdf115fa30c8a78aa23d2845e2bdeb6068bf3391321d9b3ce3241626453bb660d1a57563bea44eebadf81cb2f98f15fbaf266648ec
341
+ DEPS libasprintf libgettextpo libintl
342
+ )
343
+ # This package shouldn't be a here
344
+ z_vcpkg_acquire_msys_declare_package(
345
+ URL "https://mirror.msys2.org/msys/x86_64/gettext-devel-0.22.4-1-x86_64.pkg.tar.zst"
346
+ SHA512 e7748736014b0aa47f2bc740189a5e8e1bcc99a82ccd02d6f75e226b041704e4f353107df175c0547651a05f5a352ec474a7af693fb33d42a8885e47ac371d2e
347
+ DEPS gettext # libiconv-devel
348
+ )
349
+ z_vcpkg_acquire_msys_declare_package(
350
+ URL "https://mirror.msys2.org/msys/x86_64/gmp-6.3.0-1-x86_64.pkg.tar.zst"
351
+ SHA512 d4e8549e55d4088eca30753f867bf82d9287955209766f488f2a07ecc71bc63ef2c50fcc9d47470ea3b0d2f149f1648d9c2453e366e3eb2c2e2d60939f311a40
352
+ )
353
+ z_vcpkg_acquire_msys_declare_package(
354
+ URL "https://mirror.msys2.org/msys/x86_64/grep-1~3.0-6-x86_64.pkg.tar.zst"
355
+ SHA512 79b4c652082db04c2ca8a46ed43a86d74c47112932802b7c463469d2b73e731003adb1daf06b08cf75dc1087f0e2cdfa6fec0e8386ada47714b4cff8a2d841e1
356
+ DEPS libiconv libintl libpcre sh
357
+ )
358
+ z_vcpkg_acquire_msys_declare_package(
359
+ URL "https://mirror.msys2.org/msys/x86_64/gzip-1.13-1-x86_64.pkg.tar.zst"
360
+ SHA512 4dbcfe5df7c213b10f003fc2a15123a5ed0d1a6d09638c467098f7b7db2e4fdd75a7ceee03b3a26c2492ae485267d626db981c5b9167e3acb3d7436de97d0e97
361
+ DEPS bash
362
+ )
363
+ z_vcpkg_acquire_msys_declare_package(
364
+ URL "https://mirror.msys2.org/msys/x86_64/libasprintf-0.22.4-1-x86_64.pkg.tar.zst"
365
+ SHA512 06f353d2020d1e7168f4084e9fc17856a158a67a61098314e4b1d7db075542eb29dfe8a84bd154dad28942ee8eaae1e13a6510a4d2caab4509d9f3ea22db6d87
366
+ DEPS gcc-libs
367
+ )
368
+ z_vcpkg_acquire_msys_declare_package(
369
+ URL "https://mirror.msys2.org/msys/x86_64/libbz2-1.0.8-4-x86_64.pkg.tar.zst"
370
+ SHA512 5a7be6d04e55e6fb1dc0770a8c020ca24a317807c8c8a4813146cd5d559c12a6c61040797b062e441645bc2257b390e12dd6df42519e56278a1fe849fe76a1c4
371
+ DEPS gcc-libs
372
+ )
373
+ z_vcpkg_acquire_msys_declare_package(
374
+ URL "https://mirror.msys2.org/msys/x86_64/libgettextpo-0.22.4-1-x86_64.pkg.tar.zst"
375
+ SHA512 7552bc873331f07a4c006f27fe9f72186eed9717d68c4cbf54a75ff65c9445f874c43ccced2f9fa75ff1602c1209f6f1f4335a6ae6bf9bd5e951292584db7539
376
+ DEPS gcc-libs
377
+ )
378
+ z_vcpkg_acquire_msys_declare_package(
379
+ URL "https://mirror.msys2.org/msys/x86_64/libiconv-1.17-1-x86_64.pkg.tar.zst"
380
+ SHA512 e8fc6338d499ccf3a143b3dbdb91838697de76e1c9582bb44b0f80c1d2da5dcfe8102b7512efa798c5409ba9258f4014eb4eccd24a9a46d89631c06afc615678
381
+ DEPS gcc-libs libintl
382
+ )
383
+ z_vcpkg_acquire_msys_declare_package(
384
+ URL "https://mirror.msys2.org/msys/x86_64/libintl-0.22.4-1-x86_64.pkg.tar.zst"
385
+ SHA512 07f41f7fa53967bb5b0aca72255c70d7aeed58ea86b67bd0e765e08c20c50187ef2e775b630c0d48b3afbe62203754f7e8653a5f2e1a87a38b4af5753c7bd232
386
+ DEPS gcc-libs libiconv
387
+ )
388
+ z_vcpkg_acquire_msys_declare_package(
389
+ URL "https://mirror.msys2.org/msys/x86_64/liblzma-5.4.6-2-x86_64.pkg.tar.zst"
390
+ SHA512 d79bf6089f258e17226b30c1d68ee7b391048174386d366007f2361f2db0dc069a056549f483ac62285db238d9812d801bc347684ab485058d55cad16ce36dc0
391
+ # This package installs only a DLL. No extra deps.
392
+ DEPS # gettext libiconv sh
393
+ )
394
+ z_vcpkg_acquire_msys_declare_package(
395
+ URL "https://mirror.msys2.org/msys/x86_64/libpcre-8.45-4-x86_64.pkg.tar.zst"
396
+ SHA512 e1eb5cb38dce22012527bba2e92f908bf23c7725d77dcbd7fa14597af0f5b413319e0a7dd66555370afffc3b55d6074b8b83fd3c384d31ac505b74db246d54ac
397
+ DEPS gcc-libs
398
+ )
399
+ z_vcpkg_acquire_msys_declare_package(
400
+ URL "https://mirror.msys2.org/msys/x86_64/libreadline-8.2.010-1-x86_64.pkg.tar.zst"
401
+ SHA512 ce5e4b4abd347a2e8d4a48860aca062b0478000b3696859d0e143643f16b845bc0e7c84bf4fbf95cbcc043a6acebe2d28acc65b763d2de6a95f13ab6b3a3649f
402
+ DEPS ncurses
403
+ )
404
+ z_vcpkg_acquire_msys_declare_package(
405
+ URL "https://mirror.msys2.org/msys/x86_64/libtool-2.4.7-3-x86_64.pkg.tar.zst"
406
+ SHA512 a202ddaefa93d8a4b15431dc514e3a6200c47275c5a0027c09cc32b28bc079b1b9a93d5ef65adafdc9aba5f76a42f3303b1492106ddf72e67f1801ebfe6d02cc
407
+ DEPS sh tar
408
+ # extra deps which are really needed
409
+ awk findutils grep sed
410
+ )
411
+ z_vcpkg_acquire_msys_declare_package(
412
+ URL "https://mirror.msys2.org/msys/x86_64/libxcrypt-4.4.36-1-x86_64.pkg.tar.zst"
413
+ SHA512 457320daebd1aa45461788fb52dd4772fe91c34902201fac81d94ee2cbbfa216b02b3831a3e32a5ac638a3f12ac31fcec94ee95b19696fec6624e10e3dc5ffff
414
+ DEPS gcc-libs
415
+ )
416
+ z_vcpkg_acquire_msys_declare_package(
417
+ URL "https://mirror.msys2.org/msys/x86_64/libzstd-1.5.5-1-x86_64.pkg.tar.zst"
418
+ SHA512 c3d491f90bef0cbd7447303ff6f5a647e9fcf7bb0af9116cfe5fe421180e2283ec9403c768caa9434e9b158ce6ebde1a4750c56db8f67dfac4d6282d0ac30413
419
+ DEPS gcc-libs
420
+ )
421
+ z_vcpkg_acquire_msys_declare_package(
422
+ URL "https://mirror.msys2.org/msys/x86_64/m4-1.4.19-2-x86_64.pkg.tar.zst"
423
+ SHA512 7471099ba7e3b47e5b019dc0e563165a8660722f2bbd337fb579e6d1832c0e7dcab0ca9297c4692b18add92c4ad49e94391c621cf38874e2ff63d4f926bac38c
424
+ DEPS bash gcc-libs libiconv
425
+ )
426
+ z_vcpkg_acquire_msys_declare_package(
427
+ URL "https://mirror.msys2.org/msys/x86_64/make-4.4.1-1-x86_64.pkg.tar.zst"
428
+ SHA512 7e1c95b976d949db4b74c444e0d1495bbee26649aa82eadf34076dba3c1223d4e7b901e07935ba73dceda67f0a0cf25dd99fe3eed5300a5163fdaab14ca8d9fc
429
+ DEPS libintl sh
430
+ )
431
+ z_vcpkg_acquire_msys_declare_package(
432
+ URL "https://mirror.msys2.org/msys/x86_64/mpfr-4.2.1-1-x86_64.pkg.tar.zst"
433
+ SHA512 7417bb02a0f1073b8c1a64732463ec178d28f75eebd9621d02117cda1d214aff3e28277bd20e1e4731e191daab26e38333ace007ed44459ce3e2feae27aedc00
434
+ DEPS gmp
435
+ )
436
+ z_vcpkg_acquire_msys_declare_package(
437
+ URL "https://mirror.msys2.org/msys/x86_64/msys2-runtime-3.4.10-4-x86_64.pkg.tar.zst"
438
+ SHA512 b921b59b840dc2813825917dcff0c3686658f9af556bdb95b536fcb949d593886c9815e4bff136472797218e1f0462fbc49f87f2a31ec9abb2407c5506807f88
439
+ )
440
+ z_vcpkg_acquire_msys_declare_package(
441
+ URL "https://mirror.msys2.org/msys/x86_64/ncurses-6.4-2-x86_64.pkg.tar.zst"
442
+ SHA512 31d1e75071158aae970209de79adc3b3ff1d189ffc18460b3f1c818784e571ff3e0ff2767013516f9bb3fd0e62c2038444f1e8c1816db357d57e31f8663f4420
443
+ DEPS gcc-libs
444
+ )
445
+ z_vcpkg_acquire_msys_declare_package(
446
+ URL "https://mirror.msys2.org/msys/x86_64/patch-2.7.6-2-x86_64.pkg.tar.zst"
447
+ SHA512 eb484156e6e93da061645437859531f7b04abe6fef9973027343302f088a8681d413d87c5635a10b61ddc4a3e4d537af1de7552b3a13106639e451b95831ec91
448
+ )
449
+ z_vcpkg_acquire_msys_declare_package(
450
+ URL "https://mirror.msys2.org/msys/x86_64/perl-5.38.2-1-x86_64.pkg.tar.zst"
451
+ SHA512 00c992e0fd8847f579dd33a82140034c6a81b650f456d2b22706f82c5c6db04dce4f1194024775081ae7bffa01afc476df1815ec7cc98ebb0a676726a0c1c2b2
452
+ DEPS coreutils libxcrypt sh
453
+ )
454
+ z_vcpkg_acquire_msys_declare_package(
455
+ URL "https://mirror.msys2.org/msys/x86_64/pkgconf-2.1.0-1-x86_64.pkg.tar.zst"
456
+ SHA512 4376aba6fd2c118b1cb7e2008a23724aae62e9c972849b984a087079eaff1a29f423d3dedc3d7cfa682d931eb9a72891c8630196507a4a2cbe15f80a359bfa58
457
+ PROVIDES pkg-config
458
+ )
459
+ z_vcpkg_acquire_msys_declare_package(
460
+ URL "https://mirror.msys2.org/msys/x86_64/sed-4.9-1-x86_64.pkg.tar.zst"
461
+ SHA512 8006a83f0cc6417e3f23ffd15d0cbca2cd332f2d2690232a872ae59795ac63e8919eb361111b78f6f2675c843758cc4782d816ca472fe841f7be8a42c36e8237
462
+ DEPS libintl sh
463
+ )
464
+ z_vcpkg_acquire_msys_declare_package(
465
+ URL "https://mirror.msys2.org/msys/x86_64/tar-1.35-2-x86_64.pkg.tar.zst"
466
+ SHA512 86269fe17729e5381f8236a0251088110725c3eb930215b8378b6673e5ee136847997bb6a667fe0398b65b85e3f3a7e4679a0fd4bb2ebcb9429a5d7273a02d54
467
+ DEPS libiconv libintl sh
468
+ )
469
+ z_vcpkg_acquire_msys_declare_package(
470
+ URL "https://mirror.msys2.org/msys/x86_64/texinfo-7.1-2-x86_64.pkg.tar.zst"
471
+ SHA512 10edea1d3e2720afd47f0ff77ba47849b3eaf5d62d6025c3bce1d683302ae11126e7ee7b26751d1a6a66bc86a4c09021feb373434b1808441897e02245235c7b
472
+ DEPS perl sh
473
+ )
474
+ z_vcpkg_acquire_msys_declare_package(
475
+ URL "https://mirror.msys2.org/msys/x86_64/unzip-6.0-3-x86_64.pkg.tar.zst"
476
+ SHA512 1d6df49e826617ef3d3976be33361e189d8a5aee3a33ae79474fd08ca44ebd113981e6ba25c968b3cf5fb9826edd42dee21a97261cbc86fd8b143c950ba1f357
477
+ DEPS bash libbz2
478
+ )
479
+ z_vcpkg_acquire_msys_declare_package(
480
+ URL "https://mirror.msys2.org/msys/x86_64/which-2.21-4-x86_64.pkg.tar.zst"
481
+ SHA512 5323fd6635093adf67c24889f469e1ca8ac969188c7f087244a43b3afa0bf8f14579bd87d9d7beb16a7cd61a5ca1108515a46b331868b4817b35cebcb4eba1d1
482
+ DEPS sh
483
+ )
484
+ z_vcpkg_acquire_msys_declare_package(
485
+ URL "https://mirror.msys2.org/msys/x86_64/xz-5.4.6-2-x86_64.pkg.tar.zst"
486
+ SHA512 301e612ce0174b1d80a0e40c96f6bc2941c57f5e2a6c0e8e05b9d479cc000204d0df364c0a4df6eeb923107bee3e8f20cbef35825a2eec3e489c525ce2605534
487
+ DEPS libiconv libintl liblzma
488
+ )
489
+ z_vcpkg_acquire_msys_declare_package(
490
+ URL "https://mirror.msys2.org/msys/x86_64/zlib-1.3.1-1-x86_64.pkg.tar.zst"
491
+ SHA512 a432b0f927d342b678df706487595eff1b780371548933f956adcf697eea11ddbca2863d9d9fb88675a7040dcfddab56f8f71a8ae4d0cd4969e715545c77e87c
492
+ DEPS gcc-libs
493
+ )
494
+
495
+ # mingw64 subsystem
496
+ z_vcpkg_acquire_msys_declare_package(
497
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-bzip2-1.0.8-3-any.pkg.tar.zst"
498
+ SHA512 fb1ae524d7b04e1f35c3101c318136dbe08da8093bda98f6aea7e6c2564fec5f8533fb61cac5001b6425105cd982511964ec04099c6651f990dc3b8baf7f7057
499
+ DEPS mingw-w64-x86_64-gcc-libs
500
+ )
501
+ z_vcpkg_acquire_msys_declare_package(
502
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-ca-certificates-20230311-1-any.pkg.tar.zst"
503
+ SHA512 f7526ad35bccc5edba3fcf1354a85eacbd61dba5780b1bc65c7e8795ecb252432004af809052bb0ba981b1dea174c40e2d3f20655d8e2b29be95ad54d2aa5782
504
+ DEPS mingw-w64-x86_64-p11-kit
505
+ )
506
+ z_vcpkg_acquire_msys_declare_package(
507
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-expat-2.5.0-1-any.pkg.tar.zst"
508
+ SHA512 b49ec84750387af5b73a78d654673d62cf0e2cb2b59b4d25acb7eca3830018f7a2aefe600d67d843417cfbdd97db81ecfd49a8811e312f53b42c21fb106b230d
509
+ )
510
+ z_vcpkg_acquire_msys_declare_package(
511
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-libgfortran-13.2.0-3-any.pkg.tar.zst"
512
+ SHA512 da0902979b2fd1a556d639587caeb24a756bdab29f6179fdb2deac3463bb7c150f13db6b944da2a7ade69d496199b7e8bd22ec1515beb26fab1a01e3b4e6c2bd
513
+ PROVIDES mingw-w64-x86_64-fc-libs
514
+ DEPS mingw-w64-x86_64-gcc-libs
515
+ )
516
+ z_vcpkg_acquire_msys_declare_package(
517
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-libs-13.2.0-3-any.pkg.tar.zst"
518
+ SHA512 f904ee75196ab63df4b63b84f08bfd5956a178c72fea21fdcf8727f7d70f538b358a546316c4542c36a5c3169f88437426c785ac8e2a99d8eb952be7429216d4
519
+ PROVIDES mingw-w64-x86_64-omp
520
+ DEPS mingw-w64-x86_64-libwinpthread
521
+ )
522
+ z_vcpkg_acquire_msys_declare_package(
523
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-gettext-runtime-0.22.4-5-any.pkg.tar.zst"
524
+ SHA512 03a0210dd2c57a282e8de6a96d871cf8957b16a88464f62fa0cbf42e6ccf60046ce2ff7fcabd086775893f7ade92bb9f9bf5740e92aba6efbdc2aea3ece35c73
525
+ DEPS mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-libiconv
526
+ )
527
+ z_vcpkg_acquire_msys_declare_package(
528
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-gmp-6.3.0-2-any.pkg.tar.zst"
529
+ SHA512 38ab150051d787e44f1c75b3703d6c8deb429d244acb2a973ee232043b708e6c9e29a1f9e28f12e242c136d433e8eb5a5133a4d9ac7b87157a9749a8d215d2f0
530
+ )
531
+ z_vcpkg_acquire_msys_declare_package(
532
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libffi-3.4.4-1-any.pkg.tar.zst"
533
+ SHA512 ec88a0e0cb9b3ff3879d3fd952d3ad52f0d86a42669eddaeca47778ab0d5213abdea7d480a23aa3870e08d6b93b9c4988855e368474be7186e9719456baae5df
534
+ )
535
+ z_vcpkg_acquire_msys_declare_package(
536
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libiconv-1.17-4-any.pkg.tar.zst"
537
+ SHA512 dc703b103291a5b89175c3ddf4282c1a40bcd91549c8f993300671b9afffb28559e118a2c665f47a465bd7286b9e3400c29d42761e0189c425fb156b37783927
538
+ )
539
+ z_vcpkg_acquire_msys_declare_package(
540
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libsystre-1.0.1-5-any.pkg.tar.zst"
541
+ SHA512 10ea2bacebb8b05c642f34c0ecf61710b9f1906615851825d1104d0e25b1a911f7541a3068b97de2eb71aa13d6963f61c7fdf051c5582e0868a6f90b93f7aa77
542
+ PROVIDES mingw-w64-x86_64-libgnurx
543
+ DEPS mingw-w64-x86_64-libtre
544
+ )
545
+ z_vcpkg_acquire_msys_declare_package(
546
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libtasn1-4.19.0-1-any.pkg.tar.zst"
547
+ SHA512 761a7c316914d7f98ec6489fb4c06d227e5956d50f2e233ad9be119cfd6301f6b7e4f872316c0bae3913268c1aa9b224b172ab94130489fbd5d7269ff9064cfb
548
+ DEPS mingw-w64-x86_64-gcc-libs
549
+ )
550
+ z_vcpkg_acquire_msys_declare_package(
551
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libtre-git-r177.07e66d0-2-any.pkg.tar.zst"
552
+ SHA512 a21a03fd446707f748f4101e723f71d5f2c93c736d86205dc9eee6681d1bb1248283b8921f897391b56143d8dcf6be29cf8c2c57abcf32e1e4d0b2ea2309a790
553
+ PROVIDES mingw-w64-x86_64-libtre
554
+ DEPS mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-gettext-runtime
555
+ )
556
+ z_vcpkg_acquire_msys_declare_package(
557
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libwinpthread-git-11.0.0.r551.g86a5e0f41-1-any.pkg.tar.zst"
558
+ SHA512 2742d5939e6f677d148f0f07ddc399bf8e4bf3c07f9b90160f20314f1c69e549b9f9d6cbf0df35d7f950d2e09e57c56c0496475cb66f053dcf0bcfdf3bb14bb1
559
+ PROVIDES mingw-w64-x86_64-libwinpthread
560
+ )
561
+ z_vcpkg_acquire_msys_declare_package(
562
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-mpc-1.3.1-2-any.pkg.tar.zst"
563
+ SHA512 3fe183d4af3b3935a4394502eab75a8f7b7692f551fd44e54c67935a4691388d23a021ee1147f0345ed27ffe8a8db3e9e7e37caf2348df3413e0acd519c12a0c
564
+ DEPS mingw-w64-x86_64-gmp mingw-w64-x86_64-mpfr
565
+ )
566
+ z_vcpkg_acquire_msys_declare_package(
567
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-mpdecimal-2.5.1-1-any.pkg.tar.zst"
568
+ SHA512 1204c31367f9268ffd6658be04af7687c01f984c9d6be8c7a20ee0ebde1ca9a03b766ef1aeb1fa7aaa97b88a57f7a73afa7f7a7fed9c6b895a032db11e6133bf
569
+ DEPS mingw-w64-x86_64-gcc-libs
570
+ )
571
+ z_vcpkg_acquire_msys_declare_package(
572
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-mpfr-4.2.1-2-any.pkg.tar.zst"
573
+ SHA512 03a727e1622b09ed0b6e0cb93a6b1040c31c9504c3f14bd1a2e12b8293153609796bc99882393b343c4d96e45f402f847317a3a65212b972ff96a964e5e52815
574
+ DEPS mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-gmp
575
+ )
576
+ z_vcpkg_acquire_msys_declare_package(
577
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-ncurses-6.4.20231217-1-any.pkg.tar.zst"
578
+ SHA512 54a936731589a1af653dc73da983b683e8fc687e9c3737f5215acdef70e3596cddce44d01a6e98e482fd3f071da20cd5ab10b54d52cbdc0b34bbdc090a1cf3d3
579
+ DEPS mingw-w64-x86_64-libsystre
580
+ )
581
+ z_vcpkg_acquire_msys_declare_package(
582
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-openblas-0.3.26-1-any.pkg.tar.zst"
583
+ SHA512 de5b2b3eca6976a26dded23d5be6f1cdccb68e4a41a3568f917f78aee2bc9c91b5ff7e566cbc2fa9d6852c57b90bb92a36b95efe458c88f1819961a27d91129b
584
+ PROVIDES mingw-w64-x86_64-OpenBLAS
585
+ DEPS mingw-w64-x86_64-gcc-libgfortran mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-libwinpthread mingw-w64-x86_64-omp
586
+ )
587
+ z_vcpkg_acquire_msys_declare_package(
588
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-openssl-3.2.1-1-any.pkg.tar.zst"
589
+ SHA512 706218c8d7321358cf7f1c472c89c19f88245eeff5037712b2a64c9f81166bcd7b2a06cc3343af5a75a65c520890d845d8d1234feddbe622992b6e9825e81f5c
590
+ #DEPS mingw-w64-x86_64-ca-certificates mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-zlib
591
+ )
592
+ z_vcpkg_acquire_msys_declare_package(
593
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-p11-kit-0.25.3-2-any.pkg.tar.zst"
594
+ SHA512 81e62ad4b1bdf7da3b2de20a3a444b2a30a7b38dda8df41ca7e8baed0954a335cc9594ddd577f4ea5b6000d945348dc7d0364c9408e8a3e3afef34cc5c083c85
595
+ DEPS mingw-w64-x86_64-gettext-runtime mingw-w64-x86_64-libffi mingw-w64-x86_64-libtasn1
596
+ )
597
+ z_vcpkg_acquire_msys_declare_package(
598
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-python-3.11.7-1-any.pkg.tar.zst"
599
+ SHA512 f94e2e53887da29bdcdafd4ad86d709e98c1bd271fdf9c5a85904cf20eae7690b8efef5b858a8bc979f6106343cec6ab6a828fcad631e4c30ce89c736603375e
600
+ PROVIDES mingw-w64-x86_64-python3 mingw-w64-x86_64-python3.11
601
+ DEPS mingw-w64-x86_64-bzip2 mingw-w64-x86_64-expat mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-libffi mingw-w64-x86_64-mpdecimal mingw-w64-x86_64-ncurses mingw-w64-x86_64-openssl mingw-w64-x86_64-sqlite3 mingw-w64-x86_64-tcl mingw-w64-x86_64-tk mingw-w64-x86_64-xz mingw-w64-x86_64-zlib
602
+ )
603
+ z_vcpkg_acquire_msys_declare_package(
604
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-python-numpy-1.26.3-1-any.pkg.tar.zst"
605
+ SHA512 62fac7ca3c936bc42902652933373420fb422fb49bfe808e4a4d71183983c5d386f88c1772e6e07477c5b76f5fd489ef5084bef33588c3db63edccaa361520d2
606
+ PROVIDES mingw-w64-x86_64-python3-numpy
607
+ DEPS mingw-w64-x86_64-openblas mingw-w64-x86_64-python
608
+ )
609
+ z_vcpkg_acquire_msys_declare_package(
610
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-readline-8.2.010-1-any.pkg.tar.zst"
611
+ SHA512 ade6caf9e97e762cb2a129a838e1b73e4a2cc4488a7db5c1b6a3ec5db7206d9108a9a7fc5e0e6d7099f26d15ddf71238006dd09467ad2a7617ad9dd925ea04e2
612
+ DEPS mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-termcap
613
+ )
614
+ z_vcpkg_acquire_msys_declare_package(
615
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-sqlite3-3.45.1-1-any.pkg.tar.zst"
616
+ SHA512 b54ae774fc82f83a19a78910cc068597f85fbd798d52c518fee24030043b606986f235ed86f99879d8de3360c2cbaf53500108a3db8638da1f32096d9439e90f
617
+ PROVIDES mingw-w64-x86_64-sqlite mingw-w64-x86_64-sqlite-analyzer
618
+ DEPS mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-readline mingw-w64-x86_64-tcl mingw-w64-x86_64-zlib
619
+ )
620
+ z_vcpkg_acquire_msys_declare_package(
621
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-termcap-1.3.1-7-any.pkg.tar.zst"
622
+ SHA512 2610355be441fd933f660f8181a5ad074057361a9aadeaad85961230dcf6df5d5165b94ccf9887144c91812485be57c2d79f39e8191ff525889bdff042d34ce6
623
+ DEPS mingw-w64-x86_64-gcc-libs
624
+ )
625
+ z_vcpkg_acquire_msys_declare_package(
626
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-tcl-8.6.13-1-any.pkg.tar.zst"
627
+ SHA512 e143405ed45da7986d30d2f14bde9dff16fb0ea85a01df45d15cbe8fc52065f5efcb22f8da98962022efbfee3a704fc20e38839ec448cdbb5809336b6b97d550
628
+ DEPS mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-zlib
629
+ )
630
+ z_vcpkg_acquire_msys_declare_package(
631
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-tk-8.6.12-2-any.pkg.tar.zst"
632
+ SHA512 832c98f2bb8963540d175bc6511f00747483d86b0e0d3219c7b6e5b0bd5e7d038018db08875bf26b3fbe6082b4ff1958777e5cfd1920f5d235493f0a1ce071b2
633
+ DEPS mingw-w64-x86_64-tcl
634
+ )
635
+ z_vcpkg_acquire_msys_declare_package(
636
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-xz-5.4.6-2-any.pkg.tar.zst"
637
+ SHA512 4ca1f3707003d43bdf5c6e7df1d0ea2a9ea56acfaa8a1b8db89f76d97ac8eb709b8af4d4233da412fdec3bffb72f7809462356d2afe61675bce8d2b23a7ce1d6
638
+ DEPS mingw-w64-x86_64-gettext-runtime
639
+ )
640
+ z_vcpkg_acquire_msys_declare_package(
641
+ URL "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-zlib-1.3.1-1-any.pkg.tar.zst"
642
+ SHA512 1336cd0db102af495d8bbfc6a1956f365750b19d2377fe809e9b26f61a8a6600394e7343677645c5743f4974161535dad5c0503ff50f6126d27bb927754e7320
643
+ )
644
+ endmacro()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_add_to_path.cmake ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ function(vcpkg_add_to_path)
2
+ cmake_parse_arguments(PARSE_ARGV 0 "arg" "PREPEND" "" "")
3
+ if(arg_PREPEND)
4
+ set(operation PREPEND)
5
+ else()
6
+ set(operation APPEND)
7
+ endif()
8
+
9
+ vcpkg_host_path_list("${operation}" ENV{PATH} ${arg_UNPARSED_ARGUMENTS})
10
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_backup_restore_env_vars.cmake ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(vcpkg_backup_env_variables)
2
+ cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "VARS")
3
+ if(NOT DEFINED arg_VARS)
4
+ message(FATAL_ERROR "VARS must be defined.")
5
+ endif()
6
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
7
+ message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
8
+ endif()
9
+
10
+ foreach(envvar IN LISTS arg_VARS)
11
+ if(DEFINED ENV{${envvar}})
12
+ set("z_vcpkg_env_backup_${envvar}" "$ENV{${envvar}}" PARENT_SCOPE)
13
+ else()
14
+ unset("z_vcpkg_env_backup_${envvar}" PARENT_SCOPE)
15
+ endif()
16
+ endforeach()
17
+ endfunction()
18
+
19
+ function(vcpkg_restore_env_variables)
20
+ cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "VARS")
21
+ if(NOT DEFINED arg_VARS)
22
+ message(FATAL_ERROR "VARS must be defined.")
23
+ endif()
24
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
25
+ message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
26
+ endif()
27
+
28
+ foreach(envvar IN LISTS arg_VARS)
29
+ if(DEFINED z_vcpkg_env_backup_${envvar})
30
+ set("ENV{${envvar}}" "${z_vcpkg_env_backup_${envvar}}")
31
+ else()
32
+ unset("ENV{${envvar}}")
33
+ endif()
34
+ endforeach()
35
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_build_ninja.cmake ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(z_vcpkg_build_ninja_build config targets)
2
+ message(STATUS "Building (${config})...")
3
+ vcpkg_execute_build_process(
4
+ COMMAND "${NINJA}" -C "${CURRENT_BUILDTREES_DIR}/${config}" ${targets}
5
+ WORKING_DIRECTORY "${SOURCE_PATH}"
6
+ LOGNAME "build-${config}"
7
+ )
8
+ endfunction()
9
+
10
+
11
+ function(vcpkg_build_ninja)
12
+ cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "TARGETS")
13
+
14
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
15
+ message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
16
+ endif()
17
+ if(NOT DEFINED arg_TARGETS)
18
+ set(arg_TARGETS "")
19
+ endif()
20
+
21
+ vcpkg_find_acquire_program(NINJA)
22
+
23
+ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
24
+ z_vcpkg_build_ninja_build("${TARGET_TRIPLET}-dbg" "${arg_TARGETS}")
25
+ endif()
26
+
27
+ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
28
+ z_vcpkg_build_ninja_build("${TARGET_TRIPLET}-rel" "${arg_TARGETS}")
29
+ endif()
30
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_build_nmake.cmake ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(vcpkg_build_nmake)
2
+ cmake_parse_arguments(PARSE_ARGV 0 arg
3
+ "ADD_BIN_TO_PATH;ENABLE_INSTALL;NO_DEBUG;PREFER_JOM"
4
+ "SOURCE_PATH;PROJECT_SUBPATH;PROJECT_NAME;LOGFILE_ROOT;CL_LANGUAGE"
5
+ "OPTIONS;OPTIONS_RELEASE;OPTIONS_DEBUG;PRERUN_SHELL;PRERUN_SHELL_DEBUG;PRERUN_SHELL_RELEASE;TARGET"
6
+ )
7
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
8
+ message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
9
+ endif()
10
+ if(NOT DEFINED arg_SOURCE_PATH)
11
+ message(FATAL_ERROR "SOURCE_PATH must be specified")
12
+ endif()
13
+
14
+ if(arg_NO_DEBUG)
15
+ message(WARNING "NO_DEBUG argument to ${CMAKE_CURRENT_FUNCTION} is deprecated")
16
+ endif()
17
+ if(arg_ADD_BIN_TO_PATH)
18
+ message(WARNING "ADD_BIN_TO_PATH argument to ${CMAKE_CURRENT_FUNCTION} is deprecated - it never did anything")
19
+ endif()
20
+
21
+ if(NOT VCPKG_HOST_IS_WINDOWS)
22
+ message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} only support windows.")
23
+ endif()
24
+
25
+ if(NOT DEFINED arg_LOGFILE_ROOT)
26
+ set(arg_LOGFILE_ROOT "build")
27
+ endif()
28
+ if(NOT DEFINED arg_PROJECT_NAME)
29
+ set(arg_PROJECT_NAME makefile.vc)
30
+ endif()
31
+
32
+ if(NOT DEFINED arg_TARGET)
33
+ vcpkg_list(SET arg_TARGET all)
34
+ endif()
35
+ if(arg_ENABLE_INSTALL)
36
+ vcpkg_list(APPEND arg_TARGET install)
37
+ endif()
38
+
39
+ if(NOT DEFINED arg_CL_LANGUAGE)
40
+ vcpkg_list(SET arg_CL_LANGUAGE CXX)
41
+ endif()
42
+
43
+ find_program(NMAKE nmake REQUIRED)
44
+ get_filename_component(NMAKE_EXE_PATH "${NMAKE}" DIRECTORY)
45
+ # Load toolchains
46
+ z_vcpkg_get_cmake_vars(cmake_vars_file)
47
+ debug_message("Including cmake vars from: ${cmake_vars_file}")
48
+ include("${cmake_vars_file}")
49
+ # Set needed env
50
+ set(ENV{PATH} "$ENV{PATH};${NMAKE_EXE_PATH}")
51
+ set(ENV{INCLUDE} "${CURRENT_INSTALLED_DIR}/include;$ENV{INCLUDE}")
52
+ # Set make options
53
+ vcpkg_list(SET make_opts_base /NOLOGO /G /U /F "${arg_PROJECT_NAME}" ${arg_TARGET})
54
+
55
+ if(arg_PREFER_JOM AND VCPKG_CONCURRENCY GREATER "1")
56
+ vcpkg_find_acquire_program(JOM)
57
+ get_filename_component(JOM_EXE_PATH "${JOM}" DIRECTORY)
58
+ vcpkg_add_to_path("${JOM_EXE_PATH}")
59
+ if(arg_CL_LANGUAGE AND "${VCPKG_DETECTED_CMAKE_${arg_CL_LANGUAGE}_COMPILER_ID}" STREQUAL "MSVC")
60
+ string(REGEX REPLACE " [/-]MP[0-9]* " " " VCPKG_COMBINED_${arg_CL_LANGUAGE}_FLAGS_DEBUG " ${VCPKG_COMBINED_${arg_CL_LANGUAGE}_FLAGS_DEBUG} /FS")
61
+ string(REGEX REPLACE " [/-]MP[0-9]* " " " VCPKG_COMBINED_${arg_CL_LANGUAGE}_FLAGS_RELEASE " ${VCPKG_COMBINED_${arg_CL_LANGUAGE}_FLAGS_RELEASE} /FS")
62
+ endif()
63
+ else()
64
+ set(arg_PREFER_JOM FALSE)
65
+ endif()
66
+
67
+ # Add subpath to work directory
68
+ if(DEFINED arg_PROJECT_SUBPATH)
69
+ set(project_subpath "/${arg_PROJECT_SUBPATH}")
70
+ else()
71
+ set(project_subpath "")
72
+ endif()
73
+
74
+ vcpkg_backup_env_variables(VARS _CL_ LINK)
75
+ cmake_path(NATIVE_PATH CURRENT_PACKAGES_DIR NORMALIZE install_dir_native)
76
+ foreach(build_type IN ITEMS debug release)
77
+ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL build_type)
78
+ if(build_type STREQUAL "debug")
79
+ # Generate obj dir suffix
80
+ set(short_build_type "-dbg")
81
+ # Add install command and arguments
82
+ set(make_opts "${make_opts_base}")
83
+ if (arg_ENABLE_INSTALL)
84
+ vcpkg_list(APPEND make_opts "INSTALLDIR=${install_dir_native}\\debug")
85
+ endif()
86
+ vcpkg_list(APPEND make_opts ${arg_OPTIONS} ${arg_OPTIONS_DEBUG})
87
+ if(NOT arg_CL_LANGUAGE STREQUAL "NONE")
88
+ set(ENV{_CL_} "${VCPKG_DETECTED_CMAKE_${arg_CL_LANGUAGE}_FLAGS_DEBUG}")
89
+ endif()
90
+ set(ENV{_LINK_} "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
91
+
92
+ set(prerun_variable_name arg_PRERUN_SHELL_DEBUG)
93
+ else()
94
+ set(short_build_type "-rel")
95
+ # Add install command and arguments
96
+ set(make_opts "${make_opts_base}")
97
+ if (arg_ENABLE_INSTALL)
98
+ vcpkg_list(APPEND make_opts "INSTALLDIR=${install_dir_native}")
99
+ endif()
100
+ vcpkg_list(APPEND make_opts ${arg_OPTIONS} ${arg_OPTIONS_RELEASE})
101
+
102
+ if(NOT arg_CL_LANGUAGE STREQUAL "NONE")
103
+ set(ENV{_CL_} "${VCPKG_DETECTED_CMAKE_${arg_CL_LANGUAGE}_FLAGS_RELEASE}")
104
+ endif()
105
+ set(ENV{_LINK_} "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
106
+ set(prerun_variable_name arg_PRERUN_SHELL_RELEASE)
107
+ endif()
108
+
109
+ set(triplet_and_build_type "${TARGET_TRIPLET}${short_build_type}")
110
+ set(object_dir "${CURRENT_BUILDTREES_DIR}/${triplet_and_build_type}")
111
+
112
+ file(REMOVE_RECURSE "${object_dir}")
113
+ file(COPY "${arg_SOURCE_PATH}/" DESTINATION "${object_dir}")
114
+
115
+ if(DEFINED arg_PRERUN_SHELL)
116
+ message(STATUS "Prerunning ${triplet_and_build_type}")
117
+ vcpkg_execute_required_process(
118
+ COMMAND ${arg_PRERUN_SHELL}
119
+ WORKING_DIRECTORY "${object_dir}${project_subpath}"
120
+ LOGNAME "prerun-${triplet_and_build_type}"
121
+ )
122
+ endif()
123
+ if(DEFINED "${prerun_variable_name}")
124
+ message(STATUS "Prerunning ${triplet_and_build_type}")
125
+ vcpkg_execute_required_process(
126
+ COMMAND ${${prerun_variable_name}}
127
+ WORKING_DIRECTORY "${object_dir}${project_subpath}"
128
+ LOGNAME "prerun-specific-${triplet_and_build_type}"
129
+ )
130
+ endif()
131
+
132
+ if (NOT arg_ENABLE_INSTALL)
133
+ message(STATUS "Building ${triplet_and_build_type}")
134
+ else()
135
+ message(STATUS "Building and installing ${triplet_and_build_type}")
136
+ endif()
137
+
138
+ set(run_nmake TRUE)
139
+ set(tool_suffix "")
140
+ if(arg_PREFER_JOM)
141
+ execute_process(
142
+ COMMAND "${JOM}" /K /J ${VCPKG_CONCURRENCY} ${make_opts}
143
+ WORKING_DIRECTORY "${object_dir}${project_subpath}"
144
+ OUTPUT_FILE "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_ROOT}-${triplet_and_build_type}-jom-out.log"
145
+ ERROR_FILE "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_ROOT}-${triplet_and_build_type}-jom-err.log"
146
+ RESULT_VARIABLE error_code
147
+ )
148
+ if(error_code EQUAL "0")
149
+ set(run_nmake FALSE)
150
+ else()
151
+ message(STATUS "Restarting build without parallelism")
152
+ set(tool_suffix "-nmake")
153
+ endif()
154
+ endif()
155
+ if(run_nmake)
156
+ vcpkg_execute_build_process(
157
+ COMMAND "${NMAKE}" ${make_opts}
158
+ WORKING_DIRECTORY "${object_dir}${project_subpath}"
159
+ LOGNAME "${arg_LOGFILE_ROOT}-${triplet_and_build_type}${tool_suffix}"
160
+ )
161
+ endif()
162
+
163
+ vcpkg_restore_env_variables(VARS _CL_ LINK)
164
+ endif()
165
+ endforeach()
166
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_buildpath_length_warning.cmake ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ function(vcpkg_buildpath_length_warning warning_length)
2
+ string(LENGTH "${CURRENT_BUILDTREES_DIR}" buildtrees_path_length)
3
+ if(buildtrees_path_length GREATER warning_length AND CMAKE_HOST_WIN32)
4
+ message(WARNING "${PORT}'s buildsystem uses very long paths and may fail on your system.\n"
5
+ "We recommend moving vcpkg to a short path such as 'C:\\src\\vcpkg' or using the subst command."
6
+ )
7
+ endif()
8
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_check_features.cmake ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(z_vcpkg_check_features_last_feature out_var features_name features_list)
2
+ list(LENGTH features_list features_length)
3
+ math(EXPR features_length_mod_2 "${features_length} % 2")
4
+ if(NOT features_length_mod_2 EQUAL 0)
5
+ message(FATAL_ERROR "vcpkg_check_features has an incorrect number of arguments to ${features_name}")
6
+ endif()
7
+
8
+ math(EXPR last_feature "${features_length} / 2 - 1")
9
+ set("${out_var}" "${last_feature}" PARENT_SCOPE)
10
+ endfunction()
11
+
12
+ function(z_vcpkg_check_features_get_feature idx features_list out_feature_name out_feature_var)
13
+ math(EXPR feature_name_idx "${idx} * 2")
14
+ math(EXPR feature_var_idx "${feature_name_idx} + 1")
15
+
16
+ list(GET features_list "${feature_name_idx}" feature_name)
17
+ list(GET features_list "${feature_var_idx}" feature_var)
18
+
19
+ set("${out_feature_name}" "${feature_name}" PARENT_SCOPE)
20
+ set("${out_feature_var}" "${feature_var}" PARENT_SCOPE)
21
+ endfunction()
22
+
23
+ function(vcpkg_check_features)
24
+ cmake_parse_arguments(
25
+ PARSE_ARGV 0 "arg"
26
+ ""
27
+ "OUT_FEATURE_OPTIONS;PREFIX"
28
+ "FEATURES;INVERTED_FEATURES"
29
+ )
30
+
31
+ if(NOT DEFINED arg_OUT_FEATURE_OPTIONS)
32
+ message(FATAL_ERROR "OUT_FEATURE_OPTIONS must be defined.")
33
+ endif()
34
+ if(NOT DEFINED arg_PREFIX)
35
+ set(prefix "")
36
+ else()
37
+ set(prefix "${arg_PREFIX}_")
38
+ endif()
39
+
40
+ set(feature_options)
41
+ set(feature_variables)
42
+
43
+ if(NOT DEFINED arg_FEATURES AND NOT DEFINED arg_INVERTED_FEATURES)
44
+ message(DEPRECATION
45
+ "calling `vcpkg_check_features` without the `FEATURES` keyword has been deprecated.
46
+ Please add the `FEATURES` keyword to the call.")
47
+ set(arg_FEATURES "${arg_UNPARSED_ARGUMENTS}")
48
+ elseif(DEFINED arg_UNPARSED_ARGUMENTS)
49
+ message(FATAL_ERROR "vcpkg_check_features called with unknown arguments: ${arg_UNPARSED_ARGUMENTS}")
50
+ endif()
51
+
52
+
53
+
54
+ z_vcpkg_check_features_last_feature(last_feature "FEATURES" "${arg_FEATURES}")
55
+ if(last_feature GREATER_EQUAL 0)
56
+ foreach(feature_pair_idx RANGE "${last_feature}")
57
+ z_vcpkg_check_features_get_feature("${feature_pair_idx}" "${arg_FEATURES}" feature_name feature_var)
58
+
59
+ list(APPEND feature_variables "${feature_var}")
60
+ if(feature_name IN_LIST FEATURES)
61
+ list(APPEND feature_options "-D${feature_var}=ON")
62
+ set("${prefix}${feature_var}" ON PARENT_SCOPE)
63
+ else()
64
+ list(APPEND feature_options "-D${feature_var}=OFF")
65
+ set("${prefix}${feature_var}" OFF PARENT_SCOPE)
66
+ endif()
67
+ endforeach()
68
+ endif()
69
+
70
+ z_vcpkg_check_features_last_feature(last_inverted_feature "INVERTED_FEATURES" "${arg_INVERTED_FEATURES}")
71
+ if(last_inverted_feature GREATER_EQUAL 0)
72
+ foreach(feature_pair_idx RANGE "${last_inverted_feature}")
73
+ z_vcpkg_check_features_get_feature("${feature_pair_idx}" "${arg_INVERTED_FEATURES}" feature_name feature_var)
74
+
75
+ list(APPEND feature_variables "${feature_var}")
76
+ if(feature_name IN_LIST FEATURES)
77
+ list(APPEND feature_options "-D${feature_var}=OFF")
78
+ set("${prefix}${feature_var}" OFF PARENT_SCOPE)
79
+ else()
80
+ list(APPEND feature_options "-D${feature_var}=ON")
81
+ set("${prefix}${feature_var}" ON PARENT_SCOPE)
82
+ endif()
83
+ endforeach()
84
+ endif()
85
+
86
+ list(SORT feature_variables)
87
+ set(last_variable)
88
+ foreach(variable IN LISTS feature_variables)
89
+ if(variable STREQUAL last_variable)
90
+ message("${Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL}" "vcpkg_check_features passed the same feature variable multiple times: '${variable}'")
91
+ endif()
92
+ set(last_variable ${variable})
93
+ endforeach()
94
+
95
+ set("${arg_OUT_FEATURE_OPTIONS}" "${feature_options}" PARENT_SCOPE)
96
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_check_linkage.cmake ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(vcpkg_check_linkage)
2
+ cmake_parse_arguments(PARSE_ARGV 0 arg
3
+ "ONLY_STATIC_LIBRARY;ONLY_DYNAMIC_LIBRARY;ONLY_DYNAMIC_CRT;ONLY_STATIC_CRT"
4
+ ""
5
+ ""
6
+ )
7
+
8
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
9
+ message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
10
+ endif()
11
+
12
+ if(arg_ONLY_STATIC_LIBRARY AND arg_ONLY_DYNAMIC_LIBRARY)
13
+ message(FATAL_ERROR "Requesting both ONLY_STATIC_LIBRARY and ONLY_DYNAMIC_LIBRARY; this is an error.")
14
+ endif()
15
+ if(arg_ONLY_STATIC_CRT AND arg_ONLY_DYNAMIC_CRT)
16
+ message(FATAL_ERROR "Requesting both ONLY_STATIC_CRT and ONLY_DYNAMIC_CRT; this is an error.")
17
+ endif()
18
+
19
+ if(arg_ONLY_STATIC_LIBRARY AND "${VCPKG_LIBRARY_LINKAGE}" STREQUAL "dynamic")
20
+ message(STATUS "Note: ${PORT} only supports static library linkage. Building static library.")
21
+ set(VCPKG_LIBRARY_LINKAGE static PARENT_SCOPE)
22
+ elseif(arg_ONLY_DYNAMIC_LIBRARY AND "${VCPKG_LIBRARY_LINKAGE}" STREQUAL "static")
23
+ message(STATUS "Note: ${PORT} only supports dynamic library linkage. Building dynamic library.")
24
+ if("${VCPKG_CRT_LINKAGE}" STREQUAL "static")
25
+ message(FATAL_ERROR "Refusing to build unexpected dynamic library against the static CRT.
26
+ If this is desired, please configure your triplet to directly request this configuration.")
27
+ endif()
28
+ set(VCPKG_LIBRARY_LINKAGE dynamic PARENT_SCOPE)
29
+ endif()
30
+
31
+ if(arg_ONLY_DYNAMIC_CRT AND "${VCPKG_CRT_LINKAGE}" STREQUAL "static")
32
+ message(FATAL_ERROR "${PORT} only supports dynamic crt linkage")
33
+ elseif(arg_ONLY_STATIC_CRT AND "${VCPKG_CRT_LINKAGE}" STREQUAL "dynamic")
34
+ message(FATAL_ERROR "${PORT} only supports static crt linkage")
35
+ endif()
36
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_clean_executables_in_bin.cmake ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(z_vcpkg_clean_executables_in_bin_remove_directory_if_empty directory)
2
+ if(NOT EXISTS "${directory}")
3
+ return()
4
+ endif()
5
+
6
+ if(NOT IS_DIRECTORY "${directory}")
7
+ message(FATAL_ERROR "${directory} must be a directory")
8
+ endif()
9
+
10
+ file(GLOB items "${directory}/*")
11
+ if("${items}" STREQUAL "")
12
+ file(REMOVE_RECURSE "${directory}")
13
+ endif()
14
+ endfunction()
15
+
16
+
17
+ function(vcpkg_clean_executables_in_bin)
18
+ cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "FILE_NAMES")
19
+
20
+ if(NOT DEFINED arg_FILE_NAMES)
21
+ message(FATAL_ERROR "FILE_NAMES must be specified.")
22
+ endif()
23
+
24
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
25
+ message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
26
+ endif()
27
+
28
+
29
+ foreach(file_name IN LISTS arg_FILE_NAMES)
30
+ file(REMOVE
31
+ "${CURRENT_PACKAGES_DIR}/bin/${file_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}"
32
+ "${CURRENT_PACKAGES_DIR}/debug/bin/${file_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}"
33
+ "${CURRENT_PACKAGES_DIR}/bin/${file_name}.pdb"
34
+ "${CURRENT_PACKAGES_DIR}/debug/bin/${file_name}.pdb"
35
+ )
36
+ if(NOT VCPKG_TARGET_BUNDLE_SUFFIX STREQUAL "")
37
+ file(REMOVE_RECURSE
38
+ "${CURRENT_PACKAGES_DIR}/bin/${file_name}${VCPKG_TARGET_BUNDLE_SUFFIX}"
39
+ "${CURRENT_PACKAGES_DIR}/debug/bin/${file_name}${VCPKG_TARGET_BUNDLE_SUFFIX}"
40
+ )
41
+ endif()
42
+ endforeach()
43
+
44
+ z_vcpkg_clean_executables_in_bin_remove_directory_if_empty("${CURRENT_PACKAGES_DIR}/bin")
45
+ z_vcpkg_clean_executables_in_bin_remove_directory_if_empty("${CURRENT_PACKAGES_DIR}/debug/bin")
46
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_common_functions.cmake ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # DEPRECATED
2
+
3
+ message("${Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL}" "vcpkg_common_functions has been removed and all values are automatically provided in all portfile.cmake invocations. Please remove `include(vcpkg_common_functions)`.")
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_configure_cmake.cmake ADDED
@@ -0,0 +1,393 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(z_vcpkg_configure_cmake_both_or_neither_set var1 var2)
2
+ if(DEFINED "${var1}" AND NOT DEFINED "${var2}")
3
+ message(FATAL_ERROR "If ${var1} is set, ${var2} must be set.")
4
+ endif()
5
+ if(NOT DEFINED "${var1}" AND DEFINED "${var2}")
6
+ message(FATAL_ERROR "If ${var2} is set, ${var1} must be set.")
7
+ endif()
8
+ endfunction()
9
+ function(z_vcpkg_configure_cmake_build_cmakecache out_var whereat build_type)
10
+ set(line "build ${whereat}/CMakeCache.txt: CreateProcess\n")
11
+ string(APPEND line " process = \"${CMAKE_COMMAND}\" -E chdir \"${whereat}\"")
12
+ foreach(arg IN LISTS "${build_type}_command")
13
+ string(APPEND line " \"${arg}\"")
14
+ endforeach()
15
+ set("${out_var}" "${${out_var}}${line}\n\n" PARENT_SCOPE)
16
+ endfunction()
17
+
18
+ function(z_vcpkg_get_visual_studio_generator)
19
+ cmake_parse_arguments(PARSE_ARGV 0 arg "" "OUT_GENERATOR;OUT_ARCH" "")
20
+
21
+ if (NOT DEFINED arg_OUT_GENERATOR)
22
+ message(FATAL_ERROR "OUT_GENERATOR must be defined.")
23
+ endif()
24
+ if(NOT DEFINED arg_OUT_ARCH)
25
+ message(FATAL_ERROR "OUT_ARCH must be defined.")
26
+ endif()
27
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
28
+ message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
29
+ endif()
30
+
31
+ if(DEFINED ENV{VisualStudioVersion})
32
+ if("$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "12.99" AND
33
+ "$ENV{VisualStudioVersion}" VERSION_GREATER_EQUAL "12.0" AND
34
+ NOT "${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "arm64")
35
+ set(generator "Visual Studio 12 2013")
36
+ elseif("$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "14.99" AND
37
+ NOT "${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "arm64")
38
+ set(generator "Visual Studio 14 2015")
39
+ elseif("$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "15.99")
40
+ set(generator "Visual Studio 15 2017")
41
+ elseif("$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "16.99")
42
+ set(generator "Visual Studio 16 2019")
43
+ elseif("$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "17.99")
44
+ set(generator "Visual Studio 17 2022")
45
+ endif()
46
+ endif()
47
+
48
+ if("${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "x86")
49
+ set(generator_arch "Win32")
50
+ elseif("${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "x64")
51
+ set(generator_arch "x64")
52
+ elseif("${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "arm")
53
+ set(generator_arch "ARM")
54
+ elseif("${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "arm64")
55
+ set(generator_arch "ARM64")
56
+ endif()
57
+ set(${arg_OUT_GENERATOR} "${generator}" PARENT_SCOPE)
58
+ set(${arg_OUT_ARCH} "${generator_arch}" PARENT_SCOPE)
59
+ endfunction()
60
+
61
+ function(z_vcpkg_select_default_vcpkg_chainload_toolchain)
62
+ # Try avoiding adding more defaults here.
63
+ # Set VCPKG_CHAINLOAD_TOOLCHAIN_FILE explicitly in the triplet.
64
+ if(DEFINED Z_VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
65
+ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${Z_VCPKG_CHAINLOAD_TOOLCHAIN_FILE}")
66
+ elseif(VCPKG_TARGET_IS_MINGW)
67
+ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/mingw.cmake")
68
+ elseif(VCPKG_TARGET_IS_WINDOWS)
69
+ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake")
70
+ elseif(VCPKG_TARGET_IS_LINUX)
71
+ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/linux.cmake")
72
+ elseif(VCPKG_TARGET_IS_ANDROID)
73
+ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/android.cmake")
74
+ elseif(VCPKG_TARGET_IS_OSX)
75
+ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/osx.cmake")
76
+ elseif(VCPKG_TARGET_IS_IOS)
77
+ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/ios.cmake")
78
+ elseif(VCPKG_TARGET_IS_FREEBSD)
79
+ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/freebsd.cmake")
80
+ elseif(VCPKG_TARGET_IS_OPENBSD)
81
+ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/openbsd.cmake")
82
+ endif()
83
+ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${VCPKG_CHAINLOAD_TOOLCHAIN_FILE} PARENT_SCOPE)
84
+ endfunction()
85
+
86
+
87
+ function(vcpkg_configure_cmake)
88
+ cmake_parse_arguments(PARSE_ARGV 0 arg
89
+ "PREFER_NINJA;DISABLE_PARALLEL_CONFIGURE;NO_CHARSET_FLAG;Z_GET_CMAKE_VARS_USAGE"
90
+ "SOURCE_PATH;GENERATOR;LOGNAME"
91
+ "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;MAYBE_UNUSED_VARIABLES"
92
+ )
93
+
94
+ if(NOT arg_Z_GET_CMAKE_VARS_USAGE AND Z_VCPKG_CMAKE_CONFIGURE_GUARD)
95
+ message(FATAL_ERROR "The ${PORT} port already depends on vcpkg-cmake; using both vcpkg-cmake and vcpkg_configure_cmake in the same port is unsupported.")
96
+ endif()
97
+
98
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
99
+ message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
100
+ endif()
101
+ if(NOT DEFINED arg_SOURCE_PATH)
102
+ message(FATAL_ERROR "SOURCE_PATH must be specified")
103
+ endif()
104
+ if(NOT DEFINED arg_LOGNAME)
105
+ set(arg_LOGNAME "config-${TARGET_TRIPLET}")
106
+ endif()
107
+
108
+ vcpkg_list(SET manually_specified_variables)
109
+
110
+ if(arg_Z_GET_CMAKE_VARS_USAGE)
111
+ set(configuring_message "Getting CMake variables for ${TARGET_TRIPLET}")
112
+ else()
113
+ set(configuring_message "Configuring ${TARGET_TRIPLET}")
114
+
115
+ foreach(option IN LISTS arg_OPTIONS arg_OPTIONS_RELEASE arg_OPTIONS_DEBUG)
116
+ if("${option}" MATCHES "^-D([^:=]*)[:=]")
117
+ vcpkg_list(APPEND manually_specified_variables "${CMAKE_MATCH_1}")
118
+ endif()
119
+ endforeach()
120
+ vcpkg_list(REMOVE_DUPLICATES manually_specified_variables)
121
+ foreach(maybe_unused_var IN LISTS arg_MAYBE_UNUSED_VARIABLES)
122
+ vcpkg_list(REMOVE_ITEM manually_specified_variables "${maybe_unused_var}")
123
+ endforeach()
124
+ debug_message("manually specified variables: ${manually_specified_variables}")
125
+ endif()
126
+
127
+ set(ninja_can_be_used ON) # Ninja as generator
128
+ set(ninja_host ON) # Ninja as parallel configurator
129
+
130
+ if(NOT arg_PREFER_NINJA AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
131
+ set(ninja_can_be_used OFF)
132
+ endif()
133
+
134
+ if(VCPKG_HOST_IS_WINDOWS)
135
+ if(DEFINED ENV{PROCESSOR_ARCHITEW6432})
136
+ set(host_arch "$ENV{PROCESSOR_ARCHITEW6432}")
137
+ else()
138
+ set(host_arch "$ENV{PROCESSOR_ARCHITECTURE}")
139
+ endif()
140
+
141
+ if("${host_arch}" STREQUAL "x86")
142
+ # Prebuilt ninja binaries are only provided for x64 hosts
143
+ set(ninja_can_be_used OFF)
144
+ set(ninja_host OFF)
145
+ endif()
146
+ endif()
147
+
148
+ set(generator "Ninja") # the default generator is always ninja!
149
+ set(generator_arch "")
150
+ if(DEFINED arg_GENERATOR)
151
+ set(generator "${arg_GENERATOR}")
152
+ elseif(NOT ninja_can_be_used)
153
+ set(generator "")
154
+ z_vcpkg_get_visual_studio_generator(OUT_GENERATOR generator OUT_ARCH generator_arch)
155
+ if("${generator}" STREQUAL "" OR "${generator_arch}" STREQUAL "")
156
+ message(FATAL_ERROR
157
+ "Unable to determine appropriate generator for triplet ${TARGET_TRIPLET}:
158
+ ENV{VisualStudioVersion} : $ENV{VisualStudioVersion}
159
+ platform toolset: ${VCPKG_PLATFORM_TOOLSET}
160
+ architecture : ${VCPKG_TARGET_ARCHITECTURE}")
161
+ endif()
162
+ if(DEFINED VCPKG_PLATFORM_TOOLSET)
163
+ vcpkg_list(APPEND arg_OPTIONS "-T${VCPKG_PLATFORM_TOOLSET}")
164
+ endif()
165
+ endif()
166
+
167
+ # If we use Ninja, make sure it's on PATH
168
+ if("${generator}" STREQUAL "Ninja" AND NOT DEFINED ENV{VCPKG_FORCE_SYSTEM_BINARIES})
169
+ vcpkg_find_acquire_program(NINJA)
170
+ get_filename_component(ninja_path "${NINJA}" DIRECTORY)
171
+ vcpkg_add_to_path("${ninja_path}")
172
+ vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_MAKE_PROGRAM=${NINJA}")
173
+ endif()
174
+
175
+ file(REMOVE_RECURSE
176
+ "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
177
+ "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
178
+
179
+ if(DEFINED VCPKG_CMAKE_SYSTEM_NAME)
180
+ vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_SYSTEM_NAME=${VCPKG_CMAKE_SYSTEM_NAME}")
181
+ if(VCPKG_TARGET_IS_UWP AND NOT DEFINED VCPKG_CMAKE_SYSTEM_VERSION)
182
+ set(VCPKG_CMAKE_SYSTEM_VERSION 10.0)
183
+ elseif(VCPKG_TARGET_IS_ANDROID AND NOT DEFINED VCPKG_CMAKE_SYSTEM_VERSION)
184
+ set(VCPKG_CMAKE_SYSTEM_VERSION 21)
185
+ endif()
186
+ endif()
187
+
188
+ if(DEFINED VCPKG_XBOX_CONSOLE_TARGET)
189
+ vcpkg_list(APPEND arg_OPTIONS "-DXBOX_CONSOLE_TARGET=${VCPKG_XBOX_CONSOLE_TARGET}")
190
+ endif()
191
+
192
+ if(DEFINED VCPKG_CMAKE_SYSTEM_VERSION)
193
+ vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_SYSTEM_VERSION=${VCPKG_CMAKE_SYSTEM_VERSION}")
194
+ endif()
195
+
196
+ if("${VCPKG_LIBRARY_LINKAGE}" STREQUAL "dynamic")
197
+ vcpkg_list(APPEND arg_OPTIONS -DBUILD_SHARED_LIBS=ON)
198
+ elseif("${VCPKG_LIBRARY_LINKAGE}" STREQUAL "static")
199
+ vcpkg_list(APPEND arg_OPTIONS -DBUILD_SHARED_LIBS=OFF)
200
+ else()
201
+ message(FATAL_ERROR
202
+ "Invalid setting for VCPKG_LIBRARY_LINKAGE: \"${VCPKG_LIBRARY_LINKAGE}\".
203
+ It must be \"static\" or \"dynamic\"")
204
+ endif()
205
+
206
+ z_vcpkg_configure_cmake_both_or_neither_set(VCPKG_CXX_FLAGS_DEBUG VCPKG_C_FLAGS_DEBUG)
207
+ z_vcpkg_configure_cmake_both_or_neither_set(VCPKG_CXX_FLAGS_RELEASE VCPKG_C_FLAGS_RELEASE)
208
+ z_vcpkg_configure_cmake_both_or_neither_set(VCPKG_CXX_FLAGS VCPKG_C_FLAGS)
209
+
210
+ set(vcpkg_set_charset_flag ON)
211
+ if(arg_NO_CHARSET_FLAG)
212
+ set(vcpkg_set_charset_flag OFF)
213
+ endif()
214
+
215
+ if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
216
+ z_vcpkg_select_default_vcpkg_chainload_toolchain()
217
+ endif()
218
+
219
+ vcpkg_list(APPEND arg_OPTIONS
220
+ "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}"
221
+ "-DVCPKG_TARGET_TRIPLET=${TARGET_TRIPLET}"
222
+ "-DVCPKG_SET_CHARSET_FLAG=${vcpkg_set_charset_flag}"
223
+ "-DVCPKG_PLATFORM_TOOLSET=${VCPKG_PLATFORM_TOOLSET}"
224
+ "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON"
225
+ "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON"
226
+ "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON"
227
+ "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE"
228
+ "-DCMAKE_VERBOSE_MAKEFILE=ON"
229
+ "-DVCPKG_APPLOCAL_DEPS=OFF"
230
+ "-DCMAKE_TOOLCHAIN_FILE=${SCRIPTS}/buildsystems/vcpkg.cmake"
231
+ "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON"
232
+ "-DVCPKG_CXX_FLAGS=${VCPKG_CXX_FLAGS}"
233
+ "-DVCPKG_CXX_FLAGS_RELEASE=${VCPKG_CXX_FLAGS_RELEASE}"
234
+ "-DVCPKG_CXX_FLAGS_DEBUG=${VCPKG_CXX_FLAGS_DEBUG}"
235
+ "-DVCPKG_C_FLAGS=${VCPKG_C_FLAGS}"
236
+ "-DVCPKG_C_FLAGS_RELEASE=${VCPKG_C_FLAGS_RELEASE}"
237
+ "-DVCPKG_C_FLAGS_DEBUG=${VCPKG_C_FLAGS_DEBUG}"
238
+ "-DVCPKG_CRT_LINKAGE=${VCPKG_CRT_LINKAGE}"
239
+ "-DVCPKG_LINKER_FLAGS=${VCPKG_LINKER_FLAGS}"
240
+ "-DVCPKG_LINKER_FLAGS_RELEASE=${VCPKG_LINKER_FLAGS_RELEASE}"
241
+ "-DVCPKG_LINKER_FLAGS_DEBUG=${VCPKG_LINKER_FLAGS_DEBUG}"
242
+ "-DVCPKG_TARGET_ARCHITECTURE=${VCPKG_TARGET_ARCHITECTURE}"
243
+ "-DCMAKE_INSTALL_LIBDIR:STRING=lib"
244
+ "-DCMAKE_INSTALL_BINDIR:STRING=bin"
245
+ "-D_VCPKG_ROOT_DIR=${VCPKG_ROOT_DIR}"
246
+ "-DZ_VCPKG_ROOT_DIR=${VCPKG_ROOT_DIR}"
247
+ "-D_VCPKG_INSTALLED_DIR=${_VCPKG_INSTALLED_DIR}"
248
+ "-DVCPKG_MANIFEST_INSTALL=OFF"
249
+ )
250
+
251
+ if(NOT "${generator_arch}" STREQUAL "")
252
+ vcpkg_list(APPEND arg_OPTIONS "-A${generator_arch}")
253
+ endif()
254
+
255
+ # Sets configuration variables for macOS builds
256
+ foreach(config_var IN ITEMS INSTALL_NAME_DIR OSX_DEPLOYMENT_TARGET OSX_SYSROOT OSX_ARCHITECTURES)
257
+ if(DEFINED "VCPKG_${config_var}")
258
+ vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_${config_var}=${VCPKG_${config_var}}")
259
+ endif()
260
+ endforeach()
261
+
262
+ # Allow overrides / additional configuration variables from triplets
263
+ if(DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS)
264
+ vcpkg_list(APPEND arg_OPTIONS ${VCPKG_CMAKE_CONFIGURE_OPTIONS})
265
+ endif()
266
+ if(DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS_RELEASE)
267
+ vcpkg_list(APPEND arg_OPTIONS_RELEASE ${VCPKG_CMAKE_CONFIGURE_OPTIONS_RELEASE})
268
+ endif()
269
+ if(DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS_DEBUG)
270
+ vcpkg_list(APPEND arg_OPTIONS_DEBUG ${VCPKG_CMAKE_CONFIGURE_OPTIONS_DEBUG})
271
+ endif()
272
+
273
+ vcpkg_list(SET rel_command
274
+ "${CMAKE_COMMAND}" "${arg_SOURCE_PATH}"
275
+ -G "${generator}"
276
+ "-DCMAKE_BUILD_TYPE=Release"
277
+ "-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}"
278
+ ${arg_OPTIONS} ${arg_OPTIONS_RELEASE})
279
+ vcpkg_list(SET dbg_command
280
+ "${CMAKE_COMMAND}" "${arg_SOURCE_PATH}"
281
+ -G "${generator}"
282
+ "-DCMAKE_BUILD_TYPE=Debug"
283
+ "-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug"
284
+ ${arg_OPTIONS} ${arg_OPTIONS_DEBUG})
285
+
286
+ if(ninja_host AND CMAKE_HOST_WIN32 AND NOT arg_DISABLE_PARALLEL_CONFIGURE)
287
+ vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_DISABLE_SOURCE_CHANGES=ON")
288
+
289
+ vcpkg_find_acquire_program(NINJA)
290
+ if(NOT DEFINED ninja_path)
291
+ # if ninja_path was defined above, we've already done this
292
+ get_filename_component(ninja_path "${NINJA}" DIRECTORY)
293
+ vcpkg_add_to_path("${ninja_path}")
294
+ endif()
295
+
296
+ #parallelize the configure step
297
+ set(ninja_configure_contents
298
+ "rule CreateProcess\n command = \$process\n\n"
299
+ )
300
+
301
+ if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "release")
302
+ z_vcpkg_configure_cmake_build_cmakecache(ninja_configure_contents ".." "rel")
303
+ endif()
304
+ if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "debug")
305
+ z_vcpkg_configure_cmake_build_cmakecache(ninja_configure_contents "../../${TARGET_TRIPLET}-dbg" "dbg")
306
+ endif()
307
+
308
+ file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure")
309
+ file(WRITE
310
+ "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure/build.ninja"
311
+ "${ninja_configure_contents}")
312
+
313
+ message(STATUS "${configuring_message}")
314
+ vcpkg_execute_required_process(
315
+ COMMAND "${NINJA}" -v
316
+ WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure"
317
+ LOGNAME "${arg_LOGNAME}"
318
+ SAVE_LOG_FILES
319
+ "../../${TARGET_TRIPLET}-dbg/CMakeCache.txt" ALIAS "dbg-CMakeCache.txt.log"
320
+ "../CMakeCache.txt" ALIAS "rel-CMakeCache.txt.log"
321
+ )
322
+
323
+ vcpkg_list(APPEND config_logs
324
+ "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-out.log"
325
+ "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-err.log")
326
+ else()
327
+ if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "debug")
328
+ message(STATUS "${configuring_message}-dbg")
329
+ file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
330
+ vcpkg_execute_required_process(
331
+ COMMAND ${dbg_command}
332
+ WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg"
333
+ LOGNAME "${arg_LOGNAME}-dbg"
334
+ SAVE_LOG_FILES CMakeCache.txt
335
+ )
336
+ vcpkg_list(APPEND config_logs
337
+ "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-dbg-out.log"
338
+ "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-dbg-err.log")
339
+ endif()
340
+
341
+ if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "release")
342
+ message(STATUS "${configuring_message}-rel")
343
+ file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
344
+ vcpkg_execute_required_process(
345
+ COMMAND ${rel_command}
346
+ WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
347
+ LOGNAME "${arg_LOGNAME}-rel"
348
+ SAVE_LOG_FILES CMakeCache.txt
349
+ )
350
+ vcpkg_list(APPEND config_logs
351
+ "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-rel-out.log"
352
+ "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-rel-err.log")
353
+ endif()
354
+ endif()
355
+
356
+ # Check unused variables
357
+ vcpkg_list(SET all_unused_variables)
358
+ foreach(config_log IN LISTS config_logs)
359
+ if(NOT EXISTS "${config_log}")
360
+ continue()
361
+ endif()
362
+ file(READ "${config_log}" log_contents)
363
+ debug_message("Reading configure log ${config_log}...")
364
+ if(NOT "${log_contents}" MATCHES "Manually-specified variables were not used by the project:\n\n(( [^\n]*\n)*)")
365
+ continue()
366
+ endif()
367
+ string(STRIP "${CMAKE_MATCH_1}" unused_variables) # remove leading ` ` and trailing `\n`
368
+ string(REPLACE "\n " ";" unused_variables "${unused_variables}")
369
+ debug_message("unused variables: ${unused_variables}")
370
+
371
+ foreach(unused_variable IN LISTS unused_variables)
372
+ if("${unused_variable}" IN_LIST manually_specified_variables)
373
+ debug_message("manually specified unused variable: ${unused_variable}")
374
+ vcpkg_list(APPEND all_unused_variables "${unused_variable}")
375
+ else()
376
+ debug_message("unused variable (not manually specified): ${unused_variable}")
377
+ endif()
378
+ endforeach()
379
+ endforeach()
380
+
381
+ if(NOT "${all_unused_variables}" STREQUAL "")
382
+ vcpkg_list(REMOVE_DUPLICATES all_unused_variables)
383
+ vcpkg_list(JOIN all_unused_variables "\n " all_unused_variables)
384
+ message(WARNING "The following variables are not used in CMakeLists.txt:
385
+ ${all_unused_variables}
386
+ Please recheck them and remove the unnecessary options from the `vcpkg_configure_cmake` call.
387
+ If these options should still be passed for whatever reason, please use the `MAYBE_UNUSED_VARIABLES` argument.")
388
+ endif()
389
+
390
+ if(NOT arg_Z_GET_CMAKE_VARS_USAGE)
391
+ set(Z_VCPKG_CMAKE_GENERATOR "${generator}" PARENT_SCOPE)
392
+ endif()
393
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_configure_make.cmake ADDED
@@ -0,0 +1,912 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ macro(z_vcpkg_determine_autotools_host_cpu out_var)
2
+ # TODO: the host system processor architecture can differ from the host triplet target architecture
3
+ if(DEFINED ENV{PROCESSOR_ARCHITEW6432})
4
+ set(host_arch $ENV{PROCESSOR_ARCHITEW6432})
5
+ elseif(DEFINED ENV{PROCESSOR_ARCHITECTURE})
6
+ set(host_arch $ENV{PROCESSOR_ARCHITECTURE})
7
+ else()
8
+ set(host_arch "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}")
9
+ endif()
10
+ if(host_arch MATCHES "(amd|AMD)64")
11
+ set(${out_var} x86_64)
12
+ elseif(host_arch MATCHES "(x|X)86")
13
+ set(${out_var} i686)
14
+ elseif(host_arch MATCHES "^(ARM|arm)64$")
15
+ set(${out_var} aarch64)
16
+ elseif(host_arch MATCHES "^(ARM|arm)$")
17
+ set(${out_var} arm)
18
+ else()
19
+ message(FATAL_ERROR "Unsupported host architecture ${host_arch} in z_vcpkg_determine_autotools_host_cpu!" )
20
+ endif()
21
+ unset(host_arch)
22
+ endmacro()
23
+
24
+ macro(z_vcpkg_determine_autotools_target_cpu out_var)
25
+ if(VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)64")
26
+ set(${out_var} x86_64)
27
+ elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)86")
28
+ set(${out_var} i686)
29
+ elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)64$")
30
+ set(${out_var} aarch64)
31
+ elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)$")
32
+ set(${out_var} arm)
33
+ else()
34
+ message(FATAL_ERROR "Unsupported VCPKG_TARGET_ARCHITECTURE architecture ${VCPKG_TARGET_ARCHITECTURE} in z_vcpkg_determine_autotools_target_cpu!" )
35
+ endif()
36
+ endmacro()
37
+
38
+ macro(z_vcpkg_set_arch_mac out_var value)
39
+ # Better match the arch behavior of config.guess
40
+ # See: https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
41
+ if("${value}" MATCHES "^(ARM|arm)64$")
42
+ set(${out_var} "aarch64")
43
+ else()
44
+ set(${out_var} "${value}")
45
+ endif()
46
+ endmacro()
47
+
48
+ macro(z_vcpkg_determine_autotools_host_arch_mac out_var)
49
+ z_vcpkg_set_arch_mac(${out_var} "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}")
50
+ endmacro()
51
+
52
+ macro(z_vcpkg_determine_autotools_target_arch_mac out_var)
53
+ list(LENGTH VCPKG_OSX_ARCHITECTURES osx_archs_num)
54
+ if(osx_archs_num EQUAL 0)
55
+ z_vcpkg_set_arch_mac(${out_var} "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}")
56
+ elseif(osx_archs_num GREATER_EQUAL 2)
57
+ set(${out_var} "universal")
58
+ else()
59
+ z_vcpkg_set_arch_mac(${out_var} "${VCPKG_OSX_ARCHITECTURES}")
60
+ endif()
61
+ unset(osx_archs_num)
62
+ endmacro()
63
+
64
+ # Define variables used in both vcpkg_configure_make and vcpkg_build_make:
65
+ # short_name_<CONFIG>: unique abbreviation for the given build type (rel, dbg)
66
+ # path_suffix_<CONFIG>: installation path suffix for the given build type ('', /debug)
67
+ # current_installed_dir_escaped: CURRENT_INSTALLED_DIR with escaped space characters
68
+ # current_installed_dir_msys: CURRENT_INSTALLED_DIR with unprotected spaces, but drive letters transformed for msys
69
+ macro(z_vcpkg_configure_make_common_definitions)
70
+ set(short_name_RELEASE "rel")
71
+ set(short_name_DEBUG "dbg")
72
+
73
+ set(path_suffix_RELEASE "")
74
+ set(path_suffix_DEBUG "/debug")
75
+
76
+ # Some PATH handling for dealing with spaces....some tools will still fail with that!
77
+ # In particular, the libtool install command is unable to install correctly to paths with spaces.
78
+ string(REPLACE " " "\\ " current_installed_dir_escaped "${CURRENT_INSTALLED_DIR}")
79
+ set(current_installed_dir_msys "${CURRENT_INSTALLED_DIR}")
80
+ if(CMAKE_HOST_WIN32)
81
+ string(REGEX REPLACE "^([a-zA-Z]):/" "/\\1/" current_installed_dir_msys "${current_installed_dir_msys}")
82
+ endif()
83
+ endmacro()
84
+
85
+ # Initializes well-known and auxiliary variables for flags
86
+ # - CPPFLAGS_<CONFIG>: preprocessor flags common to C and CXX
87
+ # - CFLAGS_<CONFIG>
88
+ # - CXXFLAGS_<CONFIG>
89
+ # - LDFLAGS_<CONFIG>
90
+ # - ARFLAGS_<CONFIG>
91
+ # - LINK_ENV_${var_suffix}
92
+ # Prerequisite: VCPKG_DETECTED_CMAKE_... vars loaded
93
+ function(z_vcpkg_configure_make_process_flags var_suffix)
94
+ # separate_arguments is needed to remove outer quotes from detected cmake variables.
95
+ # (e.g. Android NDK has "--sysroot=...")
96
+ separate_arguments(CFLAGS NATIVE_COMMAND "Z_VCM_WRAP ${VCPKG_DETECTED_CMAKE_C_FLAGS_${var_suffix}} Z_VCM_WRAP")
97
+ separate_arguments(CXXFLAGS NATIVE_COMMAND "Z_VCM_WRAP ${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${var_suffix}} Z_VCM_WRAP")
98
+ separate_arguments(LDFLAGS NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${var_suffix}}")
99
+ separate_arguments(ARFLAGS NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${var_suffix}}")
100
+ foreach(var IN ITEMS CFLAGS CXXFLAGS LDFLAGS ARFLAGS)
101
+ vcpkg_list(APPEND z_vcm_all_flags ${${var}})
102
+ endforeach()
103
+ set(z_vcm_all_flags "${z_vcm_all_flags}" PARENT_SCOPE)
104
+
105
+ # Filter common CPPFLAGS out of CFLAGS and CXXFLAGS
106
+ vcpkg_list(SET CPPFLAGS)
107
+ vcpkg_list(SET pattern)
108
+ foreach(arg IN LISTS CXXFLAGS)
109
+ if(arg STREQUAL "Z_VCM_WRAP")
110
+ continue()
111
+ elseif(NOT pattern STREQUAL "")
112
+ vcpkg_list(APPEND pattern "${arg}")
113
+ elseif(arg MATCHES "^-(D|isystem).")
114
+ vcpkg_list(SET pattern "${arg}")
115
+ elseif(arg MATCHES "^-(D|isystem)\$")
116
+ vcpkg_list(SET pattern "${arg}")
117
+ continue()
118
+ elseif(arg MATCHES "^-(-sysroot|-target|m?[Aa][Rr][Cc][Hh])=.")
119
+ vcpkg_list(SET pattern "${arg}")
120
+ elseif(arg MATCHES "^-(isysroot|m32|m64|m?[Aa][Rr][Cc][Hh]|target)\$")
121
+ vcpkg_list(SET pattern "${arg}")
122
+ continue()
123
+ else()
124
+ continue()
125
+ endif()
126
+ string(FIND "${CFLAGS}" ";${pattern};" index)
127
+ if(NOT index STREQUAL "-1")
128
+ vcpkg_list(APPEND CPPFLAGS ${pattern})
129
+ string(REPLACE ";${pattern};" ";" CFLAGS "${CFLAGS}")
130
+ string(REPLACE ";${pattern};" ";" CXXFLAGS "${CXXFLAGS}")
131
+ endif()
132
+ vcpkg_list(SET pattern)
133
+ endforeach()
134
+ vcpkg_list(SET pattern)
135
+ foreach(arg IN LISTS CFLAGS)
136
+ if(arg STREQUAL "Z_VCM_WRAP")
137
+ continue()
138
+ elseif(NOT pattern STREQUAL "")
139
+ vcpkg_list(APPEND pattern "${arg}")
140
+ elseif(arg MATCHES "^-(D|isystem)\$")
141
+ vcpkg_list(SET pattern "${arg}")
142
+ continue()
143
+ elseif(arg MATCHES "^-(D|isystem).")
144
+ vcpkg_list(SET pattern "${arg}")
145
+ elseif(arg MATCHES "^-(-sysroot|-target|m?[Aa][Rr][Cc][Hh])=.")
146
+ vcpkg_list(SET pattern "${arg}")
147
+ elseif(arg MATCHES "^-(isysroot|m32|m64|m?[Aa][Rr][Cc][Hh]|target)\$")
148
+ vcpkg_list(SET pattern "${arg}")
149
+ continue()
150
+ else()
151
+ continue()
152
+ endif()
153
+ string(FIND "${CXXFLAGS}" ";${pattern};" index)
154
+ if(NOT index STREQUAL "-1")
155
+ vcpkg_list(APPEND CPPFLAGS ${pattern})
156
+ string(REPLACE ";${pattern};" ";" CFLAGS "${CFLAGS}")
157
+ string(REPLACE ";${pattern};" ";" CXXFLAGS "${CXXFLAGS}")
158
+ endif()
159
+ vcpkg_list(SET pattern)
160
+ endforeach()
161
+
162
+ # Remove start/end placeholders
163
+ foreach(list IN ITEMS CFLAGS CXXFLAGS)
164
+ vcpkg_list(REMOVE_ITEM ${list} "Z_VCM_WRAP")
165
+ endforeach()
166
+
167
+ # libtool tries to filter CFLAGS passed to the link stage via a whitelist.
168
+ # This approach is flawed since it fails to pass flags unknown to libtool
169
+ # but required for linking to the link stage (e.g. -fsanitize=<x>).
170
+ # libtool has an -R option so we need to guard against -RTC by using -Xcompiler.
171
+ # While configuring there might be a lot of unknown compiler option warnings
172
+ # due to that; just ignore them.
173
+ set(compiler_flag_escape "")
174
+ if(VCPKG_DETECTED_CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC" OR VCPKG_DETECTED_CMAKE_C_COMPILER_ID STREQUAL "MSVC")
175
+ set(compiler_flag_escape "-Xcompiler ")
176
+ endif()
177
+ if(compiler_flag_escape)
178
+ list(TRANSFORM CFLAGS PREPEND "${compiler_flag_escape}")
179
+ list(TRANSFORM CXXFLAGS PREPEND "${compiler_flag_escape}")
180
+ endif()
181
+
182
+ # Could use a future VCPKG_DETECTED_CMAKE_LIBRARY_PATH_FLAG
183
+ set(library_path_flag "-L")
184
+ # Could use a future VCPKG_DETECTED_MSVC
185
+ if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_DETECTED_CMAKE_LINKER MATCHES [[link\.exe$]])
186
+ set(library_path_flag "-LIBPATH:")
187
+ endif()
188
+ set(linker_flag_escape "")
189
+ if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES [[cl\.exe$]])
190
+ # Removed by libtool
191
+ set(linker_flag_escape "-Xlinker ")
192
+ if(arg_USE_WRAPPERS)
193
+ # 1st and 3rd are removed by libtool, 2nd by wrapper
194
+ set(linker_flag_escape "-Xlinker -Xlinker -Xlinker ")
195
+ endif()
196
+ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
197
+ string(STRIP "$ENV{_LINK_} ${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${var_suffix}}" LINK_ENV)
198
+ else()
199
+ string(STRIP "$ENV{_LINK_} ${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${var_suffix}}" LINK_ENV)
200
+ endif()
201
+ endif()
202
+ if(linker_flag_escape)
203
+ list(TRANSFORM LDFLAGS PREPEND "${linker_flag_escape}")
204
+ endif()
205
+ if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib/manual-link")
206
+ vcpkg_list(PREPEND LDFLAGS "${linker_flag_escape}${library_path_flag}${current_installed_dir_escaped}${path_suffix_${var_suffix}}/lib/manual-link")
207
+ endif()
208
+ if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib")
209
+ vcpkg_list(PREPEND LDFLAGS "${linker_flag_escape}${library_path_flag}${current_installed_dir_escaped}${path_suffix_${var_suffix}}/lib")
210
+ endif()
211
+
212
+ if(ARFLAGS)
213
+ # ARFLAGS need to know the command for creating an archive (Maybe needs user customization?)
214
+ # or extract it from CMake via CMAKE_${lang}_ARCHIVE_CREATE ?
215
+ # or from CMAKE_${lang}_${rule} with rule being one of CREATE_SHARED_MODULE CREATE_SHARED_LIBRARY LINK_EXECUTABLE
216
+ vcpkg_list(PREPEND ARFLAGS "cr")
217
+ endif()
218
+
219
+ foreach(var IN ITEMS CPPFLAGS CFLAGS CXXFLAGS LDFLAGS ARFLAGS)
220
+ list(JOIN ${var} " " string)
221
+ set(${var}_${var_suffix} "${string}" PARENT_SCOPE)
222
+ endforeach()
223
+ endfunction()
224
+
225
+ macro(z_vcpkg_append_to_configure_environment inoutstring var defaultval)
226
+ # Allows to overwrite settings in custom triplets via the environment on windows
227
+ if(CMAKE_HOST_WIN32 AND DEFINED ENV{${var}})
228
+ string(APPEND ${inoutstring} " ${var}='$ENV{${var}}'")
229
+ else()
230
+ string(APPEND ${inoutstring} " ${var}='${defaultval}'")
231
+ endif()
232
+ endmacro()
233
+
234
+ function(vcpkg_configure_make)
235
+ # parse parameters such that semicolons in options arguments to COMMAND don't get erased
236
+ cmake_parse_arguments(PARSE_ARGV 0 arg
237
+ "AUTOCONFIG;SKIP_CONFIGURE;COPY_SOURCE;DISABLE_VERBOSE_FLAGS;NO_ADDITIONAL_PATHS;ADD_BIN_TO_PATH;NO_DEBUG;USE_WRAPPERS;NO_WRAPPERS;DETERMINE_BUILD_TRIPLET"
238
+ "SOURCE_PATH;PROJECT_SUBPATH;PRERUN_SHELL;BUILD_TRIPLET"
239
+ "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;CONFIGURE_ENVIRONMENT_VARIABLES;CONFIG_DEPENDENT_ENVIRONMENT;ADDITIONAL_MSYS_PACKAGES"
240
+ )
241
+
242
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
243
+ message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
244
+ endif()
245
+
246
+ if(arg_USE_WRAPPERS AND arg_NO_WRAPPERS)
247
+ message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed conflicting options USE_WRAPPERS and NO_WRAPPERS. Please remove one of them!")
248
+ endif()
249
+
250
+ z_vcpkg_get_cmake_vars(cmake_vars_file)
251
+ debug_message("Including cmake vars from: ${cmake_vars_file}")
252
+ include("${cmake_vars_file}")
253
+
254
+ if(DEFINED VCPKG_MAKE_BUILD_TRIPLET)
255
+ set(arg_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling
256
+ endif()
257
+
258
+ set(src_dir "${arg_SOURCE_PATH}/${arg_PROJECT_SUBPATH}")
259
+
260
+ set(requires_autogen OFF) # use autogen.sh
261
+ set(requires_autoconfig OFF) # use autotools and configure.ac
262
+ if(EXISTS "${src_dir}/configure" AND EXISTS "${src_dir}/configure.ac" AND arg_AUTOCONFIG) # remove configure; rerun autoconf
263
+ set(requires_autoconfig ON)
264
+ file(REMOVE "${SRC_DIR}/configure") # remove possible outdated configure scripts
265
+ elseif(arg_SKIP_CONFIGURE)
266
+ # no action requested
267
+ elseif(EXISTS "${src_dir}/configure")
268
+ # run normally; no autoconf or autogen required
269
+ elseif(EXISTS "${src_dir}/configure.ac") # Run autoconfig
270
+ set(requires_autoconfig ON)
271
+ set(arg_AUTOCONFIG ON)
272
+ elseif(EXISTS "${src_dir}/autogen.sh") # Run autogen
273
+ set(requires_autogen ON)
274
+ else()
275
+ message(FATAL_ERROR "Could not determine method to configure make")
276
+ endif()
277
+
278
+ debug_message("requires_autogen:${requires_autogen}")
279
+ debug_message("requires_autoconfig:${requires_autoconfig}")
280
+
281
+ if(CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") #only applies to windows (clang-)cl and lib
282
+ if(arg_AUTOCONFIG)
283
+ set(arg_USE_WRAPPERS ON)
284
+ else()
285
+ # Keep the setting from portfiles.
286
+ # Without autotools we assume a custom configure script which correctly handles cl and lib.
287
+ # Otherwise the port needs to set CC|CXX|AR and probably CPP.
288
+ endif()
289
+ else()
290
+ set(arg_USE_WRAPPERS OFF)
291
+ endif()
292
+ if(arg_NO_WRAPPERS)
293
+ set(arg_USE_WRAPPERS OFF)
294
+ endif()
295
+
296
+ # Backup environment variables
297
+ # CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJCXX R UPC Y
298
+ set(cm_FLAGS AR AS CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R UPC Y RC)
299
+ list(TRANSFORM cm_FLAGS APPEND "FLAGS")
300
+ vcpkg_backup_env_variables(VARS ${cm_FLAGS})
301
+
302
+
303
+ # FC fotran compiler | FF Fortran 77 compiler
304
+ # LDFLAGS -> pass -L flags
305
+ # LIBS -> pass -l flags
306
+
307
+ # Used by gcc/linux
308
+ vcpkg_backup_env_variables(VARS C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH)
309
+
310
+ # Used by cl
311
+ vcpkg_backup_env_variables(VARS INCLUDE LIB LIBPATH)
312
+
313
+ vcpkg_list(SET z_vcm_paths_with_spaces)
314
+ if(CURRENT_PACKAGES_DIR MATCHES " ")
315
+ vcpkg_list(APPEND z_vcm_paths_with_spaces "${CURRENT_PACKAGES_DIR}")
316
+ endif()
317
+ if(CURRENT_INSTALLED_DIR MATCHES " ")
318
+ vcpkg_list(APPEND z_vcm_paths_with_spaces "${CURRENT_INSTALLED_DIR}")
319
+ endif()
320
+ if(z_vcm_paths_with_spaces)
321
+ # Don't bother with whitespace. The tools will probably fail and I tried very hard trying to make it work (no success so far)!
322
+ vcpkg_list(APPEND z_vcm_paths_with_spaces "Please move the path to one without whitespaces!")
323
+ list(JOIN z_vcm_paths_with_spaces "\n " z_vcm_paths_with_spaces)
324
+ message(STATUS "Warning: Paths with embedded space may be handled incorrectly by configure:\n ${z_vcm_paths_with_spaces}")
325
+ endif()
326
+
327
+ set(configure_env "V=1")
328
+
329
+ # Establish a bash environment as expected by autotools.
330
+ if(CMAKE_HOST_WIN32)
331
+ list(APPEND msys_require_packages autoconf-wrapper automake-wrapper binutils libtool make pkgconf which)
332
+ vcpkg_acquire_msys(MSYS_ROOT PACKAGES ${msys_require_packages} ${arg_ADDITIONAL_MSYS_PACKAGES})
333
+ set(base_cmd "${MSYS_ROOT}/usr/bin/bash.exe" --noprofile --norc --debug)
334
+ vcpkg_list(SET add_to_env)
335
+ if(arg_USE_WRAPPERS AND VCPKG_TARGET_IS_WINDOWS)
336
+ vcpkg_list(APPEND add_to_env "${SCRIPTS}/buildsystems/make_wrapper") # Other required wrappers are also located there
337
+ vcpkg_list(APPEND add_to_env "${MSYS_ROOT}/usr/share/automake-1.16")
338
+ endif()
339
+ cmake_path(CONVERT "$ENV{PATH}" TO_CMAKE_PATH_LIST path_list NORMALIZE)
340
+ cmake_path(CONVERT "$ENV{SystemRoot}" TO_CMAKE_PATH_LIST system_root NORMALIZE)
341
+ cmake_path(CONVERT "$ENV{LOCALAPPDATA}" TO_CMAKE_PATH_LIST local_app_data NORMALIZE)
342
+ file(REAL_PATH "${system_root}" system_root)
343
+
344
+ message(DEBUG "path_list:${path_list}") # Just to have --trace-expand output
345
+
346
+ vcpkg_list(SET find_system_dirs
347
+ "${system_root}/System32"
348
+ "${system_root}/System32/"
349
+ "${local_app_data}/Microsoft/WindowsApps"
350
+ "${local_app_data}/Microsoft/WindowsApps/"
351
+ )
352
+
353
+ string(TOUPPER "${find_system_dirs}" find_system_dirs_upper)
354
+
355
+ set(index 0)
356
+ set(appending TRUE)
357
+ foreach(item IN LISTS path_list)
358
+ string(TOUPPER "${item}" item_upper)
359
+ if(item_upper IN_LIST find_system_dirs_upper)
360
+ set(appending FALSE)
361
+ break()
362
+ endif()
363
+ math(EXPR index "${index} + 1")
364
+ endforeach()
365
+
366
+ if(appending)
367
+ message(WARNING "Unable to find system dir in the PATH variable! Appending required msys paths!")
368
+ endif()
369
+ vcpkg_list(INSERT path_list "${index}" ${add_to_env} "${MSYS_ROOT}/usr/bin")
370
+
371
+ cmake_path(CONVERT "${path_list}" TO_NATIVE_PATH_LIST native_path_list)
372
+ set(ENV{PATH} "${native_path_list}")
373
+ else()
374
+ find_program(base_cmd bash REQUIRED)
375
+ endif()
376
+
377
+ # macOS - cross-compiling support
378
+ if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS)
379
+ if (requires_autoconfig AND NOT arg_BUILD_TRIPLET OR arg_DETERMINE_BUILD_TRIPLET)
380
+ z_vcpkg_determine_autotools_host_arch_mac(BUILD_ARCH) # machine you are building on => --build=
381
+ z_vcpkg_determine_autotools_target_arch_mac(TARGET_ARCH)
382
+ # --build: the machine you are building on
383
+ # --host: the machine you are building for
384
+ # --target: the machine that CC will produce binaries for
385
+ # https://stackoverflow.com/questions/21990021/how-to-determine-host-value-for-configure-when-using-cross-compiler
386
+ # Only for ports using autotools so we can assume that they follow the common conventions for build/target/host
387
+ if(NOT "${TARGET_ARCH}" STREQUAL "${BUILD_ARCH}" OR NOT VCPKG_TARGET_IS_OSX) # we don't need to specify the additional flags if we build natively.
388
+ set(arg_BUILD_TRIPLET "--host=${TARGET_ARCH}-apple-darwin") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target)
389
+ endif()
390
+ debug_message("Using make triplet: ${arg_BUILD_TRIPLET}")
391
+ endif()
392
+ endif()
393
+
394
+ # Linux - cross-compiling support
395
+ if(VCPKG_TARGET_IS_LINUX)
396
+ if (requires_autoconfig AND NOT arg_BUILD_TRIPLET OR arg_DETERMINE_BUILD_TRIPLET)
397
+ # The regex below takes the prefix from the resulting CMAKE_C_COMPILER variable eg. arm-linux-gnueabihf-gcc
398
+ # set in the common toolchains/linux.cmake
399
+ # This is used via --host as a prefix for all other bin tools as well.
400
+ # Setting the compiler directly via CC=arm-linux-gnueabihf-gcc does not work acording to:
401
+ # https://www.gnu.org/software/autoconf/manual/autoconf-2.65/html_node/Specifying-Target-Triplets.html
402
+ if(VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "([^\/]*)-gcc$" AND CMAKE_MATCH_1)
403
+ set(arg_BUILD_TRIPLET "--host=${CMAKE_MATCH_1}") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target)
404
+ endif()
405
+ debug_message("Using make triplet: ${arg_BUILD_TRIPLET}")
406
+ endif()
407
+ endif()
408
+
409
+ # Pre-processing windows configure requirements
410
+ if (VCPKG_TARGET_IS_WINDOWS)
411
+ if (arg_DETERMINE_BUILD_TRIPLET OR NOT arg_BUILD_TRIPLET)
412
+ z_vcpkg_determine_autotools_host_cpu(BUILD_ARCH) # VCPKG_HOST => machine you are building on => --build=
413
+ z_vcpkg_determine_autotools_target_cpu(TARGET_ARCH)
414
+ # --build: the machine you are building on
415
+ # --host: the machine you are building for
416
+ # --target: the machine that CC will produce binaries for
417
+ # https://stackoverflow.com/questions/21990021/how-to-determine-host-value-for-configure-when-using-cross-compiler
418
+ # Only for ports using autotools so we can assume that they follow the common conventions for build/target/host
419
+ if(CMAKE_HOST_WIN32)
420
+ # Respect host triplet when determining --build
421
+ if(NOT VCPKG_CROSSCOMPILING)
422
+ set(_win32_build_arch "${TARGET_ARCH}")
423
+ else()
424
+ set(_win32_build_arch "${BUILD_ARCH}")
425
+ endif()
426
+
427
+ # This is required since we are running in a msys
428
+ # shell which will be otherwise identified as ${BUILD_ARCH}-pc-msys
429
+ set(arg_BUILD_TRIPLET "--build=${_win32_build_arch}-pc-mingw32")
430
+ endif()
431
+ if(NOT TARGET_ARCH MATCHES "${BUILD_ARCH}" OR NOT CMAKE_HOST_WIN32) # we don't need to specify the additional flags if we build nativly, this does not hold when we are not on windows
432
+ string(APPEND arg_BUILD_TRIPLET " --host=${TARGET_ARCH}-pc-mingw32") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target)
433
+ endif()
434
+ if(VCPKG_TARGET_IS_UWP AND NOT arg_BUILD_TRIPLET MATCHES "--host")
435
+ # Needs to be different from --build to enable cross builds.
436
+ string(APPEND arg_BUILD_TRIPLET " --host=${TARGET_ARCH}-unknown-mingw32")
437
+ endif()
438
+ debug_message("Using make triplet: ${arg_BUILD_TRIPLET}")
439
+ endif()
440
+
441
+ # Remove full filepaths due to spaces and prepend filepaths to PATH (cross-compiling tools are unlikely on path by default)
442
+ set(progs VCPKG_DETECTED_CMAKE_C_COMPILER VCPKG_DETECTED_CMAKE_CXX_COMPILER VCPKG_DETECTED_CMAKE_AR
443
+ VCPKG_DETECTED_CMAKE_LINKER VCPKG_DETECTED_CMAKE_RANLIB VCPKG_DETECTED_CMAKE_OBJDUMP
444
+ VCPKG_DETECTED_CMAKE_STRIP VCPKG_DETECTED_CMAKE_NM VCPKG_DETECTED_CMAKE_DLLTOOL VCPKG_DETECTED_CMAKE_RC_COMPILER)
445
+ foreach(prog IN LISTS progs)
446
+ set(filepath "${${prog}}")
447
+ if(filepath MATCHES " ")
448
+ cmake_path(GET filepath FILENAME ${prog})
449
+ find_program(z_vcm_prog_found NAMES "${${prog}}" PATHS ENV PATH NO_DEFAULT_PATH NO_CACHE)
450
+ if(NOT z_vcm_prog_found STREQUAL filepath)
451
+ cmake_path(GET filepath PARENT_PATH dir)
452
+ vcpkg_add_to_path(PREPEND "${dir}")
453
+ endif()
454
+ endif()
455
+ endforeach()
456
+ if (arg_USE_WRAPPERS)
457
+ z_vcpkg_append_to_configure_environment(configure_env CPP "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER} -E")
458
+
459
+ z_vcpkg_append_to_configure_environment(configure_env CC "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER}")
460
+ if(NOT arg_BUILD_TRIPLET MATCHES "--host")
461
+ z_vcpkg_append_to_configure_environment(configure_env CC_FOR_BUILD "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER}")
462
+ z_vcpkg_append_to_configure_environment(configure_env CPP_FOR_BUILD "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER} -E")
463
+ z_vcpkg_append_to_configure_environment(configure_env CXX_FOR_BUILD "compile ${VCPKG_DETECTED_CMAKE_CXX_COMPILER}")
464
+ else()
465
+ # Silly trick to make configure accept CC_FOR_BUILD but in reallity CC_FOR_BUILD is deactivated.
466
+ z_vcpkg_append_to_configure_environment(configure_env CC_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
467
+ z_vcpkg_append_to_configure_environment(configure_env CPP_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
468
+ z_vcpkg_append_to_configure_environment(configure_env CXX_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
469
+ endif()
470
+ z_vcpkg_append_to_configure_environment(configure_env CXX "compile ${VCPKG_DETECTED_CMAKE_CXX_COMPILER}")
471
+ z_vcpkg_append_to_configure_environment(configure_env RC "windres-rc ${VCPKG_DETECTED_CMAKE_RC_COMPILER}")
472
+ z_vcpkg_append_to_configure_environment(configure_env WINDRES "windres-rc ${VCPKG_DETECTED_CMAKE_RC_COMPILER}")
473
+ if(VCPKG_DETECTED_CMAKE_AR)
474
+ z_vcpkg_append_to_configure_environment(configure_env AR "ar-lib ${VCPKG_DETECTED_CMAKE_AR}")
475
+ else()
476
+ z_vcpkg_append_to_configure_environment(configure_env AR "ar-lib lib.exe -verbose")
477
+ endif()
478
+ else()
479
+ z_vcpkg_append_to_configure_environment(configure_env CPP "${VCPKG_DETECTED_CMAKE_C_COMPILER} -E")
480
+ z_vcpkg_append_to_configure_environment(configure_env CC "${VCPKG_DETECTED_CMAKE_C_COMPILER}")
481
+ if(NOT arg_BUILD_TRIPLET MATCHES "--host")
482
+ z_vcpkg_append_to_configure_environment(configure_env CC_FOR_BUILD "${VCPKG_DETECTED_CMAKE_C_COMPILER}")
483
+ z_vcpkg_append_to_configure_environment(configure_env CPP_FOR_BUILD "${VCPKG_DETECTED_CMAKE_C_COMPILER} -E")
484
+ z_vcpkg_append_to_configure_environment(configure_env CXX_FOR_BUILD "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}")
485
+ else()
486
+ z_vcpkg_append_to_configure_environment(configure_env CC_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
487
+ z_vcpkg_append_to_configure_environment(configure_env CPP_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
488
+ z_vcpkg_append_to_configure_environment(configure_env CXX_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
489
+ endif()
490
+ z_vcpkg_append_to_configure_environment(configure_env CXX "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}")
491
+ z_vcpkg_append_to_configure_environment(configure_env RC "${VCPKG_DETECTED_CMAKE_RC_COMPILER}")
492
+ z_vcpkg_append_to_configure_environment(configure_env WINDRES "${VCPKG_DETECTED_CMAKE_RC_COMPILER}")
493
+ if(VCPKG_DETECTED_CMAKE_AR)
494
+ z_vcpkg_append_to_configure_environment(configure_env AR "${VCPKG_DETECTED_CMAKE_AR}")
495
+ else()
496
+ z_vcpkg_append_to_configure_environment(configure_env AR "lib.exe -verbose")
497
+ endif()
498
+ endif()
499
+ z_vcpkg_append_to_configure_environment(configure_env LD "${VCPKG_DETECTED_CMAKE_LINKER} -verbose")
500
+ if(VCPKG_DETECTED_CMAKE_RANLIB)
501
+ z_vcpkg_append_to_configure_environment(configure_env RANLIB "${VCPKG_DETECTED_CMAKE_RANLIB}") # Trick to ignore the RANLIB call
502
+ else()
503
+ z_vcpkg_append_to_configure_environment(configure_env RANLIB ":")
504
+ endif()
505
+ if(VCPKG_DETECTED_CMAKE_OBJDUMP) #Objdump is required to make shared libraries. Otherwise define lt_cv_deplibs_check_method=pass_all
506
+ z_vcpkg_append_to_configure_environment(configure_env OBJDUMP "${VCPKG_DETECTED_CMAKE_OBJDUMP}") # Trick to ignore the RANLIB call
507
+ endif()
508
+ if(VCPKG_DETECTED_CMAKE_STRIP) # If required set the ENV variable STRIP in the portfile correctly
509
+ z_vcpkg_append_to_configure_environment(configure_env STRIP "${VCPKG_DETECTED_CMAKE_STRIP}")
510
+ else()
511
+ z_vcpkg_append_to_configure_environment(configure_env STRIP ":")
512
+ list(APPEND arg_OPTIONS ac_cv_prog_ac_ct_STRIP=:)
513
+ endif()
514
+ if(VCPKG_DETECTED_CMAKE_NM) # If required set the ENV variable NM in the portfile correctly
515
+ z_vcpkg_append_to_configure_environment(configure_env NM "${VCPKG_DETECTED_CMAKE_NM}")
516
+ else()
517
+ # Would be better to have a true nm here! Some symbols (mainly exported variables) get not properly imported with dumpbin as nm
518
+ # and require __declspec(dllimport) for some reason (same problem CMake has with WINDOWS_EXPORT_ALL_SYMBOLS)
519
+ z_vcpkg_append_to_configure_environment(configure_env NM "dumpbin.exe -symbols -headers")
520
+ endif()
521
+ if(VCPKG_DETECTED_CMAKE_DLLTOOL) # If required set the ENV variable DLLTOOL in the portfile correctly
522
+ z_vcpkg_append_to_configure_environment(configure_env DLLTOOL "${VCPKG_DETECTED_CMAKE_DLLTOOL}")
523
+ else()
524
+ z_vcpkg_append_to_configure_environment(configure_env DLLTOOL "link.exe -verbose -dll")
525
+ endif()
526
+ z_vcpkg_append_to_configure_environment(configure_env CCAS ":") # If required set the ENV variable CCAS in the portfile correctly
527
+ z_vcpkg_append_to_configure_environment(configure_env AS ":") # If required set the ENV variable AS in the portfile correctly
528
+
529
+ foreach(_env IN LISTS arg_CONFIGURE_ENVIRONMENT_VARIABLES)
530
+ z_vcpkg_append_to_configure_environment(configure_env ${_env} "${${_env}}")
531
+ endforeach()
532
+ debug_message("configure_env: '${configure_env}'")
533
+ # Other maybe interesting variables to control
534
+ # COMPILE This is the command used to actually compile a C source file. The file name is appended to form the complete command line.
535
+ # LINK This is the command used to actually link a C program.
536
+ # CXXCOMPILE The command used to actually compile a C++ source file. The file name is appended to form the complete command line.
537
+ # CXXLINK The command used to actually link a C++ program.
538
+
539
+ # Variables not correctly detected by configure. In release builds.
540
+ list(APPEND arg_OPTIONS gl_cv_double_slash_root=yes
541
+ ac_cv_func_memmove=yes)
542
+ #list(APPEND arg_OPTIONS lt_cv_deplibs_check_method=pass_all) # Just ignore libtool checks
543
+ if(VCPKG_TARGET_ARCHITECTURE MATCHES "^[Aa][Rr][Mm]64$")
544
+ list(APPEND arg_OPTIONS gl_cv_host_cpu_c_abi=no)
545
+ # Currently needed for arm64 because objdump yields: "unrecognised machine type (0xaa64) in Import Library Format archive"
546
+ list(APPEND arg_OPTIONS lt_cv_deplibs_check_method=pass_all)
547
+ elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^[Aa][Rr][Mm]$")
548
+ # Currently needed for arm because objdump yields: "unrecognised machine type (0x1c4) in Import Library Format archive"
549
+ list(APPEND arg_OPTIONS lt_cv_deplibs_check_method=pass_all)
550
+ endif()
551
+ else()
552
+ # OSX dosn't like CMAKE_C(XX)_COMPILER (cc) in CC/CXX and rather wants to have gcc/g++
553
+ vcpkg_list(SET z_vcm_all_tools)
554
+ function(z_vcpkg_make_set_env envvar cmakevar)
555
+ set(prog "${VCPKG_DETECTED_CMAKE_${cmakevar}}")
556
+ if(NOT DEFINED ENV{${envvar}} AND NOT prog STREQUAL "")
557
+ vcpkg_list(APPEND z_vcm_all_tools "${prog}")
558
+ if(ARGN)
559
+ string(APPEND prog " ${ARGN}")
560
+ endif()
561
+ set(z_vcm_all_tools "${z_vcm_all_tools}" PARENT_SCOPE)
562
+ set(ENV{${envvar}} "${prog}")
563
+ endif()
564
+ endfunction()
565
+ z_vcpkg_make_set_env(CC C_COMPILER)
566
+ if(NOT arg_BUILD_TRIPLET MATCHES "--host")
567
+ z_vcpkg_make_set_env(CC_FOR_BUILD C_COMPILER)
568
+ z_vcpkg_make_set_env(CPP_FOR_BUILD C_COMPILER "-E")
569
+ z_vcpkg_make_set_env(CXX_FOR_BUILD C_COMPILER)
570
+ else()
571
+ set(ENV{CC_FOR_BUILD} "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
572
+ set(ENV{CPP_FOR_BUILD} "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
573
+ set(ENV{CXX_FOR_BUILD} "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
574
+ endif()
575
+ z_vcpkg_make_set_env(CXX CXX_COMPILER)
576
+ z_vcpkg_make_set_env(NM NM)
577
+ z_vcpkg_make_set_env(RC RC)
578
+ z_vcpkg_make_set_env(WINDRES RC)
579
+ z_vcpkg_make_set_env(DLLTOOL DLLTOOL)
580
+ z_vcpkg_make_set_env(STRIP STRIP)
581
+ z_vcpkg_make_set_env(OBJDUMP OBJDUMP)
582
+ z_vcpkg_make_set_env(RANLIB RANLIB)
583
+ z_vcpkg_make_set_env(AR AR)
584
+ z_vcpkg_make_set_env(LD LINKER)
585
+ unset(z_vcpkg_make_set_env)
586
+ endif()
587
+
588
+ list(FILTER z_vcm_all_tools INCLUDE REGEX " ")
589
+ if(z_vcm_all_tools)
590
+ list(REMOVE_DUPLICATES z_vcm_all_tools)
591
+ list(JOIN z_vcm_all_tools "\n " tools)
592
+ message(STATUS "Warning: Tools with embedded space may be handled incorrectly by configure:\n ${tools}")
593
+ endif()
594
+
595
+ z_vcpkg_configure_make_common_definitions()
596
+
597
+ # Cleanup previous build dirs
598
+ file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_name_RELEASE}"
599
+ "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_name_DEBUG}"
600
+ "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}")
601
+
602
+ # Set configure paths
603
+ vcpkg_list(APPEND arg_OPTIONS_RELEASE "--prefix=${current_installed_dir_msys}")
604
+ vcpkg_list(APPEND arg_OPTIONS_DEBUG "--prefix=${current_installed_dir_msys}${path_suffix_DEBUG}")
605
+ if(NOT arg_NO_ADDITIONAL_PATHS)
606
+ # ${prefix} has an extra backslash to prevent early expansion when calling `bash -c configure "..."`.
607
+ vcpkg_list(APPEND arg_OPTIONS_RELEASE
608
+ # Important: These should all be relative to prefix!
609
+ "--bindir=\\\${prefix}/tools/${PORT}/bin"
610
+ "--sbindir=\\\${prefix}/tools/${PORT}/sbin"
611
+ "--libdir=\\\${prefix}/lib" # On some Linux distributions lib64 is the default
612
+ #"--includedir='\${prefix}'/include" # already the default!
613
+ "--mandir=\\\${prefix}/share/${PORT}"
614
+ "--docdir=\\\${prefix}/share/${PORT}"
615
+ "--datarootdir=\\\${prefix}/share/${PORT}")
616
+ vcpkg_list(APPEND arg_OPTIONS_DEBUG
617
+ # Important: These should all be relative to prefix!
618
+ "--bindir=\\\${prefix}/../tools/${PORT}${path_suffix_DEBUG}/bin"
619
+ "--sbindir=\\\${prefix}/../tools/${PORT}${path_suffix_DEBUG}/sbin"
620
+ "--libdir=\\\${prefix}/lib" # On some Linux distributions lib64 is the default
621
+ "--includedir=\\\${prefix}/../include"
622
+ "--datarootdir=\\\${prefix}/share/${PORT}")
623
+ endif()
624
+ # Setup common options
625
+ if(NOT arg_DISABLE_VERBOSE_FLAGS)
626
+ list(APPEND arg_OPTIONS --disable-silent-rules --verbose)
627
+ endif()
628
+
629
+ if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
630
+ list(APPEND arg_OPTIONS --enable-shared --disable-static)
631
+ else()
632
+ list(APPEND arg_OPTIONS --disable-shared --enable-static)
633
+ endif()
634
+
635
+ # Can be set in the triplet to append options for configure
636
+ if(DEFINED VCPKG_CONFIGURE_MAKE_OPTIONS)
637
+ list(APPEND arg_OPTIONS ${VCPKG_CONFIGURE_MAKE_OPTIONS})
638
+ endif()
639
+ if(DEFINED VCPKG_CONFIGURE_MAKE_OPTIONS_RELEASE)
640
+ list(APPEND arg_OPTIONS_RELEASE ${VCPKG_CONFIGURE_MAKE_OPTIONS_RELEASE})
641
+ endif()
642
+ if(DEFINED VCPKG_CONFIGURE_MAKE_OPTIONS_DEBUG)
643
+ list(APPEND arg_OPTIONS_DEBUG ${VCPKG_CONFIGURE_MAKE_OPTIONS_DEBUG})
644
+ endif()
645
+
646
+ file(RELATIVE_PATH relative_build_path "${CURRENT_BUILDTREES_DIR}" "${arg_SOURCE_PATH}/${arg_PROJECT_SUBPATH}")
647
+
648
+ # Used by CL
649
+ vcpkg_host_path_list(PREPEND ENV{INCLUDE} "${CURRENT_INSTALLED_DIR}/include")
650
+ # Used by GCC
651
+ vcpkg_host_path_list(PREPEND ENV{C_INCLUDE_PATH} "${CURRENT_INSTALLED_DIR}/include")
652
+ vcpkg_host_path_list(PREPEND ENV{CPLUS_INCLUDE_PATH} "${CURRENT_INSTALLED_DIR}/include")
653
+
654
+ # Flags should be set in the toolchain instead (Setting this up correctly requires a function named vcpkg_determined_cmake_compiler_flags which can also be used to setup CC and CXX etc.)
655
+ if(VCPKG_TARGET_IS_WINDOWS)
656
+ vcpkg_backup_env_variables(VARS _CL_ _LINK_)
657
+ # TODO: Should be CPP flags instead -> rewrite when vcpkg_determined_cmake_compiler_flags defined
658
+ if(VCPKG_TARGET_IS_UWP)
659
+ # Be aware that configure thinks it is crosscompiling due to:
660
+ # error while loading shared libraries: VCRUNTIME140D_APP.dll:
661
+ # cannot open shared object file: No such file or directory
662
+ # IMPORTANT: The only way to pass linker flags through libtool AND the compile wrapper
663
+ # is to use the CL and LINK environment variables !!!
664
+ # (This is due to libtool and compiler wrapper using the same set of options to pass those variables around)
665
+ file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}" VCToolsInstallDir)
666
+ set(_replacement -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\")
667
+ string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG}")
668
+ string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG "${VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG}")
669
+ string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE}")
670
+ string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_C_FLAGS_RELEASE "${VCPKG_DETECTED_CMAKE_C_FLAGS_RELEASE}")
671
+ # Can somebody please check if CMake's compiler flags for UWP are correct?
672
+ set(ENV{_CL_} "$ENV{_CL_} -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\"")
673
+ set(ENV{_LINK_} "$ENV{_LINK_} ${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
674
+ endif()
675
+ endif()
676
+
677
+ # Remove outer quotes from cmake variables which will be forwarded via makefile/shell variables
678
+ # substituted into makefile commands (e.g. Android NDK has "--sysroot=...")
679
+ separate_arguments(c_libs_list NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES}")
680
+ separate_arguments(cxx_libs_list NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
681
+ list(REMOVE_ITEM cxx_libs_list ${c_libs_list})
682
+ set(all_libs_list ${cxx_libs_list} ${c_libs_list})
683
+ #Do lib list transformation from name.lib to -lname if necessary
684
+ set(x_vcpkg_transform_libs ON)
685
+ if(VCPKG_TARGET_IS_UWP)
686
+ set(x_vcpkg_transform_libs OFF)
687
+ # Avoid libtool choke: "Warning: linker path does not have real file for library -lWindowsApp."
688
+ # The problem with the choke is that libtool always falls back to built a static library even if a dynamic was requested.
689
+ # Note: Env LIBPATH;LIB are on the search path for libtool by default on windows.
690
+ # It even does unix/dos-short/unix transformation with the path to get rid of spaces.
691
+ endif()
692
+ if(x_vcpkg_transform_libs)
693
+ list(TRANSFORM all_libs_list REPLACE "[.](dll[.]lib|lib|a|so)$" "")
694
+ if(VCPKG_TARGET_IS_WINDOWS)
695
+ list(REMOVE_ITEM all_libs_list "uuid")
696
+ endif()
697
+ list(TRANSFORM all_libs_list REPLACE "^([^-].*)" "-l\\1")
698
+ if(VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
699
+ # libtool must be told explicitly that there is no dynamic linkage for uuid.
700
+ # The "-Wl,..." syntax is understood by libtool and gcc, but no by ld.
701
+ list(TRANSFORM all_libs_list REPLACE "^-luuid\$" "-Wl,-Bstatic,-luuid,-Bdynamic")
702
+ endif()
703
+ endif()
704
+ if(all_libs_list)
705
+ list(JOIN all_libs_list " " all_libs_string)
706
+ if(DEFINED ENV{LIBS})
707
+ set(ENV{LIBS} "$ENV{LIBS} ${all_libs_string}")
708
+ else()
709
+ set(ENV{LIBS} "${all_libs_string}")
710
+ endif()
711
+ endif()
712
+ debug_message("ENV{LIBS}:$ENV{LIBS}")
713
+
714
+ # Run autoconf if necessary
715
+ if (arg_AUTOCONFIG OR requires_autoconfig AND NOT arg_NO_AUTOCONFIG)
716
+ find_program(AUTORECONF autoreconf)
717
+ if(NOT AUTORECONF)
718
+ message(FATAL_ERROR "${PORT} requires autoconf from the system package manager (example: \"sudo apt-get install autoconf\")")
719
+ endif()
720
+ message(STATUS "Generating configure for ${TARGET_TRIPLET}")
721
+ if (CMAKE_HOST_WIN32)
722
+ vcpkg_execute_required_process(
723
+ COMMAND ${base_cmd} -c "autoreconf -vfi"
724
+ WORKING_DIRECTORY "${src_dir}"
725
+ LOGNAME "autoconf-${TARGET_TRIPLET}"
726
+ )
727
+ else()
728
+ vcpkg_execute_required_process(
729
+ COMMAND "${AUTORECONF}" -vfi
730
+ WORKING_DIRECTORY "${src_dir}"
731
+ LOGNAME "autoconf-${TARGET_TRIPLET}"
732
+ )
733
+ endif()
734
+ message(STATUS "Finished generating configure for ${TARGET_TRIPLET}")
735
+ endif()
736
+ if(requires_autogen)
737
+ message(STATUS "Generating configure for ${TARGET_TRIPLET} via autogen.sh")
738
+ if (CMAKE_HOST_WIN32)
739
+ vcpkg_execute_required_process(
740
+ COMMAND ${base_cmd} -c "./autogen.sh"
741
+ WORKING_DIRECTORY "${src_dir}"
742
+ LOGNAME "autoconf-${TARGET_TRIPLET}"
743
+ )
744
+ else()
745
+ vcpkg_execute_required_process(
746
+ COMMAND "./autogen.sh"
747
+ WORKING_DIRECTORY "${src_dir}"
748
+ LOGNAME "autoconf-${TARGET_TRIPLET}"
749
+ )
750
+ endif()
751
+ message(STATUS "Finished generating configure for ${TARGET_TRIPLET}")
752
+ endif()
753
+
754
+ if (arg_PRERUN_SHELL)
755
+ message(STATUS "Prerun shell with ${TARGET_TRIPLET}")
756
+ if (CMAKE_HOST_WIN32)
757
+ vcpkg_execute_required_process(
758
+ COMMAND ${base_cmd} -c "${arg_PRERUN_SHELL}"
759
+ WORKING_DIRECTORY "${src_dir}"
760
+ LOGNAME "prerun-${TARGET_TRIPLET}"
761
+ )
762
+ else()
763
+ vcpkg_execute_required_process(
764
+ COMMAND "${base_cmd}" -c "${arg_PRERUN_SHELL}"
765
+ WORKING_DIRECTORY "${src_dir}"
766
+ LOGNAME "prerun-${TARGET_TRIPLET}"
767
+ )
768
+ endif()
769
+ endif()
770
+
771
+ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" AND NOT arg_NO_DEBUG)
772
+ list(APPEND all_buildtypes DEBUG)
773
+ z_vcpkg_configure_make_process_flags(DEBUG)
774
+ endif()
775
+ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
776
+ list(APPEND all_buildtypes RELEASE)
777
+ z_vcpkg_configure_make_process_flags(RELEASE)
778
+ endif()
779
+ list(FILTER z_vcm_all_flags INCLUDE REGEX " ")
780
+ if(z_vcm_all_flags)
781
+ list(REMOVE_DUPLICATES z_vcm_all_flags)
782
+ list(JOIN z_vcm_all_flags "\n " flags)
783
+ message(STATUS "Warning: Arguments with embedded space may be handled incorrectly by configure:\n ${flags}")
784
+ endif()
785
+
786
+ foreach(var IN ITEMS arg_OPTIONS arg_OPTIONS_RELEASE arg_OPTIONS_DEBUG)
787
+ vcpkg_list(SET tmp)
788
+ foreach(element IN LISTS "${var}")
789
+ string(REPLACE [["]] [[\"]] element "${element}")
790
+ vcpkg_list(APPEND tmp "\"${element}\"")
791
+ endforeach()
792
+ vcpkg_list(JOIN tmp " " "${var}")
793
+ endforeach()
794
+
795
+ foreach(current_buildtype IN LISTS all_buildtypes)
796
+ foreach(ENV_VAR ${arg_CONFIG_DEPENDENT_ENVIRONMENT})
797
+ if(DEFINED ENV{${ENV_VAR}})
798
+ set(backup_config_${ENV_VAR} "$ENV{${ENV_VAR}}")
799
+ endif()
800
+ set(ENV{${ENV_VAR}} "${${ENV_VAR}_${current_buildtype}}")
801
+ endforeach()
802
+
803
+ set(target_dir "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_name_${current_buildtype}}")
804
+ file(MAKE_DIRECTORY "${target_dir}")
805
+ file(RELATIVE_PATH relative_build_path "${target_dir}" "${src_dir}")
806
+
807
+ if(arg_COPY_SOURCE)
808
+ file(COPY "${src_dir}/" DESTINATION "${target_dir}")
809
+ set(relative_build_path .)
810
+ endif()
811
+
812
+ # Setup PKG_CONFIG_PATH
813
+ z_vcpkg_setup_pkgconfig_path(CONFIG "${current_buildtype}")
814
+
815
+ # Setup environment
816
+ set(ENV{CPPFLAGS} "${CPPFLAGS_${current_buildtype}}")
817
+ set(ENV{CPPFLAGS_FOR_BUILD} "${CPPFLAGS_${current_buildtype}}")
818
+ set(ENV{CFLAGS} "${CFLAGS_${current_buildtype}}")
819
+ set(ENV{CFLAGS_FOR_BUILD} "${CFLAGS_${current_buildtype}}")
820
+ set(ENV{CXXFLAGS} "${CXXFLAGS_${current_buildtype}}")
821
+ #set(ENV{CXXFLAGS_FOR_BUILD} "${CXXFLAGS_${current_buildtype}}") -> doesn't exist officially
822
+ set(ENV{RCFLAGS} "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${current_buildtype}}")
823
+ set(ENV{LDFLAGS} "${LDFLAGS_${current_buildtype}}")
824
+ set(ENV{LDFLAGS_FOR_BUILD} "${LDFLAGS_${current_buildtype}}")
825
+ if(ARFLAGS_${current_buildtype} AND NOT (arg_USE_WRAPPERS AND VCPKG_TARGET_IS_WINDOWS))
826
+ # Target windows with wrappers enabled cannot forward ARFLAGS since it breaks the wrapper
827
+ set(ENV{ARFLAGS} "${ARFLAGS_${current_buildtype}}")
828
+ endif()
829
+
830
+ if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS)
831
+ # configure not using all flags to check if compiler works ...
832
+ set(ENV{CC} "$ENV{CC} $ENV{CPPFLAGS} $ENV{CFLAGS}")
833
+ set(ENV{CC_FOR_BUILD} "$ENV{CC_FOR_BUILD} $ENV{CPPFLAGS} $ENV{CFLAGS}")
834
+ endif()
835
+
836
+ if(LINK_ENV_${current_buildtype})
837
+ set(link_config_backup "$ENV{_LINK_}")
838
+ set(ENV{_LINK_} "${LINK_ENV_${current_buildtype}}")
839
+ else()
840
+ unset(link_config_backup)
841
+ endif()
842
+
843
+ vcpkg_list(APPEND lib_env_vars LIB LIBPATH LIBRARY_PATH) # LD_LIBRARY_PATH)
844
+ foreach(lib_env_var IN LISTS lib_env_vars)
845
+ if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib")
846
+ vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib")
847
+ endif()
848
+ if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib/manual-link")
849
+ vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib/manual-link")
850
+ endif()
851
+ endforeach()
852
+ unset(lib_env_vars)
853
+
854
+ set(command "${base_cmd}" -c "${configure_env} ./${relative_build_path}/configure ${arg_BUILD_TRIPLET} ${arg_OPTIONS} ${arg_OPTIONS_${current_buildtype}}")
855
+
856
+ if(arg_ADD_BIN_TO_PATH)
857
+ set(path_backup $ENV{PATH})
858
+ vcpkg_add_to_path("${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/bin")
859
+ endif()
860
+ debug_message("Configure command:'${command}'")
861
+ if (NOT arg_SKIP_CONFIGURE)
862
+ message(STATUS "Configuring ${TARGET_TRIPLET}-${short_name_${current_buildtype}}")
863
+ vcpkg_execute_required_process(
864
+ COMMAND ${command}
865
+ WORKING_DIRECTORY "${target_dir}"
866
+ LOGNAME "config-${TARGET_TRIPLET}-${short_name_${current_buildtype}}"
867
+ SAVE_LOG_FILES config.log
868
+ )
869
+ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
870
+ file(GLOB_RECURSE libtool_files "${target_dir}*/libtool")
871
+ foreach(lt_file IN LISTS libtool_files)
872
+ file(READ "${lt_file}" _contents)
873
+ string(REPLACE ".dll.lib" ".lib" _contents "${_contents}")
874
+ file(WRITE "${lt_file}" "${_contents}")
875
+ endforeach()
876
+ endif()
877
+ endif()
878
+ z_vcpkg_restore_pkgconfig_path()
879
+
880
+ if(DEFINED link_config_backup)
881
+ set(ENV{_LINK_} "${link_config_backup}")
882
+ endif()
883
+
884
+ if(arg_ADD_BIN_TO_PATH)
885
+ set(ENV{PATH} "${path_backup}")
886
+ endif()
887
+ # Restore environment (config dependent)
888
+ foreach(ENV_VAR IN LISTS ${arg_CONFIG_DEPENDENT_ENVIRONMENT})
889
+ if(backup_config_${ENV_VAR})
890
+ set(ENV{${ENV_VAR}} "${backup_config_${ENV_VAR}}")
891
+ else()
892
+ unset(ENV{${ENV_VAR}})
893
+ endif()
894
+ endforeach()
895
+ endforeach()
896
+
897
+ # Export matching make program for vcpkg_build_make (cache variable)
898
+ if(CMAKE_HOST_WIN32 AND MSYS_ROOT)
899
+ find_program(Z_VCPKG_MAKE make PATHS "${MSYS_ROOT}/usr/bin" NO_DEFAULT_PATH REQUIRED)
900
+ elseif(VCPKG_HOST_IS_FREEBSD OR VCPKG_HOST_IS_OPENBSD)
901
+ find_program(Z_VCPKG_MAKE gmake REQUIRED)
902
+ else()
903
+ find_program(Z_VCPKG_MAKE make REQUIRED)
904
+ endif()
905
+
906
+ # Restore environment
907
+ vcpkg_restore_env_variables(VARS ${cm_FLAGS} LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH)
908
+
909
+ set(_VCPKG_PROJECT_SOURCE_PATH ${arg_SOURCE_PATH} PARENT_SCOPE)
910
+ set(_VCPKG_PROJECT_SUBPATH ${arg_PROJECT_SUBPATH} PARENT_SCOPE)
911
+ set(_VCPKG_MAKE_NO_DEBUG ${arg_NO_DEBUG} PARENT_SCOPE)
912
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_configure_qmake.cmake ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(vcpkg_configure_qmake)
2
+ # parse parameters such that semicolons in options arguments to COMMAND don't get erased
3
+ cmake_parse_arguments(PARSE_ARGV 0 arg
4
+ ""
5
+ "SOURCE_PATH"
6
+ "OPTIONS;OPTIONS_RELEASE;OPTIONS_DEBUG;BUILD_OPTIONS;BUILD_OPTIONS_RELEASE;BUILD_OPTIONS_DEBUG"
7
+ )
8
+
9
+ # Find qmake executable
10
+ find_program(qmake_executable NAMES qmake PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/qt5/bin" NO_DEFAULT_PATH)
11
+
12
+ if(NOT qmake_executable)
13
+ message(FATAL_ERROR "vcpkg_configure_qmake: unable to find qmake.")
14
+ endif()
15
+
16
+ z_vcpkg_get_cmake_vars(cmake_vars_file)
17
+ include("${cmake_vars_file}")
18
+
19
+ function(qmake_append_program var qmake_var value)
20
+ get_filename_component(prog "${value}" NAME)
21
+ # QMake assumes everything is on PATH?
22
+ vcpkg_list(APPEND ${var} "${qmake_var}=${prog}")
23
+ find_program(${qmake_var} NAMES "${prog}")
24
+ cmake_path(COMPARE "${${qmake_var}}" EQUAL "${value}" correct_prog_on_path)
25
+ if(NOT correct_prog_on_path AND NOT "${value}" MATCHES "|:")
26
+ message(FATAL_ERROR "Detect path mismatch for '${qmake_var}'. '${value}' is not the same as '${${qmake_var}}'. Please correct your PATH!")
27
+ endif()
28
+ unset(${qmake_var})
29
+ unset(${qmake_var} CACHE)
30
+ set(${var} "${${var}}" PARENT_SCOPE)
31
+ endfunction()
32
+ # Setup Build tools
33
+ set(qmake_build_tools "")
34
+ qmake_append_program(qmake_build_tools "QMAKE_CC" "${VCPKG_DETECTED_CMAKE_C_COMPILER}")
35
+ qmake_append_program(qmake_build_tools "QMAKE_CXX" "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}")
36
+ qmake_append_program(qmake_build_tools "QMAKE_AR" "${VCPKG_DETECTED_CMAKE_AR}")
37
+ qmake_append_program(qmake_build_tools "QMAKE_RANLIB" "${VCPKG_DETECTED_CMAKE_RANLIB}")
38
+ qmake_append_program(qmake_build_tools "QMAKE_STRIP" "${VCPKG_DETECTED_CMAKE_STRIP}")
39
+ qmake_append_program(qmake_build_tools "QMAKE_NM" "${VCPKG_DETECTED_CMAKE_NM}")
40
+ qmake_append_program(qmake_build_tools "QMAKE_RC" "${VCPKG_DETECTED_CMAKE_RC_COMPILER}")
41
+ qmake_append_program(qmake_build_tools "QMAKE_MT" "${VCPKG_DETECTED_CMAKE_MT}")
42
+ if(NOT VCPKG_TARGET_IS_WINDOWS OR VCPKG_DETECTED_CMAKE_AR MATCHES "ar$")
43
+ vcpkg_list(APPEND qmake_build_tools "QMAKE_AR+=qc")
44
+ endif()
45
+ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
46
+ qmake_append_program(qmake_build_tools "QMAKE_LIB" "${VCPKG_DETECTED_CMAKE_AR}")
47
+ qmake_append_program(qmake_build_tools "QMAKE_LINK" "${VCPKG_DETECTED_CMAKE_LINKER}")
48
+ else()
49
+ qmake_append_program(qmake_build_tools "QMAKE_LINK" "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}")
50
+ qmake_append_program(qmake_build_tools "QMAKE_LINK_SHLIB" "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}")
51
+ qmake_append_program(qmake_build_tools "QMAKE_LINK_C" "${VCPKG_DETECTED_CMAKE_C_COMPILER}")
52
+ qmake_append_program(qmake_build_tools "QMAKE_LINK_C_SHLIB" "${VCPKG_DETECTED_CMAKE_C_COMPILER}")
53
+ endif()
54
+ set(qmake_comp_flags "")
55
+ macro(qmake_add_flags qmake_var operation flags)
56
+ string(STRIP "${flags}" striped_flags)
57
+ if(striped_flags)
58
+ vcpkg_list(APPEND qmake_comp_flags "${qmake_var}${operation}${striped_flags}")
59
+ endif()
60
+ endmacro()
61
+
62
+ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
63
+ vcpkg_list(APPEND arg_OPTIONS "CONFIG-=shared" "CONFIG*=static")
64
+ else()
65
+ vcpkg_list(APPEND arg_OPTIONS "CONFIG-=static" "CONFIG*=shared")
66
+ vcpkg_list(APPEND arg_OPTIONS_DEBUG "CONFIG*=separate_debug_info")
67
+ endif()
68
+
69
+ if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_CRT_LINKAGE STREQUAL "static")
70
+ vcpkg_list(APPEND arg_OPTIONS "CONFIG*=static-runtime")
71
+ endif()
72
+
73
+ if(DEFINED VCPKG_OSX_DEPLOYMENT_TARGET)
74
+ set(ENV{QMAKE_MACOSX_DEPLOYMENT_TARGET} "${VCPKG_OSX_DEPLOYMENT_TARGET}")
75
+ endif()
76
+
77
+ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
78
+ z_vcpkg_setup_pkgconfig_path(CONFIG RELEASE)
79
+
80
+ set(current_binary_dir "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
81
+
82
+ # Cleanup build directories
83
+ file(REMOVE_RECURSE "${current_binary_dir}")
84
+
85
+ configure_file("${CURRENT_INSTALLED_DIR}/tools/qt5/qt_release.conf" "${current_binary_dir}/qt.conf")
86
+
87
+ message(STATUS "Configuring ${TARGET_TRIPLET}-rel")
88
+ file(MAKE_DIRECTORY "${current_binary_dir}")
89
+
90
+ qmake_add_flags("QMAKE_LIBS" "+=" "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
91
+ qmake_add_flags("QMAKE_RC" "+=" "${VCPKG_DETECTED_CMAKE_RC_FLAGS_RELEASE}")
92
+ qmake_add_flags("QMAKE_CFLAGS_RELEASE" "+=" "${VCPKG_DETECTED_CMAKE_C_FLAGS_RELEASE}")
93
+ qmake_add_flags("QMAKE_CXXFLAGS_RELEASE" "+=" "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE}")
94
+ qmake_add_flags("QMAKE_LFLAGS" "+=" "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
95
+ qmake_add_flags("QMAKE_LFLAGS_SHLIB" "+=" "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
96
+ qmake_add_flags("QMAKE_LFLAGS_PLUGIN" "+=" "${VCPKG_DETECTED_CMAKE_MODULE_LINKER_FLAGS_RELEASE}")
97
+ qmake_add_flags("QMAKE_LIBFLAGS_RELEASE" "+=" "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_RELEASE}")
98
+
99
+ vcpkg_list(SET build_opt_param)
100
+ if(DEFINED arg_BUILD_OPTIONS OR DEFINED arg_BUILD_OPTIONS_RELEASE)
101
+ vcpkg_list(SET build_opt_param -- ${arg_BUILD_OPTIONS} ${arg_BUILD_OPTIONS_RELEASE})
102
+ endif()
103
+
104
+ vcpkg_execute_required_process(
105
+ COMMAND "${qmake_executable}" CONFIG-=debug CONFIG+=release ${qmake_build_tools} ${qmake_comp_flags}
106
+ ${arg_OPTIONS} ${arg_OPTIONS_RELEASE} ${arg_SOURCE_PATH}
107
+ -qtconf "${current_binary_dir}/qt.conf"
108
+ ${build_opt_param}
109
+ WORKING_DIRECTORY "${current_binary_dir}"
110
+ LOGNAME "config-${TARGET_TRIPLET}-rel"
111
+ SAVE_LOG_FILES config.log
112
+ )
113
+ message(STATUS "Configuring ${TARGET_TRIPLET}-rel done")
114
+ if(EXISTS "${current_binary_dir}/config.log")
115
+ file(REMOVE "${CURRENT_BUILDTREES_DIR}/internal-config-${TARGET_TRIPLET}-rel.log")
116
+ file(RENAME "${current_binary_dir}/config.log" "${CURRENT_BUILDTREES_DIR}/internal-config-${TARGET_TRIPLET}-rel.log")
117
+ endif()
118
+
119
+ z_vcpkg_restore_pkgconfig_path()
120
+ endif()
121
+
122
+ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
123
+ z_vcpkg_setup_pkgconfig_path(CONFIG DEBUG)
124
+
125
+ set(current_binary_dir "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
126
+
127
+ # Cleanup build directories
128
+ file(REMOVE_RECURSE "${current_binary_dir}")
129
+
130
+ configure_file("${CURRENT_INSTALLED_DIR}/tools/qt5/qt_debug.conf" "${current_binary_dir}/qt.conf")
131
+
132
+ message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
133
+ file(MAKE_DIRECTORY "${current_binary_dir}")
134
+
135
+ set(qmake_comp_flags "")
136
+ qmake_add_flags("QMAKE_LIBS" "+=" "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
137
+ qmake_add_flags("QMAKE_RC" "+=" "${VCPKG_DETECTED_CMAKE_RC_FLAGS_DEBUG}")
138
+ qmake_add_flags("QMAKE_CFLAGS_DEBUG" "+=" "${VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG}")
139
+ qmake_add_flags("QMAKE_CXXFLAGS_DEBUG" "+=" "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG}")
140
+ qmake_add_flags("QMAKE_LFLAGS" "+=" "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
141
+ qmake_add_flags("QMAKE_LFLAGS_SHLIB" "+=" "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
142
+ qmake_add_flags("QMAKE_LFLAGS_PLUGIN" "+=" "${VCPKG_DETECTED_CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
143
+ qmake_add_flags("QMAKE_LIBFLAGS_DEBUG" "+=" "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_DEBUG}")
144
+
145
+ vcpkg_list(SET build_opt_param)
146
+ if(DEFINED arg_BUILD_OPTIONS OR DEFINED arg_BUILD_OPTIONS_DEBUG)
147
+ vcpkg_list(SET build_opt_param -- ${arg_BUILD_OPTIONS} ${arg_BUILD_OPTIONS_DEBUG})
148
+ endif()
149
+ vcpkg_execute_required_process(
150
+ COMMAND "${qmake_executable}" CONFIG-=release CONFIG+=debug ${qmake_build_tools} ${qmake_comp_flags}
151
+ ${arg_OPTIONS} ${arg_OPTIONS_DEBUG} ${arg_SOURCE_PATH}
152
+ -qtconf "${current_binary_dir}/qt.conf"
153
+ ${build_opt_param}
154
+ WORKING_DIRECTORY "${current_binary_dir}"
155
+ LOGNAME "config-${TARGET_TRIPLET}-dbg"
156
+ SAVE_LOG_FILES config.log
157
+ )
158
+ message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done")
159
+ if(EXISTS "${current_binary_dir}/config.log")
160
+ file(REMOVE "${CURRENT_BUILDTREES_DIR}/internal-config-${TARGET_TRIPLET}-dbg.log")
161
+ file(RENAME "${current_binary_dir}/config.log" "${CURRENT_BUILDTREES_DIR}/internal-config-${TARGET_TRIPLET}-dbg.log")
162
+ endif()
163
+
164
+ z_vcpkg_restore_pkgconfig_path()
165
+ endif()
166
+
167
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_copy_tool_dependencies.cmake ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(z_vcpkg_copy_tool_dependencies_search tool_dir path_to_search)
2
+ if(DEFINED Z_VCPKG_COPY_TOOL_DEPENDENCIES_COUNT)
3
+ set(count ${Z_VCPKG_COPY_TOOL_DEPENDENCIES_COUNT})
4
+ else()
5
+ set(count 0)
6
+ endif()
7
+ file(GLOB tools "${tool_dir}/*.exe" "${tool_dir}/*.dll" "${tool_dir}/*.pyd")
8
+ foreach(tool IN LISTS tools)
9
+ vcpkg_execute_required_process(
10
+ COMMAND "${Z_VCPKG_POWERSHELL_CORE}" -noprofile -executionpolicy Bypass -nologo
11
+ -file "${SCRIPTS}/buildsystems/msbuild/applocal.ps1"
12
+ -targetBinary "${tool}"
13
+ -installedDir "${path_to_search}"
14
+ -verbose
15
+ WORKING_DIRECTORY "${VCPKG_ROOT_DIR}"
16
+ LOGNAME copy-tool-dependencies-${count}
17
+ )
18
+ math(EXPR count "${count} + 1")
19
+ endforeach()
20
+ set(Z_VCPKG_COPY_TOOL_DEPENDENCIES_COUNT ${count} CACHE INTERNAL "")
21
+ endfunction()
22
+
23
+ function(vcpkg_copy_tool_dependencies tool_dir)
24
+ if(ARGC GREATER 1)
25
+ message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${ARGN}")
26
+ endif()
27
+
28
+ if(VCPKG_TARGET_IS_WINDOWS)
29
+ find_program(Z_VCPKG_POWERSHELL_CORE pwsh)
30
+ if (NOT Z_VCPKG_POWERSHELL_CORE)
31
+ message(FATAL_ERROR "Could not find PowerShell Core; please open an issue to report this.")
32
+ endif()
33
+ cmake_path(RELATIVE_PATH tool_dir
34
+ BASE_DIRECTORY "${CURRENT_PACKAGES_DIR}"
35
+ OUTPUT_VARIABLE relative_tool_dir
36
+ )
37
+ if(relative_tool_dir MATCHES "/debug/")
38
+ z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_PACKAGES_DIR}/debug/bin")
39
+ z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_INSTALLED_DIR}/debug/bin")
40
+ else()
41
+ z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_PACKAGES_DIR}/bin")
42
+ z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_INSTALLED_DIR}/bin")
43
+ endif()
44
+ endif()
45
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_download_distfile.cmake ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(z_vcpkg_check_hash result file_path sha512)
2
+ file(SHA512 "${file_path}" file_hash)
3
+ string(TOLOWER "${sha512}" sha512_lower)
4
+ string(COMPARE EQUAL "${file_hash}" "${sha512_lower}" hash_match)
5
+ set("${result}" "${hash_match}" PARENT_SCOPE)
6
+ endfunction()
7
+
8
+ function(z_vcpkg_download_distfile_test_hash file_path kind error_advice sha512 skip_sha512)
9
+ if(_VCPKG_INTERNAL_NO_HASH_CHECK)
10
+ # When using the internal hash skip, do not output an explicit message.
11
+ return()
12
+ endif()
13
+ if(skip_sha512)
14
+ message(STATUS "Skipping hash check for ${file_path}.")
15
+ return()
16
+ endif()
17
+
18
+ set(hash_match OFF)
19
+ z_vcpkg_check_hash(hash_match "${file_path}" "${sha512}")
20
+
21
+ if(NOT hash_match)
22
+ message(FATAL_ERROR
23
+ "\nFile does not have expected hash:\n"
24
+ " File path: [ ${file_path} ]\n"
25
+ " Expected hash: [ ${sha512} ]\n"
26
+ " Actual hash: [ ${file_hash} ]\n"
27
+ "${error_advice}\n")
28
+ endif()
29
+ endfunction()
30
+
31
+ function(z_vcpkg_download_distfile_show_proxy_and_fail error_code)
32
+ message(FATAL_ERROR
33
+ " \n"
34
+ " Failed to download file with error: ${error_code}\n"
35
+ " If you are using a proxy, please check your proxy setting. Possible causes are:\n"
36
+ " \n"
37
+ " 1. You are actually using an HTTP proxy, but setting HTTPS_PROXY variable\n"
38
+ " to `https://address:port`. This is not correct, because `https://` prefix\n"
39
+ " claims the proxy is an HTTPS proxy, while your proxy (v2ray, shadowsocksr\n"
40
+ " , etc..) is an HTTP proxy. Try setting `http://address:port` to both\n"
41
+ " HTTP_PROXY and HTTPS_PROXY instead.\n"
42
+ " \n"
43
+ " 2. If you are using Windows, vcpkg will automatically use your Windows IE Proxy Settings\n"
44
+ " set by your proxy software. See https://github.com/microsoft/vcpkg-tool/pull/77\n"
45
+ " The value set by your proxy might be wrong, or have same `https://` prefix issue.\n"
46
+ " \n"
47
+ " 3. Your proxy's remote server is out of service.\n"
48
+ " \n"
49
+ " If you've tried directly download the link, and believe this is not a temporary\n"
50
+ " download server failure, please submit an issue at https://github.com/Microsoft/vcpkg/issues\n"
51
+ " to report this upstream download server failure.\n"
52
+ " \n")
53
+ endfunction()
54
+
55
+ function(z_vcpkg_download_distfile_via_aria)
56
+ cmake_parse_arguments(PARSE_ARGV 1 arg
57
+ "SKIP_SHA512"
58
+ "FILENAME;SHA512"
59
+ "URLS;HEADERS"
60
+ )
61
+
62
+ message(STATUS "Downloading ${arg_FILENAME}...")
63
+
64
+ vcpkg_list(SET headers_param)
65
+ foreach(header IN LISTS arg_HEADERS)
66
+ vcpkg_list(APPEND headers_param "--header=${header}")
67
+ endforeach()
68
+
69
+ foreach(URL IN LISTS arg_URLS)
70
+ debug_message("Download Command: ${ARIA2} ${URL} -o temp/${filename} -l download-${filename}-detailed.log ${headers_param}")
71
+ vcpkg_execute_in_download_mode(
72
+ COMMAND ${ARIA2} ${URL}
73
+ -o temp/${arg_FILENAME}
74
+ -l download-${arg_FILENAME}-detailed.log
75
+ ${headers_param}
76
+ OUTPUT_FILE download-${arg_FILENAME}-out.log
77
+ ERROR_FILE download-${arg_FILENAME}-err.log
78
+ RESULT_VARIABLE error_code
79
+ WORKING_DIRECTORY "${DOWNLOADS}"
80
+ )
81
+
82
+ if ("${error_code}" STREQUAL "0")
83
+ break()
84
+ endif()
85
+ endforeach()
86
+ if (NOT "${error_code}" STREQUAL "0")
87
+ message(STATUS
88
+ "Downloading ${arg_FILENAME}... Failed.\n"
89
+ " Exit Code: ${error_code}\n"
90
+ " See logs for more information:\n"
91
+ " ${DOWNLOADS}/download-${arg_FILENAME}-out.log\n"
92
+ " ${DOWNLOADS}/download-${arg_FILENAME}-err.log\n"
93
+ " ${DOWNLOADS}/download-${arg_FILENAME}-detailed.log\n"
94
+ )
95
+ z_vcpkg_download_distfile_show_proxy_and_fail("${error_code}")
96
+ else()
97
+ z_vcpkg_download_distfile_test_hash(
98
+ "${DOWNLOADS}/temp/${arg_FILENAME}"
99
+ "downloaded file"
100
+ "The file may have been corrupted in transit."
101
+ "${arg_SHA512}"
102
+ ${arg_SKIP_SHA512}
103
+ )
104
+ file(REMOVE
105
+ ${DOWNLOADS}/download-${arg_FILENAME}-out.log
106
+ ${DOWNLOADS}/download-${arg_FILENAME}-err.log
107
+ ${DOWNLOADS}/download-${arg_FILENAME}-detailed.log
108
+ )
109
+ get_filename_component(downloaded_file_dir "${downloaded_file_path}" DIRECTORY)
110
+ file(MAKE_DIRECTORY "${downloaded_file_dir}")
111
+ file(RENAME "${DOWNLOADS}/temp/${arg_FILENAME}" "${downloaded_file_path}")
112
+ endif()
113
+ endfunction()
114
+
115
+ function(vcpkg_download_distfile out_var)
116
+ cmake_parse_arguments(PARSE_ARGV 1 arg
117
+ "SKIP_SHA512;SILENT_EXIT;QUIET;ALWAYS_REDOWNLOAD"
118
+ "FILENAME;SHA512"
119
+ "URLS;HEADERS"
120
+ )
121
+
122
+ if(NOT DEFINED arg_URLS)
123
+ message(FATAL_ERROR "vcpkg_download_distfile requires a URLS argument.")
124
+ endif()
125
+ if(NOT DEFINED arg_FILENAME)
126
+ message(FATAL_ERROR "vcpkg_download_distfile requires a FILENAME argument.")
127
+ endif()
128
+ if(arg_SILENT_EXIT)
129
+ message(WARNING "SILENT_EXIT has been deprecated as an argument to vcpkg_download_distfile -- remove the argument to resolve this warning")
130
+ endif()
131
+ if(arg_ALWAYS_REDOWNLOAD AND NOT arg_SKIP_SHA512)
132
+ message(FATAL_ERROR "ALWAYS_REDOWNLOAD option requires SKIP_SHA512 as well")
133
+ endif()
134
+
135
+ if(NOT arg_SKIP_SHA512 AND NOT DEFINED arg_SHA512)
136
+ message(FATAL_ERROR "vcpkg_download_distfile requires a SHA512 argument.
137
+ If you do not know the SHA512, add it as 'SHA512 0' and re-run this command.")
138
+ elseif(arg_SKIP_SHA512 AND DEFINED arg_SHA512)
139
+ message(FATAL_ERROR "vcpkg_download_distfile must not be passed both SHA512 and SKIP_SHA512.")
140
+ endif()
141
+
142
+ if(_VCPKG_INTERNAL_NO_HASH_CHECK)
143
+ set(arg_SKIP_SHA512 1)
144
+ endif()
145
+
146
+ if(NOT arg_SKIP_SHA512)
147
+ if("${arg_SHA512}" STREQUAL "0")
148
+ string(REPEAT 0 128 arg_SHA512)
149
+ else()
150
+ string(LENGTH "${arg_SHA512}" arg_SHA512_length)
151
+ if(NOT "${arg_SHA512_length}" EQUAL "128" OR NOT "${arg_SHA512}" MATCHES "^[a-zA-Z0-9]*$")
152
+ message(FATAL_ERROR "Invalid SHA512: ${arg_SHA512}.
153
+ If you do not know the file's SHA512, set this to \"0\".")
154
+ endif()
155
+ endif()
156
+ endif()
157
+
158
+ set(downloaded_file_path "${DOWNLOADS}/${arg_FILENAME}")
159
+
160
+ if(EXISTS "${downloaded_file_path}" AND NOT arg_SKIP_SHA512)
161
+ set(hash_match OFF)
162
+ z_vcpkg_check_hash(hash_match "${downloaded_file_path}" "${arg_SHA512}")
163
+
164
+ if(NOT hash_match)
165
+ get_filename_component(filename_component "${arg_FILENAME}" NAME_WE)
166
+ get_filename_component(extension_component "${arg_FILENAME}" EXT)
167
+ get_filename_component(directory_component "${arg_FILENAME}" DIRECTORY)
168
+
169
+ string(SUBSTRING "${arg_SHA512}" 0 8 hash)
170
+ set(arg_FILENAME "${directory_component}${filename_component}-${hash}${extension_component}")
171
+ set(downloaded_file_path "${DOWNLOADS}/${arg_FILENAME}")
172
+ endif()
173
+ endif()
174
+
175
+ set(download_file_path_part "${DOWNLOADS}/temp/${arg_FILENAME}")
176
+
177
+ # Works around issue #3399
178
+ # Delete "temp0" directory created by the old version of vcpkg
179
+ file(REMOVE_RECURSE "${DOWNLOADS}/temp0")
180
+ file(REMOVE_RECURSE "${DOWNLOADS}/temp")
181
+ file(MAKE_DIRECTORY "${DOWNLOADS}/temp")
182
+
183
+ # check if file with same name already exists in downloads
184
+ if(EXISTS "${downloaded_file_path}" AND NOT arg_ALWAYS_REDOWNLOAD)
185
+ set(advice_message "The cached file SHA512 doesn't match. The file may have been corrupted.")
186
+ if(_VCPKG_NO_DOWNLOADS)
187
+ string(APPEND advice_message " Downloads are disabled please provide a valid file at path ${downloaded_file_path} and retry.")
188
+ else()
189
+ string(APPEND advice_message " To re-download this file please delete cached file at path ${downloaded_file_path} and retry.")
190
+ endif()
191
+
192
+ z_vcpkg_download_distfile_test_hash(
193
+ "${downloaded_file_path}"
194
+ "cached file"
195
+ "${advice_message}"
196
+ "${arg_SHA512}"
197
+ "${arg_SKIP_SHA512}"
198
+ )
199
+
200
+ if(NOT vcpkg_download_distfile_QUIET)
201
+ message(STATUS "Using cached ${arg_FILENAME}.")
202
+ endif()
203
+
204
+ # Suppress the "Downloading ${arg_URLS} -> ${arg_FILENAME}..." message
205
+ set(vcpkg_download_distfile_QUIET TRUE)
206
+ endif()
207
+
208
+ # vcpkg_download_distfile_ALWAYS_REDOWNLOAD only triggers when NOT _VCPKG_NO_DOWNLOADS
209
+ # this could be de-morgan'd out but it's more clear this way
210
+ if(_VCPKG_NO_DOWNLOADS)
211
+ if(NOT EXISTS "${downloaded_file_path}")
212
+ message(FATAL_ERROR "Downloads are disabled, but '${downloaded_file_path}' does not exist.")
213
+ endif()
214
+
215
+ set("${out_var}" "${downloaded_file_path}" PARENT_SCOPE)
216
+ return()
217
+ endif()
218
+
219
+ if(NOT arg_DISABLE_ARIA2 AND _VCPKG_DOWNLOAD_TOOL STREQUAL "ARIA2" AND NOT EXISTS "${downloaded_file_path}")
220
+ if (arg_SKIP_SHA512)
221
+ set(OPTION_SKIP_SHA512 "SKIP_SHA512")
222
+ endif()
223
+ z_vcpkg_download_distfile_via_aria(
224
+ "${OPTION_SKIP_SHA512}"
225
+ FILENAME "${arg_FILENAME}"
226
+ SHA512 "${arg_SHA512}"
227
+ URLS "${arg_URLS}"
228
+ HEADERS "${arg_HEADERS}"
229
+ )
230
+ set("${out_var}" "${downloaded_file_path}" PARENT_SCOPE)
231
+ return()
232
+ endif()
233
+
234
+ vcpkg_list(SET urls_param)
235
+ foreach(url IN LISTS arg_URLS)
236
+ vcpkg_list(APPEND urls_param "--url=${url}")
237
+ endforeach()
238
+ if(NOT vcpkg_download_distfile_QUIET)
239
+ message(STATUS "Downloading ${arg_URLS} -> ${arg_FILENAME}...")
240
+ endif()
241
+
242
+ vcpkg_list(SET headers_param)
243
+ foreach(header IN LISTS arg_HEADERS)
244
+ list(APPEND headers_param "--header=${header}")
245
+ endforeach()
246
+
247
+ if(arg_SKIP_SHA512)
248
+ vcpkg_list(SET sha512_param "--skip-sha512")
249
+ else()
250
+ vcpkg_list(SET sha512_param "--sha512=${arg_SHA512}")
251
+ endif()
252
+
253
+ if(NOT EXISTS "${downloaded_file_path}" OR arg_ALWAYS_REDOWNLOAD)
254
+ vcpkg_execute_in_download_mode(
255
+ COMMAND "$ENV{VCPKG_COMMAND}" x-download
256
+ "${downloaded_file_path}"
257
+ ${sha512_param}
258
+ ${urls_param}
259
+ ${headers_param}
260
+ --debug
261
+ --feature-flags=-manifests # there's a bug in vcpkg x-download when it finds a manifest-root
262
+ OUTPUT_VARIABLE output
263
+ ERROR_VARIABLE output
264
+ RESULT_VARIABLE error_code
265
+ WORKING_DIRECTORY "${DOWNLOADS}"
266
+ )
267
+
268
+ if(NOT "${error_code}" EQUAL "0")
269
+ message("${output}")
270
+ z_vcpkg_download_distfile_show_proxy_and_fail("${error_code}")
271
+ endif()
272
+ endif()
273
+
274
+ set("${out_var}" "${downloaded_file_path}" PARENT_SCOPE)
275
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_execute_required_process.cmake ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(vcpkg_execute_required_process)
2
+ cmake_parse_arguments(PARSE_ARGV 0 arg
3
+ "ALLOW_IN_DOWNLOAD_MODE"
4
+ "WORKING_DIRECTORY;LOGNAME;TIMEOUT;OUTPUT_VARIABLE;ERROR_VARIABLE"
5
+ "COMMAND;SAVE_LOG_FILES"
6
+ )
7
+
8
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
9
+ message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
10
+ endif()
11
+ foreach(required_arg IN ITEMS WORKING_DIRECTORY COMMAND)
12
+ if(NOT DEFINED arg_${required_arg})
13
+ message(FATAL_ERROR "${required_arg} must be specified.")
14
+ endif()
15
+ endforeach()
16
+
17
+ if(NOT DEFINED arg_LOGNAME)
18
+ message(WARNING "LOGNAME should be specified.")
19
+ set(arg_LOGNAME "required")
20
+ endif()
21
+
22
+ if (VCPKG_DOWNLOAD_MODE AND NOT arg_ALLOW_IN_DOWNLOAD_MODE)
23
+ message(FATAL_ERROR
24
+ [[
25
+ This command cannot be executed in Download Mode.
26
+ Halting portfile execution.
27
+ ]])
28
+ endif()
29
+
30
+ set(log_out "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-out.log")
31
+ set(log_err "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-err.log")
32
+
33
+ set(timeout_param "")
34
+ set(output_and_error_same OFF)
35
+ set(output_variable_param "")
36
+ set(error_variable_param "")
37
+
38
+ if(DEFINED arg_TIMEOUT)
39
+ set(timeout_param TIMEOUT "${arg_TIMEOUT}")
40
+ endif()
41
+ if(DEFINED arg_OUTPUT_VARIABLE AND DEFINED arg_ERROR_VARIABLE AND arg_OUTPUT_VARIABLE STREQUAL arg_ERROR_VARIABLE)
42
+ set(output_variable_param OUTPUT_VARIABLE out_err_var)
43
+ set(error_variable_param ERROR_VARIABLE out_err_var)
44
+ set(output_and_error_same ON)
45
+ else()
46
+ if(DEFINED arg_OUTPUT_VARIABLE)
47
+ set(output_variable_param OUTPUT_VARIABLE out_var)
48
+ endif()
49
+ if(DEFINED arg_ERROR_VARIABLE)
50
+ set(error_variable_param ERROR_VARIABLE err_var)
51
+ endif()
52
+ endif()
53
+
54
+ if(X_PORT_PROFILE AND NOT arg_ALLOW_IN_DOWNLOAD_MODE)
55
+ vcpkg_list(PREPEND arg_COMMAND "${CMAKE_COMMAND}" "-E" "time")
56
+ endif()
57
+
58
+ vcpkg_execute_in_download_mode(
59
+ COMMAND ${arg_COMMAND}
60
+ OUTPUT_FILE "${log_out}"
61
+ ERROR_FILE "${log_err}"
62
+ RESULT_VARIABLE error_code
63
+ WORKING_DIRECTORY "${arg_WORKING_DIRECTORY}"
64
+ ${timeout_param}
65
+ ${output_variable_param}
66
+ ${error_variable_param}
67
+ )
68
+ vcpkg_list(SET logfiles)
69
+ vcpkg_list(SET logfile_copies)
70
+ set(expect_alias FALSE)
71
+ foreach(item IN LISTS arg_SAVE_LOG_FILES)
72
+ if(expect_alias)
73
+ vcpkg_list(POP_BACK logfile_copies)
74
+ vcpkg_list(APPEND logfile_copies "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-${item}")
75
+ set(expect_alias FALSE)
76
+ elseif(item STREQUAL "ALIAS")
77
+ if(NOT logfiles)
78
+ message(FATAL_ERROR "ALIAS used without source file")
79
+ endif()
80
+ set(expect_alias TRUE)
81
+ else()
82
+ vcpkg_list(APPEND logfiles "${arg_WORKING_DIRECTORY}/${item}")
83
+ cmake_path(GET item FILENAME filename)
84
+ if(NOT filename MATCHES "[.]log\$")
85
+ string(APPEND filename ".log")
86
+ endif()
87
+ vcpkg_list(APPEND logfile_copies "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-${filename}")
88
+ endif()
89
+ endforeach()
90
+ vcpkg_list(SET saved_logs)
91
+ foreach(logfile logfile_copy IN ZIP_LISTS logfiles logfile_copies)
92
+ if(EXISTS "${logfile}")
93
+ configure_file("${logfile}" "${logfile_copy}" COPYONLY)
94
+ vcpkg_list(APPEND saved_logs "${logfile_copy}")
95
+ endif()
96
+ endforeach()
97
+ if(NOT error_code EQUAL 0)
98
+ set(stringified_logs "")
99
+ foreach(log IN LISTS saved_logs ITEMS "${log_out}" "${log_err}")
100
+ if(NOT EXISTS "${log}")
101
+ continue()
102
+ endif()
103
+ file(SIZE "${log}" log_size)
104
+ if(NOT log_size EQUAL "0")
105
+ file(TO_NATIVE_PATH "${log}" native_log)
106
+ string(APPEND stringified_logs " ${native_log}\n")
107
+ file(APPEND "${Z_VCPKG_ERROR_LOG_COLLECTION_FILE}" "${native_log}\n")
108
+ endif()
109
+ endforeach()
110
+
111
+ z_vcpkg_prettify_command_line(pretty_command ${arg_COMMAND})
112
+ message(FATAL_ERROR
113
+ " Command failed: ${pretty_command}\n"
114
+ " Working Directory: ${arg_WORKING_DIRECTORY}\n"
115
+ " Error code: ${error_code}\n"
116
+ " See logs for more information:\n"
117
+ "${stringified_logs}"
118
+ )
119
+ endif()
120
+
121
+ # pass output parameters back to caller's scope
122
+ if(output_and_error_same)
123
+ z_vcpkg_forward_output_variable(arg_OUTPUT_VARIABLE out_err_var)
124
+ # arg_ERROR_VARIABLE = arg_OUTPUT_VARIABLE, so no need to set it again
125
+ else()
126
+ z_vcpkg_forward_output_variable(arg_OUTPUT_VARIABLE out_var)
127
+ z_vcpkg_forward_output_variable(arg_ERROR_VARIABLE err_var)
128
+ endif()
129
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_extract_source_archive.cmake ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(z_vcpkg_extract_source_archive_deprecated_mode archive working_directory)
2
+ cmake_path(GET archive FILENAME archive_filename)
3
+ if(NOT EXISTS "${working_directory}/${archive_filename}.extracted")
4
+ message(STATUS "Extracting source ${archive}")
5
+ vcpkg_extract_archive(ARCHIVE "${archive}" DESTINATION "${working_directory}")
6
+ file(TOUCH "${working_directory}/${archive_filename}.extracted")
7
+ endif()
8
+ endfunction()
9
+
10
+ function(vcpkg_extract_source_archive)
11
+ if(ARGC LESS_EQUAL "2")
12
+ z_vcpkg_deprecation_message( "Deprecated form of vcpkg_extract_source_archive used:
13
+ Please use the `vcpkg_extract_source_archive(<out-var> ARCHIVE <archive>)` form.")
14
+ if(ARGC EQUAL "0")
15
+ message(FATAL_ERROR "vcpkg_extract_source_archive requires at least one argument.")
16
+ endif()
17
+
18
+ set(archive "${ARGV0}")
19
+ if(ARGC EQUAL "1")
20
+ set(working_directory "${CURRENT_BUILDTREES_DIR}/src")
21
+ else()
22
+ set(working_directory "${ARGV1}")
23
+ endif()
24
+
25
+ z_vcpkg_extract_source_archive_deprecated_mode("${archive}" "${working_directory}")
26
+ return()
27
+ endif()
28
+
29
+ set(out_source_path "${ARGV0}")
30
+ cmake_parse_arguments(PARSE_ARGV 1 "arg"
31
+ "NO_REMOVE_ONE_LEVEL;SKIP_PATCH_CHECK;Z_ALLOW_OLD_PARAMETER_NAMES"
32
+ "ARCHIVE;SOURCE_BASE;BASE_DIRECTORY;WORKING_DIRECTORY;REF"
33
+ "PATCHES"
34
+ )
35
+
36
+ if(DEFINED arg_REF)
37
+ if(NOT arg_Z_ALLOW_OLD_PARAMETER_NAMES)
38
+ message(FATAL_ERROR "Unexpected argument REF")
39
+ elseif(DEFINED arg_SOURCE_BASE)
40
+ message(FATAL_ERROR "Cannot specify both REF and SOURCE_BASE")
41
+ else()
42
+ string(REPLACE "/" "-" arg_SOURCE_BASE "${arg_REF}")
43
+ endif()
44
+ endif()
45
+
46
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
47
+ message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
48
+ endif()
49
+ if(NOT DEFINED arg_ARCHIVE)
50
+ message(FATAL_ERROR "ARCHIVE must be specified")
51
+ endif()
52
+
53
+ if(DEFINED arg_WORKING_DIRECTORY)
54
+ if(DEFINED arg_BASE_DIRECTORY)
55
+ message(FATAL_ERROR "Cannot specify both BASE_DIRECTORY and WORKING_DIRECTORY")
56
+ elseif(NOT IS_ABSOLUTE "${arg_WORKING_DIRECTORY}")
57
+ message(FATAL_ERROR "WORKING_DIRECTORY (${arg_WORKING_DIRECTORY}) must be an absolute path")
58
+ endif()
59
+ set(working_directory "${arg_WORKING_DIRECTORY}")
60
+ else()
61
+ if(NOT DEFINED arg_BASE_DIRECTORY)
62
+ set(arg_BASE_DIRECTORY "src")
63
+ elseif(IS_ABSOLUTE "${arg_BASE_DIRECTORY}")
64
+ message(FATAL_ERROR "BASE_DIRECTORY (${arg_BASE_DIRECTORY}) must be a relative path")
65
+ endif()
66
+ cmake_path(APPEND CURRENT_BUILDTREES_DIR "${arg_BASE_DIRECTORY}"
67
+ OUTPUT_VARIABLE working_directory)
68
+ endif()
69
+
70
+ if(NOT DEFINED arg_SOURCE_BASE)
71
+ cmake_path(GET arg_ARCHIVE STEM arg_SOURCE_BASE)
72
+ elseif(arg_SOURCE_BASE MATCHES [[\\|/]])
73
+ message(FATAL_ERROR "SOURCE_BASE (${arg_SOURCE_BASE}) must not contain slashes")
74
+ endif()
75
+
76
+ # Take the last 10 chars of the base
77
+ set(base_max_length 10)
78
+ string(LENGTH "${arg_SOURCE_BASE}" source_base_length)
79
+ if(source_base_length GREATER base_max_length)
80
+ math(EXPR start "${source_base_length} - ${base_max_length}")
81
+ string(SUBSTRING "${arg_SOURCE_BASE}" "${start}" -1 arg_SOURCE_BASE)
82
+ endif()
83
+
84
+ # Hash the archive hash along with the patches. Take the first 10 chars of the hash
85
+ file(SHA512 "${arg_ARCHIVE}" patchset_hash)
86
+ foreach(patch IN LISTS arg_PATCHES)
87
+ cmake_path(ABSOLUTE_PATH patch
88
+ BASE_DIRECTORY "${CURRENT_PORT_DIR}"
89
+ OUTPUT_VARIABLE absolute_patch
90
+ )
91
+ if(NOT EXISTS "${absolute_patch}")
92
+ message(FATAL_ERROR "Could not find patch: '${patch}'")
93
+ endif()
94
+ file(SHA512 "${absolute_patch}" current_hash)
95
+ string(APPEND patchset_hash "${current_hash}")
96
+ endforeach()
97
+
98
+ string(SHA512 patchset_hash "${patchset_hash}")
99
+ string(SUBSTRING "${patchset_hash}" 0 10 patchset_hash)
100
+ cmake_path(APPEND working_directory "${arg_SOURCE_BASE}-${patchset_hash}"
101
+ OUTPUT_VARIABLE source_path
102
+ )
103
+
104
+ if(_VCPKG_EDITABLE AND EXISTS "${source_path}")
105
+ set("${out_source_path}" "${source_path}" PARENT_SCOPE)
106
+ message(STATUS "Using source at ${source_path}")
107
+ return()
108
+ elseif(NOT _VCPKG_EDITABLE)
109
+ cmake_path(APPEND_STRING source_path ".clean")
110
+ if(EXISTS "${source_path}")
111
+ message(STATUS "Cleaning sources at ${source_path}. Use --editable to skip cleaning for the packages you specify.")
112
+ file(REMOVE_RECURSE "${source_path}")
113
+ endif()
114
+ endif()
115
+
116
+ message(STATUS "Extracting source ${arg_ARCHIVE}")
117
+ cmake_path(APPEND_STRING source_path ".tmp" OUTPUT_VARIABLE temp_dir)
118
+ file(REMOVE_RECURSE "${temp_dir}")
119
+ file(MAKE_DIRECTORY "${temp_dir}")
120
+ vcpkg_execute_required_process(
121
+ ALLOW_IN_DOWNLOAD_MODE
122
+ COMMAND "${CMAKE_COMMAND}" -E tar xjf "${arg_ARCHIVE}"
123
+ WORKING_DIRECTORY "${temp_dir}"
124
+ LOGNAME extract
125
+ )
126
+
127
+ if(arg_NO_REMOVE_ONE_LEVEL)
128
+ cmake_path(SET temp_source_path "${temp_dir}")
129
+ else()
130
+ file(GLOB archive_directory "${temp_dir}/*")
131
+ # Exclude .DS_Store entries created by the finder on macOS
132
+ list(FILTER archive_directory EXCLUDE REGEX ".*/.DS_Store$")
133
+ # make sure `archive_directory` is only a single file
134
+ if(NOT archive_directory MATCHES ";" AND IS_DIRECTORY "${archive_directory}")
135
+ cmake_path(SET temp_source_path "${archive_directory}")
136
+ else()
137
+ message(FATAL_ERROR "Could not unwrap top level directory from archive. Pass NO_REMOVE_ONE_LEVEL to disable this.")
138
+ endif()
139
+ endif()
140
+
141
+ if (arg_SKIP_PATCH_CHECK)
142
+ set(quiet_param QUIET)
143
+ else()
144
+ set(quiet_param "")
145
+ endif()
146
+
147
+ z_vcpkg_apply_patches(
148
+ SOURCE_PATH "${temp_source_path}"
149
+ PATCHES ${arg_PATCHES}
150
+ ${quiet_param}
151
+ )
152
+
153
+ file(RENAME "${temp_source_path}" "${source_path}")
154
+ file(REMOVE_RECURSE "${temp_dir}")
155
+
156
+ set("${out_source_path}" "${source_path}" PARENT_SCOPE)
157
+ message(STATUS "Using source at ${source_path}")
158
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_extract_source_archive_ex.cmake ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(vcpkg_extract_source_archive_ex)
2
+ # OUT_SOURCE_PATH is an out-parameter so we need to parse it
3
+ cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "OUT_SOURCE_PATH" "")
4
+ if(NOT DEFINED arg_OUT_SOURCE_PATH)
5
+ message(FATAL_ERROR "OUT_SOURCE_PATH must be specified")
6
+ endif()
7
+
8
+ vcpkg_extract_source_archive(source_path ${arg_UNPARSED_ARGUMENTS} Z_ALLOW_OLD_PARAMETER_NAMES)
9
+
10
+ set("${arg_OUT_SOURCE_PATH}" "${source_path}" PARENT_SCOPE)
11
+ endfunction()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(DOXYGEN).cmake ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ set(program_name doxygen)
2
+ set(program_version 1.9.1)
3
+ if(CMAKE_HOST_WIN32)
4
+ set(download_filename "doxygen-${program_version}.windows.bin.zip")
5
+ set(download_sha512 "c3eeb6b9fa4eab70fb6b0864fbbf94fb8050f3fee38d117cf470921a80e3569cc1c8b0272604d6731e05f01790cfaa70e159bec5d0882fc4f2d8ae4a5d52a21b")
6
+ vcpkg_list(SET sourceforge_args
7
+ REPO doxygen
8
+ REF "rel-${program_version}"
9
+ )
10
+ set(tool_subdirectory c3eeb6b9fa-76d69c6db5)
11
+ endif()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(GIT).cmake ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ set(program_name git)
2
+ if(CMAKE_HOST_WIN32)
3
+ set(base_version 2.32.0)
4
+ set(program_version 2.32.0.2)
5
+ set(tool_subdirectory "git-${program_version}-2-windows")
6
+ set(download_urls "https://github.com/git-for-windows/git/releases/download/v${base_version}.windows.2/PortableGit-${program_version}-32-bit.7z.exe")
7
+ set(download_filename "PortableGit-${program_version}-32-bit.7z.exe")
8
+ set(download_sha512 867d8534972cbaf7a4224e25a14d484f8d17ef186f8d79e9a758afb90cf69541375cb7615a39702311f4809cb8371ef85c2b1a15bfffe9e48f0e597ac011b348)
9
+ set(paths_to_search
10
+ "${DOWNLOADS}/tools/${tool_subdirectory}/mingw32/bin"
11
+ "${DOWNLOADS}/tools/git/${tool_subdirectory}/mingw32/bin")
12
+ else()
13
+ set(brew_package_name "git")
14
+ set(apt_package_name "git")
15
+ endif()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(GPERF).cmake ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ set(program_name gperf)
2
+ set(program_version 3.0.1)
3
+ if(CMAKE_HOST_WIN32)
4
+ set(download_filename "gperf-${program_version}-bin.zip")
5
+ set(download_sha512 3f2d3418304390ecd729b85f65240a9e4d204b218345f82ea466ca3d7467789f43d0d2129fcffc18eaad3513f49963e79775b10cc223979540fa2e502fe7d4d9)
6
+ set(download_urls "https://sourceforge.net/projects/gnuwin32/files/gperf/${program_version}/gperf-${program_version}-bin.zip/download")
7
+ set(paths_to_search "${DOWNLOADS}/tools/gperf/bin")
8
+ endif()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(JOM).cmake ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ set(program_name jom)
2
+ set(program_version_string 1_1_4)
3
+ if(CMAKE_HOST_WIN32)
4
+ set(download_urls
5
+ "https://download.qt.io/official_releases/jom/jom_${program_version_string}.zip"
6
+ "https://mirrors.ocf.berkeley.edu/qt/official_releases/jom/jom_${program_version_string}.zip"
7
+ "https://mirrors.ukfast.co.uk/sites/qt.io/official_releases/jom/jom_${program_version_string}.zip"
8
+ )
9
+ set(download_filename "jom_${program_version_string}.zip")
10
+ set(download_sha512 a683bd829c84942223a791dae8abac5cfc2e3fa7de84c6fdc490ad3aa996a26c9fa0be0636890f02c9d56948bbe3225b43497cb590d1cb01e70c6fac447fa17b)
11
+ set(tool_subdirectory "jom-${program_version_string}")
12
+ set(paths_to_search "${DOWNLOADS}/tools/jom/${tool_subdirectory}")
13
+ endif()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(MESON).cmake ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ set(program_name meson)
2
+ set(search_names meson meson.py)
3
+ set(interpreter PYTHON3)
4
+ set(apt_package_name "meson")
5
+ set(brew_package_name "meson")
6
+ set(version_command --version)
7
+ set(extra_search_args EXACT_VERSION_MATCH)
8
+ if(EXISTS "${CURRENT_HOST_INSTALLED_DIR}/share/meson/version.txt")
9
+ file(READ "${CURRENT_HOST_INSTALLED_DIR}/share/meson/version.txt" program_version)
10
+ set(paths_to_search "${DOWNLOADS}/tools/meson-${program_version};${CURRENT_HOST_INSTALLED_DIR}/tools/meson")
11
+ else() # Old behavior
12
+ set(program_version 0.58.1)
13
+ set(ref aeda7f249c4a5dbbecc52e44f382246a2377b5b0)
14
+ set(paths_to_search "${DOWNLOADS}/tools/meson/meson-${ref}")
15
+ set(download_urls "https://github.com/mesonbuild/meson/archive/${ref}.tar.gz")
16
+ set(download_filename "meson-${ref}.tar.gz")
17
+ set(download_sha512 18a012a45274dbb4582e99fd69d920f38831e788d9860f9553c64847bedb1c2010ae0b5c0ef4a4350c03f5e0f95aaa0395378e1208109b59640c1a70b1e202d2)
18
+ endif()
cc-multilingual-main/cc_net/vcpkg/scripts/cmake/vcpkg_find_acquire_program(NINJA).cmake ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ set(program_name ninja)
2
+ set(program_version 1.10.2)
3
+ set(version_command --version)
4
+ if(CMAKE_HOST_WIN32)
5
+ set(download_filename "ninja-win-${program_version}.zip")
6
+ set(tool_subdirectory "${program_version}-windows")
7
+ set(download_urls "https://github.com/ninja-build/ninja/releases/download/v${program_version}/ninja-win.zip")
8
+ set(download_sha512 6004140d92e86afbb17b49c49037ccd0786ce238f340f7d0e62b4b0c29ed0d6ad0bab11feda2094ae849c387d70d63504393714ed0a1f4d3a1f155af7a4f1ba3)
9
+ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
10
+ set(download_filename "ninja-mac-${program_version}.zip")
11
+ set(download_urls "https://github.com/ninja-build/ninja/releases/download/v${program_version}/ninja-mac.zip")
12
+ set(tool_subdirectory "${program_version}-osx")
13
+ set(paths_to_search "${DOWNLOADS}/tools/ninja-${program_version}-osx")
14
+ set(download_sha512 bcd12f6a3337591306d1b99a7a25a6933779ba68db79f17c1d3087d7b6308d245daac08df99087ff6be8dc7dd0dcdbb3a50839a144745fa719502b3a7a07260b)
15
+ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "FreeBSD")
16
+ set(paths_to_search "${DOWNLOADS}/tools/${tool_subdirectory}-freebsd")
17
+ else()
18
+ vcpkg_execute_in_download_mode(COMMAND "uname" "-m" OUTPUT_VARIABLE HOST_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
19
+ if(HOST_ARCH MATCHES "x86_64|amd64|AMD64")
20
+ set(download_filename "ninja-linux-${program_version}.zip")
21
+ set(download_urls "https://github.com/ninja-build/ninja/releases/download/v${program_version}/ninja-linux.zip")
22
+ set(tool_subdirectory "${program_version}-linux")
23
+ set(paths_to_search "${DOWNLOADS}/tools/ninja-${program_version}-linux")
24
+ set(download_sha512 93e802e9c17fb59636cddde4bad1ddaadad624f4ecfee00d5c78790330a4e9d433180e795718cda27da57215ce643c3929cf72c85337ee019d868c56f2deeef3)
25
+ else()
26
+ set(version_command "") # somewhat hacky way to skip version check and use system binary
27
+ endif()
28
+ endif()