Пример #1
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir) :
    """builds the final webpage under under fips-deploy/oryol-webpage"""
    ws_dir = util.get_workspace_dir(fips_dir)
    deploy_dir = '{}/fips-deploy/yakc/yakc-emsc-make-release/'.format(ws_dir)

    # webpage files
    copy_tree(proj_dir+'/web/_site', webpage_dir)

    # copy the application files
    for name in ['yakcapp.js'] :
        log.info('> copy file: {}'.format(name))
        shutil.copy(deploy_dir + name, webpage_dir + '/' + name)

    # copy kcc and tap files
    for fname in glob.glob(proj_dir + '/files/*') :
        log.info('> copy file: {}'.format(fname))
        shutil.copy(fname, webpage_dir + '/' + os.path.basename(fname))

    # if the virtualkc directory exists, copy everything there
    # so that a simple git push is enough to upload
    # the webpage
    vkc_dir = '{}/virtualkc'.format(ws_dir)
    if os.path.isdir(vkc_dir) :
        log.info(">>> updating virtualkc repository")
        copy_tree(webpage_dir, vkc_dir)
Пример #2
0
def build_deploy_webpage(fips_dir, proj_dir, rebuild):
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/oryol-webpage'.format(ws_dir)
    if rebuild:
        if os.path.isdir(webpage_dir):
            shutil.rmtree(webpage_dir)
    if not os.path.isdir(webpage_dir):
        os.makedirs(webpage_dir)

    # compile samples
    if BuildEmscripten and emscripten.check_exists(fips_dir):
        project.gen(fips_dir, proj_dir, EmscConfig)
        project.build(fips_dir, proj_dir, EmscConfig)
    if BuildWasm and emscripten.check_exists(fips_dir):
        project.gen(fips_dir, proj_dir, WasmConfig)
        project.build(fips_dir, proj_dir, WasmConfig)

    # export sample assets
    if ExportAssets:
        export_assets(fips_dir, proj_dir, webpage_dir)

    # deploy the webpage
    deploy_webpage(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN,
                'Generated Samples web page under {}.'.format(webpage_dir))
Пример #3
0
Файл: dep.py Проект: floooh/fips
def _rec_update_imports(fips_dir, proj_dir, handled) :
    """same as _rec_fetch_imports() but for updating the imported projects
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in handled :
        handled.append(proj_name)
        imports = get_imports(fips_dir, proj_dir)
        for dep in imports:
            dep_proj_name = dep
            if dep not in handled:
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                log.colored(log.YELLOW, "=== dependency: '{}':".format(dep_proj_name))
                dep_ok = False
                if os.path.isdir(dep_proj_dir) :
                    # directory did not exist, do a fresh git clone
                    dep = imports[dep_proj_name]
                    git_commit = None if 'rev' not in dep else dep['rev']
                    if git.has_local_changes(dep_proj_dir) :
                        log.warn("  '{}' has local changes, skipping...".format(dep_proj_dir))
                    else :
                        log.colored(log.BLUE, "  updating '{}'...".format(dep_proj_dir))
                        git.update(dep_proj_dir)
                        if git_commit:
                            log.colored(log.YELLOW, "=== revision: '{}':".format(git_commit))
                            dep_ok = git.checkout(dep_proj_dir, git_commit)
                        else:
                            dep_ok = True
                else :
                    log.warn("  '{}' does not exist, please run 'fips fetch'".format(dep_proj_dir))
                # recuse
                if dep_ok :
                    handled = _rec_update_imports(fips_dir, dep_proj_dir, handled)
    # done, return the new handled array
    return handled
Пример #4
0
def build_deploy_webpage(fips_dir, proj_dir):
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/oryol-webpage'.format(ws_dir)
    if os.path.isdir(webpage_dir):
        shutil.rmtree(webpage_dir)
    os.makedirs(webpage_dir)

    # compile emscripten, pnacl and android samples
    if BuildEmscripten and emscripten.check_exists(fips_dir):
        project.gen(fips_dir, proj_dir, 'emsc-make-release')
        project.build(fips_dir, proj_dir, 'emsc-make-release')
    if BuildPNaCl and nacl.check_exists(fips_dir):
        project.gen(fips_dir, proj_dir, 'pnacl-make-release')
        project.build(fips_dir, proj_dir, 'pnacl-make-release')
    if BuildAndroid and android.check_exists(fips_dir):
        project.gen(fips_dir, proj_dir, 'android-make-release')
        project.build(fips_dir, proj_dir, 'android-make-release')

    # export sample assets
    export_assets(fips_dir, proj_dir, webpage_dir)

    # deploy the webpage
    deploy_webpage(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN,
                'Generated Samples web page under {}.'.format(webpage_dir))
Пример #5
0
def serve_webpage(fips_dir, proj_dir):
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/{}'.format(ws_dir, WebpageDeployDir)
    p = util.get_host_platform()
    if p == 'osx':
        try:
            subprocess.call('http-server -c-1 -g -o'.format(fips_dir),
                            cwd=webpage_dir,
                            shell=True)
        except KeyboardInterrupt:
            pass
    elif p == 'win':
        try:
            subprocess.call('http-server -c-1 -g -o'.format(fips_dir),
                            cwd=webpage_dir,
                            shell=True)
        except KeyboardInterrupt:
            pass
    elif p == 'linux':
        try:
            subprocess.call('http-server -c-1 -g -o'.format(fips_dir),
                            cwd=webpage_dir,
                            shell=True)
        except KeyboardInterrupt:
            pass
Пример #6
0
def serve_webpage(fips_dir, proj_dir) :
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/sokol-webpage'.format(ws_dir)
    p = util.get_host_platform()
    if p == 'osx' :
        try :
            subprocess.call(
                'open http://localhost:8000 ; python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt :
            pass
    elif p == 'win':
        try:
            subprocess.call(
                'cmd /c start http://localhost:8000 && python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt:
            pass
    elif p == 'linux':
        try:
            subprocess.call(
                'xdg-open http://localhost:8000; python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt:
            pass
Пример #7
0
def build_deploy_webpage(fips_dir, proj_dir) :
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/oryol-webpage'.format(ws_dir)
    if os.path.isdir(webpage_dir) :
        shutil.rmtree(webpage_dir)
    os.makedirs(webpage_dir)

    # compile emscripten, pnacl and android samples
    if BuildEmscripten and emscripten.check_exists(fips_dir) :
        project.gen(fips_dir, proj_dir, 'emsc-ninja-release')
        project.build(fips_dir, proj_dir, 'emsc-ninja-release')
    if BuildWasm and emscripten.check_exists(fips_dir) :
        project.gen(fips_dir, proj_dir, 'wasm-ninja-release')
        project.build(fips_dir, proj_dir, 'wasm-ninja-release')
    if BuildPNaCl and nacl.check_exists(fips_dir) :
        project.gen(fips_dir, proj_dir, 'pnacl-ninja-release')
        project.build(fips_dir, proj_dir, 'pnacl-ninja-release')
    
    # export sample assets
    export_assets(fips_dir, proj_dir, webpage_dir)

    # deploy the webpage
    deploy_webpage(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN, 'Generated Samples web page under {}.'.format(webpage_dir))
Пример #8
0
def serve_webpage(fips_dir, proj_dir) :
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/oryol-webpage'.format(ws_dir)
    p = util.get_host_platform()
    if p == 'osx' :
        try :
            subprocess.call(
                'open http://localhost:8000 ; python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt :
            pass
    elif p == 'win':
        try:
            subprocess.call(
                'cmd /c start http://localhost:8000 && python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt:
            pass
    elif p == 'linux':
        try:
            subprocess.call(
                'xdg-open http://localhost:8000; python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt:
            pass
Пример #9
0
def _rec_update_imports(fips_dir, proj_dir, handled) :
    """same as _rec_fetch_imports() but for updating the imported projects
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in handled :
        handled.append(proj_name)
        imports = get_imports(fips_dir, proj_dir)
        for dep in imports:
            dep_proj_name = dep
            if dep not in handled:
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                log.colored(log.YELLOW, "=== dependency: '{}':".format(dep_proj_name))
                dep_ok = False
                if os.path.isdir(dep_proj_dir) :
                    # directory did not exist, do a fresh git clone
                    dep = imports[dep_proj_name]
                    git_commit = None if 'rev' not in dep else dep['rev']
                    if git.has_local_changes(dep_proj_dir) :
                        log.warn("  '{}' has local changes, skipping...".format(dep_proj_dir))
                    else :
                        log.colored(log.BLUE, "  updating '{}'...".format(dep_proj_dir))
                        git.update(dep_proj_dir)
                        if git_commit:
                            log.colored(log.YELLOW, "=== revision: '{}':".format(git_commit))
                            dep_ok = git.checkout(dep_proj_dir, git_commit)
                        else:
                            dep_ok = True
                else :
                    log.warn("  '{}' does not exist, please run 'fips fetch'".format(dep_proj_dir))
                # recuse
                if dep_ok :
                    handled = _rec_update_imports(fips_dir, dep_proj_dir, handled)
    # done, return the new handled array
    return handled
Пример #10
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir):
    """builds the final webpage under under fips-deploy/oryol-webpage"""
    ws_dir = util.get_workspace_dir(fips_dir)
    asmjs_dir = '{}/fips-deploy/yakc/yakc-emsc-make-release/'.format(ws_dir)
    wasm_dir = '{}/fips-deploy/yakc/yakc-wasm-make-release/'.format(ws_dir)

    # webpage files
    copy_tree(proj_dir + '/web/_site', webpage_dir)

    # copy the application files
    shutil.copy(asmjs_dir + 'yakcapp.js', webpage_dir + '/yakcapp.js')
    shutil.copy(wasm_dir + 'yakcapp.js', webpage_dir + '/yakcapp.wasm.js')
    shutil.copy(wasm_dir + 'yakcapp.wasm', webpage_dir + '/yakcapp.wasm.txt')

    # copy game/rom image files
    for fname in glob.glob(proj_dir + '/files/*'):
        if os.path.isfile(fname):
            shutil.copy(fname, webpage_dir + '/' + os.path.basename(fname))

    # if the virtualkc directory exists, copy everything there
    # so that a simple git push is enough to upload
    # the webpage
    vkc_dir = '{}/virtualkc'.format(ws_dir)
    if os.path.isdir(vkc_dir):
        log.info(">>> updating virtualkc repository")
        copy_tree(webpage_dir, vkc_dir)
