11import argparse
22import logging
33import base
4+ import os
5+ import module_ffmpeg
46
57def setup_loggers (logger_path :str ):
68 logger = logging .getLogger ('build' )
@@ -24,23 +26,45 @@ def setup_loggers(logger_path:str):
2426 logger .addHandler (console_handler )
2527 return logger
2628
29+
2730def parse_args ():
2831 parser = argparse .ArgumentParser ()
2932 parser .add_argument ('-p' , '--platform' , type = str , default = 'android' , choices = ['apple' , 'android' , 'ios' , 'tvos' , 'macos' , 'all' ], help = 'platform must be: [apple|android|ios|tvos|macos|all]' )
3033 # only avalibale for apple
3134 parser .add_argument ('-a' , '--arch' , type = str , default = 'arm64' , choices = ['arm64' , 'arm64-simulator' ,'x86_64' , 'x86_64-simulator' , 'all' ], help = 'arch must be: [arm64|arm64-simulator|x86_64|x86_64-simulator|all], only avaliable for apple' )
3235 parser .add_argument ('-w' , '--workspace' , type = str , default = 'build' , help = 'specify workspace' )
3336 parser .add_argument ('--prefix' , type = str , help = 'install the library' )
34- parser .add_argument ('--install' , action = 'store_true' , help = 'install the library' )
35- parser .add_argument ('--init' , action = 'store_true' , help = 'initialize the library' )
36- parser .add_argument ('--build' , action = 'store_true' , help = 'build the library' )
37+ parser .add_argument ('--action' , type = str , default = 'init' , choices = ['init' , 'build' , 'install' ], help = 'action must be: [init|build|install]' )
38+ parser .add_argument ('--library' , type = str , default = "" , help = 'specify the library name' )
39+ # parser.add_argument('--install', action='store_true', help='install the library')
40+ # # prepare the repo, clone the sample code, and don't build it.
41+ # parser.add_argument('--init', action='store_true', help='initialize the library')
42+ # parser.add_argument('--build', action='store_true', help='build the library')
3743
3844 args = parser .parse_args ()
3945 return args
4046
47+ def preapre_workspaces (bcfg :base .BuildConfigure ):
48+ if not bcfg .action == "init" :
49+ logger .info ("Not initialize the library, skip checking workspace!" )
50+ return
51+ bcfg .prepare ()
52+
4153if __name__ == "__main__" :
4254 args = parse_args ()
4355 logger = setup_loggers ("build.log" )
44- args = base .BuildConfigure (args .platform , args .arch , args .workspace , args .prefix , args .build )
45- print (base .get_platform_envs (args ))
56+ build_cfg = base .BuildConfigure (args .platform , args .arch , args .workspace , args .prefix , args .action )
57+ toolchain_vars , host_vars = base .get_platform_envs (build_cfg )
58+ preapre_workspaces (build_cfg )
59+
60+ ffmpeg_module = module_ffmpeg .FFMpegModule (build_cfg , toolchain_vars , host_vars )
61+ # "repo": "https://github.com/FFmpeg/FFmpeg.git",
62+ # "repo_env": "REPO_FFMPEG",
63+ # "repo_save_dir": "FFmpeg"
64+ ffconfig = ffmpeg_module .get_module_config ()
65+ repo = os .environ .get (ffconfig ["repo_env" ], ffconfig ['repo' ])
66+ repo_save_dir = os .path .join (build_cfg .get_samples_dir (), ffconfig ['repo_save_dir' ])
67+ ffmpeg_module .init_sample_repo (repo , repo_save_dir )
68+
69+ # print(base.get_platform_envs(args))
4670 pass
0 commit comments