1
1
const std = @import ("std" );
2
2
3
- // Although this function looks imperative, note that its job is to
4
- // declaratively construct a build graph that will be executed by an external
5
- // runner.
6
3
pub fn build (b : * std.Build ) void {
7
- // Standard target options allows the person running `zig build` to choose
8
- // what target to build for. Here we do not override the defaults, which
9
- // means any target is allowed, and the default is native. Other options
10
- // for restricting supported target set are available.
11
4
const target = b .standardTargetOptions (.{});
12
-
13
- // Standard optimization options allow the person running `zig build` to select
14
- // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
15
- // set a preferred release mode, allowing the user to decide how to optimize.
16
5
const optimize = b .standardOptimizeOption (.{});
17
6
7
+ const libz_dep = b .dependency ("libz" , .{
8
+ .target = target ,
9
+ .optimize = optimize ,
10
+ });
11
+
18
12
const exe = b .addExecutable (.{
19
13
.name = "cpython" ,
20
14
.target = target ,
21
15
.optimize = optimize ,
22
16
});
17
+ exe .linkLibrary (libz_dep .artifact ("z" ));
23
18
exe .linkLibC ();
24
19
25
20
exe .addIncludePath (b .path ("Include/internal" ));
@@ -629,22 +624,44 @@ pub fn build(b: *std.Build) void {
629
624
}));
630
625
631
626
exe .addCSourceFiles (.{ .files = &.{
632
- "Programs/python.c" ,
627
+ "Modules/_abc.c" ,
628
+ "Modules/_codecsmodule.c" ,
629
+ "Modules/_collectionsmodule.c" ,
630
+ "Modules/_functoolsmodule.c" ,
631
+ "Modules/_io/_iomodule.c" ,
632
+ "Modules/_io/bufferedio.c" ,
633
+ "Modules/_io/bytesio.c" ,
634
+ "Modules/_io/fileio.c" ,
635
+ "Modules/_io/iobase.c" ,
636
+ "Modules/_io/stringio.c" ,
637
+ "Modules/_io/textio.c" ,
638
+ "Modules/_localemodule.c" ,
639
+ "Modules/_operator.c" ,
640
+ "Modules/_sre/sre.c" ,
641
+ "Modules/_stat.c" ,
642
+ "Modules/_threadmodule.c" ,
643
+ "Modules/_tracemalloc.c" ,
644
+ "Modules/_weakref.c" ,
645
+ "Modules/atexitmodule.c" ,
646
+ "Modules/config.c" ,
647
+ "Modules/errnomodule.c" ,
648
+ "Modules/faulthandler.c" ,
649
+ "Modules/gcmodule.c" ,
633
650
"Modules/getbuildinfo.c" ,
634
- "Parser/token .c" ,
635
- "Parser/pegen .c" ,
636
- "Parser/pegen_errors .c" ,
637
- "Parser/action_helpers .c" ,
638
- "Parser/parser .c" ,
639
- "Parser/string_parser .c" ,
640
- "Parser/peg_api .c" ,
641
- "Parser/myreadline .c" ,
642
- "Parser/tokenizer .c" ,
651
+ "Modules/itertoolsmodule .c" ,
652
+ "Modules/main .c" ,
653
+ "Modules/posixmodule .c" ,
654
+ "Modules/pwdmodule .c" ,
655
+ "Modules/signalmodule .c" ,
656
+ "Modules/symtablemodule .c" ,
657
+ "Modules/timemodule .c" ,
658
+ "Modules/xxsubtype .c" ,
659
+ "Modules/zlibmodule .c" ,
643
660
"Objects/abstract.c" ,
644
661
"Objects/accu.c" ,
645
662
"Objects/boolobject.c" ,
646
- "Objects/bytes_methods.c" ,
647
663
"Objects/bytearrayobject.c" ,
664
+ "Objects/bytes_methods.c" ,
648
665
"Objects/bytesobject.c" ,
649
666
"Objects/call.c" ,
650
667
"Objects/capsule.c" ,
@@ -653,57 +670,74 @@ pub fn build(b: *std.Build) void {
653
670
"Objects/codeobject.c" ,
654
671
"Objects/complexobject.c" ,
655
672
"Objects/descrobject.c" ,
673
+ "Objects/dictobject.c" ,
656
674
"Objects/enumobject.c" ,
657
675
"Objects/exceptions.c" ,
658
- "Objects/genericaliasobject.c" ,
659
- "Objects/genobject.c" ,
660
676
"Objects/fileobject.c" ,
661
677
"Objects/floatobject.c" ,
662
678
"Objects/frameobject.c" ,
663
679
"Objects/funcobject.c" ,
680
+ "Objects/genericaliasobject.c" ,
681
+ "Objects/genobject.c" ,
664
682
"Objects/interpreteridobject.c" ,
665
683
"Objects/iterobject.c" ,
666
684
"Objects/listobject.c" ,
667
685
"Objects/longobject.c" ,
668
- "Objects/dictobject.c" ,
669
- "Objects/odictobject.c" ,
670
686
"Objects/memoryobject.c" ,
671
687
"Objects/methodobject.c" ,
672
688
"Objects/moduleobject.c" ,
673
689
"Objects/namespaceobject.c" ,
674
690
"Objects/object.c" ,
675
691
"Objects/obmalloc.c" ,
692
+ "Objects/odictobject.c" ,
676
693
"Objects/picklebufobject.c" ,
677
694
"Objects/rangeobject.c" ,
678
695
"Objects/setobject.c" ,
679
696
"Objects/sliceobject.c" ,
680
697
"Objects/structseq.c" ,
681
698
"Objects/tupleobject.c" ,
682
699
"Objects/typeobject.c" ,
683
- "Objects/unicodeobject.c" ,
684
700
"Objects/unicodectype.c" ,
701
+ "Objects/unicodeobject.c" ,
685
702
"Objects/unionobject.c" ,
686
703
"Objects/weakrefobject.c" ,
687
- "Python/_warnings.c" ,
704
+ "Parser/action_helpers.c" ,
705
+ "Parser/myreadline.c" ,
706
+ "Parser/parser.c" ,
707
+ "Parser/peg_api.c" ,
708
+ "Parser/pegen.c" ,
709
+ "Parser/pegen_errors.c" ,
710
+ "Parser/string_parser.c" ,
711
+ "Parser/token.c" ,
712
+ "Parser/tokenizer.c" ,
713
+ "Programs/python.c" ,
688
714
"Python/Python-ast.c" ,
689
715
"Python/Python-tokenize.c" ,
716
+ "Python/_warnings.c" ,
690
717
"Python/asdl.c" ,
691
718
"Python/ast.c" ,
692
719
"Python/ast_opt.c" ,
693
720
"Python/ast_unparse.c" ,
694
721
"Python/bltinmodule.c" ,
722
+ "Python/bootstrap_hash.c" ,
695
723
"Python/ceval.c" ,
696
724
"Python/codecs.c" ,
697
725
"Python/compile.c" ,
698
726
"Python/context.c" ,
727
+ "Python/deepfreeze/deepfreeze.c" ,
728
+ "Python/dtoa.c" ,
699
729
"Python/dynamic_annotations.c" ,
700
730
"Python/errors.c" ,
731
+ "Python/fileutils.c" ,
732
+ "Python/formatter_unicode.c" ,
701
733
"Python/frame.c" ,
734
+ "Python/frozen.c" ,
702
735
"Python/frozenmain.c" ,
703
736
"Python/future.c" ,
704
737
"Python/getargs.c" ,
705
738
"Python/getcompiler.c" ,
706
739
"Python/getcopyright.c" ,
740
+ "Python/getopt.c" ,
707
741
"Python/getplatform.c" ,
708
742
"Python/getversion.c" ,
709
743
"Python/hamt.c" ,
@@ -724,56 +758,18 @@ pub fn build(b: *std.Build) void {
724
758
"Python/pylifecycle.c" ,
725
759
"Python/pymath.c" ,
726
760
"Python/pystate.c" ,
761
+ "Python/pystrcmp.c" ,
762
+ "Python/pystrhex.c" ,
763
+ "Python/pystrtod.c" ,
727
764
"Python/pythonrun.c" ,
728
765
"Python/pytime.c" ,
729
- "Python/bootstrap_hash.c" ,
730
766
"Python/specialize.c" ,
731
767
"Python/structmember.c" ,
768
+ "Python/suggestions.c" ,
732
769
"Python/symtable.c" ,
733
770
"Python/sysmodule.c" ,
734
771
"Python/thread.c" ,
735
772
"Python/traceback.c" ,
736
- "Python/getopt.c" ,
737
- "Python/pystrcmp.c" ,
738
- "Python/pystrtod.c" ,
739
- "Python/pystrhex.c" ,
740
- "Python/dtoa.c" ,
741
- "Python/formatter_unicode.c" ,
742
- "Python/fileutils.c" ,
743
- "Python/suggestions.c" ,
744
- "Modules/config.c" ,
745
- "Modules/main.c" ,
746
- "Modules/gcmodule.c" ,
747
- "Modules/atexitmodule.c" ,
748
- "Modules/faulthandler.c" ,
749
- "Modules/posixmodule.c" ,
750
- "Modules/signalmodule.c" ,
751
- "Modules/_tracemalloc.c" ,
752
- "Modules/_codecsmodule.c" ,
753
- "Modules/_collectionsmodule.c" ,
754
- "Modules/errnomodule.c" ,
755
- "Modules/_io/_iomodule.c" ,
756
- "Modules/_io/iobase.c" ,
757
- "Modules/_io/fileio.c" ,
758
- "Modules/_io/bytesio.c" ,
759
- "Modules/_io/bufferedio.c" ,
760
- "Modules/_io/textio.c" ,
761
- "Modules/_io/stringio.c" ,
762
- "Modules/itertoolsmodule.c" ,
763
- "Modules/_sre/sre.c" ,
764
- "Modules/_threadmodule.c" ,
765
- "Modules/timemodule.c" ,
766
- "Modules/_weakref.c" ,
767
- "Modules/_abc.c" ,
768
- "Modules/_functoolsmodule.c" ,
769
- "Modules/_localemodule.c" ,
770
- "Modules/_operator.c" ,
771
- "Modules/_stat.c" ,
772
- "Modules/symtablemodule.c" ,
773
- "Modules/pwdmodule.c" ,
774
- "Modules/xxsubtype.c" ,
775
- "Python/deepfreeze/deepfreeze.c" ,
776
- "Python/frozen.c" ,
777
773
}, .flags = &.{
778
774
"-fwrapv" ,
779
775
"-std=c11" ,
0 commit comments