Пример #11
0
def run(fips_dir, proj_dir, args):
    """run the 'physx' verb"""
    if len(args) > 0:
        noun = args[0]
        if noun == 'build':

            # FIXME all of this only works on windows at the moment and is super hacky

            if len(args) != 2:
                log.error("expected compiler target (win-vs15, win-vs16)")

            preset = util.fix_path(os.path.dirname(os.path.abspath(
                __file__))) + "/physx-presets/" + "fips" + args[1] + ".xml"
            if not os.path.isfile(preset):
                log.error("unrecognized compiler target")
            shutil.copy2(preset,
                         proj_dir + "/../physx/physx/buildtools/presets/")
            subprocess.call(proj_dir +
                            "/../physx/physx/generate_projects.bat fips" +
                            args[1])

            # figure out a version number for vswhere
            version = args[1][6:]
            version_next = str(int(version) + 1)
            version = version + ".0," + version_next + ".0"
            #use vswhere to figure out where vs is
            devenvPath = subprocess.check_output(
                proj_dir + "/../physx/externals/vswhere/vswhere -version [" +
                version + "] -property productPath").decode("utf-8").rstrip()

            devenvPath = util.fix_path(devenvPath)
            if not os.path.isfile(devenvPath):
                log.error("could not detect visual studio installation")
            log.info("Using Visual Studio from" + devenvPath)
            log.info("Compiling PhysX, this might take a while")
            log.info("Building debug version")
            subprocess.call(devenvPath + " " + proj_dir +
                            "/../physx/physx/compiler/fips" + args[1] +
                            "/PhysXSDK.sln /Build debug /Project INSTALL")
            log.info("Building release version")
            subprocess.call(devenvPath + " " + proj_dir +
                            "/../physx/physx/compiler/fips" + args[1] +
                            "/PhysXSDK.sln /Build release /Project INSTALL")
        if noun == 'deploy':
            ps_deploy = util.get_workspace_dir(
                fips_dir) + "/fips-deploy/physx/bin/"
            cur_cfg = settings.get(proj_dir, "config")
            cfg = config.load(fips_dir, proj_dir, cur_cfg)[0]
            px_target = cfg['defines']['PX_TARGET']
            target_dir = util.get_deploy_dir(
                fips_dir, util.get_project_name_from_dir(proj_dir), cur_cfg)
            for dll in glob.glob(ps_deploy + px_target + "/debug/*.dll"):
                shutil.copy2(dll, target_dir)
            for dll in glob.glob(ps_deploy + px_target + "/release/*.dll"):
                shutil.copy2(dll, target_dir)
    else:

        def run(fips_dir, proj_dir, args):
            log.error("Not supported")
Пример #12
0
def copy_build_files(fips_dir, proj_dir, webpage_dir) :
    # copy all files from the deploy dir to the webpage_dir
    ws_dir = util.get_workspace_dir(fips_dir)
    src_dir = '{}/fips-deploy/oryol-samples/wasmasmjs-make-release'.format(ws_dir)
    dst_dir = webpage_dir
    copy_tree(src_dir, dst_dir)
    shutil.copy('{}/web/wasmsuite-readme.md'.format(proj_dir), '{}/README.md'.format(dst_dir))
    shutil.copy('{}/LICENSE'.format(proj_dir), '{}/LICENSE'.format(dst_dir))
Пример #13
0
def _rec_get_all_imports_exports(fips_dir, proj_dir, result):
    """recursively get all imported projects, their exported and
    imported modules in a dictionary object:
        
        project-1:
            url:    git-url (not valid for first, top-level project)
            exports:
                header-dirs: [ ]
                conditional-header-dirs:
                    dir: cmake-if condition string
                lib-dirs: [ ]
                defines: 
                    def-key: def-val
                    ...
                modules :
                    mod: dir
                    mod: dir
                ...
            imports:
                name:
                    git:    [git-url]
                    branch: [optional: branch or tag]
                    cond:   [optional: cmake-if condition string conditionally including the dependency]
                name:
                    ...
                ...
        ...

    :param fips_dir:    absolute fips directory
    :param proj_dir:    absolute project directory
    :param result:      in/out current result
    :returns:           bool success, and modified result dictionary
    """
    success = True
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in result:
        imports = get_imports(fips_dir, proj_dir)
        exports = get_exports(proj_dir)
        for dep_proj_name in imports:
            if dep_proj_name not in result:
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                dep_url = imports[dep_proj_name]['git']
                success, result = _rec_get_all_imports_exports(
                    fips_dir, dep_proj_dir, result)
                # break recursion on error
                if not success:
                    return success, result

        result[proj_name] = {}
        result[proj_name]['proj_dir'] = proj_dir
        result[proj_name]['imports'] = imports
        result[proj_name]['exports'] = exports

    # done
    return success, result
Пример #14
0
Файл: dep.py Проект: floooh/fips
def _rec_get_all_imports_exports(fips_dir, proj_dir, result) :
    """recursively get all imported projects, their exported and
    imported modules in a dictionary object:
        
        project-1:
            url:    git-url (not valid for first, top-level project)
            exports:
                header-dirs: [ ]
                lib-dirs: [ ]
                defines: 
                    def-key: def-val
                    ...
                modules :
                    mod: dir
                    mod: dir
                ...
            imports:
                name:
                    git:    [git-url]
                    branch: [optional: branch or tag]
                    cond:   [optional: cmake-if condition string conditionally including the dependency]
                name:
                    ...
                ...
        ...

    :param fips_dir:    absolute fips directory
    :param proj_dir:    absolute project directory
    :param result:      in/out current result
    :returns:           bool success, and modified result dictionary
    """
    success = True
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in result :
        imports = get_imports(fips_dir, proj_dir)
        exports = get_exports(proj_dir)
        for dep_proj_name in imports :
            if dep_proj_name not in result :
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                dep_url = imports[dep_proj_name]['git']
                success, result = _rec_get_all_imports_exports(fips_dir, dep_proj_dir, result)
                # break recursion on error
                if not success :
                    return success, result

        result[proj_name] = {}
        result[proj_name]['proj_dir'] = proj_dir
        result[proj_name]['imports'] = imports 
        result[proj_name]['exports'] = exports 

    # done
    return success, result
Пример #15
0
def view(fips_dir, proj_dir):
    proj_name = util.get_project_name_from_dir(proj_dir)
    out_dir = util.get_workspace_dir(fips_dir)+'/fips-deploy/'+proj_name+'-markdeep'
    if os.path.isfile(out_dir+'/index.html'):
        p = util.get_host_platform()
        if p == 'osx':
            subprocess.call('open index.html', cwd=out_dir, shell=True)
        elif p == 'win':
            subprocess.call('start index.html', cwd=out_dir, shell=True)
        elif p == 'linux':
            subprocess.call('xdg-open index.html', cwd=out_dir, shell=True)
    else:
        log.error('no generated index.html found: {}'.format(out_dir+'/index.html'))
Пример #16
0
def view(fips_dir, proj_dir):
    proj_name = util.get_project_name_from_dir(proj_dir)
    out_dir = util.get_workspace_dir(fips_dir)+'/fips-deploy/'+proj_name+'-markdeep'
    if os.path.isfile(out_dir+'/index.html'):
        p = util.get_host_platform()
        if p == 'osx':
            subprocess.call('open index.html', cwd=out_dir, shell=True)
        elif p == 'win':
            subprocess.call('start index.html', cwd=out_dir, shell=True)
        elif p == 'linux':
            subprocess.call('xdg-open index.html', cwd=out_dir, shell=True)
    else:
        log.error('no generated index.html found: {}'.format(out_dir+'/index.html'))
Пример #17
0
def _rec_fetch_imports(fips_dir, proj_dir, handled) :
    """internal recursive function to fetch project imports,
    keeps an array of already handled dirs to break cyclic dependencies

    :param proj_dir:    current project directory
    :param handled:     array of already handled dirs
    :returns:           updated array of handled dirs
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in handled :
        handled.append(proj_name)

        imports = get_imports(fips_dir, proj_dir)
        for dep in imports:
            dep_proj_name = dep
            if dep not in handled:
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                log.colored(log.YELLOW, "=== dependency: '{}':".format(dep_proj_name))
                dep_ok = False
                if not os.path.isdir(dep_proj_dir) :
                    # directory did not exist, do a fresh git clone
                    dep = imports[dep_proj_name]
                    git_commit = None if 'rev' not in dep else dep['rev']
                    if git_commit :
                        if 'depth' in dep :
                            # when using rev, we may not want depth because the revision may not be reachable
                            log.colored(log.YELLOW, "=== 'depth' was ignored because parameter 'rev' is specified.")
                        dep['depth'] = None
                    git_depth = git.clone_depth if not git_commit and 'depth' not in dep else dep['depth']
                    git_url = dep['git']
                    git_branch = dep['branch']
                    if git.clone(git_url, git_branch, git_depth, dep_proj_name, ws_dir) :
                        if git_commit :
                            log.colored(log.YELLOW, "=== revision: '{}':".format(git_commit))
                            dep_ok = git.checkout(dep_proj_dir, git_commit)
                        else :
                            dep_ok = True
                    else :
                        log.error('failed to git clone {} into {}'.format(git_url, dep_proj_dir))
                else :
                    # directory already exists
                    log.info("dir '{}' exists".format(dep_proj_dir))
                    dep_ok = True

                # recuse
                if dep_ok :
                    handled = _rec_fetch_imports(fips_dir, dep_proj_dir, handled)

    # done, return the new handled array
    return handled
Пример #18
0
def _rec_fetch_imports(fips_dir, proj_dir, handled) :
    """internal recursive function to fetch project imports,
    keeps an array of already handled dirs to break cyclic dependencies

    :param proj_dir:    current project directory
    :param handled:     array of already handled dirs
    :returns:           updated array of handled dirs
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in handled :
        handled.append(proj_name)

        imports = get_imports(fips_dir, proj_dir)
        for dep in imports:
            dep_proj_name = dep
            if dep not in handled:
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                log.colored(log.YELLOW, "=== dependency: '{}':".format(dep_proj_name))
                dep_ok = False
                if not os.path.isdir(dep_proj_dir) :
                    # directory did not exist, do a fresh git clone
                    dep = imports[dep_proj_name]
                    git_commit = None if 'rev' not in dep else dep['rev']
                    if git_commit :
                        if 'depth' in dep :
                            # when using rev, we may not want depth because the revision may not be reachable
                            log.colored(log.YELLOW, "=== 'depth' was ignored because parameter 'rev' is specified.")
                        dep['depth'] = None
                    git_depth = git.clone_depth if not git_commit and 'depth' not in dep else dep['depth']
                    git_url = dep['git']
                    git_branch = dep['branch']
                    if git.clone(git_url, git_branch, git_depth, dep_proj_name, ws_dir) :
                        if git_commit :
                            log.colored(log.YELLOW, "=== revision: '{}':".format(git_commit))
                            dep_ok = git.checkout(dep_proj_dir, git_commit)
                        else :
                            dep_ok = True
                    else :
                        log.error('failed to git clone {} into {}'.format(git_url, dep_proj_dir))
                else :
                    # directory already exists
                    log.info("dir '{}' exists".format(dep_proj_dir))
                    dep_ok = True

                # recuse
                if dep_ok :
                    handled = _rec_fetch_imports(fips_dir, dep_proj_dir, handled)

    # done, return the new handled array
    return handled
Пример #19
0
def build_deploy_webpage(fips_dir, proj_dir) :
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/oryol-wasm-buildsuite'.format(ws_dir)
    if not os.path.exists(webpage_dir) :
        os.makedirs(webpage_dir)
    config = 'wasmasmjs-make-release'
    project.clean(fips_dir, proj_dir, config) 
    project.gen(fips_dir, proj_dir, config)
    for target in Samples :
        project.build(fips_dir, proj_dir, config, target)
    
    copy_build_files(fips_dir, proj_dir, webpage_dir)
    if ExportAssets :
        export_assets(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN, 'Done. ({})'.format(webpage_dir))
Пример #20
0
def build_deploy_webpage(fips_dir, proj_dir):
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/v6502r-webpage'.format(ws_dir)
    if not os.path.isdir(webpage_dir):
        os.makedirs(webpage_dir)

    project.gen(fips_dir, proj_dir, BuildConfig)
    project.build(fips_dir, proj_dir, BuildConfig)

    src_dir = '{}/fips-deploy/v6502r/{}'.format(ws_dir, BuildConfig)
    dst_dir = webpage_dir

    shutil.copy(src_dir + '/v6502r.html', dst_dir + '/index.html')
    shutil.copy(src_dir + '/v6502r.wasm', dst_dir + '/v6502r.wasm')
    shutil.copy(src_dir + '/v6502r.js', dst_dir + '/v6502r.js')

    log.colored(log.GREEN,
                'Generated Samples web page under {}.'.format(webpage_dir))
Пример #21
0
def build_deploy_webpage(fips_dir, proj_dir, rebuild) :
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/chips-webpage'.format(ws_dir)
    if rebuild :
        if os.path.isdir(webpage_dir) :
            shutil.rmtree(webpage_dir)
    if not os.path.isdir(webpage_dir) :
        os.makedirs(webpage_dir)

    # compile samples
    project.gen(fips_dir, proj_dir, BuildConfig)
    project.build(fips_dir, proj_dir, BuildConfig)
    
    # deploy the webpage
    deploy_webpage(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN, 'Generated Samples web page under {}.'.format(webpage_dir))
Пример #22
0
def build_deploy_webpage(fips_dir, proj_dir, chip):
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/{}-webpage'.format(ws_dir, chip)
    if not os.path.isdir(webpage_dir):
        os.makedirs(webpage_dir)
    project.gen(fips_dir, proj_dir, BuildConfig)
    project.build(fips_dir, proj_dir, BuildConfig)
    proj_name = util.get_project_name_from_dir(proj_dir)
    util.ensure_valid_project_dir(proj_dir)
    src_dir = '{}/fips-deploy/NextSim/{}'.format(ws_dir, BuildConfig)
    dst_dir = webpage_dir
    #This area can be cleaned up sometime
    ns = "NextSim"
    shutil.copy(src_dir + '/' + ns + '.html', dst_dir + '/index.html')
    shutil.copy(src_dir + '/' + ns + '.wasm', dst_dir + '/' + ns + '.wasm')
    shutil.copy(src_dir + '/' + ns + '.js', dst_dir + '/' + ns + '.js')
    shutil.copy(proj_dir + '/src/res/favicon.png', dst_dir + '/favicon.png')
    log.colored(log.GREEN,
                'Generated Samples web page under {}.'.format(webpage_dir))
Пример #23
0
def _rec_fetch_imports(fips_dir, proj_dir, handled):
    """internal recursive function to fetch project imports,
    keeps an array of already handled dirs to break cyclic dependencies

    :param proj_dir:    current project directory
    :param handled:     array of already handled dirs
    :returns:           updated array of handled dirs
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in handled:
        handled.append(proj_name)

        imports = get_imports(fips_dir, proj_dir)
        for dep in imports:
            dep_proj_name = dep
            if dep not in handled:
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                log.colored(log.YELLOW,
                            "=== dependency: '{}':".format(dep_proj_name))
                dep_ok = False
                if not os.path.isdir(dep_proj_dir):
                    # directory did not exist, do a fresh git clone
                    git_url = imports[dep_proj_name]['git']
                    git_branch = imports[dep_proj_name]['branch']
                    if git.clone(git_url, git_branch, dep_proj_name, ws_dir):
                        dep_ok = True
                    else:
                        log.error('failed to git clone {} into {}'.format(
                            git_url, dep_proj_dir))
                else:
                    # directory already exists
                    log.info("dir '{}' exists".format(dep_proj_dir))
                    dep_ok = True

                # recuse
                if dep_ok:
                    handled = _rec_fetch_imports(fips_dir, dep_proj_dir,
                                                 handled)

    # done, return the new handled array
    return handled
Пример #24
0
def build_deploy_webpage(fips_dir, proj_dir) :
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/yakc-webpage/virtualkc'.format(ws_dir)
    if os.path.isdir(webpage_dir) :
        shutil.rmtree(webpage_dir)
    os.makedirs(webpage_dir)

    # compile emscripten, pnacl and android samples
    if emscripten.check_exists(fips_dir) :
        project.gen(fips_dir, proj_dir, 'yakc-emsc-make-release')
        project.build(fips_dir, proj_dir, 'yakc-emsc-make-release')
   
    # build the webpage via jekyll
    subprocess.call('jekyll build', cwd=proj_dir+'/web', shell=True)

    # deploy the webpage
    deploy_webpage(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN, 'Generated web page under {}.'.format(webpage_dir))
Пример #25
0
def build_deploy_webpage(fips_dir, proj_dir) :
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/oryol-samples-webpage'.format(ws_dir)
    if os.path.isdir(webpage_dir) :
        shutil.rmtree(webpage_dir)
    os.makedirs(webpage_dir)

    if emscripten.check_exists(fips_dir) :
        project.gen(fips_dir, proj_dir, BuildConfig)
        project.build(fips_dir, proj_dir, BuildConfig)
    
    # export sample assets
    if ExportAssets :
        export_assets(fips_dir, proj_dir, webpage_dir)

    # deploy the webpage
    deploy_webpage(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN, 'Generated Samples web page under {}.'.format(webpage_dir))
Пример #26
0
def init(fips_dir, proj_name):
    """initialize an existing project directory as a fips directory by
    copying essential files and creating or updating .gitignore

    :param fips_dir:    absolute path to fips
    :param proj_name:   project directory name (dir must exist)
    :returns:           True if the project was successfully initialized
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_dir = util.get_project_dir(fips_dir, proj_name)
    if os.path.isdir(proj_dir):
        templ_values = {'project': proj_name}
        for f in ['CMakeLists.txt', 'fips', 'fips.cmd', 'fips.yml']:
            template.copy_template_file(fips_dir, proj_dir, f, templ_values)
        os.chmod(proj_dir + '/fips', 0o744)
        gitignore_entries = ['.fips-*', '*.pyc', '.vscode/', '.idea/']
        template.write_git_ignore(proj_dir, gitignore_entries)
    else:
        log.error("project dir '{}' does not exist".format(proj_dir))
        return False
Пример #27
0
def _rec_fetch_imports(fips_dir, proj_dir, handled) :
    """internal recursive function to fetch project imports,
    keeps an array of already handled dirs to break cyclic dependencies

    :param proj_dir:    current project directory
    :param handled:     array of already handled dirs
    :returns:           updated array of handled dirs
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in handled :
        handled.append(proj_name)

        imports = get_imports(fips_dir, proj_dir)
        for dep in imports:
            dep_proj_name = dep
            if dep not in handled:
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                log.colored(log.YELLOW, "=== dependency: '{}':".format(dep_proj_name))
                dep_ok = False
                if not os.path.isdir(dep_proj_dir) :
                    # directory did not exist, do a fresh git clone
                    git_url = imports[dep_proj_name]['git']
                    git_branch = imports[dep_proj_name]['branch']
                    if git.clone(git_url, git_branch, dep_proj_name, ws_dir) :
                        dep_ok = True
                    else :
                        log.error('failed to git clone {} into {}'.format(git_url, dep_proj_dir))
                else :
                    # directory already exists
                    log.info("dir '{}' exists".format(dep_proj_dir))
                    dep_ok = True

                # recuse
                if dep_ok :
                    handled = _rec_fetch_imports(fips_dir, dep_proj_dir, handled)

    # done, return the new handled array
    return handled
Пример #28
0
def build_deploy_webpage(fips_dir, proj_dir):
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/yakc-webpage/virtualkc'.format(ws_dir)
    if os.path.isdir(webpage_dir):
        shutil.rmtree(webpage_dir)
    os.makedirs(webpage_dir)

    # compile
    if emscripten.check_exists(fips_dir):
        project.gen(fips_dir, proj_dir, 'yakc-emsc-make-release')
        project.build(fips_dir, proj_dir, 'yakc-emsc-make-release')
        project.gen(fips_dir, proj_dir, 'yakc-wasm-make-release')
        project.build(fips_dir, proj_dir, 'yakc-wasm-make-release')

    # build the webpage via jekyll
    subprocess.call('jekyll build', cwd=proj_dir + '/web', shell=True)

    # deploy the webpage
    deploy_webpage(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN, 'Generated web page under {}.'.format(webpage_dir))
Пример #29
0
def init(fips_dir, proj_name) :
    """initialize an existing project directory as a fips directory by
    copying essential files and creating or updating .gitignore

    :param fips_dir:    absolute path to fips
    :param proj_name:   project directory name (dir must exist)
    :returns:           True if the project was successfully initialized
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_dir = util.get_project_dir(fips_dir, proj_name)
    if os.path.isdir(proj_dir) :
        templ_values = {
            'project': proj_name
        }
        for f in ['CMakeLists.txt', 'fips', 'fips.cmd', 'fips.yml'] :
            template.copy_template_file(fips_dir, proj_dir, f, templ_values)
        os.chmod(proj_dir + '/fips', 0o744)
        gitignore_entries = ['.fips-*', '*.pyc']
        template.write_git_ignore(proj_dir, gitignore_entries)
    else :
        log.error("project dir '{}' does not exist".format(proj_dir))
        return False
Пример #30
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir) :
    """builds the final webpage under under fips-deploy/voxel-test-webpage"""
    ws_dir = util.get_workspace_dir(fips_dir)

    # copy other required files
    for name in ['style.css', 'emsc.js', 'favicon.png'] :
        log.info('> copy file: {}'.format(name))
        shutil.copy(proj_dir + '/web/' + name, webpage_dir + '/' + name)

    # generate emscripten HTML page
    if emscripten.check_exists(fips_dir) :
        emsc_deploy_dir = '{}/fips-deploy/voxel-test/emsc-ninja-release'.format(ws_dir)
        name = 'VoxelTest'
        log.info('> generate emscripten HTML page: {}'.format(name))
        for ext in ['js', 'html.mem'] :
            src_path = '{}/{}.{}'.format(emsc_deploy_dir, name, ext)
            if os.path.isfile(src_path) :
                shutil.copy(src_path, webpage_dir)
        with open(proj_dir + '/web/emsc.html', 'r') as f :
            templ = Template(f.read())
        html = templ.safe_substitute(name=name)
        with open('{}/index.html'.format(webpage_dir), 'w') as f :
            f.write(html)
Пример #31
0
def clone(fips_dir, url) :
    """clone an existing fips project with git, do NOT fetch dependencies

    :param fips_dir:    absolute path to fips
    :param url:         git url to clone from (may contain branch name separated by '#')
    :return:            True if project was successfully cloned
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_url(url)
    proj_dir = util.get_project_dir(fips_dir, proj_name)
    if not os.path.isdir(proj_dir) :
        git_url = util.get_giturl_from_url(url)
        git_branch = util.get_gitbranch_from_url(url)
        if git.clone(git_url, git_branch, git.clone_depth, proj_name, ws_dir) :
            # fetch imports
            dep.fetch_imports(fips_dir, proj_dir)
            return True
        else :
            log.error("failed to 'git clone {}' into '{}'".format(url, proj_dir))
            return False
    else :
        log.error("project dir '{}' already exists".format(proj_dir))
        return False
Пример #32
0
def clone(fips_dir, url) :
    """clone an existing fips project with git, do NOT fetch dependencies

    :param fips_dir:    absolute path to fips
    :param url:         git url to clone from (may contain branch name separated by '#')
    :return:            True if project was successfully cloned
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_url(url)
    proj_dir = util.get_project_dir(fips_dir, proj_name)
    if not os.path.isdir(proj_dir) :
        git_url = util.get_giturl_from_url(url)
        git_branch = util.get_gitbranch_from_url(url)
        if git.clone(git_url, git_branch, proj_name, ws_dir) :
            # fetch imports
            dep.fetch_imports(fips_dir, proj_dir)
            return True
        else :
            log.error("failed to 'git clone {}' into '{}'".format(url, proj_dir))
            return False
    else :
        log.error("project dir '{}' already exists".format(proj_dir))
        return False
Пример #33
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir):
    """builds the final webpage under under fips-deploy/oryol-webpage"""
    ws_dir = util.get_workspace_dir(fips_dir)

    # load the websamples.yml file, should have been created during the last build
    with open(webpage_dir + '/websamples.yml', 'r') as f:
        samples = yaml.load(f.read())

    # build the thumbnail gallery
    content = ''
    for sample in samples:
        if sample['name'] != '__end__':
            name = sample['name']
            imgPath = sample['image']
            types = sample['type']
            desc = sample['desc']
            head, tail = os.path.split(imgPath)
            if tail == 'none':
                imgFileName = 'dummy.jpg'
            else:
                imgFileName = tail
            content += '<div class="thumb">\n'
            content += '  <div class="thumb-title">{}</div>\n'.format(name)
            content += '  <div class="img-frame"><a href="{}.html"><img class="image" src="{}" title="{}"></img></a></div>\n'.format(
                name, imgFileName, desc)
            content += '  <div class="thumb-bar">\n'
            content += '    <ul class="thumb-list">\n'
            if 'emscripten' in types:
                content += '      <li class="thumb-item"><a class="thumb-link" href="{}.html">emsc</a></li>\n'.format(
                    name)
            if 'pnacl' in types:
                content += '      <li class="thumb-item"><a class="thumb-link" href="{}_pnacl.html">pnacl</a></li>\n'.format(
                    name)
            if 'android' in types:
                content += '      <li class="thumb-item"><a class="thumb-link" href="{}-debug.apk">apk</a></li>\n'.format(
                    name)
            content += '    </ul>\n'
            content += '  </div>\n'
            content += '</div>\n'

    # populate the html template, and write to the build directory
    with open(proj_dir + '/web/index.html', 'r') as f:
        templ = Template(f.read())
    html = templ.safe_substitute(samples=content)
    with open(webpage_dir + '/index.html', 'w') as f:
        f.write(html)

    # copy other required files
    for name in [
            'style.css', 'dummy.jpg', 'emsc.js', 'pnacl.js', 'about.html',
            'favicon.png'
    ]:
        log.info('> copy file: {}'.format(name))
        shutil.copy(proj_dir + '/web/' + name, webpage_dir + '/' + name)

    # generate emscripten HTML pages
    if BuildEmscripten and emscripten.check_exists(fips_dir):
        emsc_deploy_dir = '{}/fips-deploy/oryol/emsc-make-release'.format(
            ws_dir)
        for sample in samples:
            name = sample['name']
            if name != '__end__' and 'emscripten' in sample['type']:
                log.info('> generate emscripten HTML page: {}'.format(name))
                for ext in ['js', 'html.mem']:
                    src_path = '{}/{}.{}'.format(emsc_deploy_dir, name, ext)
                    if os.path.isfile(src_path):
                        shutil.copy(src_path, webpage_dir)
                with open(proj_dir + '/web/emsc.html', 'r') as f:
                    templ = Template(f.read())
                src_url = GitHubSamplesURL + sample['src']
                html = templ.safe_substitute(name=name, source=src_url)
                with open('{}/{}.html'.format(webpage_dir, name), 'w') as f:
                    f.write(html)

    # copy PNaCl HTML pages
    if BuildPNaCl and nacl.check_exists(fips_dir):
        pnacl_deploy_dir = '{}/fips-deploy/oryol/pnacl-make-release'.format(
            ws_dir)
        for sample in samples:
            name = sample['name']
            if name != '__end__' and 'pnacl' in sample['type']:
                log.info('> generate PNaCl HTML page: {}'.format(name))
                for ext in ['nmf', 'pexe']:
                    shutil.copy('{}/{}.{}'.format(pnacl_deploy_dir, name, ext),
                                webpage_dir)
                with open(proj_dir + '/web/pnacl.html', 'r') as f:
                    templ = Template(f.read())
                src_url = GitHubSamplesURL + sample['src']
                html = templ.safe_substitute(name=name, source=src_url)
                with open('{}/{}_pnacl.html'.format(webpage_dir, name),
                          'w') as f:
                    f.write(html)

    # copy the screenshots
    for sample in samples:
        if sample['name'] != '__end__':
            img_path = sample['image']
            head, tail = os.path.split(img_path)
            if tail != 'none':
                log.info('> copy screenshot: {}'.format(tail))
                shutil.copy(img_path, webpage_dir + '/' + tail)

    # copy the Android sample files over
    if BuildAndroid and android.check_exists(fips_dir):
        android_deploy_dir = '{}/fips-deploy/oryol/android-make-release'.format(
            ws_dir)
        for sample in samples:
            if sample['name'] != '__end__' and 'android' in sample['type']:
                log.info('> copy android sample files: {}'.format(
                    sample['name']))
                shutil.copy(
                    '{}/{}-debug.apk'.format(android_deploy_dir,
                                             sample['name']), webpage_dir)
Пример #34
0
def build(fips_dir, proj_dir):
    # target directory will be 'fips-deploy/[proj]-markdeep
    proj_name = util.get_project_name_from_dir(proj_dir)
    out_dir = util.get_workspace_dir(
        fips_dir) + '/fips-deploy/' + proj_name + '-markdeep'
    log.info('building to: {}...'.format(out_dir))
    if os.path.isdir(out_dir):
        shutil.rmtree(out_dir)
    os.makedirs(out_dir)

    # check all .h files for embedded documentation
    hdrs = []
    for root, dirnames, filenames in os.walk(proj_dir):
        for filename in fnmatch.filter(filenames, '*.h'):
            hdrs.append(os.path.join(root, filename).replace('\\', '/'))
    markdeep_files = []
    capture_begin = re.compile(r'/\*#\s')
    for hdr in hdrs:
        log.info('  parsing {}'.format(hdr))
        capturing = False
        markdeep_lines = []
        with open(hdr, 'r') as src:
            lines = src.readlines()
            for line in lines:
                if "#*/" in line and capturing:
                    capturing = False
                if capturing:
                    # remove trailing tab
                    if line.startswith('    '):
                        line = line[4:]
                    elif line.startswith('\t'):
                        line = line[1:]
                    markdeep_lines.append(line)
                if capture_begin.match(line) and not capturing:
                    capturing = True
        if markdeep_lines:
            markdeep_files.append(hdr)
            dst_path = out_dir + '/' + os.path.relpath(hdr, proj_dir) + '.html'
            log.info(
                '    markdeep block(s) found, writing: {}'.format(dst_path))
            dst_dir = os.path.dirname(dst_path)
            if not os.path.isdir(dst_dir):
                os.makedirs(dst_dir)
            with open(dst_path, 'w') as dst:
                dst.write(
                    "<meta charset='utf-8' emacsmode='-*- markdown -*-'>\n")
                dst.write(
                    "<link rel='stylesheet' href='https://casual-effects.com/markdeep/latest/apidoc.css?'>\n"
                )
                for line in markdeep_lines:
                    dst.write(line)
                dst.write(
                    "<script>markdeepOptions={tocStyle:'medium'};</script>")
                dst.write(
                    "<!-- Markdeep: --><script src='https://casual-effects.com/markdeep/latest/markdeep.min.js?'></script>"
                )

    # write a toplevel index.html
    if markdeep_files:
        markdeep_files = sorted(markdeep_files)
        dst_path = out_dir + '/index.html'
        log.info('writing toc file: {}'.format(dst_path))
        with open(dst_path, 'w') as dst:
            dst.write("<meta charset='utf-8' emacsmode='-*- markdown -*-'>\n")
            dst.write(
                "<link rel='stylesheet' href='https://casual-effects.com/markdeep/latest/apidoc.css?'>\n"
            )
            dst.write('# {}\n'.format(proj_name))
            for hdr in markdeep_files:
                rel_path = os.path.relpath(hdr, proj_dir)
                dst.write('- [{}]({})\n'.format(rel_path, rel_path + '.html'))
            dst.write("<script>markdeepOptions={tocStyle:'medium'};</script>")
            dst.write(
                "<!-- Markdeep: --><script src='https://casual-effects.com/markdeep/latest/markdeep.min.js?'></script>"
            )
    else:
        log.error("no headers with embedded markdeep found in '{}'!".format(
            proj_dir))
Пример #35
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir) :
    """builds the final webpage under under fips-deploy/oryol-samples-webpage"""
    ws_dir = util.get_workspace_dir(fips_dir)

    # load the websamples.yml file, should have been created during the last build
    with open(webpage_dir + '/websamples.yml', 'r') as f :
        samples = yaml.load(f.read())

    # create directories
    for platform in ['wasm'] :
        platform_dir = '{}/{}'.format(webpage_dir, platform)
        if not os.path.isdir(platform_dir) :
            os.makedirs(platform_dir)

    # link to the Core Samples
    content  = '<div class="thumb">\n'
    content += '  <div class="thumb-title">To Core Samples...</div>\n'
    content += '  <div class="img-frame"><a href="http://floooh.github.com/oryol/index.html"><img class="image" src="core_samples.jpg"></img></a></div>\n'
    content += '</div>\n'

    # build the thumbnail gallery
    for sample in samples :
        if sample['name'] != '__end__' :
            name    = sample['name']
            imgPath = sample['image']
            types   = sample['type'] 
            desc    = sample['desc']
            head, tail = os.path.split(imgPath)
            if tail == 'none' :
                imgFileName = 'dummy.jpg'
            else :
                imgFileName = tail
            content += '<div class="thumb">\n'
            content += '  <div class="thumb-title">{}</div>\n'.format(name)
            content += '  <div class="img-frame"><a href="wasm/{}.html"><img class="image" src="{}" title="{}"></img></a></div>\n'.format(name,imgFileName,desc)
            content += '</div>\n'

    # populate the html template, and write to the build directory
    with open(proj_dir + '/web/index.html', 'r') as f :
        templ = Template(f.read())
    html = templ.safe_substitute(samples=content)
    with open(webpage_dir + '/index.html', 'w') as f :
        f.write(html)

    # copy other required files
    for name in ['style.css', 'dummy.jpg', 'emsc.js', 'favicon.png', 'core_samples.jpg'] :
        log.info('> copy file: {}'.format(name))
        shutil.copy(proj_dir + '/web/' + name, webpage_dir + '/' + name)

    # generate WebAssembly HTML pages
    if emscripten.check_exists(fips_dir) :
        wasm_deploy_dir = '{}/fips-deploy/oryol-samples/{}'.format(ws_dir, BuildConfig)
        for sample in samples :
            name = sample['name']
            if name != '__end__' and 'emscripten' in sample['type'] :
                log.info('> generate wasm HTML page: {}'.format(name))
                for ext in ['js', 'wasm'] :
                    src_path = '{}/{}.{}'.format(wasm_deploy_dir, name, ext)
                    if os.path.isfile(src_path) :
                        shutil.copy(src_path, '{}/wasm/'.format(webpage_dir))
                with open(proj_dir + '/web/wasm.html', 'r') as f :
                    templ = Template(f.read())
                src_url = GitHubSamplesURL + sample['src'];
                html = templ.safe_substitute(name=name, source=src_url)
                with open('{}/wasm/{}.html'.format(webpage_dir, name), 'w') as f :
                    f.write(html)

    # copy the screenshots
    for sample in samples :
        if sample['name'] != '__end__' :
            img_path = sample['image']
            head, tail = os.path.split(img_path)
            if tail != 'none' :
                log.info('> copy screenshot: {}'.format(tail))
                shutil.copy(img_path, webpage_dir + '/' + tail)
Пример #36
0
def get_sdk_dir(fips_dir) :
    return util.get_workspace_dir(fips_dir) + '/fips-sdks/' + util.get_host_platform()
Пример #37
0
def get_sdk_dir(fips_dir) :
    """return the platform-specific SDK dir"""
    return util.get_workspace_dir(fips_dir) + '/fips-sdks/' + util.get_host_platform()
Пример #38
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir):
    """builds the final webpage under under fips-deploy/chips-webpage"""
    ws_dir = util.get_workspace_dir(fips_dir)

    # build the thumbnail gallery
    content = ''
    for item in items:
        title = item['title']
        system = item['system']
        url = item['url']
        image = item['img']
        note = item['note']
        log.info('> adding thumbnail for {}'.format(url))
        content += '<div class="thumb">\n'
        content += '  <div class="thumb-title">{}</div>\n'.format(title)
        content += '  <div class="img-frame"><a href="{}"><img class="image" src="{}"></img></a></div>\n'.format(
            url, image)
        content += '  <div class="thumb-bar">{}</div>\n'.format(note)
        content += '</div>\n'

    # populate the html template, and write to the build directory
    with open(proj_dir + '/webpage/index.html', 'r') as f:
        templ = Template(f.read())
    html = templ.safe_substitute(samples=content)
    with open(webpage_dir + '/index.html', 'w') as f:
        f.write(html)

    # and the same with the CSS template
    with open(proj_dir + '/webpage/style.css', 'r') as f:
        templ = Template(f.read())
    css = templ.safe_substitute()
    with open(webpage_dir + '/style.css', 'w') as f:
        f.write(css)

    # copy other required files
    for name in ['emsc.js', 'favicon.png', 'help.html']:
        log.info('> copy file: {}'.format(name))
        shutil.copy(proj_dir + '/webpage/' + name, webpage_dir + '/' + name)

    # generate emu HTML pages
    emsc_deploy_dir = '{}/fips-deploy/chips-test/{}'.format(
        ws_dir, BuildConfig)
    for item in items:
        if item['type'] != 'emu':
            continue
        name = os.path.splitext(item['url'])[0]
        title = item['title']
        log.info('> generate emscripten HTML page: {}'.format(name))
        for ext in ['wasm', 'js']:
            src_path = '{}/{}.{}'.format(emsc_deploy_dir, name, ext)
            if os.path.isfile(src_path):
                shutil.copy(src_path, '{}/'.format(webpage_dir))
        with open(proj_dir + '/webpage/emsc.html', 'r') as f:
            templ = Template(f.read())
        src_url = GitHubSamplesURL + name
        html = templ.safe_substitute(name=title, prog=name, source=src_url)
        with open('{}/{}.html'.format(webpage_dir, name), 'w') as f:
            f.write(html)

    # copy data files and images
    for system in systems:
        src_dir = proj_dir + '/webpage/' + system
        if os.path.exists(src_dir):
            dst_dir = webpage_dir + '/' + system
            if os.path.isdir(dst_dir):
                shutil.rmtree(dst_dir)
            shutil.copytree(src_dir, dst_dir)
Пример #39
0
def get_sdk_dir(fips_dir) :
    return util.get_workspace_dir(fips_dir) + '/fips-sdks/android'
Пример #40
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir) :
    """builds the final webpage under under fips-deploy/oryol-webpage"""
    ws_dir = util.get_workspace_dir(fips_dir)

    # load the websamples.yml file, should have been created during the last build
    with open(webpage_dir + '/websamples.yml', 'r') as f :
        samples = yaml.load(f.read())

    # create directories
    for platform in ['asmjs', 'wasm', 'pnacl'] :
        platform_dir = '{}/{}'.format(webpage_dir, platform)
        if not os.path.isdir(platform_dir) :
            os.makedirs(platform_dir)

    # build the thumbnail gallery
    content = ''
    for sample in samples :
        if sample['name'] != '__end__' :
            name    = sample['name']
            imgPath = sample['image']
            types   = sample['type'] 
            desc    = sample['desc']
            head, tail = os.path.split(imgPath)
            if tail == 'none' :
                imgFileName = 'dummy.jpg'
            else :
                imgFileName = tail
            content += '<div class="thumb">\n'
            content += '  <div class="thumb-title">{}</div>\n'.format(name)
            content += '  <div class="img-frame"><a href="asmjs/{}.html"><img class="image" src="{}" title="{}"></img></a></div>\n'.format(name,imgFileName,desc)
            content += '  <div class="thumb-bar">\n'
            content += '    <ul class="thumb-list">\n'
            if 'emscripten' in types :
                content += '      <li class="thumb-item"><a class="thumb-link" href="asmjs/{}.html">asm.js</a></li>\n'.format(name)
            if 'pnacl' in types :
                content += '      <li class="thumb-item"><a class="thumb-link" href="pnacl/{}.html">pnacl</a></li>\n'.format(name)
            if 'emscripten' in types :
                content += '      <li class="thumb-item"><a class="thumb-link" href="wasm/{}.html">wasm</a></li>\n'.format(name)
            content += '    </ul>\n'
            content += '  </div>\n'
            content += '</div>\n'

    # populate the html template, and write to the build directory
    with open(proj_dir + '/web/index.html', 'r') as f :
        templ = Template(f.read())
    html = templ.safe_substitute(samples=content)
    with open(webpage_dir + '/index.html', 'w') as f :
        f.write(html)

    # copy other required files
    for name in ['style.css', 'dummy.jpg', 'emsc.js', 'pnacl.js', 'wasm.js', 'about.html', 'favicon.png'] :
        log.info('> copy file: {}'.format(name))
        shutil.copy(proj_dir + '/web/' + name, webpage_dir + '/' + name)

    # generate emscripten HTML pages
    if BuildEmscripten and emscripten.check_exists(fips_dir) :
        emsc_deploy_dir = '{}/fips-deploy/oryol/emsc-ninja-release'.format(ws_dir)
        for sample in samples :
            name = sample['name']
            if name != '__end__' and 'emscripten' in sample['type'] :
                log.info('> generate emscripten HTML page: {}'.format(name))
                for ext in ['js', 'html.mem'] :
                    src_path = '{}/{}.{}'.format(emsc_deploy_dir, name, ext)
                    if os.path.isfile(src_path) :
                        shutil.copy(src_path, '{}/asmjs/'.format(webpage_dir))
                with open(proj_dir + '/web/emsc.html', 'r') as f :
                    templ = Template(f.read())
                src_url = GitHubSamplesURL + sample['src'];
                html = templ.safe_substitute(name=name, source=src_url)
                with open('{}/asmjs/{}.html'.format(webpage_dir, name, name), 'w') as f :
                    f.write(html)

    # generate WebAssembly HTML pages
    if BuildWasm and emscripten.check_exists(fips_dir) :
        wasm_deploy_dir = '{}/fips-deploy/oryol/wasm-ninja-release'.format(ws_dir)
        for sample in samples :
            name = sample['name']
            if name != '__end__' and 'emscripten' in sample['type'] :
                log.info('> generate wasm HTML page: {}'.format(name))
                for ext in ['js', 'wasm.mappedGlobals'] :
                    src_path = '{}/{}.{}'.format(wasm_deploy_dir, name, ext)
                    if os.path.isfile(src_path) :
                        shutil.copy(src_path, '{}/wasm/'.format(webpage_dir))
                for ext in ['html.mem', 'wasm'] :
                    src_path = '{}/{}.{}'.format(wasm_deploy_dir, name, ext)
                    if os.path.isfile(src_path) :
                        shutil.copy(src_path, '{}/wasm/{}.{}.txt'.format(webpage_dir, name, ext))
                with open(proj_dir + '/web/wasm.html', 'r') as f :
                    templ = Template(f.read())
                src_url = GitHubSamplesURL + sample['src'];
                html = templ.safe_substitute(name=name, source=src_url)
                with open('{}/wasm/{}.html'.format(webpage_dir, name), 'w') as f :
                    f.write(html)

    # generate PNaCl HTML pages
    if BuildPNaCl and nacl.check_exists(fips_dir) :
        pnacl_deploy_dir = '{}/fips-deploy/oryol/pnacl-ninja-release'.format(ws_dir)
        for sample in samples :
            name = sample['name']
            if name != '__end__' and 'pnacl' in sample['type'] :
                log.info('> generate PNaCl HTML page: {}'.format(name))
                for ext in ['nmf', 'pexe'] :
                    src_path = '{}/{}.{}'.format(pnacl_deploy_dir, name, ext)
                    if os.path.isfile(src_path) :
                        shutil.copy(src_path, '{}/pnacl/'.format(webpage_dir))
                with open(proj_dir + '/web/pnacl.html', 'r') as f :
                    templ = Template(f.read())
                src_url = GitHubSamplesURL + sample['src'];
                html = templ.safe_substitute(name=name, source=src_url)
                with open('{}/pnacl/{}.html'.format(webpage_dir, name), 'w') as f :
                    f.write(html)

    # copy the screenshots
    for sample in samples :
        if sample['name'] != '__end__' :
            img_path = sample['image']
            head, tail = os.path.split(img_path)
            if tail != 'none' :
                log.info('> copy screenshot: {}'.format(tail))
                shutil.copy(img_path, webpage_dir + '/' + tail)
Пример #41
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir):
    """builds the final webpage under under fips-deploy/oryol-webpage"""
    ws_dir = util.get_workspace_dir(fips_dir)

    # load the websamples.yml file, should have been created during the last build
    with open(webpage_dir + "/websamples.yml", "r") as f:
        samples = yaml.load(f.read())

    # build the thumbnail gallery
    content = ""
    for sample in samples:
        if sample["name"] != "__end__":
            name = sample["name"]
            imgPath = sample["image"]
            types = sample["type"]
            desc = sample["desc"]
            head, tail = os.path.split(imgPath)
            if tail == "none":
                imgFileName = "dummy.jpg"
            else:
                imgFileName = tail
            content += '<div class="thumb">\n'
            content += '  <div class="thumb-title">{}</div>\n'.format(name)
            content += '  <div class="img-frame"><a href="{}.html"><img class="image" src="{}" title="{}"></img></a></div>\n'.format(
                name, imgFileName, desc
            )
            content += '  <div class="thumb-bar">\n'
            content += '    <ul class="thumb-list">\n'
            if "emscripten" in types:
                content += '      <li class="thumb-item"><a class="thumb-link" href="{}.html">emsc</a></li>\n'.format(
                    name
                )
            if "pnacl" in types:
                content += '      <li class="thumb-item"><a class="thumb-link" href="{}_pnacl.html">pnacl</a></li>\n'.format(
                    name
                )
            if "android" in types:
                content += '      <li class="thumb-item"><a class="thumb-link" href="{}-debug.apk">apk</a></li>\n'.format(
                    name
                )
            content += "    </ul>\n"
            content += "  </div>\n"
            content += "</div>\n"

    # populate the html template, and write to the build directory
    with open(proj_dir + "/web/index.html", "r") as f:
        templ = Template(f.read())
    html = templ.safe_substitute(samples=content)
    with open(webpage_dir + "/index.html", "w") as f:
        f.write(html)

    # copy other required files
    for name in ["style.css", "dummy.jpg", "emsc.js", "pnacl.js", "about.html", "favicon.png"]:
        log.info("> copy file: {}".format(name))
        shutil.copy(proj_dir + "/web/" + name, webpage_dir + "/" + name)

    # generate emscripten HTML pages
    if BuildEmscripten and emscripten.check_exists(fips_dir):
        emsc_deploy_dir = "{}/fips-deploy/oryol/emsc-ninja-release".format(ws_dir)
        for sample in samples:
            name = sample["name"]
            if name != "__end__" and "emscripten" in sample["type"]:
                log.info("> generate emscripten HTML page: {}".format(name))
                for ext in ["js", "html.mem"]:
                    src_path = "{}/{}.{}".format(emsc_deploy_dir, name, ext)
                    if os.path.isfile(src_path):
                        shutil.copy(src_path, webpage_dir)
                with open(proj_dir + "/web/emsc.html", "r") as f:
                    templ = Template(f.read())
                src_url = GitHubSamplesURL + sample["src"]
                html = templ.safe_substitute(name=name, source=src_url)
                with open("{}/{}.html".format(webpage_dir, name), "w") as f:
                    f.write(html)

    # copy PNaCl HTML pages
    if BuildPNaCl and nacl.check_exists(fips_dir):
        pnacl_deploy_dir = "{}/fips-deploy/oryol/pnacl-ninja-release".format(ws_dir)
        for sample in samples:
            name = sample["name"]
            if name != "__end__" and "pnacl" in sample["type"]:
                log.info("> generate PNaCl HTML page: {}".format(name))
                for ext in ["nmf", "pexe"]:
                    shutil.copy("{}/{}.{}".format(pnacl_deploy_dir, name, ext), webpage_dir)
                with open(proj_dir + "/web/pnacl.html", "r") as f:
                    templ = Template(f.read())
                src_url = GitHubSamplesURL + sample["src"]
                html = templ.safe_substitute(name=name, source=src_url)
                with open("{}/{}_pnacl.html".format(webpage_dir, name), "w") as f:
                    f.write(html)

    # copy the screenshots
    for sample in samples:
        if sample["name"] != "__end__":
            img_path = sample["image"]
            head, tail = os.path.split(img_path)
            if tail != "none":
                log.info("> copy screenshot: {}".format(tail))
                shutil.copy(img_path, webpage_dir + "/" + tail)

    # copy the Android sample files over
    if BuildAndroid and android.check_exists(fips_dir):
        android_deploy_dir = "{}/fips-deploy/oryol/android-ninja-release".format(ws_dir)
        for sample in samples:
            if sample["name"] != "__end__" and "android" in sample["type"]:
                log.info("> copy android sample files: {}".format(sample["name"]))
                shutil.copy("{}/{}-debug.apk".format(android_deploy_dir, sample["name"]), webpage_dir)
Пример #42
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir) :
    """builds the final webpage under under fips-deploy/sokol-webpage"""
    ws_dir = util.get_workspace_dir(fips_dir)
    wasm_deploy_dir = '{}/fips-deploy/sokol-samples/{}'.format(ws_dir, BuildConfig)

    # create directories
    for platform in ['wasm'] :
        platform_dir = '{}/{}'.format(webpage_dir, platform)
        if not os.path.isdir(platform_dir) :
            os.makedirs(platform_dir)

    # build the thumbnail gallery
    content = ''
    for sample in samples :
        name = sample[0]
        log.info('> adding thumbnail for {}'.format(name))
        url = "wasm/{}-sapp.html".format(name)
        ui_url = "wasm/{}-sapp-ui.html".format(name)
        img_name = name + '.jpg'
        img_path = proj_dir + '/webpage/' + img_name
        if not os.path.exists(img_path):
            img_name = 'dummy.jpg'
            img_path = proj_dir + 'webpage/dummy.jpg'
        content += '<div class="thumb">\n'
        content += '  <div class="thumb-title">{}</div>\n'.format(name)
        if os.path.exists(wasm_deploy_dir + '/' + name + '-sapp-ui.js'):
            content += '<a class="img-btn-link" href="{}"><div class="img-btn">UI</div></a>'.format(ui_url)
        content += '  <div class="img-frame"><a href="{}"><img class="image" src="{}"></img></a></div>\n'.format(url,img_name)
        content += '</div>\n'

    # populate the html template, and write to the build directory
    with open(proj_dir + '/webpage/index.html', 'r') as f :
        templ = Template(f.read())
    html = templ.safe_substitute(samples=content)
    with open(webpage_dir + '/index.html', 'w') as f :
        f.write(html)

    # copy other required files
    for name in ['dummy.jpg', 'favicon.png'] :
        log.info('> copy file: {}'.format(name))
        shutil.copy(proj_dir + '/webpage/' + name, webpage_dir + '/' + name)

    # generate WebAssembly HTML pages
    if emscripten.check_exists(fips_dir) :
        for sample in samples :
            name = sample[0]
            source = sample[1]
            log.info('> generate wasm HTML page: {}'.format(name))
            for postfix in ['sapp', 'sapp-ui']:
                for ext in ['wasm', 'js'] :
                    src_path = '{}/{}-{}.{}'.format(wasm_deploy_dir, name, postfix, ext)
                    if os.path.isfile(src_path) :
                        shutil.copy(src_path, '{}/wasm/'.format(webpage_dir))
                    with open(proj_dir + '/webpage/wasm.html', 'r') as f :
                        templ = Template(f.read())
                    src_url = GitHubSamplesURL + source
                    html = templ.safe_substitute(name=name, prog=name+'-'+postfix, source=src_url)
                    with open('{}/wasm/{}-{}.html'.format(webpage_dir, name, postfix), 'w') as f :
                        f.write(html)

    # copy the screenshots
    for sample in samples :
        img_name = sample[0] + '.jpg'
        img_path = proj_dir + '/webpage/' + img_name
        if os.path.exists(img_path):
            log.info('> copy screenshot: {}'.format(img_name))
            shutil.copy(img_path, webpage_dir + '/' + img_name)
Пример #43
0
def get_sdk_dir(fips_dir) :
    """return the platform-specific SDK dir"""
    return util.get_workspace_dir(fips_dir) + '/fips-sdks/' + util.get_host_platform()
Пример #44
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir):
    """builds the final webpage under under fips-deploy/learnopengl-examples"""
    ws_dir = util.get_workspace_dir(fips_dir)
    wasm_deploy_dir = '{}/fips-deploy/learnopengl-examples/{}'.format(
        ws_dir, BuildConfig)

    # create directories
    if not os.path.exists(webpage_dir):
        os.makedirs(webpage_dir)

    # build the thumbnail gallery
    content = ''
    for chapter in items:
        chapter_title = chapter[0]
        lessons = chapter[1]
        content += '<h2>{}</i></h2>\n'.format(chapter_title)
        for lesson in lessons:
            lesson_title = lesson[0]
            lesson_link = lesson[1]
            examples = lesson[3]
            content += '<article>\n'
            content += '<section class="header"><h3><a href="{}">{} <i class="icon-link-ext"></i></a></h3></section>\n'.format(
                lesson_link, lesson_title)
            content += '<section class="group examples">\n'
            for example in examples:
                name = example[0]
                filename = example[1]
                log.info('> adding thumbnail for {}'.format(filename))
                url = "{}.html".format(filename)
                img_name = filename + '.jpg'
                img_path = proj_dir + '/webpage/' + img_name
                if not os.path.exists(img_path):
                    img_name = 'dummy.jpg'
                    img_path = proj_dir + 'webpage/dummy.jpg'
                content += '<figure class="col-15">\n'
                content += '<figcaption><h4>{}</h4></figcaption>\n'.format(
                    name)
                content += '<div><img class="responsive" src="{}" alt=""></div>\n'.format(
                    img_name)
                content += '<a href="{}">Read More</a>\n'.format(url)
                content += '</figure>\n'
            content += '</section>\n'
            content += '</article>\n'
        content += '<hr>\n'

    # populate the html template, and write to the build directory
    with open(proj_dir + '/webpage/index.html', 'r') as f:
        templ = Template(f.read())
    html = templ.safe_substitute(
        samples=content, date=datetime.date.today().strftime("%B %d %Y"))
    with open(webpage_dir + '/index.html', 'w') as f:
        f.write(html)

    # copy other required files
    for name in [
            'dummy.jpg', 'favicon.png', 'fontello.woff', 'fontello.woff2'
    ]:
        log.info('> copy file: {}'.format(name))
        shutil.copy(proj_dir + '/webpage/' + name, webpage_dir + '/' + name)

    # generate WebAssembly HTML pages
    if emscripten.check_exists(fips_dir):
        for chapter in items:
            lessons = chapter[1]
            for lesson in lessons:
                dir = lesson[2]
                examples = lesson[3]
                for example in examples:
                    filename = example[1]
                    source = example[2]
                    glsl = example[3]
                    log.info('> generate wasm HTML page: {}'.format(filename))
                    for ext in ['wasm', 'js']:
                        src_path = '{}/{}.{}'.format(wasm_deploy_dir, filename,
                                                     ext)
                        if os.path.isfile(src_path):
                            shutil.copy(src_path, '{}/'.format(webpage_dir))
                        with open(proj_dir + '/webpage/wasm.html', 'r') as f:
                            templ = Template(f.read())
                        src_url = '{}/{}/{}'.format(GitHubExamplesURL, dir,
                                                    source)
                        if glsl is None:
                            glsl_url = "."
                            glsl_hidden = "hidden"
                        else:
                            glsl_url = '{}/{}/{}'.format(
                                GitHubExamplesURL, dir, glsl)
                            glsl_hidden = ""
                        html = templ.safe_substitute(name=filename,
                                                     prog=filename,
                                                     source=src_url,
                                                     glsl=glsl_url,
                                                     hidden=glsl_hidden)
                        with open('{}/{}.html'.format(webpage_dir, filename),
                                  'w') as f:
                            f.write(html)

    # copy assets from deploy directory
    for asset in assets:
        log.info('> copy asset file: {}'.format(asset))
        src_path = '{}/{}'.format(wasm_deploy_dir, asset)
        if os.path.isfile(src_path):
            shutil.copy(src_path, webpage_dir)

    # copy the screenshots
    for chapter in items:
        lessons = chapter[1]
        for lesson in lessons:
            examples = lesson[3]
            for example in examples:
                img_name = example[1] + '.jpg'
                img_path = proj_dir + '/webpage/' + img_name
                if os.path.exists(img_path):
                    log.info('> copy screenshot: {}'.format(img_name))
                    shutil.copy(img_path, webpage_dir + '/' + img_name)
Пример #45
0
def gather_imports(fips_dir, proj_dir) :
    """resolve imports of proj_dir and returns a big dictionary
    with all imported data, which can then be written with write_imports()

    :param fips_dir:    absolute fips directory
    :param proj_dir:    absolute project directory
    :param dry_run:     if true perform a dry run (used by 'fips diag')
    :returns:           a big dictionary which can be written with write_imports()
                        or None on error
    """
    imported = OrderedDict()
    ws_dir = util.get_workspace_dir(fips_dir)
    success, deps = get_all_imports_exports(fips_dir, proj_dir)

    unique_defines = {}
    unique_modules = {}
    
    if success :
        
        # for each project:
        for proj_name in deps :

            imports = deps[proj_name]['imports']
            exports = deps[proj_name]['exports']
            # for each imported project:
            for imp_proj_name in imports :
                
                imported[imp_proj_name] = {}
                imported[imp_proj_name]['modules'] = OrderedDict()
                imported[imp_proj_name]['hdrdirs'] = []
                imported[imp_proj_name]['libdirs'] = []
                imported[imp_proj_name]['defines'] = {}

                # add header search paths
                for imp_hdr in deps[imp_proj_name]['exports']['header-dirs'] :
                    hdr_path = '{}/{}/{}'.format(ws_dir, imp_proj_name, imp_hdr)
                    if not os.path.isdir(hdr_path) :
                        log.warn("header search path '{}' not found in project '{}'".format(hdr_path, imp_proj_name))
                    imported[imp_proj_name]['hdrdirs'].append(hdr_path)

                # add lib search paths
                for imp_lib in deps[imp_proj_name]['exports']['lib-dirs'] :
                    lib_path = '{}/{}/{}'.format(ws_dir, imp_proj_name, imp_lib)
                    if not os.path.isdir(lib_path) :
                        log.warn("lib search path '{}' not found in project '{}'".format(lib_path, imp_proj_name))
                    imported[imp_proj_name]['libdirs'].append(lib_path)

                # add defines
                for imp_def in deps[imp_proj_name]['exports']['defines'] :
                    # hmm, no check whether this define collides with an earlier define...
                    value = deps[imp_proj_name]['exports']['defines'][imp_def]
                    imported[imp_proj_name]['defines'][imp_def] = value
                    if imp_def in unique_defines :
                        if unique_defines[imp_def] != value :
                            log.warn("C define collision: '{}={}' in '{}' collides with '{}={}' in earlier import".format(
                                imp_def, value, imp_proj_name, imp_def, unique_defines[define]))
                        unique_defines[imp_def] = value

                # for each imported module:
                for imp_mod in deps[imp_proj_name]['exports']['modules'] :
                    imp_mod_src = deps[imp_proj_name]['exports']['modules'][imp_mod]
                    # import module source directory (where module's CMakeLists.txt is)
                    src_dir = '{}/{}/{}'.format(ws_dir, imp_proj_name, imp_mod_src)
                    # cmake build subdirectory
                    build_dir = '{}_{}'.format(imp_proj_name, imp_mod)
                    imported[imp_proj_name]['modules'][src_dir] = build_dir
                    if imp_mod in unique_modules :
                        if unique_modules[imp_mod] != src_dir :
                            log.warn("Import module '{}=>{}' in '{}' collides with '{}=>{}' in earlier import".format(
                                imp_mod, src_dir, imp_proj_name, imp_mod, unique_modules[imp_mod]))
                        unique_modules[imp_mod] = src_dir

        # NOTE: return the imports in reversed order, so that for instance header paths
        # are defined before the modules that need the header paths
        reverseImported = OrderedDict()
        for entry in reversed(imported) :
            reverseImported[entry] = imported[entry]
        return reverseImported

    else :
        log.warn("imports are incomplete, please run 'fips fetch'")
        return None
Пример #46
0
def gather_imports(fips_dir, proj_dir) :
    """resolve imports of proj_dir and returns a big dictionary
    with all imported data, which can then be written with write_imports()

    :param fips_dir:    absolute fips directory
    :param proj_dir:    absolute project directory
    :param dry_run:     if true perform a dry run (used by 'fips diag')
    :returns:           a big dictionary which can be written with write_imports()
                        or None on error
    """
    imported = OrderedDict()
    ws_dir = util.get_workspace_dir(fips_dir)
    success, deps = get_all_imports_exports(fips_dir, proj_dir)

    unique_defines = {}
    unique_modules = {}
    
    if success :
        
        # for each project:
        for proj_name in deps :

            imports = deps[proj_name]['imports']
            exports = deps[proj_name]['exports']
            # for each imported project:
            for imp_proj_name in sorted(imports) :
                
                imported[imp_proj_name] = {}
                imported[imp_proj_name]['modules'] = OrderedDict()
                imported[imp_proj_name]['hdrdirs'] = []
                imported[imp_proj_name]['condhdrdirs'] = {}
                imported[imp_proj_name]['libdirs'] = []
                imported[imp_proj_name]['defines'] = {}
                imported[imp_proj_name]['cond'] = imports[imp_proj_name]['cond']
                imported[imp_proj_name]['group'] = imports[imp_proj_name]['group']

                # add header search paths
                for imp_hdr in deps[imp_proj_name]['exports']['header-dirs'] :
                    hdr_path = '{}/{}/{}'.format(ws_dir, imp_proj_name, imp_hdr)
                    hdr_path = os.path.normpath(hdr_path).replace('\\', '/')
                    if not os.path.isdir(hdr_path) :
                        log.warn("header search path '{}' not found in project '{}'".format(hdr_path, imp_proj_name))
                    imported[imp_proj_name]['hdrdirs'].append(hdr_path)

                # add conditional header search paths
                for imp_hdr in deps[imp_proj_name]['exports']['conditional-header-dirs'] :
                    if not 'path' in imp_hdr :
                        log.warn("no 'path' key in conditional-header-dirs in project {}".format(imp_proj_name))
                    elif not 'cond' in imp_hdr :
                        log.warn("no 'cond' key in conditional-header-dirs in project {}".format(imp_proj_name))
                    else :
                        hdr_path = '{}/{}/{}'.format(ws_dir, imp_proj_name, imp_hdr['path'])
                        hdr_path = os.path.normpath(hdr_path).replace('\\', '/')
                        if not os.path.isdir(hdr_path) :
                            log.warn("conditional header search path '{}' not found in project '{}'".format(hdr_path, imp_proj_name))
                        value = imp_hdr['cond']
                        imported[imp_proj_name]['condhdrdirs'][hdr_path] = value

                # add lib search paths
                for imp_lib in deps[imp_proj_name]['exports']['lib-dirs'] :
                    lib_path = '{}/{}/{}'.format(ws_dir, imp_proj_name, imp_lib)
                    lib_path = os.path.normpath(lib_path).replace('\\', '/')
                    if not os.path.isdir(lib_path) :
                        log.warn("lib search path '{}' not found in project '{}'".format(lib_path, imp_proj_name))
                    imported[imp_proj_name]['libdirs'].append(lib_path)

                # add defines
                for imp_def in deps[imp_proj_name]['exports']['defines'] :
                    # hmm, no check whether this define collides with an earlier define...
                    value = deps[imp_proj_name]['exports']['defines'][imp_def]
                    imported[imp_proj_name]['defines'][imp_def] = value
                    if imp_def in unique_defines :
                        if unique_defines[imp_def] != value :
                            log.warn("C define collision: '{}={}' in '{}' collides with '{}={}' in earlier import".format(
                                imp_def, value, imp_proj_name, imp_def, unique_defines[define]))
                        unique_defines[imp_def] = value

                # for each imported module:
                for imp_mod in deps[imp_proj_name]['exports']['modules'] :
                    imp_mod_src = deps[imp_proj_name]['exports']['modules'][imp_mod]
                    # import module source directory (where module's CMakeLists.txt is)
                    src_dir = '{}/{}/{}'.format(ws_dir, imp_proj_name, imp_mod_src)
                    # cmake build subdirectory
                    build_dir = '{}_{}'.format(imp_proj_name, imp_mod)
                    imported[imp_proj_name]['modules'][src_dir] = build_dir
                    if imp_mod in unique_modules :
                        if unique_modules[imp_mod] != src_dir :
                            log.warn("Import module '{}=>{}' in '{}' collides with '{}=>{}' in earlier import".format(
                                imp_mod, src_dir, imp_proj_name, imp_mod, unique_modules[imp_mod]))
                        unique_modules[imp_mod] = src_dir
        return imported

    else :
        log.warn("imports are incomplete, please run 'fips fetch'")
        return None
Пример #47
0
def get_sdkroot_dir(fips_dir):
    return util.get_workspace_dir(fips_dir) + '/fips-sdks'
Пример #48
0
def get_sdk_dir(fips_dir):
    return util.get_workspace_dir(fips_dir) + '/fips-sdks/wasisdk'
Пример #49
0
def build(fips_dir, proj_dir):
    # target directory will be 'fips-deploy/[proj]-markdeep
    proj_name = util.get_project_name_from_dir(proj_dir)
    out_dir = util.get_workspace_dir(fips_dir)+'/fips-deploy/'+proj_name+'-markdeep'
    log.info('building to: {}...'.format(out_dir))
    if os.path.isdir(out_dir):
        shutil.rmtree(out_dir)
    os.makedirs(out_dir)

    # check all .h files for embedded documentation
    hdrs = []
    for root, dirnames, filenames in os.walk(proj_dir):
        for filename in fnmatch.filter(filenames, '*.h'):
            hdrs.append(os.path.join(root, filename).replace('\\','/'))
    markdeep_files = []
    capture_begin = re.compile(r'/\*#\s')
    for hdr in hdrs:
        log.info('  parsing {}'.format(hdr))
        capturing = False
        markdeep_lines = []
        with open(hdr, 'r') as src:
            lines = src.readlines()
            for line in lines:
                if "#*/" in line and capturing:
                    capturing = False
                if capturing:
                    # remove trailing tab
                    if line.startswith('    '):
                        line = line[4:]
                    elif line.startswith('\t'):
                        line = line[1:]
                    markdeep_lines.append(line)
                if capture_begin.match(line) and not capturing:
                    capturing = True
        if markdeep_lines:
            markdeep_files.append(hdr)
            dst_path = out_dir + '/' + os.path.relpath(hdr,proj_dir) + '.html'
            log.info('    markdeep block(s) found, writing: {}'.format(dst_path))
            dst_dir = os.path.dirname(dst_path)
            if not os.path.isdir(dst_dir):
                os.makedirs(dst_dir)
            with open(dst_path, 'w') as dst:
                dst.write("<meta charset='utf-8' emacsmode='-*- markdown -*-'>\n")
                dst.write("<link rel='stylesheet' href='https://casual-effects.com/markdeep/latest/apidoc.css?'>\n")
                for line in markdeep_lines:
                    dst.write(line)
                dst.write("<script>markdeepOptions={tocStyle:'medium'};</script>")
                dst.write("<!-- Markdeep: --><script src='https://casual-effects.com/markdeep/latest/markdeep.min.js?'></script>")
    
    # write a toplevel index.html
    if markdeep_files:
        markdeep_files = sorted(markdeep_files)
        dst_path = out_dir + '/index.html'
        log.info('writing toc file: {}'.format(dst_path))
        with open(dst_path, 'w') as dst:
            dst.write("<meta charset='utf-8' emacsmode='-*- markdown -*-'>\n")
            dst.write("<link rel='stylesheet' href='https://casual-effects.com/markdeep/latest/apidoc.css?'>\n")
            dst.write('# {}\n'.format(proj_name))
            for hdr in markdeep_files:
                rel_path = os.path.relpath(hdr,proj_dir)
                dst.write('- [{}]({})\n'.format(rel_path, rel_path+'.html'))
            dst.write("<script>markdeepOptions={tocStyle:'medium'};</script>")
            dst.write("<!-- Markdeep: --><script src='https://casual-effects.com/markdeep/latest/markdeep.min.js?'></script>")
    else:
        log.error("no headers with embedded markdeep found in '{}'!".format(proj_dir))